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,76 @@
|
|
|
1
|
+
import type { WebFallbackOptions } from "../useBaseHook.js";
|
|
2
|
+
export declare const requestHapticFeedback: (feedbackType?: string) => Promise<any>;
|
|
3
|
+
export declare const useHapticFeedback: ({ webFallback }?: WebFallbackOptions) => {
|
|
4
|
+
data: any;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
progress: any;
|
|
7
|
+
error: any;
|
|
8
|
+
isWeb: boolean;
|
|
9
|
+
isNative: boolean;
|
|
10
|
+
webFallbackActive: boolean;
|
|
11
|
+
webFallbackDisabled: boolean;
|
|
12
|
+
setWebFallback: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
13
|
+
execute: () => void;
|
|
14
|
+
clear: () => void;
|
|
15
|
+
clearError: () => void;
|
|
16
|
+
triggerHaptic: () => void;
|
|
17
|
+
trigger: () => void;
|
|
18
|
+
light: () => void;
|
|
19
|
+
medium: () => void;
|
|
20
|
+
heavy: () => void;
|
|
21
|
+
success: () => void;
|
|
22
|
+
warning: () => void;
|
|
23
|
+
errorHaptic: () => void;
|
|
24
|
+
selection: () => void;
|
|
25
|
+
impact: () => void;
|
|
26
|
+
capabilities: {
|
|
27
|
+
isSupported: boolean;
|
|
28
|
+
availableTypes: undefined[];
|
|
29
|
+
platform: string;
|
|
30
|
+
};
|
|
31
|
+
isSupported: boolean;
|
|
32
|
+
isAvailable: boolean;
|
|
33
|
+
availableTypes: any[];
|
|
34
|
+
HAPTIC_TYPES: {};
|
|
35
|
+
} | {
|
|
36
|
+
data: any;
|
|
37
|
+
loading: boolean;
|
|
38
|
+
progress: import("../useBaseHook.js").HookProgress;
|
|
39
|
+
error: any;
|
|
40
|
+
isWeb: boolean;
|
|
41
|
+
isNative: boolean;
|
|
42
|
+
webFallbackActive: boolean;
|
|
43
|
+
webFallbackDisabled: boolean;
|
|
44
|
+
setWebFallback: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
45
|
+
clear: () => void;
|
|
46
|
+
clearError: () => void;
|
|
47
|
+
execute: (type?: string, options?: {}) => Promise<any>;
|
|
48
|
+
triggerHaptic: (type?: string, options?: {}) => Promise<any>;
|
|
49
|
+
trigger: (type?: string, options?: {}) => Promise<any>;
|
|
50
|
+
light: () => Promise<any>;
|
|
51
|
+
medium: () => Promise<any>;
|
|
52
|
+
heavy: () => Promise<any>;
|
|
53
|
+
success: () => Promise<any>;
|
|
54
|
+
warning: () => Promise<any>;
|
|
55
|
+
errorHaptic: () => Promise<any>;
|
|
56
|
+
selection: () => Promise<any>;
|
|
57
|
+
impact: () => Promise<any>;
|
|
58
|
+
capabilities: {
|
|
59
|
+
isSupported: boolean;
|
|
60
|
+
availableTypes: string[];
|
|
61
|
+
platform: string;
|
|
62
|
+
};
|
|
63
|
+
isSupported: boolean;
|
|
64
|
+
isAvailable: boolean;
|
|
65
|
+
availableTypes: string[];
|
|
66
|
+
HAPTIC_TYPES: {
|
|
67
|
+
LIGHT: string;
|
|
68
|
+
MEDIUM: string;
|
|
69
|
+
HEAVY: string;
|
|
70
|
+
SUCCESS: string;
|
|
71
|
+
WARNING: string;
|
|
72
|
+
ERROR: string;
|
|
73
|
+
SELECTION: string;
|
|
74
|
+
IMPACT: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -116,7 +116,12 @@ const useHapticFeedback = ({
|
|
|
116
116
|
(0, _react.useEffect)(() => {
|
|
117
117
|
setCapabilities(detectHapticCapabilities(base.isNative));
|
|
118
118
|
}, [base.isNative]);
|
|
119
|
-
|
|
119
|
+
|
|
120
|
+
// The caller passes `(type, options)`, but the web path has never read the
|
|
121
|
+
// second argument — `navigator.vibrate` takes only a pattern. The parameter
|
|
122
|
+
// is declared so the discard is explicit at the signature rather than being
|
|
123
|
+
// an arity mismatch; behavior is unchanged.
|
|
124
|
+
const handleWebHaptic = (type, _options) => {
|
|
120
125
|
if (!navigator.vibrate) return false;
|
|
121
126
|
const vibrationPatterns = {
|
|
122
127
|
[HAPTIC_TYPES.LIGHT]: [50],
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HookProgress, HookState } from "../useBaseHook.js";
|
|
2
|
+
/** What {@link useIntent} returns. Wraps one operation: opening a file externally. */
|
|
3
|
+
export interface UseIntentResult extends HookState {
|
|
4
|
+
/** Progress of the in-flight intent, or null under SSR. */
|
|
5
|
+
progress: HookProgress | null;
|
|
6
|
+
/** Open a file with an external app. The canonical action. */
|
|
7
|
+
openFile: (fileUrl: string, mimeType?: string | null) => void;
|
|
8
|
+
/** Alias of `openFile`, named to match the shared hook contract. */
|
|
9
|
+
execute: (fileUrl: string, mimeType?: string | null) => void;
|
|
10
|
+
/** Drop the current result and error. */
|
|
11
|
+
clear: () => void;
|
|
12
|
+
/** Drop the current error, keeping any data. */
|
|
13
|
+
clearError: () => void;
|
|
14
|
+
/** The current phase of the intent, or null when idle. */
|
|
15
|
+
processingState: string | null;
|
|
16
|
+
/** True once the intent completed successfully, else null. */
|
|
17
|
+
success: boolean | null;
|
|
18
|
+
/**
|
|
19
|
+
* True while the intent is in flight.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use `loading` instead. `isLoading` is a deprecated alias kept
|
|
22
|
+
* for backward compatibility and will be removed at 2.0.
|
|
23
|
+
*/
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Drop the current result and error.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Use `clear` instead. `reset` is a deprecated alias kept for
|
|
29
|
+
* backward compatibility and will be removed at 2.0.
|
|
30
|
+
*/
|
|
31
|
+
reset: () => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const useIntent: () => UseIntentResult;
|
|
@@ -11,6 +11,8 @@ var _useBaseHook = require("../useBaseHook.js");
|
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps */
|
|
13
13
|
|
|
14
|
+
/** What {@link useIntent} returns. Wraps one operation: opening a file externally. */
|
|
15
|
+
|
|
14
16
|
const useIntent = () => {
|
|
15
17
|
const base = (0, _useBaseHook.useBaseHook)("useIntent");
|
|
16
18
|
if (typeof window === "undefined") {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { HookEnvironment } from "../useBaseHook.js";
|
|
2
|
+
/** Transition options, accepted as hook defaults and per-navigate overrides. */
|
|
3
|
+
export interface NativeTransitionOptions {
|
|
4
|
+
/** Animation style. Defaults to `"slide"`. */
|
|
5
|
+
type?: "slide" | "fade";
|
|
6
|
+
/** Slide direction. Slide only. Defaults to `"left"`. */
|
|
7
|
+
direction?: "left" | "right" | "up" | "down";
|
|
8
|
+
/** Animation length in ms. Defaults to 300. */
|
|
9
|
+
duration?: number;
|
|
10
|
+
/** Safety timer in ms. Defaults to `max(duration * 3, 800)`. */
|
|
11
|
+
timeout?: number;
|
|
12
|
+
/** Replace the current history entry instead of pushing. */
|
|
13
|
+
replace?: boolean;
|
|
14
|
+
/** Router state to carry through the navigation. */
|
|
15
|
+
state?: any;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What {@link useNativeTransition} returns.
|
|
19
|
+
*
|
|
20
|
+
* A multi-action hook: its named functions are the API, so it has no `execute`.
|
|
21
|
+
* It also returns no `error` key — a failed transition self-heals into a plain
|
|
22
|
+
* navigation, so there is nothing for a caller to handle.
|
|
23
|
+
*/
|
|
24
|
+
export interface UseNativeTransitionResult extends HookEnvironment {
|
|
25
|
+
/** Navigate with a native transition. */
|
|
26
|
+
navigate: (to: any, options?: NativeTransitionOptions) => void;
|
|
27
|
+
/** Cancel an in-flight transition. Best-effort. */
|
|
28
|
+
cancelTransition: () => void;
|
|
29
|
+
/** True while a transition is running. */
|
|
30
|
+
loading: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* True while a transition is running.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Use `loading` instead. `transitioning` is a deprecated alias
|
|
35
|
+
* kept for backward compatibility and will be removed at 2.0.
|
|
36
|
+
*/
|
|
37
|
+
transitioning: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Wraps useNavigate with native slide/fade transitions using a snapshot overlay pattern.
|
|
41
|
+
*
|
|
42
|
+
* Native path:
|
|
43
|
+
* navigate(to, opts) → startTransition → native snapshots screen → router.navigate(to) →
|
|
44
|
+
* commitTransition → native animates overlay out revealing new page.
|
|
45
|
+
*
|
|
46
|
+
* Safety net: native-side timer (configurable via opts.timeout, default max(duration*3, 800ms))
|
|
47
|
+
* force-fades the overlay if commitTransition is never called.
|
|
48
|
+
*
|
|
49
|
+
* Web fallback: CSS overlay on document.body, driven by the same state machine.
|
|
50
|
+
*
|
|
51
|
+
* @param defaults - Default transition options applied to every navigate call
|
|
52
|
+
*/
|
|
53
|
+
export declare const useNativeTransition: (defaults?: NativeTransitionOptions) => UseNativeTransitionResult;
|
|
@@ -15,6 +15,16 @@ const DEFAULT_DURATION = 300;
|
|
|
15
15
|
const DEFAULT_TIMEOUT_MULTIPLIER = 3;
|
|
16
16
|
const MIN_TIMEOUT = 800;
|
|
17
17
|
|
|
18
|
+
/** Transition options, accepted as hook defaults and per-navigate overrides. */
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* What {@link useNativeTransition} returns.
|
|
22
|
+
*
|
|
23
|
+
* A multi-action hook: its named functions are the API, so it has no `execute`.
|
|
24
|
+
* It also returns no `error` key — a failed transition self-heals into a plain
|
|
25
|
+
* navigation, so there is nothing for a caller to handle.
|
|
26
|
+
*/
|
|
27
|
+
|
|
18
28
|
/**
|
|
19
29
|
* Wraps useNavigate with native slide/fade transitions using a snapshot overlay pattern.
|
|
20
30
|
*
|
|
@@ -27,11 +37,7 @@ const MIN_TIMEOUT = 800;
|
|
|
27
37
|
*
|
|
28
38
|
* Web fallback: CSS overlay on document.body, driven by the same state machine.
|
|
29
39
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* type: 'slide' | 'fade' (default: 'slide')
|
|
32
|
-
* direction: 'left' | 'right' | 'up' | 'down' (default: 'left')
|
|
33
|
-
* duration: ms (default: 300)
|
|
34
|
-
* timeout: ms safety timer (default: max(duration*3, 800))
|
|
40
|
+
* @param defaults - Default transition options applied to every navigate call
|
|
35
41
|
*/
|
|
36
42
|
const useNativeTransition = (defaults = {}) => {
|
|
37
43
|
const router = (0, _reactRouter.useNavigate)();
|
|
@@ -211,6 +217,7 @@ const useNativeTransition = (defaults = {}) => {
|
|
|
211
217
|
navigate,
|
|
212
218
|
cancelTransition,
|
|
213
219
|
transitioning,
|
|
220
|
+
loading: transitioning,
|
|
214
221
|
isNative,
|
|
215
222
|
isWeb: !isNative
|
|
216
223
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HookEnvironment, WebFallbackOptions, WebFallbackState } from "../useBaseHook.js";
|
|
2
|
+
/**
|
|
3
|
+
* What {@link useNetworkStatus} returns: connectivity spread at the top level,
|
|
4
|
+
* plus the runtime-context keys.
|
|
5
|
+
*
|
|
6
|
+
* Read-only, so it has no action functions.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseNetworkStatusResult extends HookEnvironment, WebFallbackState {
|
|
9
|
+
/** True when the device reports a usable connection. */
|
|
10
|
+
online: boolean;
|
|
11
|
+
/** Connection type reported by native, or null when unknown. */
|
|
12
|
+
type: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* The failure message, or null.
|
|
15
|
+
*
|
|
16
|
+
* Note this is a plain string rather than a standard error object. That is
|
|
17
|
+
* a known inconsistency with the rest of the hook contract, and it stays a
|
|
18
|
+
* string until 2.0.
|
|
19
|
+
*/
|
|
20
|
+
error: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare const useNetworkStatus: ({ webFallback }?: WebFallbackOptions) => UseNetworkStatusResult;
|
|
@@ -11,6 +11,13 @@ var _utils = require("./utils.js");
|
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps */
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* What {@link useNetworkStatus} returns: connectivity spread at the top level,
|
|
16
|
+
* plus the runtime-context keys.
|
|
17
|
+
*
|
|
18
|
+
* Read-only, so it has no action functions.
|
|
19
|
+
*/
|
|
20
|
+
|
|
14
21
|
const useNetworkStatus = ({
|
|
15
22
|
webFallback
|
|
16
23
|
} = {}) => {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { HookProgress, HookState } from "../useBaseHook.js";
|
|
2
|
+
export declare const requestNotificationPermission: () => Promise<any>;
|
|
3
|
+
/**
|
|
4
|
+
* What {@link useNotificationPermission} returns.
|
|
5
|
+
*
|
|
6
|
+
* Gained `loading`, `data`, `error`, `isNative` and `isWeb` when the hook
|
|
7
|
+
* surface was made consistent, and it now reports permission failures as a
|
|
8
|
+
* standard error object instead of only logging them.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseNotificationPermissionResult extends HookState<string> {
|
|
11
|
+
/**
|
|
12
|
+
* The permission status.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Use `data` instead. `permission` is a deprecated alias kept
|
|
15
|
+
* for backward compatibility and will be removed at 2.0.
|
|
16
|
+
*/
|
|
17
|
+
permission: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* True while the permission state is resolving.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use `loading` instead. `isLoading` is a deprecated alias kept
|
|
22
|
+
* for backward compatibility and will be removed at 2.0.
|
|
23
|
+
*/
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const useNotificationPermission: () => UseNotificationPermissionResult;
|
|
27
|
+
/**
|
|
28
|
+
* What {@link useNotification} returns.
|
|
29
|
+
*
|
|
30
|
+
* This is the one multi-action hook that still carries `execute`. It and
|
|
31
|
+
* `schedule` are frozen aliases of `scheduleLocal` kept for backward
|
|
32
|
+
* compatibility, and neither should be read as the pattern for multi-action
|
|
33
|
+
* hooks — those expose their named functions and no `execute` at all.
|
|
34
|
+
*/
|
|
35
|
+
export interface UseNotificationResult extends HookState {
|
|
36
|
+
/** Progress of the in-flight operation, or null under SSR. */
|
|
37
|
+
progress: HookProgress | null;
|
|
38
|
+
/** Drop the current result and error. */
|
|
39
|
+
clear: () => void;
|
|
40
|
+
/** Drop the current error, keeping any data. */
|
|
41
|
+
clearError: () => void;
|
|
42
|
+
/** Latest notification permission status, or null. */
|
|
43
|
+
permissionStatus: string | null;
|
|
44
|
+
/** Push token issued by the platform, or null. */
|
|
45
|
+
pushToken: string | null;
|
|
46
|
+
/** Current app badge count. */
|
|
47
|
+
badges: number;
|
|
48
|
+
/** The most recently received or tapped notification, or null. */
|
|
49
|
+
lastNotification: any;
|
|
50
|
+
/** Topics this device is subscribed to. */
|
|
51
|
+
subscribedTopics: any[];
|
|
52
|
+
/** Schedule a local notification. The canonical action. */
|
|
53
|
+
scheduleLocal: (config: any) => void;
|
|
54
|
+
/** Cancel a previously scheduled local notification. */
|
|
55
|
+
cancelLocal: (notificationId: string) => void;
|
|
56
|
+
/** Register this device for push notifications. */
|
|
57
|
+
registerForPush: () => void;
|
|
58
|
+
/** Set the app badge count. */
|
|
59
|
+
updateBadge: (count: number) => void;
|
|
60
|
+
/** Subscribe to a push topic. */
|
|
61
|
+
subscribeToTopic: (topic: string) => void;
|
|
62
|
+
/** Unsubscribe from a push topic. */
|
|
63
|
+
unsubscribeFromTopic: (topic: string) => void;
|
|
64
|
+
/** Ask the native side for the current topic subscriptions. */
|
|
65
|
+
getSubscribedTopics: () => void;
|
|
66
|
+
/** Prompt for notification permission. */
|
|
67
|
+
requestPermission: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Schedule a local notification.
|
|
70
|
+
*
|
|
71
|
+
* @deprecated Use `scheduleLocal` instead. `execute` is a frozen alias kept
|
|
72
|
+
* for backward compatibility and will be removed at 2.0.
|
|
73
|
+
*/
|
|
74
|
+
execute: (config: any) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Schedule a local notification.
|
|
77
|
+
*
|
|
78
|
+
* @deprecated Use `scheduleLocal` instead. `schedule` is a frozen alias kept
|
|
79
|
+
* for backward compatibility and will be removed at 2.0.
|
|
80
|
+
*/
|
|
81
|
+
schedule: (config: any) => void;
|
|
82
|
+
}
|
|
83
|
+
export declare const useNotification: () => UseNotificationResult;
|
|
@@ -7,6 +7,7 @@ exports.useNotificationPermission = exports.useNotification = exports.requestNot
|
|
|
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 */
|
|
@@ -63,19 +64,20 @@ const requestNotificationPermission = () => {
|
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* What {@link useNotificationPermission} returns.
|
|
70
|
+
*
|
|
71
|
+
* Gained `loading`, `data`, `error`, `isNative` and `isWeb` when the hook
|
|
72
|
+
* surface was made consistent, and it now reports permission failures as a
|
|
73
|
+
* standard error object instead of only logging them.
|
|
74
|
+
*/
|
|
66
75
|
exports.requestNotificationPermission = requestNotificationPermission;
|
|
67
76
|
const useNotificationPermission = () => {
|
|
68
|
-
if (typeof window === "undefined") {
|
|
69
|
-
return {
|
|
70
|
-
permission: null,
|
|
71
|
-
isLoading: false
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (!window.WebBridge) {
|
|
75
|
-
throw new Error("WebBridge is not initialized. Call WebBridge.init() first.");
|
|
76
|
-
}
|
|
77
77
|
const [permission, setPermission] = (0, _react.useState)(null);
|
|
78
78
|
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
79
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
80
|
+
const isWeb = typeof window === "undefined" ? true : !_NativeBridge.default.isAvailable();
|
|
79
81
|
(0, _react.useEffect)(() => {
|
|
80
82
|
const requestPermission = async () => {
|
|
81
83
|
try {
|
|
@@ -90,9 +92,10 @@ const useNotificationPermission = () => {
|
|
|
90
92
|
console.log("🔔 Notification permission status updated:", data);
|
|
91
93
|
});
|
|
92
94
|
_NativeBridge.default.notification.requestPermission();
|
|
93
|
-
} catch (
|
|
94
|
-
console.error("🔔 Error requesting notification permission:",
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.error("🔔 Error requesting notification permission:", err);
|
|
95
97
|
setPermission(_NativeInterfaces.PERMISSION_STATUS.DENIED);
|
|
98
|
+
setError((0, _errors.createStandardError)(_errors.ERROR_CODES.PERMISSION_DENIED, "Notification permission denied", err));
|
|
96
99
|
setIsLoading(false);
|
|
97
100
|
}
|
|
98
101
|
};
|
|
@@ -101,11 +104,39 @@ const useNotificationPermission = () => {
|
|
|
101
104
|
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.NOTIFICATION_PERMISSION_STATUS);
|
|
102
105
|
};
|
|
103
106
|
}, []);
|
|
107
|
+
if (typeof window === "undefined") {
|
|
108
|
+
return {
|
|
109
|
+
permission: null,
|
|
110
|
+
isLoading: false,
|
|
111
|
+
loading: false,
|
|
112
|
+
data: null,
|
|
113
|
+
error: null,
|
|
114
|
+
isNative: false,
|
|
115
|
+
isWeb: true
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (!window.WebBridge) {
|
|
119
|
+
throw new Error("WebBridge is not initialized. Call WebBridge.init() first.");
|
|
120
|
+
}
|
|
104
121
|
return {
|
|
105
122
|
permission,
|
|
106
|
-
isLoading
|
|
123
|
+
isLoading,
|
|
124
|
+
loading: isLoading,
|
|
125
|
+
data: permission,
|
|
126
|
+
error,
|
|
127
|
+
isNative: !isWeb,
|
|
128
|
+
isWeb
|
|
107
129
|
};
|
|
108
130
|
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* What {@link useNotification} returns.
|
|
134
|
+
*
|
|
135
|
+
* This is the one multi-action hook that still carries `execute`. It and
|
|
136
|
+
* `schedule` are frozen aliases of `scheduleLocal` kept for backward
|
|
137
|
+
* compatibility, and neither should be read as the pattern for multi-action
|
|
138
|
+
* hooks — those expose their named functions and no `execute` at all.
|
|
139
|
+
*/
|
|
109
140
|
exports.useNotificationPermission = useNotificationPermission;
|
|
110
141
|
const useNotification = () => {
|
|
111
142
|
const base = (0, _useBaseHook.useBaseHook)("useNotification");
|
|
@@ -114,28 +145,6 @@ const useNotification = () => {
|
|
|
114
145
|
const [badges, setBadges] = (0, _react.useState)(0);
|
|
115
146
|
const [lastNotification, setLastNotification] = (0, _react.useState)(null);
|
|
116
147
|
const [subscribedTopics, setSubscribedTopics] = (0, _react.useState)([]);
|
|
117
|
-
if (typeof window === "undefined") {
|
|
118
|
-
return {
|
|
119
|
-
data: null,
|
|
120
|
-
loading: false,
|
|
121
|
-
error: null,
|
|
122
|
-
execute: () => {},
|
|
123
|
-
scheduleLocal: () => {},
|
|
124
|
-
cancelLocal: () => {},
|
|
125
|
-
registerForPush: () => {},
|
|
126
|
-
updateBadge: () => {},
|
|
127
|
-
subscribeToTopic: () => {},
|
|
128
|
-
unsubscribeFromTopic: () => {},
|
|
129
|
-
getSubscribedTopics: () => {},
|
|
130
|
-
permissionStatus: null,
|
|
131
|
-
pushToken: null,
|
|
132
|
-
badges: 0,
|
|
133
|
-
subscribedTopics: []
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (!window.WebBridge) {
|
|
137
|
-
throw new Error("WebBridge is not initialized. Call WebBridge.init() first.");
|
|
138
|
-
}
|
|
139
148
|
(0, _react.useEffect)(() => {
|
|
140
149
|
const unregister = registerPermissionStatusListener(data => {
|
|
141
150
|
setPermissionStatus(data);
|
|
@@ -252,6 +261,44 @@ const useNotification = () => {
|
|
|
252
261
|
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.SUBSCRIBED_TOPICS_RESULT);
|
|
253
262
|
};
|
|
254
263
|
}, []);
|
|
264
|
+
if (typeof window === "undefined") {
|
|
265
|
+
return {
|
|
266
|
+
data: null,
|
|
267
|
+
loading: false,
|
|
268
|
+
progress: {
|
|
269
|
+
state: "idle",
|
|
270
|
+
percentage: null,
|
|
271
|
+
message: null,
|
|
272
|
+
phase: null,
|
|
273
|
+
transport: null,
|
|
274
|
+
bytesLoaded: null,
|
|
275
|
+
bytesTotal: null
|
|
276
|
+
},
|
|
277
|
+
error: null,
|
|
278
|
+
execute: () => {},
|
|
279
|
+
clear: () => {},
|
|
280
|
+
clearError: () => {},
|
|
281
|
+
isNative: false,
|
|
282
|
+
isWeb: true,
|
|
283
|
+
permissionStatus: null,
|
|
284
|
+
pushToken: null,
|
|
285
|
+
badges: 0,
|
|
286
|
+
lastNotification: null,
|
|
287
|
+
subscribedTopics: [],
|
|
288
|
+
scheduleLocal: () => {},
|
|
289
|
+
cancelLocal: () => {},
|
|
290
|
+
registerForPush: () => {},
|
|
291
|
+
updateBadge: () => {},
|
|
292
|
+
subscribeToTopic: () => {},
|
|
293
|
+
unsubscribeFromTopic: () => {},
|
|
294
|
+
getSubscribedTopics: () => {},
|
|
295
|
+
schedule: () => {},
|
|
296
|
+
requestPermission: () => {}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
if (!window.WebBridge) {
|
|
300
|
+
throw new Error("WebBridge is not initialized. Call WebBridge.init() first.");
|
|
301
|
+
}
|
|
255
302
|
const requestPermission = () => {
|
|
256
303
|
requestNotificationPermission().catch(err => base.handleNativeError(err));
|
|
257
304
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SafeAreaInsets } from "../safeArea.js";
|
|
2
|
+
import type { HookEnvironment, WebFallbackOptions, WebFallbackState } from "../useBaseHook.js";
|
|
3
|
+
/**
|
|
4
|
+
* What {@link useSafeArea} returns: the four insets spread at the top level,
|
|
5
|
+
* plus the runtime-context keys.
|
|
6
|
+
*
|
|
7
|
+
* Read-only, so it has no action functions, and it returns no `error` key —
|
|
8
|
+
* insets always resolve to numeric defaults, so there is nothing to report.
|
|
9
|
+
*/
|
|
10
|
+
export interface UseSafeAreaResult extends SafeAreaInsets, HookEnvironment, WebFallbackState {
|
|
11
|
+
}
|
|
12
|
+
export declare const useSafeArea: ({ webFallback }?: WebFallbackOptions) => UseSafeAreaResult;
|
|
@@ -10,6 +10,14 @@ var _safeArea = require("../safeArea.js");
|
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps */
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* What {@link useSafeArea} returns: the four insets spread at the top level,
|
|
15
|
+
* plus the runtime-context keys.
|
|
16
|
+
*
|
|
17
|
+
* Read-only, so it has no action functions, and it returns no `error` key —
|
|
18
|
+
* insets always resolve to numeric defaults, so there is nothing to report.
|
|
19
|
+
*/
|
|
20
|
+
|
|
13
21
|
const useSafeArea = ({
|
|
14
22
|
webFallback
|
|
15
23
|
} = {}) => {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { WebFallbackOptions } from "../useBaseHook.js";
|
|
2
|
+
/** Options accepted when starting the native or web video stream. */
|
|
3
|
+
export interface VideoStreamStartOptions {
|
|
4
|
+
/** Which camera to open: `"back"` or `"front"`. */
|
|
5
|
+
facing?: string;
|
|
6
|
+
/** Detection filter: `"qr"`, `"barcode"` or `"all"`. */
|
|
7
|
+
format?: string;
|
|
8
|
+
/** Zoom behaviour, e.g. `{ auto: true, initial: 1.0 }`. */
|
|
9
|
+
zoom?: any;
|
|
10
|
+
/** Target frame rate. */
|
|
11
|
+
fps?: number;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
/** Options accepted by {@link useVideoStream}. */
|
|
15
|
+
export interface VideoStreamOptions extends WebFallbackOptions {
|
|
16
|
+
/** Called with each detected QR/barcode payload. */
|
|
17
|
+
onQRDetected?: (value: any) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const useVideoStream: ({ onQRDetected, webFallback }?: VideoStreamOptions) => {
|
|
20
|
+
isStreaming: boolean;
|
|
21
|
+
streamState: {
|
|
22
|
+
zoom: any;
|
|
23
|
+
minZoom: any;
|
|
24
|
+
maxZoom: any;
|
|
25
|
+
torchOn: boolean;
|
|
26
|
+
fpsMin: any;
|
|
27
|
+
fpsMax: any;
|
|
28
|
+
};
|
|
29
|
+
loading: boolean;
|
|
30
|
+
error: any;
|
|
31
|
+
isNative: boolean;
|
|
32
|
+
isWeb: boolean;
|
|
33
|
+
webFallbackActive: boolean;
|
|
34
|
+
webFallbackDisabled: boolean;
|
|
35
|
+
setWebFallback: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
36
|
+
mediaStream: any;
|
|
37
|
+
viewfinderRef: import("react").RefObject<any>;
|
|
38
|
+
start: (options?: VideoStreamStartOptions) => Promise<void>;
|
|
39
|
+
stop: () => void;
|
|
40
|
+
sendCommand: (type: any, value: any) => Promise<void>;
|
|
41
|
+
flip: () => Promise<void>;
|
|
42
|
+
clearError: () => void;
|
|
43
|
+
} | {
|
|
44
|
+
isStreaming: boolean;
|
|
45
|
+
streamState: {
|
|
46
|
+
zoom: any;
|
|
47
|
+
minZoom: any;
|
|
48
|
+
maxZoom: any;
|
|
49
|
+
torchOn: boolean;
|
|
50
|
+
fpsMin: any;
|
|
51
|
+
fpsMax: any;
|
|
52
|
+
};
|
|
53
|
+
loading: boolean;
|
|
54
|
+
error: any;
|
|
55
|
+
isNative: boolean;
|
|
56
|
+
isWeb: boolean;
|
|
57
|
+
webFallbackActive: boolean;
|
|
58
|
+
webFallbackDisabled: boolean;
|
|
59
|
+
setWebFallback: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
60
|
+
mediaStream: any;
|
|
61
|
+
viewfinderRef: import("react").RefObject<any>;
|
|
62
|
+
start: (options?: VideoStreamStartOptions) => void;
|
|
63
|
+
stop: () => void;
|
|
64
|
+
sendCommand: (type: any, value: any) => void;
|
|
65
|
+
flip: () => void;
|
|
66
|
+
clearError: () => void;
|
|
67
|
+
};
|