catalyst-core 0.3.0-beta.5 → 0.3.0-canary.2

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 (316) hide show
  1. package/changelog.md +185 -71
  2. package/dist/errors/generateDocs.js +100 -0
  3. package/dist/errors/index.js +243 -0
  4. package/dist/errors/registry.js +483 -0
  5. package/dist/errors-index.json +506 -0
  6. package/dist/globals.d.ts +62 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.jsx +5 -8
  9. package/dist/logger.js +1 -1
  10. package/dist/native/androidProject/app/build.gradle.kts +142 -7
  11. package/dist/native/androidProject/app/src/main/AndroidManifest.xml +4 -0
  12. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/NativeBridge.kt +2 -2
  13. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/camera/BarcodeDetector.kt +3 -0
  14. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/camera/CameraSessionManager.kt +3 -0
  15. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/FrameworkServerUtils.kt +43 -8
  16. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/BridgeUtilsTest.kt +181 -1
  17. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/CameraUtilsTest.kt +156 -236
  18. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FileSizeRouterUtilsTest.kt +471 -0
  19. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FileUtilsTest.kt +222 -226
  20. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FrameworkServerUtilsTest.kt +300 -0
  21. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/IntentUtilsTest.kt +244 -0
  22. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/MetricsMonitorTest.kt +359 -0
  23. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/NativeBridgeTest.kt +108 -63
  24. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/NotificationUtilsTest.kt +329 -385
  25. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/OfflineCacheServiceTest.kt +302 -0
  26. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/PerfEventBufferTest.kt +133 -0
  27. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/UtilsKtTest.kt +152 -0
  28. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/WebCacheManagerTest.kt +145 -324
  29. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/BarcodeDetectorTest.kt +132 -0
  30. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/HoldControllerTest.kt +155 -0
  31. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/TorchControllerTest.kt +150 -0
  32. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/VideoStreamStateMachineTest.kt +120 -0
  33. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/VideoStreamStateTest.kt +62 -0
  34. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/ViewfinderMapperTest.kt +143 -0
  35. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/ZoomControllerTest.kt +421 -0
  36. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/design/DesignTokensTest.kt +207 -0
  37. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/plugins/PluginBridgeTest.kt +368 -0
  38. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/FridaDetectorTest.kt +193 -0
  39. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/SecurityCheckManagerTest.kt +260 -0
  40. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/SecurityCheckSchedulerTest.kt +166 -0
  41. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/DeviceInfoUtilsTest.kt +167 -0
  42. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/DownloadUtilsTest.kt +197 -0
  43. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/NetworkMonitorTest.kt +271 -0
  44. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/PushNotificationUtilsTest.kt +119 -0
  45. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/SafeAreaUtilsTest.kt +108 -0
  46. package/dist/native/androidProject/build.gradle.kts +1 -0
  47. package/dist/native/androidProject/gradle/libs.versions.toml +26 -0
  48. package/dist/native/androidProject/settings.gradle.kts +11 -8
  49. package/dist/native/androidSetup.js +2 -2
  50. package/dist/native/bridge/WebBridge.d.ts +98 -0
  51. package/dist/native/bridge/WebBridge.js +40 -6
  52. package/dist/native/bridge/constants/NativeInterfaces.d.ts +391 -0
  53. package/dist/native/bridge/errors.d.ts +67 -0
  54. package/dist/native/bridge/errors.js +66 -151
  55. package/dist/native/bridge/hooks/index.d.ts +13 -0
  56. package/dist/native/bridge/hooks/index.js +0 -6
  57. package/dist/native/bridge/hooks/useAI.d.ts +1 -0
  58. package/dist/native/bridge/hooks/useAI.js +3 -1
  59. package/dist/native/bridge/hooks/useCamera.d.ts +86 -0
  60. package/dist/native/bridge/hooks/useCamera.js +35 -6
  61. package/dist/native/bridge/hooks/useDataProtection.d.ts +17 -0
  62. package/dist/native/bridge/hooks/useDeviceInfo.d.ts +34 -0
  63. package/dist/native/bridge/hooks/useDeviceInfo.js +5 -0
  64. package/dist/native/bridge/hooks/useFilePicker.d.ts +53 -0
  65. package/dist/native/bridge/hooks/useFilePicker.js +13 -0
  66. package/dist/native/bridge/hooks/useGoogleSignIn.d.ts +12 -0
  67. package/dist/native/bridge/hooks/useHapticFeedback.d.ts +76 -0
  68. package/dist/native/bridge/hooks/useHapticFeedback.js +6 -1
  69. package/dist/native/bridge/hooks/useIntent.d.ts +33 -0
  70. package/dist/native/bridge/hooks/useIntent.js +2 -0
  71. package/dist/native/bridge/hooks/useNativeTransition.d.ts +53 -0
  72. package/dist/native/bridge/hooks/useNativeTransition.js +12 -5
  73. package/dist/native/bridge/hooks/useNetworkStatus.d.ts +22 -0
  74. package/dist/native/bridge/hooks/useNetworkStatus.js +7 -0
  75. package/dist/native/bridge/hooks/useNotification.d.ts +83 -0
  76. package/dist/native/bridge/hooks/useNotification.js +81 -34
  77. package/dist/native/bridge/hooks/useSafeArea.d.ts +12 -0
  78. package/dist/native/bridge/hooks/useSafeArea.js +8 -0
  79. package/dist/native/bridge/hooks/useVideoStream.d.ts +67 -0
  80. package/dist/native/bridge/hooks/useVideoStream.js +38 -52
  81. package/dist/native/bridge/hooks/utils.d.ts +4 -0
  82. package/dist/native/bridge/hooks.d.ts +1 -0
  83. package/dist/native/bridge/perf/collectors/ApiCollector.d.ts +30 -0
  84. package/dist/native/bridge/perf/collectors/ApiCollector.js +4 -0
  85. package/dist/native/bridge/perf/collectors/CacheCollector.d.ts +43 -0
  86. package/dist/native/bridge/perf/collectors/CacheCollector.js +4 -0
  87. package/dist/native/bridge/perf/collectors/HookCollector.d.ts +37 -0
  88. package/dist/native/bridge/perf/collectors/HookCollector.js +4 -0
  89. package/dist/native/bridge/perf/collectors/InsightsCollector.d.ts +103 -0
  90. package/dist/native/bridge/perf/collectors/InsightsCollector.js +4 -0
  91. package/dist/native/bridge/perf/collectors/InteractionCollector.d.ts +53 -0
  92. package/dist/native/bridge/perf/collectors/InteractionCollector.js +4 -0
  93. package/dist/native/bridge/perf/collectors/KeyboardCollector.d.ts +30 -0
  94. package/dist/native/bridge/perf/collectors/KeyboardCollector.js +4 -0
  95. package/dist/native/bridge/perf/collectors/NavigationCollector.d.ts +37 -0
  96. package/dist/native/bridge/perf/collectors/NavigationCollector.js +4 -0
  97. package/dist/native/bridge/perf/collectors/NetworkTimingCollector.d.ts +30 -0
  98. package/dist/native/bridge/perf/collectors/NetworkTimingCollector.js +4 -0
  99. package/dist/native/bridge/perf/collectors/RenderCollector.d.ts +47 -0
  100. package/dist/native/bridge/perf/collectors/RenderCollector.js +8 -0
  101. package/dist/native/bridge/perf/collectors/ScrollCollector.d.ts +29 -0
  102. package/dist/native/bridge/perf/collectors/ScrollCollector.js +4 -0
  103. package/dist/native/bridge/perf/collectors/ThreadCollector.d.ts +31 -0
  104. package/dist/native/bridge/perf/collectors/ThreadCollector.js +4 -0
  105. package/dist/native/bridge/perf/core/constants.d.ts +76 -0
  106. package/dist/native/bridge/perf/core/measure.d.ts +39 -0
  107. package/dist/native/bridge/perf/core/measure.js +4 -0
  108. package/dist/native/bridge/perf/core/session.d.ts +49 -0
  109. package/dist/native/bridge/perf/core/session.js +4 -0
  110. package/dist/native/bridge/perf/core/store.d.ts +37 -0
  111. package/dist/native/bridge/perf/core/store.js +4 -0
  112. package/dist/native/bridge/perf/core/summary.d.ts +60 -0
  113. package/dist/native/bridge/perf/core/traceExport.d.ts +10 -0
  114. package/dist/native/bridge/perf/core/waterfalls.d.ts +2 -0
  115. package/dist/native/bridge/perf/index.d.ts +63 -0
  116. package/dist/native/bridge/perf/index.js +4 -0
  117. package/dist/native/bridge/safeArea.d.ts +11 -0
  118. package/dist/native/bridge/safeArea.js +2 -0
  119. package/dist/native/bridge/useBaseHook.d.ts +137 -0
  120. package/dist/native/bridge/useBaseHook.js +34 -4
  121. package/dist/native/bridge/utils/CameraUtils.d.ts +94 -0
  122. package/dist/native/bridge/utils/CameraUtils.js +4 -0
  123. package/dist/native/bridge/utils/FileObjectConverter.d.ts +36 -0
  124. package/dist/native/bridge/utils/NativeBridge.d.ts +270 -0
  125. package/dist/native/bridge/utils/NativeBridge.js +10 -0
  126. package/dist/native/buildAndroid/index.js +1 -1
  127. package/dist/native/buildAppAndroid.js +9 -0
  128. package/dist/native/buildAppIos.js +16 -1
  129. package/dist/native/buildErrorFormat.js +57 -0
  130. package/dist/native/buildIos/config.js +15 -1
  131. package/dist/native/buildIos/index.js +1 -1
  132. package/dist/native/buildIos/plugins.js +10 -1
  133. package/dist/native/iosnativeWebView/CoreLogic/Package.swift +36 -0
  134. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Camera/VideoStreamState.swift +1 -1
  135. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Camera/VideoStreamStateMachine.swift +6 -4
  136. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/BootTimingUtility.swift +3 -3
  137. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/FrameworkServerUtils.swift +14 -9
  138. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NetworkMonitor.swift +11 -9
  139. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NotificationHandlerProvider.swift +1 -1
  140. package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/URLWhitelistManager.swift +7 -7
  141. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/AnyCodableTests.swift +154 -0
  142. package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/BootTimingUtilityTests.swift +23 -5
  143. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/CatalystConstantsTests.swift +192 -0
  144. package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/ConfigMappingTests.swift +1 -1
  145. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/FrameworkServerUtilsErrorPathTests.swift +106 -0
  146. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/FrameworkServerUtilsLoopbackTests.swift +243 -0
  147. package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/FrameworkServerUtilsTests.swift +1 -1
  148. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/NetworkMonitorTests.swift +119 -0
  149. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/NotificationHandlerProviderTests.swift +59 -0
  150. package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/NotificationHandlerTests.swift +1 -1
  151. package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/URLWhitelistManagerTests.swift +1 -1
  152. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/VideoStreamStateMachineTests.swift +171 -0
  153. package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/VideoStreamStateTests.swift +91 -0
  154. package/dist/native/iosnativeWebView/Package.swift +10 -9
  155. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/LocalNotificationHandler.swift +7 -2
  156. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/NotificationManager.swift +1 -2
  157. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/PushNotificationHandler.swift +5 -4
  158. package/dist/native/iosnativeWebView/Sources/Core/Camera/CameraSessionManager.swift +1 -0
  159. package/dist/native/iosnativeWebView/Sources/Core/Camera/HoldController.swift +1 -0
  160. package/dist/native/iosnativeWebView/Sources/Core/Camera/NativeCameraManager.swift +6 -5
  161. package/dist/native/iosnativeWebView/Sources/Core/Camera/ZoomController.swift +1 -0
  162. package/dist/native/iosnativeWebView/Sources/Core/Plugins/PluginBridge.swift +1 -0
  163. package/dist/native/iosnativeWebView/Sources/Core/Utils/CacheManager.swift +31 -30
  164. package/dist/native/iosnativeWebView/Sources/Core/Utils/CameraTransportUtils.swift +2 -1
  165. package/dist/native/iosnativeWebView/Sources/Core/Utils/DeviceInfoUtils.swift +1 -1
  166. package/dist/native/iosnativeWebView/Sources/Core/Utils/FilePickerHandler.swift +22 -19
  167. package/dist/native/iosnativeWebView/Sources/Core/Utils/ImageHandler.swift +40 -39
  168. package/dist/native/iosnativeWebView/Sources/Core/Utils/PerfEventBuffer.swift +1 -0
  169. package/dist/native/iosnativeWebView/Sources/Core/Utils/ResourceURLProtocol.swift +15 -15
  170. package/dist/native/iosnativeWebView/Sources/Core/Utils/WebKitConfig.swift +4 -3
  171. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeCommandHandler.swift +6 -1
  172. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeDelegateHandler.swift +1 -0
  173. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeFileHandler.swift +2 -1
  174. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeJavaScriptInterface.swift +2 -1
  175. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeMessageValidator.swift +3 -5
  176. package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +20 -13
  177. package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashView.swift +6 -5
  178. package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashViewModel.swift +14 -13
  179. package/dist/native/iosnativeWebView/Sources/Core/WebView/TransitionManager.swift +3 -3
  180. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +9 -8
  181. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewModel.swift +7 -6
  182. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewNavigationDelegate.swift +24 -25
  183. package/dist/native/iosnativeWebView/iosnativeWebView/AppDelegate.swift +6 -1
  184. package/dist/native/iosnativeWebView/iosnativeWebView/ContentView.swift +1 -0
  185. package/dist/native/iosnativeWebView/iosnativeWebView/iosnativeWebViewApp.swift +4 -0
  186. package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +2 -22
  187. package/dist/native/iosnativeWebView/iosnativeWebViewTests/BridgeMessageValidatorTests.swift +1 -0
  188. package/dist/native/iosnativeWebView/iosnativeWebViewTests/CacheManagerTests.swift +1 -0
  189. package/dist/native/iosnativeWebView/iosnativeWebViewTests/FilePickerHandlerTests.swift +2 -1
  190. package/dist/native/iosnativeWebView/iosnativeWebViewTests/NativeBridgeTests.swift +15 -9
  191. package/dist/native/iosnativeWebView/iosnativeWebViewTests/WebViewTests.swift +1 -0
  192. package/dist/native/setupEmulatorIos.js +2 -2
  193. package/dist/native/terminalProgress.js +17 -17
  194. package/dist/router/ClientRouter.d.ts +8 -0
  195. package/dist/router/ClientRouter.js +13 -11
  196. package/dist/router/ServerRouter.d.ts +13 -0
  197. package/dist/router/ServerRouter.js +19 -7
  198. package/dist/scripts/build.js +14 -2
  199. package/dist/scripts/loadEnvironmentVariables.js +3 -2
  200. package/dist/scripts/plugins.js +1 -1
  201. package/dist/scripts/preServerInit.js +49 -3
  202. package/dist/scripts/preflight.js +111 -0
  203. package/dist/scripts/scriptUtils.js +46 -1
  204. package/dist/scripts/serve.js +7 -3
  205. package/dist/scripts/start.js +8 -3
  206. package/dist/server/expressServer.d.ts +1 -0
  207. package/dist/server/expressServer.js +247 -271
  208. package/dist/server/manifestCache.d.ts +2 -0
  209. package/dist/server/manifestCache.js +25 -33
  210. package/dist/server/renderer/ChunkExtractor.d.ts +44 -0
  211. package/dist/server/renderer/ChunkExtractor.js +113 -125
  212. package/dist/server/renderer/document/Body.d.ts +21 -0
  213. package/dist/server/renderer/document/Body.jsx +45 -45
  214. package/dist/server/renderer/document/FastRefresh.d.ts +3 -0
  215. package/dist/server/renderer/document/FastRefresh.jsx +7 -13
  216. package/dist/server/renderer/document/Head.d.ts +20 -0
  217. package/dist/server/renderer/document/Head.jsx +32 -32
  218. package/dist/server/renderer/document/index.d.ts +2 -0
  219. package/dist/server/renderer/document/index.jsx +2 -2
  220. package/dist/server/renderer/extract.d.ts +67 -0
  221. package/dist/server/renderer/extract.js +92 -89
  222. package/dist/server/renderer/handler.d.ts +2 -0
  223. package/dist/server/renderer/handler.jsx +401 -404
  224. package/dist/server/renderer/index.d.ts +2 -0
  225. package/dist/server/renderer/index.js +5 -8
  226. package/dist/server/renderer/render.d.ts +35 -0
  227. package/dist/server/renderer/render.js +25 -32
  228. package/dist/server/utils/botDetectionMiddleware.d.ts +1 -0
  229. package/dist/server/utils/botDetectionMiddleware.js +33 -23
  230. package/dist/server/utils/cjsRequire.d.ts +8 -0
  231. package/dist/server/utils/cjsRequire.js +2 -2
  232. package/dist/server/utils/userAgentUtil.d.ts +7 -0
  233. package/dist/server/utils/userAgentUtil.js +68 -71
  234. package/dist/server/utils/validator.d.ts +31 -0
  235. package/dist/server/utils/validator.js +133 -158
  236. package/dist/vite/inject-cache-key-plugin.js +3 -27
  237. package/dist/vite/moduleAliases.js +36 -0
  238. package/dist/vite/node-loader.mjs +2 -29
  239. package/dist/vite/resolveDevServerConfig.js +4 -1
  240. package/dist/vite/vite.config.js +2 -29
  241. package/dist/web-router/components/MetaTag.d.ts +4 -0
  242. package/dist/web-router/components/MetaTag.jsx +26 -28
  243. package/dist/web-router/components/MetaTag.test.jsx +100 -0
  244. package/dist/web-router/components/RouterDataProvider.d.ts +96 -0
  245. package/dist/web-router/components/RouterDataProvider.jsx +260 -259
  246. package/dist/web-router/components/RouterDataProvider.server.test.jsx +98 -0
  247. package/dist/web-router/components/RouterDataProvider.test.jsx +310 -0
  248. package/dist/web-router/components/Split.d.ts +74 -0
  249. package/dist/web-router/components/Split.jsx +147 -156
  250. package/dist/web-router/components/Split.server.test.jsx +52 -0
  251. package/dist/web-router/components/Split.test.jsx +167 -0
  252. package/dist/web-router/components/SplitInview.d.ts +22 -0
  253. package/dist/web-router/components/SplitInview.jsx +78 -89
  254. package/dist/web-router/components/SplitInview.test.jsx +112 -0
  255. package/dist/web-router/components/SsrRequestContext.d.ts +20 -0
  256. package/dist/web-router/components/SsrRequestContext.jsx +17 -7
  257. package/dist/web-router/components/SsrRequestContext.test.jsx +53 -0
  258. package/dist/web-router/context.d.ts +15 -0
  259. package/dist/web-router/context.jsx +5 -5
  260. package/dist/web-router/context.test.jsx +10 -0
  261. package/dist/web-router/utils/metaDataUtils.d.ts +24 -0
  262. package/dist/web-router/utils/metaDataUtils.jsx +86 -86
  263. package/dist/web-router/utils/metaDataUtils.test.jsx +188 -0
  264. package/dist/web-router/vitest.setup.js +12 -0
  265. package/mcp_v2/knowledge-base.json +115 -17
  266. package/mcp_v2/mcp.js +141 -3
  267. package/mcp_v2/package-lock.json +2031 -0
  268. package/mcp_v2/package.json +13 -2
  269. package/mcp_v2/scripts/copyErrorsIndex.cjs +34 -0
  270. package/mcp_v2/test/errors.test.ts +123 -0
  271. package/mcp_v2/test/github.test.ts +177 -0
  272. package/mcp_v2/tools/errors.d.ts +20 -0
  273. package/mcp_v2/tools/errors.js +63 -0
  274. package/mcp_v2/tools/github.d.ts +41 -0
  275. package/mcp_v2/tools/github.js +231 -0
  276. package/mcp_v2/vitest.config.mjs +22 -0
  277. package/package.json +60 -11
  278. package/test/errors/docsDrift.test.ts +113 -0
  279. package/test/errors/index.test.ts +200 -0
  280. package/test/errors/registry.test.ts +108 -0
  281. package/test/scripts/preflight.test.ts +118 -0
  282. package/test/server/ChunkExtractor.test.ts +97 -0
  283. package/test/server/extract.test.ts +128 -0
  284. package/test/server/fixtures/template/server/document.jsx +19 -0
  285. package/test/server/fixtures/template/server/index.js +10 -0
  286. package/test/server/fixtures/template/src/js/containers/App/index.jsx +33 -0
  287. package/test/server/fixtures/template/src/js/routes/index.jsx +72 -0
  288. package/test/server/fixtures/template/src/js/routes/utils.jsx +39 -0
  289. package/test/server/fixtures/template/src/js/store/index.js +19 -0
  290. package/test/server/handler.assets.test.ts +330 -0
  291. package/test/server/handler.test.ts +208 -0
  292. package/test/server/manifestCache.test.ts +71 -0
  293. package/test/server/render.test.ts +71 -0
  294. package/test/server/scriptUtils.test.ts +103 -0
  295. package/test/server/userAgentUtil.test.ts +48 -0
  296. package/test/server/validator.test.ts +225 -0
  297. package/test/vite/resolveDevServerConfig.test.js +4 -1
  298. package/tsconfig.test.json +23 -0
  299. package/vitest.config.ts +93 -0
  300. package/dist/caching.js +0 -1
  301. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/DeviceInfoUtilsTest.kt +0 -187
  302. package/dist/native/bridge/standardizedHooks.js +0 -611
  303. package/dist/router.js +0 -1
  304. package/dist/scripts/validator.js +0 -149
  305. package/dist/web-router/hooks.jsx +0 -72
  306. package/dist/web-router/types/components/MetaTag.d.ts +0 -2
  307. package/dist/web-router/types/components/RouterDataProvider.d.ts +0 -95
  308. package/dist/web-router/types/context.d.ts +0 -14
  309. package/dist/web-router/types/hooks.d.ts +0 -1
  310. package/dist/web-router/types/index.d.ts +0 -3
  311. package/dist/web-router/types/utils/metaDataUtils.d.ts +0 -40
  312. /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Constants/CatalystConstants.swift +0 -0
  313. /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Constants/ConfigConstants.swift +0 -0
  314. /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Notifications/NotificationModels.swift +0 -0
  315. /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Protocols/NotificationHandlerProtocol.swift +0 -0
  316. /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NullNotificationHandler.swift +0 -0
