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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChunkExtractor — collects JS and CSS assets needed for the current SSR render.
|
|
3
|
+
*
|
|
4
|
+
* Two buckets:
|
|
5
|
+
* critical — loaded in <head> (inline CSS via <style>, entry + route JS)
|
|
6
|
+
* deferred — injected after </body> via onAllReady (external <link> CSS)
|
|
7
|
+
*
|
|
8
|
+
* Critical CSS is inlined as <style> to avoid FOUC/CLS.
|
|
9
|
+
* With natural Vite code-splitting (no mega "main" chunk), critical CSS stays small (~15-25KB).
|
|
10
|
+
*/
|
|
11
|
+
export declare class ChunkExtractor {
|
|
12
|
+
manifest: any;
|
|
13
|
+
assetManifest: any;
|
|
14
|
+
components: Set<any>;
|
|
15
|
+
publicPath: string;
|
|
16
|
+
critical: {
|
|
17
|
+
js: Set<any>;
|
|
18
|
+
css: Set<any>;
|
|
19
|
+
};
|
|
20
|
+
deferred: {
|
|
21
|
+
js: Set<any>;
|
|
22
|
+
css: Set<any>;
|
|
23
|
+
};
|
|
24
|
+
_allCssPaths: Set<any>;
|
|
25
|
+
constructor({ manifest, assetManifest }?: any);
|
|
26
|
+
_loadEssentialEntrypoints(): void;
|
|
27
|
+
preloadRouteCss(allMatches?: any): void;
|
|
28
|
+
addComponent(cacheKey: any): void;
|
|
29
|
+
_addAssets(manifestEntry: any, bucket: any): void;
|
|
30
|
+
_toUrl(filePath: string): string;
|
|
31
|
+
_toCssUrl(filePath: string): string;
|
|
32
|
+
/** Critical: CSS as relative file paths (for inlining from disk), JS as URLs */
|
|
33
|
+
getCriticalAssets(): {
|
|
34
|
+
js: any[];
|
|
35
|
+
css: any[];
|
|
36
|
+
};
|
|
37
|
+
/** Deferred: CSS as URLs (external <link>), JS as URLs */
|
|
38
|
+
getDeferredAssets(): {
|
|
39
|
+
js: any[];
|
|
40
|
+
css: any[];
|
|
41
|
+
};
|
|
42
|
+
getRenderedComponentKeys(): any[];
|
|
43
|
+
}
|
|
44
|
+
export default ChunkExtractor;
|
|
@@ -9,136 +9,124 @@
|
|
|
9
9
|
* With natural Vite code-splitting (no mega "main" chunk), critical CSS stays small (~15-25KB).
|
|
10
10
|
*/
|
|
11
11
|
export class ChunkExtractor {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
constructor({
|
|
13
|
+
manifest = {},
|
|
14
|
+
assetManifest = {}
|
|
15
|
+
} = {}) {
|
|
16
|
+
this.manifest = manifest;
|
|
17
|
+
this.assetManifest = assetManifest;
|
|
18
|
+
this.components = new Set();
|
|
19
|
+
const baseUrl = `${process.env.PUBLIC_STATIC_ASSET_URL || ""}${process.env.PUBLIC_STATIC_ASSET_PATH || ""}`;
|
|
20
|
+
this.publicPath = `${baseUrl.replace(/\/+$/, "")}/`;
|
|
21
|
+
|
|
22
|
+
// JS tracked as full URLs, CSS tracked as relative file paths (for disk reading)
|
|
23
|
+
this.critical = {
|
|
24
|
+
js: new Set(),
|
|
25
|
+
css: new Set()
|
|
26
|
+
};
|
|
27
|
+
this.deferred = {
|
|
28
|
+
js: new Set(),
|
|
29
|
+
css: new Set()
|
|
30
|
+
};
|
|
31
|
+
this._allCssPaths = new Set(); // dedup across buckets
|
|
32
|
+
|
|
33
|
+
this._loadEssentialEntrypoints();
|
|
34
|
+
if (typeof global !== "undefined") {
|
|
35
|
+
;
|
|
36
|
+
global.__CHUNK_EXTRACTOR__ = this;
|
|
30
37
|
}
|
|
38
|
+
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
40
|
+
// ── Build-time essential chunks (entry + static deps) ──────────────
|
|
41
|
+
_loadEssentialEntrypoints() {
|
|
42
|
+
for (const [, entry] of Object.entries(this.assetManifest.essential || {})) {
|
|
43
|
+
this._addAssets(entry, this.critical);
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.manifest[cacheKey]
|
|
54
|
-
|
|
55
|
-
if (entry) {
|
|
56
|
-
this._addAssets(entry, this.critical)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ── Route-matched split chunks → critical (blocks first paint) ─────
|
|
48
|
+
preloadRouteCss(allMatches = []) {
|
|
49
|
+
const list = allMatches == null ? [] : Array.isArray(allMatches) ? allMatches : [];
|
|
50
|
+
for (const match of list) {
|
|
51
|
+
const route = match?.route;
|
|
52
|
+
if (!route) continue;
|
|
53
|
+
const component = route.Component || route.component;
|
|
54
|
+
const cacheKey = component?.__cacheKey;
|
|
55
|
+
if (!cacheKey) continue;
|
|
56
|
+
const entry = this.assetManifest.ssrTrue?.[cacheKey] || this.assetManifest.ssrFalse?.[cacheKey] || this.manifest[cacheKey];
|
|
57
|
+
if (entry) {
|
|
58
|
+
this._addAssets(entry, this.critical);
|
|
59
|
+
}
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (resolvedKey) {
|
|
77
|
-
entry =
|
|
78
|
-
this.assetManifest.ssrTrue?.[resolvedKey] ||
|
|
79
|
-
this.assetManifest.ssrFalse?.[resolvedKey] ||
|
|
80
|
-
this.manifest[resolvedKey]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (entry) {
|
|
85
|
-
this._addAssets(entry, this.deferred)
|
|
86
|
-
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ── Components discovered during render → deferred ─────────────────
|
|
64
|
+
addComponent(cacheKey) {
|
|
65
|
+
this.components.add(cacheKey);
|
|
66
|
+
|
|
67
|
+
// Try assetManifest first by raw cacheKey — addSourcePathAliases writes
|
|
68
|
+
// source-path entries here even when the chunk is anonymous in manifest.json
|
|
69
|
+
// (shared / multi-importer dynamic chunks). Falling back to manifest.json
|
|
70
|
+
// last keeps the existing prefix-match behavior intact.
|
|
71
|
+
let entry = this.assetManifest.ssrTrue?.[cacheKey] || this.assetManifest.ssrFalse?.[cacheKey] || this.manifest[cacheKey];
|
|
72
|
+
if (!entry) {
|
|
73
|
+
const resolvedKey = Object.keys(this.manifest).find(k => k.startsWith(cacheKey + "."));
|
|
74
|
+
if (resolvedKey) {
|
|
75
|
+
entry = this.assetManifest.ssrTrue?.[resolvedKey] || this.assetManifest.ssrFalse?.[resolvedKey] || this.manifest[resolvedKey];
|
|
76
|
+
}
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_addAssets(manifestEntry, bucket) {
|
|
91
|
-
if (!manifestEntry?.file) return
|
|
92
|
-
|
|
93
|
-
const jsUrl = this._toUrl(manifestEntry.file)
|
|
94
|
-
|
|
95
|
-
// Skip if already tracked in either bucket
|
|
96
|
-
if (this.critical.js.has(jsUrl) || this.deferred.js.has(jsUrl)) return
|
|
97
|
-
|
|
98
|
-
bucket.js.add(jsUrl)
|
|
99
|
-
|
|
100
|
-
// Collect direct + transitive CSS as relative file paths (not URLs)
|
|
101
|
-
const cssPart = Array.isArray(manifestEntry.css) ? manifestEntry.css : []
|
|
102
|
-
const allCssPart = Array.isArray(manifestEntry.allCss) ? manifestEntry.allCss : []
|
|
103
|
-
const cssFiles = [...cssPart, ...allCssPart]
|
|
104
|
-
for (const cssFile of cssFiles) {
|
|
105
|
-
if (!this._allCssPaths.has(cssFile)) {
|
|
106
|
-
this._allCssPaths.add(cssFile)
|
|
107
|
-
bucket.css.add(cssFile)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
78
|
+
if (entry) {
|
|
79
|
+
this._addAssets(entry, this.deferred);
|
|
110
80
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/** Deferred: CSS as URLs (external <link>), JS as URLs */
|
|
132
|
-
getDeferredAssets() {
|
|
133
|
-
return {
|
|
134
|
-
js: Array.from(this.deferred.js),
|
|
135
|
-
css: Array.from(this.deferred.css),
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
getRenderedComponentKeys() {
|
|
140
|
-
return Array.from(this.components)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ── Internal: add JS URLs + CSS file paths to a bucket ─────────────
|
|
84
|
+
_addAssets(manifestEntry, bucket) {
|
|
85
|
+
if (!manifestEntry?.file) return;
|
|
86
|
+
const jsUrl = this._toUrl(manifestEntry.file);
|
|
87
|
+
|
|
88
|
+
// Skip if already tracked in either bucket
|
|
89
|
+
if (this.critical.js.has(jsUrl) || this.deferred.js.has(jsUrl)) return;
|
|
90
|
+
bucket.js.add(jsUrl);
|
|
91
|
+
|
|
92
|
+
// Collect direct + transitive CSS as relative file paths (not URLs)
|
|
93
|
+
const cssPart = Array.isArray(manifestEntry.css) ? manifestEntry.css : [];
|
|
94
|
+
const allCssPart = Array.isArray(manifestEntry.allCss) ? manifestEntry.allCss : [];
|
|
95
|
+
const cssFiles = [...cssPart, ...allCssPart];
|
|
96
|
+
for (const cssFile of cssFiles) {
|
|
97
|
+
if (!this._allCssPaths.has(cssFile)) {
|
|
98
|
+
this._allCssPaths.add(cssFile);
|
|
99
|
+
bucket.css.add(cssFile);
|
|
100
|
+
}
|
|
141
101
|
}
|
|
102
|
+
}
|
|
103
|
+
_toUrl(filePath) {
|
|
104
|
+
const cleaned = filePath.replace(/^\/+/, "");
|
|
105
|
+
return `${this.publicPath}${cleaned}`;
|
|
106
|
+
}
|
|
107
|
+
_toCssUrl(filePath) {
|
|
108
|
+
const cleaned = filePath.replace(/^\/+/, "");
|
|
109
|
+
return `${this.publicPath}${cleaned}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ── Public getters ─────────────────────────────────────────────────
|
|
113
|
+
/** Critical: CSS as relative file paths (for inlining from disk), JS as URLs */
|
|
114
|
+
getCriticalAssets() {
|
|
115
|
+
return {
|
|
116
|
+
js: Array.from(this.critical.js),
|
|
117
|
+
css: Array.from(this.critical.css)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Deferred: CSS as URLs (external <link>), JS as URLs */
|
|
122
|
+
getDeferredAssets() {
|
|
123
|
+
return {
|
|
124
|
+
js: Array.from(this.deferred.js),
|
|
125
|
+
css: Array.from(this.deferred.css)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
getRenderedComponentKeys() {
|
|
129
|
+
return Array.from(this.components);
|
|
130
|
+
}
|
|
142
131
|
}
|
|
143
|
-
|
|
144
|
-
export default ChunkExtractor
|
|
132
|
+
export default ChunkExtractor;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Body component which will be used in page component
|
|
4
|
+
* @param {object} jsx - page jsx code
|
|
5
|
+
* @param {number|string} statusCode - document request status code
|
|
6
|
+
* @param {object} initialState - initial state object for redux store
|
|
7
|
+
* @param {object} fetcherData - contains data from executing serverFetcher function
|
|
8
|
+
* @param {object} children - contains any child elements defined within the component
|
|
9
|
+
*/
|
|
10
|
+
export declare function Body(props: any): React.JSX.Element;
|
|
11
|
+
export declare namespace Body {
|
|
12
|
+
var propTypes: {
|
|
13
|
+
initialState: any;
|
|
14
|
+
jsx: any;
|
|
15
|
+
statusCode: any;
|
|
16
|
+
fetcherData: any;
|
|
17
|
+
children: any;
|
|
18
|
+
safeArea: any;
|
|
19
|
+
nativeWebView: any;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
const DEFAULT_SAFE_AREA = {
|
|
4
|
+
top: 0,
|
|
5
|
+
right: 0,
|
|
6
|
+
bottom: 0,
|
|
7
|
+
left: 0
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// React does not escape the body of an inline <script>, so a "</script>" inside
|
|
11
|
+
// serialized state would end the block early. The JS parser reads \u003c back as
|
|
12
|
+
// "<", so the payload the client sees is unchanged.
|
|
13
|
+
const serialize = value => JSON.stringify(value).replace(/</g, "\\u003c");
|
|
3
14
|
|
|
4
|
-
const DEFAULT_SAFE_AREA = { top: 0, right: 0, bottom: 0, left: 0 }
|
|
5
15
|
/**
|
|
6
16
|
* Body component which will be used in page component
|
|
7
17
|
* @param {object} jsx - page jsx code
|
|
8
|
-
* @param {
|
|
18
|
+
* @param {number|string} statusCode - document request status code
|
|
9
19
|
* @param {object} initialState - initial state object for redux store
|
|
10
20
|
* @param {object} fetcherData - contains data from executing serverFetcher function
|
|
11
21
|
* @param {object} children - contains any child elements defined within the component
|
|
12
22
|
*/
|
|
13
23
|
export function Body(props) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<body>
|
|
24
|
+
const {
|
|
25
|
+
jsx = "",
|
|
26
|
+
statusCode = "",
|
|
27
|
+
initialState = {},
|
|
28
|
+
fetcherData = {},
|
|
29
|
+
children,
|
|
30
|
+
safeArea = DEFAULT_SAFE_AREA,
|
|
31
|
+
nativeWebView = false
|
|
32
|
+
} = props;
|
|
33
|
+
return <body>
|
|
27
34
|
<script
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Base pinned to Vite's resolved base by server/expressServer.js.
|
|
35
|
-
<script type="module" src={`${process.env.APP_MOUNT_PATH || ""}/client/index.js`}></script>
|
|
36
|
-
)}
|
|
35
|
+
/* eslint-disable-next-line risxss/catch-potential-xss-react */ dangerouslySetInnerHTML={{
|
|
36
|
+
__html: `window.__SAFE_AREA_INITIAL__ = ${JSON.stringify(safeArea)}; window.__CATALYST_NATIVE_WEBVIEW__ = ${nativeWebView ? "true" : "false"}`
|
|
37
|
+
}} />
|
|
38
|
+
{process.env.NODE_ENV === "development" &&
|
|
39
|
+
// Base pinned to Vite's resolved base by server/expressServer.js.
|
|
40
|
+
<script type="module" src={`${process.env.APP_MOUNT_PATH || ""}/client/index.js`}></script>}
|
|
37
41
|
{jsx}
|
|
38
42
|
<script
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}
|
|
43
|
+
/* eslint-disable */ dangerouslySetInnerHTML={{
|
|
44
|
+
__html: `
|
|
45
|
+
window.__INITIAL_STATE__ = ${serialize(initialState)}
|
|
43
46
|
window.__STATUS_CODE__ = ${JSON.stringify(statusCode || null)}
|
|
44
|
-
window.__ROUTER_INITIAL_DATA__ = ${
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/>
|
|
47
|
+
window.__ROUTER_INITIAL_DATA__ = ${serialize(fetcherData)}
|
|
48
|
+
`
|
|
49
|
+
}} />
|
|
48
50
|
|
|
49
51
|
{children}
|
|
50
|
-
</body
|
|
51
|
-
)
|
|
52
|
+
</body>;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
54
|
Body.propTypes = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
55
|
+
initialState: PropTypes.object,
|
|
56
|
+
jsx: PropTypes.any,
|
|
57
|
+
statusCode: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
58
|
+
fetcherData: PropTypes.object,
|
|
59
|
+
children: PropTypes.node,
|
|
60
|
+
safeArea: PropTypes.object,
|
|
61
|
+
nativeWebView: PropTypes.bool
|
|
62
|
+
};
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
/* eslint-disable risxss/catch-potential-xss-react */
|
|
4
4
|
const FastRefresh = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type="module"
|
|
8
|
-
dangerouslySetInnerHTML={{
|
|
9
|
-
__html: `
|
|
5
|
+
return <script type="module" dangerouslySetInnerHTML={{
|
|
6
|
+
__html: `
|
|
10
7
|
import { injectIntoGlobalHook } from "/@react-refresh";
|
|
11
8
|
injectIntoGlobalHook(window);
|
|
12
9
|
window.$RefreshReg$ = () => {};
|
|
13
10
|
window.$RefreshSig$ = () => (type) => type;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default FastRefresh
|
|
11
|
+
`
|
|
12
|
+
}} />;
|
|
13
|
+
};
|
|
14
|
+
export default FastRefresh;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Head component — inlines critical CSS as <style> and renders JS as <script type="module">.
|
|
4
|
+
* Critical CSS is small (~15-25KB) thanks to natural Vite code-splitting.
|
|
5
|
+
* Route-cached deferred CSS is inlined here on repeat visits; new deferred CSS still appends after body.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Head(props: any): React.JSX.Element;
|
|
8
|
+
export declare namespace Head {
|
|
9
|
+
var propTypes: {
|
|
10
|
+
isBot: any;
|
|
11
|
+
inlineCss: any;
|
|
12
|
+
deferredRouteInlineCss: any;
|
|
13
|
+
jsScripts: any;
|
|
14
|
+
criticalPreloadLinks: any;
|
|
15
|
+
deferredPreloadLinks: any;
|
|
16
|
+
metaTags: any;
|
|
17
|
+
publicAssetPath: any;
|
|
18
|
+
children: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
|
-
import FastRefresh from "../../../vite/FastRefresh.jsx"
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import FastRefresh from "../../../vite/FastRefresh.jsx";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Head component — inlines critical CSS as <style> and renders JS as <script type="module">.
|
|
@@ -8,20 +8,18 @@ import FastRefresh from "../../../vite/FastRefresh.jsx"
|
|
|
8
8
|
* Route-cached deferred CSS is inlined here on repeat visits; new deferred CSS still appends after body.
|
|
9
9
|
*/
|
|
10
10
|
export function Head(props) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<head>
|
|
11
|
+
const {
|
|
12
|
+
inlineCss,
|
|
13
|
+
deferredRouteInlineCss,
|
|
14
|
+
jsScripts,
|
|
15
|
+
criticalPreloadLinks,
|
|
16
|
+
deferredPreloadLinks,
|
|
17
|
+
metaTags,
|
|
18
|
+
isBot,
|
|
19
|
+
publicAssetPath,
|
|
20
|
+
children
|
|
21
|
+
} = props;
|
|
22
|
+
return <head>
|
|
25
23
|
<meta charSet="utf-8" />
|
|
26
24
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
27
25
|
{process.env.NODE_ENV === "development" && <FastRefresh />}
|
|
@@ -35,28 +33,30 @@ export function Head(props) {
|
|
|
35
33
|
|
|
36
34
|
{/* Inline critical CSS — prevents FOUC/CLS */}
|
|
37
35
|
{/* nosemgrep: typescript.react.security.audit.react-dangerouslysetinnerhtml.react-dangerouslysetinnerhtml - inlineCss is compiled CSS read from disk (readCssFromDisk), sourced from the app's own build output, never from request/user input. */}
|
|
38
|
-
{inlineCss && <style dangerouslySetInnerHTML={{
|
|
36
|
+
{inlineCss && <style dangerouslySetInnerHTML={{
|
|
37
|
+
__html: inlineCss
|
|
38
|
+
}} />}
|
|
39
39
|
|
|
40
40
|
{/* Deferred CSS from prior SSRs on this route — avoids late layout from post-body <style> */}
|
|
41
41
|
{/* nosemgrep: typescript.react.security.audit.react-dangerouslysetinnerhtml.react-dangerouslysetinnerhtml - deferredRouteInlineCss is compiled CSS read from disk (readCssFromDisk), sourced from the app's own build output, never from request/user input. */}
|
|
42
|
-
{deferredRouteInlineCss && <style dangerouslySetInnerHTML={{
|
|
42
|
+
{deferredRouteInlineCss && <style dangerouslySetInnerHTML={{
|
|
43
|
+
__html: deferredRouteInlineCss
|
|
44
|
+
}} />}
|
|
43
45
|
|
|
44
46
|
{/* JS modules */}
|
|
45
47
|
{!isBot && jsScripts}
|
|
46
48
|
|
|
47
49
|
{children}
|
|
48
|
-
</head
|
|
49
|
-
)
|
|
50
|
+
</head>;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
52
|
Head.propTypes = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
53
|
+
isBot: PropTypes.bool,
|
|
54
|
+
inlineCss: PropTypes.string,
|
|
55
|
+
deferredRouteInlineCss: PropTypes.string,
|
|
56
|
+
jsScripts: PropTypes.array,
|
|
57
|
+
criticalPreloadLinks: PropTypes.array,
|
|
58
|
+
deferredPreloadLinks: PropTypes.array,
|
|
59
|
+
metaTags: PropTypes.array,
|
|
60
|
+
publicAssetPath: PropTypes.string,
|
|
61
|
+
children: PropTypes.node
|
|
62
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Head.jsx"
|
|
2
|
-
export * from "./Body.jsx"
|
|
1
|
+
export * from "./Head.jsx";
|
|
2
|
+
export * from "./Body.jsx";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare global {
|
|
3
|
+
namespace NodeJS {
|
|
4
|
+
interface Process {
|
|
5
|
+
cssFileCache?: Record<string, string>;
|
|
6
|
+
deferredAssetsByRoute?: Map<any, {
|
|
7
|
+
css: Set<any>;
|
|
8
|
+
js: Set<any>;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Stable key for caching deferred chunks — uses the matched route pattern (e.g. "/product/:name/:id")
|
|
14
|
+
* so all pages on the same route share one entry regardless of their actual URL parameters. */
|
|
15
|
+
export declare const getDeferredRouteKey: (req: any, allMatches?: any) => any;
|
|
16
|
+
/** CSS paths (manifest-relative) previously deferred on this route — for <head> inlining. */
|
|
17
|
+
export declare const getCachedDeferredCssPathsForRoute: (routeKey: any) => any[];
|
|
18
|
+
/**
|
|
19
|
+
* Record deferred asset paths/URLs for this route. Returns CSS paths not yet on the route so they
|
|
20
|
+
* can be inlined after </body> only once; on later visits those paths are inlined in <head> instead.
|
|
21
|
+
* JS URLs are always emitted in HTML on every navigation — skipping "cached" scripts would omit modules.
|
|
22
|
+
* @returns {{ newCssPaths: string[] }}
|
|
23
|
+
*/
|
|
24
|
+
export declare const registerDeferredAssetsForRoute: (routeKey: any, { css, js }?: any, isBot?: boolean) => {
|
|
25
|
+
newCssPaths: any[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Cached deferred script URLs for this route, excluding URLs already loaded as critical scripts.
|
|
29
|
+
* @param {string|null} routeKey - Matched route pattern.
|
|
30
|
+
* @param {Iterable<string>} excludeUrls - Critical / head script src URLs.
|
|
31
|
+
* @returns {string[]}
|
|
32
|
+
*/
|
|
33
|
+
export declare const getDeferredPreloadScriptUrls: (routeKey: any, excludeUrls?: any) => any[];
|
|
34
|
+
/**
|
|
35
|
+
* React <link rel="modulepreload"> elements (deduped). Use before matching <script type="module">.
|
|
36
|
+
* @param {string[]} jsUrls
|
|
37
|
+
* @param {string} [keyPrefix] - Unique prefix for React keys when rendering multiple lists.
|
|
38
|
+
*/
|
|
39
|
+
export declare const generateModulePreloadLinkElements: (jsUrls?: any, keyPrefix?: string) => React.DetailedReactHTMLElement<{
|
|
40
|
+
key: string;
|
|
41
|
+
rel: string;
|
|
42
|
+
href: any;
|
|
43
|
+
fetchPriority: string;
|
|
44
|
+
}, HTMLElement>[];
|
|
45
|
+
/**
|
|
46
|
+
* Read CSS files from disk and return concatenated CSS string for inlining.
|
|
47
|
+
* @param {string[]} cssPaths - Relative CSS paths (from manifest).
|
|
48
|
+
* @param {string} basePath - Build output directory on disk.
|
|
49
|
+
* @returns {string} Concatenated CSS content.
|
|
50
|
+
*/
|
|
51
|
+
export declare const readCssFromDisk: (cssPaths?: any, basePath?: string) => string;
|
|
52
|
+
/**
|
|
53
|
+
* <script type="module"> React elements for JS assets.
|
|
54
|
+
*/
|
|
55
|
+
export declare const generateScriptElements: (jsUrls?: any) => React.ReactElement<{
|
|
56
|
+
key: string;
|
|
57
|
+
type: string;
|
|
58
|
+
src: any;
|
|
59
|
+
}, string | React.JSXElementConstructor<any>>[];
|
|
60
|
+
/**
|
|
61
|
+
* <link rel="stylesheet"> HTML strings for deferred CSS (non-blocking, after body).
|
|
62
|
+
*/
|
|
63
|
+
export declare const generateCssLinkStrings: (cssUrls?: any) => string;
|
|
64
|
+
/**
|
|
65
|
+
* <link rel="modulepreload"> + <script type="module"> HTML strings.
|
|
66
|
+
*/
|
|
67
|
+
export declare const generateScriptStrings: (jsUrls?: any) => string;
|