@bugsee/react-native 0.0.0-stage → 7.0.0-beta1

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 (250) hide show
  1. package/BugseeReactNative.podspec +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +552 -2
  4. package/android/build.gradle +162 -0
  5. package/android/consumer-rules.pro +2 -0
  6. package/android/src/main/AndroidManifest.xml +33 -0
  7. package/android/src/main/java/com/bugsee/reactnative/AppearanceBridge.java +82 -0
  8. package/android/src/main/java/com/bugsee/reactnative/AttributeBridge.java +209 -0
  9. package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +443 -0
  10. package/android/src/main/java/com/bugsee/reactnative/BridgeJson.java +168 -0
  11. package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +1869 -0
  12. package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +136 -0
  13. package/android/src/main/java/com/bugsee/reactnative/BugseePackage.java +42 -0
  14. package/android/src/main/java/com/bugsee/reactnative/BugseeReactNativeWrapper.java +200 -0
  15. package/android/src/main/java/com/bugsee/reactnative/BugseeStatusMapper.java +66 -0
  16. package/android/src/main/java/com/bugsee/reactnative/BugseeTokens.java +22 -0
  17. package/android/src/main/java/com/bugsee/reactnative/ConsoleEchoDedup.java +202 -0
  18. package/android/src/main/java/com/bugsee/reactnative/CreatedReports.java +127 -0
  19. package/android/src/main/java/com/bugsee/reactnative/DataRequestBridge.java +375 -0
  20. package/android/src/main/java/com/bugsee/reactnative/ExceptionBridge.java +88 -0
  21. package/android/src/main/java/com/bugsee/reactnative/ExceptionExecutors.java +33 -0
  22. package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +375 -0
  23. package/android/src/main/java/com/bugsee/reactnative/NetworkEvents.java +227 -0
  24. package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +498 -0
  25. package/android/src/main/java/com/bugsee/reactnative/PluginEndpoint.java +48 -0
  26. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWebException.java +19 -0
  27. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +61 -0
  28. package/android/src/main/java/com/bugsee/reactnative/ReactRootOriginTracker.java +867 -0
  29. package/android/src/main/java/com/bugsee/reactnative/ReportArgs.java +58 -0
  30. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerBridge.java +336 -0
  31. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerDeadlines.java +57 -0
  32. package/android/src/main/java/com/bugsee/reactnative/ReportOps.java +287 -0
  33. package/android/src/main/java/com/bugsee/reactnative/SecureRectanglePulls.java +113 -0
  34. package/android/src/main/java/com/bugsee/reactnative/SecureRectangleStore.java +692 -0
  35. package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +143 -0
  36. package/android/src/main/java/com/bugsee/reactnative/WrapperChannelHolder.java +137 -0
  37. package/android/src/main/java/com/bugsee/reactnative/WrapperEventBus.java +110 -0
  38. package/android/src/main/java/com/bugsee/reactnative/WrapperRegistrar.java +54 -0
  39. package/app.plugin.js +4 -0
  40. package/ios/BGSRNConsoleCapture.h +52 -0
  41. package/ios/BGSRNConsoleCapture.mm +344 -0
  42. package/ios/BugseeModule.h +25 -0
  43. package/ios/BugseeModule.mm +2728 -0
  44. package/ios/Package.swift +71 -0
  45. package/ios/Support/Package.resolved +14 -0
  46. package/ios/Support/Package.swift +44 -0
  47. package/ios/Support/Sources/BugseeRNSupport/BGSRNAttributes.m +52 -0
  48. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReportOps.m +236 -0
  49. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReports.m +184 -0
  50. package/ios/Support/Sources/BugseeRNSupport/BGSRNDataRequestBridge.m +431 -0
  51. package/ios/Support/Sources/BugseeRNSupport/BGSRNErrorMessage.m +40 -0
  52. package/ios/Support/Sources/BugseeRNSupport/BGSRNEventBus.m +70 -0
  53. package/ios/Support/Sources/BugseeRNSupport/BGSRNExceptions.m +63 -0
  54. package/ios/Support/Sources/BugseeRNSupport/BGSRNGuardedEmit.mm +32 -0
  55. package/ios/Support/Sources/BugseeRNSupport/BGSRNJSON.m +40 -0
  56. package/ios/Support/Sources/BugseeRNSupport/BGSRNLaunchHold.m +147 -0
  57. package/ios/Support/Sources/BugseeRNSupport/BGSRNMainThread.m +23 -0
  58. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkEvents.m +159 -0
  59. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkFilter.m +155 -0
  60. package/ios/Support/Sources/BugseeRNSupport/BGSRNPluginEndpoint.m +21 -0
  61. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactRootOriginTracker.m +63 -0
  62. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactWindow.m +251 -0
  63. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportArgs.m +47 -0
  64. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportDeadlines.m +8 -0
  65. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportHandlerBridge.m +308 -0
  66. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportOps.m +345 -0
  67. package/ios/Support/Sources/BugseeRNSupport/BGSRNSecureRectangles.m +508 -0
  68. package/ios/Support/Sources/BugseeRNSupport/BGSRNSettleOnce.m +62 -0
  69. package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +136 -0
  70. package/ios/Support/Sources/BugseeRNSupport/BGSRNStatusMapper.m +18 -0
  71. package/ios/Support/Sources/BugseeRNSupport/BGSRNTokens.m +9 -0
  72. package/ios/Support/Sources/BugseeRNSupport/BGSRNValues.m +5 -0
  73. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +54 -0
  74. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapperChannelHolder.m +59 -0
  75. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNAttributes.h +63 -0
  76. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +51 -0
  77. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReports.h +81 -0
  78. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDataRequestBridge.h +118 -0
  79. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNErrorMessage.h +30 -0
  80. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNEventBus.h +45 -0
  81. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNExceptions.h +31 -0
  82. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNGuardedEmit.h +31 -0
  83. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNJSON.h +25 -0
  84. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNLaunchHold.h +86 -0
  85. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNMainThread.h +32 -0
  86. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkEvents.h +28 -0
  87. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkFilter.h +28 -0
  88. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNPluginEndpoint.h +17 -0
  89. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactRootOriginTracker.h +48 -0
  90. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactWindow.h +135 -0
  91. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportArgs.h +17 -0
  92. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportDeadlines.h +37 -0
  93. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +94 -0
  94. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +86 -0
  95. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSecureRectangles.h +198 -0
  96. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSettleOnce.h +25 -0
  97. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +49 -0
  98. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNStatusMapper.h +26 -0
  99. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNTokens.h +14 -0
  100. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNValues.h +18 -0
  101. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapper.h +40 -0
  102. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +74 -0
  103. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNAttributesTests.m +194 -0
  104. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportOpsTests.m +274 -0
  105. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportsTests.m +240 -0
  106. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDataRequestBridgeTests.m +685 -0
  107. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNErrorMessageTests.m +102 -0
  108. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNEventBusTests.m +136 -0
  109. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNExceptionsTests.m +68 -0
  110. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +41 -0
  111. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.m +166 -0
  112. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNGuardedEmitTests.mm +85 -0
  113. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNJSONTests.m +281 -0
  114. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNLaunchHoldTests.m +230 -0
  115. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNMainThreadTests.m +97 -0
  116. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkEventsTests.m +99 -0
  117. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkFilterTests.m +134 -0
  118. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNPluginEndpointTests.m +38 -0
  119. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactRootOriginTrackerTests.m +210 -0
  120. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactWindowTests.m +548 -0
  121. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportArgsTests.m +51 -0
  122. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportDeadlinesTests.m +22 -0
  123. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +382 -0
  124. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportOpsTests.m +295 -0
  125. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSecureRectanglesTests.m +568 -0
  126. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSettleOnceTests.m +134 -0
  127. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +153 -0
  128. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNStatusMapperTests.m +81 -0
  129. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNValuesTests.m +32 -0
  130. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +205 -0
  131. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +66 -0
  132. package/ios/react-native-spm-prefix.h +10 -0
  133. package/native-versions.json +10 -0
  134. package/package.json +62 -3
  135. package/plugin/build/bundle-phase.d.ts +41 -0
  136. package/plugin/build/bundle-phase.js +116 -0
  137. package/plugin/build/bundle-phase.js.map +1 -0
  138. package/plugin/build/dsym-script.d.ts +32 -0
  139. package/plugin/build/dsym-script.js +159 -0
  140. package/plugin/build/dsym-script.js.map +1 -0
  141. package/plugin/build/endpoint.d.ts +30 -0
  142. package/plugin/build/endpoint.js +69 -0
  143. package/plugin/build/endpoint.js.map +1 -0
  144. package/plugin/build/gradle.d.ts +65 -0
  145. package/plugin/build/gradle.js +1066 -0
  146. package/plugin/build/gradle.js.map +1 -0
  147. package/plugin/build/index.d.ts +85 -0
  148. package/plugin/build/index.js +217 -0
  149. package/plugin/build/index.js.map +1 -0
  150. package/plugin/build/manifest.d.ts +48 -0
  151. package/plugin/build/manifest.js +69 -0
  152. package/plugin/build/manifest.js.map +1 -0
  153. package/plugin/build/native-versions.baked.json +4 -0
  154. package/plugin/build/native-versions.d.ts +10 -0
  155. package/plugin/build/native-versions.js +27 -0
  156. package/plugin/build/native-versions.js.map +1 -0
  157. package/plugin/build/pbx-string.d.ts +8 -0
  158. package/plugin/build/pbx-string.js +31 -0
  159. package/plugin/build/pbx-string.js.map +1 -0
  160. package/plugin/build/podfile.d.ts +3 -0
  161. package/plugin/build/podfile.js +28 -0
  162. package/plugin/build/podfile.js.map +1 -0
  163. package/plugin/build/properties.d.ts +19 -0
  164. package/plugin/build/properties.js +41 -0
  165. package/plugin/build/properties.js.map +1 -0
  166. package/plugin/build/scheme.d.ts +20 -0
  167. package/plugin/build/scheme.js +107 -0
  168. package/plugin/build/scheme.js.map +1 -0
  169. package/react-native.config.js +26 -0
  170. package/scripts/bugsee-sourcemaps.gradle +201 -0
  171. package/scripts/bugsee-xcode.sh +83 -0
  172. package/scripts/compose-then-inject.js +113 -0
  173. package/scripts/hermes-sourcemaps.js +634 -0
  174. package/scripts/hermesc-preserve-js.cmd +6 -0
  175. package/scripts/hermesc-preserve-js.js +200 -0
  176. package/scripts/hermesc-preserve-js.sh +7 -0
  177. package/src/NativeBugsee.ts +622 -0
  178. package/src/apm/notify.ts +58 -0
  179. package/src/apm/span.ts +403 -0
  180. package/src/apm/types.ts +57 -0
  181. package/src/appearance/report.ts +171 -0
  182. package/src/architecture.ts +48 -0
  183. package/src/attributes/errors.ts +39 -0
  184. package/src/attributes/validate.ts +150 -0
  185. package/src/breadcrumbs/add.ts +58 -0
  186. package/src/breadcrumbs/data.ts +33 -0
  187. package/src/breadcrumbs/filter.ts +215 -0
  188. package/src/breadcrumbs/types.ts +64 -0
  189. package/src/bridge/json.ts +110 -0
  190. package/src/console/capture.ts +180 -0
  191. package/src/console/dedup.ts +175 -0
  192. package/src/data/validate.ts +259 -0
  193. package/src/errorName.ts +32 -0
  194. package/src/exceptions/ErrorBoundary.tsx +92 -0
  195. package/src/exceptions/RootErrorReporter.tsx +61 -0
  196. package/src/exceptions/debugIds.ts +118 -0
  197. package/src/exceptions/handlers.ts +236 -0
  198. package/src/exceptions/options.ts +85 -0
  199. package/src/exceptions/payload.ts +456 -0
  200. package/src/exceptions/report.ts +170 -0
  201. package/src/exceptions/sha1.ts +148 -0
  202. package/src/exceptions/stack.ts +355 -0
  203. package/src/index.ts +944 -0
  204. package/src/logs/filter.ts +90 -0
  205. package/src/logs/log.ts +36 -0
  206. package/src/network/add.ts +165 -0
  207. package/src/network/filter.ts +198 -0
  208. package/src/options/AndroidLaunchOptions.ts +78 -0
  209. package/src/options/BugseeLaunchOptions.ts +190 -0
  210. package/src/options/IOSLaunchOptions.ts +57 -0
  211. package/src/options/android-options-manifest.json +646 -0
  212. package/src/options/createDefaultLaunchOptions.ts +29 -0
  213. package/src/options/endpoint.ts +58 -0
  214. package/src/options/enums.ts +104 -0
  215. package/src/options/ios-enums.json +19 -0
  216. package/src/options/keys.ts +39 -0
  217. package/src/options/option-enums.json +34 -0
  218. package/src/options/option-keys.json +107 -0
  219. package/src/report/BugseeReport.ts +264 -0
  220. package/src/report/CreatedReport.ts +127 -0
  221. package/src/report/dispatcher.ts +95 -0
  222. package/src/report/errors.ts +48 -0
  223. package/src/report/fields.ts +40 -0
  224. package/src/report/types.ts +157 -0
  225. package/src/report/validate.ts +197 -0
  226. package/src/secure/BugseeSecure.tsx +202 -0
  227. package/src/secure/ancestry.ts +622 -0
  228. package/src/secure/drivers.ts +342 -0
  229. package/src/secure/followEvents.ts +57 -0
  230. package/src/secure/hold.ts +99 -0
  231. package/src/secure/measureLoop.ts +323 -0
  232. package/src/secure/nativeAnimation.ts +1005 -0
  233. package/src/secure/rectangles.ts +93 -0
  234. package/src/secure/registry.ts +237 -0
  235. package/src/secure/surface.ts +83 -0
  236. package/src/secure/tracker.ts +723 -0
  237. package/src/secure/transition.ts +488 -0
  238. package/src/secure/unit.ts +22 -0
  239. package/src/status.ts +16 -0
  240. package/src/version.ts +9 -0
  241. package/src/viewtree/anchor.tsx +105 -0
  242. package/src/viewtree/constants.ts +20 -0
  243. package/src/viewtree/fiber.ts +251 -0
  244. package/src/viewtree/requests.ts +347 -0
  245. package/src/viewtree/walk.ts +902 -0
  246. package/src/wrapper/channel.ts +33 -0
  247. package/src/wrapper/collect.ts +52 -0
  248. package/src/wrapper/events.ts +45 -0
  249. package/src/wrapper/identity.ts +54 -0
  250. package/src/wrapper/lifecycle-events.ts +89 -0
