UNPKG

9.04 kBJavaScriptView Raw
1/**
2 * @license Angular v10.2.3
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@angular/service-worker",["exports","@angular/common","@angular/core","rxjs","rxjs/operators"],r):r(((e=e||self).ng=e.ng||{},e.ng.serviceWorker={}),e.ng.common,e.ng.core,e.rxjs,e.rxjs.operators)}(this,(function(e,r,t,n,i){"use strict";
7/*! *****************************************************************************
8 Copyright (c) Microsoft Corporation.
9
10 Permission to use, copy, modify, and/or distribute this software for any
11 purpose with or without fee is hereby granted.
12
13 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
20 ***************************************************************************** */
21/**
22 * @license
23 * Copyright Google LLC All Rights Reserved.
24 *
25 * Use of this source code is governed by an MIT-style license that can be
26 * found in the LICENSE file at https://angular.io/license
27 */
28var o="Service workers are disabled or not supported by this browser",s=function(){function e(e){if(this.serviceWorker=e,e){var r=n.fromEvent(e,"controllerchange").pipe(i.map((function(){return e.controller}))),t=n.defer((function(){return n.of(e.controller)})),s=n.concat(t,r);this.worker=s.pipe(i.filter((function(e){return!!e}))),this.registration=this.worker.pipe(i.switchMap((function(){return e.getRegistration()})));var a=n.fromEvent(e,"message").pipe(i.map((function(e){return e.data}))).pipe(i.filter((function(e){return e&&e.type}))).pipe(i.publish());a.connect(),this.events=a}else this.worker=this.events=this.registration=function u(e){return n.defer((function(){return n.throwError(new Error(e))}))}(o)}return e.prototype.postMessage=function(e,r){return this.worker.pipe(i.take(1),i.tap((function(t){t.postMessage(Object.assign({action:e},r))}))).toPromise().then((function(){}))},e.prototype.postMessageWithStatus=function(e,r,t){var n=this.waitForStatus(t),i=this.postMessage(e,r);return Promise.all([n,i]).then((function(){}))},e.prototype.generateNonce=function(){return Math.round(1e7*Math.random())},e.prototype.eventsOfType=function(e){return this.events.pipe(i.filter((function(r){return r.type===e})))},e.prototype.nextEventOfType=function(e){return this.eventsOfType(e).pipe(i.take(1))},e.prototype.waitForStatus=function(e){return this.eventsOfType("STATUS").pipe(i.filter((function(r){return r.nonce===e})),i.take(1),i.map((function(e){if(!e.status)throw new Error(e.error)}))).toPromise()},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return!!this.serviceWorker},enumerable:!1,configurable:!0}),e}(),a=function(){function e(e){if(this.sw=e,this.subscriptionChanges=new n.Subject,!e.isEnabled)return this.messages=n.NEVER,this.notificationClicks=n.NEVER,void(this.subscription=n.NEVER);this.messages=this.sw.eventsOfType("PUSH").pipe(i.map((function(e){return e.data}))),this.notificationClicks=this.sw.eventsOfType("NOTIFICATION_CLICK").pipe(i.map((function(e){return e.data}))),this.pushManager=this.sw.registration.pipe(i.map((function(e){return e.pushManager})));var r=this.pushManager.pipe(i.switchMap((function(e){return e.getSubscription()})));this.subscription=n.merge(r,this.subscriptionChanges)}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.sw.isEnabled},enumerable:!1,configurable:!0}),e.prototype.requestSubscription=function(e){var r=this;if(!this.sw.isEnabled)return Promise.reject(new Error(o));for(var t={userVisibleOnly:!0},n=this.decodeBase64(e.serverPublicKey.replace(/_/g,"/").replace(/-/g,"+")),s=new Uint8Array(new ArrayBuffer(n.length)),a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return t.applicationServerKey=s,this.pushManager.pipe(i.switchMap((function(e){return e.subscribe(t)})),i.take(1)).toPromise().then((function(e){return r.subscriptionChanges.next(e),e}))},e.prototype.unsubscribe=function(){var e=this;return this.sw.isEnabled?this.subscription.pipe(i.take(1),i.switchMap((function(r){if(null===r)throw new Error("Not subscribed to push notifications.");return r.unsubscribe().then((function(r){if(!r)throw new Error("Unsubscribe failed!");e.subscriptionChanges.next(null)}))}))).toPromise():Promise.reject(new Error(o))},e.prototype.decodeBase64=function(e){return atob(e)},e}();a.decorators=[{type:t.Injectable}],a.ctorParameters=function(){return[{type:s}]};
29/**
30 * @license
31 * Copyright Google LLC All Rights Reserved.
32 *
33 * Use of this source code is governed by an MIT-style license that can be
34 * found in the LICENSE file at https://angular.io/license
35 */
36var u=function(){function e(e){if(this.sw=e,!e.isEnabled)return this.available=n.NEVER,void(this.activated=n.NEVER);this.available=this.sw.eventsOfType("UPDATE_AVAILABLE"),this.activated=this.sw.eventsOfType("UPDATE_ACTIVATED")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this.sw.isEnabled},enumerable:!1,configurable:!0}),e.prototype.checkForUpdate=function(){if(!this.sw.isEnabled)return Promise.reject(new Error(o));var e=this.sw.generateNonce();return this.sw.postMessageWithStatus("CHECK_FOR_UPDATES",{statusNonce:e},e)},e.prototype.activateUpdate=function(){if(!this.sw.isEnabled)return Promise.reject(new Error(o));var e=this.sw.generateNonce();return this.sw.postMessageWithStatus("ACTIVATE_UPDATE",{statusNonce:e},e)},e}();u.decorators=[{type:t.Injectable}],u.ctorParameters=function(){return[{type:s}]};var c=function c(){},p=new t.InjectionToken("NGSW_REGISTER_SCRIPT");function f(e,o,s,a){return function(){if(r.isPlatformBrowser(a)&&"serviceWorker"in navigator&&!1!==s.enabled){var u;if(navigator.serviceWorker.addEventListener("controllerchange",(function(){null!==navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({action:"INITIALIZE"})})),"function"==typeof s.registrationStrategy)u=s.registrationStrategy();else{var c=function p(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,i,o=t.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(i)throw i.error}}return s}((s.registrationStrategy||"registerWhenStable:30000").split(":")),f=c[0],g=c.slice(1);switch(f){case"registerImmediately":u=n.of(null);break;case"registerWithDelay":u=l(+g[0]||0);break;case"registerWhenStable":u=g[0]?n.merge(h(e),l(+g[0])):h(e);break;default:throw new Error("Unknown ServiceWorker registration strategy: "+s.registrationStrategy)}}e.get(t.NgZone).runOutsideAngular((function(){return u.pipe(i.take(1)).subscribe((function(){return navigator.serviceWorker.register(o,{scope:s.scope}).catch((function(e){return console.error("Service worker registration failed with:",e)}))}))}))}}}function l(e){return n.of(null).pipe(i.delay(e))}function h(e){return e.get(t.ApplicationRef).isStable.pipe(i.filter((function(e){return e})))}function g(e,t){return new s(r.isPlatformBrowser(t)&&!1!==e.enabled?navigator.serviceWorker:void 0)}var v=function(){function e(){}return e.register=function(r,n){return void 0===n&&(n={}),{ngModule:e,providers:[{provide:p,useValue:r},{provide:c,useValue:n},{provide:s,useFactory:g,deps:[c,t.PLATFORM_ID]},{provide:t.APP_INITIALIZER,useFactory:f,deps:[t.Injector,p,c,t.PLATFORM_ID],multi:!0}]}},e}();v.decorators=[{type:t.NgModule,args:[{providers:[a,u]}]}],
37/**
38 * @license
39 * Copyright Google LLC All Rights Reserved.
40 *
41 * Use of this source code is governed by an MIT-style license that can be
42 * found in the LICENSE file at https://angular.io/license
43 */
44/**
45 * @license
46 * Copyright Google LLC All Rights Reserved.
47 *
48 * Use of this source code is governed by an MIT-style license that can be
49 * found in the LICENSE file at https://angular.io/license
50 */
51/**
52 * @license
53 * Copyright Google LLC All Rights Reserved.
54 *
55 * Use of this source code is governed by an MIT-style license that can be
56 * found in the LICENSE file at https://angular.io/license
57 */
58e.ServiceWorkerModule=v,e.SwPush=a,e.SwRegistrationOptions=c,e.SwUpdate=u,e.ɵangular_packages_service_worker_service_worker_a=s,e.ɵangular_packages_service_worker_service_worker_b=p,e.ɵangular_packages_service_worker_service_worker_c=f,e.ɵangular_packages_service_worker_service_worker_d=g,Object.defineProperty(e,"__esModule",{value:!0})}));
\No newline at end of file