@react-native-firebase/app 26.4.0 → 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +10 -27
- package/RNFBApp.podspec +13 -5
- package/android/build.gradle +3 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
- package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
- package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
- package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
- package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
- package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
- package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
- package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
- package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
- package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
- package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
- package/dist/module/FirebaseApp.js +10 -0
- package/dist/module/FirebaseApp.js.map +1 -1
- package/dist/module/common/deeps.js +3 -0
- package/dist/module/common/deeps.js.map +1 -1
- package/dist/module/internal/FirebaseModule.js.map +1 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
- package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
- package/dist/module/internal/SharedEventEmitter.js +3 -1
- package/dist/module/internal/SharedEventEmitter.js.map +1 -1
- package/dist/module/internal/index.js +1 -0
- package/dist/module/internal/index.js.map +1 -1
- package/dist/module/internal/registry/app.js +7 -1
- package/dist/module/internal/registry/app.js.map +1 -1
- package/dist/module/types/app.js.map +1 -1
- package/dist/module/types/internal.js +2 -0
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
- package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
- package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
- package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
- package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
- package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
- package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
- package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
- package/dist/typescript/lib/internal/index.d.ts +1 -0
- package/dist/typescript/lib/internal/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/app.d.ts +10 -3
- package/dist/typescript/lib/types/app.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +12 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/firebase-schema.json +4 -0
- package/firebase_spm.rb +552 -96
- package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
- package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
- package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
- package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
- package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
- package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
- package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
- package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
- package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
- package/ios/RNFBApp/RNFBAppModule.h +6 -2
- package/ios/RNFBApp/RNFBAppModule.mm +65 -228
- package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
- package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
- package/ios/RNFBApp/RNFBHandleMap.m +27 -56
- package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
- package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
- package/ios/RNFBApp/RNFBJSON.m +22 -38
- package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
- package/ios/RNFBApp/RNFBMeta.m +24 -26
- package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
- package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
- package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
- package/ios/RNFBApp/RNFBPreferences.m +22 -20
- package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
- package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
- package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
- package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
- package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
- package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
- package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
- package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
- package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
- package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
- package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
- package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
- package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
- package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
- package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
- package/ios/RNFBApp/RNFBVersion.m +1 -1
- package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
- package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
- package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
- package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
- package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
- package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
- package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
- package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
- package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
- package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
- package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
- package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
- package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
- package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
- package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
- package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
- package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
- package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
- package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
- package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
- package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
- package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
- package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
- package/ios/RNFBFirebase/Package.swift +53 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
- package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
- package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
- package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
- package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
- package/ios_config.sh +50 -22
- package/lib/FirebaseApp.ts +10 -0
- package/lib/common/deeps.ts +3 -0
- package/lib/internal/FirebaseModule.ts +6 -3
- package/lib/internal/NativeModules.ts +4 -1
- package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
- package/lib/internal/SharedEventEmitter.ts +5 -1
- package/lib/internal/index.ts +1 -0
- package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
- package/lib/internal/registry/app.ts +7 -1
- package/lib/types/app.ts +10 -3
- package/lib/types/internal.ts +19 -0
- package/lib/version.ts +1 -1
- package/package.json +8 -8
- package/plugin/build/ios/appDelegate.js +2 -2
- package/plugin/build/ios/podfile.js +16 -16
- package/plugin/build/pluginConfig.d.ts +4 -2
- package/plugin/src/ios/appDelegate.ts +2 -2
- package/plugin/src/ios/podfile.ts +20 -23
- package/plugin/src/pluginConfig.ts +4 -2
- package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
- package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
- package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
- package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
- package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
- package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
- package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
- package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
- package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
- package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
- package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
|
@@ -4,8 +4,10 @@ export interface PluginConfigType {
|
|
|
4
4
|
|
|
5
5
|
export interface PluginConfigTypeIos {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* @deprecated Firebase Apple SDK 13+ is SPM-only. Setting this to `true`
|
|
8
|
+
* fails Expo prebuild / `pod install` — CocoaPods no longer distributes Firebase.
|
|
9
|
+
* Remove this option and use `use_frameworks! :linkage => :dynamic` (via
|
|
10
|
+
* `expo-build-properties` `ios.useFrameworks: "dynamic"`).
|
|
9
11
|
*
|
|
10
12
|
* @platform ios iOS
|
|
11
13
|
*/
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.common;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import java.util.ArrayList;
|
|
21
|
-
import java.util.HashMap;
|
|
22
|
-
import java.util.List;
|
|
23
|
-
import java.util.function.Predicate;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Thread-safe id → handle registry. The lock only moves pointers; this class never invokes methods
|
|
27
|
-
* on stored values (no SDK {@code cancel}/{@code remove}). Callers {@link #take} or {@link
|
|
28
|
-
* #takeAll}, then act on the returned object(s) outside the lock.
|
|
29
|
-
*
|
|
30
|
-
* <p>{@link #put} is unique: an occupied id throws {@link RNFBHandleCollisionException}. There is
|
|
31
|
-
* no upsert. Use {@link #putIfAbsent} (first wins), {@link #putIfAbsentOrSame} (first wins or same
|
|
32
|
-
* instance), or {@link #putReplacing} (last wins) for atomic upsert. Replace at the call site with
|
|
33
|
-
* {@code take} then {@code put} only when neither helper fits.
|
|
34
|
-
*
|
|
35
|
-
* <p><strong>Do not lock on the map or on a {@code RNFBHandleMap} instance.</strong> Callers that
|
|
36
|
-
* synchronize on {@code this} (or on the internal map) can deadlock with the dedicated monitor.
|
|
37
|
-
* Android uses a private {@code lock} object; never expose it and never {@code synchronized (this)}
|
|
38
|
-
* around these methods.
|
|
39
|
-
*/
|
|
40
|
-
public class RNFBHandleMap<K, V> {
|
|
41
|
-
private final Object lock = new Object();
|
|
42
|
-
private final HashMap<K, V> map = new HashMap<>();
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Registers {@code handle} under {@code id}.
|
|
46
|
-
*
|
|
47
|
-
* @throws RNFBHandleCollisionException if {@code id} is already occupied
|
|
48
|
-
*/
|
|
49
|
-
public void put(K id, V handle) throws RNFBHandleCollisionException {
|
|
50
|
-
synchronized (lock) {
|
|
51
|
-
if (map.containsKey(id)) {
|
|
52
|
-
throw new RNFBHandleCollisionException(id);
|
|
53
|
-
}
|
|
54
|
-
map.put(id, handle);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Stores {@code handle} under {@code id} only when the id is free (first wins).
|
|
60
|
-
*
|
|
61
|
-
* @return {@code true} if stored, {@code false} if {@code id} was already occupied
|
|
62
|
-
*/
|
|
63
|
-
public boolean putIfAbsent(K id, V handle) {
|
|
64
|
-
synchronized (lock) {
|
|
65
|
-
if (map.containsKey(id)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
map.put(id, handle);
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Under one lock: stores {@code handle} when the id is free, or returns {@code true} when the
|
|
75
|
-
* existing mapping is the same instance ({@code ==}). Returns {@code false} when occupied by a
|
|
76
|
-
* different handle.
|
|
77
|
-
*/
|
|
78
|
-
public boolean putIfAbsentOrSame(K id, V handle) {
|
|
79
|
-
synchronized (lock) {
|
|
80
|
-
V existing = map.get(id);
|
|
81
|
-
if (existing == null) {
|
|
82
|
-
map.put(id, handle);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return existing == handle;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Atomically replaces the mapping for {@code id} (last wins). Returns the previous handle, or
|
|
91
|
-
* {@code null} if the id was free.
|
|
92
|
-
*/
|
|
93
|
-
public V putReplacing(K id, V handle) {
|
|
94
|
-
synchronized (lock) {
|
|
95
|
-
return map.put(id, handle);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Peeks at the handle for {@code id} without removing it (for emit while still registered).
|
|
101
|
-
*
|
|
102
|
-
* @return the handle, or {@code null} if absent
|
|
103
|
-
*/
|
|
104
|
-
public V get(K id) {
|
|
105
|
-
synchronized (lock) {
|
|
106
|
-
return map.get(id);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Removes and returns the handle for {@code id}.
|
|
112
|
-
*
|
|
113
|
-
* @return the handle, or {@code null} if absent
|
|
114
|
-
*/
|
|
115
|
-
public V take(K id) {
|
|
116
|
-
synchronized (lock) {
|
|
117
|
-
return map.remove(id);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* When {@code id} is mapped and {@code shouldTake} accepts the handle, removes and returns it;
|
|
123
|
-
* otherwise returns {@code null} and leaves the map unchanged. Lookup, predicate, and removal run
|
|
124
|
-
* under one lock — use for check-and-take that must not race with concurrent {@link #put} /
|
|
125
|
-
* {@link #take} on the same id.
|
|
126
|
-
*
|
|
127
|
-
* <p>The predicate runs under this map's lock; keep it lightweight (no SDK cancel/remove).
|
|
128
|
-
*/
|
|
129
|
-
public V takeIf(K id, Predicate<V> shouldTake) {
|
|
130
|
-
synchronized (lock) {
|
|
131
|
-
V value = map.get(id);
|
|
132
|
-
if (value != null && shouldTake.test(value)) {
|
|
133
|
-
return map.remove(id);
|
|
134
|
-
}
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Snapshot of current values, then clear. Cancel/remove each returned object after this method
|
|
141
|
-
* returns, not under this map's lock.
|
|
142
|
-
*/
|
|
143
|
-
public List<V> takeAll() {
|
|
144
|
-
synchronized (lock) {
|
|
145
|
-
List<V> values = new ArrayList<>(map.values());
|
|
146
|
-
map.clear();
|
|
147
|
-
return values;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.common;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import java.util.ArrayList;
|
|
21
|
-
import java.util.HashMap;
|
|
22
|
-
import java.util.List;
|
|
23
|
-
import java.util.Map;
|
|
24
|
-
import java.util.concurrent.ExecutorService;
|
|
25
|
-
import java.util.concurrent.LinkedBlockingQueue;
|
|
26
|
-
import java.util.concurrent.RejectedExecutionException;
|
|
27
|
-
import java.util.concurrent.RejectedExecutionHandler;
|
|
28
|
-
import java.util.concurrent.SynchronousQueue;
|
|
29
|
-
import java.util.concurrent.ThreadPoolExecutor;
|
|
30
|
-
import java.util.concurrent.TimeUnit;
|
|
31
|
-
|
|
32
|
-
public class TaskExecutorService {
|
|
33
|
-
private static final String MAXIMUM_POOL_SIZE_KEY = "android_task_executor_maximum_pool_size";
|
|
34
|
-
private static final String KEEP_ALIVE_SECONDS_KEY = "android_task_executor_keep_alive_seconds";
|
|
35
|
-
|
|
36
|
-
private final String name;
|
|
37
|
-
private final int maximumPoolSize;
|
|
38
|
-
private final int keepAliveSeconds;
|
|
39
|
-
private static final Map<String, ExecutorService> executors = new HashMap<>();
|
|
40
|
-
|
|
41
|
-
public TaskExecutorService(String name) {
|
|
42
|
-
this.name = name;
|
|
43
|
-
ReactNativeFirebaseJSON json = ReactNativeFirebaseJSON.getSharedInstance();
|
|
44
|
-
this.maximumPoolSize = json.getIntValue(MAXIMUM_POOL_SIZE_KEY, 1);
|
|
45
|
-
this.keepAliveSeconds = json.getIntValue(KEEP_ALIVE_SECONDS_KEY, 3);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public ExecutorService getExecutor() {
|
|
49
|
-
boolean isTransactional = maximumPoolSize <= 1;
|
|
50
|
-
return getExecutor(isTransactional, "");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public ExecutorService getTransactionalExecutor() {
|
|
54
|
-
return getExecutor(true, "");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public ExecutorService getTransactionalExecutor(String identifier) {
|
|
58
|
-
String executorIdentifier = maximumPoolSize != 0 ? identifier : "";
|
|
59
|
-
return getExecutor(true, executorIdentifier);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public ExecutorService getExecutor(boolean isTransactional, String identifier) {
|
|
63
|
-
String executorName = getExecutorName(isTransactional, identifier);
|
|
64
|
-
synchronized (executors) {
|
|
65
|
-
ExecutorService existingExecutor = executors.get(executorName);
|
|
66
|
-
if (existingExecutor == null) {
|
|
67
|
-
ExecutorService newExecutor = getNewExecutor(isTransactional);
|
|
68
|
-
executors.put(executorName, newExecutor);
|
|
69
|
-
return newExecutor;
|
|
70
|
-
}
|
|
71
|
-
return existingExecutor;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private ExecutorService getNewExecutor(boolean isTransactional) {
|
|
76
|
-
if (isTransactional) {
|
|
77
|
-
// A bare Executors.newSingleThreadExecutor() has no rejection handler, so a
|
|
78
|
-
// play-services Task completing after shutdown() (module invalidation racing
|
|
79
|
-
// in-flight work, e.g. App Check attestation or Auth network calls finishing
|
|
80
|
-
// while the React instance is torn down) posts to the dead executor and
|
|
81
|
-
// crashes the process with an uncaught RejectedExecutionException. Use an
|
|
82
|
-
// equivalent single-thread pool that discards work arriving after shutdown.
|
|
83
|
-
ThreadPoolExecutor transactionalExecutor =
|
|
84
|
-
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
|
85
|
-
transactionalExecutor.setRejectedExecutionHandler(discardAfterShutdown);
|
|
86
|
-
return transactionalExecutor;
|
|
87
|
-
} else {
|
|
88
|
-
ThreadPoolExecutor threadPoolExecutor =
|
|
89
|
-
new ThreadPoolExecutor(
|
|
90
|
-
0, maximumPoolSize, keepAliveSeconds, TimeUnit.SECONDS, new SynchronousQueue<>());
|
|
91
|
-
threadPoolExecutor.setRejectedExecutionHandler(executeInFallback);
|
|
92
|
-
return threadPoolExecutor;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private static final RejectedExecutionHandler discardAfterShutdown =
|
|
97
|
-
(r, executor) -> {
|
|
98
|
-
// isShutdown() remains true through the terminating and terminated states,
|
|
99
|
-
// so it is the only check needed to detect work arriving after shutdown.
|
|
100
|
-
if (executor.isShutdown()) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// Unreachable with an unbounded queue, but preserve AbortPolicy semantics
|
|
104
|
-
// for any rejection that is not caused by shutdown.
|
|
105
|
-
throw new RejectedExecutionException("Task " + r + " rejected from " + executor);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
private final RejectedExecutionHandler executeInFallback =
|
|
109
|
-
(r, executor) -> {
|
|
110
|
-
// isShutdown() remains true through the terminating and terminated states,
|
|
111
|
-
// so it is the only check needed to detect work arriving after shutdown.
|
|
112
|
-
if (executor.isShutdown()) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
ExecutorService fallbackExecutor = getTransactionalExecutor();
|
|
116
|
-
fallbackExecutor.execute(r);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
public String getExecutorName(boolean isTransactional, String identifier) {
|
|
120
|
-
if (isTransactional) {
|
|
121
|
-
return name + "TransactionalExecutor" + identifier;
|
|
122
|
-
}
|
|
123
|
-
return name + "Executor" + identifier;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
public void shutdown() {
|
|
127
|
-
synchronized (executors) {
|
|
128
|
-
List<String> existingExecutorNames = new ArrayList<>(executors.keySet());
|
|
129
|
-
for (String executorName : existingExecutorNames) {
|
|
130
|
-
if (!executorName.startsWith(name)) {
|
|
131
|
-
executors.remove(executorName);
|
|
132
|
-
} else {
|
|
133
|
-
removeExecutor(executorName);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public void removeExecutor(String executorName) {
|
|
140
|
-
synchronized (executors) {
|
|
141
|
-
ExecutorService existingExecutor = executors.get(executorName);
|
|
142
|
-
if (existingExecutor != null) {
|
|
143
|
-
existingExecutor.shutdownNow();
|
|
144
|
-
executors.remove(executorName);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.common;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import android.content.Context;
|
|
21
|
-
import java.util.HashMap;
|
|
22
|
-
import java.util.Map;
|
|
23
|
-
import java.util.concurrent.ExecutorService;
|
|
24
|
-
import javax.annotation.OverridingMethodsMustInvokeSuper;
|
|
25
|
-
|
|
26
|
-
public class UniversalFirebaseModule {
|
|
27
|
-
private final TaskExecutorService executorService;
|
|
28
|
-
|
|
29
|
-
private final Context context;
|
|
30
|
-
private final String serviceName;
|
|
31
|
-
|
|
32
|
-
public UniversalFirebaseModule(Context context, String serviceName) {
|
|
33
|
-
this.context = context;
|
|
34
|
-
this.serviceName = serviceName;
|
|
35
|
-
this.executorService = new TaskExecutorService(getName());
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public Context getContext() {
|
|
39
|
-
return context;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public Context getApplicationContext() {
|
|
43
|
-
return getContext().getApplicationContext();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public ExecutorService getExecutor() {
|
|
47
|
-
return executorService.getExecutor();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public String getName() {
|
|
51
|
-
return "Universal" + serviceName + "Module";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@OverridingMethodsMustInvokeSuper
|
|
55
|
-
public void onTearDown() {
|
|
56
|
-
executorService.shutdown();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public Map<String, Object> getConstants() {
|
|
60
|
-
return new HashMap<>();
|
|
61
|
-
}
|
|
62
|
-
}
|
package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.common;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import android.content.Context;
|
|
21
|
-
import android.content.SharedPreferences;
|
|
22
|
-
import io.invertase.firebase.app.ReactNativeFirebaseApp;
|
|
23
|
-
|
|
24
|
-
public class UniversalFirebasePreferences {
|
|
25
|
-
private static final String PREFERENCES_FILE = "io.invertase.firebase";
|
|
26
|
-
private static UniversalFirebasePreferences sharedInstance = new UniversalFirebasePreferences();
|
|
27
|
-
private SharedPreferences preferences;
|
|
28
|
-
|
|
29
|
-
public static UniversalFirebasePreferences getSharedInstance() {
|
|
30
|
-
return sharedInstance;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public boolean contains(String key) {
|
|
34
|
-
return getPreferences().contains(key);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Boolean
|
|
38
|
-
public void setBooleanValue(String key, boolean value) {
|
|
39
|
-
getPreferences().edit().putBoolean(key, value).apply();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public boolean getBooleanValue(String key, boolean defaultValue) {
|
|
43
|
-
return getPreferences().getBoolean(key, defaultValue);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Int
|
|
47
|
-
public void setIntValue(String key, int value) {
|
|
48
|
-
getPreferences().edit().putInt(key, value).apply();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public int getIntValue(String key, int defaultValue) {
|
|
52
|
-
return getPreferences().getInt(key, defaultValue);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Long
|
|
56
|
-
public void setLongValue(String key, long value) {
|
|
57
|
-
getPreferences().edit().putLong(key, value).apply();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public long getLongValue(String key, long defaultValue) {
|
|
61
|
-
return getPreferences().getLong(key, defaultValue);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// String
|
|
65
|
-
public void setStringValue(String key, String value) {
|
|
66
|
-
getPreferences().edit().putString(key, value).apply();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public String getStringValue(String key, String defaultValue) {
|
|
70
|
-
return getPreferences().getString(key, defaultValue);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public void clearAll() {
|
|
74
|
-
getPreferences().edit().clear().apply();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Note the caller is responsible for calling apply() or commit() on the
|
|
78
|
-
// returned SharedPreferences.Editor object for the remove to take affect
|
|
79
|
-
public SharedPreferences.Editor remove(String key) {
|
|
80
|
-
return getPreferences().edit().remove(key);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private SharedPreferences getPreferences() {
|
|
84
|
-
if (preferences == null) {
|
|
85
|
-
preferences =
|
|
86
|
-
ReactNativeFirebaseApp.getApplicationContext()
|
|
87
|
-
.getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE);
|
|
88
|
-
}
|
|
89
|
-
return preferences;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
package io.invertase.firebase.app;
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this library except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import android.util.Log;
|
|
21
|
-
import com.facebook.fbreact.specs.NativeRNFBTurboAppSpec;
|
|
22
|
-
import com.facebook.react.bridge.LifecycleEventListener;
|
|
23
|
-
import com.facebook.react.bridge.Promise;
|
|
24
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
25
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
26
|
-
import com.facebook.react.bridge.WritableMap;
|
|
27
|
-
import com.google.firebase.FirebaseApp;
|
|
28
|
-
import io.invertase.firebase.common.RCTConvertFirebase;
|
|
29
|
-
import io.invertase.firebase.common.ReactNativeFirebaseEvent;
|
|
30
|
-
import io.invertase.firebase.common.ReactNativeFirebaseEventEmitter;
|
|
31
|
-
import io.invertase.firebase.common.ReactNativeFirebaseJSON;
|
|
32
|
-
import io.invertase.firebase.common.ReactNativeFirebaseMeta;
|
|
33
|
-
import io.invertase.firebase.common.ReactNativeFirebasePreferences;
|
|
34
|
-
import java.util.ArrayList;
|
|
35
|
-
import java.util.HashMap;
|
|
36
|
-
import java.util.List;
|
|
37
|
-
import java.util.Map;
|
|
38
|
-
import java.util.concurrent.ConcurrentHashMap;
|
|
39
|
-
|
|
40
|
-
public class NativeRNFBTurboApp extends NativeRNFBTurboAppSpec implements LifecycleEventListener {
|
|
41
|
-
private static final String TAG = "App";
|
|
42
|
-
|
|
43
|
-
public static final Map<String, String> authDomains = new ConcurrentHashMap<>();
|
|
44
|
-
|
|
45
|
-
NativeRNFBTurboApp(ReactApplicationContext reactContext) {
|
|
46
|
-
super(reactContext);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Override
|
|
50
|
-
public void initialize() {
|
|
51
|
-
super.initialize();
|
|
52
|
-
ReactApplicationContext reactContext = getReactApplicationContext();
|
|
53
|
-
// Register unconditionally. When the host is already RESUMED, addLifecycleEventListener
|
|
54
|
-
// posts onHostResume onto the UI queue asynchronously (it is not a synchronous call), so
|
|
55
|
-
// the explicit attach below is the primary path; resume remains best-effort convergence
|
|
56
|
-
// for later host flips. Stale-generation attaches are rejected or held pending by
|
|
57
|
-
// attachReactContext's fail-closed current-context arbitration.
|
|
58
|
-
reactContext.addLifecycleEventListener(this);
|
|
59
|
-
ReactNativeFirebaseEventEmitter.getSharedInstance().attachReactContext(reactContext);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Override
|
|
63
|
-
public void invalidate() {
|
|
64
|
-
ReactApplicationContext reactContext = getReactApplicationContext();
|
|
65
|
-
reactContext.removeLifecycleEventListener(this);
|
|
66
|
-
// Identity-guarded inside the emitter: only clears state belonging to this dying context,
|
|
67
|
-
// never state a replacement runtime has already installed.
|
|
68
|
-
ReactNativeFirebaseEventEmitter.getSharedInstance().detachReactContext(reactContext);
|
|
69
|
-
super.invalidate();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@Override
|
|
73
|
-
public void onHostResume() {
|
|
74
|
-
// Re-attaching also flushes any events queued while no runtime was able to receive them.
|
|
75
|
-
ReactNativeFirebaseEventEmitter.getSharedInstance()
|
|
76
|
-
.attachReactContext(getReactApplicationContext());
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@Override
|
|
80
|
-
public void onHostPause() {
|
|
81
|
-
// no-op, required by LifecycleEventListener
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Override
|
|
85
|
-
public void onHostDestroy() {
|
|
86
|
-
// no-op, required by LifecycleEventListener
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Override
|
|
90
|
-
protected Map<String, Object> getTypedExportedConstants() {
|
|
91
|
-
Map<String, Object> constants = new HashMap<>();
|
|
92
|
-
List<Map<String, Object>> appsList = new ArrayList<>();
|
|
93
|
-
List<FirebaseApp> firebaseApps = FirebaseApp.getApps(getReactApplicationContext());
|
|
94
|
-
|
|
95
|
-
for (FirebaseApp app : firebaseApps) {
|
|
96
|
-
appsList.add(RCTConvertFirebase.firebaseAppToMap(app));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
constants.put("NATIVE_FIREBASE_APPS", appsList);
|
|
100
|
-
constants.put("FIREBASE_RAW_JSON", ReactNativeFirebaseJSON.getSharedInstance().getRawJSON());
|
|
101
|
-
|
|
102
|
-
return constants;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@Override
|
|
106
|
-
public void initializeApp(ReadableMap options, ReadableMap appConfig, Promise promise) {
|
|
107
|
-
FirebaseApp firebaseApp =
|
|
108
|
-
RCTConvertFirebase.readableMapToFirebaseApp(
|
|
109
|
-
options, appConfig, getReactApplicationContext());
|
|
110
|
-
NativeRNFBTurboApp.configureAuthDomain(
|
|
111
|
-
appConfig.getString("name"), options.getString("authDomain"));
|
|
112
|
-
|
|
113
|
-
WritableMap firebaseAppMap = RCTConvertFirebase.firebaseAppToWritableMap(firebaseApp);
|
|
114
|
-
promise.resolve(firebaseAppMap);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public static void configureAuthDomain(String name, String authDomain) {
|
|
118
|
-
if (authDomain != null) {
|
|
119
|
-
Log.d(TAG, name + " custom authDomain " + authDomain);
|
|
120
|
-
authDomains.put(name, authDomain);
|
|
121
|
-
} else {
|
|
122
|
-
authDomains.remove(name);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
@Override
|
|
127
|
-
public void setAutomaticDataCollectionEnabled(String appName, boolean enabled) {
|
|
128
|
-
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
|
|
129
|
-
firebaseApp.setDataCollectionDefaultEnabled(enabled);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@Override
|
|
133
|
-
public void deleteApp(String appName, Promise promise) {
|
|
134
|
-
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
|
|
135
|
-
|
|
136
|
-
if (firebaseApp != null) {
|
|
137
|
-
firebaseApp.delete();
|
|
138
|
-
authDomains.remove(appName);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
promise.resolve(null);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
@Override
|
|
145
|
-
public void eventsNotifyReady(boolean ready) {
|
|
146
|
-
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
|
147
|
-
emitter.notifyJsReady(ready);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@Override
|
|
151
|
-
public void eventsGetListeners(Promise promise) {
|
|
152
|
-
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
|
153
|
-
promise.resolve(emitter.getListenersMap());
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
@Override
|
|
157
|
-
public void eventsPing(String eventName, ReadableMap eventBody, Promise promise) {
|
|
158
|
-
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
|
159
|
-
emitter.sendEvent(
|
|
160
|
-
new ReactNativeFirebaseEvent(
|
|
161
|
-
eventName, RCTConvertFirebase.readableMapToWritableMap(eventBody)));
|
|
162
|
-
promise.resolve(RCTConvertFirebase.readableMapToWritableMap(eventBody));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
@Override
|
|
166
|
-
public void eventsAddListener(String eventName) {
|
|
167
|
-
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
|
168
|
-
emitter.addListener(eventName);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@Override
|
|
172
|
-
public void eventsRemoveListener(String eventName, boolean all) {
|
|
173
|
-
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
|
174
|
-
emitter.removeListener(eventName, all);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@Override
|
|
178
|
-
public void addListener(String eventName) {
|
|
179
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@Override
|
|
183
|
-
public void removeListeners(double count) {
|
|
184
|
-
// Keep: Required for RN built in Event Emitter Calls.
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
@Override
|
|
188
|
-
public void metaGetAll(Promise promise) {
|
|
189
|
-
promise.resolve(ReactNativeFirebaseMeta.getSharedInstance().getAll());
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@Override
|
|
193
|
-
public void jsonGetAll(Promise promise) {
|
|
194
|
-
promise.resolve(ReactNativeFirebaseJSON.getSharedInstance().getAll());
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
@Override
|
|
198
|
-
public void preferencesSetBool(String key, boolean value, Promise promise) {
|
|
199
|
-
ReactNativeFirebasePreferences.getSharedInstance().setBooleanValue(key, value);
|
|
200
|
-
promise.resolve(null);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@Override
|
|
204
|
-
public void preferencesSetString(String key, String value, Promise promise) {
|
|
205
|
-
ReactNativeFirebasePreferences.getSharedInstance().setStringValue(key, value);
|
|
206
|
-
promise.resolve(null);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
@Override
|
|
210
|
-
public void preferencesGetAll(Promise promise) {
|
|
211
|
-
promise.resolve(ReactNativeFirebasePreferences.getSharedInstance().getAll());
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
@Override
|
|
215
|
-
public void preferencesClearAll(Promise promise) {
|
|
216
|
-
ReactNativeFirebasePreferences.getSharedInstance().clearAll();
|
|
217
|
-
promise.resolve(null);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
@Override
|
|
221
|
-
public void setLogLevel(String logLevel) {
|
|
222
|
-
// Android uses Firebase SDK log level via manifest; no-op at runtime.
|
|
223
|
-
}
|
|
224
|
-
}
|