@@ -0,0 +1,18 @@
1
+ #import "include/BGSRNStatusMapper.h"
2
+
3
+ NSInteger BGSRNStatusToWire(BugseeStatus status) {
4
+ switch (status) {
5
+ case BugseeStatusLaunching:
6
+ return BGSRNStatusWireLaunching;
7
+ case BugseeStatusLaunched:
8
+ return BGSRNStatusWireLaunched;
9
+ case BugseeStatusStopping:
10
+ return BGSRNStatusWireStopping;
11
+ case BugseeStatusStopped:
12
+ return BGSRNStatusWireStopped;
13
+ }
14
+ // Not a `default:` inside the switch on purpose: with every case listed,
15
+ // the compiler warns when the SDK adds one, which is the signal we want.
16
+ // This only catches a value cast in from outside the enum's range.
17
+ return BGSRNStatusWireStopped;
18
+ }
@@ -0,0 +1,9 @@
1
+ #import "include/BGSRNTokens.h"
2
+
3
+ BOOL BGSRNTokenIsUsable(NSString *_Nullable token) {
4
+ if (![token isKindOfClass:[NSString class]]) {
5
+ return NO;
6
+ }
7
+ NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
8
+ return [token stringByTrimmingCharactersInSet:whitespace].length > 0;
9
+ }
@@ -0,0 +1,5 @@
1
+ #import "include/BGSRNValues.h"
2
+
3
+ NSNumber *BGSRNBoolNumber(BOOL value) {
4
+ return (__bridge NSNumber *)(value ? kCFBooleanTrue : kCFBooleanFalse);
5
+ }
@@ -0,0 +1,54 @@
1
+ #import "BGSRNWrapper.h"
2
+
3
+ static NSString *const BGSRNUnknown = @"unknown";
4
+
5
+ static NSString *BGSRNStringOr(NSDictionary *source, NSString *key, NSString *fallback) {
6
+ id value = source[key];
7
+ return [value isKindOfClass:[NSString class]] && [value length] > 0 ? value : fallback;
8
+ }
9
+
10
+ @implementation BGSRNWrapper
11
+
12
+ + (instancetype)wrapperWithIdentity:(NSDictionary *)identity {
13
+ BGSRNWrapper *wrapper = [[BGSRNWrapper alloc] init];
14
+ if (wrapper == nil) {
15
+ return nil;
16
+ }
17
+ NSDictionary *source = [identity isKindOfClass:[NSDictionary class]] ? identity : @{};
18
+
19
+ wrapper->_wrapperType = [BGSRNStringOr(source, @"type", BGSRNUnknown) copy];
20
+ wrapper->_wrapperVersion = [BGSRNStringOr(source, @"version", BGSRNUnknown) copy];
21
+
22
+ id build = source[@"build"];
23
+ wrapper->_wrapperBuild =
24
+ [build isKindOfClass:[NSString class]] ? [build copy] : nil;
25
+
26
+ // The SDK types context as string-to-string. A non-string value is dropped
27
+ // rather than described: a number rendered as "1" is indistinguishable from
28
+ // a version the wrapper actually reported.
29
+ id rawContext = source[@"context"];
30
+ if ([rawContext isKindOfClass:[NSDictionary class]]) {
31
+ NSMutableDictionary<NSString *, NSString *> *context = [NSMutableDictionary dictionary];
32
+ [(NSDictionary *)rawContext enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
33
+ if ([key isKindOfClass:[NSString class]] && [value isKindOfClass:[NSString class]]) {
34
+ context[key] = value;
35
+ }
36
+ }];
37
+ wrapper->_context = [context copy];
38
+ }
39
+
40
+ return wrapper;
41
+ }
42
+
43
+ + (instancetype)wrapperWithoutJsRuntime {
44
+ // Duplicated from WRAPPER_TYPE in src/wrapper/identity.ts and from
45
+ // package.json "version": this runs before JS can hand either down, and a
46
+ // test compares the three so they cannot drift.
47
+ return [self wrapperWithIdentity:@{
48
+ @"type" : @"react_native",
49
+ @"version" : @"7.0.0-beta1",
50
+ @"context" : @{},
51
+ }];
52
+ }
53
+
54
+ @end
@@ -0,0 +1,59 @@
1
+ #import "BGSRNWrapperChannelHolder.h"
2
+
3
+ BugseeLogLevel BGSRNLogLevelForWireValue(NSInteger wire) {
4
+ switch (wire) {
5
+ case 1:
6
+ return BugseeLogLevelError;
7
+ case 2:
8
+ return BugseeLogLevelWarning;
9
+ case 3:
10
+ return BugseeLogLevelInfo;
11
+ case 4:
12
+ return BugseeLogLevelDebug;
13
+ case 5:
14
+ return BugseeLogLevelVerbose;
15
+ default:
16
+ return BugseeLogLevelInfo;
17
+ }
18
+ }
19
+
20
+ @implementation BGSRNWrapperChannelHolder
21
+
22
+ + (instancetype)shared {
23
+ static BGSRNWrapperChannelHolder *instance;
24
+ static dispatch_once_t onceToken;
25
+ dispatch_once(&onceToken, ^{
26
+ instance = [[BGSRNWrapperChannelHolder alloc] init];
27
+ });
28
+ return instance;
29
+ }
30
+
31
+ - (void)logMessage:(nullable NSString *)message level:(NSInteger)level {
32
+ id<BGSWrapperChannel> current = self.channel;
33
+ if (current == nil) {
34
+ return;
35
+ }
36
+ // Every channel method is @optional -- a channel from an older-SDK-shaped
37
+ // wrapper, or one built for tests, need not implement all of them.
38
+ if (![current respondsToSelector:@selector(logWithTag:message:level:source:)]) {
39
+ return;
40
+ }
41
+ // No @try here -- see the class comment in the header.
42
+ [current logWithTag:nil
43
+ message:message
44
+ level:BGSRNLogLevelForWireValue(level)
45
+ source:BGSLogEventSourceCustom];
46
+ }
47
+
48
+ - (void)addNetworkEvent:(nullable BugseeNetworkEvent *)event {
49
+ id<BGSWrapperChannel> current = self.channel;
50
+ if (current == nil) {
51
+ return;
52
+ }
53
+ if (![current respondsToSelector:@selector(addNetworkEvent:requiresFiltering:)]) {
54
+ return;
55
+ }
56
+ [current addNetworkEvent:event requiresFiltering:YES];
57
+ }
58
+
59
+ @end
@@ -0,0 +1,63 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// Mirrors the SDK's `CUSTOM_ATTRIBUTE_SIZE_LIMIT` (design doc, Phase 5
6
+ /// verified facts): `+[Bugsee setAttribute:withValue:]` archives the value
7
+ /// with `NSKeyedArchiver` and silently drops it -- while still returning
8
+ /// `YES` -- once the archive exceeds this many bytes. Exposed so a caller (and
9
+ /// this class's own tests) can reason about the boundary without
10
+ /// hardcoding it twice.
11
+ FOUNDATION_EXPORT const NSInteger BGSRNAttributeArchiveLimit;
12
+
13
+ /// The custom-attribute and identity rules, between the JS wire shape and the
14
+ /// SDK's `+[Bugsee ...]` attribute surface. The iOS mirror of Android's
15
+ /// `AttributeBridge`.
16
+ ///
17
+ /// This class links no SDK: `+setValue:forKey:setter:getter:` takes the SDK's
18
+ /// setter/getter as blocks, so it (and its tests) never need `Bugsee.h` --
19
+ /// the caller (`BugseeModule.mm`, which does import it) supplies
20
+ /// `^(k, v){ return [Bugsee setAttribute:k withValue:v]; }` and
21
+ /// `^(k){ return [Bugsee getAttribute:k]; }`.
22
+ @interface BGSRNAttributes : NSObject
23
+
24
+ /// Sets `value` for `key` through `setter`, then verifies with `getter`
25
+ /// rather than trusting the setter's own return: neither SDK's
26
+ /// `setAttribute` reports a dropped value truthfully -- iOS's own
27
+ /// `+setAttribute:withValue:` returns `YES` even when it silently drops a
28
+ /// value for size (design doc, Phase 5 verified facts) -- so a read-back is
29
+ /// the only honest signal.
30
+ ///
31
+ /// `NO` from `setter` short-circuits to `NO` without calling `getter`: the
32
+ /// SDK is telling us outright nothing was set, and reading back would only
33
+ /// risk agreeing by coincidence with a stale value already there.
34
+ /// Otherwise, `YES` only when `getter(key)` is non-nil and `isEqual:` to
35
+ /// `value` afterwards.
36
+ + (BOOL)setValue:(id)value
37
+ forKey:(NSString *)key
38
+ setter:(BOOL (^)(NSString *key, id value))setter
39
+ getter:(id _Nullable (^)(NSString *key))getter;
40
+
41
+ /// The persisted attributes as JS can carry them: `string | number | boolean
42
+ /// | string[]`.
43
+ ///
44
+ /// A key that is not an `NSString` is dropped along with its value. `raw`'s
45
+ /// values pass through as: an `NSString` or `NSNumber` (a `CFBoolean` kept by
46
+ /// object identity, exactly as stored -- unlike Android, iOS never widens or
47
+ /// narrows a number on the way out); an `NSArray`, kept as an array of just
48
+ /// its `NSString` elements (mirrors Android's `Set<String>` -> `List<String>`,
49
+ /// the one collection type common to both platforms' output); anything else
50
+ /// (`NSDate`, `NSData`, a nested collection, ...) has no JS representation
51
+ /// and is dropped. `nil` reads as no attributes.
52
+ + (NSDictionary<NSString *, id> *)readable:(nullable NSDictionary *)raw;
53
+
54
+ /// The user identifier as JS should see it: `nil` and `@""` both read as
55
+ /// absent. iOS's own `+getUserIdentifier` already never returns `@""` (it
56
+ /// clears the Keychain entry on an empty `+setUserIdentifier:`), but this
57
+ /// keeps the rule explicit and in parity with Android, where an empty string
58
+ /// is stored and read back as given.
59
+ + (nullable NSString *)identifier:(nullable NSString *)raw;
60
+
61
+ @end
62
+
63
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,51 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Bugsee/Bugsee.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ /// Mirrors the SDK's `ATTACHMENTS_LIMIT`. A created report drops anything past
7
+ /// this at upload, silently; the bridge rejects at add time instead.
8
+ FOUNDATION_EXPORT const NSUInteger BGSRNCreatedReportAttachmentMaxCount;
9
+
10
+ /// Mirrors the SDK's `MAX_SIZE_ATTACHMENT` (3 MiB). Same rule: reject up front.
11
+ FOUNDATION_EXPORT const NSUInteger BGSRNCreatedReportAttachmentMaxBytes;
12
+
13
+ /// `BugseeExtendedReport` is not a `BGSReportContract`. Same wire keys as
14
+ /// `BGSRNReportOps`, different setters, and the SDK's attachment limits
15
+ /// applied here because upload would otherwise drop the file and still succeed.
16
+ @interface BGSRNCreatedReportOps : NSObject
17
+
18
+ /// `summary`, `description` (omitted when unset), `severity` (as held, 0 when
19
+ /// the SDK has not been given one), `labels`, `attributes`, `screenshotDisplayIds`
20
+ /// (`@[@0]` when a screenshot is set, else empty) and `attachmentNames`.
21
+ + (NSDictionary<NSString *, id> *)readReport:(BugseeExtendedReport *)report;
22
+
23
+ /// `validatedPatch:error:` first, so a bad field changes nothing. Then
24
+ /// `setSummary:` / `setDescription:` (NSNull clears), `setSeverity:`, labels
25
+ /// replaced by assignment, `clearAllAttributes` before attribute edits,
26
+ /// `clearAttribute:` for NSNull and `setAttribute:withValue:` otherwise.
27
+ + (BOOL)applyPatchJSON:(NSString *)json
28
+ toReport:(BugseeExtendedReport *)report
29
+ error:(NSError **)error;
30
+
31
+ /// `BGSRNReportErrorBadArgument` when `base64` does not decode.
32
+ /// `BGSRNReportErrorAttachmentRejected` when the report already holds
33
+ /// `BGSRNCreatedReportAttachmentMaxCount`, or the data is empty or over
34
+ /// `BGSRNCreatedReportAttachmentMaxBytes`.
35
+ + (BOOL)addData:(NSString *)base64
36
+ name:(NSString *)name
37
+ toReport:(BugseeExtendedReport *)report
38
+ error:(NSError **)error;
39
+
40
+ /// Size from the file's attributes before any read, then the bytes are read
41
+ /// now: a later overwrite of `path` must not change the attachment.
42
+ /// `BGSRNReportErrorAttachmentRejected` when the report is full, the file is
43
+ /// missing or unreadable, or it is empty or over the byte limit.
44
+ + (BOOL)addFileAtPath:(NSString *)path
45
+ name:(NSString *)name
46
+ toReport:(BugseeExtendedReport *)report
47
+ error:(NSError **)error;
48
+
49
+ @end
50
+
51
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,81 @@
1
+ #import <Foundation/Foundation.h>
2
+ // Not `@import Bugsee`: this header is included from ObjC++, where C++ modules
3
+ // are off on both delivery paths and a module import is a hard error.
4
+ #import <Bugsee/Bugsee.h>
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ /// One outstanding created report per process.
9
+ ///
10
+ /// iOS beta3 keeps `BugseeExtendedReport` attributes in a file-scope global,
11
+ /// so a second created report wipes the first's (P5, https://github.com/bugsee/bugsee-cocoa/issues/224). The slot covers both
12
+ /// "the SDK is still making one" and "JS holds one", and `invalidate` clears
13
+ /// it because a reload's JS cannot know the handle.
14
+ ///
15
+ /// `os_unfair_lock`: `createReport` can overlap an `invalidate` from another
16
+ /// queue. The caller reserves before any hop `invalidate` cannot cancel.
17
+ /// A reserve that ran after `clear` would hold the slot for a handle the
18
+ /// torn-down JS never uploads. The report object itself is unsynchronised
19
+ /// and is only touched on main; this lock guards the slot, not the report.
20
+ @interface BGSRNCreatedReports : NSObject
21
+
22
+ @property (class, readonly) BGSRNCreatedReports *shared;
23
+
24
+ /// 0 while a created report is outstanding or being created. Otherwise the
25
+ /// generation token `fulfil:reservation:` must present. A non-zero token is
26
+ /// an admission, which is what the existing tests assert. `clear` before
27
+ /// `beginCreate:` makes every token issued so far fail that check. The SDK's
28
+ /// completion is not cancelled.
29
+ - (NSUInteger)reserve;
30
+
31
+ /// YES when `reservation` is still the open one and `clear` has not run.
32
+ /// Does not take or free the slot.
33
+ - (BOOL)reservationIsOpen:(NSUInteger)reservation;
34
+
35
+ /// Marks `reservation` as having called `createReportWithCompletion:`.
36
+ /// NO when the token is not the open one, including after `clear`. The hop
37
+ /// uses this instead of a separate open check: `clear` between the two would
38
+ /// still `-init` a `BugseeExtendedReport`. Once this returns YES, `clear`
39
+ /// keeps the slot until `fulfil:reservation:` and that fulfil does not publish.
40
+ - (BOOL)beginCreate:(NSUInteger)reservation;
41
+
42
+ /// Ends the reservation `reservation` names. A report gets `cr-<n>` (fresh for
43
+ /// this registry, never reused after a take) and holds the slot. nil frees the
44
+ /// slot and returns nil. A token that is not the current one — including a
45
+ /// token `clear` dropped before `beginCreate:`, and the token of a reservation
46
+ /// that has already been fulfilled — returns nil and does not store a report
47
+ /// or clear the slot. After `beginCreate:`, `clear` leaves the token current
48
+ /// so this call can free the slot; it still does not publish a handle.
49
+ - (nullable NSString *)fulfil:(nullable BugseeExtendedReport *)report
50
+ reservation:(NSUInteger)reservation;
51
+
52
+ - (nullable BugseeExtendedReport *)reportFor:(NSString *)handleId;
53
+
54
+ /// Removes the report and frees the slot. nil when `handleId` is not the one held.
55
+ - (nullable BugseeExtendedReport *)take:(NSString *)handleId;
56
+
57
+ /// Drops the handle so later reads are dead, and keeps the slot until
58
+ /// `endUpload:` for `generationOut`. nil when `handleId` is not the one held;
59
+ /// `generationOut` is then 0. The slot stays taken because a second
60
+ /// `BugseeExtendedReport` resets the file-scope attributes beta3 shares.
61
+ - (nullable BugseeExtendedReport *)detachForUpload:(NSString *)handleId
62
+ generation:(NSUInteger *)generationOut;
63
+
64
+ /// Frees the slot when `generation` is still the upload `detachForUpload:`
65
+ /// started. A later upload's generation does not match, so this does not free
66
+ /// that one. `clear` does not move the generation: the in-flight upload keeps
67
+ /// the slot until this runs.
68
+ - (void)endUpload:(NSUInteger)generation;
69
+
70
+ /// Drops the handle and a reservation `beginCreate:` has not started. An
71
+ /// upload already detached keeps the slot until `endUpload:` for its
72
+ /// generation, and a `createReportWithCompletion:` already started keeps the
73
+ /// slot until `fulfil:reservation:`. Either way a reload cannot `-init`
74
+ /// another `BugseeExtendedReport` while beta3 is still using the file-scope
75
+ /// attributes of the one in flight. The in-flight create's fulfil does not
76
+ /// publish a handle the torn-down JS cannot upload.
77
+ - (void)clear;
78
+
79
+ @end
80
+
81
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,118 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// The one data-request type this bridge takes to JS: the SDK's
6
+ /// `BGSManagedHierarchyDataType` (`BGSCaptureDataProviderViewHierarchy.m`),
7
+ /// and JS's `VH_DATA_TYPE`. Every other type is answered `nil` here.
8
+ FOUNDATION_EXPORT NSString *const BGSRNDataRequestTypeViewHierarchy;
9
+
10
+ /// How long JS gets to answer, in milliseconds. Kept under the SDK's own
11
+ /// `BGSManagedHierarchyTimeoutMs` (500): past that the SDK records the pass
12
+ /// without the managed half and ignores a late answer, so this bridge answers
13
+ /// `nil` itself first -- which the SDK counts as an answer, so a slow JS never
14
+ /// pushes it into its 50 ms "silent wrapper" mode.
15
+ FOUNDATION_EXPORT const int64_t BGSRNDataRequestDeadlineMs;
16
+
17
+ /// Receives each `onDataRequest` payload: `requestId`, `type`, `originX`,
18
+ /// `originY`. Returns whether it reached JS; NO answers the request `nil` at
19
+ /// once (`by=sink-threw`). Must not throw (see `BGSRNGuardedEmit`).
20
+ typedef BOOL (^BGSRNDataRequestSinkBlock)(NSDictionary<NSString *, id> *request);
21
+
22
+ /// The React root's on-screen origin, in points, as an `NSValue` wrapping a
23
+ /// `CGPoint`; nil when there is none. Called on the requesting thread (main).
24
+ typedef NSValue *_Nullable (^BGSRNDataRequestOriginBlock)(void);
25
+
26
+ /// The SDK's answer callback.
27
+ typedef void (^BGSRNDataRequestReply)(NSString *_Nullable data);
28
+
29
+ /// Arms a request's deadline; returns a token the matching cancel block takes.
30
+ typedef id _Nonnull (^BGSRNDataRequestScheduler)(dispatch_block_t task, int64_t delayMs);
31
+ typedef void (^BGSRNDataRequestSchedulerCancel)(id token);
32
+ /// A monotonic clock, in milliseconds.
33
+ typedef int64_t (^BGSRNDataRequestClock)(void);
34
+ /// Where the one-line outcome of every request goes. `NSLog` in production,
35
+ /// which reaches the console stream the device tests match.
36
+ typedef void (^BGSRNDataRequestOutcomeLog)(NSString *line);
37
+
38
+ /// Answers the SDK's `"vh"` data request from JS, through a table of opaque
39
+ /// request ids. The iOS mirror of Android's `DataRequestBridge`, and built
40
+ /// like `BGSRNReportHandlerBridge`.
41
+ ///
42
+ /// Every `requestType:reply:` ends in exactly one run of `reply`, whichever
43
+ /// gets there first: JS completing the id, the deadline, or the sink
44
+ /// detaching (a reload), or the bridge failing (`by=failed`: the origin block
45
+ /// or the scheduler threw). Everything that cannot reach JS -- an unknown
46
+ /// type, no JS runtime or a disabled view tree, no origin -- answers `nil`
47
+ /// synchronously. The guard is one flag per request, flipped under the
48
+ /// registry lock; `reply` always runs OUTSIDE the lock, because it re-enters
49
+ /// the SDK (and may, in principle, re-enter this bridge).
50
+ ///
51
+ /// Threading (SDK `0d9c9d0a3`, `BGSCaptureDataProviderViewHierarchy.m`): the
52
+ /// SDK asks on MAIN (`capturePassAskingWrapper:`, reached by
53
+ /// `dispatch_async(dispatch_get_main_queue(), ...)`), but never waits there:
54
+ /// the answer is an asynchronous callback, accepted on any thread, and the
55
+ /// only thread that blocks for it is the SDK's background reporting thread
56
+ /// (the snapshot path's semaphore). JS's answer arrives on the TurboModule
57
+ /// method queue, and the deadline fires on this bridge's own queue; neither
58
+ /// needs main. Nothing here hops to main, and nothing may.
59
+ ///
60
+ /// Like `BGSRNReportHandlerBridge`, this outlives any one React instance: the
61
+ /// wrapper that calls in is registered at process start, while the module
62
+ /// that receives `onDataRequest` comes and goes with the JS runtime.
63
+ @interface BGSRNDataRequestBridge : NSObject
64
+
65
+ @property (class, readonly) BGSRNDataRequestBridge *shared;
66
+
67
+ /// Tests inject the scheduler and the clock; `shared` uses a private serial
68
+ /// queue and the uptime clock.
69
+ - (instancetype)initWithScheduler:(BGSRNDataRequestScheduler)schedule
70
+ cancel:(BGSRNDataRequestSchedulerCancel)cancel
71
+ clock:(BGSRNDataRequestClock)nowMs;
72
+
73
+ /// As above, with the outcome lines sent to `log` instead of `NSLog`.
74
+ - (instancetype)initWithScheduler:(BGSRNDataRequestScheduler)schedule
75
+ cancel:(BGSRNDataRequestSchedulerCancel)cancel
76
+ clock:(BGSRNDataRequestClock)nowMs
77
+ log:(BGSRNDataRequestOutcomeLog)log NS_DESIGNATED_INITIALIZER;
78
+
79
+ - (instancetype)init NS_UNAVAILABLE;
80
+
81
+ /// Whether the attached JS runtime has a mounted `Bugsee.wrap` anchor to walk.
82
+ /// The setter writes the flag directly and does not identity-check; production
83
+ /// goes through `setViewTreeEnabled:forSink:`.
84
+ @property (atomic) BOOL viewTreeEnabled;
85
+
86
+ /// The attached runtime's anchor mounted (YES) or unmounted (NO). Ignored
87
+ /// when `sink` is not the attached one: the flag is process-wide, and a
88
+ /// reload can still run the old module's last disable after the new module
89
+ /// has attached and enabled. Applying that write would leave the live
90
+ /// runtime at `by=no-js` until its anchor count passed through zero again.
91
+ - (void)setViewTreeEnabled:(BOOL)enabled forSink:(id)sink;
92
+
93
+ /// Attaches the module of a new JS runtime, replacing whatever was attached,
94
+ /// and disables the view tree: the new runtime has not mounted its anchor
95
+ /// yet. `sink` is held weakly.
96
+ - (void)attach:(id)sink block:(BGSRNDataRequestSinkBlock)block origin:(BGSRNDataRequestOriginBlock)origin;
97
+
98
+ /// Answers `nil` to every request emitted to `sink` -- nothing in any other
99
+ /// runtime knows them. Clears the sink, the origin and the enabled flag only
100
+ /// if `sink` is still the attached one: a fast reload attaches the new module
101
+ /// before the old one is invalidated.
102
+ - (void)detach:(id)sink;
103
+
104
+ /// The wrapper's `requestDataWithType:callback:`. Never throws; `reply` runs
105
+ /// exactly once.
106
+ - (void)requestType:(NSString *)type reply:(BGSRNDataRequestReply)reply;
107
+
108
+ /// JS's answer. An unknown, finished or late id is ignored.
109
+ /// @return YES only for the call that delivered `payload` to the SDK.
110
+ - (BOOL)complete:(NSString *)requestId payload:(nullable NSString *)payload;
111
+
112
+ /// Requests minted and not yet completed. For tests: every terminal path must
113
+ /// bring this back to zero.
114
+ @property (nonatomic, readonly) NSUInteger outstanding;
115
+
116
+ @end
117
+
118
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,30 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// What `BGSRNErrorMessage` says for an `NSError` this bridge did not build.
6
+ FOUNDATION_EXPORT NSString *const BGSRNForeignErrorMessage;
7
+
8
+ /// A bridge error's developer-chosen identifier (a patch key, an attribute
9
+ /// name), kept apart from its description. `BGSRNErrorMessage` puts it where
10
+ /// the description says `{identifier}`.
11
+ FOUNDATION_EXPORT NSErrorUserInfoKey const BGSRNErrorIdentifierKey;
12
+
13
+ /// The ONE place this bridge reads an `NSError`'s message, for a rejection or
14
+ /// a log line.
15
+ ///
16
+ /// An error in one of the bridge's own domains (`BGSRNJSONErrorDomain`,
17
+ /// `BGSRNReportErrorDomain`, `BGSRNExceptionsErrorDomain`) is built with a
18
+ /// string-literal description, optionally a `BGSRNErrorIdentifierKey`, and
19
+ /// optionally an `NSUnderlyingErrorKey`; `scripts/raw-messages.ts` fails the
20
+ /// build on any other construction. Its message is that description, with
21
+ /// the identifier in place of `{identifier}` and, when the underlying error
22
+ /// is the bridge's own too, `": "` and that error's message appended.
23
+ ///
24
+ /// Any other error -- a system parser's, which can repeat the malformed
25
+ /// input, a file error, which names the path, the SDK's -- returns
26
+ /// `BGSRNForeignErrorMessage`: its text was never audited, and a rejection
27
+ /// reaches JS while a log line reaches the SDK's own log capture.
28
+ FOUNDATION_EXPORT NSString *BGSRNErrorMessage(NSError *_Nullable error);
29
+
30
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,45 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// Carries the SDK's lifecycle events from the wrapper to the React Native
6
+ /// bridge.
7
+ ///
8
+ /// The two ends have different lifetimes, which is the whole reason this
9
+ /// exists. The wrapper is registered before React Native has a JS runtime and
10
+ /// is replaced once `setWrapperInfo` runs; the bridge appears later, can be
11
+ /// torn down and recreated by a reload, and is absent entirely during
12
+ /// start-up. Wiring the wrapper directly to a module would mean either
13
+ /// dropping events after a reload or holding a dead module alive.
14
+ ///
15
+ /// Events that arrive with no bridge attached are dropped, deliberately.
16
+ /// During start-up there is no JavaScript to deliver them to, and queueing
17
+ /// would deliver a burst of stale transitions the moment JS appeared — worse
18
+ /// than not delivering them, because it looks like the present. A caller that
19
+ /// needs the current state asks `getStatus`.
20
+ @interface BGSRNEventBus : NSObject
21
+
22
+ @property (class, readonly) BGSRNEventBus *shared;
23
+
24
+ /// Receives each lifecycle event. Returns whether it reached JS; the bus logs
25
+ /// and drops an event that did not. Must not throw (see `BGSRNGuardedEmit`).
26
+ typedef BOOL (^BGSRNLifecycleBlock)(NSString *name, NSString *_Nullable reportId);
27
+
28
+ /// Attaches the bridge. Replaces whatever was attached.
29
+ - (void)attach:(id)sink block:(BGSRNLifecycleBlock)block;
30
+
31
+ /// Detaches `sink` only if it is still the attached one.
32
+ ///
33
+ /// Identity-checked rather than an unconditional clear: a reload can construct
34
+ /// and attach the new module before the old one is torn down, and clearing
35
+ /// unconditionally would then silence the live bridge.
36
+ - (void)detach:(id)sink;
37
+
38
+ /// Forwards a lifecycle event, with the SDK's `com.bugsee.lifecycle.` prefix
39
+ /// removed. An unrecognised name is forwarded unchanged rather than dropped —
40
+ /// a newer SDK adding an event must not be swallowed by an older wrapper.
41
+ - (void)emitLifecycle:(NSString *)rawName reportId:(nullable NSString *)reportId;
42
+
43
+ @end
44
+
45
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,31 @@
1
+ #import <Foundation/Foundation.h>
2
+ // Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
3
+ // are off on both delivery paths and a module import is a hard error.
4
+ #import <Bugsee/Bugsee.h>
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ /// The backend routes React Native JS exceptions on this exact substring
9
+ /// (`'ReactNativeWebException' in name`). Never rename it.
10
+ FOUNDATION_EXPORT NSString *const BGSRNReactNativeExceptionName;
11
+
12
+ FOUNDATION_EXPORT NSErrorDomain const BGSRNExceptionsErrorDomain;
13
+
14
+ /// The wire options of one handled exception: only `domain`, which reaches the
15
+ /// SDK as an argument of `+logException:reason:domain:skipFrames:completion:`.
16
+ /// Labels and `includeVideo` are no longer options (7.0.0-beta7 removed
17
+ /// `BugseeExceptionLoggingOptions`; labels are set through a report handler).
18
+ @interface BGSRNExceptionOptions : NSObject
19
+ @property (nonatomic, copy, nullable) NSString *domain;
20
+ @end
21
+
22
+ @interface BGSRNExceptions : NSObject
23
+
24
+ /// `{domain?}` as `BGSRNExceptionOptions`. nil for nil text. Unparseable text
25
+ /// or a wrongly typed domain → nil and `*error`. Other keys are ignored.
26
+ + (nullable BGSRNExceptionOptions *)loggingOptionsFromJSON:(nullable NSString *)json
27
+ error:(NSError *_Nullable *_Nullable)error;
28
+
29
+ @end
30
+
31
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,31 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// Runs a codegen `emitOn*` call and reports whether it was delivered,
6
+ /// catching -- and logging -- anything it throws. Never throws itself.
7
+ ///
8
+ /// The generated `emitOn*` method calls a `std::function` that is only set
9
+ /// once `getTurboModule` builds the JSI object. An event that arrives before
10
+ /// that, or after the module has been invalidated, calls an unset one, and
11
+ /// that throws `std::bad_function_call`. Objective-C's `@catch (NSException *)`
12
+ /// cannot see a C++ exception, so left unguarded it unwinds straight through
13
+ /// to `std::terminate` and takes the app down.
14
+ ///
15
+ /// Caught here, inside Objective-C++, rather than converted and re-raised: the
16
+ /// callers (`BugseeModule.mm`'s sink blocks, invoked from `BGSRNEventBus` and
17
+ /// `BGSRNReportHandlerBridge`) sit under plain Objective-C frames compiled
18
+ /// without `-fobjc-arc-exceptions`, where an exception unwinding through
19
+ /// leaks every strong local. They branch on the result instead: the lifecycle
20
+ /// path drops the event (there is no subscriber to queue it for), and the
21
+ /// report path completes the waiting handle instead of leaving the SDK to wait
22
+ /// out a deadline no JS will ever meet.
23
+ ///
24
+ /// @param emit The codegen `emitOn*` call, wrapped in a block. `nil` is not a
25
+ /// delivery.
26
+ /// @param what Named in the log line, so it says which emit failed.
27
+ /// @return YES if `emit` ran to completion; NO if it threw anything (an
28
+ /// `NSException`, a `std::exception`, or any other C++ throw) or was `nil`.
29
+ FOUNDATION_EXPORT BOOL BGSRNGuardedEmit(dispatch_block_t _Nullable emit, NSString *what);
30
+
31
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,25 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ FOUNDATION_EXPORT NSErrorDomain const BGSRNJSONErrorDomain;
6
+
7
+ /// The JSON object `json` holds, as Foundation: `NSDictionary`, `NSArray`,
8
+ /// `NSString`, `NSNumber` (an integral literal as an integer number, a
9
+ /// fraction or exponent as a double, `true`/`false` as the CFBoolean
10
+ /// singletons) and `NSNull` for every `null` -- kept, as a key that is there.
11
+ ///
12
+ /// The iOS end of the one transport object payloads cross the bridge as
13
+ /// (`encodeBridgeObject` in `src/bridge/json.ts`). Not an `NSDictionary`
14
+ /// argument: React Native's TurboModule conversion of one
15
+ /// (`convertJSIObjectToNSDictionary`) skips every member whose value is JS
16
+ /// `null` unless an app-level feature flag is on, so "clear this" arrived as
17
+ /// "leave this alone".
18
+ ///
19
+ /// nil, with an error in `BGSRNJSONErrorDomain`, when `json` is nil or not
20
+ /// exactly one JSON object: a syntax error, another kind of value, or
21
+ /// trailing text.
22
+ FOUNDATION_EXPORT NSDictionary<NSString *, id> *_Nullable BGSRNJSONObject(NSString *_Nullable json,
23
+ NSError **error);
24
+
25
+ NS_ASSUME_NONNULL_END