react-native-yolo 0.0.1

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/Yolo.podspec +31 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/yolo/HybridYolo.kt +12 -0
  11. package/android/src/main/java/com/yolo/YoloPackage.kt +20 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridYolo.swift +14 -0
  14. package/lib/commonjs/index.js +9 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/yolo.nitro.js +6 -0
  18. package/lib/commonjs/specs/yolo.nitro.js.map +1 -0
  19. package/lib/module/index.js +5 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/specs/yolo.nitro.js +4 -0
  22. package/lib/module/specs/yolo.nitro.js.map +1 -0
  23. package/lib/typescript/src/index.d.ts +3 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/specs/yolo.nitro.d.ts +9 -0
  26. package/lib/typescript/src/specs/yolo.nitro.d.ts.map +1 -0
  27. package/nitro.json +30 -0
  28. package/nitrogen/generated/.gitattributes +1 -0
  29. package/nitrogen/generated/android/Yolo+autolinking.cmake +81 -0
  30. package/nitrogen/generated/android/Yolo+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/YoloOnLoad.cpp +54 -0
  32. package/nitrogen/generated/android/YoloOnLoad.hpp +34 -0
  33. package/nitrogen/generated/android/c++/JHybridYoloSpec.cpp +58 -0
  34. package/nitrogen/generated/android/c++/JHybridYoloSpec.hpp +64 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/HybridYoloSpec.kt +58 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/yolo/YoloOnLoad.kt +35 -0
  37. package/nitrogen/generated/ios/Yolo+autolinking.rb +62 -0
  38. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.cpp +33 -0
  39. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Bridge.hpp +51 -0
  40. package/nitrogen/generated/ios/Yolo-Swift-Cxx-Umbrella.hpp +43 -0
  41. package/nitrogen/generated/ios/YoloAutolinking.mm +33 -0
  42. package/nitrogen/generated/ios/YoloAutolinking.swift +26 -0
  43. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridYoloSpecSwift.hpp +90 -0
  45. package/nitrogen/generated/ios/swift/HybridYoloSpec.swift +56 -0
  46. package/nitrogen/generated/ios/swift/HybridYoloSpec_cxx.swift +150 -0
  47. package/nitrogen/generated/shared/c++/HybridYoloSpec.cpp +22 -0
  48. package/nitrogen/generated/shared/c++/HybridYoloSpec.hpp +63 -0
  49. package/package.json +122 -0
  50. package/src/index.ts +5 -0
  51. package/src/specs/yolo.nitro.ts +6 -0
