@scalebun/react-native 1.1.0 → 1.2.1

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 (380) hide show
  1. package/dist/scalebun.full.js +33218 -0
  2. package/dist/scalebun.full.js.map +1 -0
  3. package/dist/scalebun.slim.js +30016 -0
  4. package/dist/scalebun.slim.js.map +1 -0
  5. package/lib/commonjs/bootstrap/FeatureRegistry.js +4 -4
  6. package/lib/commonjs/bootstrap/FeatureRegistry.js.map +1 -1
  7. package/lib/commonjs/bootstrap/SDKBootstrapper.js +8 -8
  8. package/lib/commonjs/bootstrap/SDKBootstrapper.js.map +1 -1
  9. package/lib/commonjs/core/config/schema.js +412 -232
  10. package/lib/commonjs/core/config/schema.js.map +1 -1
  11. package/lib/commonjs/core/constants/protocol.js +31 -0
  12. package/lib/commonjs/core/constants/protocol.js.map +1 -0
  13. package/lib/commonjs/core/constants/timings.js +4 -1
  14. package/lib/commonjs/core/constants/timings.js.map +1 -1
  15. package/lib/commonjs/core/lifecycle/appLifecycle.js +1 -1
  16. package/lib/commonjs/core/lifecycle/appLifecycle.js.map +1 -1
  17. package/lib/commonjs/debug/bootstrap.js +30 -10
  18. package/lib/commonjs/debug/bootstrap.js.map +1 -1
  19. package/lib/commonjs/debug/exportBridge.js +5 -3
  20. package/lib/commonjs/debug/exportBridge.js.map +1 -1
  21. package/lib/commonjs/debug/hostResolver.js +2 -2
  22. package/lib/commonjs/debug/hostResolver.js.map +1 -1
  23. package/lib/commonjs/debug/perfWiring.js +4 -4
  24. package/lib/commonjs/debug/perfWiring.js.map +1 -1
  25. package/lib/commonjs/debug/replayWiring.js +5 -5
  26. package/lib/commonjs/debug/replayWiring.js.map +1 -1
  27. package/lib/commonjs/debug/screenTracking.js +2 -2
  28. package/lib/commonjs/debug/screenTracking.js.map +1 -1
  29. package/lib/commonjs/debug/sessionWiring.js +2 -2
  30. package/lib/commonjs/debug/sessionWiring.js.map +1 -1
  31. package/lib/commonjs/features/crash/NativeCrashFeature.js +1 -1
  32. package/lib/commonjs/features/crash/NativeCrashFeature.js.map +1 -1
  33. package/lib/commonjs/features/crash/globalHandler.js +3 -3
  34. package/lib/commonjs/features/crash/globalHandler.js.map +1 -1
  35. package/lib/commonjs/features/crash/nativeCrashBridge.js +7 -7
  36. package/lib/commonjs/features/crash/nativeCrashBridge.js.map +1 -1
  37. package/lib/commonjs/features/crash/rejectionHandler.js +2 -2
  38. package/lib/commonjs/features/crash/rejectionHandler.js.map +1 -1
  39. package/lib/commonjs/features/engage/EngageArchetypeRenderers.js +0 -9
  40. package/lib/commonjs/features/engage/EngageArchetypeRenderers.js.map +1 -1
  41. package/lib/commonjs/features/engage/EngageInAppView.js +1 -1
  42. package/lib/commonjs/features/engage/EngageInAppView.js.map +1 -1
  43. package/lib/commonjs/features/engage/EngagePromptProvider.js +17 -17
  44. package/lib/commonjs/features/engage/EngagePromptProvider.js.map +1 -1
  45. package/lib/commonjs/features/engage/EngageTransport.js +5 -5
  46. package/lib/commonjs/features/engage/EngageTransport.js.map +1 -1
  47. package/lib/commonjs/features/engage/engagePushTokenBridge.js +4 -4
  48. package/lib/commonjs/features/engage/engagePushTokenBridge.js.map +1 -1
  49. package/lib/commonjs/features/engage/engageShakeBridge.js +2 -2
  50. package/lib/commonjs/features/engage/engageShakeBridge.js.map +1 -1
  51. package/lib/commonjs/features/engage/engageSignals.js +1 -1
  52. package/lib/commonjs/features/engage/engageSignals.js.map +1 -1
  53. package/lib/commonjs/features/engage/engageStoreReviewBridge.js +2 -2
  54. package/lib/commonjs/features/engage/engageStoreReviewBridge.js.map +1 -1
  55. package/lib/commonjs/features/engage/engageTestSeenStore.js +1 -1
  56. package/lib/commonjs/features/engage/engageTestSeenStore.js.map +1 -1
  57. package/lib/commonjs/features/engage/engageThrottle.js +4 -4
  58. package/lib/commonjs/features/engage/engageThrottle.js.map +1 -1
  59. package/lib/commonjs/features/engage/engageTriggerEngine.js +4 -4
  60. package/lib/commonjs/features/engage/engageTriggerEngine.js.map +1 -1
  61. package/lib/commonjs/features/engage/engageWindowInsets.js +1 -1
  62. package/lib/commonjs/features/engage/engageWindowInsets.js.map +1 -1
  63. package/lib/commonjs/features/install-referrer/installReferrer.js +3 -3
  64. package/lib/commonjs/features/install-referrer/installReferrer.js.map +1 -1
  65. package/lib/commonjs/features/journey/calibrationContext.js +0 -9
  66. package/lib/commonjs/features/journey/calibrationContext.js.map +1 -1
  67. package/lib/commonjs/features/journey/journeyManager.js +4 -1
  68. package/lib/commonjs/features/journey/journeyManager.js.map +1 -1
  69. package/lib/commonjs/features/navigation/AutoScreenDetector.js +4 -4
  70. package/lib/commonjs/features/navigation/AutoScreenDetector.js.map +1 -1
  71. package/lib/commonjs/features/ota/OtaOrchestrator.js +18 -18
  72. package/lib/commonjs/features/ota/OtaOrchestrator.js.map +1 -1
  73. package/lib/commonjs/features/ota/geoCountry.js +2 -2
  74. package/lib/commonjs/features/ota/geoCountry.js.map +1 -1
  75. package/lib/commonjs/features/ota/retry.js +2 -2
  76. package/lib/commonjs/features/ota/retry.js.map +1 -1
  77. package/lib/commonjs/features/performance/PerformanceFeature.js +121 -23
  78. package/lib/commonjs/features/performance/PerformanceFeature.js.map +1 -1
  79. package/lib/commonjs/features/replay/core/logger/logger.js +0 -4
  80. package/lib/commonjs/features/replay/core/logger/logger.js.map +1 -1
  81. package/lib/commonjs/features/replay/integrations/network/networkAdapter.js +1 -54
  82. package/lib/commonjs/features/replay/integrations/network/networkAdapter.js.map +1 -1
  83. package/lib/commonjs/features/replay/integrations/react-navigation/navigationIntegration.js +1 -1
  84. package/lib/commonjs/features/replay/integrations/react-navigation/navigationIntegration.js.map +1 -1
  85. package/lib/commonjs/features/replay/integrations/touch/ReplayRoot.js +1 -1
  86. package/lib/commonjs/features/replay/integrations/touch/ReplayRoot.js.map +1 -1
  87. package/lib/commonjs/features/replay/pipeline/batching/batchManager.js +1 -1
  88. package/lib/commonjs/features/replay/pipeline/batching/batchManager.js.map +1 -1
  89. package/lib/commonjs/features/replay/pipeline/retry/retryPolicy.js +1 -1
  90. package/lib/commonjs/features/replay/pipeline/retry/retryPolicy.js.map +1 -1
  91. package/lib/commonjs/features/replay/public/api.js +7 -7
  92. package/lib/commonjs/features/replay/public/api.js.map +1 -1
  93. package/lib/commonjs/features/replay/replay/session/sessionOrchestrator.js +9 -9
  94. package/lib/commonjs/features/replay/replay/session/sessionOrchestrator.js.map +1 -1
  95. package/lib/commonjs/features/session/BackendSessionAdapter.js +41 -41
  96. package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
  97. package/lib/commonjs/features/session/DesktopSessionTransport.js +5 -2
  98. package/lib/commonjs/features/session/DesktopSessionTransport.js.map +1 -1
  99. package/lib/commonjs/features/session/JourneyEventPipeline.js +1 -1
  100. package/lib/commonjs/features/session/JourneyEventPipeline.js.map +1 -1
  101. package/lib/commonjs/features/session/ReplayCaptureManager.js +14 -14
  102. package/lib/commonjs/features/session/ReplayCaptureManager.js.map +1 -1
  103. package/lib/commonjs/features/session/SessionManager.js +9 -9
  104. package/lib/commonjs/features/session/SessionManager.js.map +1 -1
  105. package/lib/commonjs/features/session/SyncDecisionEngine.js +1 -1
  106. package/lib/commonjs/features/session/SyncDecisionEngine.js.map +1 -1
  107. package/lib/commonjs/features/skan/skanBridge.js +6 -15
  108. package/lib/commonjs/features/skan/skanBridge.js.map +1 -1
  109. package/lib/commonjs/features/skan/skanConversionManager.js +5 -5
  110. package/lib/commonjs/features/skan/skanConversionManager.js.map +1 -1
  111. package/lib/commonjs/integrations/fetch/fetchInterceptor.js +1 -1
  112. package/lib/commonjs/integrations/fetch/fetchInterceptor.js.map +1 -1
  113. package/lib/commonjs/integrations/xhr/xhrInterceptor.js +1 -1
  114. package/lib/commonjs/integrations/xhr/xhrInterceptor.js.map +1 -1
  115. package/lib/commonjs/metro/composeSourceMap.js +105 -0
  116. package/lib/commonjs/metro/composeSourceMap.js.map +1 -0
  117. package/lib/commonjs/metro/featureModules.js +131 -0
  118. package/lib/commonjs/metro/featureModules.js.map +1 -0
  119. package/lib/commonjs/metro/index.js +123 -2
  120. package/lib/commonjs/metro/index.js.map +1 -1
  121. package/lib/commonjs/metro/serializerCompose.js +129 -0
  122. package/lib/commonjs/metro/serializerCompose.js.map +1 -0
  123. package/lib/commonjs/pipeline/dispatcher/dispatcher.js +1 -1
  124. package/lib/commonjs/pipeline/dispatcher/dispatcher.js.map +1 -1
  125. package/lib/commonjs/pipeline/queue/flushQueue.js +2 -2
  126. package/lib/commonjs/pipeline/queue/flushQueue.js.map +1 -1
  127. package/lib/commonjs/pipeline/queue/persistentQueue.js +6 -37
  128. package/lib/commonjs/pipeline/queue/persistentQueue.js.map +1 -1
  129. package/lib/commonjs/pipeline/scheduler/flushScheduler.js +1 -1
  130. package/lib/commonjs/pipeline/scheduler/flushScheduler.js.map +1 -1
  131. package/lib/commonjs/public/ScaleBunFacade.js +15 -15
  132. package/lib/commonjs/public/ScaleBunFacade.js.map +1 -1
  133. package/lib/commonjs/push/PushManager.js +3 -3
  134. package/lib/commonjs/push/PushManager.js.map +1 -1
  135. package/lib/commonjs/push/adapters/NativeBridgeAdapter.js +1 -1
  136. package/lib/commonjs/push/adapters/NativeBridgeAdapter.js.map +1 -1
  137. package/lib/commonjs/push/native/nativeNotifications.js +7 -18
  138. package/lib/commonjs/push/native/nativeNotifications.js.map +1 -1
  139. package/lib/commonjs/storage/StorageBackend.js +1 -1
  140. package/lib/commonjs/storage/StorageBackend.js.map +1 -1
  141. package/lib/module/bootstrap/FeatureRegistry.js +4 -4
  142. package/lib/module/bootstrap/FeatureRegistry.js.map +1 -1
  143. package/lib/module/bootstrap/SDKBootstrapper.js +8 -8
  144. package/lib/module/bootstrap/SDKBootstrapper.js.map +1 -1
  145. package/lib/module/core/config/schema.js +411 -231
  146. package/lib/module/core/config/schema.js.map +1 -1
  147. package/lib/module/core/constants/protocol.js +25 -0
  148. package/lib/module/core/constants/protocol.js.map +1 -0
  149. package/lib/module/core/constants/timings.js +3 -1
  150. package/lib/module/core/constants/timings.js.map +1 -1
  151. package/lib/module/core/lifecycle/appLifecycle.js +1 -1
  152. package/lib/module/core/lifecycle/appLifecycle.js.map +1 -1
  153. package/lib/module/debug/bootstrap.js +30 -9
  154. package/lib/module/debug/bootstrap.js.map +1 -1
  155. package/lib/module/debug/exportBridge.js +5 -3
  156. package/lib/module/debug/exportBridge.js.map +1 -1
  157. package/lib/module/debug/hostResolver.js +2 -2
  158. package/lib/module/debug/hostResolver.js.map +1 -1
  159. package/lib/module/debug/perfWiring.js +4 -4
  160. package/lib/module/debug/perfWiring.js.map +1 -1
  161. package/lib/module/debug/replayWiring.js +5 -5
  162. package/lib/module/debug/replayWiring.js.map +1 -1
  163. package/lib/module/debug/screenTracking.js +2 -2
  164. package/lib/module/debug/screenTracking.js.map +1 -1
  165. package/lib/module/debug/sessionWiring.js +2 -2
  166. package/lib/module/debug/sessionWiring.js.map +1 -1
  167. package/lib/module/features/crash/NativeCrashFeature.js +1 -1
  168. package/lib/module/features/crash/NativeCrashFeature.js.map +1 -1
  169. package/lib/module/features/crash/globalHandler.js +3 -3
  170. package/lib/module/features/crash/globalHandler.js.map +1 -1
  171. package/lib/module/features/crash/nativeCrashBridge.js +7 -7
  172. package/lib/module/features/crash/nativeCrashBridge.js.map +1 -1
  173. package/lib/module/features/crash/rejectionHandler.js +2 -2
  174. package/lib/module/features/crash/rejectionHandler.js.map +1 -1
  175. package/lib/module/features/engage/EngageArchetypeRenderers.js +0 -8
  176. package/lib/module/features/engage/EngageArchetypeRenderers.js.map +1 -1
  177. package/lib/module/features/engage/EngageInAppView.js +1 -1
  178. package/lib/module/features/engage/EngageInAppView.js.map +1 -1
  179. package/lib/module/features/engage/EngagePromptProvider.js +17 -17
  180. package/lib/module/features/engage/EngagePromptProvider.js.map +1 -1
  181. package/lib/module/features/engage/EngageTransport.js +5 -5
  182. package/lib/module/features/engage/EngageTransport.js.map +1 -1
  183. package/lib/module/features/engage/engagePushTokenBridge.js +4 -4
  184. package/lib/module/features/engage/engagePushTokenBridge.js.map +1 -1
  185. package/lib/module/features/engage/engageShakeBridge.js +2 -2
  186. package/lib/module/features/engage/engageShakeBridge.js.map +1 -1
  187. package/lib/module/features/engage/engageSignals.js +1 -1
  188. package/lib/module/features/engage/engageSignals.js.map +1 -1
  189. package/lib/module/features/engage/engageStoreReviewBridge.js +2 -2
  190. package/lib/module/features/engage/engageStoreReviewBridge.js.map +1 -1
  191. package/lib/module/features/engage/engageTestSeenStore.js +1 -1
  192. package/lib/module/features/engage/engageTestSeenStore.js.map +1 -1
  193. package/lib/module/features/engage/engageThrottle.js +4 -4
  194. package/lib/module/features/engage/engageThrottle.js.map +1 -1
  195. package/lib/module/features/engage/engageTriggerEngine.js +4 -4
  196. package/lib/module/features/engage/engageTriggerEngine.js.map +1 -1
  197. package/lib/module/features/engage/engageWindowInsets.js +1 -1
  198. package/lib/module/features/engage/engageWindowInsets.js.map +1 -1
  199. package/lib/module/features/install-referrer/installReferrer.js +3 -3
  200. package/lib/module/features/install-referrer/installReferrer.js.map +1 -1
  201. package/lib/module/features/journey/calibrationContext.js +0 -8
  202. package/lib/module/features/journey/calibrationContext.js.map +1 -1
  203. package/lib/module/features/journey/journeyManager.js +3 -1
  204. package/lib/module/features/journey/journeyManager.js.map +1 -1
  205. package/lib/module/features/navigation/AutoScreenDetector.js +4 -4
  206. package/lib/module/features/navigation/AutoScreenDetector.js.map +1 -1
  207. package/lib/module/features/ota/OtaOrchestrator.js +18 -18
  208. package/lib/module/features/ota/OtaOrchestrator.js.map +1 -1
  209. package/lib/module/features/ota/geoCountry.js +2 -2
  210. package/lib/module/features/ota/geoCountry.js.map +1 -1
  211. package/lib/module/features/ota/retry.js +2 -2
  212. package/lib/module/features/ota/retry.js.map +1 -1
  213. package/lib/module/features/performance/PerformanceFeature.js +122 -23
  214. package/lib/module/features/performance/PerformanceFeature.js.map +1 -1
  215. package/lib/module/features/replay/core/logger/logger.js +0 -3
  216. package/lib/module/features/replay/core/logger/logger.js.map +1 -1
  217. package/lib/module/features/replay/integrations/network/networkAdapter.js +1 -52
  218. package/lib/module/features/replay/integrations/network/networkAdapter.js.map +1 -1
  219. package/lib/module/features/replay/integrations/react-navigation/navigationIntegration.js +1 -1
  220. package/lib/module/features/replay/integrations/react-navigation/navigationIntegration.js.map +1 -1
  221. package/lib/module/features/replay/integrations/touch/ReplayRoot.js +1 -1
  222. package/lib/module/features/replay/integrations/touch/ReplayRoot.js.map +1 -1
  223. package/lib/module/features/replay/pipeline/batching/batchManager.js +1 -1
  224. package/lib/module/features/replay/pipeline/batching/batchManager.js.map +1 -1
  225. package/lib/module/features/replay/pipeline/retry/retryPolicy.js +1 -1
  226. package/lib/module/features/replay/pipeline/retry/retryPolicy.js.map +1 -1
  227. package/lib/module/features/replay/public/api.js +7 -7
  228. package/lib/module/features/replay/public/api.js.map +1 -1
  229. package/lib/module/features/replay/replay/session/sessionOrchestrator.js +9 -9
  230. package/lib/module/features/replay/replay/session/sessionOrchestrator.js.map +1 -1
  231. package/lib/module/features/session/BackendSessionAdapter.js +41 -41
  232. package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
  233. package/lib/module/features/session/DesktopSessionTransport.js +4 -2
  234. package/lib/module/features/session/DesktopSessionTransport.js.map +1 -1
  235. package/lib/module/features/session/JourneyEventPipeline.js +1 -1
  236. package/lib/module/features/session/JourneyEventPipeline.js.map +1 -1
  237. package/lib/module/features/session/ReplayCaptureManager.js +14 -14
  238. package/lib/module/features/session/ReplayCaptureManager.js.map +1 -1
  239. package/lib/module/features/session/SessionManager.js +9 -9
  240. package/lib/module/features/session/SessionManager.js.map +1 -1
  241. package/lib/module/features/session/SyncDecisionEngine.js +1 -1
  242. package/lib/module/features/session/SyncDecisionEngine.js.map +1 -1
  243. package/lib/module/features/skan/skanBridge.js +6 -14
  244. package/lib/module/features/skan/skanBridge.js.map +1 -1
  245. package/lib/module/features/skan/skanConversionManager.js +5 -5
  246. package/lib/module/features/skan/skanConversionManager.js.map +1 -1
  247. package/lib/module/integrations/fetch/fetchInterceptor.js +1 -1
  248. package/lib/module/integrations/fetch/fetchInterceptor.js.map +1 -1
  249. package/lib/module/integrations/xhr/xhrInterceptor.js +1 -1
  250. package/lib/module/integrations/xhr/xhrInterceptor.js.map +1 -1
  251. package/lib/module/metro/composeSourceMap.js +97 -0
  252. package/lib/module/metro/composeSourceMap.js.map +1 -0
  253. package/lib/module/metro/featureModules.js +123 -0
  254. package/lib/module/metro/featureModules.js.map +1 -0
  255. package/lib/module/metro/index.js +122 -2
  256. package/lib/module/metro/index.js.map +1 -1
  257. package/lib/module/metro/serializerCompose.js +120 -0
  258. package/lib/module/metro/serializerCompose.js.map +1 -0
  259. package/lib/module/pipeline/dispatcher/dispatcher.js +1 -1
  260. package/lib/module/pipeline/dispatcher/dispatcher.js.map +1 -1
  261. package/lib/module/pipeline/queue/flushQueue.js +2 -2
  262. package/lib/module/pipeline/queue/flushQueue.js.map +1 -1
  263. package/lib/module/pipeline/queue/persistentQueue.js +6 -36
  264. package/lib/module/pipeline/queue/persistentQueue.js.map +1 -1
  265. package/lib/module/pipeline/scheduler/flushScheduler.js +1 -1
  266. package/lib/module/pipeline/scheduler/flushScheduler.js.map +1 -1
  267. package/lib/module/public/ScaleBunFacade.js +15 -15
  268. package/lib/module/public/ScaleBunFacade.js.map +1 -1
  269. package/lib/module/push/PushManager.js +3 -3
  270. package/lib/module/push/PushManager.js.map +1 -1
  271. package/lib/module/push/adapters/NativeBridgeAdapter.js +1 -1
  272. package/lib/module/push/adapters/NativeBridgeAdapter.js.map +1 -1
  273. package/lib/module/push/native/nativeNotifications.js +7 -17
  274. package/lib/module/push/native/nativeNotifications.js.map +1 -1
  275. package/lib/module/storage/StorageBackend.js +1 -1
  276. package/lib/module/storage/StorageBackend.js.map +1 -1
  277. package/lib/typescript/core/config/schema.d.ts +61 -40
  278. package/lib/typescript/core/config/schema.d.ts.map +1 -1
  279. package/lib/typescript/core/constants/protocol.d.ts +23 -0
  280. package/lib/typescript/core/constants/protocol.d.ts.map +1 -0
  281. package/lib/typescript/core/constants/timings.d.ts +1 -1
  282. package/lib/typescript/core/constants/timings.d.ts.map +1 -1
  283. package/lib/typescript/debug/bootstrap.d.ts +0 -1
  284. package/lib/typescript/debug/bootstrap.d.ts.map +1 -1
  285. package/lib/typescript/debug/exportBridge.d.ts.map +1 -1
  286. package/lib/typescript/features/engage/EngageArchetypeRenderers.d.ts +0 -2
  287. package/lib/typescript/features/engage/EngageArchetypeRenderers.d.ts.map +1 -1
  288. package/lib/typescript/features/journey/calibrationContext.d.ts +0 -1
  289. package/lib/typescript/features/journey/calibrationContext.d.ts.map +1 -1
  290. package/lib/typescript/features/journey/journeyManager.d.ts.map +1 -1
  291. package/lib/typescript/features/performance/PerformanceFeature.d.ts +31 -0
  292. package/lib/typescript/features/performance/PerformanceFeature.d.ts.map +1 -1
  293. package/lib/typescript/features/replay/core/logger/logger.d.ts +0 -1
  294. package/lib/typescript/features/replay/core/logger/logger.d.ts.map +1 -1
  295. package/lib/typescript/features/replay/integrations/network/networkAdapter.d.ts +0 -10
  296. package/lib/typescript/features/replay/integrations/network/networkAdapter.d.ts.map +1 -1
  297. package/lib/typescript/features/session/DesktopSessionTransport.d.ts.map +1 -1
  298. package/lib/typescript/features/skan/skanBridge.d.ts +0 -2
  299. package/lib/typescript/features/skan/skanBridge.d.ts.map +1 -1
  300. package/lib/typescript/metro/composeSourceMap.d.ts +26 -0
  301. package/lib/typescript/metro/composeSourceMap.d.ts.map +1 -0
  302. package/lib/typescript/metro/featureModules.d.ts +49 -0
  303. package/lib/typescript/metro/featureModules.d.ts.map +1 -0
  304. package/lib/typescript/metro/index.d.ts +22 -0
  305. package/lib/typescript/metro/index.d.ts.map +1 -1
  306. package/lib/typescript/metro/serializerCompose.d.ts +46 -0
  307. package/lib/typescript/metro/serializerCompose.d.ts.map +1 -0
  308. package/lib/typescript/pipeline/queue/persistentQueue.d.ts +0 -10
  309. package/lib/typescript/pipeline/queue/persistentQueue.d.ts.map +1 -1
  310. package/lib/typescript/push/native/nativeNotifications.d.ts +0 -6
  311. package/lib/typescript/push/native/nativeNotifications.d.ts.map +1 -1
  312. package/package.json +15 -11
  313. package/src/bootstrap/FeatureRegistry.ts +4 -4
  314. package/src/bootstrap/SDKBootstrapper.ts +8 -8
  315. package/src/core/config/schema.ts +353 -235
  316. package/src/core/constants/protocol.ts +24 -0
  317. package/src/core/constants/timings.ts +3 -1
  318. package/src/core/lifecycle/appLifecycle.ts +1 -1
  319. package/src/debug/bootstrap.ts +40 -7
  320. package/src/debug/exportBridge.ts +5 -3
  321. package/src/debug/hostResolver.ts +2 -2
  322. package/src/debug/perfWiring.ts +4 -4
  323. package/src/debug/replayWiring.ts +5 -5
  324. package/src/debug/screenTracking.ts +2 -2
  325. package/src/debug/sessionWiring.ts +2 -2
  326. package/src/features/crash/NativeCrashFeature.ts +1 -1
  327. package/src/features/crash/globalHandler.ts +3 -3
  328. package/src/features/crash/nativeCrashBridge.ts +7 -7
  329. package/src/features/crash/rejectionHandler.ts +2 -2
  330. package/src/features/engage/EngageArchetypeRenderers.tsx +0 -11
  331. package/src/features/engage/EngageInAppView.tsx +1 -1
  332. package/src/features/engage/EngagePromptProvider.tsx +17 -17
  333. package/src/features/engage/EngageTransport.ts +5 -5
  334. package/src/features/engage/engagePushTokenBridge.ts +4 -4
  335. package/src/features/engage/engageShakeBridge.ts +2 -2
  336. package/src/features/engage/engageSignals.ts +1 -1
  337. package/src/features/engage/engageStoreReviewBridge.ts +2 -2
  338. package/src/features/engage/engageTestSeenStore.ts +1 -1
  339. package/src/features/engage/engageThrottle.ts +4 -4
  340. package/src/features/engage/engageTriggerEngine.ts +4 -4
  341. package/src/features/engage/engageWindowInsets.ts +1 -1
  342. package/src/features/install-referrer/installReferrer.ts +3 -3
  343. package/src/features/journey/calibrationContext.ts +0 -9
  344. package/src/features/journey/journeyManager.ts +3 -1
  345. package/src/features/navigation/AutoScreenDetector.ts +4 -4
  346. package/src/features/ota/OtaOrchestrator.ts +18 -18
  347. package/src/features/ota/geoCountry.ts +2 -2
  348. package/src/features/ota/retry.ts +2 -2
  349. package/src/features/performance/PerformanceFeature.ts +130 -20
  350. package/src/features/replay/core/logger/logger.ts +0 -4
  351. package/src/features/replay/integrations/network/networkAdapter.ts +1 -56
  352. package/src/features/replay/integrations/react-navigation/navigationIntegration.ts +1 -1
  353. package/src/features/replay/integrations/touch/ReplayRoot.tsx +1 -1
  354. package/src/features/replay/pipeline/batching/batchManager.ts +1 -1
  355. package/src/features/replay/pipeline/retry/retryPolicy.ts +1 -1
  356. package/src/features/replay/public/api.ts +7 -7
  357. package/src/features/replay/replay/session/sessionOrchestrator.ts +9 -9
  358. package/src/features/session/BackendSessionAdapter.ts +41 -41
  359. package/src/features/session/DesktopSessionTransport.ts +4 -2
  360. package/src/features/session/JourneyEventPipeline.ts +1 -1
  361. package/src/features/session/ReplayCaptureManager.ts +14 -14
  362. package/src/features/session/SessionManager.ts +9 -9
  363. package/src/features/session/SyncDecisionEngine.ts +1 -1
  364. package/src/features/skan/skanBridge.ts +6 -14
  365. package/src/features/skan/skanConversionManager.ts +5 -5
  366. package/src/integrations/fetch/fetchInterceptor.ts +1 -1
  367. package/src/integrations/xhr/xhrInterceptor.ts +1 -1
  368. package/src/metro/composeSourceMap.ts +104 -0
  369. package/src/metro/featureModules.ts +143 -0
  370. package/src/metro/index.ts +173 -1
  371. package/src/metro/serializerCompose.ts +157 -0
  372. package/src/pipeline/dispatcher/dispatcher.ts +1 -1
  373. package/src/pipeline/queue/flushQueue.ts +2 -2
  374. package/src/pipeline/queue/persistentQueue.ts +6 -35
  375. package/src/pipeline/scheduler/flushScheduler.ts +1 -1
  376. package/src/public/ScaleBunFacade.ts +15 -15
  377. package/src/push/PushManager.ts +3 -3
  378. package/src/push/adapters/NativeBridgeAdapter.ts +1 -1
  379. package/src/push/native/nativeNotifications.ts +7 -16
  380. package/src/storage/StorageBackend.ts +1 -1
