UNPKG

13.1 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/compat'), require('@angular/common'), require('firebase/compat/app'), require('@angular/fire')) :
3 typeof define === 'function' && define.amd ? define('@angular/fire/compat/performance', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/compat', '@angular/common', 'firebase/compat/app', '@angular/fire'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.angular = global.angular || {}, global.angular.fire = global.angular.fire || {}, global.angular.fire.compat = global.angular.fire.compat || {}, global.angular.fire.compat.performance = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.angular.fire.compat, global.ng.common, global.firebase, global.angular.fire));
5}(this, (function (exports, i0, rxjs, operators, i1, common, firebase, fire) { 'use strict';
6
7 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9 function _interopNamespace(e) {
10 if (e && e.__esModule) return e;
11 var n = Object.create(null);
12 if (e) {
13 Object.keys(e).forEach(function (k) {
14 if (k !== 'default') {
15 var d = Object.getOwnPropertyDescriptor(e, k);
16 Object.defineProperty(n, k, d.get ? d : {
17 enumerable: true,
18 get: function () {
19 return e[k];
20 }
21 });
22 }
23 });
24 }
25 n['default'] = e;
26 return Object.freeze(n);
27 }
28
29 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
30 var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
31 var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
32
33 // DO NOT MODIFY, this file is autogenerated by tools/build.ts
34 // Export a null object with the same keys as firebase/compat/performance, so Proxy can work with proxy-polyfill in Internet Explorer
35 var proxyPolyfillCompat = {
36 app: null,
37 trace: null,
38 instrumentationEnabled: null,
39 dataCollectionEnabled: null,
40 };
41
42 var INSTRUMENTATION_ENABLED = new i0.InjectionToken('angularfire2.performance.instrumentationEnabled');
43 var DATA_COLLECTION_ENABLED = new i0.InjectionToken('angularfire2.performance.dataCollectionEnabled');
44 var AngularFirePerformance = /** @class */ (function () {
45 function AngularFirePerformance(app, instrumentationEnabled, dataCollectionEnabled, zone,
46 // tslint:disable-next-line:ban-types
47 platformId) {
48 this.zone = zone;
49 this.performance = rxjs.of(undefined).pipe(operators.switchMap(function () { return common.isPlatformBrowser(platformId) ? zone.runOutsideAngular(function () { return import('firebase/compat/performance'); }) : rxjs.EMPTY; }), operators.map(function () { return i1.ɵcacheInstance("performance", 'AngularFirePerformance', app.name, function () {
50 var performance = zone.runOutsideAngular(function () { return app.performance(); });
51 if (instrumentationEnabled === false) {
52 performance.instrumentationEnabled = false;
53 }
54 if (dataCollectionEnabled === false) {
55 performance.dataCollectionEnabled = false;
56 }
57 return performance;
58 }, [instrumentationEnabled, dataCollectionEnabled]); }), operators.shareReplay({ bufferSize: 1, refCount: false }));
59 return i1.ɵlazySDKProxy(this, this.performance, zone);
60 }
61 return AngularFirePerformance;
62 }());
63 AngularFirePerformance.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformance, deps: [{ token: i1__namespace.FirebaseApp }, { token: INSTRUMENTATION_ENABLED, optional: true }, { token: DATA_COLLECTION_ENABLED, optional: true }, { token: i0__namespace.NgZone }, { token: i0.PLATFORM_ID }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
64 AngularFirePerformance.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformance, providedIn: 'any' });
65 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformance, decorators: [{
66 type: i0.Injectable,
67 args: [{
68 providedIn: 'any'
69 }]
70 }], ctorParameters: function () {
71 return [{ type: i1__namespace.FirebaseApp }, { type: undefined, decorators: [{
72 type: i0.Optional
73 }, {
74 type: i0.Inject,
75 args: [INSTRUMENTATION_ENABLED]
76 }] }, { type: undefined, decorators: [{
77 type: i0.Optional
78 }, {
79 type: i0.Inject,
80 args: [DATA_COLLECTION_ENABLED]
81 }] }, { type: i0__namespace.NgZone }, { type: Object, decorators: [{
82 type: i0.Inject,
83 args: [i0.PLATFORM_ID]
84 }] }];
85 } });
86 var trace$ = function (traceId) {
87 var _a;
88 if (typeof window !== 'undefined' && ((_a = window.performance) === null || _a === void 0 ? void 0 : _a.mark)) {
89 var entries = window.performance.getEntriesByName(traceId, 'measure') || [];
90 var startMarkName_1 = "_" + traceId + "Start[" + entries.length + "]";
91 var endMarkName_1 = "_" + traceId + "End[" + entries.length + "]";
92 return new rxjs.Observable(function (emitter) {
93 window.performance.mark(startMarkName_1);
94 emitter.next();
95 return {
96 unsubscribe: function () {
97 window.performance.mark(endMarkName_1);
98 window.performance.measure(traceId, startMarkName_1, endMarkName_1);
99 }
100 };
101 });
102 }
103 else {
104 return rxjs.EMPTY;
105 }
106 };
107 var traceUntil = function (name, test, options) { return function (source$) { return new rxjs.Observable(function (subscriber) {
108 var traceSubscription = trace$(name).subscribe();
109 return source$.pipe(operators.tap(function (a) { return test(a) && traceSubscription.unsubscribe(); }, function () {
110 }, function () { return options && options.orComplete && traceSubscription.unsubscribe(); })).subscribe(subscriber);
111 }); }; };
112 var traceWhile = function (name, test, options) { return function (source$) { return new rxjs.Observable(function (subscriber) {
113 var traceSubscription;
114 return source$.pipe(operators.tap(function (a) {
115 if (test(a)) {
116 traceSubscription = traceSubscription || trace$(name).subscribe();
117 }
118 else {
119 if (traceSubscription) {
120 traceSubscription.unsubscribe();
121 }
122 traceSubscription = undefined;
123 }
124 }, function () {
125 }, function () { return options && options.orComplete && traceSubscription && traceSubscription.unsubscribe(); })).subscribe(subscriber);
126 }); }; };
127 var traceUntilComplete = function (name) { return function (source$) { return new rxjs.Observable(function (subscriber) {
128 var traceSubscription = trace$(name).subscribe();
129 return source$.pipe(operators.tap(function () {
130 }, function () {
131 }, function () { return traceSubscription.unsubscribe(); })).subscribe(subscriber);
132 }); }; };
133 var traceUntilFirst = function (name) { return function (source$) { return new rxjs.Observable(function (subscriber) {
134 var traceSubscription = trace$(name).subscribe();
135 return source$.pipe(operators.tap(function () { return traceSubscription.unsubscribe(); }, function () {
136 }, function () {
137 })).subscribe(subscriber);
138 }); }; };
139 var trace = function (name) { return function (source$) { return new rxjs.Observable(function (subscriber) {
140 var traceSubscription = trace$(name).subscribe();
141 return source$.pipe(operators.tap(function () { return traceSubscription.unsubscribe(); }, function () {
142 }, function () { return traceSubscription.unsubscribe(); })).subscribe(subscriber);
143 }); }; };
144 i1.ɵapplyMixins(AngularFirePerformance, [proxyPolyfillCompat]);
145
146 var IS_STABLE_START_MARK = 'Zone';
147 var IS_STABLE_END_MARK = '_isStableEnd';
148 var PerformanceMonitoringService = /** @class */ (function () {
149 function PerformanceMonitoringService(appRef) {
150 var _a;
151 if (typeof window !== 'undefined' && ((_a = window.performance) === null || _a === void 0 ? void 0 : _a.mark)) {
152 this.disposable = appRef.isStable.pipe(operators.first(function (it) { return it; }), operators.tap(function () {
153 window.performance.mark(IS_STABLE_END_MARK);
154 window.performance.measure('isStable', IS_STABLE_START_MARK, IS_STABLE_END_MARK);
155 })).subscribe();
156 }
157 }
158 PerformanceMonitoringService.prototype.ngOnDestroy = function () {
159 if (this.disposable) {
160 this.disposable.unsubscribe();
161 }
162 };
163 return PerformanceMonitoringService;
164 }());
165 PerformanceMonitoringService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: PerformanceMonitoringService, deps: [{ token: i0__namespace.ApplicationRef }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
166 PerformanceMonitoringService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: PerformanceMonitoringService });
167 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: PerformanceMonitoringService, decorators: [{
168 type: i0.Injectable
169 }], ctorParameters: function () { return [{ type: i0__namespace.ApplicationRef }]; } });
170
171 var AngularFirePerformanceModule = /** @class */ (function () {
172 function AngularFirePerformanceModule(perf, _) {
173 firebase__default['default'].registerVersion('angularfire', fire.VERSION.full, 'perf-compat');
174 // call anything here to get perf loading
175 // tslint:disable-next-line:no-unused-expression
176 perf.dataCollectionEnabled.then(function () { });
177 }
178 return AngularFirePerformanceModule;
179 }());
180 AngularFirePerformanceModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformanceModule, deps: [{ token: AngularFirePerformance }, { token: PerformanceMonitoringService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.NgModule });
181 AngularFirePerformanceModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformanceModule });
182 AngularFirePerformanceModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformanceModule, providers: [AngularFirePerformance] });
183 i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0__namespace, type: AngularFirePerformanceModule, decorators: [{
184 type: i0.NgModule,
185 args: [{
186 providers: [AngularFirePerformance]
187 }]
188 }], ctorParameters: function () {
189 return [{ type: AngularFirePerformance }, { type: PerformanceMonitoringService, decorators: [{
190 type: i0.Optional
191 }] }];
192 } });
193
194 /**
195 * Generated bundle index. Do not edit.
196 */
197
198 exports.AngularFirePerformance = AngularFirePerformance;
199 exports.AngularFirePerformanceModule = AngularFirePerformanceModule;
200 exports.DATA_COLLECTION_ENABLED = DATA_COLLECTION_ENABLED;
201 exports.INSTRUMENTATION_ENABLED = INSTRUMENTATION_ENABLED;
202 exports.PerformanceMonitoringService = PerformanceMonitoringService;
203 exports.trace = trace;
204 exports.traceUntil = traceUntil;
205 exports.traceUntilComplete = traceUntilComplete;
206 exports.traceUntilFirst = traceUntilFirst;
207 exports.traceWhile = traceWhile;
208
209 Object.defineProperty(exports, '__esModule', { value: true });
210
211})));
212//# sourceMappingURL=angular-fire-compat-performance.umd.js.map