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
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useIntent = exports.useFilePicker = exports.useCamera = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _useBaseHook = require("./useBaseHook");
|
|
9
|
-
var _NativeBridge = _interopRequireDefault(require("./utils/NativeBridge.js"));
|
|
10
|
-
var _NativeInterfaces = require("./constants/NativeInterfaces");
|
|
11
|
-
var _errors = require("./errors");
|
|
12
|
-
var _FileObjectConverter = require("./utils/FileObjectConverter.js");
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
/* eslint-disable react-compiler/react-compiler, react-hooks/exhaustive-deps, no-case-declarations */
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Standardized Camera Superhook
|
|
18
|
-
* Comprehensive camera functionality with integrated permission management
|
|
19
|
-
* Follows standardized interface with execute as primary function
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} options - Configuration options
|
|
22
|
-
* @returns {Object} Standardized camera superhook interface
|
|
23
|
-
*/
|
|
24
|
-
const useCamera = (options = {}) => {
|
|
25
|
-
const base = (0, _useBaseHook.useBaseHook)("useCamera", options);
|
|
26
|
-
const [permission, setPermission] = (0, _react.useState)({
|
|
27
|
-
status: "not_determined",
|
|
28
|
-
canRequest: true,
|
|
29
|
-
lastChecked: null
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Camera operations
|
|
33
|
-
const CAMERA_OPERATIONS = {
|
|
34
|
-
TAKE_PHOTO: "takePhoto",
|
|
35
|
-
REQUEST_PERMISSION: "requestPermission",
|
|
36
|
-
CHECK_PERMISSION: "checkPermission"
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Camera-specific progress phases
|
|
40
|
-
const CAMERA_PHASES = {
|
|
41
|
-
REQUESTING_PERMISSION: "requesting_permission",
|
|
42
|
-
CHECKING_PERMISSION: "checking_permission",
|
|
43
|
-
OPENING_CAMERA: "opening_camera",
|
|
44
|
-
CAPTURING: "capturing",
|
|
45
|
-
PROCESSING: "processing",
|
|
46
|
-
COMPLETE: "complete"
|
|
47
|
-
};
|
|
48
|
-
(0, _react.useEffect)(() => {
|
|
49
|
-
// Server-side rendering safety
|
|
50
|
-
if (typeof window === "undefined") return;
|
|
51
|
-
if (!window.WebBridge) {
|
|
52
|
-
console.warn("WebBridge not initialized. Camera functionality unavailable.");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Camera capture success handler
|
|
57
|
-
const handleCameraCapture = data => {
|
|
58
|
-
try {
|
|
59
|
-
const result = typeof data === "string" ? JSON.parse(data) : data;
|
|
60
|
-
base.updateProgress({
|
|
61
|
-
phase: CAMERA_PHASES.PROCESSING,
|
|
62
|
-
message: "Processing captured photo..."
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Handle new tri-transport format or legacy format
|
|
66
|
-
const photoData = result.fileSrc ? {
|
|
67
|
-
// New tri-transport format
|
|
68
|
-
fileSrc: result.fileSrc,
|
|
69
|
-
fileName: result.fileName,
|
|
70
|
-
size: result.size,
|
|
71
|
-
mimeType: result.mimeType,
|
|
72
|
-
transport: result.transport,
|
|
73
|
-
source: result.source,
|
|
74
|
-
filePath: result.filePath
|
|
75
|
-
} : {
|
|
76
|
-
// Legacy format (fallback)
|
|
77
|
-
fileSrc: result.imageUrl,
|
|
78
|
-
fileName: result.fileName || "camera_photo.jpg",
|
|
79
|
-
size: result.size || 0,
|
|
80
|
-
mimeType: result.mimeType || "image/jpeg",
|
|
81
|
-
transport: "LEGACY",
|
|
82
|
-
source: "camera",
|
|
83
|
-
filePath: result.filePath || null
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Create comprehensive data object with photo and permission info
|
|
87
|
-
const cameraData = {
|
|
88
|
-
...photoData,
|
|
89
|
-
permission: permission,
|
|
90
|
-
lastOperation: CAMERA_OPERATIONS.TAKE_PHOTO,
|
|
91
|
-
operationSuccess: true,
|
|
92
|
-
timestamp: new Date().toISOString()
|
|
93
|
-
};
|
|
94
|
-
base.setDataAndComplete(cameraData);
|
|
95
|
-
console.log("📷 Photo captured successfully via transport:", photoData.transport);
|
|
96
|
-
} catch (parseError) {
|
|
97
|
-
console.error("📷 Error parsing camera capture data:", parseError);
|
|
98
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.INTERNAL_ERROR, "Failed to process captured photo", parseError);
|
|
99
|
-
base.handleNativeError(error);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// Camera permission status handler
|
|
104
|
-
const handlePermissionStatus = data => {
|
|
105
|
-
const permissionStatus = typeof data === "string" ? data : data.status || data;
|
|
106
|
-
const newPermission = {
|
|
107
|
-
status: permissionStatus.toLowerCase(),
|
|
108
|
-
canRequest: permissionStatus !== "permanently_denied",
|
|
109
|
-
lastChecked: new Date().toISOString()
|
|
110
|
-
};
|
|
111
|
-
setPermission(newPermission);
|
|
112
|
-
console.log("📷 Camera permission status:", newPermission);
|
|
113
|
-
|
|
114
|
-
// Update data with permission info
|
|
115
|
-
const permissionData = {
|
|
116
|
-
permission: newPermission,
|
|
117
|
-
lastOperation: CAMERA_OPERATIONS.REQUEST_PERMISSION,
|
|
118
|
-
operationSuccess: permissionStatus === "GRANTED",
|
|
119
|
-
timestamp: new Date().toISOString()
|
|
120
|
-
};
|
|
121
|
-
if (permissionStatus === "GRANTED") {
|
|
122
|
-
base.updateProgress({
|
|
123
|
-
phase: CAMERA_PHASES.OPENING_CAMERA,
|
|
124
|
-
message: "Camera permission granted, ready to capture..."
|
|
125
|
-
});
|
|
126
|
-
base.setDataAndComplete(permissionData);
|
|
127
|
-
} else if (permissionStatus === "DENIED") {
|
|
128
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.PERMISSION_DENIED, "Camera permission denied", null, "Camera permission is required to take photos");
|
|
129
|
-
base.handleNativeError(error);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// Camera error handler
|
|
134
|
-
const handleCameraError = data => {
|
|
135
|
-
console.error("📷 Camera error:", data);
|
|
136
|
-
base.handleNativeError(data);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// Register event listeners
|
|
140
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_CAMERA_CAPTURE, handleCameraCapture);
|
|
141
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.CAMERA_PERMISSION_STATUS, handlePermissionStatus);
|
|
142
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_CAMERA_ERROR, handleCameraError);
|
|
143
|
-
|
|
144
|
-
// Cleanup function
|
|
145
|
-
return () => {
|
|
146
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_CAMERA_CAPTURE);
|
|
147
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.CAMERA_PERMISSION_STATUS);
|
|
148
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_CAMERA_ERROR);
|
|
149
|
-
};
|
|
150
|
-
}, [base]);
|
|
151
|
-
|
|
152
|
-
// Main execute function for camera superhook
|
|
153
|
-
const executeCamera = (operation, ...args) => {
|
|
154
|
-
if (base.isWeb) {
|
|
155
|
-
console.warn(`Camera ${operation} requires web fallback implementation (isWeb: true)`);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
switch (operation) {
|
|
159
|
-
case CAMERA_OPERATIONS.TAKE_PHOTO:
|
|
160
|
-
return handleTakePhoto(args[0] || {});
|
|
161
|
-
case CAMERA_OPERATIONS.REQUEST_PERMISSION:
|
|
162
|
-
return handleRequestPermission();
|
|
163
|
-
case CAMERA_OPERATIONS.CHECK_PERMISSION:
|
|
164
|
-
return handleCheckPermission();
|
|
165
|
-
default:
|
|
166
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.INVALID_PARAMETERS, `Unknown camera operation: ${operation}`, null, `Valid operations: ${Object.values(CAMERA_OPERATIONS).join(", ")}`);
|
|
167
|
-
base.handleNativeError(error);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// Camera operation handlers
|
|
172
|
-
const handleTakePhoto = (cameraOptions = {}) => {
|
|
173
|
-
base.executeOperation(() => {
|
|
174
|
-
base.updateProgress({
|
|
175
|
-
phase: CAMERA_PHASES.REQUESTING_PERMISSION,
|
|
176
|
-
message: "Requesting camera permission..."
|
|
177
|
-
});
|
|
178
|
-
_NativeBridge.default.camera.open(cameraOptions);
|
|
179
|
-
console.log("📷 Camera open requested with options:", cameraOptions);
|
|
180
|
-
}, "photo capture");
|
|
181
|
-
};
|
|
182
|
-
const handleRequestPermission = () => {
|
|
183
|
-
base.executeOperation(() => {
|
|
184
|
-
base.updateProgress({
|
|
185
|
-
phase: CAMERA_PHASES.REQUESTING_PERMISSION,
|
|
186
|
-
message: "Requesting camera permission..."
|
|
187
|
-
});
|
|
188
|
-
if (_NativeBridge.default.camera.requestPermission) {
|
|
189
|
-
_NativeBridge.default.camera.requestPermission();
|
|
190
|
-
} else {
|
|
191
|
-
// Fallback method
|
|
192
|
-
_NativeBridge.default.camera.checkPermission();
|
|
193
|
-
}
|
|
194
|
-
console.log("📷 Camera permission requested");
|
|
195
|
-
}, "permission request");
|
|
196
|
-
};
|
|
197
|
-
const handleCheckPermission = () => {
|
|
198
|
-
base.executeOperation(() => {
|
|
199
|
-
base.updateProgress({
|
|
200
|
-
phase: CAMERA_PHASES.CHECKING_PERMISSION,
|
|
201
|
-
message: "Checking camera permission..."
|
|
202
|
-
});
|
|
203
|
-
_NativeBridge.default.camera.checkPermission();
|
|
204
|
-
console.log("📷 Camera permission check requested");
|
|
205
|
-
}, "permission check");
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// Return standardized superhook interface
|
|
209
|
-
return {
|
|
210
|
-
// Standard interface (from useBaseHook)
|
|
211
|
-
data: base.data,
|
|
212
|
-
loading: base.loading,
|
|
213
|
-
progress: base.progress,
|
|
214
|
-
error: base.error,
|
|
215
|
-
isWeb: base.isWeb,
|
|
216
|
-
isNative: base.isNative,
|
|
217
|
-
clear: base.clear,
|
|
218
|
-
clearError: base.clearError,
|
|
219
|
-
// Main execute function
|
|
220
|
-
execute: executeCamera,
|
|
221
|
-
// Semantic aliases for execute
|
|
222
|
-
takePhoto: options => executeCamera(CAMERA_OPERATIONS.TAKE_PHOTO, options),
|
|
223
|
-
requestPermission: () => executeCamera(CAMERA_OPERATIONS.REQUEST_PERMISSION),
|
|
224
|
-
checkPermission: () => executeCamera(CAMERA_OPERATIONS.CHECK_PERMISSION),
|
|
225
|
-
// Current state info
|
|
226
|
-
permission: permission,
|
|
227
|
-
// Legacy compatibility
|
|
228
|
-
photo: base.data,
|
|
229
|
-
clearPhoto: base.clear
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Standardized File Picker Hook
|
|
235
|
-
* Provides consistent interface with error standardization and environment detection
|
|
236
|
-
*
|
|
237
|
-
* @param {Object} options - Configuration options
|
|
238
|
-
* @returns {Object} Standardized file picker interface
|
|
239
|
-
*/
|
|
240
|
-
exports.useCamera = useCamera;
|
|
241
|
-
const useFilePicker = (options = {}) => {
|
|
242
|
-
const base = (0, _useBaseHook.useBaseHook)("useFilePicker", options);
|
|
243
|
-
|
|
244
|
-
// Cache for converted File objects to prevent redundant conversions
|
|
245
|
-
const fileObjectCache = (0, _react.useRef)(null);
|
|
246
|
-
|
|
247
|
-
// File picker specific progress phases
|
|
248
|
-
const FILE_PICKER_PHASES = {
|
|
249
|
-
OPENING: "opening",
|
|
250
|
-
PROCESSING: "processing",
|
|
251
|
-
ROUTING: "routing",
|
|
252
|
-
COMPLETE: "complete"
|
|
253
|
-
};
|
|
254
|
-
(0, _react.useEffect)(() => {
|
|
255
|
-
// Server-side rendering safety
|
|
256
|
-
if (typeof window === "undefined") return;
|
|
257
|
-
if (!window.WebBridge) {
|
|
258
|
-
console.warn("WebBridge not initialized. File picker functionality unavailable.");
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// File picked success handler
|
|
263
|
-
const handleFilePicked = data => {
|
|
264
|
-
try {
|
|
265
|
-
const result = typeof data === "string" ? JSON.parse(data) : data;
|
|
266
|
-
console.log("📁 File picked result:", result);
|
|
267
|
-
base.updateProgress({
|
|
268
|
-
phase: FILE_PICKER_PHASES.PROCESSING,
|
|
269
|
-
message: "Processing selected file..."
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
// Handle tri-transport format
|
|
273
|
-
const fileData = {
|
|
274
|
-
fileSrc: result.fileSrc,
|
|
275
|
-
fileName: result.fileName,
|
|
276
|
-
size: result.size,
|
|
277
|
-
mimeType: result.mimeType,
|
|
278
|
-
transport: result.transport,
|
|
279
|
-
filePath: result.filePath
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
// Clear file object cache when new file is picked
|
|
283
|
-
fileObjectCache.current = null;
|
|
284
|
-
base.setDataAndComplete(fileData);
|
|
285
|
-
console.log("📁 File processed successfully via transport:", fileData.transport);
|
|
286
|
-
} catch (parseError) {
|
|
287
|
-
console.error("📁 Error parsing file picker data:", parseError);
|
|
288
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.INTERNAL_ERROR, "Failed to process selected file", parseError);
|
|
289
|
-
base.handleNativeError(error);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// File pick error handler
|
|
294
|
-
const handleFilePickError = data => {
|
|
295
|
-
console.error("📁 File pick error:", data);
|
|
296
|
-
base.handleNativeError(data);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// File pick cancelled handler
|
|
300
|
-
const handleFilePickCancelled = data => {
|
|
301
|
-
console.log("📁 File pick cancelled:", data);
|
|
302
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.OPERATION_CANCELLED, "File selection was cancelled", data);
|
|
303
|
-
base.handleNativeError(error);
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
// File picker state updates
|
|
307
|
-
const handleFilePickStateUpdate = data => {
|
|
308
|
-
try {
|
|
309
|
-
const stateData = typeof data === "string" ? JSON.parse(data) : data;
|
|
310
|
-
console.log("📁 File picker state:", stateData.state);
|
|
311
|
-
let phase = FILE_PICKER_PHASES.PROCESSING;
|
|
312
|
-
let message = "Processing...";
|
|
313
|
-
switch (stateData.state) {
|
|
314
|
-
case "opening":
|
|
315
|
-
phase = FILE_PICKER_PHASES.OPENING;
|
|
316
|
-
message = "Opening file picker...";
|
|
317
|
-
break;
|
|
318
|
-
case "processing":
|
|
319
|
-
phase = FILE_PICKER_PHASES.PROCESSING;
|
|
320
|
-
message = "Processing selected file...";
|
|
321
|
-
break;
|
|
322
|
-
case "routing":
|
|
323
|
-
phase = FILE_PICKER_PHASES.ROUTING;
|
|
324
|
-
message = "Determining transport method...";
|
|
325
|
-
break;
|
|
326
|
-
default:
|
|
327
|
-
message = stateData.state;
|
|
328
|
-
}
|
|
329
|
-
base.updateProgress({
|
|
330
|
-
phase,
|
|
331
|
-
message
|
|
332
|
-
});
|
|
333
|
-
} catch (parseError) {
|
|
334
|
-
console.error("📁 Error parsing file picker state:", parseError);
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// Register event listeners
|
|
339
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICKED, handleFilePicked);
|
|
340
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_ERROR, handleFilePickError);
|
|
341
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_CANCELLED, handleFilePickCancelled);
|
|
342
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_STATE_UPDATE, handleFilePickStateUpdate);
|
|
343
|
-
|
|
344
|
-
// Cleanup function
|
|
345
|
-
return () => {
|
|
346
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICKED);
|
|
347
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_ERROR);
|
|
348
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_CANCELLED);
|
|
349
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_FILE_PICK_STATE_UPDATE);
|
|
350
|
-
};
|
|
351
|
-
}, [base]);
|
|
352
|
-
|
|
353
|
-
// Pick file function
|
|
354
|
-
const pickFile = (mimeType = null) => {
|
|
355
|
-
base.executeOperation(() => {
|
|
356
|
-
const finalMimeType = mimeType || "*/*";
|
|
357
|
-
base.updateProgress({
|
|
358
|
-
phase: FILE_PICKER_PHASES.OPENING,
|
|
359
|
-
message: `Opening file picker${mimeType ? ` for ${mimeType}` : ""}...`
|
|
360
|
-
});
|
|
361
|
-
_NativeBridge.default.file.pick(finalMimeType);
|
|
362
|
-
console.log("📁 File picker opened with MIME type:", finalMimeType);
|
|
363
|
-
}, "file selection");
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Get File object from current file data
|
|
368
|
-
* Lazy loading - only converts when called
|
|
369
|
-
* Caches result to prevent redundant conversions
|
|
370
|
-
* @returns {Promise<File>} JavaScript File object for FormData/POST API
|
|
371
|
-
* @throws {Error} If file data is unavailable or transport is unsupported
|
|
372
|
-
*/
|
|
373
|
-
const getFileObject = (0, _react.useCallback)(async () => {
|
|
374
|
-
// Validate file data exists
|
|
375
|
-
if (!base.data) {
|
|
376
|
-
throw new Error("No file data available. Please pick a file first.");
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Return cached File object if available
|
|
380
|
-
if (fileObjectCache.current) {
|
|
381
|
-
console.log("📁 Returning cached File object");
|
|
382
|
-
return fileObjectCache.current;
|
|
383
|
-
}
|
|
384
|
-
const {
|
|
385
|
-
fileSrc,
|
|
386
|
-
fileName,
|
|
387
|
-
mimeType,
|
|
388
|
-
transport
|
|
389
|
-
} = base.data;
|
|
390
|
-
|
|
391
|
-
// Check if transport supports File object creation
|
|
392
|
-
if (!(0, _FileObjectConverter.canCreateFileObject)(transport)) {
|
|
393
|
-
const errorMessage = (0, _FileObjectConverter.getUnsupportedTransportMessage)(transport);
|
|
394
|
-
console.error("❌", errorMessage);
|
|
395
|
-
throw new Error(errorMessage);
|
|
396
|
-
}
|
|
397
|
-
console.log("📁 Converting to File object", {
|
|
398
|
-
transport,
|
|
399
|
-
fileName,
|
|
400
|
-
mimeType
|
|
401
|
-
});
|
|
402
|
-
try {
|
|
403
|
-
let fileObject;
|
|
404
|
-
if (transport === "BRIDGE_BASE64") {
|
|
405
|
-
// Synchronous conversion for base64
|
|
406
|
-
fileObject = (0, _FileObjectConverter.base64ToFile)(fileSrc, fileName, mimeType);
|
|
407
|
-
} else if (transport === "FRAMEWORK_SERVER") {
|
|
408
|
-
// Asynchronous fetch and conversion for URL
|
|
409
|
-
fileObject = await (0, _FileObjectConverter.urlToFile)(fileSrc, fileName, mimeType);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Cache the result
|
|
413
|
-
fileObjectCache.current = fileObject;
|
|
414
|
-
console.log("✅ File object created successfully", {
|
|
415
|
-
name: fileObject.name,
|
|
416
|
-
size: fileObject.size,
|
|
417
|
-
type: fileObject.type
|
|
418
|
-
});
|
|
419
|
-
return fileObject;
|
|
420
|
-
} catch (error) {
|
|
421
|
-
console.error("❌ Failed to create File object:", error);
|
|
422
|
-
throw new Error(`Failed to create File object: ${error.message}`);
|
|
423
|
-
}
|
|
424
|
-
}, [base.data]);
|
|
425
|
-
|
|
426
|
-
// Check if File object can be created from current file data
|
|
427
|
-
const canCreateFileObjectForCurrentFile = base.data ? (0, _FileObjectConverter.canCreateFileObject)(base.data.transport) : false;
|
|
428
|
-
|
|
429
|
-
// Return standardized interface
|
|
430
|
-
return {
|
|
431
|
-
// Standard interface
|
|
432
|
-
data: base.data,
|
|
433
|
-
loading: base.loading,
|
|
434
|
-
progress: base.progress,
|
|
435
|
-
error: base.error,
|
|
436
|
-
isWeb: base.isWeb,
|
|
437
|
-
isNative: base.isNative,
|
|
438
|
-
// Actions
|
|
439
|
-
execute: pickFile,
|
|
440
|
-
// Standard execute function
|
|
441
|
-
pickFile,
|
|
442
|
-
// Semantic alias
|
|
443
|
-
clear: base.clear,
|
|
444
|
-
clearError: base.clearError,
|
|
445
|
-
// File object conversion (NEW)
|
|
446
|
-
getFileObject,
|
|
447
|
-
// Lazy loading File object converter
|
|
448
|
-
canCreateFileObject: canCreateFileObjectForCurrentFile,
|
|
449
|
-
// Boolean flag
|
|
450
|
-
|
|
451
|
-
// Legacy compatibility (for gradual migration)
|
|
452
|
-
selectedFile: base.data,
|
|
453
|
-
// Legacy alias
|
|
454
|
-
isLoading: base.loading,
|
|
455
|
-
// Legacy alias
|
|
456
|
-
processingState: base.progress?.phase,
|
|
457
|
-
// Legacy alias
|
|
458
|
-
clearFile: base.clear // Legacy alias
|
|
459
|
-
};
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Standardized Intent Hook
|
|
464
|
-
* Provides consistent interface with error standardization and environment detection
|
|
465
|
-
*
|
|
466
|
-
* @param {Object} options - Configuration options
|
|
467
|
-
* @returns {Object} Standardized intent interface
|
|
468
|
-
*/
|
|
469
|
-
exports.useFilePicker = useFilePicker;
|
|
470
|
-
const useIntent = (options = {}) => {
|
|
471
|
-
const base = (0, _useBaseHook.useBaseHook)("useIntent", options);
|
|
472
|
-
|
|
473
|
-
// Intent specific progress phases
|
|
474
|
-
const INTENT_PHASES = {
|
|
475
|
-
PREPARING: "preparing",
|
|
476
|
-
DOWNLOADING: "downloading",
|
|
477
|
-
OPENING: "opening",
|
|
478
|
-
COMPLETE: "complete"
|
|
479
|
-
};
|
|
480
|
-
(0, _react.useEffect)(() => {
|
|
481
|
-
// Server-side rendering safety
|
|
482
|
-
if (typeof window === "undefined") return;
|
|
483
|
-
if (!window.WebBridge) {
|
|
484
|
-
console.warn("WebBridge not initialized. Intent functionality unavailable.");
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// Intent success handler
|
|
489
|
-
const handleIntentSuccess = data => {
|
|
490
|
-
try {
|
|
491
|
-
const result = typeof data === "string" ? JSON.parse(data) : data;
|
|
492
|
-
console.log("🔗 Intent success result:", result);
|
|
493
|
-
const intentData = {
|
|
494
|
-
url: result.url,
|
|
495
|
-
mimeType: result.mimeType,
|
|
496
|
-
success: result.success || true,
|
|
497
|
-
message: result.message || "File opened successfully"
|
|
498
|
-
};
|
|
499
|
-
base.setDataAndComplete(intentData);
|
|
500
|
-
console.log("🔗 Intent completed successfully");
|
|
501
|
-
} catch (parseError) {
|
|
502
|
-
console.error("🔗 Error parsing intent result:", parseError);
|
|
503
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.INTERNAL_ERROR, "Failed to process intent result", parseError);
|
|
504
|
-
base.handleNativeError(error);
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
// Intent error handler
|
|
509
|
-
const handleIntentError = data => {
|
|
510
|
-
console.error("🔗 Intent error:", data);
|
|
511
|
-
base.handleNativeError(data);
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
// Intent state updates (if available)
|
|
515
|
-
const handleIntentStateUpdate = data => {
|
|
516
|
-
try {
|
|
517
|
-
const stateData = typeof data === "string" ? JSON.parse(data) : data;
|
|
518
|
-
console.log("🔗 Intent state:", stateData.state);
|
|
519
|
-
let phase = INTENT_PHASES.PREPARING;
|
|
520
|
-
let message = "Processing...";
|
|
521
|
-
switch (stateData.state) {
|
|
522
|
-
case "preparing":
|
|
523
|
-
phase = INTENT_PHASES.PREPARING;
|
|
524
|
-
message = "Preparing to open file...";
|
|
525
|
-
break;
|
|
526
|
-
case "downloading":
|
|
527
|
-
phase = INTENT_PHASES.DOWNLOADING;
|
|
528
|
-
message = "Downloading file...";
|
|
529
|
-
break;
|
|
530
|
-
case "opening":
|
|
531
|
-
phase = INTENT_PHASES.OPENING;
|
|
532
|
-
message = "Opening with external app...";
|
|
533
|
-
break;
|
|
534
|
-
default:
|
|
535
|
-
message = stateData.state;
|
|
536
|
-
}
|
|
537
|
-
base.updateProgress({
|
|
538
|
-
phase,
|
|
539
|
-
message,
|
|
540
|
-
percentage: stateData.percentage || null
|
|
541
|
-
});
|
|
542
|
-
} catch (parseError) {
|
|
543
|
-
console.error("🔗 Error parsing intent state:", parseError);
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
// Register event listeners (some callbacks might not exist in legacy intent)
|
|
548
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_SUCCESS || "ON_INTENT_SUCCESS", handleIntentSuccess);
|
|
549
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_ERROR || "ON_INTENT_ERROR", handleIntentError);
|
|
550
|
-
|
|
551
|
-
// Optional state updates (might not be implemented in current intent system)
|
|
552
|
-
if (_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_STATE_UPDATE) {
|
|
553
|
-
window.WebBridge.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_STATE_UPDATE, handleIntentStateUpdate);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// Cleanup function
|
|
557
|
-
return () => {
|
|
558
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_SUCCESS || "ON_INTENT_SUCCESS");
|
|
559
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_ERROR || "ON_INTENT_ERROR");
|
|
560
|
-
if (_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_STATE_UPDATE) {
|
|
561
|
-
window.WebBridge.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_INTENT_STATE_UPDATE);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
}, [base]);
|
|
565
|
-
|
|
566
|
-
// Open file function
|
|
567
|
-
const openFile = (url, mimeType = null) => {
|
|
568
|
-
if (!url) {
|
|
569
|
-
const error = (0, _errors.createStandardError)(_errors.ERROR_CODES.INVALID_PARAMETERS, "URL is required for opening files", null, "Please provide a valid URL to open");
|
|
570
|
-
base.handleNativeError(error);
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
base.executeOperation(() => {
|
|
574
|
-
const finalMimeType = mimeType || "*/*";
|
|
575
|
-
base.updateProgress({
|
|
576
|
-
phase: INTENT_PHASES.PREPARING,
|
|
577
|
-
message: `Preparing to open ${url}...`
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
// Check if intent system has specific methods
|
|
581
|
-
if (_NativeBridge.default.intent && _NativeBridge.default.intent.openFile) {
|
|
582
|
-
_NativeBridge.default.intent.openFile(url, finalMimeType);
|
|
583
|
-
} else {
|
|
584
|
-
// Fallback to generic method if available
|
|
585
|
-
_NativeBridge.default.openFile(url, finalMimeType);
|
|
586
|
-
}
|
|
587
|
-
console.log("🔗 Intent to open file:", url, "with MIME type:", finalMimeType);
|
|
588
|
-
}, "file opening");
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
// Return standardized interface
|
|
592
|
-
return {
|
|
593
|
-
// Standard interface
|
|
594
|
-
data: base.data,
|
|
595
|
-
loading: base.loading,
|
|
596
|
-
progress: base.progress,
|
|
597
|
-
error: base.error,
|
|
598
|
-
isWeb: base.isWeb,
|
|
599
|
-
isNative: base.isNative,
|
|
600
|
-
// Actions
|
|
601
|
-
execute: openFile,
|
|
602
|
-
// Standard execute function
|
|
603
|
-
openFile,
|
|
604
|
-
// Semantic alias
|
|
605
|
-
clear: base.clear,
|
|
606
|
-
clearError: base.clearError,
|
|
607
|
-
// Legacy compatibility (for gradual migration)
|
|
608
|
-
result: base.data // Legacy alias if needed
|
|
609
|
-
};
|
|
610
|
-
};
|
|
611
|
-
exports.useIntent = useIntent;
|
package/dist/router.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@tata1mg/router"
|