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
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
var _ansis = _interopRequireDefault(require("ansis"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
class TerminalProgress {
|
|
10
10
|
constructor(steps, title = "Setup Progress", options = {}) {
|
|
11
11
|
this.steps = new Map(Object.entries(steps).map(([id, description]) => [id, {
|
|
@@ -44,7 +44,7 @@ class TerminalProgress {
|
|
|
44
44
|
console.log("\n".repeat(this.options.titlePaddingTop));
|
|
45
45
|
|
|
46
46
|
// Print the title
|
|
47
|
-
console.log(`${
|
|
47
|
+
console.log(`${_ansis.default.cyan(_ansis.default.bold(title))}`);
|
|
48
48
|
|
|
49
49
|
// Process and print each line of content
|
|
50
50
|
for (const line of content) {
|
|
@@ -58,7 +58,7 @@ class TerminalProgress {
|
|
|
58
58
|
color = "white"
|
|
59
59
|
} = line;
|
|
60
60
|
const indentation = " ".repeat(this.options.stepPaddingLeft + indent * 3);
|
|
61
|
-
const coloredText =
|
|
61
|
+
const coloredText = _ansis.default[color] ? _ansis.default[color](text) : text;
|
|
62
62
|
console.log(`${indentation}${prefix}${coloredText}`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -103,13 +103,13 @@ class TerminalProgress {
|
|
|
103
103
|
const icon = TerminalProgress.icons[step.status] || TerminalProgress.icons.pending;
|
|
104
104
|
switch (step.status) {
|
|
105
105
|
case "completed":
|
|
106
|
-
return
|
|
106
|
+
return _ansis.default.green(icon);
|
|
107
107
|
case "error":
|
|
108
|
-
return
|
|
108
|
+
return _ansis.default.red(icon);
|
|
109
109
|
case "running":
|
|
110
|
-
return
|
|
110
|
+
return _ansis.default.blue(icon);
|
|
111
111
|
default:
|
|
112
|
-
return
|
|
112
|
+
return _ansis.default.gray(icon);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
clearLines() {
|
|
@@ -126,23 +126,23 @@ class TerminalProgress {
|
|
|
126
126
|
switch (type) {
|
|
127
127
|
case "success":
|
|
128
128
|
icon = TerminalProgress.icons.completed;
|
|
129
|
-
color =
|
|
129
|
+
color = _ansis.default.green;
|
|
130
130
|
break;
|
|
131
131
|
case "error":
|
|
132
132
|
icon = TerminalProgress.icons.error;
|
|
133
|
-
color =
|
|
133
|
+
color = _ansis.default.red;
|
|
134
134
|
break;
|
|
135
135
|
case "warning":
|
|
136
136
|
icon = TerminalProgress.icons.warning;
|
|
137
|
-
color =
|
|
137
|
+
color = _ansis.default.yellow;
|
|
138
138
|
break;
|
|
139
139
|
case "prompt":
|
|
140
140
|
icon = TerminalProgress.icons.prompt;
|
|
141
|
-
color =
|
|
141
|
+
color = _ansis.default.yellow;
|
|
142
142
|
break;
|
|
143
143
|
default:
|
|
144
144
|
icon = TerminalProgress.icons.info;
|
|
145
|
-
color =
|
|
145
|
+
color = _ansis.default.blue;
|
|
146
146
|
}
|
|
147
147
|
console.log(`${" ".repeat(this.options.stepPaddingLeft)}${color(icon)} ${message}`);
|
|
148
148
|
this.resume();
|
|
@@ -158,8 +158,8 @@ class TerminalProgress {
|
|
|
158
158
|
currentLineCount += this.options.titlePaddingTop;
|
|
159
159
|
|
|
160
160
|
// Render title
|
|
161
|
-
output += `${
|
|
162
|
-
output += `${
|
|
161
|
+
output += `${_ansis.default.bold(_ansis.default.cyan(this.title))}\n`;
|
|
162
|
+
output += `${_ansis.default.gray("─".repeat(this.title.length))}\n`;
|
|
163
163
|
currentLineCount += 2;
|
|
164
164
|
|
|
165
165
|
// Add padding after title
|
|
@@ -169,13 +169,13 @@ class TerminalProgress {
|
|
|
169
169
|
// Render steps
|
|
170
170
|
for (const step of this.steps.values()) {
|
|
171
171
|
const icon = this.getStepIcon(step);
|
|
172
|
-
const description = step.status === "error" ?
|
|
172
|
+
const description = step.status === "error" ? _ansis.default.red(step.description) : step.status === "completed" ? _ansis.default.green(step.description) : step.status === "running" ? _ansis.default.blue(step.description) : _ansis.default.gray(step.description);
|
|
173
173
|
const stepPadding = " ".repeat(this.options.stepPaddingLeft);
|
|
174
174
|
output += `${stepPadding}${icon} ${description}\n`;
|
|
175
175
|
currentLineCount++;
|
|
176
176
|
if (step.status === "error" && step.error) {
|
|
177
177
|
const errorPadding = " ".repeat(this.options.errorPaddingLeft);
|
|
178
|
-
output += `${errorPadding}${
|
|
178
|
+
output += `${errorPadding}${_ansis.default.red("↳")} ${_ansis.default.red(step.error)}\n`;
|
|
179
179
|
currentLineCount++;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { createBrowserRouter } from "
|
|
2
|
-
import { preparedRoutes } from "@catalyst/template/src/js/routes/utils"
|
|
3
|
-
import { registerCatalystServiceWorker } from "../offline/registerServiceWorker.js"
|
|
4
|
-
|
|
5
|
-
registerCatalystServiceWorker()
|
|
1
|
+
import { createBrowserRouter } from "react-router";
|
|
2
|
+
import { preparedRoutes } from "@catalyst/template/src/js/routes/utils";
|
|
3
|
+
import { registerCatalystServiceWorker } from "../offline/registerServiceWorker.js";
|
|
4
|
+
registerCatalystServiceWorker();
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* @returns returns browsers routers (client routes)
|
|
9
8
|
*/
|
|
10
|
-
const clientRouter = ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const clientRouter = ({
|
|
10
|
+
routerInitialState
|
|
11
|
+
}) => {
|
|
12
|
+
const browserRouter = createBrowserRouter(preparedRoutes({
|
|
13
|
+
routerInitialState
|
|
14
|
+
}));
|
|
15
|
+
return browserRouter;
|
|
16
|
+
};
|
|
17
|
+
export default clientRouter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Store } from "redux";
|
|
2
|
+
/**
|
|
3
|
+
* Redux data handed to the server router by the SSR handler. `store` is the
|
|
4
|
+
* app's redux store (created by the app's `createStore`); `intialData` is the
|
|
5
|
+
* router initial state hydrated onto the client. The spelling of `intialData`
|
|
6
|
+
* is part of the frozen internal shape and is deliberately preserved.
|
|
7
|
+
*/
|
|
8
|
+
export interface ServerRouterProps {
|
|
9
|
+
store?: Store;
|
|
10
|
+
intialData?: any;
|
|
11
|
+
}
|
|
12
|
+
declare const ServerRouter: (reduxData: ServerRouterProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export default ServerRouter;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import { useRoutes } from "
|
|
2
|
-
import { preparedRoutes } from "@catalyst/template/src/js/routes/utils"
|
|
1
|
+
import { useRoutes } from "react-router";
|
|
2
|
+
import { preparedRoutes } from "@catalyst/template/src/js/routes/utils";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Redux data handed to the server router by the SSR handler. `store` is the
|
|
6
|
+
* app's redux store (created by the app's `createStore`); `intialData` is the
|
|
7
|
+
* router initial state hydrated onto the client. The spelling of `intialData`
|
|
8
|
+
* is part of the frozen internal shape and is deliberately preserved.
|
|
9
|
+
*/
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const ServerRouter = reduxData => {
|
|
12
|
+
const {
|
|
13
|
+
store,
|
|
14
|
+
intialData
|
|
15
|
+
} = reduxData;
|
|
16
|
+
return useRoutes(preparedRoutes({
|
|
17
|
+
store,
|
|
18
|
+
routerInitialState: intialData
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
export default ServerRouter;
|
package/dist/scripts/build.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import { spawn } from "child_process"
|
|
3
|
-
import { arrayToObject } from "./scriptUtils.js"
|
|
3
|
+
import { arrayToObject, resolveOutputMode, getDebugEnvInfo } from "./scriptUtils.js"
|
|
4
4
|
import { fileURLToPath } from "url"
|
|
5
5
|
import { dirname } from "path"
|
|
6
6
|
import { readFileSync, existsSync, rmSync } from "fs"
|
|
7
7
|
import { createRequire } from "module"
|
|
8
|
+
import { wrapForeignError, formatError } from "../errors/index.js"
|
|
9
|
+
import { runStaticPreflightOrExit } from "./preflight.js"
|
|
10
|
+
|
|
11
|
+
// Fail fast on a misconfigured app (missing/invalid config.json, package.json,
|
|
12
|
+
// or moduleAliases) with a coded, doc-linked error — must run before the raw
|
|
13
|
+
// config.json read below, which would otherwise crash with a bare
|
|
14
|
+
// ENOENT/SyntaxError on a broken config.
|
|
15
|
+
runStaticPreflightOrExit()
|
|
8
16
|
|
|
9
17
|
const __filename = fileURLToPath(import.meta.url)
|
|
10
18
|
const __dirname = dirname(__filename)
|
|
@@ -42,6 +50,7 @@ function runBuildStep(args, options) {
|
|
|
42
50
|
async function build() {
|
|
43
51
|
const commandLineArguments = process.argv.slice(2)
|
|
44
52
|
const argumentsObject = arrayToObject(commandLineArguments)
|
|
53
|
+
const outputMode = resolveOutputMode(process.argv)
|
|
45
54
|
const dirname = path.resolve(__dirname, "../../")
|
|
46
55
|
|
|
47
56
|
// Read package.json
|
|
@@ -63,6 +72,7 @@ async function build() {
|
|
|
63
72
|
VITE_BUILD_MODE: "true",
|
|
64
73
|
APPLICATION: name || "catalyst_app",
|
|
65
74
|
NODE_OPTIONS: `--loader ${loaderPath}`,
|
|
75
|
+
CATALYST_OUTPUT_MODE: outputMode,
|
|
66
76
|
...argumentsObject,
|
|
67
77
|
filterKeys: JSON.stringify([
|
|
68
78
|
"src_path",
|
|
@@ -93,8 +103,10 @@ async function build() {
|
|
|
93
103
|
env: { ...baseEnv, CATALYST_VITE_CACHE_ID: "client" },
|
|
94
104
|
}),
|
|
95
105
|
])
|
|
96
|
-
} catch {
|
|
106
|
+
} catch (err) {
|
|
97
107
|
console.error("❌ Build failed!")
|
|
108
|
+
const debugEnv = outputMode === "debug" ? getDebugEnvInfo() : undefined
|
|
109
|
+
console.error(formatError(wrapForeignError("BUNDLE", err), outputMode, debugEnv))
|
|
98
110
|
process.exit(1)
|
|
99
111
|
}
|
|
100
112
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
|
|
4
|
-
const appConfigPath = path.resolve(process.env.src_path, "config/config.json")
|
|
5
|
-
// import { validateConfigFile } from "../scripts/validator"
|
|
6
4
|
/**
|
|
7
5
|
* @description stores all config.json key value into process.env before server starts.
|
|
8
6
|
*/
|
|
9
7
|
const loadEnvironmentVariables = async () => {
|
|
10
8
|
try {
|
|
9
|
+
// Resolved at call time, not import time, so preServerInit.js can report a
|
|
10
|
+
// missing src_path before any path is built from it.
|
|
11
|
+
const appConfigPath = path.resolve(process.env.src_path, "config/config.json")
|
|
11
12
|
const filterKeys = JSON.parse(process.env.filterKeys)
|
|
12
13
|
const configContent = fs.readFileSync(appConfigPath, "utf8")
|
|
13
14
|
const appConfig = JSON.parse(configContent)
|
package/dist/scripts/plugins.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from "node:path"
|
|
|
3
3
|
import readline from "node:readline"
|
|
4
4
|
import { createRequire } from "node:module"
|
|
5
5
|
import { fileURLToPath } from "node:url"
|
|
6
|
-
import { bold, cyan, dim, green, red, yellow } from "
|
|
6
|
+
import { bold, cyan, dim, green, red, yellow } from "ansis"
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url)
|
|
9
9
|
const { discoverInternalPlugins, resolveInternalPluginsRoot } = require("../native/internalPluginUtils.js")
|
|
@@ -1,13 +1,59 @@
|
|
|
1
1
|
import path from "path"
|
|
2
|
+
import { createRequire } from "module"
|
|
2
3
|
import loadEnvironmentVariables from "./loadEnvironmentVariables.js"
|
|
3
|
-
import {
|
|
4
|
+
import { validatePreInitServer, handleError, safeCallNamed } from "../server/utils/validator.js"
|
|
5
|
+
|
|
6
|
+
// src_path is the application root, set by the CLI when it spawns this process.
|
|
7
|
+
// Without it every path below would be resolved against undefined.
|
|
8
|
+
const appRoot = process.env.src_path
|
|
9
|
+
if (!appRoot) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
"catalyst-core: process.env.src_path is not set, so the application root cannot be resolved. " +
|
|
12
|
+
"Start the server with `catalyst serve` or `catalyst start` from the application root."
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// react-router is a peer dependency: fail loudly at startup rather than on a
|
|
17
|
+
// missing export deep inside a render. Resolve from the app root, not from
|
|
18
|
+
// catalyst-core's own tree — the app's copy is the one vite and SSR load.
|
|
19
|
+
const REQUIRED_REACT_ROUTER = "^7.18.2"
|
|
20
|
+
const appRequire = createRequire(path.join(appRoot, "package.json"))
|
|
21
|
+
let reactRouterVersion
|
|
22
|
+
try {
|
|
23
|
+
reactRouterVersion = appRequire("react-router/package.json").version
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`catalyst-core requires react-router ${REQUIRED_REACT_ROUTER} as a peer dependency, but it is not installed. ` +
|
|
27
|
+
`Install it: npm install react-router@${REQUIRED_REACT_ROUTER}`
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
const [major, minor, patch] = reactRouterVersion.split("-")[0].split(".").map(Number)
|
|
31
|
+
const isValid =
|
|
32
|
+
[major, minor, patch].every(Number.isFinite) &&
|
|
33
|
+
major === 7 &&
|
|
34
|
+
(minor > 18 || (minor === 18 && patch >= 2))
|
|
35
|
+
if (!isValid) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`catalyst-core requires react-router ${REQUIRED_REACT_ROUTER}, but found ${reactRouterVersion}. ` +
|
|
38
|
+
`Install a compatible version: npm install react-router@${REQUIRED_REACT_ROUTER}`
|
|
39
|
+
)
|
|
40
|
+
}
|
|
4
41
|
|
|
5
42
|
let preServerInit
|
|
6
43
|
try {
|
|
7
|
-
const hooks = await import(path.join(
|
|
44
|
+
const hooks = await import(path.join(appRoot, "server/index.js"))
|
|
8
45
|
preServerInit = hooks.preServerInit
|
|
9
46
|
} catch {
|
|
10
47
|
// No hooks file — preServerInit remains undefined
|
|
11
48
|
}
|
|
12
49
|
await loadEnvironmentVariables()
|
|
13
|
-
|
|
50
|
+
|
|
51
|
+
// preServerInit is an OPTIONAL hook — an app with no server/index.js is
|
|
52
|
+
// valid, so PREFLIGHT-010 (missing) is deliberately not surfaced here. But
|
|
53
|
+
// if the app DID export something under that name and it isn't callable,
|
|
54
|
+
// that's a real mistake worth flagging (PREFLIGHT-011).
|
|
55
|
+
if (preServerInit !== undefined) {
|
|
56
|
+
const preInitErr = validatePreInitServer(preServerInit)
|
|
57
|
+
if (preInitErr) handleError(preInitErr)
|
|
58
|
+
}
|
|
59
|
+
await safeCallNamed("preServerInit", preServerInit)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readFileSync } from "fs"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import {
|
|
4
|
+
validateConfigFile,
|
|
5
|
+
validatePackageJson,
|
|
6
|
+
validateModuleAlias,
|
|
7
|
+
} from "../server/utils/validator.js"
|
|
8
|
+
import { formatError, createError, ERROR_CODES } from "../errors/index.js"
|
|
9
|
+
import { resolveOutputMode } from "./scriptUtils.js"
|
|
10
|
+
|
|
11
|
+
// Static preflight — the file-based checks a developer's misconfiguration
|
|
12
|
+
// would trip. Runs in the parent CLI process (start.js / serve.js / build.js)
|
|
13
|
+
// BEFORE the server is spawned, so a bad config.json / package.json fails
|
|
14
|
+
// fast with a coded, doc-linked error instead of a raw ENOENT or SyntaxError
|
|
15
|
+
// deep in the boot sequence.
|
|
16
|
+
//
|
|
17
|
+
// The in-server hook validators (middleware / getRoutes / configureStore /
|
|
18
|
+
// preInitServer / reducer / customDocument) are NOT run here — those need the
|
|
19
|
+
// app's modules loaded, so they stay at their call sites in expressServer.js
|
|
20
|
+
// and handler.jsx, where they log-and-continue.
|
|
21
|
+
//
|
|
22
|
+
// Behaviour: collect EVERY failure, print them all, then throw so the caller
|
|
23
|
+
// exits non-zero. The caller is expected to catch and `process.exit(1)` —
|
|
24
|
+
// see runStaticPreflightOrExit below.
|
|
25
|
+
|
|
26
|
+
function readJson(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
return { value: JSON.parse(readFileSync(filePath, "utf8")), error: null }
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return { value: null, error: e }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run the static preflight checks against an app directory.
|
|
36
|
+
* @param {string} [appDir] - the consumer app root. Defaults to the current
|
|
37
|
+
* working directory. `process.env.PWD` is preferred when set (it survives a
|
|
38
|
+
* `cd` in the invoking shell script), but it is not exported by every shell
|
|
39
|
+
* / CI runner, so `process.cwd()` is the fallback — never `undefined`, which
|
|
40
|
+
* would make the `path.join` calls below throw.
|
|
41
|
+
* @returns {import("../errors/index.js").CatalystError[]} all failures (empty = passed)
|
|
42
|
+
*/
|
|
43
|
+
export function runStaticPreflight(appDir = process.env.PWD || process.cwd()) {
|
|
44
|
+
const failures = []
|
|
45
|
+
|
|
46
|
+
// config/config.json
|
|
47
|
+
const cfgPath = path.join(appDir, "config", "config.json")
|
|
48
|
+
const cfg = readJson(cfgPath)
|
|
49
|
+
if (cfg.error) {
|
|
50
|
+
failures.push(
|
|
51
|
+
createError(ERROR_CODES.PREFLIGHT_CONFIG_MISSING, {
|
|
52
|
+
details:
|
|
53
|
+
cfg.error.code === "ENOENT"
|
|
54
|
+
? `config/config.json not found at ${cfgPath}`
|
|
55
|
+
: `config/config.json could not be parsed: ${cfg.error.message}`,
|
|
56
|
+
})
|
|
57
|
+
)
|
|
58
|
+
} else {
|
|
59
|
+
const err = validateConfigFile(cfg.value)
|
|
60
|
+
if (err) failures.push(err)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// package.json (+ its moduleAliases)
|
|
64
|
+
const pkgPath = path.join(appDir, "package.json")
|
|
65
|
+
const pkg = readJson(pkgPath)
|
|
66
|
+
if (pkg.error) {
|
|
67
|
+
failures.push(
|
|
68
|
+
createError(
|
|
69
|
+
pkg.error.code === "ENOENT"
|
|
70
|
+
? ERROR_CODES.PREFLIGHT_PACKAGE_JSON_MISSING
|
|
71
|
+
: ERROR_CODES.PREFLIGHT_PACKAGE_JSON_INVALID,
|
|
72
|
+
{
|
|
73
|
+
details:
|
|
74
|
+
pkg.error.code === "ENOENT"
|
|
75
|
+
? `package.json not found at ${pkgPath} — run this command from the project root`
|
|
76
|
+
: `package.json could not be parsed: ${pkg.error.message}`,
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
} else {
|
|
81
|
+
const pkgErr = validatePackageJson(pkg.value)
|
|
82
|
+
if (pkgErr) failures.push(pkgErr)
|
|
83
|
+
|
|
84
|
+
const aliases = pkg.value._moduleAliases ?? pkg.value.moduleAliases
|
|
85
|
+
const aliasErr = validateModuleAlias(aliases)
|
|
86
|
+
if (aliasErr) failures.push(aliasErr)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return failures
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Run static preflight and, if anything failed, print every error in the
|
|
94
|
+
* caller's output mode and exit the process non-zero. Call this at the top
|
|
95
|
+
* of a CLI entry script (start / serve / build).
|
|
96
|
+
* @param {string} [appDir]
|
|
97
|
+
*/
|
|
98
|
+
export function runStaticPreflightOrExit(appDir = process.env.PWD || process.cwd()) {
|
|
99
|
+
const mode = resolveOutputMode(process.argv)
|
|
100
|
+
const failures = runStaticPreflight(appDir)
|
|
101
|
+
if (failures.length === 0) return
|
|
102
|
+
|
|
103
|
+
for (const err of failures) {
|
|
104
|
+
console.error(formatError(err, mode))
|
|
105
|
+
}
|
|
106
|
+
console.error(
|
|
107
|
+
`\nPreflight failed with ${failures.length} error${failures.length === 1 ? "" : "s"}. ` +
|
|
108
|
+
`Fix the above and re-run.`
|
|
109
|
+
)
|
|
110
|
+
process.exit(1)
|
|
111
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import fs from "fs"
|
|
2
2
|
import path from "path"
|
|
3
|
+
import { fileURLToPath } from "url"
|
|
3
4
|
import util from "node:util"
|
|
4
|
-
import pkg from "
|
|
5
|
+
import pkg from "ansis"
|
|
5
6
|
const { gray, cyan } = pkg
|
|
6
7
|
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
let cachedCatalystCoreVersion
|
|
10
|
+
|
|
7
11
|
// Function to get file size synchronously
|
|
8
12
|
function getFileSizeSync(filePath) {
|
|
9
13
|
try {
|
|
@@ -53,3 +57,44 @@ export function arrayToObject(array) {
|
|
|
53
57
|
})
|
|
54
58
|
return obj
|
|
55
59
|
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the output mode for error formatting from a bare boolean CLI flag
|
|
63
|
+
* (--debug/--verbose, matching the --inspect convention already used by
|
|
64
|
+
* serve.js — not arrayToObject, which requires --key=value and silently
|
|
65
|
+
* drops valueless flags) or an inherited CATALYST_OUTPUT_MODE env var, for
|
|
66
|
+
* scripts spawned as a child process (see serve.js/start.js forwarding it
|
|
67
|
+
* to expressServer.js). An explicit flag on argv wins over an inherited env
|
|
68
|
+
* value, so e.g. `catalyst serve --debug` overrides a parent that set
|
|
69
|
+
* CATALYST_OUTPUT_MODE=verbose.
|
|
70
|
+
*/
|
|
71
|
+
export function resolveOutputMode(argv = process.argv, env = process.env) {
|
|
72
|
+
if (argv.includes("--debug")) return "debug"
|
|
73
|
+
if (argv.includes("--verbose")) return "verbose"
|
|
74
|
+
if (env.CATALYST_OUTPUT_MODE === "debug" || env.CATALYST_OUTPUT_MODE === "verbose") {
|
|
75
|
+
return env.CATALYST_OUTPUT_MODE
|
|
76
|
+
}
|
|
77
|
+
return "default"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Environment info for debug-mode error output: catalyst-core's own
|
|
82
|
+
* installed version (read from this package's own package.json, not the
|
|
83
|
+
* consuming app's — so it reflects what's actually running, not just what
|
|
84
|
+
* the app's package.json range says), Node version, and platform.
|
|
85
|
+
*/
|
|
86
|
+
export function getDebugEnvInfo() {
|
|
87
|
+
if (cachedCatalystCoreVersion === undefined) {
|
|
88
|
+
try {
|
|
89
|
+
const pkgPath = path.resolve(__dirname, "../../package.json")
|
|
90
|
+
cachedCatalystCoreVersion = JSON.parse(fs.readFileSync(pkgPath, "utf-8")).version
|
|
91
|
+
} catch {
|
|
92
|
+
cachedCatalystCoreVersion = "unknown"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
node: process.version,
|
|
97
|
+
platform: process.platform,
|
|
98
|
+
catalystCore: cachedCatalystCoreVersion,
|
|
99
|
+
}
|
|
100
|
+
}
|
package/dist/scripts/serve.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import { spawnSync } from "child_process"
|
|
3
|
-
import { arrayToObject } from "./scriptUtils.js"
|
|
3
|
+
import { arrayToObject, resolveOutputMode } from "./scriptUtils.js"
|
|
4
|
+
import { runStaticPreflightOrExit } from "./preflight.js"
|
|
4
5
|
import { fileURLToPath } from "url"
|
|
5
6
|
import { dirname } from "path"
|
|
6
7
|
import { readFileSync } from "fs"
|
|
@@ -14,8 +15,12 @@ const preInitPath = path.resolve(__dirname, "preServerInit.js")
|
|
|
14
15
|
* @description - starts the application in production mode
|
|
15
16
|
*/
|
|
16
17
|
function startProd() {
|
|
18
|
+
// Fail fast on a misconfigured app before spawning the production server.
|
|
19
|
+
runStaticPreflightOrExit()
|
|
20
|
+
|
|
17
21
|
const commandLineArguments = process.argv.slice(2)
|
|
18
22
|
const argumentsObject = arrayToObject(commandLineArguments)
|
|
23
|
+
const outputMode = resolveOutputMode(process.argv)
|
|
19
24
|
const dirname = path.resolve(__dirname, "../../")
|
|
20
25
|
|
|
21
26
|
// Read package.json
|
|
@@ -35,13 +40,12 @@ function startProd() {
|
|
|
35
40
|
...process.env,
|
|
36
41
|
src_path: process.env.PWD,
|
|
37
42
|
NODE_ENV: "production",
|
|
38
|
-
IS_DEV_COMMAND: false,
|
|
39
43
|
APPLICATION: name || "catalyst_app",
|
|
44
|
+
CATALYST_OUTPUT_MODE: outputMode,
|
|
40
45
|
...argumentsObject,
|
|
41
46
|
filterKeys: JSON.stringify([
|
|
42
47
|
"src_path",
|
|
43
48
|
"NODE_ENV",
|
|
44
|
-
"IS_DEV_COMMAND",
|
|
45
49
|
"APPLICATION",
|
|
46
50
|
...Object.keys(argumentsObject),
|
|
47
51
|
]),
|
package/dist/scripts/start.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import { spawnSync } from "child_process"
|
|
3
|
-
import { arrayToObject } from "./scriptUtils.js"
|
|
3
|
+
import { arrayToObject, resolveOutputMode } from "./scriptUtils.js"
|
|
4
|
+
import { runStaticPreflightOrExit } from "./preflight.js"
|
|
4
5
|
import { fileURLToPath } from "url"
|
|
5
6
|
import { dirname } from "path"
|
|
6
7
|
import { readFileSync } from "fs"
|
|
@@ -14,8 +15,13 @@ const preInitPath = path.resolve(__dirname, "preServerInit.js")
|
|
|
14
15
|
* @description - starts webpack dev server and node server.
|
|
15
16
|
*/
|
|
16
17
|
function start() {
|
|
18
|
+
// Fail fast on a misconfigured app (missing/invalid config.json, package.json,
|
|
19
|
+
// or moduleAliases) with a coded, doc-linked error before spawning the server.
|
|
20
|
+
runStaticPreflightOrExit()
|
|
21
|
+
|
|
17
22
|
const commandLineArguments = process.argv.slice(2)
|
|
18
23
|
const argumentsObject = arrayToObject(commandLineArguments)
|
|
24
|
+
const outputMode = resolveOutputMode(process.argv)
|
|
19
25
|
const dirname = path.resolve(__dirname, "../../")
|
|
20
26
|
|
|
21
27
|
// Read package.json
|
|
@@ -29,13 +35,12 @@ function start() {
|
|
|
29
35
|
...process.env,
|
|
30
36
|
src_path: process.env.PWD,
|
|
31
37
|
NODE_ENV: "development",
|
|
32
|
-
IS_DEV_COMMAND: false,
|
|
33
38
|
APPLICATION: name || "catalyst_app",
|
|
39
|
+
CATALYST_OUTPUT_MODE: outputMode,
|
|
34
40
|
...argumentsObject,
|
|
35
41
|
filterKeys: JSON.stringify([
|
|
36
42
|
"src_path",
|
|
37
43
|
"NODE_ENV",
|
|
38
|
-
"IS_DEV_COMMAND",
|
|
39
44
|
"APPLICATION",
|
|
40
45
|
...Object.keys(argumentsObject),
|
|
41
46
|
]),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|