From 64ef7439d89e0b993cfb12d0e759f4d6b59ebae3 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Sun, 21 Apr 2024 23:34:01 +0200 Subject: [PATCH] chore: Cleanup TS codebase and fix Skia Preview View style/layout issue (#2767) * chore: Cleanup TS codebase * chore: More refactors * fix: Put Skia Canvas into CameraView * Update Camera.tsx * fix: Fix JNI types --- .../FRAME_PROCESSORS_CREATE_OVERVIEW.mdx | 8 ++-- .../FRAME_PROCESSORS_CREATE_PLUGIN_CPP.mdx | 2 +- docs/docs/guides/FRAME_PROCESSORS_TIPS.mdx | 2 +- .../FRAME_PROCESSOR_CREATE_PLUGIN_IOS.mdx | 4 +- .../cpp/frameprocessors/VisionCameraProxy.h | 2 +- .../frameprocessors/java-bindings/JFrame.h | 2 +- .../java-bindings/JFrameProcessor.h | 2 +- .../java-bindings/JFrameProcessorPlugin.h | 2 +- .../java-bindings/JJSUnionValue.h | 4 +- .../java-bindings/JOrientation.h | 2 +- .../java-bindings/JPixelFormat.h | 4 +- .../java-bindings/JSharedArray.h | 2 +- .../java-bindings/JVisionCameraProxy.h | 2 +- .../java-bindings/JVisionCameraScheduler.h | 2 +- package/src/Camera.tsx | 46 +++++++++---------- package/src/CameraDevices.ts | 2 +- package/src/FrameProcessorPlugins.ts | 2 +- package/src/devices/getCameraDevice.ts | 2 +- package/src/devices/getCameraFormat.ts | 2 +- package/src/hooks/useCameraDevice.ts | 2 +- package/src/hooks/useCameraDevices.ts | 2 +- package/src/hooks/useCameraFormat.ts | 2 +- package/src/hooks/useCodeScanner.ts | 2 +- package/src/hooks/useFrameProcessor.ts | 4 +- package/src/index.ts | 23 +++++----- package/src/skia/SkiaCameraCanvas.tsx | 2 +- package/src/skia/useSkiaFrameProcessor.ts | 6 +-- package/src/{ => types}/CameraDevice.ts | 0 package/src/{ => types}/CameraProps.ts | 2 +- package/src/{ => types}/CodeScanner.ts | 0 package/src/{ => types}/Frame.ts | 0 package/src/{ => types}/Orientation.ts | 0 package/src/{ => types}/PhotoFile.ts | 0 package/src/{ => types}/PixelFormat.ts | 0 package/src/{ => types}/Point.ts | 0 package/src/{ => types}/Snapshot.ts | 0 package/src/{ => types}/TemporaryFile.ts | 0 package/src/{ => types}/VideoFile.ts | 2 +- 38 files changed, 70 insertions(+), 71 deletions(-) rename package/src/{ => types}/CameraDevice.ts (100%) rename package/src/{ => types}/CameraProps.ts (99%) rename package/src/{ => types}/CodeScanner.ts (100%) rename package/src/{ => types}/Frame.ts (100%) rename package/src/{ => types}/Orientation.ts (100%) rename package/src/{ => types}/PhotoFile.ts (100%) rename package/src/{ => types}/PixelFormat.ts (100%) rename package/src/{ => types}/Point.ts (100%) rename package/src/{ => types}/Snapshot.ts (100%) rename package/src/{ => types}/TemporaryFile.ts (100%) rename package/src/{ => types}/VideoFile.ts (97%) diff --git a/docs/docs/guides/FRAME_PROCESSORS_CREATE_OVERVIEW.mdx b/docs/docs/guides/FRAME_PROCESSORS_CREATE_OVERVIEW.mdx index 8ac258e843..23428c9afd 100644 --- a/docs/docs/guides/FRAME_PROCESSORS_CREATE_OVERVIEW.mdx +++ b/docs/docs/guides/FRAME_PROCESSORS_CREATE_OVERVIEW.mdx @@ -203,10 +203,10 @@ Your Frame Processor Plugins have to be fast. Use the FPS Graph (`enableFpsGraph #### 🚀 Create your first Frame Processor Plugin for [iOS](frame-processors-plugins-ios) or [Android](frame-processors-plugins-android)! [1]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/src/Frame.ts -[2]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/ios/Frame%20Processor/Frame.h -[3]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/android/src/main/java/com/mrousavy/camera/frameprocessor/Frame.java +[2]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/ios/FrameProcessors/Frame.h +[3]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/android/src/main/java/com/mrousavy/camera/frameprocessors/Frame.java [4]: https://github.com/facebook/react-native/blob/9a43eac7a32a6ba3164a048960101022a92fcd5a/React/Base/RCTBridgeModule.h#L20-L24 [5]: https://developer.apple.com/documentation/coremedia/cmsamplebuffer [6]: https://developer.android.com/reference/androidx/camera/core/ImageProxy -[7]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/ios/Frame%20Processor/SharedArray.h -[8]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/android/src/main/java/com/mrousavy/camera/frameprocessor/SharedArray.java +[7]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/ios/FrameProcessors/SharedArray.h +[8]: https://github.com/mrousavy/react-native-vision-camera/blob/main/package/android/src/main/java/com/mrousavy/camera/frameprocessors/SharedArray.java diff --git a/docs/docs/guides/FRAME_PROCESSORS_CREATE_PLUGIN_CPP.mdx b/docs/docs/guides/FRAME_PROCESSORS_CREATE_PLUGIN_CPP.mdx index 68a6e9510f..dad7a792af 100644 --- a/docs/docs/guides/FRAME_PROCESSORS_CREATE_PLUGIN_CPP.mdx +++ b/docs/docs/guides/FRAME_PROCESSORS_CREATE_PLUGIN_CPP.mdx @@ -20,7 +20,7 @@ For example: ```cpp // 1. Include headers -#include "frameprocessor/FrameHostObject.h" +#include "frameprocessors/FrameHostObject.h" // 2. Create C++ func auto myPlugin = [=](jsi::Runtime& runtime, diff --git a/docs/docs/guides/FRAME_PROCESSORS_TIPS.mdx b/docs/docs/guides/FRAME_PROCESSORS_TIPS.mdx index 8a57df0fae..4776272c32 100644 --- a/docs/docs/guides/FRAME_PROCESSORS_TIPS.mdx +++ b/docs/docs/guides/FRAME_PROCESSORS_TIPS.mdx @@ -54,7 +54,7 @@ In my benchmarks, Frame Processors can run more than 1000 times a second. Frame Processor Plugins are native functions (written in Objective-C, Swift, C++, Java or Kotlin) that are injected into the VisionCamera JS-Runtime. They can be synchronously called from your JS Frame Processors (using JSI) without ever going over the bridge. Because VisionCamera provides an easy-to-use plugin API, you can easily create a Frame Processor Plugin yourself. Some examples include [Barcode Scanning](https://developers.google.com/ml-kit/vision/barcode-scanning), [Face Detection](https://developers.google.com/ml-kit/vision/face-detection), [Image Labeling](https://developers.google.com/ml-kit/vision/image-labeling), [Text Recognition](https://developers.google.com/ml-kit/vision/text-recognition) and more. -> Learn how to [create Frame Processor Plugins](frame-processors-plugins-overview), or check out the [example Frame Processor Plugin for iOS](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/Frame%20Processor%20Plugins/Example%20Swift%20Plugin/ExampleSwiftFrameProcessor.swift) or [Android](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/android/app/src/main/java/com/mrousavy/camera/example/ExampleKotlinFrameProcessorPlugin.kt). +> Learn how to [create Frame Processor Plugins](frame-processors-plugins-overview), or check out the [example Frame Processor Plugin for iOS](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/FrameProcessors%20Plugins/Example%20Swift%20Plugin/ExampleSwiftFrameProcessor.swift) or [Android](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/android/app/src/main/java/com/mrousavy/camera/example/ExampleKotlinFrameProcessorPlugin.kt). ### The `Frame` object diff --git a/docs/docs/guides/FRAME_PROCESSOR_CREATE_PLUGIN_IOS.mdx b/docs/docs/guides/FRAME_PROCESSOR_CREATE_PLUGIN_IOS.mdx index fefa0f1b2b..33800034f9 100644 --- a/docs/docs/guides/FRAME_PROCESSOR_CREATE_PLUGIN_IOS.mdx +++ b/docs/docs/guides/FRAME_PROCESSOR_CREATE_PLUGIN_IOS.mdx @@ -75,7 +75,7 @@ VISION_EXPORT_FRAME_PROCESSOR(FaceDetectorFrameProcessorPlugin, detectFaces) The Frame Processor Plugin will be exposed to JS through the `VisionCameraProxy` object. In this case, it would be `VisionCameraProxy.initFrameProcessorPlugin("detectFaces")`. ::: -4. **Implement your Frame Processing.** See the [Example Plugin (Objective-C)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/Frame%20Processor%20Plugins/Example%20Plugin/ExampleFrameProcessorPlugin.m) for reference. +4. **Implement your Frame Processing.** See the [Example Plugin (Objective-C)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/FrameProcessors%20Plugins/Example%20Plugin/ExampleFrameProcessorPlugin.m) for reference. @@ -118,7 +118,7 @@ VISION_EXPORT_SWIFT_FRAME_PROCESSOR(FaceDetectorFrameProcessorPlugin, detectFace // highlight-end ``` -5. **Implement your frame processing.** See [Example Plugin (Swift)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/Frame%20Processor%20Plugins/Example%20Swift%20Plugin/ExampleSwiftFrameProcessor.swift) for reference. +5. **Implement your frame processing.** See [Example Plugin (Swift)](https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/ios/FrameProcessors%20Plugins/Example%20Swift%20Plugin/ExampleSwiftFrameProcessor.swift) for reference. diff --git a/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.h b/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.h index 078130748e..6dc8fde483 100644 --- a/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.h +++ b/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.h @@ -37,7 +37,7 @@ class VisionCameraProxy : public jsi::HostObject { class VisionCameraInstaller : public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraInstaller;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/VisionCameraInstaller;"; static void registerNatives(); static void install(jni::alias_ref clazz, jni::alias_ref proxy); }; diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrame.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrame.h index 19d8b5d261..802b5751d1 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrame.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrame.h @@ -17,7 +17,7 @@ using namespace facebook; using namespace jni; struct JFrame : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/Frame;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/Frame;"; public: int getWidth() const; diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.h index 3c688a88fa..c164290a5d 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.h @@ -23,7 +23,7 @@ using namespace facebook; struct JFrameProcessor : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/FrameProcessor;"; static void registerNatives(); static jni::local_ref create(const std::shared_ptr& worklet, const std::shared_ptr& context); diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.h index d565734333..4d07c29460 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.h @@ -16,7 +16,7 @@ using namespace facebook; using namespace jni; struct JFrameProcessorPlugin : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessorPlugin;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/FrameProcessorPlugin;"; public: /** diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JJSUnionValue.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JJSUnionValue.h index 16c9baddde..4e82ab8f4c 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JJSUnionValue.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JJSUnionValue.h @@ -13,7 +13,7 @@ using namespace facebook; using namespace jni; struct JJSUnionValue : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/types/JSUnionValue;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/core/types/JSUnionValue;"; local_ref getUnionValue() { const auto getUnionValueMethod = getClass()->getMethod("getUnionValue"); @@ -21,4 +21,4 @@ struct JJSUnionValue : public JavaClass { } }; -} // namespace vision \ No newline at end of file +} // namespace vision diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JOrientation.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JOrientation.h index 458ed1b649..971351b681 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JOrientation.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JOrientation.h @@ -14,7 +14,7 @@ using namespace facebook; using namespace jni; struct JOrientation : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/types/Orientation;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/core/types/Orientation;"; }; } // namespace vision diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JPixelFormat.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JPixelFormat.h index 8b04c53f02..af2a61b6a9 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JPixelFormat.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JPixelFormat.h @@ -14,7 +14,7 @@ using namespace facebook; using namespace jni; struct JPixelFormat : public JavaClass { - static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/types/PixelFormat;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/core/types/PixelFormat;"; }; -} // namespace vision \ No newline at end of file +} // namespace vision diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JSharedArray.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JSharedArray.h index d9f6612a01..4069c2d790 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JSharedArray.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JSharedArray.h @@ -16,7 +16,7 @@ using namespace facebook; class JSharedArray : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/SharedArray;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/SharedArray;"; static void registerNatives(); public: diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.h index 031675054b..d06eaa84df 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.h @@ -56,7 +56,7 @@ class JVisionCameraProxy : public jni::HybridClass { #endif static auto constexpr TAG = "VisionCameraProxy"; - static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraProxy;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/VisionCameraProxy;"; explicit JVisionCameraProxy(const jni::alias_ref& javaThis, jsi::Runtime* jsRuntime, const std::shared_ptr& jsCallInvoker, diff --git a/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.h b/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.h index 06603b060a..3c153fd115 100644 --- a/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.h +++ b/package/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.h @@ -25,7 +25,7 @@ using namespace facebook; */ class JVisionCameraScheduler : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraScheduler;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessors/VisionCameraScheduler;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); diff --git a/package/src/Camera.tsx b/package/src/Camera.tsx index 2aa7517e10..329aeb3308 100644 --- a/package/src/Camera.tsx +++ b/package/src/Camera.tsx @@ -1,20 +1,20 @@ import React from 'react' -import { requireNativeComponent, findNodeHandle, View, StyleSheet } from 'react-native' -import type { CameraDevice } from './CameraDevice' +import { requireNativeComponent, findNodeHandle, StyleSheet } from 'react-native' +import type { CameraDevice } from './types/CameraDevice' import type { ErrorWithCause, CameraCaptureError } from './CameraError' import { CameraRuntimeError, tryParseNativeCameraError, isErrorWithCause } from './CameraError' -import type { CameraProps, OnShutterEvent } from './CameraProps' +import type { CameraProps, OnShutterEvent } from './types/CameraProps' import { CameraModule } from './NativeCameraModule' -import type { PhotoFile, TakePhotoOptions } from './PhotoFile' -import type { Point } from './Point' -import type { RecordVideoOptions, VideoFile } from './VideoFile' +import type { PhotoFile, TakePhotoOptions } from './types/PhotoFile' +import type { Point } from './types/Point' +import type { RecordVideoOptions, VideoFile } from './types/VideoFile' import { VisionCameraProxy } from './FrameProcessorPlugins' import { CameraDevices } from './CameraDevices' import type { EmitterSubscription, NativeSyntheticEvent, NativeMethods } from 'react-native' -import type { Code, CodeScanner, CodeScannerFrame } from './CodeScanner' -import type { TakeSnapshotOptions } from './Snapshot' +import type { Code, CodeScanner, CodeScannerFrame } from './types/CodeScanner' +import type { TakeSnapshotOptions } from './types/Snapshot' import { SkiaCameraCanvas } from './skia/SkiaCameraCanvas' -import type { Frame } from './Frame' +import type { Frame } from './types/Frame' //#region Types export type CameraPermissionStatus = 'granted' | 'not-determined' | 'denied' | 'restricted' @@ -586,7 +586,7 @@ export class Camera extends React.PureComponent { const torch = this.state.isRecordingWithFlash ? 'on' : props.torch const isRenderingWithSkia = frameProcessor?.type === 'drawable-skia' - const result = ( + return ( { enableFrameProcessor={frameProcessor != null} enableBufferCompression={props.enableBufferCompression ?? shouldEnableBufferCompression} enableFpsGraph={frameProcessor != null && props.enableFpsGraph} - preview={isRenderingWithSkia ? false : props.preview ?? true} - /> - ) - - if (frameProcessor?.type === 'drawable-skia') { - return ( - + preview={isRenderingWithSkia ? false : props.preview ?? true}> + {frameProcessor?.type === 'drawable-skia' && ( - {result} - - ) - } else { - return result - } + )} + + ) } } //#endregion @@ -631,3 +623,9 @@ const NativeCameraView = requireNativeComponent( // @ts-expect-error because the type declarations are kinda wrong, no? Camera, ) + +const styles = StyleSheet.create({ + customPreviewView: { + flex: 1, + }, +}) diff --git a/package/src/CameraDevices.ts b/package/src/CameraDevices.ts index e23c83052a..5866143858 100644 --- a/package/src/CameraDevices.ts +++ b/package/src/CameraDevices.ts @@ -1,5 +1,5 @@ import { NativeModules, NativeEventEmitter } from 'react-native' -import type { CameraDevice } from './CameraDevice' +import type { CameraDevice } from './types/CameraDevice' const CameraDevicesManager = NativeModules.CameraDevices as { getConstants: () => { diff --git a/package/src/FrameProcessorPlugins.ts b/package/src/FrameProcessorPlugins.ts index 6e52161bca..c8bd29dfee 100644 --- a/package/src/FrameProcessorPlugins.ts +++ b/package/src/FrameProcessorPlugins.ts @@ -1,4 +1,4 @@ -import type { Frame, FrameInternal } from './Frame' +import type { Frame, FrameInternal } from './types/Frame' import { CameraRuntimeError } from './CameraError' import { CameraModule } from './NativeCameraModule' import { assertJSIAvailable } from './JSIHelper' diff --git a/package/src/devices/getCameraDevice.ts b/package/src/devices/getCameraDevice.ts index e8dcc9e8fe..6a3da28748 100644 --- a/package/src/devices/getCameraDevice.ts +++ b/package/src/devices/getCameraDevice.ts @@ -1,4 +1,4 @@ -import type { CameraDevice, CameraPosition, PhysicalCameraDeviceType } from '../CameraDevice' +import type { CameraDevice, CameraPosition, PhysicalCameraDeviceType } from '../types/CameraDevice' export interface DeviceFilter { /** diff --git a/package/src/devices/getCameraFormat.ts b/package/src/devices/getCameraFormat.ts index bdccebdf48..ec48e951b8 100644 --- a/package/src/devices/getCameraFormat.ts +++ b/package/src/devices/getCameraFormat.ts @@ -1,4 +1,4 @@ -import type { AutoFocusSystem, CameraDevice, CameraDeviceFormat, VideoStabilizationMode } from '../CameraDevice' +import type { AutoFocusSystem, CameraDevice, CameraDeviceFormat, VideoStabilizationMode } from '../types/CameraDevice' import { CameraRuntimeError } from '../CameraError' interface Size { diff --git a/package/src/hooks/useCameraDevice.ts b/package/src/hooks/useCameraDevice.ts index b0af516e4f..dcad60e3f5 100644 --- a/package/src/hooks/useCameraDevice.ts +++ b/package/src/hooks/useCameraDevice.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react' -import type { CameraDevice, CameraPosition } from '../CameraDevice' +import type { CameraDevice, CameraPosition } from '../types/CameraDevice' import type { DeviceFilter } from '../devices/getCameraDevice' import { getCameraDevice } from '../devices/getCameraDevice' import { useCameraDevices } from './useCameraDevices' diff --git a/package/src/hooks/useCameraDevices.ts b/package/src/hooks/useCameraDevices.ts index 0e98c50368..6dbd038321 100644 --- a/package/src/hooks/useCameraDevices.ts +++ b/package/src/hooks/useCameraDevices.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import type { CameraDevice } from '../CameraDevice' +import type { CameraDevice } from '../types/CameraDevice' import { CameraDevices } from '../CameraDevices' /** diff --git a/package/src/hooks/useCameraFormat.ts b/package/src/hooks/useCameraFormat.ts index 2304c85cc2..3b4df4a90a 100644 --- a/package/src/hooks/useCameraFormat.ts +++ b/package/src/hooks/useCameraFormat.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react' -import type { CameraDevice, CameraDeviceFormat } from '../CameraDevice' +import type { CameraDevice, CameraDeviceFormat } from '../types/CameraDevice' import type { FormatFilter } from '../devices/getCameraFormat' import { getCameraFormat } from '../devices/getCameraFormat' diff --git a/package/src/hooks/useCodeScanner.ts b/package/src/hooks/useCodeScanner.ts index 991e39113a..7a241baacc 100644 --- a/package/src/hooks/useCodeScanner.ts +++ b/package/src/hooks/useCodeScanner.ts @@ -1,5 +1,5 @@ import { useCallback, useMemo, useRef } from 'react' -import type { Code, CodeScanner, CodeScannerFrame } from '../CodeScanner' +import type { Code, CodeScanner, CodeScannerFrame } from '../types/CodeScanner' export function useCodeScanner(codeScanner: CodeScanner): CodeScanner { const { onCodeScanned, ...codeScannerOptions } = codeScanner diff --git a/package/src/hooks/useFrameProcessor.ts b/package/src/hooks/useFrameProcessor.ts index d63acdc478..8afa677a59 100644 --- a/package/src/hooks/useFrameProcessor.ts +++ b/package/src/hooks/useFrameProcessor.ts @@ -1,8 +1,8 @@ import type { DependencyList } from 'react' import { useMemo } from 'react' import { wrapFrameProcessorWithRefCounting } from '../FrameProcessorPlugins' -import type { ReadonlyFrameProcessor } from '../CameraProps' -import type { Frame } from '../Frame' +import type { ReadonlyFrameProcessor } from '../types/CameraProps' +import type { Frame } from '../types/Frame' /** * Create a new Frame Processor function which you can pass to the ``. diff --git a/package/src/index.ts b/package/src/index.ts index d385cb3462..79a4adbb90 100644 --- a/package/src/index.ts +++ b/package/src/index.ts @@ -1,16 +1,17 @@ export * from './Camera' -export * from './CameraDevice' export * from './CameraError' -export * from './CameraProps' -export * from './Frame' export * from './FrameProcessorPlugins' -export * from './Orientation' -export * from './PhotoFile' -export * from './Snapshot' -export * from './PixelFormat' -export * from './Point' -export * from './VideoFile' -export * from './CodeScanner' + +export * from './types/CameraDevice' +export * from './types/CameraProps' +export * from './types/Frame' +export * from './types/Orientation' +export * from './types/PhotoFile' +export * from './types/Snapshot' +export * from './types/PixelFormat' +export * from './types/Point' +export * from './types/VideoFile' +export * from './types/CodeScanner' export * from './devices/getCameraFormat' export * from './devices/getCameraDevice' @@ -20,7 +21,7 @@ export * from './hooks/useCameraDevice' export * from './hooks/useCameraDevices' export * from './hooks/useCameraFormat' export * from './hooks/useCameraPermission' -export * from './hooks/useFrameProcessor' export * from './hooks/useCodeScanner' +export * from './hooks/useFrameProcessor' export * from './skia/useSkiaFrameProcessor' diff --git a/package/src/skia/SkiaCameraCanvas.tsx b/package/src/skia/SkiaCameraCanvas.tsx index 9dd2f9e442..e3a9ccd1f0 100644 --- a/package/src/skia/SkiaCameraCanvas.tsx +++ b/package/src/skia/SkiaCameraCanvas.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from 'react' import type { LayoutChangeEvent, ViewProps } from 'react-native' -import type { CameraProps } from '../CameraProps' +import type { CameraProps } from '../types/CameraProps' import type { ISharedValue } from 'react-native-worklets-core' import { ReanimatedProxy } from '../dependencies/ReanimatedProxy' import type { SkImage } from '@shopify/react-native-skia' diff --git a/package/src/skia/useSkiaFrameProcessor.ts b/package/src/skia/useSkiaFrameProcessor.ts index d4eb8ea763..b78e97135c 100644 --- a/package/src/skia/useSkiaFrameProcessor.ts +++ b/package/src/skia/useSkiaFrameProcessor.ts @@ -1,9 +1,9 @@ -import type { Frame, FrameInternal } from '../Frame' +import type { Frame, FrameInternal } from '../types/Frame' import type { DependencyList } from 'react' import { useEffect, useMemo } from 'react' -import type { Orientation } from '../Orientation' +import type { Orientation } from '../types/Orientation' import { VisionCameraProxy, wrapFrameProcessorWithRefCounting } from '../FrameProcessorPlugins' -import type { DrawableFrameProcessor } from '../CameraProps' +import type { DrawableFrameProcessor } from '../types/CameraProps' import type { ISharedValue, IWorkletNativeApi } from 'react-native-worklets-core' import { WorkletsProxy } from '../dependencies/WorkletsProxy' import type { SkCanvas, SkPaint, SkImage, SkSurface } from '@shopify/react-native-skia' diff --git a/package/src/CameraDevice.ts b/package/src/types/CameraDevice.ts similarity index 100% rename from package/src/CameraDevice.ts rename to package/src/types/CameraDevice.ts diff --git a/package/src/CameraProps.ts b/package/src/types/CameraProps.ts similarity index 99% rename from package/src/CameraProps.ts rename to package/src/types/CameraProps.ts index feb7098013..09991abbd5 100644 --- a/package/src/CameraProps.ts +++ b/package/src/types/CameraProps.ts @@ -1,6 +1,6 @@ import type { ViewProps } from 'react-native' import type { CameraDevice, CameraDeviceFormat, VideoStabilizationMode } from './CameraDevice' -import type { CameraRuntimeError } from './CameraError' +import type { CameraRuntimeError } from '../CameraError' import type { CodeScanner } from './CodeScanner' import type { Frame } from './Frame' import type { Orientation } from './Orientation' diff --git a/package/src/CodeScanner.ts b/package/src/types/CodeScanner.ts similarity index 100% rename from package/src/CodeScanner.ts rename to package/src/types/CodeScanner.ts diff --git a/package/src/Frame.ts b/package/src/types/Frame.ts similarity index 100% rename from package/src/Frame.ts rename to package/src/types/Frame.ts diff --git a/package/src/Orientation.ts b/package/src/types/Orientation.ts similarity index 100% rename from package/src/Orientation.ts rename to package/src/types/Orientation.ts diff --git a/package/src/PhotoFile.ts b/package/src/types/PhotoFile.ts similarity index 100% rename from package/src/PhotoFile.ts rename to package/src/types/PhotoFile.ts diff --git a/package/src/PixelFormat.ts b/package/src/types/PixelFormat.ts similarity index 100% rename from package/src/PixelFormat.ts rename to package/src/types/PixelFormat.ts diff --git a/package/src/Point.ts b/package/src/types/Point.ts similarity index 100% rename from package/src/Point.ts rename to package/src/types/Point.ts diff --git a/package/src/Snapshot.ts b/package/src/types/Snapshot.ts similarity index 100% rename from package/src/Snapshot.ts rename to package/src/types/Snapshot.ts diff --git a/package/src/TemporaryFile.ts b/package/src/types/TemporaryFile.ts similarity index 100% rename from package/src/TemporaryFile.ts rename to package/src/types/TemporaryFile.ts diff --git a/package/src/VideoFile.ts b/package/src/types/VideoFile.ts similarity index 97% rename from package/src/VideoFile.ts rename to package/src/types/VideoFile.ts index 65d37220e2..28007f2d53 100644 --- a/package/src/VideoFile.ts +++ b/package/src/types/VideoFile.ts @@ -1,4 +1,4 @@ -import type { CameraCaptureError } from './CameraError' +import type { CameraCaptureError } from '../CameraError' import type { TemporaryFile } from './TemporaryFile' export interface RecordVideoOptions {