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
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package io.yourname.androidproject.utils
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import org.junit.Assert.assertEquals
|
|
6
|
+
import org.junit.Assert.assertFalse
|
|
7
|
+
import org.junit.Assert.assertNull
|
|
8
|
+
import org.junit.Assert.assertTrue
|
|
9
|
+
import org.junit.Test
|
|
10
|
+
import org.mockito.kotlin.mock
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Unit tests for PushNotificationUtils (Android coverage batch 4),
|
|
14
|
+
* previously entirely untested (0/18 lines).
|
|
15
|
+
*
|
|
16
|
+
* Source-set note: this project swaps PushNotificationUtils between two
|
|
17
|
+
* source sets (noFcm/withFcm) based on buildIos/config.js's
|
|
18
|
+
* isNotificationsEnabled() check in app/build.gradle.kts. Verified
|
|
19
|
+
* empirically for this checkout: no catalyst-build.properties file exists,
|
|
20
|
+
* so isNotificationsEnabled() falls back to its default (false), and the
|
|
21
|
+
* noFcm variant is what actually compiles for testDebugUnitTest -- confirmed
|
|
22
|
+
* both by the noFcm-only compiler warnings during `./gradlew
|
|
23
|
+
* testDebugUnitTest` and by `app/build/tmp/kotlin-classes/debug` containing
|
|
24
|
+
* only io/yourname/androidproject/utils/PushNotificationUtils(.class|
|
|
25
|
+
* $Companion.class) built from the noFcm source file. This test file
|
|
26
|
+
* therefore targets app/src/noFcm/java/.../PushNotificationUtils.kt, a
|
|
27
|
+
* trivial no-op stub (Firebase disabled) whose methods only log via
|
|
28
|
+
* BridgeUtils.logInfo/logWarning (which call android.util.Log directly --
|
|
29
|
+
* safe under the mockable android.jar's isReturnDefaultValues=true, no
|
|
30
|
+
* static mocking needed) and otherwise return hardcoded
|
|
31
|
+
* false/null/empty/"none"/"" values.
|
|
32
|
+
*
|
|
33
|
+
* Out of scope: app/src/withFcm/java/.../PushNotificationUtils.kt (the real
|
|
34
|
+
* Firebase-backed implementation) is not compiled under the current build
|
|
35
|
+
* config in this checkout, so it is untestable from testDebugUnitTest here
|
|
36
|
+
* and is not covered by this file.
|
|
37
|
+
*/
|
|
38
|
+
class PushNotificationUtilsTest {
|
|
39
|
+
|
|
40
|
+
private val context: Context = mock()
|
|
41
|
+
private val utils = PushNotificationUtils()
|
|
42
|
+
|
|
43
|
+
@Test
|
|
44
|
+
fun `initializeAndGetToken always returns empty string`() {
|
|
45
|
+
assertEquals("", utils.initializeAndGetToken(context))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Test
|
|
49
|
+
fun `handleIncomingPush is a no-op with a real webView`() {
|
|
50
|
+
val webView: WebView = mock()
|
|
51
|
+
// Should not throw; no-op stub only logs.
|
|
52
|
+
utils.handleIncomingPush(webView, context, mapOf("key" to "value"))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Test
|
|
56
|
+
fun `handleIncomingPush is a no-op with a null webView`() {
|
|
57
|
+
utils.handleIncomingPush(null, context, emptyMap())
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Test
|
|
61
|
+
fun `handleTokenRefresh is a no-op with a real webView`() {
|
|
62
|
+
val webView: WebView = mock()
|
|
63
|
+
utils.handleTokenRefresh(webView, "some-token")
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Test
|
|
67
|
+
fun `handleTokenRefresh is a no-op with a null webView`() {
|
|
68
|
+
utils.handleTokenRefresh(null, "some-token")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Test
|
|
72
|
+
fun `subscribeToTopic always returns false`() {
|
|
73
|
+
assertFalse(utils.subscribeToTopic(context, "topic"))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Test
|
|
77
|
+
fun `unsubscribeFromTopic always returns false`() {
|
|
78
|
+
assertFalse(utils.unsubscribeFromTopic(context, "topic"))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Test
|
|
82
|
+
fun `getPushToken always returns null`() {
|
|
83
|
+
assertNull(utils.getPushToken(context))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Test
|
|
87
|
+
fun `getSubscribedTopics always returns an empty set`() {
|
|
88
|
+
assertTrue(utils.getSubscribedTopics(context).isEmpty())
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Test
|
|
92
|
+
fun `deleteAllPushData always returns false`() {
|
|
93
|
+
assertFalse(utils.deleteAllPushData(context))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Test
|
|
97
|
+
fun `getPushProvider always returns none`() {
|
|
98
|
+
assertEquals("none", utils.getPushProvider(context))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Test
|
|
102
|
+
fun `isAvailable always returns false`() {
|
|
103
|
+
assertFalse(utils.isAvailable(context))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@Test
|
|
107
|
+
fun `companion action and extra constants have expected values`() {
|
|
108
|
+
assertEquals(
|
|
109
|
+
"io.yourname.androidproject.PUSH_MESSAGE_RECEIVED",
|
|
110
|
+
PushNotificationUtils.ACTION_MESSAGE_RECEIVED
|
|
111
|
+
)
|
|
112
|
+
assertEquals(
|
|
113
|
+
"io.yourname.androidproject.PUSH_TOKEN_REFRESHED",
|
|
114
|
+
PushNotificationUtils.ACTION_TOKEN_REFRESHED
|
|
115
|
+
)
|
|
116
|
+
assertEquals("message_data", PushNotificationUtils.EXTRA_MESSAGE_DATA)
|
|
117
|
+
assertEquals("token", PushNotificationUtils.EXTRA_TOKEN)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package io.yourname.androidproject.utils
|
|
2
|
+
|
|
3
|
+
import androidx.core.graphics.Insets
|
|
4
|
+
import androidx.core.view.WindowInsetsCompat
|
|
5
|
+
import org.junit.Assert.assertEquals
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
import org.mockito.kotlin.doReturn
|
|
8
|
+
import org.mockito.kotlin.mock
|
|
9
|
+
import org.mockito.kotlin.whenever
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Unit tests for SafeAreaUtils.fromWindowInsets (Android coverage batch
|
|
13
|
+
* 3), previously entirely untested (0/17 lines).
|
|
14
|
+
*
|
|
15
|
+
* androidx.core.graphics.Insets and WindowInsetsCompat are androidx
|
|
16
|
+
* library classes (not android.jar SDK stubs) -- Insets.of(l,t,r,b) is a
|
|
17
|
+
* real static factory that actually assigns its fields, so value
|
|
18
|
+
* assertions on the returned SafeAreaInsets are meaningful here (unlike
|
|
19
|
+
* android.graphics.RectF in ViewfinderMapperTest, which IS an android.jar
|
|
20
|
+
* stub whose constructor never runs).
|
|
21
|
+
*
|
|
22
|
+
* Deliberately out of scope, per the task: getSafeAreaInsets(window,
|
|
23
|
+
* rootView, edgeToEdgeEnabled) is a thin passthrough that calls
|
|
24
|
+
* ViewCompat.getRootWindowInsets(...) -- a static androidx method --
|
|
25
|
+
* before delegating to fromWindowInsets. Testing it would require
|
|
26
|
+
* mockStatic(ViewCompat), which the task explicitly says to skip; only
|
|
27
|
+
* fromWindowInsets is covered.
|
|
28
|
+
*/
|
|
29
|
+
class SafeAreaUtilsTest {
|
|
30
|
+
|
|
31
|
+
private fun windowInsetsCompatWith(systemBars: Insets, cutout: Insets = Insets.NONE): WindowInsetsCompat {
|
|
32
|
+
return mock {
|
|
33
|
+
on { getInsets(WindowInsetsCompat.Type.systemBars()) } doReturn systemBars
|
|
34
|
+
on { getInsets(WindowInsetsCompat.Type.displayCutout()) } doReturn cutout
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ============================================================
|
|
39
|
+
// Null input
|
|
40
|
+
// ============================================================
|
|
41
|
+
|
|
42
|
+
@Test
|
|
43
|
+
fun `fromWindowInsets returns ZERO when insets is null`() {
|
|
44
|
+
val result = SafeAreaUtils.fromWindowInsets(null, edgeToEdgeEnabled = true)
|
|
45
|
+
assertEquals(SafeAreaInsets.ZERO, result)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============================================================
|
|
49
|
+
// edge-to-edge disabled -- system bars only
|
|
50
|
+
// ============================================================
|
|
51
|
+
|
|
52
|
+
@Test
|
|
53
|
+
fun `fromWindowInsets with edge-to-edge disabled returns system bar insets directly`() {
|
|
54
|
+
val systemBars = Insets.of(10, 20, 30, 40)
|
|
55
|
+
val windowInsets = windowInsetsCompatWith(systemBars)
|
|
56
|
+
|
|
57
|
+
val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = false)
|
|
58
|
+
|
|
59
|
+
assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Test
|
|
63
|
+
fun `fromWindowInsets with edge-to-edge disabled ignores the display cutout`() {
|
|
64
|
+
val systemBars = Insets.of(10, 20, 30, 40)
|
|
65
|
+
val cutout = Insets.of(100, 100, 100, 100)
|
|
66
|
+
val windowInsets = windowInsetsCompatWith(systemBars, cutout)
|
|
67
|
+
|
|
68
|
+
val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = false)
|
|
69
|
+
|
|
70
|
+
assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ============================================================
|
|
74
|
+
// edge-to-edge enabled -- max(system bars, cutout) per edge
|
|
75
|
+
// ============================================================
|
|
76
|
+
|
|
77
|
+
@Test
|
|
78
|
+
fun `fromWindowInsets with edge-to-edge enabled takes the max of system bars and cutout per edge`() {
|
|
79
|
+
val systemBars = Insets.of(10, 50, 30, 5)
|
|
80
|
+
val cutout = Insets.of(0, 20, 60, 15)
|
|
81
|
+
val windowInsets = windowInsetsCompatWith(systemBars, cutout)
|
|
82
|
+
|
|
83
|
+
val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = true)
|
|
84
|
+
|
|
85
|
+
// left: max(10, 0)=10, top: max(50, 20)=50, right: max(30, 60)=60, bottom: max(5, 15)=15
|
|
86
|
+
assertEquals(SafeAreaInsets(top = 50, right = 60, bottom = 15, left = 10), result)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Test
|
|
90
|
+
fun `fromWindowInsets with edge-to-edge enabled and a zero cutout equals the system bars`() {
|
|
91
|
+
val systemBars = Insets.of(10, 20, 30, 40)
|
|
92
|
+
val windowInsets = windowInsetsCompatWith(systemBars, Insets.NONE)
|
|
93
|
+
|
|
94
|
+
val result = SafeAreaUtils.fromWindowInsets(windowInsets, edgeToEdgeEnabled = true)
|
|
95
|
+
|
|
96
|
+
assertEquals(SafeAreaInsets(top = 20, right = 30, bottom = 40, left = 10), result)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============================================================
|
|
100
|
+
// SafeAreaInsets.toMap()
|
|
101
|
+
// ============================================================
|
|
102
|
+
|
|
103
|
+
@Test
|
|
104
|
+
fun `toMap exposes all four edges by name`() {
|
|
105
|
+
val insets = SafeAreaInsets(top = 1, right = 2, bottom = 3, left = 4)
|
|
106
|
+
assertEquals(mapOf("top" to 1, "right" to 2, "bottom" to 3, "left" to 4), insets.toMap())
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -12,6 +12,23 @@ webkit = "1.13.0"
|
|
|
12
12
|
googleServices = "4.4.0"
|
|
13
13
|
androidxCredentials = "1.3.0"
|
|
14
14
|
googleId = "1.1.1"
|
|
15
|
+
# JVM unit test coverage (Tier 1, mirrors the CatalystCoreLogic llvm-cov
|
|
16
|
+
# setup on iOS — see #432/#413). 0.8.12 is the latest 0.8.x line still
|
|
17
|
+
# compatible with this project's Gradle 8.13 / AGP 8.11.1 without pulling
|
|
18
|
+
# in Jacoco's newer bytecode-instrumentation changes meant for JDK 21+
|
|
19
|
+
# language features this app doesn't use.
|
|
20
|
+
jacoco = "0.8.12"
|
|
21
|
+
# Test-only deps for #413 (Tier 1 Android unit tests). kotlinReflect is
|
|
22
|
+
# pinned ahead of the project's forced 2.0.21 Kotlin compiler version
|
|
23
|
+
# solely to satisfy mockito-kotlin 6.x's own kotlin-reflect requirement
|
|
24
|
+
# (>=2.1.20) — see the resolutionStrategy override in app/build.gradle.kts.
|
|
25
|
+
# kotlinxCoroutinesTest is pinned to the 1.10.x line (not the newer 1.11.x)
|
|
26
|
+
# because 1.11.x requires Kotlin 2.2.20, which is out of scope here; 1.10.x
|
|
27
|
+
# is the latest line still JVM-compatible with Kotlin 2.1.x.
|
|
28
|
+
mockitoCore = "5.23.0"
|
|
29
|
+
mockitoKotlin = "6.3.0"
|
|
30
|
+
kotlinReflect = "2.1.20"
|
|
31
|
+
kotlinxCoroutinesTest = "1.10.2"
|
|
15
32
|
|
|
16
33
|
[libraries]
|
|
17
34
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
|
@@ -25,8 +42,17 @@ androidx-webkit = { group = "androidx.webkit", name = "webkit", version.ref = "w
|
|
|
25
42
|
androidx-credentials = { group = "androidx.credentials", name = "credentials", version.ref = "androidxCredentials" }
|
|
26
43
|
androidx-credentials-play-services-auth = { group = "androidx.credentials", name = "credentials-play-services-auth", version.ref = "androidxCredentials" }
|
|
27
44
|
googleid = { group = "com.google.android.libraries.identity.googleid", name = "googleid", version.ref = "googleId" }
|
|
45
|
+
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockitoCore" }
|
|
46
|
+
mockito-kotlin = { group = "org.mockito.kotlin", name = "mockito-kotlin", version.ref = "mockitoKotlin" }
|
|
47
|
+
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlinReflect" }
|
|
48
|
+
kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTest" }
|
|
28
49
|
|
|
29
50
|
[plugins]
|
|
30
51
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
|
52
|
+
# Same AGP version as android-application -- needed so the optional
|
|
53
|
+
# :catalyst-ai library module (wired in settings.gradle.kts when the npm
|
|
54
|
+
# package is installed) can apply `id("com.android.library")` without
|
|
55
|
+
# declaring its own version.
|
|
56
|
+
android-library = { id = "com.android.library", version.ref = "agp" }
|
|
31
57
|
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
|
32
58
|
google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" }
|
|
@@ -34,12 +34,15 @@ dependencyResolutionManagement {
|
|
|
34
34
|
rootProject.name = "Catalyst Application"
|
|
35
35
|
include(":app")
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
// The
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// catalyst-ai — include when the npm package is installed.
|
|
38
|
+
// The package ships an /android library module (namespace io.catalyst.nativeai)
|
|
39
|
+
// for native AI; wire it here so Gradle picks it up. After running:
|
|
40
|
+
// npm install catalyst-ai && npm run sync-packages -- --packages ai
|
|
41
|
+
// (an `ai.enabled=true` build syncs it automatically -- see
|
|
42
|
+
// buildAndroid/index.js:syncAIPackageIfEnabled). Also set ai.enabled=true in
|
|
43
|
+
// your app config to enable useLegacyPackaging for GPU dlopen().
|
|
44
|
+
val catalystAiDir = File(rootDir, "../node_modules/catalyst-ai/android")
|
|
45
|
+
if (catalystAiDir.exists()) {
|
|
46
|
+
include(":catalyst-ai")
|
|
47
|
+
project(":catalyst-ai").projectDir = catalystAiDir
|
|
45
48
|
}
|
|
@@ -4,7 +4,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
4
4
|
var _path = _interopRequireDefault(require("path"));
|
|
5
5
|
var _child_process = require("child_process");
|
|
6
6
|
var _utils = require("./utils.js");
|
|
7
|
-
var
|
|
7
|
+
var _terminalProgress = _interopRequireDefault(require("./terminalProgress.js"));
|
|
8
8
|
var _setupServer = require("./setupServer.js");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const catalystCorePath = _path.default.dirname(require.resolve("catalyst-core/package.json"));
|
|
@@ -27,7 +27,7 @@ const progressPaddingConfig = {
|
|
|
27
27
|
errorPaddingLeft: 6,
|
|
28
28
|
bottomMargin: 2
|
|
29
29
|
};
|
|
30
|
-
const progress = new
|
|
30
|
+
const progress = new _terminalProgress.default(steps, "Catalyst Universal Android Setup", progressPaddingConfig);
|
|
31
31
|
async function checkJavaInstallation() {
|
|
32
32
|
try {
|
|
33
33
|
(0, _utils.runCommand)("java -version");
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
declare class WebBridge {
|
|
2
|
+
/**
|
|
3
|
+
* Registered callback handlers, keyed by native interface name.
|
|
4
|
+
*
|
|
5
|
+
* Declared without an initializer so it erases to nothing at compile time —
|
|
6
|
+
* the constructor below remains the only thing that assigns it, exactly as
|
|
7
|
+
* before this file was converted.
|
|
8
|
+
*/
|
|
9
|
+
handlers: Map<string, (data: any) => void>;
|
|
10
|
+
/** True once {@link WebBridge.init} has attached this instance to `window`. */
|
|
11
|
+
initialized: boolean;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Log initialization info
|
|
15
|
+
*/
|
|
16
|
+
_logInitialization(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Static method to initialize WebBridge on window object
|
|
19
|
+
*/
|
|
20
|
+
static init: () => any;
|
|
21
|
+
/**
|
|
22
|
+
* Main callback handler called by native platforms
|
|
23
|
+
* @param {string} interfaceName - The callback interface name
|
|
24
|
+
* @param {any} data - Data from native platform
|
|
25
|
+
*/
|
|
26
|
+
callback: (interfaceName: any, data: any) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Register a callback handler for a native interface
|
|
29
|
+
* @param {string} interfaceName - The callback interface name (from NATIVE_CALLBACKS)
|
|
30
|
+
* @param {function} callback - The callback function to execute
|
|
31
|
+
* @returns {boolean} - Success status
|
|
32
|
+
*/
|
|
33
|
+
register: (interfaceName: any, callback: any) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Unregister a callback handler
|
|
36
|
+
* @param {string} interfaceName - The callback interface name to unregister
|
|
37
|
+
* @returns {boolean} - Success status
|
|
38
|
+
*/
|
|
39
|
+
unregister: (interfaceName: any) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a callback interface is registered
|
|
42
|
+
* @param {string} interfaceName - The callback interface name
|
|
43
|
+
* @returns {boolean} - Registration status
|
|
44
|
+
*/
|
|
45
|
+
isRegistered: (interfaceName: any) => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get all registered callback interfaces
|
|
48
|
+
* @returns {string[]} - Array of registered interface names
|
|
49
|
+
*/
|
|
50
|
+
getRegisteredInterfaces: () => string[];
|
|
51
|
+
/**
|
|
52
|
+
* Get handler for a specific interface (for debugging)
|
|
53
|
+
* @param {string} interfaceName - The callback interface name
|
|
54
|
+
* @returns {function|null} - The registered handler or null
|
|
55
|
+
*/
|
|
56
|
+
getHandler: (interfaceName: any) => (data: any) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Clear all registered handlers
|
|
59
|
+
*/
|
|
60
|
+
clearAll: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Debug method to log current state
|
|
63
|
+
*/
|
|
64
|
+
debug: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Test callback functionality (for debugging)
|
|
67
|
+
* @param {string} interfaceName - The callback interface to test
|
|
68
|
+
* @param {any} testData - Test data to pass
|
|
69
|
+
*/
|
|
70
|
+
testCallback: (interfaceName: any, testData?: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Request haptic feedback
|
|
73
|
+
* @param {string} feedbackType - Type of haptic feedback (VIRTUAL_KEY, LONG_PRESS, DEFAULT)
|
|
74
|
+
* @returns {Promise<Object>} - Promise that resolves with haptic feedback result or rejects with error
|
|
75
|
+
*/
|
|
76
|
+
requestHapticFeedback: (feedbackType?: string) => Promise<unknown>;
|
|
77
|
+
/**
|
|
78
|
+
* Open camera and capture image
|
|
79
|
+
* @param {Object} options - Camera options (quality, format, cameraDevice, flashMode, allowEditing)
|
|
80
|
+
* @returns {Promise<Object>} - Promise that resolves with camera result or rejects with error
|
|
81
|
+
*/
|
|
82
|
+
openCamera: (options?: {}) => Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* Request camera permission
|
|
85
|
+
* @param {Object} config - Permission configuration (includeDetails)
|
|
86
|
+
* @returns {Promise<Object>} - Promise that resolves with permission status or rejects with error
|
|
87
|
+
*/
|
|
88
|
+
requestCameraPermission: (config?: {}) => Promise<any>;
|
|
89
|
+
getDeviceInfoFromLegacyBridge: (parseDeviceInfo: any) => Promise<unknown>;
|
|
90
|
+
getDeviceInfoFromPluginBridge: (parseDeviceInfo: any) => Promise<unknown>;
|
|
91
|
+
shouldFallbackToLegacyDeviceInfo: (error: any) => boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Get device information
|
|
94
|
+
* @returns {Promise<Object>} - Promise that resolves with device info or rejects with error
|
|
95
|
+
*/
|
|
96
|
+
getDeviceInfo: () => Promise<unknown>;
|
|
97
|
+
}
|
|
98
|
+
export default WebBridge;
|
|
@@ -8,6 +8,7 @@ var _NativeInterfaces = require("./constants/NativeInterfaces.js");
|
|
|
8
8
|
var _NativeBridge = _interopRequireDefault(require("./utils/NativeBridge.js"));
|
|
9
9
|
var _CameraUtils = _interopRequireDefault(require("./utils/CameraUtils.js"));
|
|
10
10
|
var _PluginBridge = _interopRequireDefault(require("../plugin-bridge/PluginBridge.js"));
|
|
11
|
+
var _index = require("../../errors/index.js");
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
14
|
const DEVICE_INFO_PLUGIN = {
|
|
@@ -47,6 +48,16 @@ const createDeviceInfoError = (payload, fallbackMessage) => {
|
|
|
47
48
|
return error;
|
|
48
49
|
};
|
|
49
50
|
class WebBridge {
|
|
51
|
+
/**
|
|
52
|
+
* Registered callback handlers, keyed by native interface name.
|
|
53
|
+
*
|
|
54
|
+
* Declared without an initializer so it erases to nothing at compile time —
|
|
55
|
+
* the constructor below remains the only thing that assigns it, exactly as
|
|
56
|
+
* before this file was converted.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/** True once {@link WebBridge.init} has attached this instance to `window`. */
|
|
60
|
+
|
|
50
61
|
constructor() {
|
|
51
62
|
this.handlers = new Map();
|
|
52
63
|
this.initialized = false;
|
|
@@ -69,10 +80,15 @@ class WebBridge {
|
|
|
69
80
|
*/
|
|
70
81
|
static init = () => {
|
|
71
82
|
if (typeof window === "undefined") {
|
|
72
|
-
console.error(
|
|
83
|
+
console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INIT_FAILED, {
|
|
84
|
+
details: "WebBridge.init() was called outside a browser environment (no `window`)."
|
|
85
|
+
})));
|
|
73
86
|
return null;
|
|
74
87
|
}
|
|
75
88
|
if (window.WebBridge) {
|
|
89
|
+
// Not a failure — the bridge is already up and working, just return it.
|
|
90
|
+
// No code here: RUNTIME-NATIVE-022 means init genuinely failed, which
|
|
91
|
+
// this path is not.
|
|
76
92
|
console.warn("🌉 WebBridge already initialized!");
|
|
77
93
|
return window.WebBridge;
|
|
78
94
|
}
|
|
@@ -109,19 +125,27 @@ class WebBridge {
|
|
|
109
125
|
|
|
110
126
|
// Validate interface
|
|
111
127
|
if (!(0, _NativeInterfaces.isValidCallback)(interfaceName)) {
|
|
112
|
-
console.error(
|
|
128
|
+
console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_CALLBACK, {
|
|
129
|
+
details: `Received "${interfaceName}", which is not in the registered NATIVE_CALLBACKS list.`
|
|
130
|
+
})));
|
|
113
131
|
console.log("🌉 Available callbacks:", _NativeInterfaces.ALL_CALLBACKS);
|
|
114
132
|
return;
|
|
115
133
|
}
|
|
116
134
|
if (!this.handlers.has(interfaceName)) {
|
|
117
|
-
console.warn(
|
|
135
|
+
console.warn((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_HANDLER_NOT_REGISTERED, {
|
|
136
|
+
details: `No handler registered for interface "${interfaceName}".`
|
|
137
|
+
})));
|
|
118
138
|
return;
|
|
119
139
|
}
|
|
120
140
|
try {
|
|
121
141
|
const handler = this.handlers.get(interfaceName);
|
|
122
142
|
handler(data);
|
|
123
143
|
} catch (error) {
|
|
124
|
-
|
|
144
|
+
const wrapped = (0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_HANDLER_THREW, {
|
|
145
|
+
details: `The handler registered for "${interfaceName}" threw.`,
|
|
146
|
+
cause: error
|
|
147
|
+
});
|
|
148
|
+
console.error((0, _index.formatError)(wrapped));
|
|
125
149
|
|
|
126
150
|
// In development, provide more helpful error info
|
|
127
151
|
if (process.env.NODE_ENV === "development") {
|
|
@@ -143,13 +167,17 @@ class WebBridge {
|
|
|
143
167
|
register = (interfaceName, callback) => {
|
|
144
168
|
// Validate callback function
|
|
145
169
|
if (typeof callback !== "function") {
|
|
146
|
-
console.error(
|
|
170
|
+
console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_REGISTRATION, {
|
|
171
|
+
details: `register("${interfaceName}", ...) was called with a non-function callback (got ${typeof callback}).`
|
|
172
|
+
})));
|
|
147
173
|
return false;
|
|
148
174
|
}
|
|
149
175
|
|
|
150
176
|
// Validate interface name
|
|
151
177
|
if (!(0, _NativeInterfaces.isValidCallback)(interfaceName)) {
|
|
152
|
-
console.error(
|
|
178
|
+
console.error((0, _index.formatError)((0, _index.createError)(_index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_INVALID_REGISTRATION, {
|
|
179
|
+
details: `register() was called with "${interfaceName}", which is not a valid callback interface.`
|
|
180
|
+
})));
|
|
153
181
|
console.log("🌉 Available callback interfaces:", _NativeInterfaces.ALL_CALLBACKS);
|
|
154
182
|
return false;
|
|
155
183
|
}
|
|
@@ -391,6 +419,12 @@ class WebBridge {
|
|
|
391
419
|
}
|
|
392
420
|
}));
|
|
393
421
|
try {
|
|
422
|
+
// `as any` only because PluginBridge is still plain JS: TypeScript
|
|
423
|
+
// infers its `emit({ pluginId, command, data = null } = {})` shape
|
|
424
|
+
// from the `= {}` default alone and concludes it accepts only
|
|
425
|
+
// `{ data?: any }`, rejecting the two keys the body itself reads.
|
|
426
|
+
// The assertion erases at compile time — the emitted call is byte
|
|
427
|
+
// for byte the one this file made before the conversion.
|
|
394
428
|
_PluginBridge.default.emit({
|
|
395
429
|
pluginId: DEVICE_INFO_PLUGIN.pluginId,
|
|
396
430
|
command: DEVICE_INFO_PLUGIN.command
|