@rxap/service-worker 21.0.1 → 22.0.0-dev.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/CHANGELOG.md +7 -0
- package/compodoc/changelog.html +6 -0
- package/compodoc/dependencies.html +6 -6
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +38 -38
- package/docs/html/classes/AutoUpdateService.html +2 -2
- package/docs/html/classes/CheckForUpdateService.html +2 -2
- package/docs/html/classes/DialogUpdateService.html +2 -2
- package/docs/html/classes/LogUpdateService.html +2 -2
- package/docs/html/classes/ServiceWorkerUpdateDialogComponent.html +2 -2
- package/docs/html/classes/SnackbarUpdateService.html +2 -2
- package/docs/html/functions/ProvideServiceWorkerUpdater.html +1 -1
- package/docs/html/functions/UnregisterServiceWorker.html +1 -1
- package/docs/html/functions/withAutoUpdater.html +1 -1
- package/docs/html/functions/withDialogUpdater.html +1 -1
- package/docs/html/functions/withLogUpdater.html +1 -1
- package/docs/html/functions/withSnackbarUpdater.html +1 -1
- package/docs/html/index.html +2 -2
- package/docs/html/modules.html +1 -1
- package/docs/html/variables/UPDATE_AVAILABLE_EVENT.html +1 -1
- package/docs/markdown/README.md +1 -1
- package/docs/markdown/classes/AutoUpdateService.md +3 -3
- package/docs/markdown/classes/CheckForUpdateService.md +3 -3
- package/docs/markdown/classes/DialogUpdateService.md +3 -3
- package/docs/markdown/classes/LogUpdateService.md +3 -3
- package/docs/markdown/classes/ServiceWorkerUpdateDialogComponent.md +7 -7
- package/docs/markdown/classes/SnackbarUpdateService.md +3 -3
- package/docs/markdown/functions/ProvideServiceWorkerUpdater.md +2 -2
- package/docs/markdown/functions/UnregisterServiceWorker.md +2 -2
- package/docs/markdown/functions/withAutoUpdater.md +2 -2
- package/docs/markdown/functions/withDialogUpdater.md +2 -2
- package/docs/markdown/functions/withLogUpdater.md +2 -2
- package/docs/markdown/functions/withSnackbarUpdater.md +2 -2
- package/docs/markdown/globals.md +2 -2
- package/docs/markdown/variables/UPDATE_AVAILABLE_EVENT.md +2 -2
- package/docs/wiki/Class.AutoUpdateService.md +2 -2
- package/docs/wiki/Class.CheckForUpdateService.md +2 -2
- package/docs/wiki/Class.DialogUpdateService.md +2 -2
- package/docs/wiki/Class.LogUpdateService.md +2 -2
- package/docs/wiki/Class.ServiceWorkerUpdateDialogComponent.md +6 -6
- package/docs/wiki/Class.SnackbarUpdateService.md +2 -2
- package/docs/wiki/Function.ProvideServiceWorkerUpdater.md +1 -1
- package/docs/wiki/Function.UnregisterServiceWorker.md +1 -1
- package/docs/wiki/Function.withAutoUpdater.md +1 -1
- package/docs/wiki/Function.withDialogUpdater.md +1 -1
- package/docs/wiki/Function.withLogUpdater.md +1 -1
- package/docs/wiki/Function.withSnackbarUpdater.md +1 -1
- package/docs/wiki/Variable.UPDATE_AVAILABLE_EVENT.md +1 -1
- package/docs/wiki/globals.md +1 -1
- package/fesm2022/rxap-service-worker.mjs +256 -136
- package/fesm2022/rxap-service-worker.mjs.map +1 -1
- package/package.json +14 -14
- package/types/rxap-service-worker.d.ts +55 -60
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { __decorate, __metadata } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { SwUpdate } from
|
|
5
|
-
import { filter, interval, take
|
|
6
|
-
import {
|
|
7
|
-
import { LifeCycleService } from
|
|
8
|
-
import { outputToObservable } from
|
|
9
|
-
import { MatSnackBar } from
|
|
10
|
-
const UPDATE_AVAILABLE_EVENT = new InjectionToken(
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ApplicationRef, ChangeDetectionStrategy, Component, Injectable, InjectionToken, Injector, afterNextRender, createComponent, inject, output, provideAppInitializer, viewChild } from "@angular/core";
|
|
4
|
+
import { SwUpdate } from "@angular/service-worker";
|
|
5
|
+
import { filter, finalize, interval, take } from "rxjs";
|
|
6
|
+
import { concatMap, startWith, tap } from "rxjs/operators";
|
|
7
|
+
import { LifeCycleService } from "@rxap/life-cycle";
|
|
8
|
+
import { outputToObservable } from "@angular/core/rxjs-interop";
|
|
9
|
+
import { MatSnackBar } from "@angular/material/snack-bar";
|
|
10
|
+
const UPDATE_AVAILABLE_EVENT = new InjectionToken("UPDATE_AVAILABLE_EVENT");
|
|
11
11
|
let ServiceWorkerUpdateDialogComponent = class ServiceWorkerUpdateDialogComponent {
|
|
12
12
|
constructor() {
|
|
13
|
-
this.dialog = viewChild.required(
|
|
13
|
+
this.dialog = viewChild.required("dialog", ...ngDevMode ? [{ debugName: "dialog" }] : /* istanbul ignore next */ []);
|
|
14
14
|
this.closeDialog = output();
|
|
15
15
|
this.updateAvailableEvent = inject(UPDATE_AVAILABLE_EVENT);
|
|
16
16
|
afterNextRender(() => this.dialog().nativeElement.showModal());
|
|
@@ -19,39 +19,108 @@ let ServiceWorkerUpdateDialogComponent = class ServiceWorkerUpdateDialogComponen
|
|
|
19
19
|
this.dialog().nativeElement.close();
|
|
20
20
|
this.closeDialog.emit();
|
|
21
21
|
}
|
|
22
|
-
static {
|
|
23
|
-
|
|
22
|
+
static {
|
|
23
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
24
|
+
minVersion: "12.0.0",
|
|
25
|
+
version: "22.3.0",
|
|
26
|
+
ngImport: i0,
|
|
27
|
+
type: ServiceWorkerUpdateDialogComponent,
|
|
28
|
+
deps: [],
|
|
29
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static {
|
|
33
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
34
|
+
minVersion: "17.0.0",
|
|
35
|
+
version: "22.3.0",
|
|
36
|
+
type: ServiceWorkerUpdateDialogComponent,
|
|
37
|
+
isStandalone: true,
|
|
38
|
+
selector: "rxap-service-worker-update-dialog",
|
|
39
|
+
outputs: { closeDialog: "closeDialog" },
|
|
40
|
+
viewQueries: [{
|
|
41
|
+
propertyName: "dialog",
|
|
42
|
+
first: true,
|
|
43
|
+
predicate: ["dialog"],
|
|
44
|
+
descendants: true,
|
|
45
|
+
isSignal: true
|
|
46
|
+
}],
|
|
47
|
+
ngImport: i0,
|
|
48
|
+
template: "<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl bg-white text-black dark:bg-black dark:text-white flex flex-col gap-3 p-6\">\n <h2 class=\"text-2xl font-bold\" i18n>A new application version is available</h2>\n @switch ($any(updateAvailableEvent).type) {\n @case ('VERSION_DETECTED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_INSTALLATION_FAILED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Version installation error</th>\n <td>{{$any(updateAvailableEvent)['error']}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_READY') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Current version hash</th>\n <td>{{$any(updateAvailableEvent)['currentVersion'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Last version hash</th>\n <td>{{$any(updateAvailableEvent)['latestVersion'].hash}}</td>\n </tr>\n </table>\n }\n @case ('NoNewVersionDetectedEvent') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n }\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>Update</button>\n</dialog>\n",
|
|
49
|
+
styles: [""],
|
|
50
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
51
|
+
});
|
|
52
|
+
}
|
|
24
53
|
};
|
|
25
54
|
ServiceWorkerUpdateDialogComponent = __decorate([
|
|
26
|
-
__metadata("design:paramtypes", [])
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
__metadata("design:paramtypes", [])], ServiceWorkerUpdateDialogComponent);
|
|
56
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
57
|
+
minVersion: "12.0.0",
|
|
58
|
+
version: "22.3.0",
|
|
59
|
+
ngImport: i0,
|
|
60
|
+
type: ServiceWorkerUpdateDialogComponent,
|
|
61
|
+
decorators: [{
|
|
29
62
|
type: Component,
|
|
30
|
-
args: [{
|
|
31
|
-
|
|
32
|
-
|
|
63
|
+
args: [{
|
|
64
|
+
selector: "rxap-service-worker-update-dialog",
|
|
65
|
+
imports: [],
|
|
66
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
67
|
+
template: "<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl bg-white text-black dark:bg-black dark:text-white flex flex-col gap-3 p-6\">\n <h2 class=\"text-2xl font-bold\" i18n>A new application version is available</h2>\n @switch ($any(updateAvailableEvent).type) {\n @case ('VERSION_DETECTED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_INSTALLATION_FAILED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Version installation error</th>\n <td>{{$any(updateAvailableEvent)['error']}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_READY') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Current version hash</th>\n <td>{{$any(updateAvailableEvent)['currentVersion'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Last version hash</th>\n <td>{{$any(updateAvailableEvent)['latestVersion'].hash}}</td>\n </tr>\n </table>\n }\n @case ('NoNewVersionDetectedEvent') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n }\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>Update</button>\n</dialog>\n"
|
|
68
|
+
}]
|
|
69
|
+
}],
|
|
70
|
+
ctorParameters: () => [],
|
|
71
|
+
propDecorators: {
|
|
72
|
+
dialog: [{
|
|
73
|
+
type: i0.ViewChild,
|
|
74
|
+
args: ["dialog", { isSignal: true }]
|
|
75
|
+
}],
|
|
76
|
+
closeDialog: [{
|
|
77
|
+
type: i0.Output,
|
|
78
|
+
args: ["closeDialog"]
|
|
79
|
+
}]
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var AutoUpdateService = class AutoUpdateService {
|
|
33
83
|
constructor() {
|
|
34
84
|
this.updates = inject(SwUpdate);
|
|
35
85
|
}
|
|
36
86
|
start() {
|
|
37
|
-
console.debug(
|
|
38
|
-
this.updates.versionUpdates
|
|
39
|
-
|
|
40
|
-
console.log('auto app update completed. Reload app.');
|
|
87
|
+
console.debug("start auto update service");
|
|
88
|
+
this.updates.versionUpdates.pipe(filter((event) => event.type === "VERSION_READY"), tap(() => console.log("start auto app update")), tap(() => this.updates.activateUpdate().then(() => {
|
|
89
|
+
console.log("auto app update completed. Reload app.");
|
|
41
90
|
document.location.reload();
|
|
42
|
-
})))
|
|
43
|
-
.subscribe();
|
|
91
|
+
}))).subscribe();
|
|
44
92
|
}
|
|
45
|
-
static {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
93
|
+
static {
|
|
94
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
95
|
+
minVersion: "12.0.0",
|
|
96
|
+
version: "22.3.0",
|
|
97
|
+
ngImport: i0,
|
|
98
|
+
type: AutoUpdateService,
|
|
99
|
+
deps: [],
|
|
100
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
static {
|
|
104
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
105
|
+
minVersion: "12.0.0",
|
|
106
|
+
version: "22.3.0",
|
|
107
|
+
ngImport: i0,
|
|
108
|
+
type: AutoUpdateService,
|
|
109
|
+
providedIn: "root"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
114
|
+
minVersion: "12.0.0",
|
|
115
|
+
version: "22.3.0",
|
|
116
|
+
ngImport: i0,
|
|
117
|
+
type: AutoUpdateService,
|
|
118
|
+
decorators: [{
|
|
49
119
|
type: Injectable,
|
|
50
|
-
args: [{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class CheckForUpdateService {
|
|
120
|
+
args: [{ providedIn: "root" }]
|
|
121
|
+
}]
|
|
122
|
+
});
|
|
123
|
+
var CheckForUpdateService = class CheckForUpdateService {
|
|
55
124
|
constructor() {
|
|
56
125
|
this.lifeCycle = inject(LifeCycleService);
|
|
57
126
|
this.updates = inject(SwUpdate);
|
|
@@ -59,181 +128,232 @@ class CheckForUpdateService {
|
|
|
59
128
|
}
|
|
60
129
|
start() {
|
|
61
130
|
if (this._started) {
|
|
62
|
-
console.warn(
|
|
131
|
+
console.warn("check for update already started");
|
|
63
132
|
return;
|
|
64
133
|
}
|
|
65
134
|
this._started = true;
|
|
66
135
|
if (this.updates.isEnabled) {
|
|
67
|
-
console.debug(
|
|
136
|
+
console.debug("start check for update");
|
|
68
137
|
this.updates.checkForUpdate();
|
|
69
|
-
this
|
|
70
|
-
.lifeCycle
|
|
71
|
-
.whenReady(() => interval(15 * 60 * 1000)
|
|
72
|
-
.pipe(startWith(null), tap(() => console.log('check for update')), tap(() => this.updates.checkForUpdate())))
|
|
73
|
-
.subscribe();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
console.warn('service worker updates are not enabled');
|
|
138
|
+
this.lifeCycle.whenReady(() => interval(9e5).pipe(startWith(null), tap(() => console.log("check for update")), tap(() => this.updates.checkForUpdate()))).subscribe();
|
|
77
139
|
}
|
|
140
|
+
else
|
|
141
|
+
console.warn("service worker updates are not enabled");
|
|
78
142
|
}
|
|
79
|
-
static {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
143
|
+
static {
|
|
144
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
145
|
+
minVersion: "12.0.0",
|
|
146
|
+
version: "22.3.0",
|
|
147
|
+
ngImport: i0,
|
|
148
|
+
type: CheckForUpdateService,
|
|
149
|
+
deps: [],
|
|
150
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
static {
|
|
154
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
155
|
+
minVersion: "12.0.0",
|
|
156
|
+
version: "22.3.0",
|
|
157
|
+
ngImport: i0,
|
|
158
|
+
type: CheckForUpdateService,
|
|
159
|
+
providedIn: "root"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
164
|
+
minVersion: "12.0.0",
|
|
165
|
+
version: "22.3.0",
|
|
166
|
+
ngImport: i0,
|
|
167
|
+
type: CheckForUpdateService,
|
|
168
|
+
decorators: [{
|
|
83
169
|
type: Injectable,
|
|
84
|
-
args: [{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class DialogUpdateService {
|
|
170
|
+
args: [{ providedIn: "root" }]
|
|
171
|
+
}]
|
|
172
|
+
});
|
|
173
|
+
var DialogUpdateService = class DialogUpdateService {
|
|
89
174
|
constructor() {
|
|
90
175
|
this.applicationRef = inject(ApplicationRef);
|
|
91
176
|
this.updates = inject(SwUpdate);
|
|
92
177
|
}
|
|
93
178
|
start() {
|
|
94
|
-
console.debug(
|
|
95
|
-
this.updates.versionUpdates
|
|
96
|
-
|
|
97
|
-
console.log('app update completed. Reload app.');
|
|
179
|
+
console.debug("start dialog update service");
|
|
180
|
+
this.updates.versionUpdates.pipe(filter((event) => event.type === "VERSION_READY"), concatMap((event) => this.openUpdateDialog(event)), tap(() => console.log("start app update")), tap(() => this.updates.activateUpdate().then(() => {
|
|
181
|
+
console.log("app update completed. Reload app.");
|
|
98
182
|
document.location.reload();
|
|
99
|
-
})))
|
|
100
|
-
.subscribe();
|
|
183
|
+
}))).subscribe();
|
|
101
184
|
}
|
|
102
185
|
openUpdateDialog(event) {
|
|
103
|
-
console.debug(
|
|
104
|
-
const body = document.getElementsByTagName(
|
|
105
|
-
const div = document.createElement(
|
|
186
|
+
console.debug("open update dialog");
|
|
187
|
+
const body = document.getElementsByTagName("body")[0];
|
|
188
|
+
const div = document.createElement("div");
|
|
106
189
|
body.appendChild(div);
|
|
107
190
|
const componentRef = createComponent(ServiceWorkerUpdateDialogComponent, {
|
|
108
191
|
hostElement: div,
|
|
109
192
|
environmentInjector: this.applicationRef.injector,
|
|
110
|
-
elementInjector: Injector.create({
|
|
111
|
-
providers: [
|
|
112
|
-
{
|
|
193
|
+
elementInjector: Injector.create({ providers: [{
|
|
113
194
|
provide: UPDATE_AVAILABLE_EVENT,
|
|
114
|
-
useValue: event
|
|
115
|
-
}
|
|
116
|
-
],
|
|
117
|
-
}),
|
|
195
|
+
useValue: event
|
|
196
|
+
}] })
|
|
118
197
|
});
|
|
119
198
|
this.applicationRef.attachView(componentRef.hostView);
|
|
120
|
-
// The cleanup must run after the close event has been forwarded. Destroying the component
|
|
121
|
-
// inside a tap completes the output observable before the value reaches the subscriber,
|
|
122
|
-
// so the update would never be activated.
|
|
123
199
|
return outputToObservable(componentRef.instance.closeDialog).pipe(take(1), finalize(() => {
|
|
124
200
|
componentRef.destroy();
|
|
125
201
|
body.removeChild(div);
|
|
126
202
|
div.remove();
|
|
127
203
|
}));
|
|
128
204
|
}
|
|
129
|
-
static {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
205
|
+
static {
|
|
206
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
207
|
+
minVersion: "12.0.0",
|
|
208
|
+
version: "22.3.0",
|
|
209
|
+
ngImport: i0,
|
|
210
|
+
type: DialogUpdateService,
|
|
211
|
+
deps: [],
|
|
212
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
static {
|
|
216
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
217
|
+
minVersion: "12.0.0",
|
|
218
|
+
version: "22.3.0",
|
|
219
|
+
ngImport: i0,
|
|
220
|
+
type: DialogUpdateService,
|
|
221
|
+
providedIn: "root"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
226
|
+
minVersion: "12.0.0",
|
|
227
|
+
version: "22.3.0",
|
|
228
|
+
ngImport: i0,
|
|
229
|
+
type: DialogUpdateService,
|
|
230
|
+
decorators: [{
|
|
133
231
|
type: Injectable,
|
|
134
|
-
args: [{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
class LogUpdateService {
|
|
232
|
+
args: [{ providedIn: "root" }]
|
|
233
|
+
}]
|
|
234
|
+
});
|
|
235
|
+
var LogUpdateService = class LogUpdateService {
|
|
139
236
|
constructor() {
|
|
140
237
|
this.updates = inject(SwUpdate);
|
|
141
238
|
}
|
|
142
239
|
start() {
|
|
143
|
-
console.debug(
|
|
144
|
-
this.updates.versionUpdates.pipe(filter(event => event.type !==
|
|
145
|
-
console.log(
|
|
240
|
+
console.debug("start log update");
|
|
241
|
+
this.updates.versionUpdates.pipe(filter((event) => event.type !== "NO_NEW_VERSION_DETECTED")).subscribe((event) => {
|
|
242
|
+
console.log("version update event", event);
|
|
146
243
|
});
|
|
147
244
|
}
|
|
148
|
-
static {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
245
|
+
static {
|
|
246
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
247
|
+
minVersion: "12.0.0",
|
|
248
|
+
version: "22.3.0",
|
|
249
|
+
ngImport: i0,
|
|
250
|
+
type: LogUpdateService,
|
|
251
|
+
deps: [],
|
|
252
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
static {
|
|
256
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
257
|
+
minVersion: "12.0.0",
|
|
258
|
+
version: "22.3.0",
|
|
259
|
+
ngImport: i0,
|
|
260
|
+
type: LogUpdateService,
|
|
261
|
+
providedIn: "root"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
266
|
+
minVersion: "12.0.0",
|
|
267
|
+
version: "22.3.0",
|
|
268
|
+
ngImport: i0,
|
|
269
|
+
type: LogUpdateService,
|
|
270
|
+
decorators: [{
|
|
152
271
|
type: Injectable,
|
|
153
|
-
args: [{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
class SnackbarUpdateService {
|
|
272
|
+
args: [{ providedIn: "root" }]
|
|
273
|
+
}]
|
|
274
|
+
});
|
|
275
|
+
var SnackbarUpdateService = class SnackbarUpdateService {
|
|
158
276
|
constructor() {
|
|
159
277
|
this.snackBar = inject(MatSnackBar);
|
|
160
278
|
this.updates = inject(SwUpdate);
|
|
161
279
|
}
|
|
162
280
|
start() {
|
|
163
|
-
console.debug(
|
|
164
|
-
this.updates.versionUpdates
|
|
165
|
-
|
|
166
|
-
console.log('app update completed. Reload app.');
|
|
281
|
+
console.debug("start dialog update service");
|
|
282
|
+
this.updates.versionUpdates.pipe(filter((event) => event.type === "VERSION_READY"), concatMap((event) => this.openUpdateSnackBar(event)), tap(() => console.log("start app update")), tap(() => this.updates.activateUpdate().then(() => {
|
|
283
|
+
console.log("app update completed. Reload app.");
|
|
167
284
|
document.location.reload();
|
|
168
|
-
})))
|
|
169
|
-
.subscribe();
|
|
285
|
+
}))).subscribe();
|
|
170
286
|
}
|
|
171
287
|
openUpdateSnackBar(event) {
|
|
172
|
-
console.debug(
|
|
173
|
-
|
|
174
|
-
return ref.afterDismissed().pipe(take(1));
|
|
288
|
+
console.debug("open update snack bar");
|
|
289
|
+
return this.snackBar.open($localize `A new version is available`, $localize `Update`).afterDismissed().pipe(take(1));
|
|
175
290
|
}
|
|
176
|
-
static {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
291
|
+
static {
|
|
292
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
293
|
+
minVersion: "12.0.0",
|
|
294
|
+
version: "22.3.0",
|
|
295
|
+
ngImport: i0,
|
|
296
|
+
type: SnackbarUpdateService,
|
|
297
|
+
deps: [],
|
|
298
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
static {
|
|
302
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
303
|
+
minVersion: "12.0.0",
|
|
304
|
+
version: "22.3.0",
|
|
305
|
+
ngImport: i0,
|
|
306
|
+
type: SnackbarUpdateService,
|
|
307
|
+
providedIn: "root"
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
312
|
+
minVersion: "12.0.0",
|
|
313
|
+
version: "22.3.0",
|
|
314
|
+
ngImport: i0,
|
|
315
|
+
type: SnackbarUpdateService,
|
|
316
|
+
decorators: [{
|
|
180
317
|
type: Injectable,
|
|
181
|
-
args: [{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}] });
|
|
318
|
+
args: [{ providedIn: "root" }]
|
|
319
|
+
}]
|
|
320
|
+
});
|
|
185
321
|
function ProvideServiceWorkerUpdater(...providers) {
|
|
186
|
-
return [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return initializerFn();
|
|
190
|
-
}),
|
|
191
|
-
...providers,
|
|
192
|
-
];
|
|
322
|
+
return [provideAppInitializer(() => {
|
|
323
|
+
return ((checkForUpdate) => () => checkForUpdate.start())(inject(CheckForUpdateService))();
|
|
324
|
+
}), ...providers];
|
|
193
325
|
}
|
|
194
326
|
function withLogUpdater() {
|
|
195
327
|
return provideAppInitializer(() => {
|
|
196
|
-
|
|
197
|
-
return initializerFn();
|
|
328
|
+
return ((logUpdateService) => () => logUpdateService.start())(inject(LogUpdateService))();
|
|
198
329
|
});
|
|
199
330
|
}
|
|
200
331
|
function withDialogUpdater() {
|
|
201
332
|
return provideAppInitializer(() => {
|
|
202
|
-
|
|
203
|
-
return initializerFn();
|
|
333
|
+
return ((dus) => () => dus.start())(inject(DialogUpdateService))();
|
|
204
334
|
});
|
|
205
335
|
}
|
|
206
336
|
function withAutoUpdater() {
|
|
207
337
|
return provideAppInitializer(() => {
|
|
208
|
-
|
|
209
|
-
return initializerFn();
|
|
338
|
+
return ((aus) => () => aus.start())(inject(AutoUpdateService))();
|
|
210
339
|
});
|
|
211
340
|
}
|
|
212
341
|
function withSnackbarUpdater() {
|
|
213
342
|
return provideAppInitializer(() => {
|
|
214
|
-
|
|
215
|
-
return initializerFn();
|
|
343
|
+
return ((snackbarUpdateService) => () => snackbarUpdateService.start())(inject(SnackbarUpdateService))();
|
|
216
344
|
});
|
|
217
345
|
}
|
|
218
346
|
function UnregisterServiceWorker(environment) {
|
|
219
|
-
if (!environment.serviceWorker)
|
|
347
|
+
if (!environment.serviceWorker)
|
|
220
348
|
navigator?.serviceWorker?.getRegistrations().then(async (registrations) => {
|
|
221
349
|
await Promise.all(registrations.map((registration) => {
|
|
222
|
-
console.log(
|
|
350
|
+
console.log("unregister service worker: " + registration.scope);
|
|
223
351
|
return registration.unregister();
|
|
224
352
|
}));
|
|
225
353
|
if (registrations.length) {
|
|
226
|
-
|
|
227
|
-
if (response) {
|
|
354
|
+
if (confirm("All dangling service worker are unregistered. Should the application be reloaded to complete the migration"))
|
|
228
355
|
location.reload();
|
|
229
|
-
}
|
|
230
356
|
}
|
|
231
357
|
});
|
|
232
|
-
}
|
|
233
358
|
}
|
|
234
|
-
// region service-worker-update-dialog
|
|
235
|
-
// endregion
|
|
236
|
-
/**
|
|
237
|
-
* Generated bundle index. Do not edit.
|
|
238
|
-
*/
|
|
239
359
|
export { AutoUpdateService, CheckForUpdateService, DialogUpdateService, LogUpdateService, ProvideServiceWorkerUpdater, ServiceWorkerUpdateDialogComponent, SnackbarUpdateService, UPDATE_AVAILABLE_EVENT, UnregisterServiceWorker, withAutoUpdater, withDialogUpdater, withLogUpdater, withSnackbarUpdater };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-service-worker.mjs","sources":["../../../../../packages/angular/service-worker/src/lib/service-worker-update-dialog/service-worker-update-dialog.component.ts","../../../../../packages/angular/service-worker/src/lib/service-worker-update-dialog/service-worker-update-dialog.component.html","../../../../../packages/angular/service-worker/src/lib/auto-update.service.ts","../../../../../packages/angular/service-worker/src/lib/check-for-update.service.ts","../../../../../packages/angular/service-worker/src/lib/dialog-update.service.ts","../../../../../packages/angular/service-worker/src/lib/log-update.service.ts","../../../../../packages/angular/service-worker/src/lib/snackbar-update.service.ts","../../../../../packages/angular/service-worker/src/lib/provide-service-worker-updater.ts","../../../../../packages/angular/service-worker/src/lib/unregister-service-worker.ts","../../../../../packages/angular/service-worker/src/index.ts","../../../../../packages/angular/service-worker/src/rxap-service-worker.ts"],"sourcesContent":["\nimport {\n afterNextRender,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n inject,\n InjectionToken,\n output,\n viewChild\n} from '@angular/core';\nimport { VersionEvent } from '@angular/service-worker';\nimport { Showcase } from '@ng-prism/core';\n\nexport const UPDATE_AVAILABLE_EVENT = new InjectionToken<VersionEvent>('UPDATE_AVAILABLE_EVENT');\n\n@Showcase({\n title: 'Service Worker Update Dialog',\n category: 'Service Worker',\n description: 'Modal dialog that informs the user about an available app update. The `UPDATE_AVAILABLE_EVENT` is provided by the styleguide host.',\n status: 'stable',\n variants: [\n { name: 'Default' },\n ],\n})\n@Component({\n selector: 'rxap-service-worker-update-dialog',\n imports: [],\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './service-worker-update-dialog.component.html',\n styleUrls: ['./service-worker-update-dialog.component.scss']\n})\nexport class ServiceWorkerUpdateDialogComponent {\n\n public readonly dialog = viewChild.required<ElementRef<HTMLDialogElement>>('dialog');\n\n public readonly closeDialog = output<void>();\n\n public readonly updateAvailableEvent = inject(UPDATE_AVAILABLE_EVENT);\n\n constructor() {\n afterNextRender(() => this.dialog().nativeElement.showModal());\n }\n\n close() {\n this.dialog().nativeElement.close();\n this.closeDialog.emit();\n }\n\n}\n","<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl bg-white text-black dark:bg-black dark:text-white flex flex-col gap-3 p-6\">\n <h2 class=\"text-2xl font-bold\" i18n>A new application version is available</h2>\n @switch ($any(updateAvailableEvent).type) {\n @case ('VERSION_DETECTED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_INSTALLATION_FAILED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Version installation error</th>\n <td>{{$any(updateAvailableEvent)['error']}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_READY') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Current version hash</th>\n <td>{{$any(updateAvailableEvent)['currentVersion'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Last version hash</th>\n <td>{{$any(updateAvailableEvent)['latestVersion'].hash}}</td>\n </tr>\n </table>\n }\n @case ('NoNewVersionDetectedEvent') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n }\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>Update</button>\n</dialog>\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { filter } from 'rxjs';\nimport { tap } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AutoUpdateService {\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n public start(): void {\n console.debug('start auto update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n tap(() => console.log('start auto app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('auto app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n}\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { LifeCycleService } from '@rxap/life-cycle';\nimport { interval } from 'rxjs';\nimport {\n startWith,\n tap,\n} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class CheckForUpdateService {\n private readonly lifeCycle = inject<LifeCycleService>(LifeCycleService);\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n private _started = false;\n\n public start(): void {\n if (this._started) {\n console.warn('check for update already started');\n return;\n }\n this._started = true;\n if (this.updates.isEnabled) {\n\n console.debug('start check for update');\n\n this.updates.checkForUpdate();\n\n this\n .lifeCycle\n .whenReady(() => interval(15 * 60 * 1000)\n .pipe(\n startWith(null),\n tap(() => console.log('check for update')),\n tap(() => this.updates.checkForUpdate()),\n ),\n )\n .subscribe();\n\n } else {\n console.warn('service worker updates are not enabled');\n }\n }\n\n}\n","import { ApplicationRef, createComponent, Injectable, Injector, inject } from '@angular/core';\nimport { outputToObservable } from '@angular/core/rxjs-interop';\nimport {\n SwUpdate,\n VersionEvent,\n} from '@angular/service-worker';\nimport {\n filter,\n finalize,\n Observable,\n take,\n} from 'rxjs';\nimport {\n concatMap,\n tap,\n} from 'rxjs/operators';\nimport {\n ServiceWorkerUpdateDialogComponent,\n UPDATE_AVAILABLE_EVENT,\n} from './service-worker-update-dialog/service-worker-update-dialog.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DialogUpdateService {\n private readonly applicationRef = inject<ApplicationRef>(ApplicationRef);\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n public start(): void {\n console.debug('start dialog update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n concatMap((event) => this.openUpdateDialog(event)),\n tap(() => console.log('start app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n private openUpdateDialog(event: VersionEvent): Observable<void> {\n console.debug('open update dialog');\n const body = document.getElementsByTagName('body')[0];\n const div = document.createElement('div');\n body.appendChild(div);\n const componentRef = createComponent(ServiceWorkerUpdateDialogComponent, {\n hostElement: div,\n environmentInjector: this.applicationRef.injector,\n elementInjector: Injector.create({\n providers: [\n {\n provide: UPDATE_AVAILABLE_EVENT,\n useValue: event,\n },\n ],\n }),\n });\n this.applicationRef.attachView(componentRef.hostView);\n\n // The cleanup must run after the close event has been forwarded. Destroying the component\n // inside a tap completes the output observable before the value reaches the subscriber,\n // so the update would never be activated.\n return outputToObservable(componentRef.instance.closeDialog).pipe(\n take(1),\n finalize(() => {\n componentRef.destroy();\n body.removeChild(div);\n div.remove();\n }),\n );\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { filter } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LogUpdateService {\n private readonly updates = inject(SwUpdate);\n\n\n public start() {\n console.debug('start log update');\n this.updates.versionUpdates.pipe(\n filter(event => event.type !== 'NO_NEW_VERSION_DETECTED'),\n ).subscribe(event => {\n console.log('version update event', event);\n });\n }\n\n}\n\n","import {\n inject,\n Injectable,\n} from '@angular/core';\nimport { MatSnackBar } from '@angular/material/snack-bar';\nimport {\n SwUpdate,\n VersionEvent,\n} from '@angular/service-worker';\nimport {\n filter,\n Observable,\n take,\n} from 'rxjs';\nimport {\n concatMap,\n tap,\n} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SnackbarUpdateService {\n private readonly snackBar = inject(MatSnackBar);\n private readonly updates = inject(SwUpdate);\n\n public start(): void {\n console.debug('start dialog update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n concatMap((event) => this.openUpdateSnackBar(event)),\n tap(() => console.log('start app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n private openUpdateSnackBar(event: VersionEvent): Observable<any> {\n console.debug('open update snack bar');\n const ref = this.snackBar.open($localize`A new version is available`, $localize`Update`);\n return ref.afterDismissed().pipe(\n take(1),\n );\n }\n}\n","import {\n Provider,\n inject,\n provideAppInitializer,\n EnvironmentProviders,\n} from '@angular/core';\nimport { AutoUpdateService } from './auto-update.service';\nimport { CheckForUpdateService } from './check-for-update.service';\nimport { DialogUpdateService } from './dialog-update.service';\nimport { LogUpdateService } from './log-update.service';\nimport { SnackbarUpdateService } from './snackbar-update.service';\n\nexport function ProvideServiceWorkerUpdater(...providers: Array<Provider | EnvironmentProviders>): Array<Provider | EnvironmentProviders> {\n return [\n provideAppInitializer(() => {\n const initializerFn = ((checkForUpdate: CheckForUpdateService) => () => checkForUpdate.start())(inject(CheckForUpdateService));\n return initializerFn();\n }),\n ...providers,\n ];\n}\n\nexport function withLogUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((logUpdateService: LogUpdateService) => () => logUpdateService.start())(inject(LogUpdateService));\n return initializerFn();\n });\n}\n\nexport function withDialogUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((dus: DialogUpdateService) => () => dus.start())(inject(DialogUpdateService));\n return initializerFn();\n });\n}\n\nexport function withAutoUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((aus: AutoUpdateService) => () => aus.start())(inject(AutoUpdateService));\n return initializerFn();\n });\n}\n\nexport function withSnackbarUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((snackbarUpdateService: SnackbarUpdateService) => () => snackbarUpdateService.start())(inject(SnackbarUpdateService));\n return initializerFn();\n });\n}\n","import { Environment } from '@rxap/environment';\n\nexport function UnregisterServiceWorker(environment: Environment) {\n if (!environment.serviceWorker) {\n navigator?.serviceWorker?.getRegistrations().then(async (registrations) => {\n await Promise.all(registrations.map((registration) => {\n console.log('unregister service worker: ' + registration.scope);\n return registration.unregister();\n }));\n if (registrations.length) {\n const response = confirm(\n 'All dangling service worker are unregistered. Should the application be reloaded to complete the migration');\n if (response) {\n location.reload();\n }\n }\n });\n }\n}\n","// region service-worker-update-dialog\nexport * from './lib/service-worker-update-dialog/service-worker-update-dialog.component';\n// endregion\n\n// region \nexport * from './lib/auto-update.service';\nexport * from './lib/check-for-update.service';\nexport * from './lib/dialog-update.service';\nexport * from './lib/log-update.service';\nexport * from './lib/provide-service-worker-updater';\nexport * from './lib/snackbar-update.service';\nexport * from './lib/unregister-service-worker';\n// endregion\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAca,sBAAsB,GAAG,IAAI,cAAc,CAAe,wBAAwB;AAkBxF,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC,CAAA;AAQ7C,IAAA,WAAA,GAAA;AANgB,QAAA,IAAA,CAAA,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAgC,QAAQ,CAAC;QAEpE,IAAA,CAAA,WAAW,GAAG,MAAM,EAAQ;AAE5B,QAAA,IAAA,CAAA,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC;AAGnE,QAAA,eAAe,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;IAChE;IAEA,KAAK,GAAA;QACH,IAAI,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE;AACnC,QAAA,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;IACzB;8GAfW,kCAAkC,EAAA,IAAA,EAAA,EAAA,EAA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names":[],"sources":["../../../../../packages/angular/service-worker/src/lib/service-worker-update-dialog/service-worker-update-dialog.component.ts","../../../../../packages/angular/service-worker/src/lib/service-worker-update-dialog/service-worker-update-dialog.component.html","../../../../../packages/angular/service-worker/src/lib/auto-update.service.ts","../../../../../packages/angular/service-worker/src/lib/check-for-update.service.ts","../../../../../packages/angular/service-worker/src/lib/dialog-update.service.ts","../../../../../packages/angular/service-worker/src/lib/log-update.service.ts","../../../../../packages/angular/service-worker/src/lib/snackbar-update.service.ts","../../../../../packages/angular/service-worker/src/lib/provide-service-worker-updater.ts","../../../../../packages/angular/service-worker/src/lib/unregister-service-worker.ts"],"sourcesContent":["\nimport {\n afterNextRender,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n inject,\n InjectionToken,\n output,\n viewChild\n} from '@angular/core';\nimport { VersionEvent } from '@angular/service-worker';\nimport { Showcase } from '@ng-prism/core';\n\nexport const UPDATE_AVAILABLE_EVENT = new InjectionToken<VersionEvent>('UPDATE_AVAILABLE_EVENT');\n\n@Showcase({\n title: 'Service Worker Update Dialog',\n category: 'Service Worker',\n description: 'Modal dialog that informs the user about an available app update. The `UPDATE_AVAILABLE_EVENT` is provided by the styleguide host.',\n status: 'stable',\n variants: [\n { name: 'Default' },\n ],\n})\n@Component({\n selector: 'rxap-service-worker-update-dialog',\n imports: [],\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './service-worker-update-dialog.component.html',\n styleUrls: ['./service-worker-update-dialog.component.scss']\n})\nexport class ServiceWorkerUpdateDialogComponent {\n\n public readonly dialog = viewChild.required<ElementRef<HTMLDialogElement>>('dialog');\n\n public readonly closeDialog = output<void>();\n\n public readonly updateAvailableEvent = inject(UPDATE_AVAILABLE_EVENT);\n\n constructor() {\n afterNextRender(() => this.dialog().nativeElement.showModal());\n }\n\n close() {\n this.dialog().nativeElement.close();\n this.closeDialog.emit();\n }\n\n}\n","<dialog #dialog\n class=\"max-w-6xl rounded overflow-auto drop-shadow-2xl bg-white text-black dark:bg-black dark:text-white flex flex-col gap-3 p-6\">\n <h2 class=\"text-2xl font-bold\" i18n>A new application version is available</h2>\n @switch ($any(updateAvailableEvent).type) {\n @case ('VERSION_DETECTED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_INSTALLATION_FAILED') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Version installation error</th>\n <td>{{$any(updateAvailableEvent)['error']}}</td>\n </tr>\n </table>\n }\n @case ('VERSION_READY') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Current version hash</th>\n <td>{{$any(updateAvailableEvent)['currentVersion'].hash}}</td>\n </tr>\n <tr>\n <th i18n>Last version hash</th>\n <td>{{$any(updateAvailableEvent)['latestVersion'].hash}}</td>\n </tr>\n </table>\n }\n @case ('NoNewVersionDetectedEvent') {\n <table class=\"table-auto\">\n <tr>\n <th i18n>Version hash</th>\n <td>{{$any(updateAvailableEvent)['version'].hash}}</td>\n </tr>\n </table>\n }\n }\n <button (click)=\"close()\" class=\"px-4 py-2 rounded bg-primary-500\" i18n>Update</button>\n</dialog>\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { filter } from 'rxjs';\nimport { tap } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AutoUpdateService {\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n public start(): void {\n console.debug('start auto update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n tap(() => console.log('start auto app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('auto app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n}\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { LifeCycleService } from '@rxap/life-cycle';\nimport { interval } from 'rxjs';\nimport {\n startWith,\n tap,\n} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class CheckForUpdateService {\n private readonly lifeCycle = inject<LifeCycleService>(LifeCycleService);\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n private _started = false;\n\n public start(): void {\n if (this._started) {\n console.warn('check for update already started');\n return;\n }\n this._started = true;\n if (this.updates.isEnabled) {\n\n console.debug('start check for update');\n\n this.updates.checkForUpdate();\n\n this\n .lifeCycle\n .whenReady(() => interval(15 * 60 * 1000)\n .pipe(\n startWith(null),\n tap(() => console.log('check for update')),\n tap(() => this.updates.checkForUpdate()),\n ),\n )\n .subscribe();\n\n } else {\n console.warn('service worker updates are not enabled');\n }\n }\n\n}\n","import { ApplicationRef, createComponent, Injectable, Injector, inject } from '@angular/core';\nimport { outputToObservable } from '@angular/core/rxjs-interop';\nimport {\n SwUpdate,\n VersionEvent,\n} from '@angular/service-worker';\nimport {\n filter,\n finalize,\n Observable,\n take,\n} from 'rxjs';\nimport {\n concatMap,\n tap,\n} from 'rxjs/operators';\nimport {\n ServiceWorkerUpdateDialogComponent,\n UPDATE_AVAILABLE_EVENT,\n} from './service-worker-update-dialog/service-worker-update-dialog.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DialogUpdateService {\n private readonly applicationRef = inject<ApplicationRef>(ApplicationRef);\n private readonly updates = inject<SwUpdate>(SwUpdate);\n\n\n public start(): void {\n console.debug('start dialog update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n concatMap((event) => this.openUpdateDialog(event)),\n tap(() => console.log('start app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n private openUpdateDialog(event: VersionEvent): Observable<void> {\n console.debug('open update dialog');\n const body = document.getElementsByTagName('body')[0];\n const div = document.createElement('div');\n body.appendChild(div);\n const componentRef = createComponent(ServiceWorkerUpdateDialogComponent, {\n hostElement: div,\n environmentInjector: this.applicationRef.injector,\n elementInjector: Injector.create({\n providers: [\n {\n provide: UPDATE_AVAILABLE_EVENT,\n useValue: event,\n },\n ],\n }),\n });\n this.applicationRef.attachView(componentRef.hostView);\n\n // The cleanup must run after the close event has been forwarded. Destroying the component\n // inside a tap completes the output observable before the value reaches the subscriber,\n // so the update would never be activated.\n return outputToObservable(componentRef.instance.closeDialog).pipe(\n take(1),\n finalize(() => {\n componentRef.destroy();\n body.removeChild(div);\n div.remove();\n }),\n );\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { SwUpdate } from '@angular/service-worker';\nimport { filter } from 'rxjs';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class LogUpdateService {\n private readonly updates = inject(SwUpdate);\n\n\n public start() {\n console.debug('start log update');\n this.updates.versionUpdates.pipe(\n filter(event => event.type !== 'NO_NEW_VERSION_DETECTED'),\n ).subscribe(event => {\n console.log('version update event', event);\n });\n }\n\n}\n\n","import {\n inject,\n Injectable,\n} from '@angular/core';\nimport { MatSnackBar } from '@angular/material/snack-bar';\nimport {\n SwUpdate,\n VersionEvent,\n} from '@angular/service-worker';\nimport {\n filter,\n Observable,\n take,\n} from 'rxjs';\nimport {\n concatMap,\n tap,\n} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SnackbarUpdateService {\n private readonly snackBar = inject(MatSnackBar);\n private readonly updates = inject(SwUpdate);\n\n public start(): void {\n console.debug('start dialog update service');\n this.updates.versionUpdates\n .pipe(\n filter(event => event.type === 'VERSION_READY'),\n concatMap((event) => this.openUpdateSnackBar(event)),\n tap(() => console.log('start app update')),\n tap(() =>\n this.updates.activateUpdate().then(() => {\n console.log('app update completed. Reload app.');\n document.location.reload();\n }),\n ),\n )\n .subscribe();\n }\n\n private openUpdateSnackBar(event: VersionEvent): Observable<any> {\n console.debug('open update snack bar');\n const ref = this.snackBar.open($localize`A new version is available`, $localize`Update`);\n return ref.afterDismissed().pipe(\n take(1),\n );\n }\n}\n","import {\n Provider,\n inject,\n provideAppInitializer,\n EnvironmentProviders,\n} from '@angular/core';\nimport { AutoUpdateService } from './auto-update.service';\nimport { CheckForUpdateService } from './check-for-update.service';\nimport { DialogUpdateService } from './dialog-update.service';\nimport { LogUpdateService } from './log-update.service';\nimport { SnackbarUpdateService } from './snackbar-update.service';\n\nexport function ProvideServiceWorkerUpdater(...providers: Array<Provider | EnvironmentProviders>): Array<Provider | EnvironmentProviders> {\n return [\n provideAppInitializer(() => {\n const initializerFn = ((checkForUpdate: CheckForUpdateService) => () => checkForUpdate.start())(inject(CheckForUpdateService));\n return initializerFn();\n }),\n ...providers,\n ];\n}\n\nexport function withLogUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((logUpdateService: LogUpdateService) => () => logUpdateService.start())(inject(LogUpdateService));\n return initializerFn();\n });\n}\n\nexport function withDialogUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((dus: DialogUpdateService) => () => dus.start())(inject(DialogUpdateService));\n return initializerFn();\n });\n}\n\nexport function withAutoUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((aus: AutoUpdateService) => () => aus.start())(inject(AutoUpdateService));\n return initializerFn();\n });\n}\n\nexport function withSnackbarUpdater() {\n return provideAppInitializer(() => {\n const initializerFn = ((snackbarUpdateService: SnackbarUpdateService) => () => snackbarUpdateService.start())(inject(SnackbarUpdateService));\n return initializerFn();\n });\n}\n","import { Environment } from '@rxap/environment';\n\nexport function UnregisterServiceWorker(environment: Environment) {\n if (!environment.serviceWorker) {\n navigator?.serviceWorker?.getRegistrations().then(async (registrations) => {\n await Promise.all(registrations.map((registration) => {\n console.log('unregister service worker: ' + registration.scope);\n return registration.unregister();\n }));\n if (registrations.length) {\n const response = confirm(\n 'All dangling service worker are unregistered. Should the application be reloaded to complete the migration');\n if (response) {\n location.reload();\n }\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,MAA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