@@ -1,241 +1,359 @@
1
- import { z, type Infer } from '../../vendor/protocol';
1
+ /**
2
+ * ScaleBun SDK — init-config validation and normalization.
3
+ *
4
+ * Hand-rolled, table-driven replacement for the vendored mini-Zod this schema used to be built
5
+ * on. The generic validator cost ~6.7 KB of minified bundle to serve exactly one consumer —
6
+ * `SDKBootstrapper.safeParse(rawConfig)` — so the machinery is replaced by a field table and a
7
+ * ~1.5 KB engine with BEHAVIOUR PARITY, byte-for-byte on messages:
8
+ *
9
+ * - same accept/reject decisions (strict types, no coercion; min/max reject rather than clamp)
10
+ * - same normalized output (defaults filled, nested defaults via `{}`, unknown keys stripped,
11
+ * optional-and-absent keys omitted)
12
+ * - same error surface (`safeParse` → `{ success, data | error }`, error with `.issues`
13
+ * [{path, message}] and Zod-style `.format()`), with identical message strings
14
+ *
15
+ * The parity suite in __tests__/schemaParity.test.ts runs a generated matrix of configs against
16
+ * BOTH this implementation and a verbatim copy of the old vendored-z construction, and
17
+ * deep-compares every result. Changing behaviour here without failing that suite should be
18
+ * treated as impossible; if you extend the config, extend the parity suite's reference schema in
19
+ * the same commit.
20
+ *
21
+ * `apiBaseUrl` note: any value is accepted (`kind: 'any'`, backward compatibility) but the
22
+ * bootstrapper force-overwrites it with DEFAULT_API_BASE_URL immediately after parse — the
23
+ * endpoint is locked at build time by design.
24
+ */
2
25
  import { DEFAULT_TIER2_SAMPLE_RATE } from '../../features/performance/config';
