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
@@ -1,164 +1,139 @@
1
- import pc from "picocolors"
1
+ import pc from "ansis";
2
+ import { createError, formatError, ERROR_CODES } from "../../errors/index.js";
3
+ import { resolveOutputMode, getDebugEnvInfo } from "../../scripts/scriptUtils.js";
2
4
 
3
- const handleError = (e) => {
4
- console.log(pc.red("Failed to start server: "), e)
5
- }
5
+ // Resolved once at module load — this module runs inside expressServer.js,
6
+ // spawned by serve.js/start.js which forward the mode via
7
+ // CATALYST_OUTPUT_MODE. Passed an empty argv on purpose: this process never
8
+ // sees the parent's CLI flags, so only CATALYST_OUTPUT_MODE is real input.
9
+ const outputMode = resolveOutputMode([], process.env);
6
10
 
7
- const validatePreInitServer = (fn) => {
8
- try {
9
- if (!fn) throw new Error("preServerInit named function should be defined in server/index.js")
10
- if (typeof fn !== "function")
11
- throw new Error("preServerInit should be function present in server/index.js")
12
- return true
13
- } catch (e) {
14
- handleError(e)
15
- }
16
- }
17
-
18
- const validateMiddleware = (fn) => {
19
- try {
20
- if (!fn) throw new Error("addMiddlewares named function not found in server/server.js")
21
- if (typeof fn !== "function")
22
- throw new Error("addMiddlewares should be function present in server/server.js")
23
- return true
24
- } catch (e) {
25
- handleError(e)
26
- }
27
- }
28
-
29
- const validateReducerFunction = (fn) => {
30
- try {
31
- if (!fn) throw new Error("reducer not found in src/js/containers/App/reducer")
32
- if (typeof fn !== "function")
33
- throw new Error("reducer should present in src/js/containers/App/reducer")
34
- return true
35
- } catch (e) {
36
- handleError(e)
37
- }
38
- }
39
-
40
- const validateConfigFile = (obj) => {
41
- try {
42
- if (!obj) throw new Error("config not found in config folder")
43
- if (typeof obj !== "object")
44
- throw new Error(
45
- "config object should be exported from config folder inside your project root directory"
46
- )
47
- if (typeof obj === "object") {
48
- const requiredConfigKeys = {
49
- NODE_SERVER_HOSTNAME: "",
50
- NODE_SERVER_PORT: "",
51
- WEBPACK_DEV_SERVER_HOSTNAME: "",
52
- WEBPACK_DEV_SERVER_PORT: "",
53
- BUILD_OUTPUT_PATH: "",
54
- PUBLIC_STATIC_ASSET_PATH: "",
55
- PUBLIC_STATIC_ASSET_URL: "",
56
- CLIENT_ENV_VARIABLES: [],
57
- ANALYZE_BUNDLE: "",
58
- }
59
- for (let key in requiredConfigKeys) {
60
- if (!(key in obj)) throw new Error(`${key} key not found inside config.json`)
61
- }
62
- }
63
- return true
64
- } catch (e) {
65
- handleError(e)
66
- }
67
- }
68
-
69
- const validatePackageJson = (obj) => {
70
- try {
71
- if (!obj) throw new Error("package.json not found in the project")
72
- if (typeof obj !== "object")
73
- throw new Error("package.json should be defined in project root directory")
74
- return true
75
- } catch (e) {
76
- handleError(e)
77
- }
78
- }
79
-
80
- const validateModuleAlias = (obj) => {
81
- try {
82
- if (!obj) throw new Error("moduleAliases not found in package.json file present in root directory.")
83
- if (typeof obj !== "object")
84
- throw new Error("moduleAliases named object should be exported from package.json")
85
- if (typeof obj === "object") {
86
- const requiredModuleAliases = {
87
- "@api": "api.js",
88
- "@containers": "src/js/containers",
89
- "@server": "server",
90
- "@config": "config",
91
- "@css": "src/static/css",
92
- "@routes": "src/js/routes/",
93
- }
94
- for (let key in requiredModuleAliases) {
95
- if (key.includes("catalyst"))
96
- throw new Error(`Catalyst keyword is restricted for defining aliases`)
97
- if (!(key in obj)) throw new Error(`${key} module alias not defined inside package.json`)
98
- }
99
- }
100
- return true
101
- } catch (e) {
102
- handleError(e)
103
- }
104
- }
105
-
106
- const validateConfigureStore = (fn) => {
107
- try {
108
- if (!fn) throw new Error("configureStore not found in file src/js/store/index.js")
109
- if (typeof fn !== "function")
110
- throw new Error("configureStore should be function exported from src/js/store/index.js")
111
- return true
112
- } catch (e) {
113
- handleError(e)
114
- }
115
- }
116
-
117
- const validateGetRoutes = (fn) => {
118
- try {
119
- if (!fn) throw new Error("getRoutes not found in file src/js/routes/utils.js")
120
- if (typeof fn !== "function")
121
- throw new Error("getRoutes should be function exported from src/js/routers/index.js")
122
- return true
123
- } catch (e) {
124
- handleError(e)
125
- }
126
- }
127
-
128
- const validateCustomDocument = (fn) => {
129
- try {
130
- if (!fn) throw new Error("document not found in file server/document.js")
131
- if (typeof fn !== "function")
132
- throw new Error("document should be a react component exported from server/document.js")
133
- return true
134
- } catch (e) {
135
- handleError(e)
136
- }
137
- }
11
+ // The validate* functions are PURE: they return `null` when the input is
12
+ // valid and a `CatalystError` (never thrown, never logged) when it isn't.
13
+ // This lets two very different callers share one definition:
14
+ // - scripts/preflight.js (parent CLI process) collects the errors from
15
+ // several validators and prints them all, then exits non-zero.
16
+ // - the in-server call sites (expressServer.js, handler.jsx) log the
17
+ // single error and fall back, keeping the request alive.
18
+ // `handleError` below is the shared "log it, in whatever output mode" helper
19
+ // those in-server sites use.
20
+ const handleError = e => {
21
+ const debugEnv = outputMode === "debug" ? getDebugEnvInfo() : undefined;
22
+ if (outputMode === "default") {
23
+ console.log(pc.red("Failed to start server: "), formatError(e, outputMode));
24
+ } else {
25
+ console.log(formatError(e, outputMode, debugEnv));
26
+ }
27
+ };
28
+ const validatePreInitServer = fn => {
29
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_PRE_SERVER_INIT_MISSING);
30
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_PRE_SERVER_INIT_NOT_FUNCTION);
31
+ return null;
32
+ };
33
+ const validateMiddleware = fn => {
34
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_MIDDLEWARE_MISSING);
35
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_MIDDLEWARE_NOT_FUNCTION);
36
+ return null;
37
+ };
38
+ const validateReducerFunction = fn => {
39
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_REDUCER_MISSING);
40
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_REDUCER_NOT_FUNCTION);
41
+ return null;
42
+ };
43
+ const validateConfigFile = obj => {
44
+ if (!obj) return createError(ERROR_CODES.PREFLIGHT_CONFIG_MISSING);
45
+ if (typeof obj !== "object") return createError(ERROR_CODES.PREFLIGHT_CONFIG_NOT_OBJECT);
46
+ const requiredConfigKeys = ["NODE_SERVER_HOSTNAME", "NODE_SERVER_PORT", "BUILD_OUTPUT_PATH", "PUBLIC_STATIC_ASSET_PATH", "PUBLIC_STATIC_ASSET_URL", "CLIENT_ENV_VARIABLES"];
47
+ for (const key of requiredConfigKeys) {
48
+ if (!(key in obj)) return createError(ERROR_CODES.PREFLIGHT_CONFIG_KEY_MISSING, {
49
+ details: `${key} key not found inside config.json`
50
+ });
51
+ }
52
+ return null;
53
+ };
54
+ const validatePackageJson = obj => {
55
+ if (!obj) return createError(ERROR_CODES.PREFLIGHT_PACKAGE_JSON_MISSING);
56
+ if (typeof obj !== "object") return createError(ERROR_CODES.PREFLIGHT_PACKAGE_JSON_INVALID);
57
+ return null;
58
+ };
59
+ const validateModuleAlias = obj => {
60
+ if (!obj) return createError(ERROR_CODES.PREFLIGHT_MODULE_ALIAS_MISSING);
61
+ if (typeof obj !== "object") return createError(ERROR_CODES.PREFLIGHT_MODULE_ALIAS_NOT_OBJECT);
62
+ // A consumer app must not shadow the framework's own "@catalyst*" aliases
63
+ // (both "@catalyst/…" and "@catalyst-…" are reserved) with its own
64
+ // moduleAliases entries — check the INPUT's keys, not the required list
65
+ // (that check was previously on the wrong side and could never fire;
66
+ // PREFLIGHT-008). Anchored to the start and case-insensitive: a bare
67
+ // `.includes("catalyst")` also (wrongly) rejected unrelated names like
68
+ // "@my-catalyst-helpers", which don't shadow anything.
69
+ if (Object.keys(obj).some(key => /^@catalyst($|[/-])/i.test(key))) return createError(ERROR_CODES.PREFLIGHT_MODULE_ALIAS_RESTRICTED);
70
+ const requiredModuleAliases = ["@api", "@containers", "@server", "@config", "@css", "@routes"];
71
+ for (const key of requiredModuleAliases) {
72
+ if (!(key in obj)) return createError(ERROR_CODES.PREFLIGHT_MODULE_ALIAS_KEY_MISSING, {
73
+ details: `${key} module alias not defined inside package.json`
74
+ });
75
+ }
76
+ return null;
77
+ };
78
+ const validateConfigureStore = fn => {
79
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_CONFIGURE_STORE_MISSING);
80
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_CONFIGURE_STORE_NOT_FUNCTION);
81
+ return null;
82
+ };
83
+ const validateGetRoutes = fn => {
84
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_GET_ROUTES_MISSING);
85
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_GET_ROUTES_NOT_FUNCTION);
86
+ return null;
87
+ };
88
+ const validateCustomDocument = fn => {
89
+ if (!fn) return createError(ERROR_CODES.PREFLIGHT_CUSTOM_DOCUMENT_MISSING);
90
+ if (typeof fn !== "function") return createError(ERROR_CODES.PREFLIGHT_CUSTOM_DOCUMENT_NOT_FUNCTION);
91
+ return null;
92
+ };
138
93
 
