react-native-nitro-image-pipeline 0.1.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.
- package/LICENSE +21 -0
- package/NitroImagePipeline.podspec +39 -0
- package/README.md +125 -0
- package/android/CMakeLists.txt +34 -0
- package/android/build.gradle +158 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +119 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/NitroImagePipelinePackage.kt +19 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/BlurTransformation.kt +84 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridNitroImagePipeline.swift +114 -0
- package/lib/commonjs/index.js +50 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/nitro-image-toolkit.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-image-toolkit.nitro.js.map +1 -0
- package/lib/module/index.js +45 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/nitro-image-toolkit.nitro.js +4 -0
- package/lib/module/specs/nitro-image-toolkit.nitro.js.map +1 -0
- package/lib/typescript/src/index.d.ts +28 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +20 -0
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroImagePipeline+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroImagePipeline+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroImagePipelineOnLoad.cpp +54 -0
- package/nitrogen/generated/android/NitroImagePipelineOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JCacheOption.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +140 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.hpp +67 -0
- package/nitrogen/generated/android/c++/JOptions.hpp +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/CacheOption.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipelineSpec.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/NitroImagePipelineOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/Options.kt +44 -0
- package/nitrogen/generated/ios/NitroImagePipeline+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.cpp +68 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +244 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +58 -0
- package/nitrogen/generated/ios/NitroImagePipelineAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroImagePipelineAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +124 -0
- package/nitrogen/generated/ios/swift/CacheOption.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_.swift +51 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec_cxx.swift +224 -0
- package/nitrogen/generated/ios/swift/Options.swift +71 -0
- package/nitrogen/generated/shared/c++/CacheOption.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.hpp +75 -0
- package/nitrogen/generated/shared/c++/Options.hpp +93 -0
- package/package.json +99 -0
- package/src/index.ts +66 -0
- package/src/specs/nitro-image-toolkit.nitro.ts +16 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_.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 NitroImage
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: (any HybridImageSpec)) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: (any HybridImageSpec)) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: (any HybridImageSpec)) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: bridge.std__shared_ptr_margelo__nitro__image__HybridImageSpec_) -> Void {
|
|
26
|
+
self.closure({ () -> any HybridImageSpec in
|
|
27
|
+
let __unsafePointer = bridge.get_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(value)
|
|
28
|
+
let __instance = HybridImageSpec_cxx.fromUnsafe(__unsafePointer)
|
|
29
|
+
return __instance.getHybridImageSpec()
|
|
30
|
+
}())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
35
|
+
* This acquires one additional strong reference on the object!
|
|
36
|
+
*/
|
|
37
|
+
@inline(__always)
|
|
38
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
39
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Casts an unsafe pointer to a `Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_`.
|
|
44
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_>`.
|
|
45
|
+
* This removes one strong reference from the object!
|
|
46
|
+
*/
|
|
47
|
+
@inline(__always)
|
|
48
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_ {
|
|
49
|
+
return Unmanaged<Func_void_std__shared_ptr_margelo__nitro__image__HybridImageSpec_>.fromOpaque(pointer).takeRetainedValue()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroImagePipelineSpec.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 NitroImage
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridNitroImagePipelineSpec``
|
|
12
|
+
public protocol HybridNitroImagePipelineSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func loadImage(url: String, options: Options?) throws -> Promise<(any HybridImageSpec)>
|
|
18
|
+
func preLoadImage(url: String) throws -> Promise<Void>
|
|
19
|
+
func preLoadImages(urls: [String]) throws -> Promise<Void>
|
|
20
|
+
func gaussianBlur(image: (any HybridImageSpec), radius: Double) throws -> Promise<(any HybridImageSpec)>
|
|
21
|
+
func clearCache() throws -> Void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public extension HybridNitroImagePipelineSpec_protocol {
|
|
25
|
+
/// Default implementation of ``HybridObject.toString``
|
|
26
|
+
func toString() -> String {
|
|
27
|
+
return "[HybridObject NitroImagePipeline]"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// See ``HybridNitroImagePipelineSpec``
|
|
32
|
+
open class HybridNitroImagePipelineSpec_base {
|
|
33
|
+
private weak var cxxWrapper: HybridNitroImagePipelineSpec_cxx? = nil
|
|
34
|
+
public init() { }
|
|
35
|
+
public func getCxxWrapper() -> HybridNitroImagePipelineSpec_cxx {
|
|
36
|
+
#if DEBUG
|
|
37
|
+
guard self is any HybridNitroImagePipelineSpec else {
|
|
38
|
+
fatalError("`self` is not a `HybridNitroImagePipelineSpec`! Did you accidentally inherit from `HybridNitroImagePipelineSpec_base` instead of `HybridNitroImagePipelineSpec`?")
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
} else {
|
|
44
|
+
let cxxWrapper = HybridNitroImagePipelineSpec_cxx(self as! any HybridNitroImagePipelineSpec)
|
|
45
|
+
self.cxxWrapper = cxxWrapper
|
|
46
|
+
return cxxWrapper
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A Swift base-protocol representing the NitroImagePipeline HybridObject.
|
|
53
|
+
* Implement this protocol to create Swift-based instances of NitroImagePipeline.
|
|
54
|
+
* ```swift
|
|
55
|
+
* class HybridNitroImagePipeline : HybridNitroImagePipelineSpec {
|
|
56
|
+
* // ...
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
public typealias HybridNitroImagePipelineSpec = HybridNitroImagePipelineSpec_protocol & HybridNitroImagePipelineSpec_base
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroImagePipelineSpec_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
|
+
import NitroImage
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridNitroImagePipelineSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridNitroImagePipelineSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitroimagepipeline::bridge::swift`)
|
|
23
|
+
* from `NitroImagePipeline-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridNitroImagePipelineSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridNitroImagePipelineSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridNitroImagePipelineSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridNitroImagePipelineSpec_cxx` that wraps the given `HybridNitroImagePipelineSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridNitroImagePipelineSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridNitroImagePipelineSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridNitroImagePipelineSpec() -> any HybridNitroImagePipelineSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridNitroImagePipelineSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroImagePipelineSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroImagePipelineSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridNitroImagePipelineSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridNitroImagePipelineSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroImagePipelineSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroImagePipelineSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroImagePipelineSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Compares this object with the given [other] object for reference equality.
|
|
101
|
+
*/
|
|
102
|
+
@inline(__always)
|
|
103
|
+
public func equals(other: HybridNitroImagePipelineSpec_cxx) -> Bool {
|
|
104
|
+
return self.__implementation === other.__implementation
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Call dispose() on the Swift class.
|
|
109
|
+
* This _may_ be called manually from JS.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func dispose() {
|
|
113
|
+
self.__implementation.dispose()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Call toString() on the Swift class.
|
|
118
|
+
*/
|
|
119
|
+
@inline(__always)
|
|
120
|
+
public func toString() -> String {
|
|
121
|
+
return self.__implementation.toString()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Properties
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// Methods
|
|
128
|
+
@inline(__always)
|
|
129
|
+
public final func loadImage(url: std.string, options: bridge.std__optional_Options_) -> bridge.Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____ {
|
|
130
|
+
do {
|
|
131
|
+
let __result = try self.__implementation.loadImage(url: String(url), options: options.value)
|
|
132
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___ in
|
|
133
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___()
|
|
134
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___(__promise)
|
|
135
|
+
__result
|
|
136
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__shared_ptr_margelo__nitro__image__HybridImageSpec_ in
|
|
137
|
+
let __cxxWrapped = __result.getCxxWrapper()
|
|
138
|
+
return __cxxWrapped.getCxxPart()
|
|
139
|
+
}()) })
|
|
140
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
141
|
+
return __promise
|
|
142
|
+
}()
|
|
143
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____(__resultCpp)
|
|
144
|
+
} catch (let __error) {
|
|
145
|
+
let __exceptionPtr = __error.toCpp()
|
|
146
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____(__exceptionPtr)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@inline(__always)
|
|
151
|
+
public final func preLoadImage(url: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
152
|
+
do {
|
|
153
|
+
let __result = try self.__implementation.preLoadImage(url: String(url))
|
|
154
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
155
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
156
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
157
|
+
__result
|
|
158
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
159
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
160
|
+
return __promise
|
|
161
|
+
}()
|
|
162
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
163
|
+
} catch (let __error) {
|
|
164
|
+
let __exceptionPtr = __error.toCpp()
|
|
165
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@inline(__always)
|
|
170
|
+
public final func preLoadImages(urls: bridge.std__vector_std__string_) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
171
|
+
do {
|
|
172
|
+
let __result = try self.__implementation.preLoadImages(urls: urls.map({ __item in String(__item) }))
|
|
173
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
|
|
174
|
+
let __promise = bridge.create_std__shared_ptr_Promise_void__()
|
|
175
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
|
|
176
|
+
__result
|
|
177
|
+
.then({ __result in __promiseHolder.resolve() })
|
|
178
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
179
|
+
return __promise
|
|
180
|
+
}()
|
|
181
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
|
|
182
|
+
} catch (let __error) {
|
|
183
|
+
let __exceptionPtr = __error.toCpp()
|
|
184
|
+
return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@inline(__always)
|
|
189
|
+
public final func gaussianBlur(image: bridge.std__shared_ptr_margelo__nitro__image__HybridImageSpec_, radius: Double) -> bridge.Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____ {
|
|
190
|
+
do {
|
|
191
|
+
let __result = try self.__implementation.gaussianBlur(image: { () -> any HybridImageSpec in
|
|
192
|
+
let __unsafePointer = bridge.get_std__shared_ptr_margelo__nitro__image__HybridImageSpec_(image)
|
|
193
|
+
let __instance = HybridImageSpec_cxx.fromUnsafe(__unsafePointer)
|
|
194
|
+
return __instance.getHybridImageSpec()
|
|
195
|
+
}(), radius: radius)
|
|
196
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___ in
|
|
197
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___()
|
|
198
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec___(__promise)
|
|
199
|
+
__result
|
|
200
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__shared_ptr_margelo__nitro__image__HybridImageSpec_ in
|
|
201
|
+
let __cxxWrapped = __result.getCxxWrapper()
|
|
202
|
+
return __cxxWrapped.getCxxPart()
|
|
203
|
+
}()) })
|
|
204
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
205
|
+
return __promise
|
|
206
|
+
}()
|
|
207
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____(__resultCpp)
|
|
208
|
+
} catch (let __error) {
|
|
209
|
+
let __exceptionPtr = __error.toCpp()
|
|
210
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_margelo__nitro__image__HybridImageSpec____(__exceptionPtr)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@inline(__always)
|
|
215
|
+
public final func clearCache() -> bridge.Result_void_ {
|
|
216
|
+
do {
|
|
217
|
+
try self.__implementation.clearCache()
|
|
218
|
+
return bridge.create_Result_void_()
|
|
219
|
+
} catch (let __error) {
|
|
220
|
+
let __exceptionPtr = __error.toCpp()
|
|
221
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Options.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
|
+
* Represents an instance of `Options`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias Options = margelo.nitro.nitroimagepipeline.Options
|
|
14
|
+
|
|
15
|
+
public extension Options {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitroimagepipeline.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `Options`.
|
|
20
|
+
*/
|
|
21
|
+
init(blur: Double?, cache: CacheOption?, cornerRadius: Double?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_double_ in
|
|
23
|
+
if let __unwrappedValue = blur {
|
|
24
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_CacheOption_ in
|
|
29
|
+
if let __unwrappedValue = cache {
|
|
30
|
+
return bridge.create_std__optional_CacheOption_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
35
|
+
if let __unwrappedValue = cornerRadius {
|
|
36
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@inline(__always)
|
|
44
|
+
var blur: Double? {
|
|
45
|
+
return { () -> Double? in
|
|
46
|
+
if bridge.has_value_std__optional_double_(self.__blur) {
|
|
47
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__blur)
|
|
48
|
+
return __unwrapped
|
|
49
|
+
} else {
|
|
50
|
+
return nil
|
|
51
|
+
}
|
|
52
|
+
}()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inline(__always)
|
|
56
|
+
var cache: CacheOption? {
|
|
57
|
+
return self.__cache.value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@inline(__always)
|
|
61
|
+
var cornerRadius: Double? {
|
|
62
|
+
return { () -> Double? in
|
|
63
|
+
if bridge.has_value_std__optional_double_(self.__cornerRadius) {
|
|
64
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__cornerRadius)
|
|
65
|
+
return __unwrapped
|
|
66
|
+
} else {
|
|
67
|
+
return nil
|
|
68
|
+
}
|
|
69
|
+
}()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CacheOption.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CacheOption).
|
|
30
|
+
*/
|
|
31
|
+
enum class CacheOption {
|
|
32
|
+
MEMORY SWIFT_NAME(memory) = 0,
|
|
33
|
+
DISK SWIFT_NAME(disk) = 1,
|
|
34
|
+
NONE SWIFT_NAME(none) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ CacheOption <> JS CacheOption (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::nitroimagepipeline::CacheOption> final {
|
|
44
|
+
static inline margelo::nitro::nitroimagepipeline::CacheOption fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("memory"): return margelo::nitro::nitroimagepipeline::CacheOption::MEMORY;
|
|
48
|
+
case hashString("disk"): return margelo::nitro::nitroimagepipeline::CacheOption::DISK;
|
|
49
|
+
case hashString("none"): return margelo::nitro::nitroimagepipeline::CacheOption::NONE;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CacheOption - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroimagepipeline::CacheOption arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::nitroimagepipeline::CacheOption::MEMORY: return JSIConverter<std::string>::toJSI(runtime, "memory");
|
|
57
|
+
case margelo::nitro::nitroimagepipeline::CacheOption::DISK: return JSIConverter<std::string>::toJSI(runtime, "disk");
|
|
58
|
+
case margelo::nitro::nitroimagepipeline::CacheOption::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert CacheOption to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("memory"):
|
|
71
|
+
case hashString("disk"):
|
|
72
|
+
case hashString("none"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroImagePipelineSpec.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 "HybridNitroImagePipelineSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
11
|
+
|
|
12
|
+
void HybridNitroImagePipelineSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("loadImage", &HybridNitroImagePipelineSpec::loadImage);
|
|
18
|
+
prototype.registerHybridMethod("preLoadImage", &HybridNitroImagePipelineSpec::preLoadImage);
|
|
19
|
+
prototype.registerHybridMethod("preLoadImages", &HybridNitroImagePipelineSpec::preLoadImages);
|
|
20
|
+
prototype.registerHybridMethod("gaussianBlur", &HybridNitroImagePipelineSpec::gaussianBlur);
|
|
21
|
+
prototype.registerHybridMethod("clearCache", &HybridNitroImagePipelineSpec::clearCache);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroImagePipelineSpec.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
|
+
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
18
|
+
// Forward declaration of `Options` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
20
|
+
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include <NitroImage/HybridImageSpec.hpp>
|
|
23
|
+
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include <string>
|
|
25
|
+
#include "Options.hpp"
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include <vector>
|
|
28
|
+
|
|
29
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
30
|
+
|
|
31
|
+
using namespace margelo::nitro;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An abstract base class for `NitroImagePipeline`
|
|
35
|
+
* Inherit this class to create instances of `HybridNitroImagePipelineSpec` in C++.
|
|
36
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
37
|
+
* @example
|
|
38
|
+
* ```cpp
|
|
39
|
+
* class HybridNitroImagePipeline: public HybridNitroImagePipelineSpec {
|
|
40
|
+
* public:
|
|
41
|
+
* HybridNitroImagePipeline(...): HybridObject(TAG) { ... }
|
|
42
|
+
* // ...
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
class HybridNitroImagePipelineSpec: public virtual HybridObject {
|
|
47
|
+
public:
|
|
48
|
+
// Constructor
|
|
49
|
+
explicit HybridNitroImagePipelineSpec(): HybridObject(TAG) { }
|
|
50
|
+
|
|
51
|
+
// Destructor
|
|
52
|
+
~HybridNitroImagePipelineSpec() override = default;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Properties
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// Methods
|
|
60
|
+
virtual std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadImage(const std::string& url, const std::optional<Options>& options) = 0;
|
|
61
|
+
virtual std::shared_ptr<Promise<void>> preLoadImage(const std::string& url) = 0;
|
|
62
|
+
virtual std::shared_ptr<Promise<void>> preLoadImages(const std::vector<std::string>& urls) = 0;
|
|
63
|
+
virtual std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> gaussianBlur(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& image, double radius) = 0;
|
|
64
|
+
virtual void clearCache() = 0;
|
|
65
|
+
|
|
66
|
+
protected:
|
|
67
|
+
// Hybrid Setup
|
|
68
|
+
void loadHybridMethods() override;
|
|
69
|
+
|
|
70
|
+
protected:
|
|
71
|
+
// Tag for logging
|
|
72
|
+
static constexpr auto TAG = "NitroImagePipeline";
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Options.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/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `CacheOption` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
33
|
+
|
|
34
|
+
#include <optional>
|
|
35
|
+
#include "CacheOption.hpp"
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (Options).
|
|
41
|
+
*/
|
|
42
|
+
struct Options final {
|
|
43
|
+
public:
|
|
44
|
+
std::optional<double> blur SWIFT_PRIVATE;
|
|
45
|
+
std::optional<CacheOption> cache SWIFT_PRIVATE;
|
|
46
|
+
std::optional<double> cornerRadius SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
Options() = default;
|
|
50
|
+
explicit Options(std::optional<double> blur, std::optional<CacheOption> cache, std::optional<double> cornerRadius): blur(blur), cache(cache), cornerRadius(cornerRadius) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const Options& lhs, const Options& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ Options <> JS Options (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::nitroimagepipeline::Options> final {
|
|
63
|
+
static inline margelo::nitro::nitroimagepipeline::Options fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::nitroimagepipeline::Options(
|
|
66
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blur"))),
|
|
67
|
+
JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::CacheOption>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cache"))),
|
|
68
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cornerRadius")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroimagepipeline::Options& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "blur"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.blur));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cache"), JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::CacheOption>>::toJSI(runtime, arg.cache));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cornerRadius"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.cornerRadius));
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
79
|
+
if (!value.isObject()) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
jsi::Object obj = value.getObject(runtime);
|
|
83
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blur")))) return false;
|
|
87
|
+
if (!JSIConverter<std::optional<margelo::nitro::nitroimagepipeline::CacheOption>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cache")))) return false;
|
|
88
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cornerRadius")))) return false;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro
|