3
26
  import { DEFAULT_API_BASE_URL } from '../constants/endpoints';
4
27
 
5
- export const ConfigSchema = z.object({
6
- projectId: z.string().min(1).optional(),
7
- publishableKey: z.string().min(1).optional(),
8
- /**
9
- * Backend API base URL. LOCKED to {@link DEFAULT_API_BASE_URL} — the ScaleBun
10
- * cloud endpoint is fixed and cannot be overridden by integrators. Any value
11
- * supplied here is accepted (no validation error, for backward compatibility)
12
- * but ignored: the bootstrapper force-overwrites it with DEFAULT_API_BASE_URL
13
- * immediately after parse. To point the SDK at a different backend, change the
14
- * constant at build time.
15
- */
16
- // NB: `.default()` on the vendored `z` types its arg as `Partial<T> | (() => T)`, so a bare
17
- // string arg fails `tsc` (.d.ts generation via bob) with TS2345. The factory form satisfies the
18
- // `(() => any)` overload. Behaviour is identical — omitted apiBaseUrl resolves to the default,
19
- // which the bootstrapper overwrites anyway (the endpoint is locked).
20
- apiBaseUrl: z.any().default(() => DEFAULT_API_BASE_URL),
21
- debug: z.boolean().default(false),
22
- /**
23
- * SDK internal log verbosity. Recoverable transport failures are logged at
24
- * 'warn' (never console.error), so they never surface as a RedBox.
25
- * Default: 'warn'. If omitted and debug=true, the bootstrapper uses 'debug'.
26
- */
27
- logLevel: z.enum(['silent', 'error', 'warn', 'info', 'debug']).optional(),
28
- flushIntervalMs: z.number().min(1000).default(5000),
29
- /**
30
- * When true, end the recording session on APP_BACKGROUND and start a fresh
31
- * one on next foreground (per-foreground sessions). Default false: a single
32
- * session spans app-switches; the server-side reaper closes it if the app is
33
- * killed in the background. Background always flushes pending data regardless.
34
- */
35
- finalizeOnBackground: z.boolean().default(false),
36
- /**
37
- * Inactivity gap (ms) at/after which timeline time is treated as "idle" and
38
- * excluded from the active session duration. Sent to the backend on session
39
- * start and echoed back in the session detail so the dashboard draws idle
40
- * bands + computes active duration with the SAME threshold the SDK declared
41
- * (no client-side guess). Default 60000 (60s).
42
- */
43
- idleThresholdMs: z.number().min(1000).default(60_000),
44
- /**
45
- * Max time (ms) the app may stay backgrounded before the analytics session is
46
- * finalized on the next foreground and a fresh one is opened ("cap then
47
- * reaper"). Below the cap, a background/foreground round-trip keeps ONE
48
- * session (background span is flagged, not split). The server-side stale
49
- * reaper is the backstop for a true process kill. Default 1800000 (30 min).
50
- */
51
- sessionBackgroundCapMs: z.number().min(60_000).default(30 * 60 * 1000),
52
- maxQueueSize: z.number().min(1).default(1000),
53
- enableNetworkMonitoring: z.boolean().default(true),
54
- /**
55
- * Opt-in: capture request/response headers and bodies.
56
- * Default: false must be explicitly enabled by the integrator.
57
- * See ScaleBunFeatures.captureNetworkBodies for the full privacy warning.
58
- */
59
- captureNetworkBodies: z.boolean().default(false),
60
- /**
61
- * Max bytes captured per body (request or response) before truncation.
62
- * Range: 1 byte 1 MiB. Default: 65536 (64 KiB).
63
- */
64
- networkBodyMaxBytes: z.number().min(1).max(1_048_576).default(65_536),
65
- /**
66
- * Persistent queue configuration.
67
- * Controls whether the event queue persists to disk and its bounds.
68
- */
69
- persistence: z.object({
70
- /** Enable disk persistence (survives app restarts). Default: true */
71
- enabled: z.boolean().default(true),
72
- /** Max total bytes stored on disk. Default: 5 MB (5_242_880) */
73
- maxBytes: z.number().min(1024).default(5_242_880),
74
- /** Max total entries stored. Default: 5000 */
75
- maxEntries: z.number().min(10).default(5_000),
76
- /** Strip PII from payloads before writing to disk. Default: true */
77
- redactBeforeWrite: z.boolean().default(true),
78
- }).default({}),
79
- clientKey: z.string().optional(),
80
- /**
81
- * Upload replay frame bytes to object storage via presigned PUT instead of
82
- * inline base64 in the frames JSON body. Default false (legacy inline). Safe
83
- * to enable before the backend is ready: the SDK auto-falls back to inline if
84
- * the presign endpoint reports storage is not configured. SaaS (clientKey) only.
85
- */
86
- useObjectStorage: z.boolean().default(false),
87
- /**
88
- * Native file-based replay outbox (durable, survives app restart/process kill).
89
- * When true, frames are captured natively to disk and metadata is handed to the
90
- * native outbox instead of buffering base64 in the JS in-memory pendingFrames.
91
- * Default false: existing in-memory JS upload path stays the only path. If the
92
- * native module or a native call is unavailable, the SDK falls back to the
93
- * existing JS path. SaaS (clientKey) only — uploads target /ingestion endpoints.
94
- */
95
- enableNativeFileOutbox: z.boolean().default(false),
96
- /**
97
- * Allow the NATIVE outbox to perform uploads (presign -> PUT -> commit, plus
98
- * JSONL telemetry batches) on its own. Default false: even with the outbox on,
99
- * native only captures+stores; JS still drives flush by calling the native
100
- * flush bridge method. Set true to let native upload directly. Requires
101
- * enableNativeFileOutbox.
102
- */
103
- nativeOutboxUploadEnabled: z.boolean().default(false),
104
- /**
105
- * Within the native outbox, upload frame image bytes to object storage via
106
- * presigned PUT (key-only metadata commit) instead of inline base64. Default
107
- * false. If the presign endpoint reports storage disabled, native falls back to
108
- * the JS path for that frame (it does NOT send base64 over the bridge in the
109
- * outbox path). Requires enableNativeFileOutbox.
110
- */
111
- useObjectStorageForFrames: z.boolean().default(false),
112
- /**
113
- * Native outbox tuning (all additive, all optional — native parses both the
114
- * `nativeOutbox*` keys here and bare `outbox*` aliases). These only take effect
115
- * when enableNativeFileOutbox is true; defaults mirror the native ReplayConfig
116
- * defaults so omitting them changes nothing.
117
- */
118
- /** Armed-retry interval for due outbox work, ms. Default 3000. */
119
- nativeOutboxRetryIntervalMs: z.number().min(250).default(3000),
120
- /** Server-attempt cap before a batch is moved to dead. Default 30. */
121
- nativeOutboxMaxUploadAttempts: z.number().min(1).default(30),
122
- /** Poison (4xx≠429) attempt cap before dead. Default 2. */
123
- nativeOutboxPoisonMaxAttempts: z.number().min(1).default(2),
124
- /** Honor server Retry-After on 429/503. Default true. */
125
- nativeOutboxRespectRetryAfter: z.boolean().default(true),
126
- /** Force fixed 3s retry, ignoring exponential backoff. Default false. */
127
- nativeOutboxStrictThreeSecondRetry: z.boolean().default(false),
128
- /** Count NETWORK_UNAVAILABLE failures toward the dead threshold. Default false. */
129
- nativeOutboxNetworkFailuresCountTowardDead: z.boolean().default(false),
130
- /** Outbox on-disk byte cap before GC. Default 100 MiB. */
131
- nativeOutboxMaxBytes: z.number().min(1024).default(100 * 1024 * 1024),
132
- /** Outbox max age before GC, ms. Default 7 days. */
133
- nativeOutboxMaxAgeMs: z.number().min(1000).default(7 * 24 * 60 * 60 * 1000),
134
- /**
135
- * Performance pipeline activation flags (SaaS).
136
- * Tiered by cost. Defaults are conservative ("default-safe"): cheap
137
- * event-driven Tier-1 collectors on; heavier UI-hang watchdog and Tier-2
138
- * sampled collectors OFF until device-measured. All flippable via config
139
- * with no SDK release.
140
- */
141
- performance: z.object({
142
- /** Master enable; also gates native ScaleBunPerformance.initialize(). Default: true */
143
- enabled: z.boolean().default(true),
144
- /** Tier-1: cheap, event-driven collectors. */
145
- tier1: z.object({
146
- /** App launch (one-shot at start). Default: true */
147
- appLaunch: z.boolean().default(true),
148
- /** Screen load (per navigation). Default: true */
149
- screenLoad: z.boolean().default(true),
150
- /** Network perf (slow/failed requests). Default: true */
151
- network: z.boolean().default(true),
152
- /** UI hang / ANR watchdog. Default: true — additive, forward-only (needs native module). */
153
- uiHang: z.boolean().default(true),
154
- }).default({}),
155
- /** Tier-2: heavy, continuous collectors (frame_metrics + js_stall), sampled. */
156
- tier2: z.object({
157
- /** Master enable for Tier-2. Default: true (still gated by sampleRate). */
158
- enabled: z.boolean().default(true),
159
- /** Per-session sampling fraction 0..1. Default: 10% — conservative, host-overridable (0 disables). */
160
- sampleRate: z.number().min(0).max(1).default(DEFAULT_TIER2_SAMPLE_RATE),
161
- }).default({}),
162
- }).default({}),
163
- /**
164
- * Session-replay capture cadence for the unified SessionManager.
165
- * 'navigation' (SDK default) captures only on screen change → a session with
166
- * no navigation produces ~0 frames. 'frequency' captures on a timer
167
- * (intervalMs, min 500ms) for a continuous replay. 'interactions' on gestures.
168
- * Plumbed into SessionManager via SDKBootstrapper.
169
- */
170
- replay: z.object({
171
- // Auto-start frame recording in SaaS mode (clientKey set) at cold launch, so replay
172
- // sessions carry frames out of the box. Default: true (undefined ⇒ record). Set false for
173
- // events-only sessions the host can still record on demand via ScaleBun.startSession().
174
- // Decoupled from finalizeOnBackground (which only governs per-foreground session boundaries).
175
- record: z.boolean().optional(),
176
- captureMode: z.enum(['navigation', 'interactions', 'frequency']).optional(),
177
- intervalMs: z.number().min(500).optional(),
178
- quality: z.enum(['high', 'normal', 'low', 'grayscale']).optional(),
179
- // P2-5: emit deltas between keyframes (default false in DEFAULT_SESSION_REPLAY_CONFIG).
180
- deltaEncoding: z.boolean().optional(),
181
- deltaKeyframeInterval: z.number().int().min(1).optional(),
182
- }).optional(),
183
- /**
184
- * Heatmap interaction capture (Feature #4).
185
- *
186
- * When true, tap/gesture coordinates (normalizedX/Y + gesture type + screen)
187
- * are ALSO emitted to the always-on analytics lane — so heatmaps receive data
188
- * even when no replay-recording session is active. This is ADDITIVE: it does
189
- * NOT change replay-recording capture, and reuses the exact same USER_ACTION
190
- * payload keys (normalizedX, normalizedY, gestureType, screen) the recording
191
- * lane writes, so the backend aggregate reads them identically.
192
- *
193
- * Coordinates are NORMALIZED (0..1) and carry no PII. The analytics lane is
194
- * SaaS-only (requires clientKey) and finalize-scoped per foreground; while ON
195
- * a tap on every gesture is enqueued (bounded buffer, drop-oldest).
196
- *
197
- * Default: true (ON). Coords are normalized + PII-free, and volume is bounded
198
- * by a per-foreground sampling cap in SessionManager (HEATMAP_MAX_INTERACTIONS_
199
- * PER_WINDOW) so the gesture stream can't run away. Integrators who want zero
200
- * extra analytics events can still set this false. SaaS (clientKey) only.
201
- *
202
- * CAVEAT: heatmaps populate going FORWARD only sessions recorded before this
203
- * shipped (or with the flag off) carry no analytics-lane interaction data.
204
- */
205
- captureInteractionHeatmap: z.boolean().default(true),
206
- /**
207
- * OTA (Over-the-Air) update configuration.
208
- * When enabled, the SDK checks for JS bundle updates on app foreground
209
- * and applies them atomically. Opt-in: existing integrators are unaffected.
210
- * SaaS (clientKey) only.
211
- */
212
- ota: z.object({
213
- /** Enable OTA update checking. Default: false (opt-in). */
214
- enabled: z.boolean().default(false),
215
- /** Check for updates on each app foreground. Default: true. */
216
- checkOnForeground: z.boolean().default(true),
217
- /** Override the auto-resolved channel (env-based). */
218
- channelOverride: z.string().optional(),
219
- /** Ed25519 public key for bundle signature verification (base64). */
220
- publicSigningKey: z.string().optional(),
221
- /**
222
- * Ed25519 verifier supplied by the host — the SDK ships no crypto
223
- * implementation. Required whenever `publicSigningKey` is set: pinning a
224
- * key without a verifier is fail-closed, so updates stop installing.
225
- * `(message, signature, publicKey) => boolean | Promise<boolean>`.
226
- */
227
- verifySignature: z.any().optional(),
228
- /** Override how long a new bundle has to prove healthy (ms). */
229
- healthyTimeoutMs: z.number().optional(),
230
- /** Block UI interaction while a mandatory update is pending. Default: false. */
231
- mandatoryBlocksUi: z.boolean().default(false),
232
- }).optional(),
233
- }).refine(
234
- (data) => !!data.clientKey || (!!data.projectId && !!data.publishableKey),
235
- { message: 'Either clientKey (SaaS mode) or both projectId and publishableKey (legacy mode) are required' }
236
- );
237
-
238
- export type ScaleBunConfig = Infer<typeof ConfigSchema>;
28
+ // ─── Result surface (drop-in for the vendored validator's) ─────────────────────
29
+
30
+ export type ValidationIssue = { path: Array<string | number>; message: string };
31
+
32
+ export type FormattedError = {
33
+ _errors: string[];
34
+ [key: string]: FormattedError | string[];
35
+ };
36
+
37
+ export class ConfigValidationError extends Error {
38
+ readonly issues: ValidationIssue[];
39
+
40
+ constructor(issues: ValidationIssue[]) {
41
+ super(issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; '));
42
+ this.name = 'ValidationError';
43
+ this.issues = issues;
44
+ }
45
+
46
+ /** Nested error object keyed by path, matching Zod's `error.format()`. */
47
+ format(): FormattedError {
48
+ const root: FormattedError = { _errors: [] };
49
+ for (const issue of this.issues) {
50
+ if (issue.path.length === 0) {
51
+ root._errors.push(issue.message);
52
+ continue;
53
+ }
54
+ let node = root;
55
+ for (let i = 0; i < issue.path.length; i++) {
56
+ const key = String(issue.path[i]);
57
+ const existing = node[key];
58
+ let child: FormattedError;
59
+ if (existing && !Array.isArray(existing)) {
60
+ child = existing;
61
+ } else {
62
+ child = { _errors: [] };
63
+ node[key] = child;
64
+ }
65
+ if (i === issue.path.length - 1) {
66
+ child._errors.push(issue.message);
67
+ }
68
+ node = child;
69
+ }
70
+ }
71
+ return root;
72
+ }
73
+ }
74
+
75
+ export type SafeParseResult<T> =
76
+ | { success: true; data: T }
77
+ | { success: false; error: ConfigValidationError };
78
+
79
+ // ─── Field table ────────────────────────────────────────────────────────────────
80
+ //
81
+ // One row per config key. `def` present → the field always exists in the output (the default is
82
+ // itself validated, matching DefaultSchema semantics). `opt` → absent input stays absent.
83
+
84
+ type Field =
85
+ | { kind: 'bool'; def?: boolean; opt?: true }
86
+ | { kind: 'num'; min?: number; max?: number; int?: true; def?: number; opt?: true }
87
+ | { kind: 'str'; min?: number; opt?: true }
88
+ | { kind: 'enum'; values: readonly string[]; opt?: true }
89
+ | { kind: 'any'; def: () => unknown }
90
+ | { kind: 'obj'; shape: Record<string, Field>; def?: true; opt?: true };
91
+
92
+ const bool = (def?: boolean): Field => (def === undefined ? { kind: 'bool' } : { kind: 'bool', def });
93
+ const num = (o: { min?: number; max?: number; int?: true; def?: number; opt?: true }): Field => ({ kind: 'num', ...o });
94
+
95
+ const SHAPE: Record<string, Field> = {
96
+ projectId: { kind: 'str', min: 1, opt: true },
97
+ publishableKey: { kind: 'str', min: 1, opt: true },
98
+ apiBaseUrl: { kind: 'any', def: () => DEFAULT_API_BASE_URL },
99
+ debug: bool(false),
100
+ logLevel: { kind: 'enum', values: ['silent', 'error', 'warn', 'info', 'debug'], opt: true },
101
+ flushIntervalMs: num({ min: 1000, def: 5000 }),
102
+ finalizeOnBackground: bool(false),
103
+ idleThresholdMs: num({ min: 1000, def: 60_000 }),
104
+ sessionBackgroundCapMs: num({ min: 60_000, def: 30 * 60 * 1000 }),
105
+ maxQueueSize: num({ min: 1, def: 1000 }),
106
+ enableNetworkMonitoring: bool(true),
107
+ captureNetworkBodies: bool(false),
108
+ networkBodyMaxBytes: num({ min: 1, max: 1_048_576, def: 65_536 }),
109
+ persistence: {
110
+ kind: 'obj',
111
+ def: true,
112
+ shape: {
113
+ enabled: bool(true),
114
+ maxBytes: num({ min: 1024, def: 5_242_880 }),
115
+ maxEntries: num({ min: 10, def: 5_000 }),
116
+ redactBeforeWrite: bool(true),
117
+ },
118
+ },
119
+ clientKey: { kind: 'str', opt: true },
120
+ useObjectStorage: bool(false),
121
+ enableNativeFileOutbox: bool(false),
122
+ nativeOutboxUploadEnabled: bool(false),
123
+ useObjectStorageForFrames: bool(false),
124
+ nativeOutboxRetryIntervalMs: num({ min: 250, def: 3000 }),
125
+ nativeOutboxMaxUploadAttempts: num({ min: 1, def: 30 }),
126
+ nativeOutboxPoisonMaxAttempts: num({ min: 1, def: 2 }),
127
+ nativeOutboxRespectRetryAfter: bool(true),
128
+ nativeOutboxStrictThreeSecondRetry: bool(false),
129
+ nativeOutboxNetworkFailuresCountTowardDead: bool(false),
130
+ nativeOutboxMaxBytes: num({ min: 1024, def: 100 * 1024 * 1024 }),
131
+ nativeOutboxMaxAgeMs: num({ min: 1000, def: 7 * 24 * 60 * 60 * 1000 }),
132
+ performance: {
133
+ kind: 'obj',
134
+ def: true,
135
+ shape: {
136
+ enabled: bool(true),
137
+ tier1: {
138
+ kind: 'obj',
139
+ def: true,
140
+ shape: {
141
+ appLaunch: bool(true),
142
+ screenLoad: bool(true),
143
+ network: bool(true),
144
+ uiHang: bool(true),
145
+ },
146
+ },
147
+ tier2: {
148
+ kind: 'obj',
149
+ def: true,
150
+ shape: {
151
+ enabled: bool(true),
152
+ sampleRate: num({ min: 0, max: 1, def: DEFAULT_TIER2_SAMPLE_RATE }),
153
+ },
154
+ },
155
+ },
156
+ },
157
+ replay: {
158
+ kind: 'obj',
159
+ opt: true,
160
+ shape: {
161
+ // Auto-start frame recording in SaaS mode (clientKey set) at cold launch, so replay
162
+ // sessions carry frames out of the box. Default: true (undefined ⇒ record). Set false
163
+ // for events-only sessions — the host can still record via ScaleBun.startSession().
164
+ record: { kind: 'bool', opt: true },
165
+ captureMode: { kind: 'enum', values: ['navigation', 'interactions', 'frequency'], opt: true },
166
+ intervalMs: num({ min: 500, opt: true }),
167
+ quality: { kind: 'enum', values: ['high', 'normal', 'low', 'grayscale'], opt: true },
168
+ deltaEncoding: { kind: 'bool', opt: true },
169
+ deltaKeyframeInterval: num({ min: 1, int: true, opt: true }),
170
+ },
171
+ },
172
+ captureInteractionHeatmap: bool(true),
173
+ ota: {
174
+ kind: 'obj',
175
+ opt: true,
176
+ shape: {
177
+ enabled: bool(false),
178
+ checkOnForeground: bool(true),
179
+ channelOverride: { kind: 'str', opt: true },
180
+ publicSigningKey: { kind: 'str', opt: true },
181
+ mandatoryBlocksUi: bool(false),
182
+ },
183
+ },
184
+ };
185
+
186
+ // ─── Engine ─────────────────────────────────────────────────────────────────────
187
+
188
+ const typeofName = (v: unknown): string =>
189
+ v === null ? 'null' : Array.isArray(v) ? 'array' : typeof v;
190
+
191
+ function parseField(
192
+ field: Field,
193
+ input: unknown,
194
+ path: Array<string | number>,
195
+ issues: ValidationIssue[],
196
+ ): { ok: boolean; value?: unknown; present: boolean } {
197
+ const fail = (message: string) => {
198
+ issues.push({ path, message });
199
+ return { ok: false, present: true };
200
+ };
201
+
202
+ if (input === undefined) {
203
+ if ('opt' in field && field.opt) return { ok: true, present: false };
204
+ if (field.kind === 'any') return { ok: true, value: field.def(), present: true };
205
+ if (field.kind === 'obj' && field.def) return parseField({ ...field, def: undefined } as Field, {}, path, issues);
206
+ if ('def' in field && field.def !== undefined) return { ok: true, value: field.def, present: true };
207
+ // Required with no default (matches the base schemas' type errors on undefined).
208
+ return fail(
209
+ field.kind === 'bool'
210
+ ? 'Expected boolean, received undefined'
211
+ : field.kind === 'num'
212
+ ? 'Expected number, received undefined'
213
+ : field.kind === 'str'
214
+ ? 'Expected string, received undefined'
215
+ : field.kind === 'enum'
216
+ ? "Invalid enum value. Expected " + field.values.map((v) => `'${v}'`).join(' | ')
217
+ : 'Expected object, received undefined',
218
+ );
219
+ }
220
+
221
+ switch (field.kind) {
222
+ case 'any':
223
+ return { ok: true, value: input, present: true };
224
+ case 'bool':
225
+ if (typeof input !== 'boolean') return fail(`Expected boolean, received ${typeofName(input)}`);
226
+ return { ok: true, value: input, present: true };
227
+ case 'str':
228
+ if (typeof input !== 'string') return fail(`Expected string, received ${typeofName(input)}`);
229
+ if (field.min !== undefined && input.length < field.min) {
230
+ return fail(`String must contain at least ${field.min} character(s)`);
231
+ }
232
+ return { ok: true, value: input, present: true };
233
+ case 'num':
234
+ if (typeof input !== 'number' || Number.isNaN(input)) {
235
+ return fail(`Expected number, received ${typeofName(input)}`);
236
+ }
237
+ if (field.int && !Number.isInteger(input)) return fail('Expected integer, received float');
238
+ if (field.min !== undefined && input < field.min) {
239
+ return fail(`Number must be greater than or equal to ${field.min}`);
240
+ }
241
+ if (field.max !== undefined && input > field.max) {
242
+ return fail(`Number must be less than or equal to ${field.max}`);
243
+ }
244
+ return { ok: true, value: input, present: true };
245
+ case 'enum':
246
+ if (typeof input !== 'string' || !field.values.includes(input)) {
247
+ return fail(`Invalid enum value. Expected ${field.values.map((v) => `'${v}'`).join(' | ')}`);
248
+ }
249
+ return { ok: true, value: input, present: true };
250
+ case 'obj': {
251
+ if (typeofName(input) !== 'object') return fail(`Expected object, received ${typeofName(input)}`);
252
+ const src = input as Record<string, unknown>;
253
+ const out: Record<string, unknown> = {};
254
+ let ok = true;
255
+ for (const key of Object.keys(field.shape)) {
256
+ const r = parseField(field.shape[key]!, src[key], [...path, key], issues);
257
+ if (!r.ok) ok = false;
258
+ // Mirrors ObjectSchema: keep defined results, and explicit `key in input`
259
+ // occurrences even when the parsed value is undefined (optional present-but-
260
+ // undefined keys survive as own properties, exactly like the old parser).
261
+ else if (r.value !== undefined || key in src) {
262
+ if (r.present || key in src) out[key] = r.value;
263
+ }
264
+ }
265
+ // Unknown keys are stripped (Zod's default `.strip()` behaviour).
266
+ return ok ? { ok: true, value: out, present: true } : { ok: false, present: true };
267
+ }
268
+ }
269
+ }
270
+
271
+ /** The one root-level cross-field rule (was `.refine(...)` on the old schema). */
272
+ const ROOT_REFINE_MESSAGE =
273
+ 'Either clientKey (SaaS mode) or both projectId and publishableKey (legacy mode) are required';
274
+
275
+ export const ConfigSchema = {
276
+ safeParse(input: unknown): SafeParseResult<ScaleBunConfig> {
277
+ const issues: ValidationIssue[] = [];
278
+ const r = parseField({ kind: 'obj', shape: SHAPE }, input, [], issues);
279
+ if (r.ok && issues.length === 0) {
280
+ const data = r.value as ScaleBunConfig;
281
+ if (!(!!data.clientKey || (!!data.projectId && !!data.publishableKey))) {
282
+ issues.push({ path: [], message: ROOT_REFINE_MESSAGE });
283
+ return { success: false, error: new ConfigValidationError(issues) };
284
+ }
285
+ return { success: true, data };
286
+ }
287
+ return { success: false, error: new ConfigValidationError(issues) };
288
+ },
289
+
290
+ parse(input: unknown): ScaleBunConfig {
291
+ const r = this.safeParse(input);
292
+ if (!r.success) throw r.error;
293
+ return r.data;
294
+ },
295
+ };
296
+
297
+ // ─── Output type (was Infer<typeof ConfigSchema>) ──────────────────────────────
298
+
299
+ export interface ScaleBunConfig {
300
+ projectId?: string;
301
+ publishableKey?: string;
302
+ // `any`, not `unknown`: the old schema's z.any() inferred `any`, and the bootstrapper/facade
303
+ // assign and pass it as a string after force-locking it to DEFAULT_API_BASE_URL.
304
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
305
+ apiBaseUrl: any;
306
+ debug: boolean;
307
+ logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug';
308
+ flushIntervalMs: number;
309
+ finalizeOnBackground: boolean;
310
+ idleThresholdMs: number;
311
+ sessionBackgroundCapMs: number;
312
+ maxQueueSize: number;
313
+ enableNetworkMonitoring: boolean;
314
+ captureNetworkBodies: boolean;
315
+ networkBodyMaxBytes: number;
316
+ persistence: {
317
+ enabled: boolean;
318
+ maxBytes: number;
319
+ maxEntries: number;
320
+ redactBeforeWrite: boolean;
321
+ };
322
+ clientKey?: string;
323
+ useObjectStorage: boolean;
324
+ enableNativeFileOutbox: boolean;
325
+ nativeOutboxUploadEnabled: boolean;
326
+ useObjectStorageForFrames: boolean;
327
+ nativeOutboxRetryIntervalMs: number;
328
+ nativeOutboxMaxUploadAttempts: number;
329
+ nativeOutboxPoisonMaxAttempts: number;
330
+ nativeOutboxRespectRetryAfter: boolean;
331
+ nativeOutboxStrictThreeSecondRetry: boolean;
332
+ nativeOutboxNetworkFailuresCountTowardDead: boolean;
333
+ nativeOutboxMaxBytes: number;
334
+ nativeOutboxMaxAgeMs: number;
335
+ performance: {
336
+ enabled: boolean;
337
+ tier1: { appLaunch: boolean; screenLoad: boolean; network: boolean; uiHang: boolean };
338
+ tier2: { enabled: boolean; sampleRate: number };
339
+ };
340
+ replay?: {
341
+ record?: boolean;
342
+ captureMode?: 'navigation' | 'interactions' | 'frequency';
343
+ intervalMs?: number;
344
+ quality?: 'high' | 'normal' | 'low' | 'grayscale';
345
+ deltaEncoding?: boolean;
346
+ deltaKeyframeInterval?: number;
347
+ };
348
+ captureInteractionHeatmap: boolean;
349
+ ota?: {
350
+ enabled: boolean;
351
+ checkOnForeground: boolean;
352
+ channelOverride?: string;
353
+ publicSigningKey?: string;
354
+ mandatoryBlocksUi: boolean;
355
+ };
356
+ }
239
357
 
240
358
  // Re-export config types from contracts for consumers migrating to new import paths
241
359
  export type {