chore: Clean up root directory (#236)
* Clean up root * remove unused REA patches * Remove `cpp/` and create headers per platform * fix `#import` * fix `VISION_CAMERA_DISABLE_FRAME_PROCESSORS`
This commit is contained in:
parent
65168f7abb
commit
2fa0f8fd46
@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
bracketSpacing: true,
|
||||
jsxBracketSameLine: true,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
semi: true,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
printWidth: 140
|
||||
};
|
@ -49,7 +49,6 @@ target_include_directories(
|
||||
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/headers/Registries"
|
||||
"${NODE_MODULES_DIR}/react-native-reanimated/Common/cpp/hidden_headers"
|
||||
"src/main/cpp"
|
||||
"../cpp"
|
||||
)
|
||||
|
||||
# find libraries
|
||||
|
30
android/src/main/cpp/MakeJSIRuntime.h
Normal file
30
android/src/main/cpp/MakeJSIRuntime.h
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Created by Marc Rousavy on 06.07.21.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jsi/jsi.h>
|
||||
#include <memory>
|
||||
|
||||
#if FOR_HERMES
|
||||
// Hermes
|
||||
#include <hermes/hermes.h>
|
||||
#else
|
||||
// JSC
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#endif
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
namespace vision {
|
||||
|
||||
static std::unique_ptr<jsi::Runtime> makeJSIRuntime() {
|
||||
#if FOR_HERMES
|
||||
return facebook::hermes::makeHermesRuntime();
|
||||
#else
|
||||
return facebook::jsc::makeJSCRuntime();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace vision
|
@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
};
|
@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <jsi/jsi.h>
|
||||
#include <memory>
|
||||
|
||||
#ifdef ON_ANDROID
|
||||
|
||||
// on Android we need to pass FOR_HERMES flag to determine if hermes is used or not since both headers are there.
|
||||
|
||||
#if FOR_HERMES
|
||||
// Hermes
|
||||
#include <hermes/hermes.h>
|
||||
#else
|
||||
// JSC
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// on iOS, we simply check by __has_include. Headers are only available if the sources are there too.
|
||||
|
||||
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
||||
// Hermes (https://hermesengine.dev) (RN 0.65+)
|
||||
#include <reacthermes/HermesExecutorFactory.h>
|
||||
#elif __has_include(<hermes/hermes.h>)
|
||||
// Hermes (https://hermesengine.dev)
|
||||
#include <hermes/hermes.h>
|
||||
#elif __has_include(<v8runtime/V8RuntimeFactory.h>)
|
||||
// V8 (https://github.com/Kudo/react-native-v8)
|
||||
#include <v8runtime/V8RuntimeFactory.h>
|
||||
#else
|
||||
// JSC
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
namespace vision {
|
||||
|
||||
static std::unique_ptr<jsi::Runtime> makeJSIRuntime() {
|
||||
#ifdef ON_ANDROID
|
||||
|
||||
#if FOR_HERMES
|
||||
return facebook::hermes::makeHermesRuntime();
|
||||
#else
|
||||
return facebook::jsc::makeJSCRuntime();
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if __has_include(<hermes/hermes.h>) || __has_include(<reacthermes/HermesExecutorFactory.h>)
|
||||
return facebook::hermes::makeHermesRuntime();
|
||||
#elif __has_include(<v8runtime/V8RuntimeFactory.h>)
|
||||
return facebook::createV8Runtime("");
|
||||
#else
|
||||
return facebook::jsc::makeJSCRuntime();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace vision
|
@ -1,26 +0,0 @@
|
||||
# cpp
|
||||
|
||||
This folder contains the Shared C++ code for react-native-vision-camera.
|
||||
|
||||
## Prerequesites
|
||||
|
||||
1. For Android, download the [NDK and build tools](https://developer.android.com/studio/projects/add-native-code#download-ndk)
|
||||
2. For iOS, Xcode will be enough.
|
||||
3. Install cpplint
|
||||
```sh
|
||||
brew install cpplint
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
It is recommended that you work on the code using the Example project (`example/android/` or `example/ios/VisionCameraExample.xcworkspace`), since that always includes the React Native header files, plus you can easily test changes that way.
|
||||
|
||||
You can however still edit the library project here by opening this folder with any C++ editor.
|
||||
|
||||
## Committing
|
||||
|
||||
Before committing, make sure that you're not violating the cpplint codestyles. To do that, run the following command:
|
||||
|
||||
```bash
|
||||
yarn check-cpp
|
||||
```
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Logger.h"
|
||||
#include <string>
|
||||
|
||||
namespace vision {
|
||||
|
||||
class SpeedChecker {
|
||||
public:
|
||||
static void checkSpeed(std::string tag, std::function<void()> fun) {
|
||||
auto start = std::chrono::system_clock::now();
|
||||
fun();
|
||||
auto end = std::chrono::system_clock::now();
|
||||
std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
tag += " " + std::to_string(elapsed_seconds.count()) + "s";
|
||||
Logger::log(tag.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace vision
|
@ -118,7 +118,7 @@ module.exports = {
|
||||
name: 'VisionCamera',
|
||||
entryPoints: ['../src'],
|
||||
exclude: "../src/index.ts",
|
||||
tsconfig: '../tsconfig.docs.json',
|
||||
tsconfig: '../tsconfig.build.json',
|
||||
excludePrivate: true,
|
||||
excludeProtected: true,
|
||||
excludeExternals: true,
|
||||
|
@ -1,20 +0,0 @@
|
||||
diff --git a/node_modules/react-native-reanimated/android/build.gradle b/node_modules/react-native-reanimated/android/build.gradle
|
||||
index bb707e7..9186873 100644
|
||||
--- a/node_modules/react-native-reanimated/android/build.gradle
|
||||
+++ b/node_modules/react-native-reanimated/android/build.gradle
|
||||
@@ -7,8 +7,12 @@ def reactNativeVersion = json.version as String
|
||||
def (major, minor, patch) = reactNativeVersion.tokenize('.')
|
||||
|
||||
def engine = "jsc"
|
||||
-if (project(':app').ext.react.enableHermes) {
|
||||
- engine = "hermes"
|
||||
-}
|
||||
+rootProject.getSubprojects().forEach({project ->
|
||||
+ if (project.plugins.hasPlugin("com.android.application")) {
|
||||
+ if(project.ext.react.enableHermes) {
|
||||
+ engine = "hermes"
|
||||
+ }
|
||||
+ }
|
||||
+ })
|
||||
|
||||
artifacts.add("default", file("react-native-reanimated-${minor}-${engine}.aar"))
|
@ -19,25 +19,25 @@
|
||||
#import <React/RCTUIManager.h>
|
||||
#import <ReactCommon/RCTTurboModuleManager.h>
|
||||
|
||||
#if __has_include(<RNReanimated/NativeReanimatedModule.h>)
|
||||
#ifndef VISION_CAMERA_DISABLE_FRAME_PROCESSORS
|
||||
#if __has_include(<RNReanimated/NativeReanimatedModule.h>)
|
||||
#if __has_include(<RNReanimated/RuntimeManager.h>)
|
||||
#ifndef VISION_CAMERA_DISABLE_FRAME_PROCESSORS
|
||||
#import <RNReanimated/RuntimeManager.h>
|
||||
#import <RNReanimated/RuntimeDecorator.h>
|
||||
#import <RNReanimated/REAIOSScheduler.h>
|
||||
#import <RNReanimated/REAIOSErrorHandler.h>
|
||||
#define ENABLE_FRAME_PROCESSORS
|
||||
#endif
|
||||
#else
|
||||
#warning Your react-native-reanimated version is not compatible with VisionCamera, Frame Processors are disabled. Make sure you're using reanimated 2.2.0 or above!
|
||||
#endif
|
||||
#else
|
||||
#else
|
||||
#warning The NativeReanimatedModule.h header could not be found, Frame Processors are disabled. If you want to use Frame Processors, make sure you install react-native-reanimated!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "../../cpp/MakeJSIRuntime.h"
|
||||
#import "FrameProcessorUtils.h"
|
||||
#import "FrameProcessorCallback.h"
|
||||
#import "../React Utils/MakeJSIRuntime.h"
|
||||
#import "../React Utils/JSIUtils.h"
|
||||
|
||||
// Forward declarations for the Swift classes
|
||||
|
42
ios/React Utils/MakeJSIRuntime.h
Normal file
42
ios/React Utils/MakeJSIRuntime.h
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// MakeJSIRuntime.h
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 06.07.21.
|
||||
// Copyright © 2021 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jsi/jsi.h>
|
||||
#include <memory>
|
||||
|
||||
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
||||
// Hermes (https://hermesengine.dev) (RN 0.65+)
|
||||
#include <reacthermes/HermesExecutorFactory.h>
|
||||
#elif __has_include(<hermes/hermes.h>)
|
||||
// Hermes (https://hermesengine.dev)
|
||||
#include <hermes/hermes.h>
|
||||
#elif __has_include(<v8runtime/V8RuntimeFactory.h>)
|
||||
// V8 (https://github.com/Kudo/react-native-v8)
|
||||
#include <v8runtime/V8RuntimeFactory.h>
|
||||
#else
|
||||
// JSC
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#endif
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
namespace vision {
|
||||
|
||||
static std::unique_ptr<jsi::Runtime> makeJSIRuntime() {
|
||||
#if __has_include(<hermes/hermes.h>) || __has_include(<reacthermes/HermesExecutorFactory.h>)
|
||||
return facebook::hermes::makeHermesRuntime();
|
||||
#elif __has_include(<v8runtime/V8RuntimeFactory.h>)
|
||||
return facebook::createV8Runtime("");
|
||||
#else
|
||||
return facebook::jsc::makeJSCRuntime();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace vision
|
@ -88,6 +88,7 @@
|
||||
B84760A22608EE38004C3180 /* FrameHostObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FrameHostObject.h; sourceTree = "<group>"; };
|
||||
B84760A52608EE7C004C3180 /* FrameHostObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameHostObject.mm; sourceTree = "<group>"; };
|
||||
B84760DE2608F57D004C3180 /* CameraQueues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraQueues.swift; sourceTree = "<group>"; };
|
||||
B84C10592694A182006EFA70 /* MakeJSIRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MakeJSIRuntime.h; sourceTree = "<group>"; };
|
||||
B86DC970260E2D5200FB17B2 /* AVAudioSession+trySetAllowHaptics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVAudioSession+trySetAllowHaptics.swift"; sourceTree = "<group>"; };
|
||||
B86DC973260E310600FB17B2 /* CameraView+AVAudioSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CameraView+AVAudioSession.swift"; sourceTree = "<group>"; };
|
||||
B86DC976260E315100FB17B2 /* CameraView+AVCaptureSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CameraView+AVCaptureSession.swift"; sourceTree = "<group>"; };
|
||||
@ -138,8 +139,6 @@
|
||||
B8DB3BC7263DC28C004C18D7 /* AVAssetWriter.Status+descriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVAssetWriter.Status+descriptor.swift"; sourceTree = "<group>"; };
|
||||
B8DB3BC9263DC4D8004C18D7 /* RecordingSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordingSession.swift; sourceTree = "<group>"; };
|
||||
B8DB3BCB263DC97E004C18D7 /* AVFileType+descriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVFileType+descriptor.swift"; sourceTree = "<group>"; };
|
||||
B8DCF09125EA7BEE00EA5C72 /* SpeedChecker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeedChecker.h; sourceTree = "<group>"; };
|
||||
B8DCF14425EA817D00EA5C72 /* MakeJSIRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MakeJSIRuntime.h; sourceTree = "<group>"; };
|
||||
B8F7DDD1266F715D00120533 /* Frame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Frame.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -180,7 +179,6 @@
|
||||
B887518125E0102000DB86D6 /* CameraViewManager.swift */,
|
||||
B8DB3BC9263DC4D8004C18D7 /* RecordingSession.swift */,
|
||||
B887515C25E0102000DB86D6 /* PhotoCaptureDelegate.swift */,
|
||||
B8DCF08F25EA7BEE00EA5C72 /* cpp */,
|
||||
B887516125E0102000DB86D6 /* Extensions */,
|
||||
B887517225E0102000DB86D6 /* Parsers */,
|
||||
B887516D25E0102000DB86D6 /* React Utils */,
|
||||
@ -222,6 +220,7 @@
|
||||
B8994E6B263F03E100069589 /* JSIUtils.mm */,
|
||||
B8805065266798AB00EAD7F2 /* JSConsoleHelper.h */,
|
||||
B8805066266798B600EAD7F2 /* JSConsoleHelper.mm */,
|
||||
B84C10592694A182006EFA70 /* MakeJSIRuntime.h */,
|
||||
);
|
||||
path = "React Utils";
|
||||
sourceTree = "<group>";
|
||||
@ -247,16 +246,6 @@
|
||||
path = Parsers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B8DCF08F25EA7BEE00EA5C72 /* cpp */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B8DCF14425EA817D00EA5C72 /* MakeJSIRuntime.h */,
|
||||
B8DCF09125EA7BEE00EA5C72 /* SpeedChecker.h */,
|
||||
);
|
||||
name = cpp;
|
||||
path = ../cpp;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B8DCF2D725EA940700EA5C72 /* Frame Processor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
18
package.json
18
package.json
@ -98,12 +98,18 @@
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native",
|
||||
"modulePathIgnorePatterns": [
|
||||
"<rootDir>/example/node_modules",
|
||||
"<rootDir>/lib/"
|
||||
]
|
||||
"prettier": {
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"semi": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"printWidth": 140
|
||||
},
|
||||
"babel": {
|
||||
"presets": ["module:metro-react-native-babel-preset"]
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
|
@ -1,20 +0,0 @@
|
||||
diff --git a/node_modules/react-native-reanimated/android/build.gradle b/node_modules/react-native-reanimated/android/build.gradle
|
||||
index bb707e7..9186873 100644
|
||||
--- a/node_modules/react-native-reanimated/android/build.gradle
|
||||
+++ b/node_modules/react-native-reanimated/android/build.gradle
|
||||
@@ -7,8 +7,12 @@ def reactNativeVersion = json.version as String
|
||||
def (major, minor, patch) = reactNativeVersion.tokenize('.')
|
||||
|
||||
def engine = "jsc"
|
||||
-if (project(':app').ext.react.enableHermes) {
|
||||
- engine = "hermes"
|
||||
-}
|
||||
+rootProject.getSubprojects().forEach({project ->
|
||||
+ if (project.plugins.hasPlugin("com.android.application")) {
|
||||
+ if(project.ext.react.enableHermes) {
|
||||
+ engine = "hermes"
|
||||
+ }
|
||||
+ }
|
||||
+ })
|
||||
|
||||
artifacts.add("default", file("react-native-reanimated-${minor}-${engine}.aar"))
|
@ -1,5 +0,0 @@
|
||||
|
||||
{
|
||||
"extends": "./tsconfig",
|
||||
"exclude": ["example"]
|
||||
}
|
@ -30,7 +30,6 @@
|
||||
"src",
|
||||
"example",
|
||||
".eslintrc.js",
|
||||
".prettierrc.js",
|
||||
"babel.config.js",
|
||||
],
|
||||
"exclude": [
|
||||
|
Loading…
Reference in New Issue
Block a user