@react-native-firebase/database 25.1.0 → 26.1.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.
Files changed (136) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/RNFBDatabase.podspec +20 -7
  3. package/android/build.gradle +19 -0
  4. package/android/src/main/java/io/invertase/firebase/database/UniversalFirebaseDatabaseModule.java +4 -14
  5. package/android/src/reactnative/java/io/invertase/firebase/database/DatabaseTurboModuleSupport.java +56 -0
  6. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseModule.java → NativeRNFBTurboDatabase.java} +16 -36
  7. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseOnDisconnectModule.java → NativeRNFBTurboDatabaseOnDisconnect.java} +19 -14
  8. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseQueryModule.java → NativeRNFBTurboDatabaseQuery.java} +41 -105
  9. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseReferenceModule.java → NativeRNFBTurboDatabaseReference.java} +27 -20
  10. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseTransactionModule.java → NativeRNFBTurboDatabaseTransaction.java} +41 -19
  11. package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabasePackage.java +5 -5
  12. package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseTransactionHandler.java +11 -0
  13. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseOnDisconnectSpec.java +55 -0
  14. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseQuerySpec.java +52 -0
  15. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseReferenceSpec.java +55 -0
  16. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseSpec.java +57 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseTransactionSpec.java +42 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/CMakeLists.txt +36 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules-generated.cpp +182 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules.h +63 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI.h +440 -0
  23. package/dist/module/DatabaseDataSnapshot.js +20 -6
  24. package/dist/module/DatabaseDataSnapshot.js.map +1 -1
  25. package/dist/module/DatabaseOnDisconnect.js.map +1 -1
  26. package/dist/module/DatabaseQuery.js +13 -16
  27. package/dist/module/DatabaseQuery.js.map +1 -1
  28. package/dist/module/DatabaseReference.js +16 -15
  29. package/dist/module/DatabaseReference.js.map +1 -1
  30. package/dist/module/DatabaseSyncTree.js +5 -4
  31. package/dist/module/DatabaseSyncTree.js.map +1 -1
  32. package/dist/module/DatabaseThenableReference.js +1 -2
  33. package/dist/module/DatabaseThenableReference.js.map +1 -1
  34. package/dist/module/index.js +210 -5
  35. package/dist/module/index.js.map +1 -1
  36. package/dist/module/modular/query.js +14 -15
  37. package/dist/module/modular/query.js.map +1 -1
  38. package/dist/module/modular/transaction.js +1 -2
  39. package/dist/module/modular/transaction.js.map +1 -1
  40. package/dist/module/version.js +1 -1
  41. package/dist/module/web/RNFBDatabaseModule.js +4 -8
  42. package/dist/module/web/RNFBDatabaseModule.js.map +1 -1
  43. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts +9 -7
  44. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts.map +1 -1
  45. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts +3 -3
  46. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts.map +1 -1
  47. package/dist/typescript/lib/DatabaseQuery.d.ts +18 -18
  48. package/dist/typescript/lib/DatabaseQuery.d.ts.map +1 -1
  49. package/dist/typescript/lib/DatabaseReference.d.ts +8 -8
  50. package/dist/typescript/lib/DatabaseReference.d.ts.map +1 -1
  51. package/dist/typescript/lib/DatabaseSyncTree.d.ts +2 -2
  52. package/dist/typescript/lib/DatabaseSyncTree.d.ts.map +1 -1
  53. package/dist/typescript/lib/DatabaseThenableReference.d.ts +8 -8
  54. package/dist/typescript/lib/DatabaseThenableReference.d.ts.map +1 -1
  55. package/dist/typescript/lib/index.d.ts +57 -4
  56. package/dist/typescript/lib/index.d.ts.map +1 -1
  57. package/dist/typescript/lib/modular/query.d.ts.map +1 -1
  58. package/dist/typescript/lib/modular/transaction.d.ts.map +1 -1
  59. package/dist/typescript/lib/types/database.d.ts +5 -5
  60. package/dist/typescript/lib/types/database.d.ts.map +1 -1
  61. package/dist/typescript/lib/types/internal.d.ts +32 -31
  62. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  63. package/dist/typescript/lib/version.d.ts +1 -1
  64. package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts.map +1 -1
  65. package/ios/RNFBDatabase/RNFBDatabaseCommon.h +13 -6
  66. package/ios/RNFBDatabase/RNFBDatabaseCommon.m +2 -10
  67. package/ios/RNFBDatabase/RNFBDatabaseConstants.h +25 -0
  68. package/ios/RNFBDatabase/RNFBDatabaseModule.mm +90 -0
  69. package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.h +39 -0
  70. package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.m +64 -0
  71. package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectHelper.h +59 -0
  72. package/ios/RNFBDatabase/{RNFBDatabaseOnDisconnectModule.m → RNFBDatabaseOnDisconnectHelper.m} +41 -47
  73. package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectModule.mm +121 -0
  74. package/ios/RNFBDatabase/RNFBDatabaseQuery.h +11 -0
  75. package/ios/RNFBDatabase/RNFBDatabaseQueryHelper.h +49 -0
  76. package/ios/RNFBDatabase/{RNFBDatabaseQueryModule.m → RNFBDatabaseQueryHelper.m} +77 -91
  77. package/ios/RNFBDatabase/RNFBDatabaseQueryModule.h +5 -1
  78. package/ios/RNFBDatabase/RNFBDatabaseQueryModule.mm +105 -0
  79. package/ios/RNFBDatabase/RNFBDatabaseQueue.h +29 -0
  80. package/ios/RNFBDatabase/RNFBDatabaseQueue.m +31 -0
  81. package/ios/RNFBDatabase/RNFBDatabaseReferenceHelper.h +59 -0
  82. package/ios/RNFBDatabase/{RNFBDatabaseReferenceModule.m → RNFBDatabaseReferenceHelper.m} +42 -48
  83. package/ios/RNFBDatabase/RNFBDatabaseReferenceModule.mm +125 -0
  84. package/ios/RNFBDatabase/RNFBDatabaseTransactionHelper.h +38 -0
  85. package/ios/RNFBDatabase/{RNFBDatabaseTransactionModule.m → RNFBDatabaseTransactionHelper.m} +52 -51
  86. package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.h +0 -1
  87. package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.mm +86 -0
  88. package/ios/RNFBDatabase.xcodeproj/project.pbxproj +24 -24
  89. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  90. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  91. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  92. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  93. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  94. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  95. package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules-generated.mm +254 -0
  96. package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules.h +264 -0
  97. package/ios/generated/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
  98. package/ios/generated/RNFBDatabaseTurboModulesJSI.h +440 -0
  99. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  100. package/lib/DatabaseDataSnapshot.ts +43 -38
  101. package/lib/DatabaseOnDisconnect.ts +3 -3
  102. package/lib/DatabaseQuery.ts +45 -77
  103. package/lib/DatabaseReference.ts +37 -66
  104. package/lib/DatabaseSyncTree.ts +8 -11
  105. package/lib/DatabaseThenableReference.ts +9 -17
  106. package/lib/index.ts +325 -6
  107. package/lib/modular/query.ts +14 -70
  108. package/lib/modular/transaction.ts +1 -4
  109. package/lib/types/database.ts +5 -5
  110. package/lib/types/internal.ts +31 -56
  111. package/lib/version.ts +1 -1
  112. package/lib/web/RNFBDatabaseModule.ts +6 -10
  113. package/package.json +26 -4
  114. package/react-native.config.js +10 -0
  115. package/specs/NativeRNFBTurboDatabase.ts +13 -0
  116. package/specs/NativeRNFBTurboDatabaseOnDisconnect.ts +18 -0
  117. package/specs/NativeRNFBTurboDatabaseQuery.ts +25 -0
  118. package/specs/NativeRNFBTurboDatabaseReference.ts +13 -0
  119. package/specs/NativeRNFBTurboDatabaseTransaction.ts +16 -0
  120. package/typedoc.json +1 -1
  121. package/dist/module/modular.js +0 -76
  122. package/dist/module/modular.js.map +0 -1
  123. package/dist/module/namespaced.js +0 -147
  124. package/dist/module/namespaced.js.map +0 -1
  125. package/dist/module/types/namespaced.js +0 -67
  126. package/dist/module/types/namespaced.js.map +0 -1
  127. package/dist/typescript/lib/modular.d.ts +0 -24
  128. package/dist/typescript/lib/modular.d.ts.map +0 -1
  129. package/dist/typescript/lib/namespaced.d.ts +0 -13
  130. package/dist/typescript/lib/namespaced.d.ts.map +0 -1
  131. package/dist/typescript/lib/types/namespaced.d.ts +0 -1230
  132. package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
  133. package/ios/RNFBDatabase/RNFBDatabaseModule.m +0 -100
  134. package/lib/modular.ts +0 -134
  135. package/lib/namespaced.ts +0 -253
  136. package/lib/types/namespaced.ts +0 -1366
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <React/RCTUtils.h>
19
+
20
+ #import "RNFBDatabaseQueryHelper.h"
21
+ #import "RNFBDatabaseQueryModule.h"
22
+ #import "RNFBDatabaseQueue.h"
23
+ #import "RNFBDatabaseTurboModules.h"
24
+
25
+ // NOTE: This module deliberately never imports Firebase Database headers.
26
+ // See RNFBDatabaseModule.mm for rationale. All Firebase Database calls and
27
+ // query/listener bookkeeping live in the plain Objective-C
28
+ // `RNFBDatabaseQueryHelper`.
29
+
30
+ @interface RNFBDatabaseQueryModule () <NativeRNFBTurboDatabaseQuerySpec, RCTBridgeModule>
31
+ @end
32
+
33
+ @implementation RNFBDatabaseQueryModule
34
+ #pragma mark -
35
+ #pragma mark Module Setup
36
+
37
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
38
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
39
+ return std::make_shared<facebook::react::NativeRNFBTurboDatabaseQuerySpecJSI>(params);
40
+ }
41
+
42
+ RCT_EXPORT_MODULE(NativeRNFBTurboDatabaseQuery);
43
+
44
+ + (BOOL)requiresMainQueueSetup {
45
+ return NO;
46
+ }
47
+
48
+ - (dispatch_queue_t)methodQueue {
49
+ return [RNFBDatabaseQueue getDispatchQueue];
50
+ }
51
+
52
+ - (void)dealloc {
53
+ [self invalidate];
54
+ }
55
+
56
+ - (void)invalidate {
57
+ [RNFBDatabaseQueryHelper invalidate];
58
+ }
59
+
60
+ #pragma mark -
61
+ #pragma mark Firebase Database
62
+
63
+ - (void)once:(NSString *)app
64
+ dbURL:(NSString *)dbURL
65
+ path:(NSString *)path
66
+ modifiers:(NSArray *)modifiers
67
+ eventType:(NSString *)eventType
68
+ resolve:(RCTPromiseResolveBlock)resolve
69
+ reject:(RCTPromiseRejectBlock)reject {
70
+ [RNFBDatabaseQueryHelper once:app
71
+ dbURL:dbURL
72
+ path:path
73
+ modifiers:modifiers
74
+ eventType:eventType
75
+ resolve:resolve
76
+ reject:reject];
77
+ }
78
+
79
+ - (void)on:(NSString *)app dbURL:(NSString *)dbURL props:(NSDictionary *)props {
80
+ [RNFBDatabaseQueryHelper on:app dbURL:dbURL props:props];
81
+ }
82
+
83
+ - (void)off:(NSString *)queryKey eventRegistrationKey:(NSString *)eventRegistrationKey {
84
+ [RNFBDatabaseQueryHelper off:queryKey eventRegistrationKey:eventRegistrationKey];
85
+ }
86
+
87
+ - (void)keepSynced:(NSString *)app
88
+ dbURL:(NSString *)dbURL
89
+ key:(NSString *)key
90
+ path:(NSString *)path
91
+ modifiers:(NSArray *)modifiers
92
+ enabled:(BOOL)value
93
+ resolve:(RCTPromiseResolveBlock)resolve
94
+ reject:(RCTPromiseRejectBlock)reject {
95
+ [RNFBDatabaseQueryHelper keepSynced:app
96
+ dbURL:dbURL
97
+ key:key
98
+ path:path
99
+ modifiers:modifiers
100
+ enabled:value
101
+ resolve:resolve
102
+ reject:reject];
103
+ }
104
+
105
+ @end
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <Foundation/Foundation.h>
19
+
20
+ // Deliberately Firebase-free: this header is imported by Objective-C++ (.mm)
21
+ // modules that must not pull in any Firebase Database headers directly (see
22
+ // RNFBDatabaseCommon.h for why). Keeping it isolated means the shared serial
23
+ // queue used as `methodQueue` can be obtained without ever importing
24
+ // Firebase from a .mm translation unit.
25
+ @interface RNFBDatabaseQueue : NSObject
26
+
27
+ + (dispatch_queue_t)getDispatchQueue;
28
+
29
+ @end
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import "RNFBDatabaseQueue.h"
19
+
20
+ @implementation RNFBDatabaseQueue
21
+
22
+ + (dispatch_queue_t)getDispatchQueue {
23
+ static dispatch_once_t once;
24
+ static dispatch_queue_t sharedInstance;
25
+ dispatch_once(&once, ^{
26
+ sharedInstance = dispatch_queue_create("io.invertase.firebase.database", DISPATCH_QUEUE_SERIAL);
27
+ });
28
+ return sharedInstance;
29
+ }
30
+
31
+ @end
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <Foundation/Foundation.h>
19
+ #import <React/RCTBridgeModule.h>
20
+
21
+ // See RNFBDatabaseModuleHelper.h for rationale: plain Objective-C helper
22
+ // that owns all `FIRDatabaseReference` calls for RNFBDatabaseReferenceModule.
23
+ @interface RNFBDatabaseReferenceHelper : NSObject
24
+
25
+ + (void)set:(NSString *)app
26
+ dbURL:(NSString *)dbURL
27
+ path:(NSString *)path
28
+ props:(NSDictionary *)props
29
+ resolve:(RCTPromiseResolveBlock)resolve
30
+ reject:(RCTPromiseRejectBlock)reject;
31
+
32
+ + (void)update:(NSString *)app
33
+ dbURL:(NSString *)dbURL
34
+ path:(NSString *)path
35
+ props:(NSDictionary *)props
36
+ resolve:(RCTPromiseResolveBlock)resolve
37
+ reject:(RCTPromiseRejectBlock)reject;
38
+
39
+ + (void)setWithPriority:(NSString *)app
40
+ dbURL:(NSString *)dbURL
41
+ path:(NSString *)path
42
+ props:(NSDictionary *)props
43
+ resolve:(RCTPromiseResolveBlock)resolve
44
+ reject:(RCTPromiseRejectBlock)reject;
45
+
46
+ + (void)remove:(NSString *)app
47
+ dbURL:(NSString *)dbURL
48
+ path:(NSString *)path
49
+ resolve:(RCTPromiseResolveBlock)resolve
50
+ reject:(RCTPromiseRejectBlock)reject;
51
+
52
+ + (void)setPriority:(NSString *)app
53
+ dbURL:(NSString *)dbURL
54
+ path:(NSString *)path
55
+ props:(NSDictionary *)props
56
+ resolve:(RCTPromiseResolveBlock)resolve
57
+ reject:(RCTPromiseRejectBlock)reject;
58
+
59
+ @end
@@ -15,32 +15,26 @@
15
15
  *
