catalyst-core 0.3.0-beta.4 → 0.3.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +80 -0
- 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 +14 -7
- 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 -1
- package/dist/scripts/start.js +8 -1
- 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 +33 -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 +13 -31
- 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 +52 -8
- package/mcp_v2/mcp.js +140 -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 +121 -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 +331 -0
- package/test/server/handler.test.ts +210 -0
- package/test/server/manifestCache.test.ts +71 -0
- package/test/server/render.test.ts +90 -0
- package/test/server/scriptUtils.test.ts +103 -0
- package/test/server/userAgentUtil.test.ts +48 -0
- package/test/server/validator.test.ts +228 -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 -24
- /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,304 +1,280 @@
|
|
|
1
|
-
import path from "path"
|
|
2
|
-
import express from "express"
|
|
3
|
-
import bodyParser from "body-parser"
|
|
4
|
-
import compression from "compression"
|
|
5
|
-
import cookieParser from "cookie-parser"
|
|
6
|
-
import expressStaticGzip from "express-static-gzip"
|
|
7
|
-
import { createServer as createViteServer } from "vite"
|
|
8
|
-
import util from "node:util"
|
|
9
|
-
import pc from "
|
|
10
|
-
import fs from "fs"
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
|
|
1
|
+
import path from "path";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import bodyParser from "body-parser";
|
|
4
|
+
import compression from "compression";
|
|
5
|
+
import cookieParser from "cookie-parser";
|
|
6
|
+
import expressStaticGzip from "express-static-gzip";
|
|
7
|
+
import { createServer as createViteServer } from "vite";
|
|
8
|
+
import util from "node:util";
|
|
9
|
+
import pc from "ansis";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
const {
|
|
12
|
+
cyan,
|
|
13
|
+
yellow,
|
|
14
|
+
green
|
|
15
|
+
} = pc;
|
|
16
|
+
import { toMountPathPrefix } from "../vite/resolveDevServerConfig.js";
|
|
17
|
+
import { validateMiddleware, handleError, safeCall } from "./utils/validator.js";
|
|
18
|
+
import { botDetectionMiddleware } from "./utils/botDetectionMiddleware.js";
|
|
19
|
+
import { cjsRequire } from "./utils/cjsRequire.js";
|
|
20
|
+
const {
|
|
21
|
+
addMiddlewares
|
|
22
|
+
} = await import(path.join(process.env.src_path, "server/server.js"));
|
|
18
23
|
|
|
19
24
|
// Mount AI route if catalyst-ai is installed
|
|
20
25
|
function mountAIRouter(app) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return
|
|
26
|
+
let aiPackagePath;
|
|
27
|
+
try {
|
|
28
|
+
aiPackagePath = cjsRequire.resolve("catalyst-ai/route", {
|
|
29
|
+
paths: [process.env.src_path || process.cwd()]
|
|
30
|
+
});
|
|
31
|
+
} catch (resolveErr) {
|
|
32
|
+
if (resolveErr.code !== "MODULE_NOT_FOUND") {
|
|
33
|
+
console.error("[catalyst-core/ai] Unexpected error resolving catalyst-ai:", resolveErr);
|
|
34
|
+
} else {
|
|
35
|
+
console.debug("[catalyst-core/ai] catalyst-ai not installed — AI routes unavailable");
|
|
33
36
|
}
|
|
34
|
-
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const aiRouter = cjsRequire(aiPackagePath);
|
|
41
|
+
let aiConfig = {};
|
|
35
42
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
} catch (e) {
|
|
46
|
-
console.warn(`[catalyst-core/ai] Invalid AI_CONFIG JSON, ignoring: ${e.message}`)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (aiConfig.enabled === false) {
|
|
50
|
-
console.log("[catalyst-core/ai] AI_CONFIG.enabled is false, skipping AI router")
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const aiBasePath = aiConfig.basePath || "/ai"
|
|
55
|
-
console.log(`[catalyst-core/ai] mounting AI router at ${aiBasePath}`)
|
|
56
|
-
app.use(aiBasePath, aiRouter)
|
|
57
|
-
} catch (mountErr) {
|
|
58
|
-
console.error("[catalyst-core/ai] Failed to mount AI router:", mountErr)
|
|
43
|
+
const parsedConfig = JSON.parse(process.env.AI_CONFIG || "{}");
|
|
44
|
+
if (parsedConfig && typeof parsedConfig === "object" && !Array.isArray(parsedConfig)) {
|
|
45
|
+
aiConfig = parsedConfig;
|
|
46
|
+
} else {
|
|
47
|
+
console.warn("[catalyst-core/ai] AI_CONFIG must be a JSON object, ignoring it");
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.warn(`[catalyst-core/ai] Invalid AI_CONFIG JSON, ignoring: ${e.message}`);
|
|
59
51
|
}
|
|
52
|
+
if (aiConfig.enabled === false) {
|
|
53
|
+
console.log("[catalyst-core/ai] AI_CONFIG.enabled is false, skipping AI router");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const aiBasePath = aiConfig.basePath || "/ai";
|
|
57
|
+
console.log(`[catalyst-core/ai] mounting AI router at ${aiBasePath}`);
|
|
58
|
+
app.use(aiBasePath, aiRouter);
|
|
59
|
+
} catch (mountErr) {
|
|
60
|
+
console.error("[catalyst-core/ai] Failed to mount AI router:", mountErr);
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
// OpenTelemetry is opt-in (OTEL_ENABLE) — mirrors server/renderer/handler.jsx.
|
|
63
65
|
// Passthrough no-op middleware when disabled or packages aren't installed.
|
|
64
|
-
let responseFlushMiddleware = () => (_req, _res, next) => next()
|
|
66
|
+
let responseFlushMiddleware = () => (_req, _res, next) => next();
|
|
67
|
+
// config.json booleans survive the process.env swap in loadEnvironmentVariables(),
|
|
68
|
+
// so this is genuinely true at runtime when config sets OTEL_ENABLE: true. The cast
|
|
69
|
+
// exists only because TS types process.env values as string | undefined.
|
|
65
70
|
if (process.env.OTEL_ENABLE === true) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
try {
|
|
72
|
+
const otel = await import("../otel.js");
|
|
73
|
+
responseFlushMiddleware = otel.responseFlushMiddleware;
|
|
74
|
+
} catch {
|
|
75
|
+
// otel packages not installed — continue without the flush span
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
|
-
|
|
74
|
-
const SSR_SERVICE = process.env.SERVICE_NAME || `pwa-${process.env.APPLICATION}-node-server`
|
|
78
|
+
const SSR_SERVICE = process.env.SERVICE_NAME || `pwa-${process.env.APPLICATION}-node-server`;
|
|
75
79
|
|
|
76
80
|
// ─── Load app-defined server lifecycle hooks ──────────────────────────────────
|
|
77
|
-
let onServerError
|
|
81
|
+
let onServerError;
|
|
78
82
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
const hooks = await import(path.join(process.env.src_path, "server/index.js"));
|
|
84
|
+
onServerError = hooks.onServerError;
|
|
81
85
|
} catch {
|
|
82
|
-
|
|
86
|
+
// No hooks file — onServerError remains undefined
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
// ─── Process-level error handlers ─────────────────────────────────────────────
|
|
86
90
|
|
|
87
91
|
function safeStringify(err) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
try {
|
|
93
|
+
return JSON.stringify(err);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.log("error in safeStringify", e);
|
|
96
|
+
return err;
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
|
-
|
|
96
99
|
process.on("uncaughtException", (err, origin) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
|
|
100
|
+
console.log(process.stderr.fd);
|
|
101
|
+
console.log(`Caught exception: ${err}\n` + `Exception origin: ${origin}`);
|
|
102
|
+
});
|
|
101
103
|
process.on("uncaughtExceptionMonitor", (err, origin) => {
|
|
102
|
-
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
process.on("unhandledRejection", (err) => console.log("unhandledRejection in Catalyst", safeStringify(err)))
|
|
106
|
-
|
|
104
|
+
console.log(err, origin);
|
|
105
|
+
});
|
|
106
|
+
process.on("unhandledRejection", err => console.log("unhandledRejection in Catalyst", err?.stack || safeStringify(err)));
|
|
107
107
|
process.on("SIGINT", function () {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
})
|
|
111
|
-
|
|
108
|
+
console.log("SIGINT");
|
|
109
|
+
process.exit(0);
|
|
110
|
+
});
|
|
112
111
|
process.on("message", function (msg) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const isProduction = process.env.NODE_ENV === "production"
|
|
127
|
-
|
|
112
|
+
if (msg == "shutdown") {
|
|
113
|
+
console.log("Closing all connections...");
|
|
114
|
+
setTimeout(function () {
|
|
115
|
+
console.log("Finished closing connections");
|
|
116
|
+
process.exit(0);
|
|
117
|
+
}, 1500);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
import { fileURLToPath } from "url";
|
|
121
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
122
|
+
const __dirname = path.dirname(__filename);
|
|
123
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
128
124
|
function serveBuildFile(app, buildPath, urlPath, fileName, headers = {}) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
app.get(urlPath, (_req, res, next) => {
|
|
126
|
+
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal - fileName is always a hardcoded literal passed at each serveBuildFile call site, never derived from the request.
|
|
127
|
+
const filePath = path.join(buildPath, fileName);
|
|
128
|
+
if (!fs.existsSync(filePath)) return next();
|
|
129
|
+
res.set(headers);
|
|
130
|
+
res.sendFile(filePath);
|
|
131
|
+
});
|
|
136
132
|
}
|
|
137
|
-
|
|
138
133
|
async function createServer() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
134
|
+
const port = process.env.NODE_SERVER_PORT ?? 3005;
|
|
135
|
+
const host = process.env.NODE_SERVER_HOSTNAME ?? "localhost";
|
|
136
|
+
const app = express();
|
|
137
|
+
|
|
138
|
+
// This middleware is being used to extract the body of the request
|
|
139
|
+
app.use(bodyParser.json());
|
|
140
|
+
|
|
141
|
+
// // This middleware has been added to accommodate "byetstream array"
|
|
142
|
+
app.use(bodyParser.raw({
|
|
143
|
+
type: "application/*"
|
|
144
|
+
}));
|
|
145
|
+
|
|
146
|
+
// This middleware is being used to parse cookies!
|
|
147
|
+
app.use(cookieParser());
|
|
148
|
+
|
|
149
|
+
// All the middlewares defined by the user will run here.
|
|
150
|
+
{
|
|
151
|
+
const middlewareErr = validateMiddleware(addMiddlewares);
|
|
152
|
+
if (middlewareErr) handleError(middlewareErr);else addMiddlewares(app);
|
|
153
|
+
}
|
|
154
|
+
mountAIRouter(app);
|
|
155
|
+
|
|
156
|
+
// response.compress + response.flush spans straddle compression — they
|
|
157
|
+
// attribute the time past the `handler` span (gzip/brotli, then egress).
|
|
158
|
+
// MUST be mounted immediately before compression() so its outer res.end
|
|
159
|
+
// hook reliably wraps compression's patch (no-op when OTEL off).
|
|
160
|
+
app.use(responseFlushMiddleware(SSR_SERVICE, "response.flush", "response.compress"));
|
|
161
|
+
|
|
162
|
+
// The middleware will attempt to compress response bodies for all request that traverse through the middleware
|
|
163
|
+
app.use(compression());
|
|
164
|
+
let vite;
|
|
165
|
+
if (isProduction) {
|
|
166
|
+
// In production, serve built assets. Build manifests themselves are
|
|
167
|
+
// loaded once at startup by ./manifestCache.js — handler reads from
|
|
168
|
+
// that singleton instead of attaching them to every `req`.
|
|
169
|
+
const buildPath = path.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH || "build");
|
|
170
|
+
const publicPath = path.join(buildPath, "client", "assets");
|
|
171
|
+
const publicAssetBase = `/${(process.env.PUBLIC_STATIC_ASSET_PATH || "/assets/").replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/")}/client/assets`;
|
|
172
|
+
serveBuildFile(app, buildPath, "/catalyst-offline-manifest.json", "catalyst-offline-manifest.json", {
|
|
173
|
+
"cache-control": "no-store"
|
|
174
|
+
});
|
|
175
|
+
serveBuildFile(app, buildPath, "/catalyst-sw.js", "catalyst-sw.js", {
|
|
176
|
+
"cache-control": "no-cache",
|
|
177
|
+
"service-worker-allowed": "/"
|
|
178
|
+
});
|
|
179
|
+
serveBuildFile(app, buildPath, "/offline.html", "offline.html", {
|
|
180
|
+
"cache-control": "no-cache"
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Serve static assets — prefers pre-compressed .br / .gz files generated at build time
|
|
184
|
+
app.use(publicAssetBase, expressStaticGzip(publicPath, {
|
|
185
|
+
enableBrotli: true,
|
|
186
|
+
orderPreference: ["br", "gz"],
|
|
187
|
+
serveStatic: {
|
|
188
|
+
maxAge: "1y",
|
|
189
|
+
etag: true,
|
|
190
|
+
lastModified: true
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
} else {
|
|
194
|
+
// In development, use Vite middleware
|
|
195
|
+
vite = await createViteServer({
|
|
196
|
+
configFile: "./dist/vite/vite.config.js",
|
|
197
|
+
server: {
|
|
198
|
+
middlewareMode: true
|
|
199
|
+
},
|
|
200
|
+
appType: "custom",
|
|
201
|
+
root: process.env.src_path
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Expose Vite's resolved base to the SSR renderer so the URLs it injects
|
|
205
|
+
// (client entry, react-refresh preamble) match the path Vite serves under.
|
|
206
|
+
// Vite normalizes base with a trailing slash; trim it for clean URL joins.
|
|
207
|
+
process.env.APP_MOUNT_PATH = toMountPathPrefix(vite.config.base);
|
|
208
|
+
app.use(vite.middlewares);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// In production, resolve the render module once at startup so the ESM
|
|
212
|
+
// loader and lazy-chunk cache are not re-entered on every request.
|
|
213
|
+
let productionRender;
|
|
214
|
+
if (isProduction) {
|
|
215
|
+
const serverPath = path.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH || "build", "server", "server.js");
|
|
216
|
+
if (fs.existsSync(serverPath)) {
|
|
217
|
+
productionRender = await import(serverPath);
|
|
202
218
|
} else {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
configFile: "./dist/vite/vite.config.js",
|
|
206
|
-
server: {
|
|
207
|
-
middlewareMode: true,
|
|
208
|
-
},
|
|
209
|
-
appType: "custom",
|
|
210
|
-
root: process.env.src_path,
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
// Expose Vite's resolved base to the SSR renderer so the URLs it injects
|
|
214
|
-
// (client entry, react-refresh preamble) match the path Vite serves under.
|
|
215
|
-
// Vite normalizes base with a trailing slash; trim it for clean URL joins.
|
|
216
|
-
process.env.APP_MOUNT_PATH = toMountPathPrefix(vite.config.base)
|
|
217
|
-
|
|
218
|
-
app.use(vite.middlewares)
|
|
219
|
+
const rendererPath = path.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH || "build", "server", "index.js");
|
|
220
|
+
productionRender = await import(rendererPath);
|
|
219
221
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
222
|
+
}
|
|
223
|
+
app.use(botDetectionMiddleware);
|
|
224
|
+
app.use("*", async (req, res, next) => {
|
|
225
|
+
try {
|
|
226
|
+
let render;
|
|
227
|
+
if (isProduction) {
|
|
228
|
+
render = productionRender;
|
|
229
|
+
} else {
|
|
230
|
+
// In development, load through Vite SSR per-request to support HMR
|
|
231
|
+
const rendererPath = path.join(__dirname, "./renderer/index.js");
|
|
232
|
+
render = await vite.ssrLoadModule(rendererPath);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Render your app
|
|
236
|
+
if (render && render.default) {
|
|
237
|
+
await render.default(req, res, next);
|
|
238
|
+
} else {
|
|
239
|
+
console.error("Renderer not found or invalid");
|
|
240
|
+
res.status(500).send("Error loading renderer");
|
|
241
|
+
}
|
|
242
|
+
} catch (err) {
|
|
243
|
+
console.error("SSR Error:", err);
|
|
244
|
+
if (vite) {
|
|
245
|
+
vite.ssrFixStacktrace(err);
|
|
246
|
+
}
|
|
247
|
+
res.status(500).send("Internal Server Error");
|
|
242
248
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
res.status(500).send("Internal Server Error")
|
|
271
|
-
}
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
app.listen({ port, host }, (error) => {
|
|
275
|
-
const { APPLICATION, NODE_SERVER_HOSTNAME, NODE_SERVER_PORT } = process.env
|
|
276
|
-
|
|
277
|
-
if (error) {
|
|
278
|
-
console.log("An error occured while starting the Application server : ", error)
|
|
279
|
-
safeCall(onServerError)
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (process.env.NODE_ENV === "development") console.log(green("Compiled successfully!"))
|
|
284
|
-
|
|
285
|
-
console.log(`\nYou can now view ${APPLICATION} in the browser.\n`)
|
|
286
|
-
console.log(
|
|
287
|
-
util.format("\tLocal:".padEnd(8), cyan(`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`))
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
if (process.env.NODE_ENV === "development") {
|
|
291
|
-
console.log("\nNote that the development build is not optimized.")
|
|
292
|
-
console.log("To create a production build, use " + cyan("npm run build"))
|
|
293
|
-
} else {
|
|
294
|
-
console.log(
|
|
295
|
-
green(`\nProduction server running in ${isProduction ? "production" : "development"} mode`)
|
|
296
|
-
)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
console.log("\nFind out more about deployment here:")
|
|
300
|
-
console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"))
|
|
301
|
-
})
|
|
249
|
+
});
|
|
250
|
+
app.listen({
|
|
251
|
+
port,
|
|
252
|
+
host
|
|
253
|
+
}, error => {
|
|
254
|
+
const {
|
|
255
|
+
APPLICATION,
|
|
256
|
+
NODE_SERVER_HOSTNAME,
|
|
257
|
+
NODE_SERVER_PORT
|
|
258
|
+
} = process.env;
|
|
259
|
+
if (error) {
|
|
260
|
+
console.log("An error occured while starting the Application server : ", error);
|
|
261
|
+
safeCall(onServerError);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (process.env.NODE_ENV === "development") console.log(green("Compiled successfully!"));
|
|
265
|
+
console.log(`\nYou can now view ${APPLICATION} in the browser.\n`);
|
|
266
|
+
console.log(util.format("\tLocal:".padEnd(8), cyan(`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`)));
|
|
267
|
+
if (process.env.NODE_ENV === "development") {
|
|
268
|
+
console.log("\nNote that the development build is not optimized.");
|
|
269
|
+
console.log("To create a production build, use " + cyan("npm run build"));
|
|
270
|
+
} else {
|
|
271
|
+
console.log(green(`\nProduction server running in ${isProduction ? "production" : "development"} mode`));
|
|
272
|
+
}
|
|
273
|
+
console.log("\nFind out more about deployment here:");
|
|
274
|
+
console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));
|
|
275
|
+
});
|
|
302
276
|
}
|
|
303
|
-
|
|
304
|
-
|
|
277
|
+
createServer().catch(err => {
|
|
278
|
+
console.error(err?.stack || err);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
});
|
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
import fs from "fs"
|
|
2
|
-
import path from "path"
|
|
3
|
-
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const isProduction = process.env.NODE_ENV === "production"
|
|
9
|
-
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
let manifest = null;
|
|
4
|
+
let assetManifest = null;
|
|
5
|
+
let loaded = false;
|
|
6
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
10
7
|
function loadManifests() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (fs.existsSync(manifestPath)) {
|
|
21
|
-
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"))
|
|
22
|
-
}
|
|
23
|
-
if (fs.existsSync(assetManifestPath)) {
|
|
24
|
-
assetManifest = JSON.parse(fs.readFileSync(assetManifestPath, "utf-8"))
|
|
25
|
-
}
|
|
26
|
-
loaded = true
|
|
27
|
-
} catch (error) {
|
|
28
|
-
loaded = false
|
|
29
|
-
console.warn("Could not load build manifests:", error.message)
|
|
8
|
+
if (loaded) return;
|
|
9
|
+
if (!isProduction) return;
|
|
10
|
+
const buildPath = path.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH || "build");
|
|
11
|
+
try {
|
|
12
|
+
const manifestPath = path.join(buildPath, ".vite", "manifest.json");
|
|
13
|
+
const assetManifestPath = path.join(buildPath, ".vite", "asset-categories.json");
|
|
14
|
+
if (fs.existsSync(manifestPath)) {
|
|
15
|
+
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
30
16
|
}
|
|
17
|
+
if (fs.existsSync(assetManifestPath)) {
|
|
18
|
+
assetManifest = JSON.parse(fs.readFileSync(assetManifestPath, "utf-8"));
|
|
19
|
+
}
|
|
20
|
+
loaded = true;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
loaded = false;
|
|
23
|
+
console.warn("Could not load build manifests:", error.message);
|
|
24
|
+
}
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export const getManifest = () => manifest
|
|
36
|
-
export const getAssetManifest = () => assetManifest
|
|
26
|
+
loadManifests();
|
|
27
|
+
export const getManifest = () => manifest;
|
|
28
|
+
export const getAssetManifest = () => assetManifest;
|