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
package/mcp_v2/package.json
CHANGED
|
@@ -6,9 +6,20 @@
|
|
|
6
6
|
"main": "mcp.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"setup": "node setup.js",
|
|
9
|
-
"start": "node mcp.js"
|
|
9
|
+
"start": "node mcp.js",
|
|
10
|
+
"test": "npm run test:types && vitest run",
|
|
11
|
+
"test:watch": "vitest",
|
|
12
|
+
"test:types": "tsc --noEmit"
|
|
10
13
|
},
|
|
11
14
|
"dependencies": {
|
|
12
|
-
"better-sqlite3": "
|
|
15
|
+
"better-sqlite3": "12.4.6"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^7.0.2",
|
|
19
|
+
"vitest": "^4.1.11",
|
|
20
|
+
"yaml": "^2.5.0"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
13
24
|
}
|
|
14
25
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
// Copies the monorepo-root errors/index.json into this package's dist/ so
|
|
4
|
+
// mcp_v2/tools/errors.js#explain_error can find it once catalyst-core is
|
|
5
|
+
// installed as a real npm dependency — the repo-root errors/ directory is a
|
|
6
|
+
// sibling of packages/catalyst-core, not inside it, so it never ends up in
|
|
7
|
+
// a published tarball on its own.
|
|
8
|
+
//
|
|
9
|
+
// Run as part of the "prepare"/"prepublishOnly" scripts. Non-fatal if the
|
|
10
|
+
// source file doesn't exist (e.g. running outside this monorepo, or before
|
|
11
|
+
// generateDocs.js has ever run) — explain_error degrades to reporting every
|
|
12
|
+
// code as non-catalyst-owned rather than failing the whole build.
|
|
13
|
+
|
|
14
|
+
const fs = require("fs")
|
|
15
|
+
const path = require("path")
|
|
16
|
+
|
|
17
|
+
const SOURCE_PATH = path.join(__dirname, "..", "..", "..", "..", "errors", "index.json")
|
|
18
|
+
const DEST_PATH = path.join(__dirname, "..", "..", "dist", "errors-index.json")
|
|
19
|
+
|
|
20
|
+
function copyErrorsIndex() {
|
|
21
|
+
if (!fs.existsSync(SOURCE_PATH)) {
|
|
22
|
+
console.log(`[copyErrorsIndex] ${SOURCE_PATH} not found, skipping (run generateDocs.js first for explain_error to work)`)
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
fs.mkdirSync(path.dirname(DEST_PATH), { recursive: true })
|
|
26
|
+
fs.copyFileSync(SOURCE_PATH, DEST_PATH)
|
|
27
|
+
console.log(`[copyErrorsIndex] copied ${SOURCE_PATH} -> ${DEST_PATH}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (require.main === module) {
|
|
31
|
+
copyErrorsIndex()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { copyErrorsIndex }
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// describe/it/expect come from vitest's `globals: true` config (see
|
|
2
|
+
// vitest.config.mjs) — vitest's own exports can't be require()'d, only
|
|
3
|
+
// import'd, so globals injects them instead.
|
|
4
|
+
//
|
|
5
|
+
// tools/errors.js itself is loaded via require() rather than import — it's
|
|
6
|
+
// a CommonJS module, matching how it's actually loaded in production.
|
|
7
|
+
// Typed against the hand-written declaration in ../tools/errors.d.ts rather
|
|
8
|
+
// than left as `unknown` (errors.js stays plain JS until #420's source
|
|
9
|
+
// conversion).
|
|
10
|
+
const fs = require("fs")
|
|
11
|
+
const path = require("path")
|
|
12
|
+
const { init, handle_explain_error }: typeof import("../tools/errors.js") = require("../tools/errors.js")
|
|
13
|
+
|
|
14
|
+
// Framework-level (Tier 1) contract tests for the explain_error MCP tool —
|
|
15
|
+
// see issue #340/#411. Covers both real load paths (packaged dist/ copy and
|
|
16
|
+
// the monorepo-root fallback) rather than mocking fs, since the whole point
|
|
17
|
+
// of this module is "does the real file get found on disk."
|
|
18
|
+
//
|
|
19
|
+
// CAUTION: these tests move/restore errors/index.json and
|
|
20
|
+
// dist/errors-index.json on real disk (with try/finally restoration). This
|
|
21
|
+
// is safe run standalone or sequentially after other suites (see the root
|
|
22
|
+
// test:unit script's `&&` chaining) but would race against any other suite
|
|
23
|
+
// reading those same files concurrently in the same checkout — don't
|
|
24
|
+
// parallelize this file's run against docsDrift.test.js or generateDocs.js.
|
|
25
|
+
|
|
26
|
+
const PACKAGED_INDEX_PATH = path.join(__dirname, "..", "..", "dist", "errors-index.json")
|
|
27
|
+
const MONOREPO_INDEX_PATH = path.join(__dirname, "..", "..", "..", "..", "errors", "index.json")
|
|
28
|
+
|
|
29
|
+
function packagedIndexExists() {
|
|
30
|
+
return fs.existsSync(PACKAGED_INDEX_PATH)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe("init() + handle_explain_error() — packaged path (dist/errors-index.json)", () => {
|
|
34
|
+
beforeAll(() => {
|
|
35
|
+
// This test only means something when the packaged copy actually
|
|
36
|
+
// exists — it's a build artifact (see mcp_v2/scripts/copyErrorsIndex.cjs
|
|
37
|
+
// + the "prepare" script), not guaranteed present in every checkout.
|
|
38
|
+
// Skip rather than false-fail if `npm run prepare` hasn't run yet.
|
|
39
|
+
if (!packagedIndexExists()) return
|
|
40
|
+
init()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it.runIf(packagedIndexExists())("finds a known code via the packaged path and reports it as catalyst-owned", () => {
|
|
44
|
+
const result = handle_explain_error({ code: "PREFLIGHT-001" })
|
|
45
|
+
expect(result.is_catalyst_owned).toBe(true)
|
|
46
|
+
expect(result.category).toBe("PREFLIGHT")
|
|
47
|
+
expect(result.message).toBeTruthy()
|
|
48
|
+
expect(result.docUrl).toContain("PREFLIGHT-001.md")
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe("init() + handle_explain_error() — monorepo-root fallback (errors/index.json)", () => {
|
|
53
|
+
let packagedBackup: Buffer | undefined
|
|
54
|
+
|
|
55
|
+
beforeAll(() => {
|
|
56
|
+
// Force the fallback path: temporarily move the packaged copy aside
|
|
57
|
+
// (if present) so init() must fall through to MONOREPO_INDEX_PATH.
|
|
58
|
+
if (fs.existsSync(PACKAGED_INDEX_PATH)) {
|
|
59
|
+
packagedBackup = fs.readFileSync(PACKAGED_INDEX_PATH)
|
|
60
|
+
fs.unlinkSync(PACKAGED_INDEX_PATH)
|
|
61
|
+
}
|
|
62
|
+
init()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
afterAll(() => {
|
|
66
|
+
if (packagedBackup) fs.writeFileSync(PACKAGED_INDEX_PATH, packagedBackup)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it("finds a known code via the monorepo-root fallback", () => {
|
|
70
|
+
const result = handle_explain_error({ code: "PREFLIGHT-001" })
|
|
71
|
+
expect(result.is_catalyst_owned).toBe(true)
|
|
72
|
+
expect(result.category).toBe("PREFLIGHT")
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("reports a non-catalyst code as not owned, with a helpful note", () => {
|
|
76
|
+
const result = handle_explain_error({ code: "SOME-UPSTREAM-CODE" })
|
|
77
|
+
expect(result.is_catalyst_owned).toBe(false)
|
|
78
|
+
expect(result.note).toContain("not a catalyst-owned error code")
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("requires code and returns a clear error when it's missing", () => {
|
|
82
|
+
const result = handle_explain_error({})
|
|
83
|
+
expect(result.error).toMatch(/code is required/)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it("uses an own-property lookup — a code matching an inherited Object.prototype member is never misreported as catalyst-owned", () => {
|
|
87
|
+
expect(handle_explain_error({ code: "toString" }).is_catalyst_owned).toBe(false)
|
|
88
|
+
expect(handle_explain_error({ code: "constructor" }).is_catalyst_owned).toBe(false)
|
|
89
|
+
expect(handle_explain_error({ code: "hasOwnProperty" }).is_catalyst_owned).toBe(false)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe("init() — neither path resolvable", () => {
|
|
94
|
+
let packagedBackup: Buffer | undefined
|
|
95
|
+
|
|
96
|
+
beforeAll(() => {
|
|
97
|
+
if (fs.existsSync(PACKAGED_INDEX_PATH)) {
|
|
98
|
+
packagedBackup = fs.readFileSync(PACKAGED_INDEX_PATH)
|
|
99
|
+
fs.unlinkSync(PACKAGED_INDEX_PATH)
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
afterAll(() => {
|
|
104
|
+
if (packagedBackup) fs.writeFileSync(PACKAGED_INDEX_PATH, packagedBackup)
|
|
105
|
+
// Restore real state for any test file that runs after this one in
|
|
106
|
+
// the same process (vitest may share workers across files).
|
|
107
|
+
init()
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it("degrades gracefully — reports a load error instead of throwing, when errors/index.json genuinely can't be read", () => {
|
|
111
|
+
// Simulate by pointing init() at a broken state: rename the real
|
|
112
|
+
// monorepo index aside temporarily.
|
|
113
|
+
const monorepoBackup = fs.readFileSync(MONOREPO_INDEX_PATH)
|
|
114
|
+
fs.unlinkSync(MONOREPO_INDEX_PATH)
|
|
115
|
+
try {
|
|
116
|
+
init()
|
|
117
|
+
const result = handle_explain_error({ code: "PREFLIGHT-001" })
|
|
118
|
+
expect(result.error).toMatch(/Could not load errors\/index\.json/)
|
|
119
|
+
} finally {
|
|
120
|
+
fs.writeFileSync(MONOREPO_INDEX_PATH, monorepoBackup)
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
})
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// describe/it/expect come from vitest's `globals: true` config (see
|
|
2
|
+
// vitest.config.mjs). tools/github.js is CommonJS, loaded via require() and
|
|
3
|
+
// typed against the hand-written declaration in ../tools/github.d.ts (that
|
|
4
|
+
// file stays plain JS for now — same rationale as errors.js / issue #420).
|
|
5
|
+
const fs = require("fs")
|
|
6
|
+
const path = require("path")
|
|
7
|
+
const YAML = require("yaml")
|
|
8
|
+
const github: typeof import("../tools/github.js") = require("../tools/github.js")
|
|
9
|
+
|
|
10
|
+
// Drift guard: the MCP carries a code-embedded copy of the repo's issue and
|
|
11
|
+
// PR templates (ISSUE_TEMPLATES / PR_TEMPLATES in tools/github.js) so an
|
|
12
|
+
// agent raising an issue or PR through the MCP produces the same structure
|
|
13
|
+
// as one raised through the GitHub UI. This suite asserts the two copies
|
|
14
|
+
// can't diverge — the same stance as test/errors.test.ts: check the real
|
|
15
|
+
// files on disk, don't mock fs.
|
|
16
|
+
//
|
|
17
|
+
// mcp_v2 lives four levels under the repo root
|
|
18
|
+
// (packages/catalyst-core/mcp_v2/test → repo root), matching
|
|
19
|
+
// MONOREPO_INDEX_PATH's resolution in errors.test.ts.
|
|
20
|
+
const ISSUE_TEMPLATE_DIR = path.join(__dirname, "..", "..", "..", "..", ".github", "ISSUE_TEMPLATE")
|
|
21
|
+
const PR_TEMPLATE_DIR = path.join(__dirname, "..", "..", "..", "..", ".github", "PULL_REQUEST_TEMPLATE")
|
|
22
|
+
|
|
23
|
+
function templatesOnDisk() {
|
|
24
|
+
return fs.existsSync(ISSUE_TEMPLATE_DIR) && fs.existsSync(PR_TEMPLATE_DIR)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The ordered `##` headings of a Markdown PR template, minus the shared
|
|
28
|
+
// footer checklist (which lives in PR_FOOTER_CHECKLIST, asserted separately).
|
|
29
|
+
function prTemplateSections(md: string): string[] {
|
|
30
|
+
return [...md.matchAll(/^##\s+(.+?)\s*$/gm)].map((m) => m[1])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// The ordered field labels of a GitHub issue form, minus `markdown` blocks
|
|
34
|
+
// (intro prose) and the `checkboxes` Preflight Checklist (form-only UX, not
|
|
35
|
+
// a content section the MCP renders).
|
|
36
|
+
function issueFormSections(form: { body?: Array<Record<string, any>> }): string[] {
|
|
37
|
+
return (form.body || [])
|
|
38
|
+
.filter((b) => b.type !== "markdown")
|
|
39
|
+
.filter((b) => !(b.type === "checkboxes" && b.attributes?.label === "Preflight Checklist"))
|
|
40
|
+
.map((b) => b.attributes.label)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe.skipIf(!templatesOnDisk())("issue forms ↔ ISSUE_TEMPLATES", () => {
|
|
44
|
+
for (const key of Object.keys(github.ISSUE_TEMPLATES)) {
|
|
45
|
+
const tmpl = github.ISSUE_TEMPLATES[key]
|
|
46
|
+
|
|
47
|
+
it(`${key}.yml exists and its label matches`, () => {
|
|
48
|
+
const file = path.join(ISSUE_TEMPLATE_DIR, `${key}.yml`)
|
|
49
|
+
expect(fs.existsSync(file)).toBe(true)
|
|
50
|
+
const form = YAML.parse(fs.readFileSync(file, "utf8"))
|
|
51
|
+
expect(form.labels).toContain(tmpl.label)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it(`${key}.yml body fields match ISSUE_TEMPLATES.${key}.sections in order`, () => {
|
|
55
|
+
const form = YAML.parse(fs.readFileSync(path.join(ISSUE_TEMPLATE_DIR, `${key}.yml`), "utf8"))
|
|
56
|
+
// "Preflight Checklist" may appear in tmpl.sections (bug) — the MCP
|
|
57
|
+
// renders it there — but it's a checkboxes block in the form, so
|
|
58
|
+
// compare against the form's non-preflight sections either way.
|
|
59
|
+
const want = tmpl.sections.filter((s) => s !== "Preflight Checklist")
|
|
60
|
+
expect(issueFormSections(form)).toEqual(want)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
it("config.yml disables blank issues", () => {
|
|
65
|
+
const cfg = YAML.parse(fs.readFileSync(path.join(ISSUE_TEMPLATE_DIR, "config.yml"), "utf8"))
|
|
66
|
+
expect(cfg.blank_issues_enabled).toBe(false)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it("every ISSUE_TEMPLATE/*.yml (except config) has a matching ISSUE_TEMPLATES key", () => {
|
|
70
|
+
const files = fs
|
|
71
|
+
.readdirSync(ISSUE_TEMPLATE_DIR)
|
|
72
|
+
.filter((f: string) => f.endsWith(".yml") && f !== "config.yml")
|
|
73
|
+
.map((f: string) => f.replace(/\.yml$/, ""))
|
|
74
|
+
expect(files.sort()).toEqual(Object.keys(github.ISSUE_TEMPLATES).sort())
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe.skipIf(!templatesOnDisk())("PR templates ↔ PR_TEMPLATES", () => {
|
|
79
|
+
for (const key of Object.keys(github.PR_TEMPLATES) as Array<"fix" | "feature" | "chore">) {
|
|
80
|
+
const tmpl = github.PR_TEMPLATES[key]
|
|
81
|
+
|
|
82
|
+
it(`${key}.md exists and its ## headings match PR_TEMPLATES.${key}.sections in order`, () => {
|
|
83
|
+
const file = path.join(PR_TEMPLATE_DIR, `${key}.md`)
|
|
84
|
+
expect(fs.existsSync(file)).toBe(true)
|
|
85
|
+
const md = fs.readFileSync(file, "utf8")
|
|
86
|
+
expect(prTemplateSections(md)).toEqual(tmpl.sections)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it(`${key}.md ends with the shared footer checklist`, () => {
|
|
90
|
+
const md = fs.readFileSync(path.join(PR_TEMPLATE_DIR, `${key}.md`), "utf8")
|
|
91
|
+
for (const line of github.PR_FOOTER_CHECKLIST.split("\n")) {
|
|
92
|
+
expect(md).toContain(line)
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
it("the default PULL_REQUEST_TEMPLATE.md carries the shared footer checklist", () => {
|
|
98
|
+
const md = fs.readFileSync(path.join(PR_TEMPLATE_DIR, "..", "PULL_REQUEST_TEMPLATE.md"), "utf8")
|
|
99
|
+
for (const line of github.PR_FOOTER_CHECKLIST.split("\n")) {
|
|
100
|
+
expect(md).toContain(line)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it("every PULL_REQUEST_TEMPLATE/*.md has a matching PR_TEMPLATES key", () => {
|
|
105
|
+
const files = fs
|
|
106
|
+
.readdirSync(PR_TEMPLATE_DIR)
|
|
107
|
+
.filter((f: string) => f.endsWith(".md"))
|
|
108
|
+
.map((f: string) => f.replace(/\.md$/, ""))
|
|
109
|
+
expect(files.sort()).toEqual(Object.keys(github.PR_TEMPLATES).sort())
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
describe("handle_create_github_pr() — dry run rendering", () => {
|
|
114
|
+
beforeAll(() => github.init({ dir: process.cwd() }))
|
|
115
|
+
|
|
116
|
+
it("renders a fix PR body in template section order with the footer", async () => {
|
|
117
|
+
const res: any = await github.handle_create_github_pr({
|
|
118
|
+
change_type: "fix",
|
|
119
|
+
title: "fix: thing",
|
|
120
|
+
root_cause: "the widget cache key collided",
|
|
121
|
+
repro: "1. open two tabs",
|
|
122
|
+
fix: "namespace the key",
|
|
123
|
+
regression_test: "added cache-key.test.ts",
|
|
124
|
+
head: "feature/x",
|
|
125
|
+
base: "epic/329",
|
|
126
|
+
dry_run: true,
|
|
127
|
+
})
|
|
128
|
+
expect(res.ok).toBe(true)
|
|
129
|
+
expect(res.dry_run).toBe(true)
|
|
130
|
+
expect(res.preview.change_type).toBe("fix")
|
|
131
|
+
const headings = prTemplateSections(res.preview.body)
|
|
132
|
+
expect(headings).toEqual(["Root cause", "Repro", "Fix", "Regression test", "Affected error codes"])
|
|
133
|
+
expect(res.preview.body).toContain(github.PR_FOOTER_CHECKLIST.split("\n")[0])
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it("infers change_type from the title when not given", async () => {
|
|
137
|
+
const res: any = await github.handle_create_github_pr({
|
|
138
|
+
title: "feat: add useTool hook",
|
|
139
|
+
summary: "new imperative WebMCP hook",
|
|
140
|
+
head: "feature/x",
|
|
141
|
+
base: "main",
|
|
142
|
+
dry_run: true,
|
|
143
|
+
})
|
|
144
|
+
expect(res.preview.change_type).toBe("feature")
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it("prepends Closes #<n> when closes_issue is set", async () => {
|
|
148
|
+
const res: any = await github.handle_create_github_pr({
|
|
149
|
+
change_type: "chore",
|
|
150
|
+
title: "chore: bump x",
|
|
151
|
+
summary: "routine bump",
|
|
152
|
+
closes_issue: 441,
|
|
153
|
+
head: "feature/x",
|
|
154
|
+
base: "main",
|
|
155
|
+
dry_run: true,
|
|
156
|
+
})
|
|
157
|
+
expect(res.preview.body.startsWith("Closes #441")).toBe(true)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it("requires a title", async () => {
|
|
161
|
+
const res: any = await github.handle_create_github_pr({ summary: "x" })
|
|
162
|
+
expect(res.ok).toBe(false)
|
|
163
|
+
expect(res.error).toMatch(/title is required/)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it("rejects head === base", async () => {
|
|
167
|
+
const res: any = await github.handle_create_github_pr({
|
|
168
|
+
title: "chore: x",
|
|
169
|
+
summary: "x",
|
|
170
|
+
head: "main",
|
|
171
|
+
base: "main",
|
|
172
|
+
dry_run: true,
|
|
173
|
+
})
|
|
174
|
+
expect(res.ok).toBe(false)
|
|
175
|
+
expect(res.error).toMatch(/same branch/)
|
|
176
|
+
})
|
|
177
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Hand-written type declaration for errors.js — that file stays plain CJS
|
|
2
|
+
// until a future source conversion (see issue #420); this exists only so
|
|
3
|
+
// require("../tools/errors.js") gets real types in test/errors.test.ts
|
|
4
|
+
// instead of `unknown`. Keep in sync with errors.js's actual shape by hand
|
|
5
|
+
// for now.
|
|
6
|
+
|
|
7
|
+
export interface ExplainErrorResult {
|
|
8
|
+
code?: string
|
|
9
|
+
error?: string
|
|
10
|
+
is_catalyst_owned?: boolean
|
|
11
|
+
category?: string
|
|
12
|
+
message?: string
|
|
13
|
+
details?: string
|
|
14
|
+
suggestedAction?: string
|
|
15
|
+
docUrl?: string
|
|
16
|
+
note?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function init(): void
|
|
20
|
+
export function handle_explain_error(args?: { code?: string }): ExplainErrorResult
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
const fs = require("fs")
|
|
4
|
+
const path = require("path")
|
|
5
|
+
|
|
6
|
+
let _index = null
|
|
7
|
+
let _loadError = null
|
|
8
|
+
|
|
9
|
+
// Prefer the copy published inside the package itself (dist/errors-index.json,
|
|
10
|
+
// see the "prepare" script) — the repo-root errors/ directory is a sibling of
|
|
11
|
+
// packages/catalyst-core, not inside it, so it never ends up in a published
|
|
12
|
+
// tarball. Fall back to the repo-root path for local dev inside this
|
|
13
|
+
// monorepo, where dist/errors-index.json may not have been generated yet.
|
|
14
|
+
const PACKAGED_INDEX_PATH = path.join(__dirname, "..", "..", "dist", "errors-index.json")
|
|
15
|
+
const MONOREPO_INDEX_PATH = path.join(__dirname, "..", "..", "..", "..", "errors", "index.json")
|
|
16
|
+
|
|
17
|
+
function init() {
|
|
18
|
+
for (const candidate of [PACKAGED_INDEX_PATH, MONOREPO_INDEX_PATH]) {
|
|
19
|
+
try {
|
|
20
|
+
_index = JSON.parse(fs.readFileSync(candidate, "utf-8"))
|
|
21
|
+
_loadError = null
|
|
22
|
+
return
|
|
23
|
+
} catch (e) {
|
|
24
|
+
_loadError = e
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
_index = {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function handle_explain_error({ code } = {}) {
|
|
31
|
+
if (!code) {
|
|
32
|
+
return { error: "code is required, e.g. 'PREFLIGHT-001'" }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (_loadError) {
|
|
36
|
+
return {
|
|
37
|
+
code,
|
|
38
|
+
error: `Could not load errors/index.json (run generateDocs.js): ${_loadError.message}`,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const entry = Object.prototype.hasOwnProperty.call(_index, code) ? _index[code] : null
|
|
43
|
+
|
|
44
|
+
if (!entry) {
|
|
45
|
+
return {
|
|
46
|
+
code,
|
|
47
|
+
is_catalyst_owned: false,
|
|
48
|
+
note: `"${code}" is not a catalyst-owned error code. It likely came from an upstream tool (Vite, Rollup, Xcode, Gradle, etc). Catalyst does not reinterpret foreign error codes — check the upstream tool's own documentation for this code.`,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
code,
|
|
54
|
+
is_catalyst_owned: true,
|
|
55
|
+
category: entry.category,
|
|
56
|
+
message: entry.message,
|
|
57
|
+
details: entry.details,
|
|
58
|
+
suggestedAction: entry.suggestedAction,
|
|
59
|
+
docUrl: entry.docUrl,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = { init, handle_explain_error }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Hand-written type declaration for github.js — that file stays plain CJS
|
|
2
|
+
// for now (same rationale as errors.d.ts / issue #420). This exists only so
|
|
3
|
+
// require("../tools/github.js") gets real types in test/github.test.ts
|
|
4
|
+
// instead of `unknown`. Keep in sync with github.js's actual exports by hand.
|
|
5
|
+
|
|
6
|
+
export interface IssueTemplate {
|
|
7
|
+
label: string
|
|
8
|
+
name: string
|
|
9
|
+
use_when: string
|
|
10
|
+
sections: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PrTemplate {
|
|
14
|
+
change_type: "fix" | "feature" | "chore"
|
|
15
|
+
name: string
|
|
16
|
+
use_when: string
|
|
17
|
+
sections: string[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ISSUE_TEMPLATES: Record<string, IssueTemplate>
|
|
21
|
+
export const PR_TEMPLATES: Record<"fix" | "feature" | "chore", PrTemplate>
|
|
22
|
+
export const PR_FOOTER_CHECKLIST: string
|
|
23
|
+
export const DEFAULT_LABELS: string[]
|
|
24
|
+
|
|
25
|
+
export function init(projectInfo?: unknown): void
|
|
26
|
+
|
|
27
|
+
export function handle_create_github_issue(args?: Record<string, unknown>): Promise<Record<string, unknown>>
|
|
28
|
+
|
|
29
|
+
export function handle_create_github_pr(args?: {
|
|
30
|
+
change_type?: "fix" | "feature" | "chore"
|
|
31
|
+
title?: string
|
|
32
|
+
body?: string
|
|
33
|
+
summary?: string
|
|
34
|
+
head?: string
|
|
35
|
+
base?: string
|
|
36
|
+
draft?: boolean
|
|
37
|
+
dry_run?: boolean
|
|
38
|
+
closes_issue?: string | number
|
|
39
|
+
project_path?: string
|
|
40
|
+
[key: string]: unknown
|
|
41
|
+
}): Promise<Record<string, unknown>>
|