16
16
  */
17
17
 
18
+ #if __has_include(<Firebase/Firebase.h>)
18
19
  #import <Firebase/Firebase.h>
19
- #import <React/RCTUtils.h>
20
+ #else
21
+ @import FirebaseCore;
22
+ @import FirebaseDatabaseInternal;
23
+ #endif
20
24
 
25
+ #import "RNFBApp/RCTConvert+FIRApp.h"
21
26
  #import "RNFBDatabaseCommon.h"
22
- #import "RNFBDatabaseReferenceModule.h"
27
+ #import "RNFBDatabaseReferenceHelper.h"
23
28
 
24
- @implementation RNFBDatabaseReferenceModule
25
- #pragma mark -
26
- #pragma mark Module Setup
29
+ @implementation RNFBDatabaseReferenceHelper
27
30
 
28
- RCT_EXPORT_MODULE();
29
-
30
- - (dispatch_queue_t)methodQueue {
31
- return [RNFBDatabaseCommon getDispatchQueue];
32
- }
33
-
34
- #pragma mark -
35
- #pragma mark Firebase Database
36
-
37
- RCT_EXPORT_METHOD(set
38
- : (FIRApp *)firebaseApp
39
- : (NSString *)dbURL
40
- : (NSString *)path
41
- : (NSDictionary *)props
42
- : (RCTPromiseResolveBlock)resolve
43
- : (RCTPromiseRejectBlock)reject) {
31
+ + (void)set:(NSString *)app
32
+ dbURL:(NSString *)dbURL
33
+ path:(NSString *)path
34
+ props:(NSDictionary *)props
35
+ resolve:(RCTPromiseResolveBlock)resolve
36
+ reject:(RCTPromiseRejectBlock)reject {
37
+ FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
44
38
  FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
45
39
  FIRDatabaseReference *firDatabaseReference =
46
40
  [RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
@@ -55,13 +49,13 @@ RCT_EXPORT_METHOD(set
55
49
  }];
56
50
  }
57
51
 
58
- RCT_EXPORT_METHOD(update
59
- : (FIRApp *)firebaseApp
60
- : (NSString *)dbURL
61
- : (NSString *)path
62
- : (NSDictionary *)props
63
- : (RCTPromiseResolveBlock)resolve
64
- : (RCTPromiseRejectBlock)reject) {
52
+ + (void)update:(NSString *)app
53
+ dbURL:(NSString *)dbURL
54
+ path:(NSString *)path
55
+ props:(NSDictionary *)props
56
+ resolve:(RCTPromiseResolveBlock)resolve
57
+ reject:(RCTPromiseRejectBlock)reject {
58
+ FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
65
59
  FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
66
60
  FIRDatabaseReference *firDatabaseReference =
67
61
  [RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
@@ -76,13 +70,13 @@ RCT_EXPORT_METHOD(update
76
70
  }];
77
71
  }
78
72
 
79
- RCT_EXPORT_METHOD(setWithPriority
80
- : (FIRApp *)firebaseApp
81
- : (NSString *)dbURL
82
- : (NSString *)path
83
- : (NSDictionary *)props
84
- : (RCTPromiseResolveBlock)resolve
85
- : (RCTPromiseRejectBlock)reject) {
73
+ + (void)setWithPriority:(NSString *)app
74
+ dbURL:(NSString *)dbURL
75
+ path:(NSString *)path
76
+ props:(NSDictionary *)props
77
+ resolve:(RCTPromiseResolveBlock)resolve
78
+ reject:(RCTPromiseRejectBlock)reject {
79
+ FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
86
80
  FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
87
81
  FIRDatabaseReference *firDatabaseReference =
88
82
  [RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
@@ -98,12 +92,12 @@ RCT_EXPORT_METHOD(setWithPriority
98
92
  }];
99
93
  }
100
94
 
101
- RCT_EXPORT_METHOD(remove
102
- : (FIRApp *)firebaseApp
103
- : (NSString *)dbURL
104
- : (NSString *)path
105
- : (RCTPromiseResolveBlock)resolve
106
- : (RCTPromiseRejectBlock)reject) {
95
+ + (void)remove:(NSString *)app
96
+ dbURL:(NSString *)dbURL
97
+ path:(NSString *)path
98
+ resolve:(RCTPromiseResolveBlock)resolve
99
+ reject:(RCTPromiseRejectBlock)reject {
100
+ FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
107
101
  FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
108
102
  FIRDatabaseReference *firDatabaseReference =
109
103
  [RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
@@ -118,13 +112,13 @@ RCT_EXPORT_METHOD(remove
118
112
  }];
119
113
  }
120
114
 
121
- RCT_EXPORT_METHOD(setPriority
122
- : (FIRApp *)firebaseApp
123
- : (NSString *)dbURL
124
- : (NSString *)path
125
- : (NSDictionary *)props
126
- : (RCTPromiseResolveBlock)resolve
127
- : (RCTPromiseRejectBlock)reject) {
115
+ + (void)setPriority:(NSString *)app
116
+ dbURL:(NSString *)dbURL
117
+ path:(NSString *)path
118
+ props:(NSDictionary *)props
119
+ resolve:(RCTPromiseResolveBlock)resolve
120
+ reject:(RCTPromiseRejectBlock)reject {
121
+ FIRApp *firebaseApp = [RCTConvert firAppFromString:app];
128
122
  FIRDatabase *firDatabase = [RNFBDatabaseCommon getDatabaseForApp:firebaseApp dbURL:dbURL];
129
123
  FIRDatabaseReference *firDatabaseReference =
130
124
  [RNFBDatabaseCommon getReferenceForDatabase:firDatabase path:path];
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <React/RCTUtils.h>
19
+
20
+ #import "RNFBDatabaseQueue.h"
21
+ #import "RNFBDatabaseReferenceHelper.h"
22
+ #import "RNFBDatabaseReferenceModule.h"
23
+ #import "RNFBDatabaseTurboModules.h"
24
+
25
+ // NOTE: This module deliberately never imports Firebase Database headers.
26
+ // See RNFBDatabaseModule.mm for rationale. All Firebase Database calls are
27
+ // delegated to the plain Objective-C `RNFBDatabaseReferenceHelper`.
28
+
29
+ @interface RNFBDatabaseReferenceModule () <NativeRNFBTurboDatabaseReferenceSpec, RCTBridgeModule>
30
+ @end
31
+
32
+ @implementation RNFBDatabaseReferenceModule
33
+ #pragma mark -
34
+ #pragma mark Module Setup
35
+
36
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
37
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
38
+ return std::make_shared<facebook::react::NativeRNFBTurboDatabaseReferenceSpecJSI>(params);
39
+ }
40
+
41
+ RCT_EXPORT_MODULE(NativeRNFBTurboDatabaseReference);
42
+
43
+ + (BOOL)requiresMainQueueSetup {
44
+ return NO;
45
+ }
46
+
47
+ - (dispatch_queue_t)methodQueue {
48
+ return [RNFBDatabaseQueue getDispatchQueue];
49
+ }
50
+
51
+ - (void)dealloc {
52
+ [self invalidate];
53
+ }
54
+
55
+ - (void)invalidate {
56
+ }
57
+
58
+ #pragma mark -
59
+ #pragma mark Firebase Database
60
+
61
+ - (void)set:(NSString *)app
62
+ dbURL:(NSString *)dbURL
63
+ path:(NSString *)path
64
+ props:(NSDictionary *)props
65
+ resolve:(RCTPromiseResolveBlock)resolve
66
+ reject:(RCTPromiseRejectBlock)reject {
67
+ [RNFBDatabaseReferenceHelper set:app
68
+ dbURL:dbURL
69
+ path:path
70
+ props:props
71
+ resolve:resolve
72
+ reject:reject];
73
+ }
74
+
75
+ - (void)update:(NSString *)app
76
+ dbURL:(NSString *)dbURL
77
+ path:(NSString *)path
78
+ props:(NSDictionary *)props
79
+ resolve:(RCTPromiseResolveBlock)resolve
80
+ reject:(RCTPromiseRejectBlock)reject {
81
+ [RNFBDatabaseReferenceHelper update:app
82
+ dbURL:dbURL
83
+ path:path
84
+ props:props
85
+ resolve:resolve
86
+ reject:reject];
87
+ }
88
+
89
+ - (void)setWithPriority:(NSString *)app
90
+ dbURL:(NSString *)dbURL
91
+ path:(NSString *)path
92
+ props:(NSDictionary *)props
93
+ resolve:(RCTPromiseResolveBlock)resolve
94
+ reject:(RCTPromiseRejectBlock)reject {
95
+ [RNFBDatabaseReferenceHelper setWithPriority:app
96
+ dbURL:dbURL
97
+ path:path
98
+ props:props
99
+ resolve:resolve
100
+ reject:reject];
101
+ }
102
+
103
+ - (void)remove:(NSString *)app
104
+ dbURL:(NSString *)dbURL
105
+ path:(NSString *)path
106
+ resolve:(RCTPromiseResolveBlock)resolve
107
+ reject:(RCTPromiseRejectBlock)reject {
108
+ [RNFBDatabaseReferenceHelper remove:app dbURL:dbURL path:path resolve:resolve reject:reject];
109
+ }
110
+
111
+ - (void)setPriority:(NSString *)app
112
+ dbURL:(NSString *)dbURL
113
+ path:(NSString *)path
114
+ props:(NSDictionary *)props
115
+ resolve:(RCTPromiseResolveBlock)resolve
116
+ reject:(RCTPromiseRejectBlock)reject {
117
+ [RNFBDatabaseReferenceHelper setPriority:app
118
+ dbURL:dbURL
119
+ path:path
120
+ props:props
121
+ resolve:resolve
122
+ reject:reject];
123
+ }
124
+
125
+ @end
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <Foundation/Foundation.h>
19
+
20
+ // See RNFBDatabaseModuleHelper.h for rationale: plain Objective-C helper
21
+ // that owns all `FIRDatabaseReference`/`FIRTransactionResult` calls and the
22
+ // pending-transaction bookkeeping for RNFBDatabaseTransactionModule.
23
+ @interface RNFBDatabaseTransactionHelper : NSObject
24
+
25
+ + (void)transactionStart:(NSString *)app
26
+ dbURL:(NSString *)dbURL
27
+ path:(NSString *)path
28
+ transactionId:(double)transactionId
29
+ applyLocally:(BOOL)applyLocally;
30
+
31
+ + (void)transactionTryCommit:(NSString *)app
32
+ dbURL:(NSString *)dbURL
33
+ transactionId:(double)transactionId
34
+ updates:(NSDictionary *)updates;
35
+
36
+ + (void)invalidate;
37
+
38
+ @end