|
1 | 1 | import { Version } from '@angular/core';
|
2 | 2 | import { FirebaseApp, getApps } from 'firebase/app';
|
3 | 3 | import { ComponentContainer } from '@firebase/component';
|
4 |
| -import { isSupported as isRemoteConfigSupported } from 'firebase/remote-config'; |
5 |
| -import { isSupported as isMessagingSupported } from 'firebase/messaging'; |
6 |
| -import { isSupported as isAnalyticsSupported } from 'firebase/analytics'; |
7 | 4 |
|
8 | 5 | export const VERSION = new Version('ANGULARFIRE2_VERSION');
|
9 | 6 |
|
10 |
| -const isAnalyticsSupportedValueSymbol = '__angularfire_symbol__analyticsIsSupportedValue'; |
11 |
| -const isAnalyticsSupportedPromiseSymbol = '__angularfire_symbol__analyticsIsSupported'; |
12 |
| -const isRemoteConfigSupportedValueSymbol = '__angularfire_symbol__remoteConfigIsSupportedValue'; |
13 |
| -const isRemoteConfigSupportedPromiseSymbol = '__angularfire_symbol__remoteConfigIsSupported'; |
14 |
| -const isMessagingSupportedValueSymbol = '__angularfire_symbol__messagingIsSupportedValue'; |
15 |
| -const isMessagingSupportedPromiseSymbol = '__angularfire_symbol__messagingIsSupported'; |
16 |
| - |
17 |
| -globalThis[isAnalyticsSupportedPromiseSymbol] ||= isAnalyticsSupported().then(it => |
18 |
| - globalThis[isAnalyticsSupportedValueSymbol] = it |
19 |
| -).catch(() => |
20 |
| - globalThis[isAnalyticsSupportedValueSymbol] = false |
21 |
| -); |
22 |
| - |
23 |
| -globalThis[isMessagingSupportedPromiseSymbol] ||= isMessagingSupported().then(it => |
24 |
| - globalThis[isMessagingSupportedValueSymbol] = it |
25 |
| -).catch(() => |
26 |
| - globalThis[isMessagingSupportedValueSymbol] = false |
27 |
| -); |
28 |
| - |
29 |
| -globalThis[isRemoteConfigSupportedPromiseSymbol] ||= isRemoteConfigSupported().then(it => |
30 |
| - globalThis[isRemoteConfigSupportedValueSymbol] = it |
31 |
| -).catch(() => |
32 |
| - globalThis[isRemoteConfigSupportedValueSymbol] = false |
33 |
| -); |
34 |
| - |
35 |
| -const isSupportedError = (module: string) => |
| 7 | +export const ɵisSupportedError = (module: string) => |
36 | 8 | `The APP_INITIALIZER that is "making" isSupported() sync for the sake of convenient DI has not resolved in this
|
37 | 9 | context. Rather than injecting ${module} in the constructor, first ensure that ${module} is supported by calling
|
38 | 10 | \`await isSupported()\`, then retrieve the instance from the injector manually \`injector.get(${module})\`.`;
|
39 | 11 |
|
40 |
| -export const ɵisMessagingSupportedFactory = { |
41 |
| - async: () => globalThis[isMessagingSupportedPromiseSymbol], |
42 |
| - sync: () => { |
43 |
| - const ret = globalThis[isMessagingSupportedValueSymbol]; |
44 |
| - if (ret === undefined) { throw new Error(isSupportedError('Messaging')); } |
45 |
| - return ret; |
46 |
| - } |
47 |
| -}; |
48 |
| - |
49 |
| -export const ɵisRemoteConfigSupportedFactory = { |
50 |
| - async: () => globalThis[isRemoteConfigSupportedPromiseSymbol], |
51 |
| - sync: () => { |
52 |
| - const ret = globalThis[isRemoteConfigSupportedValueSymbol]; |
53 |
| - if (ret === undefined) { throw new Error(isSupportedError('RemoteConfig')); } |
54 |
| - return ret; |
55 |
| - } |
56 |
| -}; |
57 |
| - |
58 |
| -export const ɵisAnalyticsSupportedFactory = { |
59 |
| - async: () => globalThis[isAnalyticsSupportedPromiseSymbol], |
60 |
| - sync: () => { |
61 |
| - const ret = globalThis[isAnalyticsSupportedValueSymbol]; |
62 |
| - if (ret === undefined) { throw new Error(isSupportedError('Analytics')); } |
63 |
| - return ret; |
64 |
| - } |
65 |
| -}; |
66 |
| - |
67 | 12 | // TODO is there a better way to get at the internal types?
|
68 | 13 | interface FirebaseAppWithContainer extends FirebaseApp {
|
69 | 14 | container: ComponentContainer;
|
|
0 commit comments