@@ -0,0 +1,150 @@
1
+ ///
2
+ /// HybridYoloSpec_cxx.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridYoloSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridYoloSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::yolo::bridge::swift`)
22
+ * from `Yolo-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.yolo.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridYoloSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridYoloSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridYoloSpec_
36
+
37
+ /**
38
+ * Create a new `HybridYoloSpec_cxx` that wraps the given `HybridYoloSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridYoloSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridYoloSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridYoloSpec() -> any HybridYoloSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridYoloSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridYoloSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridYoloSpec_cxx {
69
+ return Unmanaged<HybridYoloSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridYoloSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridYoloSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridYoloSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridYoloSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridYoloSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func sum(num1: Double, num2: Double) -> bridge.Result_double_ {
129
+ do {
130
+ let __result = try self.__implementation.sum(num1: num1, num2: num2)
131
+ let __resultCpp = __result
132
+ return bridge.create_Result_double_(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_double_(__exceptionPtr)
136
+ }
137
+ }
138
+
139
+ @inline(__always)
140
+ public final func subtract(num1: Double, num2: Double) -> bridge.Result_double_ {
141
+ do {
142
+ let __result = try self.__implementation.subtract(num1: num1, num2: num2)
143
+ let __resultCpp = __result
144
+ return bridge.create_Result_double_(__resultCpp)
145
+ } catch (let __error) {
146
+ let __exceptionPtr = __error.toCpp()
147
+ return bridge.create_Result_double_(__exceptionPtr)
148
+ }
149
+ }
150
+ }
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridYoloSpec.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 "HybridYoloSpec.hpp"
9
+
10
+ namespace margelo::nitro::yolo {
11
+
12
+ void HybridYoloSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("sum", &HybridYoloSpec::sum);
18
+ prototype.registerHybridMethod("subtract", &HybridYoloSpec::subtract);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::yolo
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridYoloSpec.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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+
19
+
20
+ namespace margelo::nitro::yolo {
21
+
22
+ using namespace margelo::nitro;
23
+
24
+ /**
25
+ * An abstract base class for `Yolo`
26
+ * Inherit this class to create instances of `HybridYoloSpec` in C++.
27
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
28
+ * @example
29
+ * ```cpp
30
+ * class HybridYolo: public HybridYoloSpec {
31
+ * public:
32
+ * HybridYolo(...): HybridObject(TAG) { ... }
33
+ * // ...
34
+ * };
35
+ * ```
36
+ */
37
+ class HybridYoloSpec: public virtual HybridObject {
38
+ public:
39
+ // Constructor
40
+ explicit HybridYoloSpec(): HybridObject(TAG) { }
41
+
42
+ // Destructor
43
+ ~HybridYoloSpec() override = default;
44
+
45
+ public:
46
+ // Properties
47
+
48
+
49
+ public:
50
+ // Methods
51
+ virtual double sum(double num1, double num2) = 0;
52
+ virtual double subtract(double num1, double num2) = 0;
53
+
54
+ protected:
55
+ // Hybrid Setup
56
+ void loadHybridMethods() override;
57
+
58
+ protected:
59
+ // Tag for logging
60
+ static constexpr auto TAG = "Yolo";
61
+ };
62
+
63
+ } // namespace margelo::nitro::yolo
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "react-native-yolo",
3
+ "version": "0.0.1",
4
+ "description": "react-native-yolo is a react native package built with Nitro",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "clean": "git clean -dfX",
13
+ "release": "semantic-release",
14
+ "build": "npm run typecheck && bob build",
15
+ "codegen": "nitrogen --logLevel=\"debug\" && npm run build && node post-script.js"
16
+ },
17
+ "keywords": [
18
+ "react-native",
19
+ "react-native-yolo"
20
+ ],
21
+ "files": [
22
+ "src",
23
+ "react-native.config.js",
24
+ "lib",
25
+ "nitrogen",
26
+ "cpp",
27
+ "nitro.json",
28
+ "android/build.gradle",
29
+ "android/fix-prefab.gradle",
30
+ "android/gradle.properties",
31
+ "android/CMakeLists.txt",
32
+ "android/src",
33
+ "ios/**/*.h",
34
+ "ios/**/*.m",
35
+ "ios/**/*.mm",
36
+ "ios/**/*.cpp",
37
+ "ios/**/*.swift",
38
+ "app.plugin.js",
39
+ "*.podspec",
40
+ "README.md"
41
+ ],
42
+ "workspaces": [
43
+ "example"
44
+ ],
45
+ "repository": "https://github.com/khaoula-ghalimi/react-native-yolo.git",
46
+ "author": "Khaoula-Ghalimi",
47
+ "license": "MIT",
48
+ "bugs": "https://github.com/khaoula-ghalimi/react-native-yolo/issues",
49
+ "homepage": "https://github.com/khaoula-ghalimi/react-native-yolo#readme",
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "registry": "https://registry.npmjs.org/"
53
+ },
54
+ "devDependencies": {
55
+ "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
56
+ "@semantic-release/changelog": "^6.0.3",
57
+ "@semantic-release/git": "^10.0.1",
58
+ "@types/jest": "^29.5.12",
59
+ "@types/react": "19.2.0",
60
+ "nitrogen": "0.35.9",
61
+ "react": "19.2.3",
62
+ "react-native": "0.84.1",
63
+ "react-native-builder-bob": "^0.40.18",
64
+ "react-native-nitro-modules": "0.35.9",
65
+ "conventional-changelog-conventionalcommits": "^9.1.0",
66
+ "semantic-release": "^25.0.3",
67
+ "typescript": "^5.8.3"
68
+ },
69
+ "peerDependencies": {
70
+ "react": "*",
71
+ "react-native": "*",
72
+ "react-native-nitro-modules": "*"
73
+ },
74
+ "eslintConfig": {
75
+ "root": true,
76
+ "extends": [
77
+ "@react-native",
78
+ "prettier"
79
+ ],
80
+ "plugins": [
81
+ "prettier"
82
+ ],
83
+ "rules": {
84
+ "prettier/prettier": [
85
+ "warn",
86
+ {
87
+ "quoteProps": "consistent",
88
+ "singleQuote": true,
89
+ "tabWidth": 2,
90
+ "trailingComma": "es5",
91
+ "useTabs": false
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ "eslintIgnore": [
97
+ "node_modules/",
98
+ "lib/"
99
+ ],
100
+ "prettier": {
101
+ "quoteProps": "consistent",
102
+ "singleQuote": true,
103
+ "tabWidth": 2,
104
+ "trailingComma": "es5",
105
+ "useTabs": false,
106
+ "semi": false
107
+ },
108
+ "react-native-builder-bob": {
109
+ "source": "src",
110
+ "output": "lib",
111
+ "targets": [
112
+ "commonjs",
113
+ "module",
114
+ [
115
+ "typescript",
116
+ {
117
+ "project": "tsconfig.json"
118
+ }
119
+ ]
120
+ ]
121
+ }
122
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { NitroModules } from 'react-native-nitro-modules'
2
+ import type { Yolo as YoloSpec } from './specs/yolo.nitro'
3
+
4
+ export const Yolo =
5
+ NitroModules.createHybridObject<YoloSpec>('Yolo')
@@ -0,0 +1,6 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules'
2
+
3
+ export interface Yolo extends HybridObject<{ ios: 'swift', android: 'kotlin' }> {
4
+ sum(num1: number, num2: number): number
5
+ subtract(num1: number, num2: number): number
6
+ }