@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,86 @@
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
+ /// WORKAROUND for https://github.com/bugsee/bugsee-cocoa/issues/227 -- remove
9
+ /// this class, and its call sites in BugseeModule.mm, once every call it holds
10
+ /// is accepted while the SDK is `Launching`. 7.0.0-beta7 accepts logException,
11
+ /// logError and uploadWithSummary then (bugsee-cocoa#234);
12
+ /// `+createReportWithCompletion:` and `+showReportDialog...` still return
13
+ /// silently, so the hold stays for them and keeps all the calls in order.
14
+ ///
15
+ /// iOS 7.0.0-beta5 drops a report-creating call made while the SDK is
16
+ /// `Launching`: `+logException:asHandled:withOptions:andCompletion:`
17
+ /// (`Bugsee.m:1431` at c015f6ba2), `+uploadWithSummary:` (1647),
18
+ /// `+createReportWithCompletion:` (1748) and `+showReportDialog...` (861,
19
+ /// 1327, 1355) all return when the status is not `Launched`, silently, and
20
+ /// call any completion. `launch()` resolves while the status is still
21
+ /// `Launching` -- `Launched` comes from an asynchronous completion, up to the
22
+ /// SDK's 8 s drain budget later on a device -- so `await launch()` followed by
23
+ /// `logException` lost the report on iOS, while Android kept it.
24
+ ///
25
+ /// This holds such calls while the SDK is `Launching` and replays them, in
26
+ /// order, once it is `Launched`. A call made when nothing is held runs at
27
+ /// once, exactly as before, whatever the status.
28
+ ///
29
+ /// Main thread only, except `lifecycleEvent:`: every SDK entry point already
30
+ /// runs there (`BGSRNRunOnMain`), and so do the status reads, the replay and
31
+ /// the deadline, so the hold needs no lock and keeps call order for free.
32
+ @interface BGSRNLaunchHold : NSObject
33
+
34
+ /// How a gated call is asked to run.
35
+ typedef NS_ENUM(NSInteger, BGSRNGatedRun) {
36
+ /// Nothing was held: run it now, as the bridge always did.
37
+ BGSRNGatedRunNow = 0,
38
+ /// It was held and the SDK is now `Launched`: run it now.
39
+ BGSRNGatedRunReplay = 1,
40
+ /// It was held and the launch did not complete (stopped, stopping, the
41
+ /// deadline passed, or the hold was full): do not call the SDK. Settle it
42
+ /// the way the SDK settles a dropped call -- no report, and any promise
43
+ /// resolves as the SDK's completion would have (nil).
44
+ BGSRNGatedRunDrop = 2,
45
+ };
46
+
47
+ typedef void (^BGSRNGatedCall)(BGSRNGatedRun run);
48
+
49
+ /// The most calls held at once (`BGSRNLaunchHoldCapacity`). One more is
50
+ /// dropped at once, logged.
51
+ FOUNDATION_EXPORT const NSUInteger BGSRNLaunchHoldCapacity;
52
+
53
+ /// How long the first held call waits for `Launched` before every held call
54
+ /// is settled anyway (`BGSRNLaunchHoldDeadlineMs`): well past the SDK's 8 s
55
+ /// synchronous drain budget, and short enough that a launch which never
56
+ /// finishes cannot keep a promise pending for good.
57
+ FOUNDATION_EXPORT const int64_t BGSRNLaunchHoldDeadlineMs;
58
+
59
+ /// The process-wide hold, reading `+[Bugsee sharedInstance].status`.
60
+ @property (class, readonly) BGSRNLaunchHold *shared;
61
+
62
+ /// For tests: a hold with its own bounds, and the SDK status read from
63
+ /// `status`.
64
+ - (instancetype)initWithCapacity:(NSUInteger)capacity
65
+ deadlineMs:(int64_t)deadlineMs
66
+ status:(BugseeStatus (^)(void))status NS_DESIGNATED_INITIALIZER;
67
+
68
+ - (instancetype)init NS_UNAVAILABLE;
69
+
70
+ /// Main thread only. Runs `call` now (`BGSRNGatedRunNow`), or holds it when
71
+ /// the SDK is `Launching`. Anything already held is settled first, so calls
72
+ /// keep their order across `Launched` even when this arrives before the
73
+ /// lifecycle event does. `label` names the call in the log lines, e.g.
74
+ /// `BugseeRN <label> held until launched`.
75
+ - (void)submit:(NSString *)label call:(BGSRNGatedCall)call;
76
+
77
+ /// Any thread: the SDK's `com.bugsee.lifecycle.*` event. `Launched` replays
78
+ /// what is held; `Stopping` and `Stopped` drop it. Hops to main.
79
+ - (void)lifecycleEvent:(NSString *)name;
80
+
81
+ /// Main thread only. How many calls are held.
82
+ @property (nonatomic, readonly) NSUInteger heldCount;
83
+
84
+ @end
85
+
86
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// Runs @c block on the main thread, without deadlocking if already there.
6
+ ///
7
+ /// The Bugsee SDK touches UIKit during start-up, and React Native delivers
8
+ /// TurboModule calls on a background queue — measured on device, every call
9
+ /// arrives with @c isMainThread==0. So the hop is load-bearing, not defensive.
10
+ ///
11
+ /// @c dispatch_sync onto the main queue from the main thread is a hard
12
+ /// deadlock, and React Native does sometimes invoke a TurboModule method on
13
+ /// the main thread, so the already-on-main case must run the block directly.
14
+ ///
15
+ /// This lives in the Support package rather than beside its caller so that it
16
+ /// can be tested: removing the hop is otherwise invisible — the device e2e
17
+ /// still passes without it.
18
+ FOUNDATION_EXPORT void BGSRNRunOnMain(dispatch_block_t block);
19
+
20
+ /// Runs @c block on the main thread and does not return until it has finished.
21
+ ///
22
+ /// Same already-on-main inline rule as @c BGSRNRunOnMain (a @c dispatch_sync
23
+ /// from main would deadlock). Off main, hops with @c dispatch_sync so the
24
+ /// caller may rely on side effects the block made on main.
25
+ ///
26
+ /// Reserved for work that must be established before the caller continues —
27
+ /// today, the module-init wrapper registration. Ordinary SDK entry points
28
+ /// stay on @c BGSRNRunOnMain (async off main) so they never block a JS
29
+ /// queue waiting on main.
30
+ FOUNDATION_EXPORT void BGSRNRunOnMainSync(dispatch_block_t block);
31
+
32
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Bugsee/Bugsee.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ typedef NS_ENUM(NSInteger, BGSRNNetworkEventOutcome) {
7
+ BGSRNNetworkEventOutcomeAdded = 0,
8
+ /// `eventWithID:` produced nothing. The caller logs the drop and returns.
9
+ BGSRNNetworkEventOutcomeNoEvent,
10
+ BGSRNNetworkEventOutcomeRejected,
11
+ };
12
+
13
+ typedef void (^BGSRNNetworkEventSubmit)(BugseeNetworkEvent *event, BOOL requiresFiltering);
14
+
15
+ /// Builds one app-recorded `BugseeNetworkEvent` and submits it with filtering
16
+ /// required. Shipped beta3's exchange-factory `createNetworkEvent` is a stub
17
+ /// that always returns nil, so this does not call it: the event is
18
+ /// `+[BugseeNetworkEvent eventWithID:HTTPmethod:...]`, then
19
+ /// `addNetworkEvent:requiresFiltering:` with YES. There is no timer that
20
+ /// would pass the original through.
21
+ ///
22
+ /// `nowMs` is epoch milliseconds, the unit `BugseeGetCurrentTimeStampMs` uses.
23
+ FOUNDATION_EXPORT BGSRNNetworkEventOutcome BGSRNRecordNetworkEvent(
24
+ NSDictionary<NSString *, id> *object,
25
+ BGSRNNetworkEventSubmit submit,
26
+ NSTimeInterval nowMs);
27
+
28
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
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 event, in the shape JS's filter receives. `type` matches the bundle:
9
+ /// `websocket` / `udpsocket` for sockets, otherwise the HTTP stage. The
10
+ /// websocket subtype is `websocketEvent`.
11
+ ///
12
+ /// `body` is JSON null when the bytes are nil or empty. When they are
13
+ /// non-empty and not UTF-8 the key is omitted, so a spread of this snapshot
14
+ /// does not clear a JPEG, protobuf, or binary frame. Apply leaves a missing
15
+ /// key alone and treats JSON null as clear.
16
+ ///
17
+ /// `redirectedFromURL` and `error` are always present. JSON null is sent
18
+ /// when the native value is nil. `error` is the event's dictionary.
19
+ FOUNDATION_EXPORT NSString *_Nullable BGSRNNetworkEventJSON(BugseeNetworkEvent *event);
20
+
21
+ /// Writes `url`, `body`, `headers`, `redirectedFromURL` and `error` from
22
+ /// JS's replacement onto `event`. A missing key is left alone. A string
23
+ /// `redirectedFromURL` and a dictionary `error` are written back. JSON null
24
+ /// clears. An illegal value, or a write that does not stick, refuses the
25
+ /// replacement so the caller drops the event.
26
+ FOUNDATION_EXPORT BOOL BGSRNApplyNetworkReplacement(BugseeNetworkEvent *event, NSString *_Nullable eventJson);
27
+
28
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,17 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// The Info.plist key the Expo config plugin writes its `endpoint` option to
6
+ /// (plugin/src/index.ts, IOS_ENDPOINT_PLIST_KEY), already in the form the iOS
7
+ /// SDK's `endpoint` launch option takes, with the API version.
8
+ FOUNDATION_EXPORT NSString *const BGSRNPluginEndpointInfoKey;
9
+
10
+ /// `options` with the configured endpoint as its `endpoint` when JS passed
11
+ /// none, or `options` itself. An endpoint JS passed always wins; a missing,
12
+ /// non-string or blank configured value changes nothing, so the SDK keeps its
13
+ /// own default. `options` is never modified.
14
+ FOUNDATION_EXPORT NSDictionary *BGSRNOptionsWithPluginEndpoint(NSDictionary *_Nullable options,
15
+ id _Nullable configured);
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,48 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// The shortest time between two searches for the React root on the SDK's
6
+ /// pulls, in seconds, while no root found earlier is in a window.
7
+ FOUNDATION_EXPORT const NSTimeInterval BGSRNReactRootSearchMinInterval;
8
+
9
+ /// Where the React root's window starts in the frame the SDK records: the main
10
+ /// surface's origin, what moves its secure rectangles and the `vh` tree onto
11
+ /// the screen. The iOS peer of Android's `ReactRootOriginTracker`.
12
+ ///
13
+ /// The SDK pulls the secure rectangles on the main thread once per captured
14
+ /// frame and per report screenshot, and the main surface's origin is re-read
15
+ /// on each pull, so a window that moves (Stage Manager, Split View, iPhone Duo
16
+ /// side by side) is followed with nothing published. A search walks every
17
+ /// window the SDK walks, to its budget when there is no React root (a
18
+ /// brownfield app's native screens), so the tracker keeps the root it found
19
+ /// last, weakly -- a reload replaces it and it must not be kept alive -- and
20
+ /// only reads its window's place while it is in one. Without such a root a
21
+ /// pull searches at most once per `BGSRNReactRootSearchMinInterval`; a JS
22
+ /// publish or a `vh` request searches at once.
23
+ ///
24
+ /// Never guesses: nil when there is no root, or its place cannot be read, and
25
+ /// the caller keeps the origin it has. Main thread only. An exception from
26
+ /// either block is logged and read as nil.
27
+ @interface BGSRNReactRootOriginTracker : NSObject
28
+
29
+ /// @param findRoot searches for the React root; nil when there is none.
30
+ /// @param readOrigin the place of the window holding the root.
31
+ /// @param clock seconds on a monotonic clock, for the pulls' search interval.
32
+ - (instancetype)initWithFindRoot:(UIView *_Nullable (^)(void))findRoot
33
+ readOrigin:(NSValue *_Nullable (^)(UIWindow *window))readOrigin
34
+ clock:(NSTimeInterval (^)(void))clock NS_DESIGNATED_INITIALIZER;
35
+ - (instancetype)init NS_UNAVAILABLE;
36
+
37
+ /// For the SDK's pull: the origin of the root found last while it is in a
38
+ /// window. Without one, searches, at most once per
39
+ /// `BGSRNReactRootSearchMinInterval`.
40
+ - (nullable NSValue *)origin;
41
+
42
+ /// For a JS publish or a `vh` request: the same, but searching now whenever
43
+ /// the root found last is in no window.
44
+ - (nullable NSValue *)originFindingTheRoot;
45
+
46
+ @end
47
+
48
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,135 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ #import "BGSRNSecureRectangles.h"
4
+
5
+ NS_ASSUME_NONNULL_BEGIN
6
+
7
+ /// Where the `vh` request's origin comes from: the one number that puts the
8
+ /// React tree in the same space as the SDK's native tree.
9
+ ///
10
+ /// The SDK's view-hierarchy engine places every node in the frame it records
11
+ /// (`+[BGSTrackerApplication captureRectForRect:inView:]`,
12
+ /// `BGSCaptureViewHierarchyEngine.m` `dumpView:`): on iOS every window of the
13
+ /// app at its place on the screen (iPad Stage Manager and Split View, iPhone
14
+ /// Duo side by side). JS measures with `measureInWindow` -- window-relative --
15
+ /// so the origin it must add is where the window hosting the React root starts
16
+ /// in that frame (`BGSRNWindowRecordedOrigin`), the same origin that moves the
17
+ /// secure rectangles (`BGSRNReactRootOriginTracker`).
18
+ ///
19
+ /// Everything here reads UIKit, so it must run on main.
20
+
21
+ /// How many views `BGSRNWindowHostingReactRoot` inspects per window before
22
+ /// giving up on it. A React root sits a few levels down in any real app; this
23
+ /// only keeps a pathological native hierarchy from costing the main thread.
24
+ FOUNDATION_EXPORT const NSUInteger BGSRNReactRootSearchBudget;
25
+
26
+ /// The key window exactly as the SDK picks it (`+[BGSTrackerApplication
27
+ /// resolveKeyWindow]`): the application's key window while its scene is in the
28
+ /// foreground -- the window the user brought forward last, when several of the
29
+ /// app's scenes are on screen -- else, among window scenes with a key window,
30
+ /// the foreground-active one whose key window `isKeyWindow`, else the first
31
+ /// foreground-active one, else the last scene's key window seen. Not unit
32
+ /// tested: it needs connected scenes.
33
+ FOUNDATION_EXPORT UIWindow *_Nullable BGSRNSdkKeyWindow(void);
34
+
35
+ /// The windows the SDK records and walks for that key window
36
+ /// (`BGSWindowsToRecord`, `+[BGSTrackerApplication captureWindows]`). Where
37
+ /// the SDK composes the app's windows on the screen -- iOS, not on a Mac --
38
+ /// and the app declares a `UIApplicationSceneManifest` and has more than one
39
+ /// scene connected: the windows of every foreground window scene on the key
40
+ /// window's screen. Else its scene's windows with a manifest, or
41
+ /// `-[UIApplication windows]` without one -- which is the React Native
42
+ /// template's case. The SDK orders the scenes back to front; this list is for
43
+ /// finding a window, so it keeps `connectedScenes` order. Not unit tested
44
+ /// either: the test runner has no application and no scenes.
45
+ FOUNDATION_EXPORT NSArray<UIWindow *> *BGSRNSdkWalkedWindows(UIWindow *_Nullable keyWindow);
46
+
47
+ /// The first view `isReactRoot` accepts, searching each window's tree
48
+ /// breadth-first over at most `budget` views. `keyWindow` is tried first, then
49
+ /// `windows` in order. nil if no window has one.
50
+ FOUNDATION_EXPORT UIView *_Nullable BGSRNReactRootView(UIWindow *_Nullable keyWindow,
51
+ NSArray<UIWindow *> *windows,
52
+ BOOL (^isReactRoot)(UIView *view),
53
+ NSUInteger budget);
54
+
55
+ /// The window hosting that view (`BGSRNReactRootView`), or nil.
56
+ FOUNDATION_EXPORT UIWindow *_Nullable BGSRNWindowHostingReactRoot(UIWindow *_Nullable keyWindow,
57
+ NSArray<UIWindow *> *windows,
58
+ BOOL (^isReactRoot)(UIView *view),
59
+ NSUInteger budget);
60
+
61
+ /// Where that window starts in the frame the SDK records
62
+ /// (`BGSRNWindowRecordedOrigin`), boxed as a `CGPoint`; nil when no window
63
+ /// hosts the React root, or it is on no screen -- a request then answers
64
+ /// `by=no-origin` rather than a tree offset by a guess.
65
+ FOUNDATION_EXPORT NSValue *_Nullable BGSRNReactRootOrigin(UIWindow *_Nullable keyWindow,
66
+ NSArray<UIWindow *> *windows,
67
+ BOOL (^isReactRoot)(UIView *view));
68
+
69
+ /// Where `window`'s own coordinate space starts in the frame the SDK records,
70
+ /// in points, boxed as a `CGPoint`: what to add to a `measureInWindow`
71
+ /// rectangle to put it where the SDK draws it, as its secure-rectangle
72
+ /// contract wants. nil when the window is on no screen.
73
+ ///
74
+ /// The SDK records every window of the app at its place on the screen on iOS,
75
+ /// so this is the window's place on its screen (interface orientation),
76
+ /// through the screen's fixed (portrait) space as the SDK places windows
77
+ /// (`+[BGSTrackerApplication screenRectForRect:inView:]`): converted straight
78
+ /// to `screen.coordinateSpace`, a scene that shares its screen (iPad tiling,
79
+ /// iPhone Duo side by side) reads {0, 0}. An iPhone or iPad app running on a
80
+ /// Mac, and Mac Catalyst, record the key window's scene alone, where the SDK
81
+ /// adds `frame.origin` (`+[BGSTrackerApplication captureRectForRect:inView:]`).
82
+ FOUNDATION_EXPORT NSValue *_Nullable BGSRNWindowRecordedOrigin(UIWindow *window);
83
+
84
+ /// How many views `BGSRNUniqueTaggedView` inspects per window before moving
85
+ /// on to the next. A `<Modal>` host sits inside the React tree, deeper than a
86
+ /// root, so this is larger than `BGSRNReactRootSearchBudget`; it still keeps
87
+ /// a pathological native hierarchy from costing the main thread on a pull.
88
+ FOUNDATION_EXPORT const NSUInteger BGSRNModalHostSearchBudget;
89
+
90
+ /// The one view whose `tag` is `tag` and that `matches` accepts, searching
91
+ /// each of `windows` breadth-first over at most `budget` views per window.
92
+ /// nil when there is none, AND when there is more than one: Fabric sets a
93
+ /// component view's `tag` to its React tag, but tags are not a window-wide
94
+ /// namespace. A native view can carry the same small integer (a non-matching
95
+ /// view does not end the search, unlike `-[UIView viewWithTag:]`), and during
96
+ /// a reload two runtimes' hosts can share one tag, so two matches cannot say
97
+ /// which is current.
98
+ FOUNDATION_EXPORT UIView *_Nullable BGSRNUniqueTaggedView(NSArray<UIWindow *> *windows,
99
+ NSInteger tag,
100
+ BOOL (^matches)(UIView *view),
101
+ NSUInteger budget);
102
+
103
+ /// Where `measureInWindow`'s (0, 0) sits on the screen, in points, inside the
104
+ /// `<Modal>` whose host component view is `host`: the origin of the host's
105
+ /// presented view controller's view in its window, plus `windowOrigin` of
106
+ /// that window: where it starts in the frame the SDK records
107
+ /// (`BGSRNWindowRecordedOrigin`), the same window placement the main surface
108
+ /// uses. Fabric inserts the Modal's children into that view
109
+ /// (`RCTModalHostViewComponentView`), and `measureInWindow` inside a Modal
110
+ /// stops at the `ModalHostView` node with an identity transform, so this is
111
+ /// the window's origin for a full-screen Modal and inset for a `pageSheet` or
112
+ /// `formSheet` one. nil when `host` has no `viewController`, or that view is
113
+ /// not loaded or has no window (the Modal is not presented), or
114
+ /// `windowOrigin` has no place for the window (it is on no screen).
115
+ FOUNDATION_EXPORT NSValue *_Nullable BGSRNModalHostOrigin(UIView *host,
116
+ NSValue *_Nullable (^windowOrigin)(UIWindow *window));
117
+
118
+ /// The screen origin of `surface`, a `<Modal>` lane in `store`. Read from the
119
+ /// current runtime's host (`hostForSurface:accepting:`, which takes a view
120
+ /// `isHost` accepts with that tag) when there is one, even when that gives no
121
+ /// origin yet. nil while a host or lookup the current runtime named finds
122
+ /// nothing (`isHostNamedForSurface:`): the host mounts after the publish, and
123
+ /// until then the origin is unknown. Only when nothing was ever named (no
124
+ /// registry), the one view `isHost` accepts with that tag in `windows`
125
+ /// (`BGSRNUniqueTaggedView`); nil when there are none or several. A nil
126
+ /// leaves the lane's origin as it was: unknown for a new lane, which is
127
+ /// served as the whole display. `windowOrigin` places the host's window, as
128
+ /// for `BGSRNModalHostOrigin`. Main thread only.
129
+ FOUNDATION_EXPORT NSValue *_Nullable BGSRNSecureSurfaceOrigin(BGSRNSecureRectangles *store,
130
+ NSInteger surface,
131
+ NSArray<UIWindow *> *windows,
132
+ BOOL (^isHost)(UIView *view),
133
+ NSValue *_Nullable (^windowOrigin)(UIWindow *window));
134
+
135
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,17 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// High (`BugseeSeverityHigh`, 3). Used when neither the requested severity
6
+ /// nor the launch option is an integer 1..5.
7
+ FOUNDATION_EXPORT const NSInteger BGSRNDefaultBugPriorityFallback;
8
+
9
+ /// `requested` when it is 1..5; otherwise
10
+ /// `launchOptions[BugseeOptionReportingDefaultBugPriority]` when that value
11
+ /// is an integer 1..5; otherwise `BGSRNDefaultBugPriorityFallback`.
12
+ FOUNDATION_EXPORT NSInteger BGSRNUploadSeverity(NSInteger requested, NSDictionary *_Nullable launchOptions);
13
+
14
+ /// nil for nil; the NSString elements otherwise. Anything else is dropped.
15
+ FOUNDATION_EXPORT NSArray<NSString *> *_Nullable BGSRNStringArray(NSArray *_Nullable raw);
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,37 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /// How long JS gets to handle one report callback on iOS.
6
+ ///
7
+ /// The SDK tells a handler which path it is on only by the thread it calls on
8
+ /// (`BGSContracts.h`, `BGSReportHandler`):
9
+ ///
10
+ /// - LIVE: a report raised by the running app. Handlers run on the MAIN
11
+ /// thread, and the SDK waits for each completion, capped at 30 s per
12
+ /// handler. The JS deadline sits 5 s inside that cap: past it the SDK
13
+ /// proceeds without us, and anything JS writes afterwards lands on a report
14
+ /// that has moved on.
15
+ /// - RECOVERY: a report recovered on the next launch. Handlers run OFF main,
16
+ /// in a bounded 3 s window, and the SDK does NOT wait for the completion --
17
+ /// but it re-persists the report when a late completion arrives, until the
18
+ /// bundle is assembled. So, unlike Android, recovery still goes to JS, with
19
+ /// a deadline inside that 3 s window. JS edits there are best-effort, but
20
+ /// real.
21
+ ///
22
+ /// Fixed, not derived from an option: iOS exposes no per-handler timeout
23
+ /// option (Android's `ReportHandlerCallbackTimeout` has no counterpart).
24
+
25
+ /// 5 s inside the SDK's 30 s per-handler cap on the live (main-thread) path.
26
+ FOUNDATION_EXPORT const int64_t BGSRNLiveDeadlineMs;
27
+
28
+ /// 0.5 s inside the SDK's 3 s bounded window on the recovery (off-main) path.
29
+ FOUNDATION_EXPORT const int64_t BGSRNRecoveryDeadlineMs;
30
+
31
+ /// The deadline for a dispatch on the main thread (live) or off it (recovery).
32
+ ///
33
+ /// Takes the thread as an argument, rather than asking `NSThread` itself, so
34
+ /// the rule is testable; the caller passes `NSThread.isMainThread`.
35
+ FOUNDATION_EXPORT int64_t BGSRNDeadlineMs(BOOL onMainThread);
36
+
37
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,94 @@
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
+ typedef NS_ENUM(NSInteger, BGSRNReportPhase) {
9
+ BGSRNReportPhaseBefore,
10
+ BGSRNReportPhaseAfter,
11
+ };
12
+
13
+ /// Receives each `onReportHandlerRequest` payload: `handleId`, `phase`
14
+ /// (`"before"`/`"after"`), `reportId`, `type` and `deadlineMs`. Returns
15
+ /// whether it reached JS; NO completes the handle at once. Must not throw
16
+ /// (see `BGSRNGuardedEmit`).
17
+ typedef BOOL (^BGSRNReportRequestBlock)(NSDictionary<NSString *, id> *request);
18
+
19
+ /// Arms a handle's deadline; returns a token the matching cancel block takes.
20
+ typedef id _Nonnull (^BGSRNReportScheduler)(dispatch_block_t task, int64_t delayMs);
21
+ typedef void (^BGSRNReportSchedulerCancel)(id token);
22
+ /// Where the one-line outcome of every dispatch goes. `NSLog` in production,
23
+ /// which reaches the `devicectl --console` stream the device tests match.
24
+ typedef void (^BGSRNReportOutcomeLog)(NSString *line);
25
+
26
+ /// Routes the SDK's report callbacks to JS and back, through a table of opaque
27
+ /// handles. The iOS mirror of Android's `ReportHandlerBridge`.
28
+ ///
29
+ /// Every dispatch ends in exactly one run of the SDK's completion, whichever
30
+ /// gets there first: JS completing the handle, the handle's deadline, the
31
+ /// bridge detaching (a reload), or a failure to reach JS at all. The guard is
32
+ /// one flag per handle, flipped under the registry lock; the completion itself
33
+ /// always runs OUTSIDE the lock, because it re-enters the SDK.
34
+ ///
35
+ /// Unlike Android, a recovered report (dispatched off the main thread) DOES
36
+ /// reach JS, with the shorter recovery deadline: see `BGSRNReportDeadlines.h`.
37
+ ///
38
+ /// Nothing here hops to the main queue, and nothing may. On the live path the
39
+ /// SDK calls in on main via `dispatch_async`, but it does not wait there for
40
+ /// the completion: that completion is a thread-agnostic run-once that hops to
41
+ /// a private queue, so main is never blocked on it. The rule holds anyway --
42
+ /// there is no need to hop, and an op that did would queue behind whatever UI
43
+ /// work is already on main, eating into the handle's deadline for nothing.
44
+ ///
45
+ /// Like `BGSRNEventBus`, this outlives any one React instance: the wrapper
46
+ /// that calls in is registered at process start, while the module that
47
+ /// receives comes and goes with the JS runtime.
48
+ @interface BGSRNReportHandlerBridge : NSObject
49
+
50
+ @property (class, readonly) BGSRNReportHandlerBridge *shared;
51
+
52
+ /// Tests inject the scheduler; `shared` uses a private serial queue.
53
+ - (instancetype)initWithScheduler:(BGSRNReportScheduler)schedule
54
+ cancel:(BGSRNReportSchedulerCancel)cancel;
55
+
56
+ /// As above, with the outcome lines sent to `log` instead of `NSLog`.
57
+ - (instancetype)initWithScheduler:(BGSRNReportScheduler)schedule
58
+ cancel:(BGSRNReportSchedulerCancel)cancel
59
+ log:(BGSRNReportOutcomeLog)log NS_DESIGNATED_INITIALIZER;
60
+
61
+ - (instancetype)init NS_UNAVAILABLE;
62
+
63
+ /// Which phases the attached JS runtime wants delivered.
64
+ - (void)setPhasesBefore:(BOOL)before after:(BOOL)after;
65
+
66
+ /// Attaches the module of a new JS runtime, replacing whatever was attached,
67
+ /// and clears the phases: the new runtime has registered none yet, and until
68
+ /// it does a dispatch must complete at once rather than wait on a listener
69
+ /// that does not exist. `sink` is held weakly.
70
+ - (void)attach:(id)sink block:(BGSRNReportRequestBlock)block;
71
+
72
+ /// Completes every handle emitted to `sink` -- nothing in any other runtime
73
+ /// knows them. Clears the sink and the phases only if `sink` is still the
74
+ /// attached one: a fast reload attaches the new module before the old one is
75
+ /// invalidated.
76
+ - (void)detach:(id)sink;
77
+
78
+ /// The wrapper's `onBeforeReportCreated:`/`onAfterReportCreated:`. The caller
79
+ /// passes `NSThread.isMainThread` as `onMain`, which selects the deadline.
80
+ - (void)dispatchPhase:(BGSRNReportPhase)phase
81
+ report:(id<BGSReportContract>)report
82
+ isTerminating:(BOOL)isTerminating
83
+ onMainThread:(BOOL)onMain
84
+ completion:(nullable BGSCallback)completion;
85
+
86
+ /// @return YES only for the call that ran the SDK completion.
87
+ - (BOOL)complete:(NSString *)handleId;
88
+
89
+ /// The live report behind `handleId`, or nil once it is completed.
90
+ - (nullable id<BGSReportContract>)reportFor:(NSString *)handleId;
91
+
92
+ @end
93
+
94
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,86 @@
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
+ FOUNDATION_EXPORT NSErrorDomain const BGSRNReportErrorDomain;
9
+
10
+ /// Why a report operation refused. Each maps to one stable wire code of
11
+ /// `src/report/errors.ts` through `BGSRNReportErrorWireCode`.
12
+ typedef NS_ERROR_ENUM(BGSRNReportErrorDomain, BGSRNReportError) {
13
+ /// `E_REPORT_BAD_ARGUMENT`: nothing was applied.
14
+ BGSRNReportErrorBadArgument = 1,
15
+ /// `E_REPORT_ATTACHMENT_REJECTED`: the SDK returned nil for the attachment.
16
+ BGSRNReportErrorAttachmentRejected = 2,
17
+ };
18
+
19
+ /// The JS error code for an error from `BGSRNReportOps`, or nil for any other.
20
+ FOUNDATION_EXPORT NSString *_Nullable BGSRNReportErrorWireCode(NSError *error);
21
+
22
+ /// The `BugseeReport` operations, between the JS wire shape and the SDK's
23
+ /// `BGSReportContract`. The iOS mirror of Android's `ReportOps`.
24
+ ///
25
+ /// Called on the module's own method queue, never the main queue: the
26
+ /// contract's methods are lock-synchronized (`BGSContracts.h`), and there is
27
+ /// no need to hop -- the SDK does not block main waiting on us, and hopping
28
+ /// would only queue an op behind whatever UI work is already there, eating
29
+ /// into the handle's deadline for nothing.
30
+ @interface BGSRNReportOps : NSObject
31
+
32
+ /// The snapshot `reportRead` returns: `summary`, `description` (both omitted
33
+ /// when unset), `severity` (0..5 as the SDK holds it -- 0 is "not set", which
34
+ /// JS reads as undefined), `labels`, `attributes` (string/number/boolean
35
+ /// values only), `screenshotDisplayIds` (ascending) and `attachmentNames`.
36
+ + (NSDictionary<NSString *, id> *)readReport:(id<BGSReportContract>)report;
37
+
38
+ /// Applies a `reportUpdate` patch: validates every field first, and only then
39
+ /// touches the report, so a rejected patch changes nothing.
40
+ + (BOOL)applyPatch:(NSDictionary *)patch
41
+ toReport:(id<BGSReportContract>)report
42
+ error:(NSError **)error;
43
+
44
+ /// The validation half of `applyPatch:toReport:error:`. nil, with `error`,
45
+ /// when any field is invalid — the caller applies nothing. Otherwise the
46
+ /// patch, with attribute numbers already in the form the SDK should store
47
+ /// (an exact integer as an integer). `BGSRNCreatedReportOps` applies the
48
+ /// same dictionary through `BugseeExtendedReport`'s own setters.
49
+ + (nullable NSDictionary<NSString *, id> *)validatedPatch:(NSDictionary *)patch
50
+ error:(NSError **)error;
51
+
52
+ /// `applyPatch:toReport:error:` on the JSON text `reportUpdate` receives
53
+ /// (`BGSRNJSONObject`), which is how a `null` -- clear the summary or
54
+ /// description, remove an attribute -- survives the bridge. Text that is not
55
+ /// a JSON object is `BGSRNReportErrorBadArgument`, and nothing is applied.
56
+ + (BOOL)applyPatchJSON:(NSString *)json
57
+ toReport:(id<BGSReportContract>)report
58
+ error:(NSError **)error;
59
+
60
+ /// `addAttachmentWithFilePath:name:mimeType:move:`. NO with
61
+ /// `BGSRNReportErrorAttachmentRejected` when the SDK returns nil.
62
+ + (BOOL)addFileAtPath:(NSString *)path
63
+ name:(NSString *)name
64
+ mimeType:(nullable NSString *)mimeType
65
+ move:(BOOL)move
66
+ toReport:(id<BGSReportContract>)report
67
+ error:(NSError **)error;
68
+
69
+ /// Decodes `base64` and calls `addAttachmentWithData:name:mimeType:`. NO with
70
+ /// `BGSRNReportErrorBadArgument` when it does not decode (and the SDK is not
71
+ /// called), or `BGSRNReportErrorAttachmentRejected` when the SDK returns nil.
72
+ + (BOOL)addData:(NSString *)base64
73
+ name:(NSString *)name
74
+ mimeType:(nullable NSString *)mimeType
75
+ toReport:(id<BGSReportContract>)report
76
+ error:(NSError **)error;
77
+
78
+ /// What a rejection says when `operation` (e.g. `"reportRead"`) faults with an
79
+ /// `NSException`: the operation only, never the exception's `reason`, which
80
+ /// can echo report content. The iOS mirror of Android's
81
+ /// `ReportOps.failureMessage`.
82
+ + (NSString *)failureMessageForOperation:(NSString *)operation;
83
+
84
+ @end
85
+
86
+ NS_ASSUME_NONNULL_END