139
94
  /**
140
- * Safely call a function, catching and logging any errors.
141
- * Used for user-defined hooks (onRouteMatch, onFetcherError, etc.)
142
- * that should never crash the SSR pipeline.
95
+ * Safely call a function, catching and logging any errors — including a
96
+ * rejected promise if `fn` is async. Used for user-defined hooks
97
+ * (preServerInit, onRouteMatch, onFetcherError, onServerError, etc.) that
98
+ * should never crash the SSR pipeline.
99
+ *
100
+ * Async by necessity: awaiting `fn`'s return value is the only way to catch
101
+ * a rejection in the same try/catch as a synchronous throw. Existing call
102
+ * sites that don't await safeCall(...) are unaffected — they already
103
+ * treated its return value as fire-and-forget — but the rejection now
104
+ * reaches the same structured-error path a sync throw does, instead of
105
+ * surfacing as an unhandled promise rejection.
143
106
  */
144
- const safeCall = (fn, ...args) => {
145
- if (typeof fn !== "function") return
146
- try {
147
- return fn(...args)
148
- } catch (e) {
149
- console.error("Error in user hook:", e)
150
- }
151
- }
107
+ const safeCall = async (fn, ...args) => {
108
+ if (typeof fn !== "function") return;
109
+ try {
110
+ return await fn(...args);
111
+ } catch (e) {
112
+ const wrapped = createError(ERROR_CODES.PROCESS_USER_HOOK_FAILED, {
113
+ cause: e
114
+ });
115
+ const debugEnv = outputMode === "debug" ? getDebugEnvInfo() : undefined;
116
+ console.error(formatError(wrapped, outputMode, debugEnv));
117
+ }
118
+ };
152
119
 
