react-native-spiral-image 0.1.0

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 (54) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +39 -0
  3. package/SpiralImage.podspec +29 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +112 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  8. package/android/src/main/java/com/margelo/nitro/spiralimage/SpiralImage.kt +10 -0
  9. package/android/src/main/java/com/margelo/nitro/spiralimage/SpiralImagePackage.kt +22 -0
  10. package/ios/SpiralImage.swift +5 -0
  11. package/lib/module/SpiralImage.nitro.js +4 -0
  12. package/lib/module/SpiralImage.nitro.js.map +1 -0
  13. package/lib/module/index.js +4 -0
  14. package/lib/module/index.js.map +1 -0
  15. package/lib/module/multiply.js +6 -0
  16. package/lib/module/multiply.js.map +1 -0
  17. package/lib/module/multiply.native.js +8 -0
  18. package/lib/module/multiply.native.js.map +1 -0
  19. package/lib/module/package.json +1 -0
  20. package/lib/typescript/package.json +1 -0
  21. package/lib/typescript/src/SpiralImage.nitro.d.ts +8 -0
  22. package/lib/typescript/src/SpiralImage.nitro.d.ts.map +1 -0
  23. package/lib/typescript/src/index.d.ts +2 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/multiply.d.ts +2 -0
  26. package/lib/typescript/src/multiply.d.ts.map +1 -0
  27. package/lib/typescript/src/multiply.native.d.ts +2 -0
  28. package/lib/typescript/src/multiply.native.d.ts.map +1 -0
  29. package/nitro.json +23 -0
  30. package/nitrogen/generated/android/c++/JHybridSpiralImageSpec.cpp +53 -0
  31. package/nitrogen/generated/android/c++/JHybridSpiralImageSpec.hpp +63 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/spiralimage/HybridSpiralImageSpec.kt +54 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/spiralimage/spiralimageOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/spiralimage+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/spiralimage+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/spiralimageOnLoad.cpp +54 -0
  37. package/nitrogen/generated/android/spiralimageOnLoad.hpp +34 -0
  38. package/nitrogen/generated/ios/SpiralImage+autolinking.rb +62 -0
  39. package/nitrogen/generated/ios/SpiralImage-Swift-Cxx-Bridge.cpp +33 -0
  40. package/nitrogen/generated/ios/SpiralImage-Swift-Cxx-Bridge.hpp +51 -0
  41. package/nitrogen/generated/ios/SpiralImage-Swift-Cxx-Umbrella.hpp +43 -0
  42. package/nitrogen/generated/ios/SpiralImageAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/SpiralImageAutolinking.swift +26 -0
  44. package/nitrogen/generated/ios/c++/HybridSpiralImageSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridSpiralImageSpecSwift.hpp +82 -0
  46. package/nitrogen/generated/ios/swift/HybridSpiralImageSpec.swift +55 -0
  47. package/nitrogen/generated/ios/swift/HybridSpiralImageSpec_cxx.swift +138 -0
  48. package/nitrogen/generated/shared/c++/HybridSpiralImageSpec.cpp +21 -0
  49. package/nitrogen/generated/shared/c++/HybridSpiralImageSpec.hpp +62 -0
  50. package/package.json +184 -0
  51. package/src/SpiralImage.nitro.ts +8 -0
  52. package/src/index.tsx +1 -0
  53. package/src/multiply.native.tsx +9 -0
  54. package/src/multiply.tsx +3 -0
