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.
- package/changelog.md +185 -71
- package/dist/errors/generateDocs.js +100 -0
- package/dist/errors/index.js +243 -0
- package/dist/errors/registry.js +483 -0
- package/dist/errors-index.json +506 -0
- package/dist/globals.d.ts +62 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.jsx +5 -8
- package/dist/logger.js +1 -1
- package/dist/native/androidProject/app/build.gradle.kts +142 -7
- package/dist/native/androidProject/app/src/main/AndroidManifest.xml +4 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/NativeBridge.kt +2 -2
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/camera/BarcodeDetector.kt +3 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/camera/CameraSessionManager.kt +3 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/FrameworkServerUtils.kt +43 -8
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/BridgeUtilsTest.kt +181 -1
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/CameraUtilsTest.kt +156 -236
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FileSizeRouterUtilsTest.kt +471 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FileUtilsTest.kt +222 -226
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/FrameworkServerUtilsTest.kt +300 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/IntentUtilsTest.kt +244 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/MetricsMonitorTest.kt +359 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/NativeBridgeTest.kt +108 -63
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/NotificationUtilsTest.kt +329 -385
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/OfflineCacheServiceTest.kt +302 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/PerfEventBufferTest.kt +133 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/UtilsKtTest.kt +152 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/WebCacheManagerTest.kt +145 -324
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/BarcodeDetectorTest.kt +132 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/HoldControllerTest.kt +155 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/TorchControllerTest.kt +150 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/VideoStreamStateMachineTest.kt +120 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/VideoStreamStateTest.kt +62 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/ViewfinderMapperTest.kt +143 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/camera/ZoomControllerTest.kt +421 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/design/DesignTokensTest.kt +207 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/plugins/PluginBridgeTest.kt +368 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/FridaDetectorTest.kt +193 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/SecurityCheckManagerTest.kt +260 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/security/SecurityCheckSchedulerTest.kt +166 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/DeviceInfoUtilsTest.kt +167 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/DownloadUtilsTest.kt +197 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/NetworkMonitorTest.kt +271 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/PushNotificationUtilsTest.kt +119 -0
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/utils/SafeAreaUtilsTest.kt +108 -0
- package/dist/native/androidProject/build.gradle.kts +1 -0
- package/dist/native/androidProject/gradle/libs.versions.toml +26 -0
- package/dist/native/androidProject/settings.gradle.kts +11 -8
- package/dist/native/androidSetup.js +2 -2
- package/dist/native/bridge/WebBridge.d.ts +98 -0
- package/dist/native/bridge/WebBridge.js +40 -6
- package/dist/native/bridge/constants/NativeInterfaces.d.ts +391 -0
- package/dist/native/bridge/errors.d.ts +67 -0
- package/dist/native/bridge/errors.js +66 -151
- package/dist/native/bridge/hooks/index.d.ts +13 -0
- package/dist/native/bridge/hooks/index.js +0 -6
- package/dist/native/bridge/hooks/useAI.d.ts +1 -0
- package/dist/native/bridge/hooks/useAI.js +3 -1
- package/dist/native/bridge/hooks/useCamera.d.ts +86 -0
- package/dist/native/bridge/hooks/useCamera.js +35 -6
- package/dist/native/bridge/hooks/useDataProtection.d.ts +17 -0
- package/dist/native/bridge/hooks/useDeviceInfo.d.ts +34 -0
- package/dist/native/bridge/hooks/useDeviceInfo.js +5 -0
- package/dist/native/bridge/hooks/useFilePicker.d.ts +53 -0
- package/dist/native/bridge/hooks/useFilePicker.js +13 -0
- package/dist/native/bridge/hooks/useGoogleSignIn.d.ts +12 -0
- package/dist/native/bridge/hooks/useHapticFeedback.d.ts +76 -0
- package/dist/native/bridge/hooks/useHapticFeedback.js +6 -1
- package/dist/native/bridge/hooks/useIntent.d.ts +33 -0
- package/dist/native/bridge/hooks/useIntent.js +2 -0
- package/dist/native/bridge/hooks/useNativeTransition.d.ts +53 -0
- package/dist/native/bridge/hooks/useNativeTransition.js +12 -5
- package/dist/native/bridge/hooks/useNetworkStatus.d.ts +22 -0
- package/dist/native/bridge/hooks/useNetworkStatus.js +7 -0
- package/dist/native/bridge/hooks/useNotification.d.ts +83 -0
- package/dist/native/bridge/hooks/useNotification.js +81 -34
- package/dist/native/bridge/hooks/useSafeArea.d.ts +12 -0
- package/dist/native/bridge/hooks/useSafeArea.js +8 -0
- package/dist/native/bridge/hooks/useVideoStream.d.ts +67 -0
- package/dist/native/bridge/hooks/useVideoStream.js +38 -52
- package/dist/native/bridge/hooks/utils.d.ts +4 -0
- package/dist/native/bridge/hooks.d.ts +1 -0
- package/dist/native/bridge/perf/collectors/ApiCollector.d.ts +30 -0
- package/dist/native/bridge/perf/collectors/ApiCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/CacheCollector.d.ts +43 -0
- package/dist/native/bridge/perf/collectors/CacheCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/HookCollector.d.ts +37 -0
- package/dist/native/bridge/perf/collectors/HookCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/InsightsCollector.d.ts +103 -0
- package/dist/native/bridge/perf/collectors/InsightsCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/InteractionCollector.d.ts +53 -0
- package/dist/native/bridge/perf/collectors/InteractionCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/KeyboardCollector.d.ts +30 -0
- package/dist/native/bridge/perf/collectors/KeyboardCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/NavigationCollector.d.ts +37 -0
- package/dist/native/bridge/perf/collectors/NavigationCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/NetworkTimingCollector.d.ts +30 -0
- package/dist/native/bridge/perf/collectors/NetworkTimingCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/RenderCollector.d.ts +47 -0
- package/dist/native/bridge/perf/collectors/RenderCollector.js +8 -0
- package/dist/native/bridge/perf/collectors/ScrollCollector.d.ts +29 -0
- package/dist/native/bridge/perf/collectors/ScrollCollector.js +4 -0
- package/dist/native/bridge/perf/collectors/ThreadCollector.d.ts +31 -0
- package/dist/native/bridge/perf/collectors/ThreadCollector.js +4 -0
- package/dist/native/bridge/perf/core/constants.d.ts +76 -0
- package/dist/native/bridge/perf/core/measure.d.ts +39 -0
- package/dist/native/bridge/perf/core/measure.js +4 -0
- package/dist/native/bridge/perf/core/session.d.ts +49 -0
- package/dist/native/bridge/perf/core/session.js +4 -0
- package/dist/native/bridge/perf/core/store.d.ts +37 -0
- package/dist/native/bridge/perf/core/store.js +4 -0
- package/dist/native/bridge/perf/core/summary.d.ts +60 -0
- package/dist/native/bridge/perf/core/traceExport.d.ts +10 -0
- package/dist/native/bridge/perf/core/waterfalls.d.ts +2 -0
- package/dist/native/bridge/perf/index.d.ts +63 -0
- package/dist/native/bridge/perf/index.js +4 -0
- package/dist/native/bridge/safeArea.d.ts +11 -0
- package/dist/native/bridge/safeArea.js +2 -0
- package/dist/native/bridge/useBaseHook.d.ts +137 -0
- package/dist/native/bridge/useBaseHook.js +34 -4
- package/dist/native/bridge/utils/CameraUtils.d.ts +94 -0
- package/dist/native/bridge/utils/CameraUtils.js +4 -0
- package/dist/native/bridge/utils/FileObjectConverter.d.ts +36 -0
- package/dist/native/bridge/utils/NativeBridge.d.ts +270 -0
- package/dist/native/bridge/utils/NativeBridge.js +10 -0
- package/dist/native/buildAndroid/index.js +1 -1
- package/dist/native/buildAppAndroid.js +9 -0
- package/dist/native/buildAppIos.js +16 -1
- package/dist/native/buildErrorFormat.js +57 -0
- package/dist/native/buildIos/config.js +15 -1
- package/dist/native/buildIos/index.js +1 -1
- package/dist/native/buildIos/plugins.js +10 -1
- package/dist/native/iosnativeWebView/CoreLogic/Package.swift +36 -0
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Camera/VideoStreamState.swift +1 -1
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Camera/VideoStreamStateMachine.swift +6 -4
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/BootTimingUtility.swift +3 -3
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/FrameworkServerUtils.swift +14 -9
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NetworkMonitor.swift +11 -9
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NotificationHandlerProvider.swift +1 -1
- package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/URLWhitelistManager.swift +7 -7
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/AnyCodableTests.swift +154 -0
- package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/BootTimingUtilityTests.swift +23 -5
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/CatalystConstantsTests.swift +192 -0
- package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/ConfigMappingTests.swift +1 -1
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/FrameworkServerUtilsErrorPathTests.swift +106 -0
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/FrameworkServerUtilsLoopbackTests.swift +243 -0
- package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/FrameworkServerUtilsTests.swift +1 -1
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/NetworkMonitorTests.swift +119 -0
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/NotificationHandlerProviderTests.swift +59 -0
- package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/NotificationHandlerTests.swift +1 -1
- package/dist/native/iosnativeWebView/{iosnativeWebViewTests → CoreLogic/Tests/CatalystCoreLogicTests}/URLWhitelistManagerTests.swift +1 -1
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/VideoStreamStateMachineTests.swift +171 -0
- package/dist/native/iosnativeWebView/CoreLogic/Tests/CatalystCoreLogicTests/VideoStreamStateTests.swift +91 -0
- package/dist/native/iosnativeWebView/Package.swift +10 -9
- package/dist/native/iosnativeWebView/Sources/CatalystNotifications/LocalNotificationHandler.swift +7 -2
- package/dist/native/iosnativeWebView/Sources/CatalystNotifications/NotificationManager.swift +1 -2
- package/dist/native/iosnativeWebView/Sources/CatalystNotifications/PushNotificationHandler.swift +5 -4
- package/dist/native/iosnativeWebView/Sources/Core/Camera/CameraSessionManager.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Camera/HoldController.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Camera/NativeCameraManager.swift +6 -5
- package/dist/native/iosnativeWebView/Sources/Core/Camera/ZoomController.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Plugins/PluginBridge.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Utils/CacheManager.swift +31 -30
- package/dist/native/iosnativeWebView/Sources/Core/Utils/CameraTransportUtils.swift +2 -1
- package/dist/native/iosnativeWebView/Sources/Core/Utils/DeviceInfoUtils.swift +1 -1
- package/dist/native/iosnativeWebView/Sources/Core/Utils/FilePickerHandler.swift +22 -19
- package/dist/native/iosnativeWebView/Sources/Core/Utils/ImageHandler.swift +40 -39
- package/dist/native/iosnativeWebView/Sources/Core/Utils/PerfEventBuffer.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/Utils/ResourceURLProtocol.swift +15 -15
- package/dist/native/iosnativeWebView/Sources/Core/Utils/WebKitConfig.swift +4 -3
- package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeCommandHandler.swift +6 -1
- package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeDelegateHandler.swift +1 -0
- package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeFileHandler.swift +2 -1
- package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeJavaScriptInterface.swift +2 -1
- package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeMessageValidator.swift +3 -5
- package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +20 -13
- package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashView.swift +6 -5
- package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashViewModel.swift +14 -13
- package/dist/native/iosnativeWebView/Sources/Core/WebView/TransitionManager.swift +3 -3
- package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +9 -8
- package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewModel.swift +7 -6
- package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewNavigationDelegate.swift +24 -25
- package/dist/native/iosnativeWebView/iosnativeWebView/AppDelegate.swift +6 -1
- package/dist/native/iosnativeWebView/iosnativeWebView/ContentView.swift +1 -0
- package/dist/native/iosnativeWebView/iosnativeWebView/iosnativeWebViewApp.swift +4 -0
- package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +2 -22
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/BridgeMessageValidatorTests.swift +1 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/CacheManagerTests.swift +1 -0
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/FilePickerHandlerTests.swift +2 -1
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/NativeBridgeTests.swift +15 -9
- package/dist/native/iosnativeWebView/iosnativeWebViewTests/WebViewTests.swift +1 -0
- package/dist/native/setupEmulatorIos.js +2 -2
- package/dist/native/terminalProgress.js +17 -17
- package/dist/router/ClientRouter.d.ts +8 -0
- package/dist/router/ClientRouter.js +13 -11
- package/dist/router/ServerRouter.d.ts +13 -0
- package/dist/router/ServerRouter.js +19 -7
- package/dist/scripts/build.js +14 -2
- package/dist/scripts/loadEnvironmentVariables.js +3 -2
- package/dist/scripts/plugins.js +1 -1
- package/dist/scripts/preServerInit.js +49 -3
- package/dist/scripts/preflight.js +111 -0
- package/dist/scripts/scriptUtils.js +46 -1
- package/dist/scripts/serve.js +7 -3
- package/dist/scripts/start.js +8 -3
- package/dist/server/expressServer.d.ts +1 -0
- package/dist/server/expressServer.js +247 -271
- package/dist/server/manifestCache.d.ts +2 -0
- package/dist/server/manifestCache.js +25 -33
- package/dist/server/renderer/ChunkExtractor.d.ts +44 -0
- package/dist/server/renderer/ChunkExtractor.js +113 -125
- package/dist/server/renderer/document/Body.d.ts +21 -0
- package/dist/server/renderer/document/Body.jsx +45 -45
- package/dist/server/renderer/document/FastRefresh.d.ts +3 -0
- package/dist/server/renderer/document/FastRefresh.jsx +7 -13
- package/dist/server/renderer/document/Head.d.ts +20 -0
- package/dist/server/renderer/document/Head.jsx +32 -32
- package/dist/server/renderer/document/index.d.ts +2 -0
- package/dist/server/renderer/document/index.jsx +2 -2
- package/dist/server/renderer/extract.d.ts +67 -0
- package/dist/server/renderer/extract.js +92 -89
- package/dist/server/renderer/handler.d.ts +2 -0
- package/dist/server/renderer/handler.jsx +401 -404
- package/dist/server/renderer/index.d.ts +2 -0
- package/dist/server/renderer/index.js +5 -8
- package/dist/server/renderer/render.d.ts +35 -0
- package/dist/server/renderer/render.js +25 -32
- package/dist/server/utils/botDetectionMiddleware.d.ts +1 -0
- package/dist/server/utils/botDetectionMiddleware.js +33 -23
- package/dist/server/utils/cjsRequire.d.ts +8 -0
- package/dist/server/utils/cjsRequire.js +2 -2
- package/dist/server/utils/userAgentUtil.d.ts +7 -0
- package/dist/server/utils/userAgentUtil.js +68 -71
- package/dist/server/utils/validator.d.ts +31 -0
- package/dist/server/utils/validator.js +133 -158
- package/dist/vite/inject-cache-key-plugin.js +3 -27
- package/dist/vite/moduleAliases.js +36 -0
- package/dist/vite/node-loader.mjs +2 -29
- package/dist/vite/resolveDevServerConfig.js +4 -1
- package/dist/vite/vite.config.js +2 -29
- package/dist/web-router/components/MetaTag.d.ts +4 -0
- package/dist/web-router/components/MetaTag.jsx +26 -28
- package/dist/web-router/components/MetaTag.test.jsx +100 -0
- package/dist/web-router/components/RouterDataProvider.d.ts +96 -0
- package/dist/web-router/components/RouterDataProvider.jsx +260 -259
- package/dist/web-router/components/RouterDataProvider.server.test.jsx +98 -0
- package/dist/web-router/components/RouterDataProvider.test.jsx +310 -0
- package/dist/web-router/components/Split.d.ts +74 -0
- package/dist/web-router/components/Split.jsx +147 -156
- package/dist/web-router/components/Split.server.test.jsx +52 -0
- package/dist/web-router/components/Split.test.jsx +167 -0
- package/dist/web-router/components/SplitInview.d.ts +22 -0
- package/dist/web-router/components/SplitInview.jsx +78 -89
- package/dist/web-router/components/SplitInview.test.jsx +112 -0
- package/dist/web-router/components/SsrRequestContext.d.ts +20 -0
- package/dist/web-router/components/SsrRequestContext.jsx +17 -7
- package/dist/web-router/components/SsrRequestContext.test.jsx +53 -0
- package/dist/web-router/context.d.ts +15 -0
- package/dist/web-router/context.jsx +5 -5
- package/dist/web-router/context.test.jsx +10 -0
- package/dist/web-router/utils/metaDataUtils.d.ts +24 -0
- package/dist/web-router/utils/metaDataUtils.jsx +86 -86
- package/dist/web-router/utils/metaDataUtils.test.jsx +188 -0
- package/dist/web-router/vitest.setup.js +12 -0
- package/mcp_v2/knowledge-base.json +115 -17
- package/mcp_v2/mcp.js +141 -3
- package/mcp_v2/package-lock.json +2031 -0
- package/mcp_v2/package.json +13 -2
- package/mcp_v2/scripts/copyErrorsIndex.cjs +34 -0
- package/mcp_v2/test/errors.test.ts +123 -0
- package/mcp_v2/test/github.test.ts +177 -0
- package/mcp_v2/tools/errors.d.ts +20 -0
- package/mcp_v2/tools/errors.js +63 -0
- package/mcp_v2/tools/github.d.ts +41 -0
- package/mcp_v2/tools/github.js +231 -0
- package/mcp_v2/vitest.config.mjs +22 -0
- package/package.json +60 -11
- package/test/errors/docsDrift.test.ts +113 -0
- package/test/errors/index.test.ts +200 -0
- package/test/errors/registry.test.ts +108 -0
- package/test/scripts/preflight.test.ts +118 -0
- package/test/server/ChunkExtractor.test.ts +97 -0
- package/test/server/extract.test.ts +128 -0
- package/test/server/fixtures/template/server/document.jsx +19 -0
- package/test/server/fixtures/template/server/index.js +10 -0
- package/test/server/fixtures/template/src/js/containers/App/index.jsx +33 -0
- package/test/server/fixtures/template/src/js/routes/index.jsx +72 -0
- package/test/server/fixtures/template/src/js/routes/utils.jsx +39 -0
- package/test/server/fixtures/template/src/js/store/index.js +19 -0
- package/test/server/handler.assets.test.ts +330 -0
- package/test/server/handler.test.ts +208 -0
- package/test/server/manifestCache.test.ts +71 -0
- package/test/server/render.test.ts +71 -0
- package/test/server/scriptUtils.test.ts +103 -0
- package/test/server/userAgentUtil.test.ts +48 -0
- package/test/server/validator.test.ts +225 -0
- package/test/vite/resolveDevServerConfig.test.js +4 -1
- package/tsconfig.test.json +23 -0
- package/vitest.config.ts +93 -0
- package/dist/caching.js +0 -1
- package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/DeviceInfoUtilsTest.kt +0 -187
- package/dist/native/bridge/standardizedHooks.js +0 -611
- package/dist/router.js +0 -1
- package/dist/scripts/validator.js +0 -149
- package/dist/web-router/hooks.jsx +0 -72
- package/dist/web-router/types/components/MetaTag.d.ts +0 -2
- package/dist/web-router/types/components/RouterDataProvider.d.ts +0 -95
- package/dist/web-router/types/context.d.ts +0 -14
- package/dist/web-router/types/hooks.d.ts +0 -1
- package/dist/web-router/types/index.d.ts +0 -3
- package/dist/web-router/types/utils/metaDataUtils.d.ts +0 -40
- /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Constants/CatalystConstants.swift +0 -0
- /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Constants/ConfigConstants.swift +0 -0
- /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Notifications/NotificationModels.swift +0 -0
- /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Protocols/NotificationHandlerProtocol.swift +0 -0
- /package/dist/native/iosnativeWebView/{Sources/Core → CoreLogic/Sources/CatalystCoreLogic}/Utils/NullNotificationHandler.swift +0 -0
|
@@ -1,164 +1,139 @@
|
|
|
1
|
-
import pc from "
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
142
|
-
*
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
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
|
|
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
|
|
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)
|
|
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,
|
package/dist/vite/vite.config.js
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
};
|