@@ -0,0 +1,119 @@
1
+ package io.yourname.androidproject.utils
2
+
3
+ import android.content.Context
4
+ import android.webkit.WebView
5
+ import org.junit.Assert.assertEquals
6
+ import org.junit.Assert.assertFalse
7
+ import org.junit.Assert.assertNull
8
+ import org.junit.Assert.assertTrue
9
+ import org.junit.Test
10
+ import org.mockito.kotlin.mock
11
+
12
+ /**
13
+ * Unit tests for PushNotificationUtils (Android coverage batch 4),
14
+ * previously entirely untested (0/18 lines).
15
+ *
16
+ * Source-set note: this project swaps PushNotificationUtils between two
17
+ * source sets (noFcm/withFcm) based on buildIos/config.js's
18
+ * isNotificationsEnabled() check in app/build.gradle.kts. Verified
19
+ * empirically for this checkout: no catalyst-build.properties file exists,
20
+ * so isNotificationsEnabled() falls back to its default (false), and the
21
+ * noFcm variant is what actually compiles for testDebugUnitTest -- confirmed
22
+ * both by the noFcm-only compiler warnings during `./gradlew
23
+ * testDebugUnitTest` and by `app/build/tmp/kotlin-classes/debug` containing
24
+ * only io/yourname/androidproject/utils/PushNotificationUtils(.class|
25
+ * $Companion.class) built from the noFcm source file. This test file
26
+ * therefore targets app/src/noFcm/java/.../PushNotificationUtils.kt, a
27
+ * trivial no-op stub (Firebase disabled) whose methods only log via
28
+ * BridgeUtils.logInfo/logWarning (which call android.util.Log directly --
29
+ * safe under the mockable android.jar's isReturnDefaultValues=true, no
30
+ * static mocking needed) and otherwise return hardcoded
31
+ * false/null/empty/"none"/"" values.
32
+ *
33
+ * Out of scope: app/src/withFcm/java/.../PushNotificationUtils.kt (the real
34
+ * Firebase-backed implementation) is not compiled under the current build
35
+ * config in this checkout, so it is untestable from testDebugUnitTest here
36
+ * and is not covered by this file.
37
+ */
38
+ class PushNotificationUtilsTest {
39
+
40
+ private val context: Context = mock()
41
+ private val utils = PushNotificationUtils()
42
+
43
+ @Test
44
+ fun `initializeAndGetToken always returns empty string`() {
45
+ assertEquals("", utils.initializeAndGetToken(context))
46
+ }
47
+
48
+ @Test
49
+ fun `handleIncomingPush is a no-op with a real webView`() {
50
+ val webView: WebView = mock()
51
+ // Should not throw; no-op stub only logs.
52
+ utils.handleIncomingPush(webView, context, mapOf("key" to "value"))
53
+ }
54
+
55
+ @Test
56
+ fun `handleIncomingPush is a no-op with a null webView`() {
57
+ utils.handleIncomingPush(null, context, emptyMap())
58
+ }
59
+
60
+ @Test
61
+ fun `handleTokenRefresh is a no-op with a real webView`() {
62
+ val webView: WebView = mock()
63
+ utils.handleTokenRefresh(webView, "some-token")
64
+ }
65
+
66
+ @Test
67
+ fun `handleTokenRefresh is a no-op with a null webView`() {
68
+ utils.handleTokenRefresh(null, "some-token")
69
+ }
70
+
71
+ @Test
72
+ fun `subscribeToTopic always returns false`() {
73
+ assertFalse(utils.subscribeToTopic(context, "topic"))
74
+ }
75
+
76
+ @Test
77
+ fun `unsubscribeFromTopic always returns false`() {
78
+ assertFalse(utils.unsubscribeFromTopic(context, "topic"))
79
+ }
80
+
81
+ @Test
82
+ fun `getPushToken always returns null`() {
83
+ assertNull(utils.getPushToken(context))
84
+ }
85
+
86
+ @Test
87
+ fun `getSubscribedTopics always returns an empty set`() {
88
+ assertTrue(utils.getSubscribedTopics(context).isEmpty())
89
+ }
90
+
91
+ @Test
92
+ fun `deleteAllPushData always returns false`() {
93
+ assertFalse(utils.deleteAllPushData(context))
94
+ }
95
+
96
+ @Test
97
+ fun `getPushProvider always returns none`() {
98
+ assertEquals("none", utils.getPushProvider(context))
99
+ }
100
+
101
+ @Test
102
+ fun `isAvailable always returns false`() {
103
+ assertFalse(utils.isAvailable(context))
104
+ }
105
+
106
+ @Test
107
+ fun `companion action and extra constants have expected values`() {
108
+ assertEquals(
109
+ "io.yourname.androidproject.PUSH_MESSAGE_RECEIVED",
110
+ PushNotificationUtils.ACTION_MESSAGE_RECEIVED
111
+ )
112
+ assertEquals(
113
+ "io.yourname.androidproject.PUSH_TOKEN_REFRESHED",
114
+ PushNotificationUtils.ACTION_TOKEN_REFRESHED
115
+ )
116
+ assertEquals("message_data", PushNotificationUtils.EXTRA_MESSAGE_DATA)
117
+ assertEquals("token", PushNotificationUtils.EXTRA_TOKEN)
118
+ }
119
+ }
@@ -0,0 +1,108 @@
1
+ package io.yourname.androidproject.utils
2
+
3
+ import androidx.core.graphics.Insets
4
+ import androidx.core.view.WindowInsetsCompat
5
+ import org.junit.Assert.assertEquals
6
+ import org.junit.Test
7
+ import org.mockito.kotlin.doReturn
8
+ import org.mockito.kotlin.mock
9
+ import org.mockito.kotlin.whenever
10
+
11
+ /**
12
+ * Unit tests for SafeAreaUtils.fromWindowInsets (Android coverage batch
13
+ * 3), previously entirely untested (0/17 lines).
14
+ *
15
+ * androidx.core.graphics.Insets and WindowInsetsCompat are androidx
16
+ * library classes (not android.jar SDK stubs) -- Insets.of(l,t,r,b) is a
17
+ * real static factory that actually assigns its fields, so value
18
+ * assertions on the returned SafeAreaInsets are meaningful here (unlike
19
+ * android.graphics.RectF in ViewfinderMapperTest, which IS an android.jar
20
+ * stub whose constructor never runs).
21
+ *
22
+ * Deliberately out of scope, per the task: getSafeAreaInsets(window,
23
+ * rootView, edgeToEdgeEnabled) is a thin passthrough that calls
24
+ * ViewCompat.getRootWindowInsets(...) -- a static androidx method --
25
+ * before delegating to fromWindowInsets. Testing it would require
26
+ * mockStatic(ViewCompat), which the task explicitly says to skip; only
27
+ * fromWindowInsets is covered.
28
+ */
29
+ class SafeAreaUtilsTest {
30
+
31
+ private fun windowInsetsCompatWith(systemBars: Insets, cutout: Insets = Insets.NONE): WindowInsetsCompat {
32
+ return mock {
33
+ on { getInsets(WindowInsetsCompat.Type.systemBars()) } doReturn systemBars
34
+ on { getInsets(WindowInsetsCompat.Type.displayCutout()) } doReturn cutout
35
+ }
36
+ }
37
+
38
+ // ============================================================
39
+ // Null input
40
+ // ============================================================
41
+
42
+ @Test
43
+ fun `fromWindowInsets returns ZERO when insets is null`() {
44
+ val result = SafeAreaUtils.fromWindowInsets(null, edgeToEdgeEnabled = true)
45
+ assertEquals(SafeAreaInsets.ZERO, result)
46
+ }
47
+
48
+ // ============================================================
49
+ // edge-to-edge disabled -- system bars only
50
+ // ============================================================
51
+
52
+ @Test
53
+ fun `fromWindowInsets with edge-to-edge disabled returns system bar insets directly`() {
54
+ val systemBars = Insets.of(10, 20, 30, 40)
55
+ val windowInsets = windowInsetsCompatWith(systemBars)
56
+
57
+ val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = false)
58
+
59
+ assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
60
+ }
61
+
62
+ @Test
63
+ fun `fromWindowInsets with edge-to-edge disabled ignores the display cutout`() {
64
+ val systemBars = Insets.of(10, 20, 30, 40)
65
+ val cutout = Insets.of(100, 100, 100, 100)
66
+ val windowInsets = windowInsetsCompatWith(systemBars, cutout)
67
+
68
+ val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = false)
69
+
70
+ assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
71
+ }
72
+
73
+ // ============================================================
74
+ // edge-to-edge enabled -- max(system bars, cutout) per edge
75
+ // ============================================================
76
+
77
+ @Test
78
+ fun `fromWindowInsets with edge-to-edge enabled takes the max of system bars and cutout per edge`() {
79
+ val systemBars = Insets.of(10, 50, 30, 5)
80
+ val cutout = Insets.of(0, 20, 60, 15)
81
+ val windowInsets = windowInsetsCompatWith(systemBars, cutout)
82
+
83
+ val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = true)
84
+
85
+ // left: max(10, 0)=10, top: max(50, 20)=50, right: max(30, 60)=60, bottom: max(5, 15)=15
86
+ assertEquals(SafeAreaInsets(top = 50, right = 60, bottom = 15, left = 10), result)
87
+ }
88
+
89
+ @Test
90
+ fun `fromWindowInsets with edge-to-edge enabled and a zero cutout equals the system bars`() {
91
+ val systemBars = Insets.of(10, 20, 30, 40)
92
+ val windowInsets = windowInsetsCompatWith(systemBars, Insets.NONE)
93
+
94
+ val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = true)
95
+
96
+ assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
97
+ }
98
+
99
+ // ============================================================
100
+ // SafeAreaInsets.toMap()
101
+ // ============================================================
102
+
103
+ @Test
104
+ fun `toMap exposes all four edges by name`() {
105
+ val insets = SafeAreaInsets(top = 1, right = 2, bottom = 3, left = 4)
106
+ assertEquals(mapOf("top" to 1, "right" to 2, "bottom" to 3, "left" to 4), insets.toMap())
107
+ }
108
+ }
@@ -7,5 +7,6 @@ buildscript {
7
7
 
8
8
  plugins {
9
9
  alias(libs.plugins.android.application) apply false
10
+ alias(libs.plugins.android.library) apply false
10
11
  alias(libs.plugins.jetbrains.kotlin.android) apply false
11
12
  }
@@ -12,6 +12,23 @@ webkit = "1.13.0"
12
12
  googleServices = "4.4.0"
13
13
  androidxCredentials = "1.3.0"
14
14
  googleId = "1.1.1"
15
+ # JVM unit test coverage (Tier 1, mirrors the CatalystCoreLogic llvm-cov
16
+ # setup on iOS — see #432/#413). 0.8.12 is the latest 0.8.x line still
17
+ # compatible with this project's Gradle 8.13 / AGP 8.11.1 without pulling
18
+ # in Jacoco's newer bytecode-instrumentation changes meant for JDK 21+
19
+ # language features this app doesn't use.
20
+ jacoco = "0.8.12"
21
+ # Test-only deps for #413 (Tier 1 Android unit tests). kotlinReflect is
22
+ # pinned ahead of the project's forced 2.0.21 Kotlin compiler version
23
+ # solely to satisfy mockito-kotlin 6.x's own kotlin-reflect requirement
24
+ # (>=2.1.20) — see the resolutionStrategy override in app/build.gradle.kts.
25
+ # kotlinxCoroutinesTest is pinned to the 1.10.x line (not the newer 1.11.x)
26
+ # because 1.11.x requires Kotlin 2.2.20, which is out of scope here; 1.10.x
27
+ # is the latest line still JVM-compatible with Kotlin 2.1.x.
28
+ mockitoCore = "5.23.0"
29
+ mockitoKotlin = "6.3.0"
30
+ kotlinReflect = "2.1.20"
31
+ kotlinxCoroutinesTest = "1.10.2"
15
32
 
16
33
  [libraries]
17
34
  androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -25,8 +42,17 @@ androidx-webkit = { group = "androidx.webkit", name = "webkit", version.ref = "w
25
42
  androidx-credentials = { group = "androidx.credentials", name = "credentials", version.ref = "androidxCredentials" }
26
43
  androidx-credentials-play-services-auth = { group = "androidx.credentials", name = "credentials-play-services-auth", version.ref = "androidxCredentials" }
27
44
  googleid = { group = "com.google.android.libraries.identity.googleid", name = "googleid", version.ref = "googleId" }
45
+ mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockitoCore" }
46
+ mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockitoKotlin" }
47
+ kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlinReflect" }
48
+ kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTest" }
28
49
 
29
50
  [plugins]
30
51
  android-application = { id = "com.android.application", version.ref = "agp" }
52
+ # Same AGP version as android-application -- needed so the optional
53
+ # :catalyst-ai library module (wired in settings.gradle.kts when the npm
54
+ # package is installed) can apply `id("com.android.library")` without
55
+ # declaring its own version.
56
+ android-library = { id = "com.android.library", version.ref = "agp" }
31
57
  jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
32
58
  google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
@@ -34,12 +34,15 @@ dependencyResolutionManagement {
34
34
  rootProject.name = "Catalyst Application"
35
35
  include(":app")
36
36
 
37
- // @catalyst/cloud-ai — include when the package is installed.
38
- // The npm package ships an /android library module for native AI; wire it here so Gradle picks it up.
39
- // After running: npm install @catalyst/cloud-ai && npm run sync-packages -- --packages cloud-ai
40
- // Also set ai.enabled=true in your app config to enable useLegacyPackaging for GPU dlopen().
41
- val cloudAiDir = File(rootDir, "../node_modules/@catalyst/cloud-ai/android")
42
- if (cloudAiDir.exists()) {
43
- include(":catalyst-cloud-ai")
44
- project(":catalyst-cloud-ai").projectDir = cloudAiDir
37
+ // catalyst-ai — include when the npm package is installed.
38
+ // The package ships an /android library module (namespace io.catalyst.nativeai)
39
+ // for native AI; wire it here so Gradle picks it up. After running:
40
+ // npm install catalyst-ai && npm run sync-packages -- --packages ai
41
+ // (an `ai.enabled=true` build syncs it automatically -- see
42
+ // buildAndroid/index.js:syncAIPackageIfEnabled). Also set ai.enabled=true in
43
+ // your app config to enable useLegacyPackaging for GPU dlopen().
44
+ val catalystAiDir = File(rootDir, "../node_modules/catalyst-ai/android")
45
+ if (catalystAiDir.exists()) {
46
+ include(":catalyst-ai")
47
+ project(":catalyst-ai").projectDir = catalystAiDir
45
48
  }
@@ -4,7 +4,7 @@ var _fs = _interopRequireDefault(require("fs"));
4
4
  var _path = _interopRequireDefault(require("path"));
5
5
  var _child_process = require("child_process");
6
6
  var _utils = require("./utils.js");
7
- var _TerminalProgress = _interopRequireDefault(require("./TerminalProgress.js"));
7
+ var _terminalProgress = _interopRequireDefault(require("./terminalProgress.js"));
8
8
  var _setupServer = require("./setupServer.js");
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  const catalystCorePath = _path.default.dirname(require.resolve("catalyst-core/package.json"));
@@ -27,7 +27,7 @@ const progressPaddingConfig = {
27
27
  errorPaddingLeft: 6,
28
28
  bottomMargin: 2
29
29
  };
30
- const progress = new _TerminalProgress.default(steps, "Catalyst Universal Android Setup", progressPaddingConfig);
30
+ const progress = new _terminalProgress.default(steps, "Catalyst Universal Android Setup", progressPaddingConfig);
31
31
  async function checkJavaInstallation() {
32
32
  try {
33
33
  (0, _utils.runCommand)("java -version");
@@ -0,0 +1,98 @@
1
+ declare class WebBridge {
2
+ /**
3
+ * Registered callback handlers, keyed by native interface name.
4
+ *
5
+ * Declared without an initializer so it erases to nothing at compile time —
6
+ * the constructor below remains the only thing that assigns it, exactly as
7
+ * before this file was converted.
8
+ */
9
+ handlers: Map<string, (data: any) => void>;
10
+ /** True once {@link WebBridge.init} has attached this instance to `window`. */
11
+ initialized: boolean;
12
+ constructor();
13
+ /**
14
+ * Log initialization info
15
+ */
16
+ _logInitialization(): void;
17
+ /**
18
+ * Static method to initialize WebBridge on window object
19
+ */
20
+ static init: () => any;
21
+ /**
22
+ * Main callback handler called by native platforms
23
+ * @param {string} interfaceName - The callback interface name
24
+ * @param {any} data - Data from native platform
25
+ */
26
+ callback: (interfaceName: any, data: any) => void;
27
+ /**
28
+ * Register a callback handler for a native interface
29
+ * @param {string} interfaceName - The callback interface name (from NATIVE_CALLBACKS)
30
+ * @param {function} callback - The callback function to execute
31
+ * @returns {boolean} - Success status
32
+ */
33
+ register: (interfaceName: any, callback: any) => boolean;
34
+ /**
35
+ * Unregister a callback handler
36
+ * @param {string} interfaceName - The callback interface name to unregister
37
+ * @returns {boolean} - Success status
38
+ */
39
+ unregister: (interfaceName: any) => boolean;
40
+ /**
41
+ * Check if a callback interface is registered
42
+ * @param {string} interfaceName - The callback interface name
43
+ * @returns {boolean} - Registration status
44
+ */
45
+ isRegistered: (interfaceName: any) => boolean;
46
+ /**
47
+ * Get all registered callback interfaces
48
+ * @returns {string[]} - Array of registered interface names
49
+ */
50
+ getRegisteredInterfaces: () => string[];
51
+ /**
52
+ * Get handler for a specific interface (for debugging)
53
+ * @param {string} interfaceName - The callback interface name
54
+ * @returns {function|null} - The registered handler or null
55
+ */
56
+ getHandler: (interfaceName: any) => (data: any) => void;
57
+ /**
58
+ * Clear all registered handlers
59
+ */
60
+ clearAll: () => void;
61
+ /**
62
+ * Debug method to log current state
63
+ */
64
+ debug: () => void;
65
+ /**
66
+ * Test callback functionality (for debugging)
67
+ * @param {string} interfaceName - The callback interface to test
68
+ * @param {any} testData - Test data to pass
69
+ */
70
+ testCallback: (interfaceName: any, testData?: string) => void;
71
+ /**
72
+ * Request haptic feedback
73
+ * @param {string} feedbackType - Type of haptic feedback (VIRTUAL_KEY, LONG_PRESS, DEFAULT)
74
+ * @returns {Promise<Object>} - Promise that resolves with haptic feedback result or rejects with error
75
+ */
76
+ requestHapticFeedback: (feedbackType?: string) => Promise<unknown>;
77
+ /**
78
+ * Open camera and capture image
79
+ * @param {Object} options - Camera options (quality, format, cameraDevice, flashMode, allowEditing)
80
+ * @returns {Promise<Object>} - Promise that resolves with camera result or rejects with error
81
+ */
82
+ openCamera: (options?: {}) => Promise<any>;
83
+ /**
84
+ * Request camera permission
85
+ * @param {Object} config - Permission configuration (includeDetails)
86
+ * @returns {Promise<Object>} - Promise that resolves with permission status or rejects with error
87
+ */
88
+ requestCameraPermission: (config?: {}) => Promise<any>;
89
+ getDeviceInfoFromLegacyBridge: (parseDeviceInfo: any) => Promise<unknown>;
90
+ getDeviceInfoFromPluginBridge: (parseDeviceInfo: any) => Promise<unknown>;
91
+ shouldFallbackToLegacyDeviceInfo: (error: any) => boolean;
92
+ /**
93
+ * Get device information
94
+ * @returns {Promise<Object>} - Promise that resolves with device info or rejects with error
95
+ */
96
+ getDeviceInfo: () => Promise<unknown>;
97
+ }
98
+ export default WebBridge;
@@ -8,6 +8,7 @@ var _NativeInterfaces = require("./constants/NativeInterfaces.js");
8
8
  var _NativeBridge = _interopRequireDefault(require("./utils/NativeBridge.js"));
9
9
  var _CameraUtils = _interopRequireDefault(require("./utils/CameraUtils.js"));
10
10
  var _PluginBridge = _interopRequireDefault(require("../plugin-bridge/PluginBridge.js"));
11
+ var _index = require("../../errors/index.js");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
14
  const DEVICE_INFO_PLUGIN = {
@@ -47,6 +48,16 @@ const createDeviceInfoError = (payload, fallbackMessage) => {
47
48
  return error;
48
49
  };
49
50
  class WebBridge {
51
+ /**
52
+ * Registered callback handlers, keyed by native interface name.
53
+ *
54
+ * Declared without an initializer so it erases to nothing at compile time —
55
+ * the constructor below remains the only thing that assigns it, exactly as
56
+ * before this file was converted.
57
+ */
58
+
59
+ /** True once {@link WebBridge.init} has attached this instance to `window`. */
60
+
50
61
  constructor() {
51
62
  this.handlers = new Map();
52
63
  this.initialized = false;
@@ -69,10 +80,15 @@ class WebBridge {
69
80
  */
70
81
  static init = () => {
71
82
  if (typeof window === "undefined") {
72
- console.error("🌉 WebBridge cannot be initialized outside the browser!");
83
+ console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INIT_FAILED, {
84
+ details: "WebBridge.init() was called outside a browser environment (no `window`)."
85
+ })));
73
86
  return null;
74
87
  }
75
88
  if (window.WebBridge) {
89
+ // Not a failure — the bridge is already up and working, just return it.
90
+ // No code here: RUNTIME-NATIVE-022 means init genuinely failed, which
91
+ // this path is not.
76
92
  console.warn("🌉 WebBridge already initialized!");
77
93
  return window.WebBridge;
78
94
  }
@@ -109,19 +125,27 @@ class WebBridge {
109
125
 
110
126
  // Validate interface
111
127
  if (!(0, _NativeInterfaces.isValidCallback)(interfaceName)) {
112
- console.error(`🌉 Invalid callback interface: ${interfaceName}`);
128
+ console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_CALLBACK, {
129
+ details: `Received "${interfaceName}", which is not in the registered NATIVE_CALLBACKS list.`
130
+ })));
113
131
  console.log("🌉 Available callbacks:", _NativeInterfaces.ALL_CALLBACKS);
114
132
  return;
115
133
  }
116
134
  if (!this.handlers.has(interfaceName)) {
117
- console.warn(`🌉 No handler registered for interface: ${interfaceName}`);
135
+ console.warn((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_HANDLER_NOT_REGISTERED, {
136
+ details: `No handler registered for interface "${interfaceName}".`
137
+ })));
118
138
  return;
119
139
  }
120
140
  try {
121
141
  const handler = this.handlers.get(interfaceName);
122
142
  handler(data);
123
143
  } catch (error) {
124
- console.error(`🌉 Error executing callback for ${interfaceName}:`, error);
144
+ const wrapped = (0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_HANDLER_THREW, {
145
+ details: `The handler registered for "${interfaceName}" threw.`,
146
+ cause: error
147
+ });
148
+ console.error((0, _index.formatError)(wrapped));
125
149
 
126
150
  // In development, provide more helpful error info
127
151
  if (process.env.NODE_ENV === "development") {
@@ -143,13 +167,17 @@ class WebBridge {
143
167
  register = (interfaceName, callback) => {
144
168
  // Validate callback function
145
169
  if (typeof callback !== "function") {
146
- console.error("🌉 Callback must be a function!");
170
+ console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_REGISTRATION, {
171
+ details: `register("${interfaceName}", ...) was called with a non-function callback (got ${typeof callback}).`
172
+ })));
147
173
  return false;
148
174
  }
149
175
 
150
176
  // Validate interface name
151
177
  if (!(0, _NativeInterfaces.isValidCallback)(interfaceName)) {
152
- console.error(`🌉 Invalid callback interface: ${interfaceName}`);
178
+ console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_REGISTRATION, {
179
+ details: `register() was called with "${interfaceName}", which is not a valid callback interface.`
180
+ })));
153
181
  console.log("🌉 Available callback interfaces:", _NativeInterfaces.ALL_CALLBACKS);
154
182
  return false;
155
183
  }
@@ -391,6 +419,12 @@ class WebBridge {
391
419
  }
392
420
  }));
393
421
  try {
422
+ // `as any` only because PluginBridge is still plain JS: TypeScript
423
+ // infers its `emit({ pluginId, command, data = null } = {})` shape
424
+ // from the `= {}` default alone and concludes it accepts only
425
+ // `{ data?: any }`, rejecting the two keys the body itself reads.
426
+ // The assertion erases at compile time — the emitted call is byte
427
+ // for byte the one this file made before the conversion.
394
428
  _PluginBridge.default.emit({
395
429
  pluginId: DEVICE_INFO_PLUGIN.pluginId,
396
430
  command: DEVICE_INFO_PLUGIN.command