153
- export {
154
- validateConfigFile,
155
- validateConfigureStore,
156
- validateCustomDocument,
157
- validateGetRoutes,
158
- validatePackageJson,
159
- validateReducerFunction,
160
- validateModuleAlias,
161
- validatePreInitServer,
162
- validateMiddleware,
163
- safeCall,
164
- }
120
+ /**
121
+ * Same as safeCall, but names the specific hook (e.g. "preServerInit") in the
122
+ * error so it's identifiable rather than generic. Used at call sites that know
123
+ * which hook they're invoking.
124
+ */
125
+ const safeCallNamed = async (hookName, fn, ...args) => {
126
+ if (typeof fn !== "function") return;
127
+ try {
128
+ return await fn(...args);
129
+ } catch (e) {
130
+ const code = hookName === "preServerInit" ? ERROR_CODES.PROCESS_SERVER_INIT_FAILED : ERROR_CODES.PROCESS_USER_HOOK_FAILED;
131
+ const wrapped = createError(code, {
132
+ details: `The "${hookName}" hook threw. See the cause below.`,
133
+ cause: e
134
+ });
135
+ const debugEnv = outputMode === "debug" ? getDebugEnvInfo() : undefined;
136
+ console.error(formatError(wrapped, outputMode, debugEnv));
137
+ }
138
+ };
139
+ export { handleError, validateConfigFile, validateConfigureStore, validateCustomDocument, validateGetRoutes, validatePackageJson, validateReducerFunction, validateModuleAlias, validatePreInitServer, validateMiddleware, safeCall, safeCallNamed };
@@ -1,9 +1,6 @@
1
1
  import path from "path"
