UNPKG

21.2 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/fire'), require('rxjs'), require('rxjs/operators'), require('@angular/core'), require('@angular/fire/app'), require('firebase/app'), require('firebase/messaging')) :
3 typeof define === 'function' && define.amd ? define('@angular/fire/messaging', ['exports', '@angular/fire', 'rxjs', 'rxjs/operators', '@angular/core', '@angular/fire/app', 'firebase/app', 'firebase/messaging'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.angular = global.angular || {}, global.angular.fire = global.angular.fire || {}, global.angular.fire.messaging = {}), global.angular.fire, global.rxjs, global.rxjs.operators, global.ng.core, global.angular.fire.app, global.app$1, global['firebase-messaging']));
5}(this, (function (exports, fire, rxjs, operators, i0, app, app$1, messaging) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
29 var Messaging = /** @class */ (function () {
30 function Messaging(messaging) {
31 return messaging;
32 }
33 return Messaging;
34 }());
35 var MESSAGING_PROVIDER_NAME = 'messaging';
36 var MessagingInstances = /** @class */ (function () {
37 function MessagingInstances() {
38 return fire.ɵgetAllInstancesOf(MESSAGING_PROVIDER_NAME);
39 }
40 return MessagingInstances;
41 }());
42 var messagingInstance$ = rxjs.timer(0, 300).pipe(operators.concatMap(function () { return rxjs.from(fire.ɵgetAllInstancesOf(MESSAGING_PROVIDER_NAME)); }), operators.distinct());
43
44 /*! *****************************************************************************
45 Copyright (c) Microsoft Corporation.
46
47 Permission to use, copy, modify, and/or distribute this software for any
48 purpose with or without fee is hereby granted.
49
50 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
51 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
52 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
53 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
54 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
55 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
56 PERFORMANCE OF THIS SOFTWARE.
57 ***************************************************************************** */
58 /* global Reflect, Promise */
59 var extendStatics = function (d, b) {
60 extendStatics = Object.setPrototypeOf ||
61 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
62 function (d, b) { for (var p in b)
63 if (Object.prototype.hasOwnProperty.call(b, p))
64 d[p] = b[p]; };
65 return extendStatics(d, b);
66 };
67 function __extends(d, b) {
68 if (typeof b !== "function" && b !== null)
69 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
70 extendStatics(d, b);
71 function __() { this.constructor = d; }
72 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
73 }
74 var __assign = function () {
75 __assign = Object.assign || function __assign(t) {
76 for (var s, i = 1, n = arguments.length; i < n; i++) {
77 s = arguments[i];
78 for (var p in s)
79 if (Object.prototype.hasOwnProperty.call(s, p))
80 t[p] = s[p];
81 }
82 return t;
83 };
84 return __assign.apply(this, arguments);
85 };
86 function __rest(s, e) {
87 var t = {};
88 for (var p in s)
89 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
90 t[p] = s[p];
91 if (s != null && typeof Object.getOwnPropertySymbols === "function")
92 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
93 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
94 t[p[i]] = s[p[i]];
95 }
96 return t;
97 }
98 function __decorate(decorators, target, key, desc) {
99 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
100 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
101 r = Reflect.decorate(decorators, target, key, desc);
102 else
103 for (var i = decorators.length - 1; i >= 0; i--)
104 if (d = decorators[i])
105 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
106 return c > 3 && r && Object.defineProperty(target, key, r), r;
107 }
108 function __param(paramIndex, decorator) {
109 return function (target, key) { decorator(target, key, paramIndex); };
110 }
111 function __metadata(metadataKey, metadataValue) {
112 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
113 return Reflect.metadata(metadataKey, metadataValue);
114 }
115 function __awaiter(thisArg, _arguments, P, generator) {
116 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
117 return new (P || (P = Promise))(function (resolve, reject) {
118 function fulfilled(value) { try {
119 step(generator.next(value));
120 }
121 catch (e) {
122 reject(e);
123 } }
124 function rejected(value) { try {
125 step(generator["throw"](value));
126 }
127 catch (e) {
128 reject(e);
129 } }
130 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
131 step((generator = generator.apply(thisArg, _arguments || [])).next());
132 });
133 }
134 function __generator(thisArg, body) {
135 var _ = { label: 0, sent: function () { if (t[0] & 1)
136 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
137 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
138 function verb(n) { return function (v) { return step([n, v]); }; }
139 function step(op) {
140 if (f)
141 throw new TypeError("Generator is already executing.");
142 while (_)
143 try {
144 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
145 return t;
146 if (y = 0, t)
147 op = [op[0] & 2, t.value];
148 switch (op[0]) {
149 case 0:
150 case 1:
151 t = op;
152 break;
153 case 4:
154 _.label++;
155 return { value: op[1], done: false };
156 case 5:
157 _.label++;
158 y = op[1];
159 op = [0];
160 continue;
161 case 7:
162 op = _.ops.pop();
163 _.trys.pop();
164 continue;
165 default:
166 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
167 _ = 0;
168 continue;
169 }
170 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
171 _.label = op[1];
172 break;
173 }
174 if (op[0] === 6 && _.label < t[1]) {
175 _.label = t[1];
176 t = op;
177 break;
178 }
179 if (t && _.label < t[2]) {
180 _.label = t[2];
181 _.ops.push(op);
182 break;
183 }
184 if (t[2])
185 _.ops.pop();
186 _.trys.pop();
187 continue;
188 }
189 op = body.call(thisArg, _);
190 }
191 catch (e) {
192 op = [6, e];
193 y = 0;
194 }
195 finally {
196 f = t = 0;
197 }
198 if (op[0] & 5)
199 throw op[1];
200 return { value: op[0] ? op[1] : void 0, done: true };
201 }
202 }
203 var __createBinding = Object.create ? (function (o, m, k, k2) {
204 if (k2 === undefined)
205 k2 = k;
206 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
207 }) : (function (o, m, k, k2) {
208 if (k2 === undefined)
209 k2 = k;
210 o[k2] = m[k];
211 });
212 function __exportStar(m, o) {
213 for (var p in m)
214 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
215 __createBinding(o, m, p);
216 }
217 function __values(o) {
218 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
219 if (m)
220 return m.call(o);
221 if (o && typeof o.length === "number")
222 return {
223 next: function () {
224 if (o && i >= o.length)
225 o = void 0;
226 return { value: o && o[i++], done: !o };
227 }
228 };
229 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
230 }
231 function __read(o, n) {
232 var m = typeof Symbol === "function" && o[Symbol.iterator];
233 if (!m)
234 return o;
235 var i = m.call(o), r, ar = [], e;
236 try {
237 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
238 ar.push(r.value);
239 }
240 catch (error) {
241 e = { error: error };
242 }
243 finally {
244 try {
245 if (r && !r.done && (m = i["return"]))
246 m.call(i);
247 }
248 finally {
249 if (e)
250 throw e.error;
251 }
252 }
253 return ar;
254 }
255 /** @deprecated */
256 function __spread() {
257 for (var ar = [], i = 0; i < arguments.length; i++)
258 ar = ar.concat(__read(arguments[i]));
259 return ar;
260 }
261 /** @deprecated */
262 function __spreadArrays() {
263 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
264 s += arguments[i].length;
265 for (var r = Array(s), k = 0, i = 0; i < il; i++)
266 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
267 r[k] = a[j];
268 return r;
269 }
270 function __spreadArray(to, from) {
271 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
272 to[j] = from[i];
273 return to;
274 }
275 function __await(v) {
276 return this instanceof __await ? (this.v = v, this) : new __await(v);
277 }
278 function __asyncGenerator(thisArg, _arguments, generator) {
279 if (!Symbol.asyncIterator)
280 throw new TypeError("Symbol.asyncIterator is not defined.");
281 var g = generator.apply(thisArg, _arguments || []), i, q = [];
282 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
283 function verb(n) { if (g[n])
284 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
285 function resume(n, v) { try {
286 step(g[n](v));
287 }
288 catch (e) {
289 settle(q[0][3], e);
290 } }
291 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
292 function fulfill(value) { resume("next", value); }
293 function reject(value) { resume("throw", value); }
294 function settle(f, v) { if (f(v), q.shift(), q.length)
295 resume(q[0][0], q[0][1]); }
296 }
297 function __asyncDelegator(o) {
298 var i, p;
299 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
300 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
301 }
302 function __asyncValues(o) {
303 if (!Symbol.asyncIterator)
304 throw new TypeError("Symbol.asyncIterator is not defined.");
305 var m = o[Symbol.asyncIterator], i;
306 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
307 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
308 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
309 }
310 function __makeTemplateObject(cooked, raw) {
311 if (Object.defineProperty) {
312 Object.defineProperty(cooked, "raw", { value: raw });
313 }
314 else {
315 cooked.raw = raw;
316 }
317 return cooked;
318 }
319 ;
320 var __setModuleDefault = Object.create ? (function (o, v) {
321 Object.defineProperty(o, "default", { enumerable: true, value: v });
322 }) : function (o, v) {
323 o["default"] = v;
324 };
325 function __importStar(mod) {
326 if (mod && mod.__esModule)
327 return mod;
328 var result = {};
329 if (mod != null)
330 for (var k in mod)
331 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
332 __createBinding(result, mod, k);
333 __setModuleDefault(result, mod);
334 return result;
335 }
336 function __importDefault(mod) {
337 return (mod && mod.__esModule) ? mod : { default: mod };
338 }
339 function __classPrivateFieldGet(receiver, state, kind, f) {
340 if (kind === "a" && !f)
341 throw new TypeError("Private accessor was defined without a getter");
342 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343 throw new TypeError("Cannot read private member from an object whose class did not declare it");
344 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
345 }
346 function __classPrivateFieldSet(receiver, state, value, kind, f) {
347 if (kind === "m")
348 throw new TypeError("Private method is not writable");
349 if (kind === "a" && !f)
350 throw new TypeError("Private accessor was defined without a setter");
351 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
352 throw new TypeError("Cannot write private member to an object whose class did not declare it");
353 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
354 }
355
356 var PROVIDED_MESSAGING_INSTANCES = new i0.InjectionToken('angularfire2.messaging-instances');
357 function defaultMessagingInstanceFactory(provided, defaultApp) {
358 if (!fire.ɵisMessagingSupportedFactory.sync()) {
359 return null;
360 }
361 var defaultMessaging = fire.ɵgetDefaultInstanceOf(MESSAGING_PROVIDER_NAME, provided, defaultApp);
362 return defaultMessaging && new Messaging(defaultMessaging);
363 }
364 function messagingInstanceFactory(fn) {
365 return function (zone, injector) {
366 if (!fire.ɵisMessagingSupportedFactory.sync()) {
367 return null;
368 }
369 var messaging = zone.runOutsideAngular(function () { return fn(injector); });
370 return new Messaging(messaging);
371 };
372 }
373 var MESSAGING_INSTANCES_PROVIDER = {
374 provide: MessagingInstances,
375 deps: [
376 [new i0.Optional(), PROVIDED_MESSAGING_INSTANCES],
377 ]
378 };
379 var DEFAULT_MESSAGING_INSTANCE_PROVIDER = {
380 provide: Messaging,
381 useFactory: defaultMessagingInstanceFactory,
382 deps: [
383 [new i0.Optional(), PROVIDED_MESSAGING_INSTANCES],
384 app.FirebaseApp,
385 ]
386 };
387 var MessagingModule = /** @class */ (function () {
388 function MessagingModule() {
389 app$1.registerVersion('angularfire', fire.VERSION.full, 'fcm');
390 }
391 return MessagingModule;
392 }());
393 MessagingModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: MessagingModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
394 MessagingModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: MessagingModule });
395 MessagingModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: MessagingModule, providers: [
396 DEFAULT_MESSAGING_INSTANCE_PROVIDER,
397 MESSAGING_INSTANCES_PROVIDER,
398 {
399 provide: i0.APP_INITIALIZER,
400 useValue: fire.ɵisMessagingSupportedFactory.async,
401 multi: true,
402 },
403 ] });
404 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: MessagingModule, decorators: [{
405 type: i0.NgModule,
406 args: [{
407 providers: [
408 DEFAULT_MESSAGING_INSTANCE_PROVIDER,
409 MESSAGING_INSTANCES_PROVIDER,
410 {
411 provide: i0.APP_INITIALIZER,
412 useValue: fire.ɵisMessagingSupportedFactory.async,
413 multi: true,
414 },
415 ]
416 }]
417 }], ctorParameters: function () { return []; } });
418 function provideMessaging(fn) {
419 var deps = [];
420 for (var _i = 1; _i < arguments.length; _i++) {
421 deps[_i - 1] = arguments[_i];
422 }
423 return {
424 ngModule: MessagingModule,
425 providers: [{
426 provide: PROVIDED_MESSAGING_INSTANCES,
427 useFactory: messagingInstanceFactory(fn),
428 multi: true,
429 deps: __spreadArray([
430 i0.NgZone,
431 i0.Injector,
432 fire.ɵAngularFireSchedulers,
433 app.FirebaseApps
434 ], __read(deps)),
435 }]
436 };
437 }
438
439 var isSupported = fire.ɵisMessagingSupportedFactory.async;
440
441 // DO NOT MODIFY, this file is autogenerated by tools/build.ts
442 var deleteToken = fire.ɵzoneWrap(messaging.deleteToken, true);
443 var getMessaging = fire.ɵzoneWrap(messaging.getMessaging, true);
444 var getToken = fire.ɵzoneWrap(messaging.getToken, true);
445 var onMessage = fire.ɵzoneWrap(messaging.onMessage, false);
446
447 /**
448 * Generated bundle index. Do not edit.
449 */
450
451 exports.Messaging = Messaging;
452 exports.MessagingInstances = MessagingInstances;
453 exports.MessagingModule = MessagingModule;
454 exports.deleteToken = deleteToken;
455 exports.getMessaging = getMessaging;
456 exports.getToken = getToken;
457 exports.isSupported = isSupported;
458 exports.messagingInstance$ = messagingInstance$;
459 exports.onMessage = onMessage;
460 exports.provideMessaging = provideMessaging;
461 Object.keys(messaging).forEach(function (k) {
462 if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
463 enumerable: true,
464 get: function () {
465 return messaging[k];
466 }
467 });
468 });
469
470 Object.defineProperty(exports, '__esModule', { value: true });
471
472})));
473//# sourceMappingURL=angular-fire-messaging.umd.js.map