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

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 +557 -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 +962 -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,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeSymbolicatePrebuilt = removeSymbolicatePrebuilt;
4
+ exports.insertSymbolicatePrebuilt = insertSymbolicatePrebuilt;
5
+ /**
6
+ * React Native's prebuilt `React.xcframework` ships without dSYMs unless
7
+ * `pod install` runs with RCT_SYMBOLICATE_PREBUILT_FRAMEWORKS=1 (RN
8
+ * scripts/cocoapods/rncore.rb). Without them the Archive's dSYMs folder has no
9
+ * React dSYM and React frames stay raw addresses. Expo's Podfile reads only a
10
+ * fixed set of Podfile.properties.json keys into ENV, so there is no property
11
+ * to set; the plugin adds one marked line to the Podfile instead. `||=` keeps
12
+ * an explicit value from the environment (RCT_SYMBOLICATE_PREBUILT_FRAMEWORKS=0).
13
+ */
14
+ const BEGIN = '# @generated begin bugsee-symbolicate-prebuilt - expo prebuild (DO NOT MODIFY)';
15
+ const END = '# @generated end bugsee-symbolicate-prebuilt';
16
+ const BLOCK = `${BEGIN}\nENV['RCT_SYMBOLICATE_PREBUILT_FRAMEWORKS'] ||= '1'\n${END}\n`;
17
+ const EXISTING = new RegExp(`${escape(BEGIN)}[\\s\\S]*?${escape(END)}\\n?`);
18
+ function escape(text) {
19
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
20
+ }
21
+ function removeSymbolicatePrebuilt(podfile) {
22
+ return podfile.replace(EXISTING, '');
23
+ }
24
+ /** Idempotent: the block is added once, at the top of the Podfile. */
25
+ function insertSymbolicatePrebuilt(podfile) {
26
+ return `${BLOCK}${removeSymbolicatePrebuilt(podfile)}`;
27
+ }
28
+ //# sourceMappingURL=podfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"podfile.js","sourceRoot":"","sources":["../src/podfile.ts"],"names":[],"mappings":";;AAkBA,8DAEC;AAGD,8DAEC;AAzBD;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG,gFAAgF,CAAC;AAC/F,MAAM,GAAG,GAAG,8CAA8C,CAAC;AAC3D,MAAM,KAAK,GAAG,GAAG,KAAK,yDAAyD,GAAG,IAAI,CAAC;AACvF,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE5E,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,yBAAyB,CAAC,OAAe;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,sEAAsE;AACtE,SAAgB,yBAAyB,CAAC,OAAe;IACvD,OAAO,GAAG,KAAK,GAAG,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;AACzD,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare function isPlaceholderToken(token: string): boolean;
2
+ export interface PropertiesInput {
3
+ readonly appToken?: string;
4
+ /** Defaults on. Opt out with `false`. */
5
+ readonly nativeCrashReporting?: boolean;
6
+ /** A base `pluginEndpoint` validated; written as `plugin.endpoint`. */
7
+ readonly endpoint?: string;
8
+ }
9
+ /**
10
+ * `<rootProject>/bugsee.properties`. The token is the unprefixed `app_token`
11
+ * key, written only for a real token: the Gradle plugin uploads the R8
12
+ * mapping and registers the APK with any `app_token` it finds, so a
13
+ * placeholder would reach `plugin.endpoint`, or production. For the same
14
+ * token, `plugin.ndk.enabled=true` follows while native crash reporting is on
15
+ * (the default). `plugin.appToken` is not a key the Gradle plugin reads, and
16
+ * this file never emits it. `plugin.endpoint` is the `endpoint` option, for
17
+ * every Gradle upload; without it the plugin's default, production, stands.
18
+ */
19
+ export declare function bugseePropertiesText(input?: PropertiesInput): string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlaceholderToken = isPlaceholderToken;
4
+ exports.bugseePropertiesText = bugseePropertiesText;
5
+ /**
6
+ * Same rule as `isPlaceholderToken` in examples/bare/endpoint.ts. The CI
7
+ * token `00000000-0000-4000-8000-000000000000` matches. Copied here so the
8
+ * plugin does not import the example app.
9
+ */
10
+ const PLACEHOLDER_TOKEN = /^0{12}[0-9a-f]0{3}[0-9a-f]0{15}$/i;
11
+ function isPlaceholderToken(token) {
12
+ return PLACEHOLDER_TOKEN.test(token.replace(/-/g, ''));
13
+ }
14
+ /**
15
+ * `<rootProject>/bugsee.properties`. The token is the unprefixed `app_token`
16
+ * key, written only for a real token: the Gradle plugin uploads the R8
17
+ * mapping and registers the APK with any `app_token` it finds, so a
18
+ * placeholder would reach `plugin.endpoint`, or production. For the same
19
+ * token, `plugin.ndk.enabled=true` follows while native crash reporting is on
20
+ * (the default). `plugin.appToken` is not a key the Gradle plugin reads, and
21
+ * this file never emits it. `plugin.endpoint` is the `endpoint` option, for
22
+ * every Gradle upload; without it the plugin's default, production, stands.
23
+ */
24
+ function bugseePropertiesText(input = {}) {
25
+ const token = input.appToken ?? '';
26
+ const lines = [];
27
+ if (token.length > 0 && !isPlaceholderToken(token)) {
28
+ lines.push(`app_token=${token}`);
29
+ if (input.nativeCrashReporting !== false) {
30
+ lines.push('plugin.ndk.enabled=true');
31
+ }
32
+ }
33
+ if (input.endpoint) {
34
+ lines.push(`plugin.endpoint=${input.endpoint}`);
35
+ }
36
+ if (lines.length === 0) {
37
+ return '# Generated by @bugsee/react-native. No app token configured.\n';
38
+ }
39
+ return `${lines.join('\n')}\n`;
40
+ }
41
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":";;AAOA,gDAEC;AAoBD,oDAgBC;AA7CD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AAE9D,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC;AAUD;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAAC,QAAyB,EAAE;IAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QACnD,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,EAAE,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,oBAAoB,KAAK,KAAK,EAAE,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,mBAAmB,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,iEAAiE,CAAC;IAC3E,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { DSYM_POST_ACTION_SCRIPT } from './dsym-script';
2
+ export { DSYM_POST_ACTION_SCRIPT };
3
+ export declare function encodeXmlAttr(value: string): string;
4
+ /**
5
+ * Inserts the Archive post-action. The EnvironmentBuildable is the scheme's
6
+ * own app target, so ARCHIVE_PATH is provided. Xcode allows one PostActions
7
+ * element; a scheme that already has one gets another ExecutionAction inside
8
+ * it. A wrapping PostActions is emitted only when ArchiveAction has none.
9
+ * An action an earlier prebuild inserted is replaced, so a changed token
10
+ * reaches the scheme.
11
+ */
12
+ export declare function insertDsymPostAction(scheme: string, script?: string): string;
13
+ /**
14
+ * Removes the Archive post-action this plugin inserted. A later prebuild
15
+ * with `uploadSymbols: false` has to undo an earlier default-on edit,
16
+ * because insert is otherwise one-way. A sibling ExecutionAction stays.
17
+ * When the Bugsee action was the only child, the wrapping PostActions
18
+ * element goes too, so the scheme stays valid.
19
+ */
20
+ export declare function removeDsymPostAction(scheme: string): string;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DSYM_POST_ACTION_SCRIPT = void 0;
4
+ exports.encodeXmlAttr = encodeXmlAttr;
5
+ exports.insertDsymPostAction = insertDsymPostAction;
6
+ exports.removeDsymPostAction = removeDsymPostAction;
7
+ const dsym_script_1 = require("./dsym-script");
8
+ Object.defineProperty(exports, "DSYM_POST_ACTION_SCRIPT", { enumerable: true, get: function () { return dsym_script_1.DSYM_POST_ACTION_SCRIPT; } });
9
+ function encodeXmlAttr(value) {
10
+ return value
11
+ .replace(/&/g, '&amp;')
12
+ .replace(/"/g, '&quot;')
13
+ .replace(/</g, '&lt;')
14
+ .replace(/>/g, '&gt;')
15
+ .replace(/\r/g, '&#13;')
16
+ .replace(/\n/g, '&#10;');
17
+ }
18
+ const ARCHIVE_ACTION = /<ArchiveAction\b[\s\S]*?<\/ArchiveAction>/;
19
+ function appBuildableReference(scheme) {
20
+ const refs = scheme.match(/<BuildableReference\b[\s\S]*?<\/BuildableReference>/g) ?? [];
21
+ const app = refs.find((ref) => /BuildableName\s*=\s*"[^"]+\.app"/.test(ref));
22
+ if (!app) {
23
+ throw new Error('scheme has no .app BuildableReference');
24
+ }
25
+ return app;
26
+ }
27
+ /**
28
+ * The reference is copied from the BuildAction, where it sits at another
29
+ * depth; shift it so it nests under EnvironmentBuildable.
30
+ */
31
+ function nestReference(reference, indent) {
32
+ const refLines = reference.split('\n');
33
+ const closing = refLines[refLines.length - 1] ?? '';
34
+ const depth = closing.length - closing.trimStart().length;
35
+ return refLines.map((line, i) => indent + (i === 0 ? line : line.slice(depth))).join('\n');
36
+ }
37
+ function executionActionXml(reference, script) {
38
+ return [
39
+ ' <ExecutionAction',
40
+ ' ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">',
41
+ ' <ActionContent',
42
+ ' title = "Upload dSYMs"',
43
+ ` scriptText = "${encodeXmlAttr(script)}">`,
44
+ ' <EnvironmentBuildable>',
45
+ nestReference(reference, ' '),
46
+ ' </EnvironmentBuildable>',
47
+ ' </ActionContent>',
48
+ ' </ExecutionAction>',
49
+ ].join('\n');
50
+ }
51
+ /**
52
+ * Inserts the Archive post-action. The EnvironmentBuildable is the scheme's
53
+ * own app target, so ARCHIVE_PATH is provided. Xcode allows one PostActions
54
+ * element; a scheme that already has one gets another ExecutionAction inside
55
+ * it. A wrapping PostActions is emitted only when ArchiveAction has none.
56
+ * An action an earlier prebuild inserted is replaced, so a changed token
57
+ * reaches the scheme.
58
+ */
59
+ function insertDsymPostAction(scheme, script = dsym_script_1.DSYM_POST_ACTION_SCRIPT) {
60
+ scheme = removeDsymPostAction(scheme);
61
+ const archive = ARCHIVE_ACTION.exec(scheme);
62
+ if (!archive) {
63
+ throw new Error('ArchiveAction missing');
64
+ }
65
+ const execution = executionActionXml(appBuildableReference(scheme), script);
66
+ const updated = insertArchiveExecution(archive[0], execution);
67
+ return scheme.slice(0, archive.index) + updated + scheme.slice(archive.index + archive[0].length);
68
+ }
69
+ function insertArchiveExecution(archive, execution) {
70
+ const open = /<PostActions\b[^>]*>/.exec(archive);
71
+ const closeAt = archive.indexOf('</PostActions>');
72
+ if (open && closeAt > open.index) {
73
+ const lineStart = archive.lastIndexOf('\n', closeAt - 1) + 1;
74
+ return archive.slice(0, lineStart) + execution + '\n' + archive.slice(lineStart);
75
+ }
76
+ const block = [' <PostActions>', execution, ' </PostActions>'].join('\n');
77
+ return archive.replace(/[ \t]*<\/ArchiveAction>/, `${block}\n </ArchiveAction>`);
78
+ }
79
+ const EXECUTION_ACTION = /[ \t]*<ExecutionAction\b[\s\S]*?<\/ExecutionAction>\n?/g;
80
+ const EMPTY_POST_ACTIONS = /\n[ \t]*<PostActions\b[^>]*>\s*<\/PostActions>/g;
81
+ /**
82
+ * Removes the Archive post-action this plugin inserted. A later prebuild
83
+ * with `uploadSymbols: false` has to undo an earlier default-on edit,
84
+ * because insert is otherwise one-way. A sibling ExecutionAction stays.
85
+ * When the Bugsee action was the only child, the wrapping PostActions
86
+ * element goes too, so the scheme stays valid.
87
+ */
88
+ function removeDsymPostAction(scheme) {
89
+ const archive = ARCHIVE_ACTION.exec(scheme);
90
+ if (!archive) {
91
+ return scheme;
92
+ }
93
+ let removed = false;
94
+ let archiveXml = archive[0].replace(EXECUTION_ACTION, (block) => {
95
+ if (!block.includes('xcode post-action')) {
96
+ return block;
97
+ }
98
+ removed = true;
99
+ return '';
100
+ });
101
+ if (!removed) {
102
+ return scheme;
103
+ }
104
+ archiveXml = archiveXml.replace(EMPTY_POST_ACTIONS, '');
105
+ return scheme.slice(0, archive.index) + archiveXml + scheme.slice(archive.index + archive[0].length);
106
+ }
107
+ //# sourceMappingURL=scheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheme.js","sourceRoot":"","sources":["../src/scheme.ts"],"names":[],"mappings":";;;AAIA,sCAQC;AA+CD,oDASC;AAuBD,oDAkBC;AA7GD,+CAAwD;AAE/C,wGAFA,qCAAuB,OAEA;AAEhC,SAAgB,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,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,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACvG,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * React Native derives a Swift package name for every autolinked dependency
3
+ * with `toSwiftName()`, which strips the npm scope. That turns
4
+ * `@bugsee/react-native` into `ReactNative` — which is in RN's
5
+ * RESERVED_SWIFT_NAMES, alongside ReactCodegen, Autolinked and the header
6
+ * products.
7
+ *
8
+ * Left alone, the autolinker silently "scope-borrows" to `BugseeReactNative`,
9
+ * and THAT becomes the product name `ios/Package.swift` must vend. Pinning it
10
+ * here makes the contract explicit instead of emergent, and stops a future
11
+ * change to RN's collision handling from renaming our product underneath us.
12
+ *
13
+ * Verified against RN 0.87.1:
14
+ * toSwiftName('@bugsee/react-native') === 'ReactNative' // reserved
15
+ */
16
+ module.exports = {
17
+ dependency: {
18
+ platforms: {
19
+ ios: {},
20
+ android: {},
21
+ },
22
+ },
23
+ spm: {
24
+ name: 'BugseeReactNative',
25
+ },
26
+ };
@@ -0,0 +1,201 @@
1
+ // Bugsee: debug ids and source-map upload for React Native release bundles.
2
+ //
3
+ // Apply it at the end of the app module's build.gradle. The Expo config
4
+ // plugin writes that line; a bare app resolves the package through node, so
5
+ // a hoisted or nested install works too (README, "Android source maps"):
6
+ // def bugseeDir = new File(["node", "--print", "require.resolve('@bugsee/react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile()
7
+ // apply from: new File(new File(bugseeDir, "scripts"), "bugsee-sourcemaps.gradle")
8
+ //
9
+ // After each createBundle<Variant>JsAndAssets:
10
+ // - Hermes on: hermesc must have run through the preserve wrapper
11
+ // (react { hermesCommand = ... }: hermesc-preserve-js.sh on macOS and
12
+ // Linux, hermesc-preserve-js.cmd on Windows). The debug id is injected into the
13
+ // composed map and the bytecode, then that map is uploaded. Without the
14
+ // preserved JS the task fails: the bundle would ship without a debug id.
15
+ // - Hermes off: the packaged bundle is Metro's JS and the map is Metro's;
16
+ // both get the debug id, then the map is uploaded. Any preserve file is an
17
+ // earlier build's and is ignored.
18
+ // The upload needs a real token (app_token in the root bugsee.properties, or
19
+ // BUGSEE_APP_TOKEN). Without one, with the placeholder, with
20
+ // -PbugseeUploadSourcemaps=false or BUGSEE_UPLOAD_SOURCEMAPS=false it skips
21
+ // with one line, and a failed upload warns: neither fails the build. The
22
+ // version and build number are those of the variant that owns the task.
23
+ //
24
+ // Paths are built with File, never with a separator, and node is RN's own
25
+ // nodeExecutableAndArgs. Not yet verified with Gradle's configuration cache.
26
+
27
+ // Applied twice, the second copy would find the first one's preserve file
28
+ // gone and fail a correctly wired build. Only the first apply counts.
29
+ if (project.extensions.extraProperties.has("bugseeSourcemapsApplied")) {
30
+ return
31
+ }
32
+ project.extensions.extraProperties.set("bugseeSourcemapsApplied", true)
33
+
34
+ def bugseeHermesSourcemaps = new File(buildscript.sourceFile.parentFile, "hermes-sourcemaps.js")
35
+ def bugseeUploadSourcemaps = String.valueOf(findProperty('bugseeUploadSourcemaps') ?: 'true')
36
+ def bugseeProperties = rootProject.file("bugsee.properties")
37
+ def bugseeBuildDir = project.layout.buildDirectory.get().asFile
38
+ def bugseeVariantVersions = [:]
39
+
40
+ // Keyed the way React Native names the task: createBundle + the variant name
41
+ // with its first letter title-cased + JsAndAssets. A flavor declared with a
42
+ // capital keeps its name. Character.toTitleCase is what RN 0.87 uses and is
43
+ // locale-insensitive; String.toUpperCase() is not (under tr_TR an "i" becomes
44
+ // "İ", and the lookup would miss). Only the two version providers are kept.
45
+ androidComponents.onVariants(androidComponents.selector().all()) { variant ->
46
+ def output = variant.outputs.first()
47
+ def key = String.valueOf(Character.toTitleCase(variant.name.charAt(0))) + variant.name.substring(1)
48
+ bugseeVariantVersions[key] = [output.versionName, output.versionCode]
49
+ }
50
+
51
+ // The preserve wrapper writes beside generated/assets/<x> in
52
+ // intermediates/bugsee-sourcemaps/<x>. Null when the bundle is elsewhere.
53
+ def bugseePreserveDir = { File assetDir ->
54
+ def relative = bugseeBuildDir.toPath().relativize(assetDir.toPath())
55
+ if (relative.nameCount < 3 || relative.getName(0).toString() != "generated" || relative.getName(1).toString() != "assets") {
56
+ return null
57
+ }
58
+ bugseeBuildDir.toPath().resolve("intermediates").resolve("bugsee-sourcemaps")
59
+ .resolve(relative.subpath(2, relative.nameCount)).toFile()
60
+ }
61
+
62
+ // The hermesCommand the README and expo prebuild write: the launcher for the
63
+ // host, so one build.gradle serves macOS, Linux and Windows.
64
+ def bugseeHermesCommandFix =
65
+ "react { hermesCommand = new File(new File(bugseeDir, \"scripts\"), " +
66
+ "System.getProperty(\"os.name\").startsWith(\"Windows\") ? \"hermesc-preserve-js.cmd\" : \"hermesc-preserve-js.sh\").absolutePath }"
67
+
68
+ def bugseeMissingPreserve = { String taskName ->
69
+ "Bugsee: ${taskName} compiled the bundle with Hermes, but hermesc did not run through " +
70
+ "the preserve wrapper, so the app would ship without a debug id and its source map could " +
71
+ "not be uploaded. Set ${bugseeHermesCommandFix} " +
72
+ "in this module's build.gradle (expo prebuild writes it). See " +
73
+ "node_modules/@bugsee/react-native/README.md, \"Android source maps\"."
74
+ }
75
+
76
+ // React Native runs hermesCommand through `cmd /c` on Windows, and cmd cannot
77
+ // run a shell script: it exits 0, no bytecode is written, and the task only
78
+ // fails later on a missing .hbc. Say why before that happens.
79
+ def bugseeShellOnWindows = { String taskName, String command ->
80
+ "Bugsee: ${taskName} would run hermesc through ${command}, a shell script, but on Windows " +
81
+ "React Native runs hermesCommand with cmd, which cannot run it, so no bytecode would be " +
82
+ "written. Set ${bugseeHermesCommandFix} in this module's build.gradle (expo prebuild " +
83
+ "writes it). See node_modules/@bugsee/react-native/README.md, \"Android source maps\"."
84
+ }
85
+
86
+ // React Native runs hermesCommand through `cmd /c` on Windows, and cmd cuts a
87
+ // launcher path that holds a space or one of ( ) & < > ^ |. Quoted (Java
88
+ // quotes a path with a space), cmd strips the quotes unless the path is free
89
+ // of ( ) & < > @ ^ |, so "C:\Program Files (x86)\..." runs as "C:\Program".
90
+ // Unquoted (no space), ( ) still group: C:\Users\John(US)\... runs as
91
+ // "C:\Users\John". React Native passes its own paths relative to the project
92
+ // root and runs hermesc from there, so on Windows the launcher is given the
93
+ // same way whenever its absolute path holds any of those characters. The
94
+ // relative path goes unquoted, so @ in it is fine (node_modules\@bugsee).
95
+ // Another drive, or a relative path that holds a space or ( ) & < > ^ | too,
96
+ // keeps the command as written. Kept on the project for the hook's tests.
97
+ def bugseeCmdUnsafe = ~/[\s()&<>^|@]/
98
+ def bugseeCmdUnsafeUnquoted = ~/[\s()&<>^|]/
99
+ def bugseeCmdSafeCommand = { String command, File root ->
100
+ def file = new File(command)
101
+ if (!(command =~ bugseeCmdUnsafe) || !file.isAbsolute()) {
102
+ return command
103
+ }
104
+ try {
105
+ def relative = root.toPath().toAbsolutePath().normalize()
106
+ .relativize(file.toPath().toAbsolutePath().normalize()).toString()
107
+ return (relative =~ bugseeCmdUnsafeUnquoted) ? command : relative
108
+ } catch (IllegalArgumentException ignored) {
109
+ return command
110
+ }
111
+ }
112
+ project.extensions.extraProperties.set("bugseeCmdSafeCommand", bugseeCmdSafeCommand)
113
+ def bugseeReact = project.extensions.findByName("react")
114
+ if (System.getProperty("os.name").startsWith("Windows") && bugseeReact != null && bugseeReact.hermesCommand.isPresent()) {
115
+ def written = bugseeReact.hermesCommand.get()
116
+ def safe = bugseeCmdSafeCommand(written, bugseeReact.root.get().asFile)
117
+ if (safe != written) {
118
+ bugseeReact.hermesCommand.set(safe)
119
+ }
120
+ }
121
+
122
+ tasks.matching { task ->
123
+ task.name.startsWith("createBundle") && task.name.endsWith("JsAndAssets")
124
+ }.configureEach { bundleTask ->
125
+ bundleTask.doFirst {
126
+ def command = bundleTask.hermesCommand.getOrElse("")
127
+ if (bundleTask.hermesEnabled.get() && System.getProperty("os.name").startsWith("Windows") &&
128
+ command.toLowerCase(Locale.ROOT).endsWith(".sh")) {
129
+ throw new GradleException(bugseeShellOnWindows(bundleTask.name, command))
130
+ }
131
+ }
132
+ bundleTask.doLast {
133
+ def asset = bundleTask.bundleAssetName.get()
134
+ def assetDir = bundleTask.jsBundleDir.get().asFile
135
+ // Assets are packaged, intermediates are not.
136
+ def preserveDir = bugseePreserveDir(assetDir)
137
+ def preserved = preserveDir == null ? null : new File(preserveDir, asset + ".bugsee-js-source")
138
+ def hermescNote = preserveDir == null ? null : new File(preserveDir, asset + ".bugsee-hermesc")
139
+ def packagedCopies = [
140
+ new File(assetDir, asset + ".bugsee-js-source"),
141
+ new File(assetDir, asset + ".bugsee-hermesc"),
142
+ new File(assetDir, asset + ".bugsee-recompile"),
143
+ new File(assetDir, asset + ".bugsee-recompile.map"),
144
+ ]
145
+ // createBundleFreeReleaseJsAndAssets belongs to variant freeRelease.
146
+ def versions = bugseeVariantVersions[bundleTask.name.substring("createBundle".length(), bundleTask.name.length() - "JsAndAssets".length())]
147
+ def versionName = versions == null ? null : versions[0].getOrNull()
148
+ def versionCode = versions == null ? null : versions[1].getOrNull()
149
+ def composed = new File(bundleTask.jsSourceMapsDir.get().asFile, asset + ".map")
150
+ try {
151
+ def cmd = []
152
+ cmd.addAll(bundleTask.nodeExecutableAndArgs.get())
153
+ cmd.addAll([bugseeHermesSourcemaps.absolutePath, "finish"])
154
+ if (bundleTask.hermesEnabled.get()) {
155
+ if (preserved == null || !preserved.isFile()) {
156
+ throw new GradleException(bugseeMissingPreserve(bundleTask.name))
157
+ }
158
+ def interDir = bundleTask.jsIntermediateSourceMapsDir.get().asFile
159
+ cmd.addAll([
160
+ "--bundle", preserved.absolutePath,
161
+ "--bytecode", new File(assetDir, asset).absolutePath,
162
+ "--composed", composed.absolutePath,
163
+ "--intermediate", new File(interDir, asset + ".compiler.map").absolutePath,
164
+ "--packager", new File(interDir, asset + ".packager.map").absolutePath,
165
+ "--compose", new File(new File(bundleTask.reactNativeDir.get().asFile, "scripts"), "compose-source-maps.js").absolutePath,
166
+ ])
167
+ if (hermescNote.isFile()) {
168
+ cmd.add("--hermesc")
169
+ cmd.add(hermescNote.getText("UTF-8").trim())
170
+ }
171
+ bundleTask.hermesFlags.get().each { flag ->
172
+ cmd.add("--hermes-arg")
173
+ cmd.add(flag)
174
+ }
175
+ } else {
176
+ cmd.addAll([
177
+ "--bundle", new File(assetDir, asset).absolutePath,
178
+ "--composed", composed.absolutePath,
179
+ ])
180
+ }
181
+ cmd.addAll([
182
+ "--platform", "android",
183
+ "--project-root", bundleTask.root.get().asFile.absolutePath,
184
+ "--properties", bugseeProperties.absolutePath,
185
+ "--upload-sourcemaps", bugseeUploadSourcemaps,
186
+ // Not Elvis: versionCode 0 is a valid code.
187
+ "--app-version", versionName == null ? "" : versionName.toString(),
188
+ "--app-build", versionCode == null ? "" : versionCode.toString(),
189
+ ])
190
+ // Gradle 9 removed Project.exec.
191
+ bundleTask.services.get(org.gradle.process.ExecOperations).exec {
192
+ commandLine cmd
193
+ }
194
+ } finally {
195
+ packagedCopies.each { copy -> copy.delete() }
196
+ // This build's only: a later build must never recompile them.
197
+ preserved?.delete()
198
+ hermescNote?.delete()
199
+ }
200
+ }
201
+ }
@@ -0,0 +1,83 @@
1
+ #!/bin/bash
2
+ # Compose the Hermes source map, then inject a debug id into that composed
3
+ # map and into the JavaScript hermesc compiles, then upload that map with
4
+ # bugsee-cli. The upload needs a real app token: BUGSEE_PLUGIN_APP_TOKEN (the
5
+ # Expo plugin bakes it into this phase), BUGSEE_APP_TOKEN, BUGSEE_TOKEN_IOS,
6
+ # or `ios` in ../credentials.json. BUGSEE_UPLOAD_SOURCEMAPS=false turns it off.
7
+ # Debug configurations skip it unless BUGSEE_UPLOAD_DEBUG_SOURCEMAPS=true.
8
+ # Without a token, or with the placeholder, one build-log line says it skipped.
9
+ # A failed upload warns; it never fails the build.
10
+
11
+ set -euo pipefail
12
+
13
+ # react-native-xcode.sh cds to PROJECT_ROOT before compose. CocoaPods expands
14
+ # REACT_NATIVE_PATH to an absolute path; SPM leaves it relative to ios/
15
+ # (`../node_modules/react-native`). Resolve it while cwd is still SRCROOT, or
16
+ # Node looks for the composer under the project root after that cd.
17
+ REACT_NATIVE_PATH="$(cd "$REACT_NATIVE_PATH" && pwd)"
18
+ export REACT_NATIVE_PATH
19
+
20
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ REAL_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"
22
+ BUNDLE_NAME="${BUNDLE_NAME:-main}"
23
+
24
+ if [[ -z "${SOURCEMAP_FILE:-}" ]]; then
25
+ mkdir -p "$CONFIGURATION_TEMP_DIR"
26
+ export SOURCEMAP_FILE="$CONFIGURATION_TEMP_DIR/${BUNDLE_NAME}.jsbundle.composed.map"
27
+ fi
28
+
29
+ export BUGSEE_JS_BUNDLE="${CONFIGURATION_BUILD_DIR}/${BUNDLE_NAME}.jsbundle"
30
+ export BUGSEE_BYTECODE_BUNDLE="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${BUNDLE_NAME}.jsbundle"
31
+ export BUGSEE_REAL_COMPOSE="$REACT_NATIVE_PATH/scripts/compose-source-maps.js"
32
+ export COMPOSE_SOURCEMAP_PATH="$HOOK_DIR/compose-then-inject.js"
33
+ export BUGSEE_CREDENTIALS_FILE="${BUGSEE_CREDENTIALS_FILE:-${SRCROOT}/../credentials.json}"
34
+
35
+ if [[ "${CONFIGURATION:-}" == *Debug* ]]; then
36
+ export BUGSEE_HERMES_ARGS="-Og -output-source-map"
37
+ else
38
+ export BUGSEE_HERMES_ARGS="-O -output-source-map"
39
+ fi
40
+
41
+ resolve_hermesc() {
42
+ if [[ -n "${HERMES_CLI_PATH:-}" && -x "$HERMES_CLI_PATH" ]]; then
43
+ echo "$HERMES_CLI_PATH"
44
+ return
45
+ fi
46
+ if [[ -n "${PODS_ROOT:-}" && -x "$PODS_ROOT/hermes-engine/destroot/bin/hermesc" ]]; then
47
+ echo "$PODS_ROOT/hermes-engine/destroot/bin/hermesc"
48
+ return
49
+ fi
50
+ REACT_NATIVE_PATH="$REACT_NATIVE_PATH" "$NODE_BINARY" -e '
51
+ const fs = require("fs");
52
+ const path = require("path");
53
+ try {
54
+ const pkg = require.resolve("hermes-compiler/package.json", {
55
+ paths: [process.env.REACT_NATIVE_PATH],
56
+ });
57
+ const bin = path.join(path.dirname(pkg), "hermesc", "osx-bin", "hermesc");
58
+ if (fs.existsSync(bin)) process.stdout.write(bin);
59
+ } catch (e) {}
60
+ '
61
+ }
62
+
63
+ if [[ "${USE_HERMES:-true}" != "false" ]]; then
64
+ export BUGSEE_HERMESC="$(resolve_hermesc)"
65
+ fi
66
+
67
+ /bin/sh "$REAL_XCODE"
68
+
69
+ # No compose step when Hermes is off. The map Metro wrote is the one to inject
70
+ # and upload. With Hermes on, compose-then-inject.js has already uploaded.
71
+ if [[ "${USE_HERMES:-true}" == "false" && -f "$BUGSEE_BYTECODE_BUNDLE" && -f "$SOURCEMAP_FILE" ]]; then
72
+ "$NODE_BINARY" "$HOOK_DIR/hermes-sourcemaps.js" inject \
73
+ --bundle "$BUGSEE_BYTECODE_BUNDLE" \
74
+ --composed "$SOURCEMAP_FILE"
75
+ "$NODE_BINARY" "$HOOK_DIR/hermes-sourcemaps.js" upload \
76
+ --composed "$SOURCEMAP_FILE" \
77
+ --platform ios \
78
+ --configuration "${CONFIGURATION:-}" \
79
+ --credentials "$BUGSEE_CREDENTIALS_FILE" \
80
+ --app-version "${MARKETING_VERSION:-}" \
81
+ --app-build "${CURRENT_PROJECT_VERSION:-}" \
82
+ --project-root "${PROJECT_ROOT:-$SRCROOT/..}"
83
+ fi
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * Drop-in for React Native's compose-source-maps.js. The Xcode bundle script
6
+ * calls this with `<packager map> <compiler map> -o <composed map>` after
7
+ * hermesc. Compose first, then inject the composed map. The compiler map is
8
+ * the intermediate one and is not the inject target. Then upload that map:
9
+ * this runs only when React Native composed in this build, so the map is never
10
+ * a stale one. Version and build come from Xcode's MARKETING_VERSION and
11
+ * CURRENT_PROJECT_VERSION. A Debug CONFIGURATION is skipped unless
12
+ * BUGSEE_UPLOAD_DEBUG_SOURCEMAPS=true.
13
+ */
14
+
15
+ const { spawnSync } = require('node:child_process');
16
+ const {
17
+ debugUploadAllowed,
18
+ finishAfterCompose,
19
+ resolveUploadSettings,
20
+ uploadComposedSourceMap,
21
+ uploadDisabled,
22
+ } = require('./hermes-sourcemaps');
23
+
24
+ function parseComposeArgv(argv) {
25
+ const positional = [];
26
+ let output;
27
+ for (let i = 0; i < argv.length; i += 1) {
28
+ if (argv[i] === '-o') {
29
+ output = argv[(i += 1)];
30
+ continue;
31
+ }
32
+ positional.push(argv[i]);
33
+ }
34
+ return { packager: positional[0], compiler: positional[1], output };
35
+ }
36
+
37
+ /** React Native's own default: PROJECT_ROOT, else the parent of the ios folder. */
38
+ function projectRootFrom(env) {
39
+ if (env.PROJECT_ROOT) return env.PROJECT_ROOT;
40
+ const ios = env.SRCROOT || env.PROJECT_DIR;
41
+ return ios ? require('node:path').resolve(ios, '..') : undefined;
42
+ }
43
+
44
+ function fail(message) {
45
+ process.stderr.write(`${message}\n`);
46
+ return 1;
47
+ }
48
+
49
+ /** Returns the process exit code. */
50
+ function run(argv, env) {
51
+ const realCompose = env.BUGSEE_REAL_COMPOSE;
52
+ const bundlePath = env.BUGSEE_JS_BUNDLE;
53
+ const bytecodePath = env.BUGSEE_BYTECODE_BUNDLE;
54
+ if (!realCompose || !bundlePath || !bytecodePath) {
55
+ return fail('BUGSEE_REAL_COMPOSE, BUGSEE_JS_BUNDLE and BUGSEE_BYTECODE_BUNDLE must be set');
56
+ }
57
+
58
+ const { packager, compiler, output } = parseComposeArgv(argv);
59
+ if (!packager || !compiler || !output) {
60
+ return fail('usage: compose-then-inject.js <packager map> <compiler map> -o <composed map>');
61
+ }
62
+
63
+ const composed = spawnSync(process.execPath, [realCompose, packager, compiler, '-o', output], {
64
+ encoding: 'utf8',
65
+ });
66
+ if (composed.status !== 0) {
67
+ process.stderr.write(composed.stderr || composed.stdout || '');
68
+ return composed.status || 1;
69
+ }
70
+
71
+ const hermesArgs = (env.BUGSEE_HERMES_ARGS || '-O -output-source-map').split(/\s+/).filter(Boolean);
72
+
73
+ let finished;
74
+ try {
75
+ finished = finishAfterCompose({
76
+ bundlePath,
77
+ bytecodePath,
78
+ composedMapPath: output,
79
+ intermediateMapPath: compiler,
80
+ packagerMapPath: packager,
81
+ composeScript: realCompose,
82
+ hermesc: env.BUGSEE_HERMESC || undefined,
83
+ hermesArgs,
84
+ });
85
+ } catch (err) {
86
+ return fail(err.message);
87
+ }
88
+ if (finished) {
89
+ const settings = resolveUploadSettings({
90
+ platform: 'ios',
91
+ credentialsPath: env.BUGSEE_CREDENTIALS_FILE,
92
+ env,
93
+ });
94
+ uploadComposedSourceMap({
95
+ composedMapPath: output,
96
+ enabled: !uploadDisabled(undefined, env),
97
+ configuration: env.CONFIGURATION,
98
+ allowDebug: debugUploadAllowed(env),
99
+ token: settings.token,
100
+ endpoint: settings.endpoint,
101
+ appVersion: env.MARKETING_VERSION,
102
+ appBuild: env.CURRENT_PROJECT_VERSION,
103
+ projectRoot: projectRootFrom(env),
104
+ });
105
+ }
106
+ return 0;
107
+ }
108
+
109
+ module.exports = { parseComposeArgv, projectRootFrom, run };
110
+
111
+ if (require.main === module) {
112
+ process.exitCode = run(process.argv.slice(2), process.env);
113
+ }