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
|
@@ -3,172 +3,87 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.translateError = exports.isDevelopment = exports.createStandardError = exports.
|
|
6
|
+
exports.translateError = exports.isDevelopment = exports.createStandardError = exports.ERROR_CODES = void 0;
|
|
7
|
+
var _index = require("../../errors/index.js");
|
|
7
8
|
/**
|
|
8
9
|
* Standardized Error System for Catalyst Framework
|
|
9
10
|
* Translates native errors into web developer-friendly messages
|
|
11
|
+
*
|
|
12
|
+
* Codes/definitions now live in ../../errors/registry.js as RUNTIME-NATIVE-xxx
|
|
13
|
+
* (shared taxonomy across CLI/build/server/native, see RFC #155). This module
|
|
14
|
+
* keeps its own ERROR_CODES map for backwards-compatible imports, aliased to
|
|
15
|
+
* the shared codes, plus the native-error string-sniffing logic in
|
|
16
|
+
* translateError(), which is the one piece of real value here.
|
|
10
17
|
*/
|
|
11
18
|
|
|
12
|
-
//
|
|
13
|
-
const ERROR_CATEGORIES = exports.ERROR_CATEGORIES = {
|
|
14
|
-
PERMISSION: "PERMISSION",
|
|
15
|
-
NETWORK: "NETWORK",
|
|
16
|
-
FILE_SYSTEM: "FILE_SYSTEM",
|
|
17
|
-
USER_ACTION: "USER_ACTION",
|
|
18
|
-
VALIDATION: "VALIDATION",
|
|
19
|
-
SYSTEM: "SYSTEM",
|
|
20
|
-
UNKNOWN: "UNKNOWN"
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// Standardized error codes
|
|
19
|
+
// Backwards-compatible local names, aliased to the shared RUNTIME-NATIVE-xxx codes.
|
|
24
20
|
const ERROR_CODES = exports.ERROR_CODES = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// System errors
|
|
43
|
-
BRIDGE_UNAVAILABLE: "BRIDGE_UNAVAILABLE",
|
|
44
|
-
FEATURE_UNSUPPORTED: "FEATURE_UNSUPPORTED",
|
|
45
|
-
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
46
|
-
// Camera specific errors
|
|
47
|
-
CAMERA_UNAVAILABLE: "CAMERA_UNAVAILABLE",
|
|
48
|
-
CAMERA_IN_USE: "CAMERA_IN_USE"
|
|
21
|
+
PERMISSION_DENIED: _index.ERROR_CODES.RUNTIME_NATIVE_PERMISSION_DENIED,
|
|
22
|
+
PERMISSION_REQUIRED: _index.ERROR_CODES.RUNTIME_NATIVE_PERMISSION_REQUIRED,
|
|
23
|
+
NETWORK_UNAVAILABLE: _index.ERROR_CODES.RUNTIME_NATIVE_NETWORK_UNAVAILABLE,
|
|
24
|
+
DOWNLOAD_FAILED: _index.ERROR_CODES.RUNTIME_NATIVE_DOWNLOAD_FAILED,
|
|
25
|
+
FILE_NOT_FOUND: _index.ERROR_CODES.RUNTIME_NATIVE_FILE_NOT_FOUND,
|
|
26
|
+
FILE_TOO_LARGE: _index.ERROR_CODES.RUNTIME_NATIVE_FILE_TOO_LARGE,
|
|
27
|
+
STORAGE_FULL: _index.ERROR_CODES.RUNTIME_NATIVE_STORAGE_FULL,
|
|
28
|
+
FILE_CORRUPTED: _index.ERROR_CODES.RUNTIME_NATIVE_FILE_CORRUPTED,
|
|
29
|
+
OPERATION_CANCELLED: _index.ERROR_CODES.RUNTIME_NATIVE_OPERATION_CANCELLED,
|
|
30
|
+
NO_FILE_SELECTED: _index.ERROR_CODES.RUNTIME_NATIVE_NO_FILE_SELECTED,
|
|
31
|
+
INVALID_FILE_TYPE: _index.ERROR_CODES.RUNTIME_NATIVE_INVALID_FILE_TYPE,
|
|
32
|
+
INVALID_PARAMETERS: _index.ERROR_CODES.RUNTIME_NATIVE_INVALID_PARAMETERS,
|
|
33
|
+
BRIDGE_UNAVAILABLE: _index.ERROR_CODES.RUNTIME_NATIVE_BRIDGE_UNAVAILABLE,
|
|
34
|
+
FEATURE_UNSUPPORTED: _index.ERROR_CODES.RUNTIME_NATIVE_FEATURE_UNSUPPORTED,
|
|
35
|
+
INTERNAL_ERROR: _index.ERROR_CODES.RUNTIME_NATIVE_INTERNAL_ERROR,
|
|
36
|
+
CAMERA_UNAVAILABLE: _index.ERROR_CODES.RUNTIME_NATIVE_CAMERA_UNAVAILABLE,
|
|
37
|
+
CAMERA_IN_USE: _index.ERROR_CODES.RUNTIME_NATIVE_CAMERA_IN_USE
|
|
49
38
|
};
|
|
50
39
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
category: ERROR_CATEGORIES.FILE_SYSTEM,
|
|
76
|
-
defaultMessage: "File not found",
|
|
77
|
-
defaultDetails: "The requested file could not be located",
|
|
78
|
-
recoverable: false,
|
|
79
|
-
suggestedAction: "The file may have been moved or deleted"
|
|
80
|
-
},
|
|
81
|
-
[ERROR_CODES.FILE_TOO_LARGE]: {
|
|
82
|
-
category: ERROR_CATEGORIES.VALIDATION,
|
|
83
|
-
defaultMessage: "File too large",
|
|
84
|
-
defaultDetails: "File exceeds the maximum size limit",
|
|
85
|
-
recoverable: true,
|
|
86
|
-
suggestedAction: "Choose a smaller file or compress the current file"
|
|
87
|
-
},
|
|
88
|
-
[ERROR_CODES.STORAGE_FULL]: {
|
|
89
|
-
category: ERROR_CATEGORIES.FILE_SYSTEM,
|
|
90
|
-
defaultMessage: "Storage full",
|
|
91
|
-
defaultDetails: "Device storage is full and cannot save the file",
|
|
92
|
-
recoverable: true,
|
|
93
|
-
suggestedAction: "Free up some storage space and try again"
|
|
94
|
-
},
|
|
95
|
-
[ERROR_CODES.OPERATION_CANCELLED]: {
|
|
96
|
-
category: ERROR_CATEGORIES.USER_ACTION,
|
|
97
|
-
defaultMessage: "Operation cancelled",
|
|
98
|
-
defaultDetails: "The operation was cancelled by the user",
|
|
99
|
-
recoverable: true,
|
|
100
|
-
suggestedAction: "Try again if you want to complete the operation"
|
|
101
|
-
},
|
|
102
|
-
[ERROR_CODES.INVALID_FILE_TYPE]: {
|
|
103
|
-
category: ERROR_CATEGORIES.VALIDATION,
|
|
104
|
-
defaultMessage: "Invalid file type",
|
|
105
|
-
defaultDetails: "The selected file type is not supported",
|
|
106
|
-
recoverable: true,
|
|
107
|
-
suggestedAction: "Choose a file with a supported format"
|
|
108
|
-
},
|
|
109
|
-
[ERROR_CODES.BRIDGE_UNAVAILABLE]: {
|
|
110
|
-
category: ERROR_CATEGORIES.SYSTEM,
|
|
111
|
-
defaultMessage: "Native feature unavailable",
|
|
112
|
-
defaultDetails: "The native bridge is not available or not initialized",
|
|
113
|
-
recoverable: false,
|
|
114
|
-
suggestedAction: "Use web fallback if available"
|
|
115
|
-
},
|
|
116
|
-
[ERROR_CODES.FEATURE_UNSUPPORTED]: {
|
|
117
|
-
category: ERROR_CATEGORIES.SYSTEM,
|
|
118
|
-
defaultMessage: "Feature not supported",
|
|
119
|
-
defaultDetails: "This feature is not supported on the current platform",
|
|
120
|
-
recoverable: false,
|
|
121
|
-
suggestedAction: "Try using an alternative method or device"
|
|
122
|
-
},
|
|
123
|
-
[ERROR_CODES.CAMERA_UNAVAILABLE]: {
|
|
124
|
-
category: ERROR_CATEGORIES.SYSTEM,
|
|
125
|
-
defaultMessage: "Camera unavailable",
|
|
126
|
-
defaultDetails: "Camera hardware is not available or accessible",
|
|
127
|
-
recoverable: false,
|
|
128
|
-
suggestedAction: "Check if your device has a camera and try again"
|
|
129
|
-
},
|
|
130
|
-
[ERROR_CODES.CAMERA_IN_USE]: {
|
|
131
|
-
category: ERROR_CATEGORIES.SYSTEM,
|
|
132
|
-
defaultMessage: "Camera in use",
|
|
133
|
-
defaultDetails: "Camera is being used by another application",
|
|
134
|
-
recoverable: true,
|
|
135
|
-
suggestedAction: "Close other camera apps and try again"
|
|
136
|
-
},
|
|
137
|
-
[ERROR_CODES.INTERNAL_ERROR]: {
|
|
138
|
-
category: ERROR_CATEGORIES.UNKNOWN,
|
|
139
|
-
defaultMessage: "An unexpected error occurred",
|
|
140
|
-
defaultDetails: "An internal error occurred while processing the request",
|
|
141
|
-
recoverable: true,
|
|
142
|
-
suggestedAction: "Try again or contact support if the problem persists"
|
|
143
|
-
}
|
|
144
|
-
};
|
|
40
|
+
/** One of the {@link ERROR_CODES} values — a shared `RUNTIME-NATIVE-xxx` code. */
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Broad grouping an error code belongs to.
|
|
44
|
+
*
|
|
45
|
+
* Categories are owned by the shared registry (`../../errors/registry.js`) and
|
|
46
|
+
* are the code's prefix — every code this module aliases is `"RUNTIME-NATIVE"`.
|
|
47
|
+
* `"UNKNOWN"` is what the registry substitutes for a code it does not own.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The error object every hook reports through its `error` key.
|
|
52
|
+
*
|
|
53
|
+
* Now an alias of the shared {@link CatalystError} (a real `Error` subclass)
|
|
54
|
+
* rather than a plain object literal: the shared error system owns the shape.
|
|
55
|
+
* Compared with the pre-merge local shape, `message`/`details`/`code` survive,
|
|
56
|
+
* `category` is a registry category string, `action` is now `suggestedAction`,
|
|
57
|
+
* `nativeError` is now the standard `cause`, and `recoverable`/`timestamp` are
|
|
58
|
+
* gone — the registry does not track recoverability, and verbose/debug
|
|
59
|
+
* formatting stamps its own timestamp at print time.
|
|
60
|
+
*
|
|
61
|
+
* Two hooks predate this contract and still report a plain string: `error` on
|
|
62
|
+
* `useDeviceInfo` and `useNetworkStatus` stays a string until 2.0.
|
|
63
|
+
*/
|
|
145
64
|
|
|
146
65
|
/**
|
|
147
|
-
* Create a standardized error object
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @param
|
|
151
|
-
* @param
|
|
152
|
-
* @
|
|
66
|
+
* Create a standardized error object (CatalystError instance) for a
|
|
67
|
+
* RUNTIME-NATIVE-xxx code, with the native error attached as `cause`.
|
|
68
|
+
*
|
|
69
|
+
* @param code - Error code from ERROR_CODES
|
|
70
|
+
* @param userMessage - Custom user-friendly message (optional)
|
|
71
|
+
* @param nativeError - Original native error for debugging
|
|
72
|
+
* @param customDetails - Custom details (optional)
|
|
73
|
+
* @returns Standardized error object
|
|
153
74
|
*/
|
|
154
75
|
const createStandardError = (code, userMessage = null, nativeError = null, customDetails = null) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
details: customDetails || errorInfo.defaultDetails,
|
|
161
|
-
recoverable: errorInfo.recoverable,
|
|
162
|
-
action: errorInfo.suggestedAction,
|
|
163
|
-
nativeError: nativeError,
|
|
164
|
-
timestamp: new Date().toISOString()
|
|
165
|
-
};
|
|
76
|
+
return (0, _index.createError)(code, {
|
|
77
|
+
message: userMessage,
|
|
78
|
+
details: customDetails,
|
|
79
|
+
cause: nativeError
|
|
80
|
+
});
|
|
166
81
|
};
|
|
167
82
|
|
|
168
83
|
/**
|
|
169
84
|
* Translate native error to standardized error
|
|
170
|
-
* @param
|
|
171
|
-
* @returns
|
|
85
|
+
* @param nativeError - Native error from Android/iOS
|
|
86
|
+
* @returns Standardized error object
|
|
172
87
|
*/
|
|
173
88
|
exports.createStandardError = createStandardError;
|
|
174
89
|
const translateError = nativeError => {
|
|
@@ -254,7 +169,7 @@ const translateError = nativeError => {
|
|
|
254
169
|
|
|
255
170
|
/**
|
|
256
171
|
* Check if development mode is enabled
|
|
257
|
-
* @returns
|
|
172
|
+
* @returns True if in development mode
|
|
258
173
|
*/
|
|
259
174
|
exports.translateError = translateError;
|
|
260
175
|
const isDevelopment = () => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { useAI } from "./useAI.js";
|
|
2
|
+
export { useGoogleSignIn } from "./useGoogleSignIn.js";
|
|
3
|
+
export { useCamera, requestCameraPermission, useCameraPermission } from "./useCamera.js";
|
|
4
|
+
export { useIntent } from "./useIntent.js";
|
|
5
|
+
export { useFilePicker } from "./useFilePicker.js";
|
|
6
|
+
export { useHapticFeedback, requestHapticFeedback } from "./useHapticFeedback.js";
|
|
7
|
+
export { useNotification, useNotificationPermission, requestNotificationPermission, } from "./useNotification.js";
|
|
8
|
+
export { useNetworkStatus } from "./useNetworkStatus.js";
|
|
9
|
+
export { useDeviceInfo } from "./useDeviceInfo.js";
|
|
10
|
+
export { useDataProtection } from "./useDataProtection.js";
|
|
11
|
+
export { useSafeArea } from "./useSafeArea.js";
|
|
12
|
+
export { useVideoStream } from "./useVideoStream.js";
|
|
13
|
+
export { useNativeTransition } from "./useNativeTransition.js";
|
|
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "requestNotificationPermission", {
|
|
|
21
21
|
return _useNotification.requestNotificationPermission;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "sanitizeFilePickerOptions", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _useFilePicker.sanitizeFilePickerOptions;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
24
|
Object.defineProperty(exports, "useAI", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useAI(options?: any): any;
|
|
@@ -45,6 +45,8 @@ const _pkg = typeof window !== "undefined" && (typeof __CATALYST_PACKAGES__ ===
|
|
|
45
45
|
// provider: "transformers" → useWebAI (catalyst-ai)
|
|
46
46
|
// "native" → useNativeAI (catalyst-ai, falls back to useCloudAI if bridge unavailable)
|
|
47
47
|
// anything else → useCloudAI (catalyst-ai, default)
|
|
48
|
+
// The shape of this hook is owned by the catalyst-ai package and sits outside
|
|
49
|
+
// the native hook contract entirely, so its options and result stay loose here.
|
|
48
50
|
function useAI(options = {}) {
|
|
49
51
|
const {
|
|
50
52
|
provider
|
|
@@ -82,7 +84,7 @@ function emptyHook() {
|
|
|
82
84
|
metrics: null,
|
|
83
85
|
isLocal: false,
|
|
84
86
|
isNative: false,
|
|
85
|
-
isWeb:
|
|
87
|
+
isWeb: true,
|
|
86
88
|
generate: () => {},
|
|
87
89
|
cancel: () => {},
|
|
88
90
|
reset: () => {},
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { HookProgress, HookState, WebFallbackOptions, WebFallbackState } from "../useBaseHook.js";
|
|
2
|
+
/** A captured photo, however it reached the web layer. */
|
|
3
|
+
export interface CapturedPhoto {
|
|
4
|
+
/** Displayable source for the image. */
|
|
5
|
+
fileSrc: string;
|
|
6
|
+
/** Name the file was given. */
|
|
7
|
+
fileName: string;
|
|
8
|
+
/** Size in bytes, or 0 when the native side did not report it. */
|
|
9
|
+
size: number;
|
|
10
|
+
/** MIME type of the image. */
|
|
11
|
+
mimeType: string;
|
|
12
|
+
/** How the payload crossed the bridge. */
|
|
13
|
+
transport: string;
|
|
14
|
+
/** What produced the photo. */
|
|
15
|
+
source: string;
|
|
16
|
+
}
|
|
17
|
+
/** What {@link useCamera} returns. Wraps one operation: capturing a photo. */
|
|
18
|
+
export interface UseCameraResult extends HookState<CapturedPhoto>, WebFallbackState {
|
|
19
|
+
/** Progress of the in-flight capture, or null under SSR. */
|
|
20
|
+
progress: HookProgress | null;
|
|
21
|
+
/** Capture a photo. The canonical action. */
|
|
22
|
+
takePhoto: () => void;
|
|
23
|
+
/** Alias of `takePhoto`, named to match the shared hook contract. */
|
|
24
|
+
execute: () => void;
|
|
25
|
+
/** Drop the captured photo and any error. */
|
|
26
|
+
clear: () => void;
|
|
27
|
+
/** Drop the current error, keeping any photo. */
|
|
28
|
+
clearError: () => void;
|
|
29
|
+
/** Native camera permission status, or null on web. */
|
|
30
|
+
permission: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The captured photo.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Use `data` instead. `photo` is a deprecated alias kept for
|
|
35
|
+
* backward compatibility and will be removed at 2.0.
|
|
36
|
+
*/
|
|
37
|
+
photo: CapturedPhoto | null;
|
|
38
|
+
/**
|
|
39
|
+
* True while a capture is in flight.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated Use `loading` instead. `isLoading` is a deprecated alias kept
|
|
42
|
+
* for backward compatibility and will be removed at 2.0.
|
|
43
|
+
*/
|
|
44
|
+
isLoading: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Drop the captured photo and any error.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Use `clear` instead. `clearPhoto` is a deprecated alias kept
|
|
49
|
+
* for backward compatibility and will be removed at 2.0.
|
|
50
|
+
*/
|
|
51
|
+
clearPhoto: () => void;
|
|
52
|
+
}
|
|
53
|
+
export declare const useCamera: ({ webFallback }?: WebFallbackOptions) => UseCameraResult;
|
|
54
|
+
export declare const requestCameraPermission: () => Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* What {@link useCameraPermission} returns.
|
|
57
|
+
*
|
|
58
|
+
* Gained `loading`, `data`, `error`, `execute`, `isNative` and `isWeb` when the
|
|
59
|
+
* hook surface was made consistent; the older key for each is kept as an alias.
|
|
60
|
+
*/
|
|
61
|
+
export interface UseCameraPermissionResult extends HookState<string>, WebFallbackState {
|
|
62
|
+
/** Request camera access. The canonical action. */
|
|
63
|
+
execute: () => Promise<void> | void;
|
|
64
|
+
/**
|
|
65
|
+
* The permission status.
|
|
66
|
+
*
|
|
67
|
+
* @deprecated Use `data` instead. `permission` is a deprecated alias kept
|
|
68
|
+
* for backward compatibility and will be removed at 2.0.
|
|
69
|
+
*/
|
|
70
|
+
permission: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* True while the permission state is resolving.
|
|
73
|
+
*
|
|
74
|
+
* @deprecated Use `loading` instead. `isLoading` is a deprecated alias kept
|
|
75
|
+
* for backward compatibility and will be removed at 2.0.
|
|
76
|
+
*/
|
|
77
|
+
isLoading: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Request camera access.
|
|
80
|
+
*
|
|
81
|
+
* @deprecated Use `execute` instead. `request` is a deprecated alias kept
|
|
82
|
+
* for backward compatibility and will be removed at 2.0.
|
|
83
|
+
*/
|
|
84
|
+
request: () => Promise<void> | void;
|
|
85
|
+
}
|
|
86
|
+
export declare const useCameraPermission: ({ webFallback }?: WebFallbackOptions) => UseCameraPermissionResult;
|
|
@@ -7,10 +7,15 @@ exports.useCameraPermission = exports.useCamera = exports.requestCameraPermissio
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _NativeBridge = _interopRequireDefault(require("../utils/NativeBridge.js"));
|
|
9
9
|
var _NativeInterfaces = require("../constants/NativeInterfaces.js");
|
|
10
|
+
var _errors = require("../errors.js");
|
|
10
11
|
var _useBaseHook = require("../useBaseHook.js");
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps */
|
|
13
14
|
|
|
15
|
+
/** A captured photo, however it reached the web layer. */
|
|
16
|
+
|
|
17
|
+
/** What {@link useCamera} returns. Wraps one operation: capturing a photo. */
|
|
18
|
+
|
|
14
19
|
const useCamera = ({
|
|
15
20
|
webFallback
|
|
16
21
|
} = {}) => {
|
|
@@ -212,6 +217,13 @@ const requestCameraPermission = () => {
|
|
|
212
217
|
}
|
|
213
218
|
});
|
|
214
219
|
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* What {@link useCameraPermission} returns.
|
|
223
|
+
*
|
|
224
|
+
* Gained `loading`, `data`, `error`, `execute`, `isNative` and `isWeb` when the
|
|
225
|
+
* hook surface was made consistent; the older key for each is kept as an alias.
|
|
226
|
+
*/
|
|
215
227
|
exports.requestCameraPermission = requestCameraPermission;
|
|
216
228
|
const useCameraPermission = ({
|
|
217
229
|
webFallback
|
|
@@ -225,6 +237,7 @@ const useCameraPermission = ({
|
|
|
225
237
|
const webFallbackDisabled = isWeb && !webFallbackResolved;
|
|
226
238
|
const [permission, setPermission] = (0, _react.useState)(null);
|
|
227
239
|
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
240
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
228
241
|
const permResultRef = (0, _react.useRef)(null);
|
|
229
242
|
(0, _react.useEffect)(() => {
|
|
230
243
|
if (typeof window === "undefined") {
|
|
@@ -277,9 +290,10 @@ const useCameraPermission = ({
|
|
|
277
290
|
console.log("📷 Camera permission status updated:", data);
|
|
278
291
|
});
|
|
279
292
|
_NativeBridge.default.camera.requestPermission();
|
|
280
|
-
} catch (
|
|
281
|
-
console.error("📷 Error requesting camera permission:",
|
|
293
|
+
} catch (err) {
|
|
294
|
+
console.error("📷 Error requesting camera permission:", err);
|
|
282
295
|
setPermission(_NativeInterfaces.PERMISSION_STATUS.DENIED);
|
|
296
|
+
setError((0, _errors.createStandardError)(_errors.ERROR_CODES.PERMISSION_DENIED, "Camera permission denied", err));
|
|
283
297
|
setIsLoading(false);
|
|
284
298
|
}
|
|
285
299
|
};
|
|
@@ -298,13 +312,16 @@ const useCameraPermission = ({
|
|
|
298
312
|
if (!navigator.mediaDevices?.getUserMedia) return;
|
|
299
313
|
try {
|
|
300
314
|
setIsLoading(true);
|
|
315
|
+
setError(null);
|
|
301
316
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
302
317
|
video: true,
|
|
303
318
|
audio: false
|
|
304
319
|
});
|
|
305
320
|
stream.getTracks().forEach(t => t.stop());
|
|
306
|
-
} catch (
|
|
307
|
-
//
|
|
321
|
+
} catch (err) {
|
|
322
|
+
// Permission state change still fires via permResultRef.current.onchange;
|
|
323
|
+
// surface the rejection as a standard error for callers reading `error`.
|
|
324
|
+
setError((0, _errors.createStandardError)(_errors.ERROR_CODES.PERMISSION_DENIED, "Camera access denied", err));
|
|
308
325
|
}
|
|
309
326
|
|
|
310
327
|
// Re-query to get the authoritative state after the prompt
|
|
@@ -332,7 +349,13 @@ const useCameraPermission = ({
|
|
|
332
349
|
webFallbackActive: false,
|
|
333
350
|
webFallbackDisabled: false,
|
|
334
351
|
setWebFallback: () => {},
|
|
335
|
-
request: () => {}
|
|
352
|
+
request: () => {},
|
|
353
|
+
loading: false,
|
|
354
|
+
data: null,
|
|
355
|
+
error: null,
|
|
356
|
+
execute: () => {},
|
|
357
|
+
isNative: false,
|
|
358
|
+
isWeb: true
|
|
336
359
|
};
|
|
337
360
|
}
|
|
338
361
|
return {
|
|
@@ -341,7 +364,13 @@ const useCameraPermission = ({
|
|
|
341
364
|
webFallbackActive,
|
|
342
365
|
webFallbackDisabled,
|
|
343
366
|
setWebFallback,
|
|
344
|
-
request
|
|
367
|
+
request,
|
|
368
|
+
loading: isLoading,
|
|
369
|
+
data: permission,
|
|
370
|
+
error,
|
|
371
|
+
execute: request,
|
|
372
|
+
isNative: !isWeb,
|
|
373
|
+
isWeb
|
|
345
374
|
};
|
|
346
375
|
};
|
|
347
376
|
exports.useCameraPermission = useCameraPermission;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WebFallbackOptions } from "../useBaseHook.js";
|
|
2
|
+
export declare const useDataProtection: ({ webFallback }?: WebFallbackOptions) => {
|
|
3
|
+
data: any;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
progress: import("../useBaseHook.js").HookProgress;
|
|
6
|
+
error: any;
|
|
7
|
+
isWeb: boolean;
|
|
8
|
+
isNative: boolean;
|
|
9
|
+
webFallbackActive: boolean;
|
|
10
|
+
webFallbackDisabled: boolean;
|
|
11
|
+
setWebFallback: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
12
|
+
clear: () => void;
|
|
13
|
+
clearError: () => void;
|
|
14
|
+
screenSecure: boolean;
|
|
15
|
+
setScreenSecure: (enable: any) => void;
|
|
16
|
+
clearWebData: () => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HookEnvironment, WebFallbackOptions, WebFallbackState } from "../useBaseHook.js";
|
|
2
|
+
/** Device details reported by the native host, or derived from browser APIs on web. */
|
|
3
|
+
export interface DeviceInfo {
|
|
4
|
+
model: string;
|
|
5
|
+
manufacturer: string;
|
|
6
|
+
platform: string;
|
|
7
|
+
screenWidth: number;
|
|
8
|
+
screenHeight: number;
|
|
9
|
+
screenDensity: number;
|
|
10
|
+
appInfo: any;
|
|
11
|
+
}
|
|
12
|
+
/** What {@link useDeviceInfo} returns. Read-only: no action functions. */
|
|
13
|
+
export interface UseDeviceInfoResult extends HookEnvironment, WebFallbackState {
|
|
14
|
+
/** The device details, or null until they resolve. */
|
|
15
|
+
data: DeviceInfo | null;
|
|
16
|
+
/**
|
|
17
|
+
* The device details.
|
|
18
|
+
*
|
|
19
|
+
* @deprecated Use `data` instead. `deviceInfo` is a deprecated alias kept
|
|
20
|
+
* for backward compatibility and will be removed at 2.0.
|
|
21
|
+
*/
|
|
22
|
+
deviceInfo: DeviceInfo | null;
|
|
23
|
+
/** True while the device details are being fetched. */
|
|
24
|
+
loading: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The failure message, or null.
|
|
27
|
+
*
|
|
28
|
+
* Note this is a plain string rather than a standard error object. That is
|
|
29
|
+
* a known inconsistency with the rest of the hook contract, and it stays a
|
|
30
|
+
* string until 2.0.
|
|
31
|
+
*/
|
|
32
|
+
error: string | null;
|
|
33
|
+
}
|
|
34
|
+
export declare const useDeviceInfo: ({ webFallback }?: WebFallbackOptions) => UseDeviceInfoResult;
|
|
@@ -9,6 +9,10 @@ var _NativeBridge = _interopRequireDefault(require("../utils/NativeBridge.js"));
|
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps */
|
|
11
11
|
|
|
12
|
+
/** Device details reported by the native host, or derived from browser APIs on web. */
|
|
13
|
+
|
|
14
|
+
/** What {@link useDeviceInfo} returns. Read-only: no action functions. */
|
|
15
|
+
|
|
12
16
|
const useDeviceInfo = ({
|
|
13
17
|
webFallback
|
|
14
18
|
} = {}) => {
|
|
@@ -59,6 +63,7 @@ const useDeviceInfo = ({
|
|
|
59
63
|
}, [webFallbackDisabled]);
|
|
60
64
|
return {
|
|
61
65
|
deviceInfo,
|
|
66
|
+
data: deviceInfo,
|
|
62
67
|
loading,
|
|
63
68
|
error,
|
|
64
69
|
isNative,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { HookProgress, HookState, WebFallbackOptions, WebFallbackState } from "../useBaseHook.js";
|
|
2
|
+
export declare const sanitizeFilePickerOptions: (input: any) => any;
|
|
3
|
+
/**
|
|
4
|
+
* What {@link useFilePicker} returns. Wraps one operation: picking a file.
|
|
5
|
+
*
|
|
6
|
+
* The web-fallback keys are declared required: every client branch returns
|
|
7
|
+
* them, and consumers should not have to null-check keys that never miss at
|
|
8
|
+
* runtime. The SSR stub under-delivers on this shape (it omits
|
|
9
|
+
* `webFallbackActive`, `webFallbackDisabled` and `setWebFallback`) and is cast
|
|
10
|
+
* below — reconciling the stub itself is a behavior change that belongs to the
|
|
11
|
+
* freeze, not to this conversion.
|
|
12
|
+
*/
|
|
13
|
+
export interface UseFilePickerResult extends HookState, WebFallbackState {
|
|
14
|
+
/** Progress of the in-flight pick, or null under SSR. */
|
|
15
|
+
progress: HookProgress | null;
|
|
16
|
+
/** Open the file picker. The canonical action. */
|
|
17
|
+
pickFile: (input?: any) => void;
|
|
18
|
+
/** Alias of `pickFile`, named to match the shared hook contract. */
|
|
19
|
+
execute: (input?: any) => void;
|
|
20
|
+
/** Drop the picked files, the cached File objects and any error. */
|
|
21
|
+
clear: () => void;
|
|
22
|
+
/** Drop the current error, keeping any data. */
|
|
23
|
+
clearError: () => void;
|
|
24
|
+
/** Materialize the picked file as a `File`. */
|
|
25
|
+
getFileObject: (...args: any[]) => Promise<any>;
|
|
26
|
+
/** Materialize every picked file as a `File`. */
|
|
27
|
+
getAllFileObjects: (...args: any[]) => Promise<any>;
|
|
28
|
+
/** Whether the current file's transport supports `File` creation. */
|
|
29
|
+
canCreateFileObject: boolean;
|
|
30
|
+
/** Per-file view of `canCreateFileObject`. */
|
|
31
|
+
canCreateFileObjects: any[];
|
|
32
|
+
/** First picked file, or null. */
|
|
33
|
+
selectedFile: any;
|
|
34
|
+
/** Every picked file. */
|
|
35
|
+
selectedFiles: any[];
|
|
36
|
+
/** The current phase of the pick, or null when idle. */
|
|
37
|
+
processingState: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* True while a pick is in flight.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated Use `loading` instead. `isLoading` is a deprecated alias kept
|
|
42
|
+
* for backward compatibility and will be removed at 2.0.
|
|
43
|
+
*/
|
|
44
|
+
isLoading: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Drop the picked files and any error.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Use `clear` instead. `clearFile` is a deprecated alias kept
|
|
49
|
+
* for backward compatibility and will be removed at 2.0.
|
|
50
|
+
*/
|
|
51
|
+
clearFile: () => void;
|
|
52
|
+
}
|
|
53
|
+
export declare const useFilePicker: ({ webFallback }?: WebFallbackOptions) => UseFilePickerResult;
|
|
@@ -150,6 +150,18 @@ const mapStateToProgress = state => {
|
|
|
150
150
|
message: `File picker: ${rawState}...`
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* What {@link useFilePicker} returns. Wraps one operation: picking a file.
|
|
156
|
+
*
|
|
157
|
+
* The web-fallback keys are declared required: every client branch returns
|
|
158
|
+
* them, and consumers should not have to null-check keys that never miss at
|
|
159
|
+
* runtime. The SSR stub under-delivers on this shape (it omits
|
|
160
|
+
* `webFallbackActive`, `webFallbackDisabled` and `setWebFallback`) and is cast
|
|
161
|
+
* below — reconciling the stub itself is a behavior change that belongs to the
|
|
162
|
+
* freeze, not to this conversion.
|
|
163
|
+
*/
|
|
164
|
+
|
|
153
165
|
const useFilePicker = ({
|
|
154
166
|
webFallback
|
|
155
167
|
} = {}) => {
|
|
@@ -207,6 +219,7 @@ const useFilePicker = ({
|
|
|
207
219
|
}, [base]);
|
|
208
220
|
const webFiles = (0, _react.useMemo)(() => extractFiles(base.data), [base.data]);
|
|
209
221
|
if (typeof window === "undefined") {
|
|
222
|
+
// The stub under-delivers on UseFilePickerResult (no web-fallback keys).
|
|
210
223
|
return SSR_FILE_PICKER_STUB;
|
|
211
224
|
}
|
|
212
225
|
if (base.webFallbackDisabled) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const useGoogleSignIn: (defaultOptions?: {}) => {
|
|
2
|
+
data: any;
|
|
3
|
+
loading: boolean;
|
|
4
|
+
progress: import("../useBaseHook.js").HookProgress;
|
|
5
|
+
error: any;
|
|
6
|
+
isWeb: boolean;
|
|
7
|
+
isNative: boolean;
|
|
8
|
+
signIn: (options?: {}) => void;
|
|
9
|
+
execute: (options?: {}) => void;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
clearError: () => void;
|
|
12
|
+
};
|