react-native-yolo 0.0.2 → 0.0.4
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/LICENSE +20 -20
- package/README.md +51 -29
- package/Yolo.podspec +31 -31
- package/android/CMakeLists.txt +35 -32
- package/android/build.gradle +154 -147
- package/android/fix-prefab.gradle +50 -50
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +3 -2
- package/android/src/main/cpp/cpp-adapter.cpp +8 -8
- package/android/src/main/java/com/yolo/HybridYolo.kt +65 -27
- package/android/src/main/java/com/yolo/YoloPackage.kt +20 -29
- package/android/src/main/java/com/yolo/loader/YoloModelLoader.kt +130 -0
- package/android/src/main/java/com/yolo/utils/BitmapOrientationFixer.kt +56 -0
- package/android/src/main/java/com/yolo/utils/ContextProvider.kt +14 -0
- package/android/src/main/java/com/yolo/utils/FrameJpegConverter.kt +27 -0
- package/android/src/main/java/com/yolo/utils/FrameValidator.kt +29 -0
- package/android/src/main/java/com/yolo/utils/Nv21JpegEncoder.kt +34 -0
- package/android/src/main/java/com/yolo/utils/Yuv420ToNv21Converter.kt +62 -0
- package/ios/Bridge.h +8 -8
- package/ios/HybridYolo.swift +14 -21
- package/lib/commonjs/index.js +10 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +11 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/yolo.nitro.d.ts +8 -8
- package/lib/typescript/src/specs/yolo.nitro.d.ts.map +1 -1
- package/nitro.json +29 -29
- package/nitrogen/generated/android/Yolo+autolinking.cmake +0 -2
- package/nitrogen/generated/android/YoloOnLoad.cpp +0 -2
- package/nitrogen/generated/android/c++/JHybridYoloSpec.cpp +21 -12
- package/nitrogen/generated/android/c++/JHybridYoloSpec.hpp +4 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/HybridYoloSpec.kt +13 -7
- package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.cpp +11 -0
- package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp +47 -0
- package/nitrogen/generated/ios/Yolo-Swift-Cxx-Umbrella.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.hpp +28 -9
- package/nitrogen/generated/ios/swift/HybridYoloSpec.swift +6 -3
- package/nitrogen/generated/ios/swift/HybridYoloSpec_cxx.swift +35 -25
- package/nitrogen/generated/shared/c++/HybridYoloSpec.cpp +3 -2
- package/nitrogen/generated/shared/c++/HybridYoloSpec.hpp +9 -5
- package/package.json +127 -122
- package/src/index.ts +12 -14
- package/src/specs/yolo.nitro.ts +8 -13
- package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.cpp +0 -56
- package/nitrogen/generated/android/c++/views/JHybridYoloStateUpdater.hpp +0 -49
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloManager.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/views/HybridYoloStateUpdater.kt +0 -23
- package/nitrogen/generated/ios/c++/views/HybridYoloComponent.mm +0 -122
- package/nitrogen/generated/shared/c++/views/HybridYoloComponent.cpp +0 -83
- package/nitrogen/generated/shared/c++/views/HybridYoloComponent.hpp +0 -110
- package/nitrogen/generated/shared/json/YoloConfig.json +0 -10
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridYoloComponent.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "HybridYoloComponent.hpp"
|
|
9
|
-
|
|
10
|
-
#include <string>
|
|
11
|
-
#include <exception>
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
-
#include <NitroModules/PropNameIDCache.hpp>
|
|
16
|
-
#include <react/renderer/core/RawValue.h>
|
|
17
|
-
#include <react/renderer/core/ShadowNode.h>
|
|
18
|
-
#include <react/renderer/core/ComponentDescriptor.h>
|
|
19
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
20
|
-
|
|
21
|
-
namespace margelo::nitro::yolo::views {
|
|
22
|
-
|
|
23
|
-
extern const char HybridYoloComponentName[] = "Yolo";
|
|
24
|
-
|
|
25
|
-
HybridYoloProps::HybridYoloProps(const react::PropsParserContext& context,
|
|
26
|
-
const HybridYoloProps& sourceProps,
|
|
27
|
-
const react::RawProps& rawProps):
|
|
28
|
-
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
29
|
-
isRed([&]() -> CachedProp<bool> {
|
|
30
|
-
try {
|
|
31
|
-
const react::RawValue* rawValue = rawProps.at("isRed", nullptr, nullptr);
|
|
32
|
-
if (rawValue == nullptr) return sourceProps.isRed;
|
|
33
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
34
|
-
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.isRed);
|
|
35
|
-
} catch (const std::exception& exc) {
|
|
36
|
-
throw std::runtime_error(std::string("Yolo.isRed: ") + exc.what());
|
|
37
|
-
}
|
|
38
|
-
}()),
|
|
39
|
-
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>> {
|
|
40
|
-
try {
|
|
41
|
-
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
42
|
-
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
43
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
44
|
-
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
45
|
-
} catch (const std::exception& exc) {
|
|
46
|
-
throw std::runtime_error(std::string("Yolo.hybridRef: ") + exc.what());
|
|
47
|
-
}
|
|
48
|
-
}()) { }
|
|
49
|
-
|
|
50
|
-
bool HybridYoloProps::filterObjectKeys(const std::string& propName) {
|
|
51
|
-
switch (hashString(propName)) {
|
|
52
|
-
case hashString("isRed"): return true;
|
|
53
|
-
case hashString("hybridRef"): return true;
|
|
54
|
-
default: return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
HybridYoloComponentDescriptor::HybridYoloComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
59
|
-
: ConcreteComponentDescriptor(parameters,
|
|
60
|
-
react::RawPropsParser(/* enableJsiParser */ true)) {}
|
|
61
|
-
|
|
62
|
-
std::shared_ptr<const react::Props> HybridYoloComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
63
|
-
const std::shared_ptr<const react::Props>& props,
|
|
64
|
-
react::RawProps rawProps) const {
|
|
65
|
-
// 1. Prepare raw props parser
|
|
66
|
-
rawProps.parse(rawPropsParser_);
|
|
67
|
-
// 2. Copy props with Nitro's cached copy constructor
|
|
68
|
-
return HybridYoloShadowNode::Props(context, /* & */ rawProps, props);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
#ifdef ANDROID
|
|
72
|
-
void HybridYoloComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
73
|
-
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
74
|
-
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
75
|
-
auto& concreteShadowNode = static_cast<HybridYoloShadowNode&>(shadowNode);
|
|
76
|
-
const std::shared_ptr<const HybridYoloProps>& constProps = concreteShadowNode.getConcreteSharedProps();
|
|
77
|
-
const std::shared_ptr<HybridYoloProps>& props = std::const_pointer_cast<HybridYoloProps>(constProps);
|
|
78
|
-
HybridYoloState state{props};
|
|
79
|
-
concreteShadowNode.setStateData(std::move(state));
|
|
80
|
-
}
|
|
81
|
-
#endif
|
|
82
|
-
|
|
83
|
-
} // namespace margelo::nitro::yolo::views
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridYoloComponent.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#include <optional>
|
|
11
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
12
|
-
#include <NitroModules/NitroHash.hpp>
|
|
13
|
-
#include <NitroModules/CachedProp.hpp>
|
|
14
|
-
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
18
|
-
|
|
19
|
-
#include <memory>
|
|
20
|
-
#include "HybridYoloSpec.hpp"
|
|
21
|
-
#include <functional>
|
|
22
|
-
#include <optional>
|
|
23
|
-
|
|
24
|
-
namespace margelo::nitro::yolo::views {
|
|
25
|
-
|
|
26
|
-
using namespace facebook;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The name of the actual native View.
|
|
30
|
-
*/
|
|
31
|
-
extern const char HybridYoloComponentName[];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Props for the "Yolo" View.
|
|
35
|
-
*/
|
|
36
|
-
class HybridYoloProps final: public react::ViewProps {
|
|
37
|
-
public:
|
|
38
|
-
HybridYoloProps() = default;
|
|
39
|
-
HybridYoloProps(const react::PropsParserContext& context,
|
|
40
|
-
const HybridYoloProps& sourceProps,
|
|
41
|
-
const react::RawProps& rawProps);
|
|
42
|
-
|
|
43
|
-
public:
|
|
44
|
-
CachedProp<bool> isRed;
|
|
45
|
-
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridYoloSpec>& /* ref */)>>> hybridRef;
|
|
46
|
-
|
|
47
|
-
private:
|
|
48
|
-
static bool filterObjectKeys(const std::string& propName);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* State for the "Yolo" View.
|
|
53
|
-
*/
|
|
54
|
-
class HybridYoloState final {
|
|
55
|
-
public:
|
|
56
|
-
HybridYoloState() = default;
|
|
57
|
-
explicit HybridYoloState(const std::shared_ptr<HybridYoloProps>& props):
|
|
58
|
-
_props(props) {}
|
|
59
|
-
|
|
60
|
-
public:
|
|
61
|
-
[[nodiscard]]
|
|
62
|
-
const std::shared_ptr<HybridYoloProps>& getProps() const {
|
|
63
|
-
return _props;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public:
|
|
67
|
-
#ifdef ANDROID
|
|
68
|
-
HybridYoloState(const HybridYoloState& /* previousState */, folly::dynamic /* data */) {}
|
|
69
|
-
folly::dynamic getDynamic() const {
|
|
70
|
-
throw std::runtime_error("HybridYoloState does not support folly!");
|
|
71
|
-
}
|
|
72
|
-
react::MapBuffer getMapBuffer() const {
|
|
73
|
-
throw std::runtime_error("HybridYoloState does not support MapBuffer!");
|
|
74
|
-
};
|
|
75
|
-
#endif
|
|
76
|
-
|
|
77
|
-
private:
|
|
78
|
-
std::shared_ptr<HybridYoloProps> _props;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The Shadow Node for the "Yolo" View.
|
|
83
|
-
*/
|
|
84
|
-
using HybridYoloShadowNode = react::ConcreteViewShadowNode<HybridYoloComponentName /* "HybridYolo" */,
|
|
85
|
-
HybridYoloProps /* custom props */,
|
|
86
|
-
react::ViewEventEmitter /* default */,
|
|
87
|
-
HybridYoloState /* custom state */>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The Component Descriptor for the "Yolo" View.
|
|
91
|
-
*/
|
|
92
|
-
class HybridYoloComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridYoloShadowNode> {
|
|
93
|
-
public:
|
|
94
|
-
explicit HybridYoloComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
95
|
-
|
|
96
|
-
public:
|
|
97
|
-
/**
|
|
98
|
-
* A faster path for cloning props - reuses the caching logic from `HybridYoloProps`.
|
|
99
|
-
*/
|
|
100
|
-
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
|
|
101
|
-
const std::shared_ptr<const react::Props>& props,
|
|
102
|
-
react::RawProps rawProps) const override;
|
|
103
|
-
#ifdef ANDROID
|
|
104
|
-
void adopt(react::ShadowNode& shadowNode) const override;
|
|
105
|
-
#endif
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/* The actual view for "Yolo" needs to be implemented in platform-specific code. */
|
|
109
|
-
|
|
110
|
-
} // namespace margelo::nitro::yolo::views
|