2
- import { readFileSync, existsSync, statSync } from "fs"
3
- import { fileURLToPath } from "url"
4
-
5
- const __filename = fileURLToPath(import.meta.url)
6
- const __dirname = path.dirname(__filename)
2
+ import { existsSync, statSync } from "fs"
3
+ import { getModuleAliases } from "./moduleAliases.js"
7
4
 
8
5
  // Cache for loaded aliases
9
6
  let aliasCache = null
@@ -18,28 +15,7 @@ function loadAliases() {
18
15
  }
19
16
 
20
17
  const appRoot = process.env.src_path || process.cwd()
21
- const appPackageJsonConfig = path.resolve(appRoot, "package.json")
22
- const catalystPackageJsonConfig = path.resolve(__dirname, "../../package.json")
23
-
24
- let appModuleAliases = {}
25
- let catalystModuleAliases = {}
26
-
27
- try {
28
- const appPackageJson = JSON.parse(readFileSync(appPackageJsonConfig, "utf8"))
29
- appModuleAliases = appPackageJson._moduleAliases || {}
30
- } catch {
31
- // Silently fail if app package.json doesn't exist or is invalid
32
- }
33
-
34
- try {
35
- const catalystPackageJson = JSON.parse(readFileSync(catalystPackageJsonConfig, "utf8"))
36
- catalystModuleAliases = catalystPackageJson._moduleAliases || {}
37
- } catch {
38
- // Silently fail if catalyst package.json doesn't exist or is invalid
39
- }
40
-
41
- // Application aliases take precedence over catalyst-core aliases
42
- const allAliases = { ...catalystModuleAliases, ...appModuleAliases }
18
+ const allAliases = getModuleAliases(appRoot)
43
19
 
44
20
  aliasCache = {}
