1 | import * as i0 from '@angular/core';
|
2 | import { InjectionToken, Optional, NgModule, NgZone, Injector } from '@angular/core';
|
3 | import { ɵgetAllInstancesOf, ɵgetDefaultInstanceOf, VERSION, ɵAngularFireSchedulers, ɵzoneWrap } from '@angular/fire';
|
4 | import { timer, from } from 'rxjs';
|
5 | import { concatMap, distinct } from 'rxjs/operators';
|
6 | import { FirebaseApp, FirebaseApps } from '@angular/fire/app';
|
7 | import { AuthInstances } from '@angular/fire/auth';
|
8 | import { registerVersion } from 'firebase/app';
|
9 | import { AppCheckInstances } from '@angular/fire/app-check';
|
10 | import { httpsCallable as httpsCallable$1 } from 'rxfire/functions';
|
11 | import { connectFunctionsEmulator as connectFunctionsEmulator$1, getFunctions as getFunctions$1, httpsCallable as httpsCallable$2 } from 'firebase/functions';
|
12 | export * from 'firebase/functions';
|
13 |
|
14 | class Functions {
|
15 | constructor(functions) {
|
16 | return functions;
|
17 | }
|
18 | }
|
19 | const FUNCTIONS_PROVIDER_NAME = 'functions';
|
20 | class FunctionsInstances {
|
21 | constructor() {
|
22 | return ɵgetAllInstancesOf(FUNCTIONS_PROVIDER_NAME);
|
23 | }
|
24 | }
|
25 | const functionInstance$ = timer(0, 300).pipe(concatMap(() => from(ɵgetAllInstancesOf(FUNCTIONS_PROVIDER_NAME))), distinct());
|
26 |
|
27 | const PROVIDED_FUNCTIONS_INSTANCES = new InjectionToken('angularfire2.functions-instances');
|
28 | function defaultFunctionsInstanceFactory(provided, defaultApp) {
|
29 | const defaultAuth = ɵgetDefaultInstanceOf(FUNCTIONS_PROVIDER_NAME, provided, defaultApp);
|
30 | return defaultAuth && new Functions(defaultAuth);
|
31 | }
|
32 | function functionsInstanceFactory(fn) {
|
33 | return (zone, injector) => {
|
34 | const functions = zone.runOutsideAngular(() => fn(injector));
|
35 | return new Functions(functions);
|
36 | };
|
37 | }
|
38 | const FUNCTIONS_INSTANCES_PROVIDER = {
|
39 | provide: FunctionsInstances,
|
40 | deps: [
|
41 | [new Optional(), PROVIDED_FUNCTIONS_INSTANCES],
|
42 | ]
|
43 | };
|
44 | const DEFAULT_FUNCTIONS_INSTANCE_PROVIDER = {
|
45 | provide: Functions,
|
46 | useFactory: defaultFunctionsInstanceFactory,
|
47 | deps: [
|
48 | [new Optional(), PROVIDED_FUNCTIONS_INSTANCES],
|
49 | FirebaseApp,
|
50 | ]
|
51 | };
|
52 | class FunctionsModule {
|
53 | constructor() {
|
54 | registerVersion('angularfire', VERSION.full, 'fn');
|
55 | }
|
56 | }
|
57 | FunctionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: FunctionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
58 | FunctionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: FunctionsModule });
|
59 | FunctionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: FunctionsModule, providers: [
|
60 | DEFAULT_FUNCTIONS_INSTANCE_PROVIDER,
|
61 | FUNCTIONS_INSTANCES_PROVIDER,
|
62 | ] });
|
63 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.3", ngImport: i0, type: FunctionsModule, decorators: [{
|
64 | type: NgModule,
|
65 | args: [{
|
66 | providers: [
|
67 | DEFAULT_FUNCTIONS_INSTANCE_PROVIDER,
|
68 | FUNCTIONS_INSTANCES_PROVIDER,
|
69 | ]
|
70 | }]
|
71 | }], ctorParameters: function () { return []; } });
|
72 | function provideFunctions(fn, ...deps) {
|
73 | return {
|
74 | ngModule: FunctionsModule,
|
75 | providers: [{
|
76 | provide: PROVIDED_FUNCTIONS_INSTANCES,
|
77 | useFactory: functionsInstanceFactory(fn),
|
78 | multi: true,
|
79 | deps: [
|
80 | NgZone,
|
81 | Injector,
|
82 | ɵAngularFireSchedulers,
|
83 | FirebaseApps,
|
84 |
|
85 | [new Optional(), AuthInstances],
|
86 | [new Optional(), AppCheckInstances],
|
87 | ...deps,
|
88 | ]
|
89 | }]
|
90 | };
|
91 | }
|
92 |
|
93 |
|
94 | const httpsCallableData = ɵzoneWrap(httpsCallable$1, true);
|
95 |
|
96 |
|
97 | const connectFunctionsEmulator = ɵzoneWrap(connectFunctionsEmulator$1, true);
|
98 | const getFunctions = ɵzoneWrap(getFunctions$1, true);
|
99 | const httpsCallable = ɵzoneWrap(httpsCallable$2, true);
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | export { Functions, FunctionsInstances, FunctionsModule, connectFunctionsEmulator, functionInstance$, getFunctions, httpsCallable, httpsCallableData, provideFunctions };
|
106 |
|