@@ -0,0 +1,138 @@
1
+ ///
2
+ /// HybridSpiralImageSpec_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 HybridSpiralImageSpec 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 HybridSpiralImageSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::spiralimage::bridge::swift`)
22
+ * from `SpiralImage-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.spiralimage.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridSpiralImageSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridSpiralImageSpec
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_HybridSpiralImageSpec_
36
+
37
+ /**
38
+ * Create a new `HybridSpiralImageSpec_cxx` that wraps the given `HybridSpiralImageSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridSpiralImageSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridSpiralImageSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridSpiralImageSpec() -> any HybridSpiralImageSpec {
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 `HybridSpiralImageSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridSpiralImageSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridSpiralImageSpec_cxx {
69
+ return Unmanaged<HybridSpiralImageSpec_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<HybridSpiralImageSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridSpiralImageSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridSpiralImageSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridSpiralImageSpec_(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: HybridSpiralImageSpec_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 multiply(a: Double, b: Double) -> bridge.Result_double_ {
129
+ do {
130
+ let __result = try self.__implementation.multiply(a: a, b: b)
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
+ }
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridSpiralImageSpec.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 "HybridSpiralImageSpec.hpp"
9
+
10
+ namespace margelo::nitro::spiralimage {
11
+
12
+ void HybridSpiralImageSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("multiply", &HybridSpiralImageSpec::multiply);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::spiralimage
@@ -0,0 +1,62 @@
1
+ ///
2
+ /// HybridSpiralImageSpec.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::spiralimage {
21
+
22
+ using namespace margelo::nitro;
23
+
24
+ /**
25
+ * An abstract base class for `SpiralImage`
26
+ * Inherit this class to create instances of `HybridSpiralImageSpec` in C++.
27
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
28
+ * @example
29
+ * ```cpp
30
+ * class HybridSpiralImage: public HybridSpiralImageSpec {
31
+ * public:
32
+ * HybridSpiralImage(...): HybridObject(TAG) { ... }
33
+ * // ...
34
+ * };
35
+ * ```
36
+ */
37
+ class HybridSpiralImageSpec: public virtual HybridObject {
38
+ public:
39
+ // Constructor
40
+ explicit HybridSpiralImageSpec(): HybridObject(TAG) { }
41
+
42
+ // Destructor
43
+ ~HybridSpiralImageSpec() override = default;
44
+
45
+ public:
46
+ // Properties
47
+
48
+
49
+ public:
50
+ // Methods
51
+ virtual double multiply(double a, double b) = 0;
52
+
53
+ protected:
54
+ // Hybrid Setup
55
+ void loadHybridMethods() override;
56
+
57
+ protected:
58
+ // Tag for logging
59
+ static constexpr auto TAG = "SpiralImage";
60
+ };
61
+
62
+ } // namespace margelo::nitro::spiralimage
package/package.json ADDED
@@ -0,0 +1,184 @@
1
+ {
2
+ "name": "react-native-spiral-image",
3
+ "version": "0.1.0",
4
+ "description": "High performance image processing library for React Native",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "react-native-spiral-image-source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "nitrogen",
22
+ "nitro.json",
23
+ "*.podspec",
24
+ "react-native.config.js",
25
+ "!ios/build",
26
+ "!android/build",
27
+ "!android/gradle",
28
+ "!android/gradlew",
29
+ "!android/gradlew.bat",
30
+ "!android/local.properties",
31
+ "!**/__tests__",
32
+ "!**/__fixtures__",
33
+ "!**/__mocks__",
34
+ "!**/.*"
35
+ ],
36
+ "scripts": {
37
+ "example": "npm run --workspace react-native-spiral-image-example",
38
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
39
+ "prepare": "bob build",
40
+ "nitrogen": "nitrogen",
41
+ "typecheck": "tsc",
42
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
43
+ "test": "jest",
44
+ "release": "release-it --only-version",
45
+ "web": "vite",
46
+ "build:web": "vite build"
47
+ },
48
+ "keywords": [
49
+ "react-native",
50
+ "ios",
51
+ "android"
52
+ ],
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/spiral-team-sys/react-native-spiral-image.git"
56
+ },
57
+ "author": "Spiral Team <spiral.it27b@gmail.com> (https://github.com/spiral-team-sys)",
58
+ "license": "MIT",
59
+ "bugs": {
60
+ "url": "https://github.com/spiral-team-sys/react-native-spiral-image/issues"
61
+ },
62
+ "homepage": "https://github.com/spiral-team-sys/react-native-spiral-image#readme",
63
+ "devDependencies": {
64
+ "@commitlint/config-conventional": "^21.0.2",
65
+ "@eslint/compat": "^2.1.0",
66
+ "@eslint/eslintrc": "^3.3.5",
67
+ "@eslint/js": "^9.39.0",
68
+ "@jest/globals": "^29.7.0",
69
+ "@react-native/babel-preset": "0.85.0",
70
+ "@react-native/eslint-config": "0.85.0",
71
+ "@react-native/jest-preset": "0.85.0",
72
+ "@release-it/conventional-changelog": "^11.0.1",
73
+ "@types/react": "^19.2.0",
74
+ "commitlint": "^21.0.2",
75
+ "del-cli": "^7.0.0",
76
+ "eslint": "^9.39.4",
77
+ "eslint-config-prettier": "^10.1.8",
78
+ "eslint-plugin-ft-flow": "^3.0.11",
79
+ "eslint-plugin-prettier": "^5.5.6",
80
+ "jest": "^29.7.0",
81
+ "lefthook": "^2.1.9",
82
+ "nitrogen": "^0.36.1",
83
+ "prettier": "^3.8.3",
84
+ "react": "19.2.7",
85
+ "react-native": "0.85.0",
86
+ "react-native-builder-bob": "^0.43.0",
87
+ "react-native-nitro-modules": "^0.36.1",
88
+ "react-native-web": "~0.21.2",
89
+ "release-it": "^20.2.0",
90
+ "turbo": "^2.9.16",
91
+ "typescript": "^6.0.3"
92
+ },
93
+ "peerDependencies": {
94
+ "react": "*",
95
+ "react-native": "*",
96
+ "react-native-nitro-modules": "^0.36.1"
97
+ },
98
+ "workspaces": [
99
+ "example"
100
+ ],
101
+ "packageManager": "npm@11.6.2",
102
+ "react-native-builder-bob": {
103
+ "source": "src",
104
+ "output": "lib",
105
+ "targets": [
106
+ [
107
+ "custom",
108
+ {
109
+ "script": "nitrogen",
110
+ "clean": "nitrogen/"
111
+ }
112
+ ],
113
+ [
114
+ "module",
115
+ {
116
+ "esm": true
117
+ }
118
+ ],
119
+ [
120
+ "typescript",
121
+ {
122
+ "project": "tsconfig.build.json"
123
+ }
124
+ ]
125
+ ]
126
+ },
127
+ "prettier": {
128
+ "quoteProps": "consistent",
129
+ "singleQuote": true,
130
+ "tabWidth": 2,
131
+ "trailingComma": "es5",
132
+ "useTabs": false
133
+ },
134
+ "jest": {
135
+ "preset": "@react-native/jest-preset",
136
+ "testEnvironmentOptions": {
137
+ "customExportConditions": [
138
+ "require",
139
+ "react-native",
140
+ "<%- project.sourceCondition -%>"
141
+ ]
142
+ },
143
+ "modulePathIgnorePatterns": [
144
+ "<rootDir>/example/node_modules",
145
+ "<rootDir>/lib/"
146
+ ]
147
+ },
148
+ "commitlint": {
149
+ "extends": [
150
+ "@commitlint/config-conventional"
151
+ ]
152
+ },
153
+ "release-it": {
154
+ "git": {
155
+ "commitMessage": "chore: release ${version}",
156
+ "tagName": "v${version}"
157
+ },
158
+ "npm": {
159
+ "publish": true
160
+ },
161
+ "github": {
162
+ "release": true
163
+ },
164
+ "plugins": {
165
+ "@release-it/conventional-changelog": {
166
+ "preset": {
167
+ "name": "angular"
168
+ }
169
+ }
170
+ }
171
+ },
172
+ "create-react-native-library": {
173
+ "type": "nitro-module",
174
+ "languages": "kotlin-swift",
175
+ "tools": [
176
+ "eslint",
177
+ "jest",
178
+ "lefthook",
179
+ "release-it",
180
+ "vite"
181
+ ],
182
+ "version": "0.63.0"
183
+ }
184
+ }
@@ -0,0 +1,8 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface SpiralImage extends HybridObject<{
4
+ ios: 'swift';
5
+ android: 'kotlin';
6
+ }> {
7
+ multiply(a: number, b: number): number;
8
+ }
package/src/index.tsx ADDED
@@ -0,0 +1 @@
1
+ export { multiply } from './multiply';
@@ -0,0 +1,9 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ import type { SpiralImage } from './SpiralImage.nitro';
3
+
4
+ const SpiralImageHybridObject =
5
+ NitroModules.createHybridObject<SpiralImage>('SpiralImage');
6
+
7
+ export function multiply(a: number, b: number): number {
8
+ return SpiralImageHybridObject.multiply(a, b);
9
+ }
@@ -0,0 +1,3 @@
1
+ export function multiply(a: number, b: number): number {
2
+ return a * b;
3
+ }