45
21
  for (const [alias, aliasPath] of Object.entries(allAliases)) {
@@ -0,0 +1,36 @@
1
+ // Single source of truth for merging the consuming app's `_moduleAliases` with
2
+ // catalyst-core's own. Three call sites (vite.config.js, node-loader.mjs,
3
+ // inject-cache-key-plugin.js) previously each read both package.jsons and
4
+ // merged them inline, and their spread order had drifted apart. Path resolution
5
+ // deliberately stays with the callers — they resolve differently — so this owns
6
+ // only the reading and the precedence.
7
+
8
+ import path from "path"
9
+ import fs from "fs"
10
+ import { fileURLToPath } from "url"
11
+
12
+ const __filename = fileURLToPath(import.meta.url)
13
+ const __dirname = path.dirname(__filename)
14
+
15
+ function readModuleAliases(packageJsonPath) {
16
+ try {
17
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
18
+ return packageJson._moduleAliases || {}
19
+ } catch {
20
+ return {}
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Raw (unresolved) alias map for an app root, with the app's own aliases taking
26
+ * precedence over catalyst-core's on key collision.
27
+ *
28
+ * @param {string} [appRoot] - The consuming application's root directory. Defaults to process.cwd().
29
+ * @returns {Record<string, string>} Merged alias name -> raw alias path.
30
+ */
31
+ export function getModuleAliases(appRoot = process.cwd()) {
32
+ const appModuleAliases = readModuleAliases(path.resolve(appRoot, "package.json"))
33
+ const catalystModuleAliases = readModuleAliases(path.resolve(__dirname, "../../package.json"))
34
+
35
+ return { ...catalystModuleAliases, ...appModuleAliases }
36
+ }
@@ -3,9 +3,7 @@ import { dirname, resolve as resolvePath, join, extname } from "path"
3
3
  import { readFileSync, existsSync, statSync } from "fs"
4
4
  import { createRequire } from "module"
5
5
  import { transformSync } from "esbuild"
6
-
7
- const __filename = fileURLToPath(import.meta.url)
8
- const __dirname = dirname(__filename)
6
+ import { getModuleAliases } from "./moduleAliases.js"
9
7
 
10
8
  // Cache for loaded aliases
11
9
  let aliasCache = null
@@ -20,32 +18,7 @@ function loadAliases() {
20
18
 
21
19
  const appRoot = process.env.src_path || process.cwd()
22
20
 
23
- const appPackageJsonConfig = resolvePath(appRoot, "package.json")
24
- const catalystPackageJsonConfig = resolvePath(__dirname, "../../package.json")
25
-
26
- let appModuleAliases = {}
27
- let catalystModuleAliases = {}
28
-
29
- // Read aliases from consuming application's package.json
30
- try {
31
- const appPackageJsonContent = readFileSync(appPackageJsonConfig, "utf8")
32
- const appPackageJson = JSON.parse(appPackageJsonContent)
33
- appModuleAliases = appPackageJson._moduleAliases || {}
34
- } catch (error) {
35
- // Silently fail if app package.json doesn't exist or is invalid
36
- }
37
-
38
- // Read aliases from catalyst-core's package.json
39
- try {
40
- const catalystPackageJsonContent = readFileSync(catalystPackageJsonConfig, "utf8")
41
- const catalystPackageJson = JSON.parse(catalystPackageJsonContent)
42
- catalystModuleAliases = catalystPackageJson._moduleAliases || {}
43
- } catch (error) {
44
- // Silently fail if catalyst package.json doesn't exist or is invalid
45
- }
46
-
47
- // Application aliases take precedence over catalyst-core aliases
48
- const allAliases = { ...catalystModuleAliases, ...appModuleAliases }
21
+ const allAliases = getModuleAliases(appRoot)
49
22
 
50
23
  // Convert aliases to resolved paths
51
24
  aliasCache = {}
@@ -10,7 +10,9 @@
10
10
  export function resolveDevBase(devServer = {}) {
11
11
  const base = devServer?.base
12
12
  if (!base || base === "/") return "/"
13
- return `/${String(base).trim().replace(/^\/+|\/+$/g, "")}`
13
+ return `/${String(base)
14
+ .trim()
15
+ .replace(/^\/+|\/+$/g, "")}`
14
16
  }
15
17
 
16
18
  /**
@@ -36,6 +38,7 @@ export function resolveDevFsAllow(devFs, frameworkPaths) {
36
38
  * first so the framework-owned `hmr` and `fs` always win.
37
39
  */
38
40
  export function buildDevServer(devServer = {}, { frameworkPaths, isProduction = false } = {}) {
41
+ // eslint-disable-next-line no-unused-vars -- base is destructured only to omit it from serverOverrides
39
42
  const { base, hmr, fs, ...serverOverrides } = devServer
40
43
  return {
41
44
  ...serverOverrides,
@@ -4,6 +4,7 @@ import svgr from "vite-plugin-svgr"
4
4
  import { builtinModules, createRequire } from "node:module"
5
5
  import { loadCustomViteConfig } from "./loadCustomViteConfig.js"
6
6
  import { resolveDevBase, buildDevServer } from "./resolveDevServerConfig.js"
7
+ import { getModuleAliases } from "./moduleAliases.js"
7
8
 
8
9
  /**
9
10
  * Treat all .scss imports as CSS modules (webpack compat).
@@ -103,35 +104,7 @@ const __dirname = dirname(__filename)
103
104
  import path from "path"
104
105
  import fs from "fs"
105
106
 
106
- const packageJsonConfig = path.resolve(process.env.src_path, "package.json")
107
- const catalystPackageJsonConfig = path.resolve(__dirname, "../../package.json")
108
-
109
- let packageJsonContent, catalystPackageJsonContent
110
- let _moduleAliases = {},
111
- catalyst_moduleAliases = {}
112
-
113
- try {
114
- packageJsonContent = fs.readFileSync(packageJsonConfig, "utf8")
115
- const packageJson = JSON.parse(packageJsonContent)
116
- _moduleAliases = packageJson._moduleAliases || {}
117
- } catch (error) {
118
- // nosemgrep: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring - packageJsonConfig is a build-time-resolved local path, not attacker-controlled; console.warn here does no printf-style substitution.
119
- console.warn(`Failed to read or parse package.json from ${packageJsonConfig}:`, error.message)
120
- }
121
-
122
- try {
123
- catalystPackageJsonContent = fs.readFileSync(catalystPackageJsonConfig, "utf8")
124
- const catalystPackageJson = JSON.parse(catalystPackageJsonContent)
125
- catalyst_moduleAliases = catalystPackageJson._moduleAliases || {}
126
- } catch (error) {
127
- console.warn(
128
- // nosemgrep: javascript.lang.security.audit.unsafe-formatstring.unsafe-formatstring - catalystPackageJsonConfig is a build-time-resolved local path, not attacker-controlled; console.warn here does no printf-style substitution.
129
- `Failed to read or parse catalyst package.json from ${catalystPackageJsonConfig}:`,
130
- error.message
131
- )
132
- }
133
-
134
- const allAliases = { ..._moduleAliases, ...catalyst_moduleAliases }
107
+ const allAliases = getModuleAliases(process.env.src_path)
135
108
 
136
109
  import { imageUrl, fontUrl } from "./scssParams.js"
137
110
 
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @description renders meta tags component assigned to setMetaData
3
+ */
4
+ export declare const MetaTag: () => any;
@@ -1,34 +1,32 @@
1
- import React, { useContext, useState, useEffect } from "react"
2
- import { HelmetProvider, Helmet } from "react-helmet-async"
3
- import { OneMgRouterContext } from "../context.jsx"
4
- import { useRouterData } from "./RouterDataProvider.jsx"
5
- import { deleteHeadTagsByDataAttribute, getMetaData } from "../utils/metaDataUtils.jsx"
6
- import { useLocation } from "react-router"
1
+ import React, { useContext, useState, useEffect } from "react";
2
+ import { HelmetProvider, Helmet } from "react-helmet-async";
3
+ import { OneMgRouterContext } from "../context.jsx";
4
+ import { useRouterData } from "./RouterDataProvider.jsx";
5
+ import { deleteHeadTagsByDataAttribute, getMetaData } from "../utils/metaDataUtils.jsx";
6
+ import { useLocation } from "react-router";
7
7
 
8
8
  /**
9
9
  * @description renders meta tags component assigned to setMetaData
10
10
  */
11
11
  export const MetaTag = () => {
12
- const { matchedRoutes } = useContext(OneMgRouterContext)
13
- const routeData = useRouterData()
14
- const location = useLocation()
15
- const [metaTags, setMetaTags] = useState([<meta key={0}></meta>])
16
-
17
- useEffect(() => {
18
- const mergedMetaTags = getMetaData(matchedRoutes, routeData)
19
- if (Array.isArray(mergedMetaTags) && mergedMetaTags.length > 0) {
20
- setMetaTags(mergedMetaTags)
21
- }
22
- return () => deleteHeadTagsByDataAttribute("catalyst")
23
- // eslint-disable-next-line react-hooks/exhaustive-deps
24
- }, [location])
25
-
26
- if (Array.isArray(metaTags) && metaTags.length >= 0) {
27
- return (
28
- <HelmetProvider>
29
- <Helmet>{metaTags}</Helmet>
30
- </HelmetProvider>
31
- )
12
+ const {
13
+ matchedRoutes
14
+ } = useContext(OneMgRouterContext);
15
+ const routeData = useRouterData();
16
+ const location = useLocation();
17
+ const [metaTags, setMetaTags] = useState([<meta key={0}></meta>]);
18
+ useEffect(() => {
19
+ const mergedMetaTags = getMetaData(matchedRoutes, routeData);
20
+ if (Array.isArray(mergedMetaTags) && mergedMetaTags.length > 0) {
21
+ setMetaTags(mergedMetaTags);
32
22
  }
33
- return <></>
34
- }
23
+ return () => deleteHeadTagsByDataAttribute("catalyst");
24
+ // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ }, [location]);
26
+ if (Array.isArray(metaTags) && metaTags.length >= 0) {
27
+ return <HelmetProvider>
28
+ <Helmet>{metaTags}</Helmet>
29
+ </HelmetProvider>;
30
+ }
31
+ return <></>;
32
+ };