@onekeyfe/react-native-skeleton 1.1.11
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 -0
- package/README.md +39 -0
- package/Skeleton.podspec +29 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/skeleton/Skeleton.kt +135 -0
- package/android/src/main/java/com/margelo/nitro/skeleton/SkeletonPackage.kt +29 -0
- package/ios/Skeleton.swift +126 -0
- package/lib/module/Skeleton.nitro.js +4 -0
- package/lib/module/Skeleton.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/nitrogen/generated/android/c++/JHybridSkeletonSpec.cpp +85 -0
- package/lib/nitrogen/generated/android/c++/JHybridSkeletonSpec.hpp +68 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.cpp +60 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.hpp +49 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/HybridSkeletonSpec.kt +65 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/skeletonOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonManager.kt +50 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/skeleton+autolinking.cmake +83 -0
- package/lib/nitrogen/generated/android/skeleton+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/skeletonOnLoad.cpp +46 -0
- package/lib/nitrogen/generated/android/skeletonOnLoad.hpp +25 -0
- package/lib/nitrogen/generated/ios/Skeleton+autolinking.rb +60 -0
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.cpp +33 -0
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.hpp +84 -0
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Umbrella.hpp +44 -0
- package/lib/nitrogen/generated/ios/SkeletonAutolinking.mm +33 -0
- package/lib/nitrogen/generated/ios/SkeletonAutolinking.swift +25 -0
- package/lib/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.hpp +84 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridSkeletonComponent.mm +101 -0
- package/lib/nitrogen/generated/ios/swift/HybridSkeletonSpec.swift +57 -0
- package/lib/nitrogen/generated/ios/swift/HybridSkeletonSpec_cxx.swift +176 -0
- package/lib/nitrogen/generated/shared/c++/HybridSkeletonSpec.cpp +24 -0
- package/lib/nitrogen/generated/shared/c++/HybridSkeletonSpec.hpp +67 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.cpp +99 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.hpp +110 -0
- package/lib/nitrogen/generated/shared/json/SkeletonConfig.json +11 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Skeleton.nitro.d.ts +9 -0
- package/lib/typescript/src/Skeleton.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridSkeletonSpec.cpp +85 -0
- package/nitrogen/generated/android/c++/JHybridSkeletonSpec.hpp +68 -0
- package/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.cpp +60 -0
- package/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/HybridSkeletonSpec.kt +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/skeletonOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonStateUpdater.kt +23 -0
- package/nitrogen/generated/android/skeleton+autolinking.cmake +83 -0
- package/nitrogen/generated/android/skeleton+autolinking.gradle +27 -0
- package/nitrogen/generated/android/skeletonOnLoad.cpp +46 -0
- package/nitrogen/generated/android/skeletonOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/Skeleton+autolinking.rb +60 -0
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.hpp +84 -0
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Umbrella.hpp +44 -0
- package/nitrogen/generated/ios/SkeletonAutolinking.mm +33 -0
- package/nitrogen/generated/ios/SkeletonAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.hpp +84 -0
- package/nitrogen/generated/ios/c++/views/HybridSkeletonComponent.mm +101 -0
- package/nitrogen/generated/ios/swift/HybridSkeletonSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridSkeletonSpec_cxx.swift +176 -0
- package/nitrogen/generated/shared/c++/HybridSkeletonSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridSkeletonSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.cpp +99 -0
- package/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.hpp +110 -0
- package/nitrogen/generated/shared/json/SkeletonConfig.json +11 -0
- package/package.json +170 -0
- package/src/Skeleton.nitro.ts +13 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonComponent.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import "HybridSkeletonComponent.hpp"
|
|
9
|
+
#import <memory>
|
|
10
|
+
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <React/RCTComponentViewFactory.h>
|
|
13
|
+
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
+
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
+
#import <UIKit/UIKit.h>
|
|
16
|
+
|
|
17
|
+
#import "HybridSkeletonSpecSwift.hpp"
|
|
18
|
+
#import "Skeleton-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
using namespace facebook;
|
|
21
|
+
using namespace margelo::nitro::skeleton;
|
|
22
|
+
using namespace margelo::nitro::skeleton::views;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the React Native View holder for the Nitro "Skeleton" HybridView.
|
|
26
|
+
*/
|
|
27
|
+
@interface HybridSkeletonComponent: RCTViewComponentView
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation HybridSkeletonComponent {
|
|
31
|
+
std::shared_ptr<HybridSkeletonSpecSwift> _hybridView;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (void) load {
|
|
35
|
+
[super load];
|
|
36
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridSkeletonComponent class]];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
40
|
+
return react::concreteComponentDescriptorProvider<HybridSkeletonComponentDescriptor>();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (instancetype) init {
|
|
44
|
+
if (self = [super init]) {
|
|
45
|
+
std::shared_ptr<HybridSkeletonSpec> hybridView = Skeleton::SkeletonAutolinking::createSkeleton();
|
|
46
|
+
_hybridView = std::dynamic_pointer_cast<HybridSkeletonSpecSwift>(hybridView);
|
|
47
|
+
[self updateView];
|
|
48
|
+
}
|
|
49
|
+
return self;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void) updateView {
|
|
53
|
+
// 1. Get Swift part
|
|
54
|
+
Skeleton::HybridSkeletonSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
55
|
+
|
|
56
|
+
// 2. Get UIView*
|
|
57
|
+
void* viewUnsafe = swiftPart.getView();
|
|
58
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
59
|
+
|
|
60
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
61
|
+
[self setContentView:view];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
65
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
66
|
+
// 1. Downcast props
|
|
67
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridSkeletonProps const>(props);
|
|
68
|
+
auto& newViewProps = const_cast<HybridSkeletonProps&>(newViewPropsConst);
|
|
69
|
+
Skeleton::HybridSkeletonSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
70
|
+
|
|
71
|
+
// 2. Update each prop individually
|
|
72
|
+
swiftPart.beforeUpdate();
|
|
73
|
+
|
|
74
|
+
// shimmerSpeed: optional
|
|
75
|
+
if (newViewProps.shimmerSpeed.isDirty) {
|
|
76
|
+
swiftPart.setShimmerSpeed(newViewProps.shimmerSpeed.value);
|
|
77
|
+
newViewProps.shimmerSpeed.isDirty = false;
|
|
78
|
+
}
|
|
79
|
+
// shimmerGradientColors: optional
|
|
80
|
+
if (newViewProps.shimmerGradientColors.isDirty) {
|
|
81
|
+
swiftPart.setShimmerGradientColors(newViewProps.shimmerGradientColors.value);
|
|
82
|
+
newViewProps.shimmerGradientColors.isDirty = false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
swiftPart.afterUpdate();
|
|
86
|
+
|
|
87
|
+
// 3. Update hybridRef if it changed
|
|
88
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
89
|
+
// hybridRef changed - call it with new this
|
|
90
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
91
|
+
if (maybeFunc.has_value()) {
|
|
92
|
+
maybeFunc.value()(_hybridView);
|
|
93
|
+
}
|
|
94
|
+
newViewProps.hybridRef.isDirty = false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 4. Continue in base class
|
|
98
|
+
[super updateProps:props oldProps:oldProps];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridSkeletonSpec``
|
|
12
|
+
public protocol HybridSkeletonSpec_protocol: HybridObject, HybridView {
|
|
13
|
+
// Properties
|
|
14
|
+
var shimmerSpeed: Double? { get set }
|
|
15
|
+
var shimmerGradientColors: [String]? { get set }
|
|
16
|
+
|
|
17
|
+
// Methods
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public extension HybridSkeletonSpec_protocol {
|
|
22
|
+
/// Default implementation of ``HybridObject.toString``
|
|
23
|
+
func toString() -> String {
|
|
24
|
+
return "[HybridObject Skeleton]"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// See ``HybridSkeletonSpec``
|
|
29
|
+
open class HybridSkeletonSpec_base {
|
|
30
|
+
private weak var cxxWrapper: HybridSkeletonSpec_cxx? = nil
|
|
31
|
+
public init() { }
|
|
32
|
+
public func getCxxWrapper() -> HybridSkeletonSpec_cxx {
|
|
33
|
+
#if DEBUG
|
|
34
|
+
guard self is HybridSkeletonSpec else {
|
|
35
|
+
fatalError("`self` is not a `HybridSkeletonSpec`! Did you accidentally inherit from `HybridSkeletonSpec_base` instead of `HybridSkeletonSpec`?")
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
39
|
+
return cxxWrapper
|
|
40
|
+
} else {
|
|
41
|
+
let cxxWrapper = HybridSkeletonSpec_cxx(self as! HybridSkeletonSpec)
|
|
42
|
+
self.cxxWrapper = cxxWrapper
|
|
43
|
+
return cxxWrapper
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Swift base-protocol representing the Skeleton HybridObject.
|
|
50
|
+
* Implement this protocol to create Swift-based instances of Skeleton.
|
|
51
|
+
* ```swift
|
|
52
|
+
* class HybridSkeleton : HybridSkeletonSpec {
|
|
53
|
+
* // ...
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
public typealias HybridSkeletonSpec = HybridSkeletonSpec_protocol & HybridSkeletonSpec_base
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridSkeletonSpec 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 HybridSkeletonSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::skeleton::bridge::swift`)
|
|
23
|
+
* from `Skeleton-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.skeleton.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridSkeletonSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridSkeletonSpec
|
|
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_HybridSkeletonSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridSkeletonSpec_cxx` that wraps the given `HybridSkeletonSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridSkeletonSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridSkeletonSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridSkeletonSpec() -> any HybridSkeletonSpec {
|
|
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 `HybridSkeletonSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridSkeletonSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridSkeletonSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridSkeletonSpec_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<HybridSkeletonSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridSkeletonSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridSkeletonSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridSkeletonSpec_(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
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
public final var shimmerSpeed: bridge.std__optional_double_ {
|
|
118
|
+
@inline(__always)
|
|
119
|
+
get {
|
|
120
|
+
return { () -> bridge.std__optional_double_ in
|
|
121
|
+
if let __unwrappedValue = self.__implementation.shimmerSpeed {
|
|
122
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
123
|
+
} else {
|
|
124
|
+
return .init()
|
|
125
|
+
}
|
|
126
|
+
}()
|
|
127
|
+
}
|
|
128
|
+
@inline(__always)
|
|
129
|
+
set {
|
|
130
|
+
self.__implementation.shimmerSpeed = newValue.value
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public final var shimmerGradientColors: bridge.std__optional_std__vector_std__string__ {
|
|
135
|
+
@inline(__always)
|
|
136
|
+
get {
|
|
137
|
+
return { () -> bridge.std__optional_std__vector_std__string__ in
|
|
138
|
+
if let __unwrappedValue = self.__implementation.shimmerGradientColors {
|
|
139
|
+
return bridge.create_std__optional_std__vector_std__string__({ () -> bridge.std__vector_std__string_ in
|
|
140
|
+
var __vector = bridge.create_std__vector_std__string_(__unwrappedValue.count)
|
|
141
|
+
for __item in __unwrappedValue {
|
|
142
|
+
__vector.push_back(std.string(__item))
|
|
143
|
+
}
|
|
144
|
+
return __vector
|
|
145
|
+
}())
|
|
146
|
+
} else {
|
|
147
|
+
return .init()
|
|
148
|
+
}
|
|
149
|
+
}()
|
|
150
|
+
}
|
|
151
|
+
@inline(__always)
|
|
152
|
+
set {
|
|
153
|
+
self.__implementation.shimmerGradientColors = { () -> [String]? in
|
|
154
|
+
if bridge.has_value_std__optional_std__vector_std__string__(newValue) {
|
|
155
|
+
let __unwrapped = bridge.get_std__optional_std__vector_std__string__(newValue)
|
|
156
|
+
return __unwrapped.map({ __item in String(__item) })
|
|
157
|
+
} else {
|
|
158
|
+
return nil
|
|
159
|
+
}
|
|
160
|
+
}()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Methods
|
|
165
|
+
public final func getView() -> UnsafeMutableRawPointer {
|
|
166
|
+
return Unmanaged.passRetained(__implementation.view).toOpaque()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public final func beforeUpdate() {
|
|
170
|
+
__implementation.beforeUpdate()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public final func afterUpdate() {
|
|
174
|
+
__implementation.afterUpdate()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridSkeletonSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::skeleton {
|
|
11
|
+
|
|
12
|
+
void HybridSkeletonSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("shimmerSpeed", &HybridSkeletonSpec::getShimmerSpeed);
|
|
18
|
+
prototype.registerHybridSetter("shimmerSpeed", &HybridSkeletonSpec::setShimmerSpeed);
|
|
19
|
+
prototype.registerHybridGetter("shimmerGradientColors", &HybridSkeletonSpec::getShimmerGradientColors);
|
|
20
|
+
prototype.registerHybridSetter("shimmerGradientColors", &HybridSkeletonSpec::setShimmerGradientColors);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace margelo::nitro::skeleton
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 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
|
+
#include <optional>
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::skeleton {
|
|
23
|
+
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An abstract base class for `Skeleton`
|
|
28
|
+
* Inherit this class to create instances of `HybridSkeletonSpec` in C++.
|
|
29
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
+
* @example
|
|
31
|
+
* ```cpp
|
|
32
|
+
* class HybridSkeleton: public HybridSkeletonSpec {
|
|
33
|
+
* public:
|
|
34
|
+
* HybridSkeleton(...): HybridObject(TAG) { ... }
|
|
35
|
+
* // ...
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class HybridSkeletonSpec: public virtual HybridObject {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor
|
|
42
|
+
explicit HybridSkeletonSpec(): HybridObject(TAG) { }
|
|
43
|
+
|
|
44
|
+
// Destructor
|
|
45
|
+
~HybridSkeletonSpec() override = default;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Properties
|
|
49
|
+
virtual std::optional<double> getShimmerSpeed() = 0;
|
|
50
|
+
virtual void setShimmerSpeed(std::optional<double> shimmerSpeed) = 0;
|
|
51
|
+
virtual std::optional<std::vector<std::string>> getShimmerGradientColors() = 0;
|
|
52
|
+
virtual void setShimmerGradientColors(const std::optional<std::vector<std::string>>& shimmerGradientColors) = 0;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Methods
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
protected:
|
|
59
|
+
// Hybrid Setup
|
|
60
|
+
void loadHybridMethods() override;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Tag for logging
|
|
64
|
+
static constexpr auto TAG = "Skeleton";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro::skeleton
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonComponent.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridSkeletonComponent.hpp"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <exception>
|
|
12
|
+
#include <utility>
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <react/renderer/core/RawValue.h>
|
|
16
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
17
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
18
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::skeleton::views {
|
|
21
|
+
|
|
22
|
+
extern const char HybridSkeletonComponentName[] = "Skeleton";
|
|
23
|
+
|
|
24
|
+
HybridSkeletonProps::HybridSkeletonProps(const react::PropsParserContext& context,
|
|
25
|
+
const HybridSkeletonProps& sourceProps,
|
|
26
|
+
const react::RawProps& rawProps):
|
|
27
|
+
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
28
|
+
shimmerSpeed([&]() -> CachedProp<std::optional<double>> {
|
|
29
|
+
try {
|
|
30
|
+
const react::RawValue* rawValue = rawProps.at("shimmerSpeed", nullptr, nullptr);
|
|
31
|
+
if (rawValue == nullptr) return sourceProps.shimmerSpeed;
|
|
32
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
33
|
+
return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.shimmerSpeed);
|
|
34
|
+
} catch (const std::exception& exc) {
|
|
35
|
+
throw std::runtime_error(std::string("Skeleton.shimmerSpeed: ") + exc.what());
|
|
36
|
+
}
|
|
37
|
+
}()),
|
|
38
|
+
shimmerGradientColors([&]() -> CachedProp<std::optional<std::vector<std::string>>> {
|
|
39
|
+
try {
|
|
40
|
+
const react::RawValue* rawValue = rawProps.at("shimmerGradientColors", nullptr, nullptr);
|
|
41
|
+
if (rawValue == nullptr) return sourceProps.shimmerGradientColors;
|
|
42
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
43
|
+
return CachedProp<std::optional<std::vector<std::string>>>::fromRawValue(*runtime, value, sourceProps.shimmerGradientColors);
|
|
44
|
+
} catch (const std::exception& exc) {
|
|
45
|
+
throw std::runtime_error(std::string("Skeleton.shimmerGradientColors: ") + exc.what());
|
|
46
|
+
}
|
|
47
|
+
}()),
|
|
48
|
+
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSkeletonSpec>& /* ref */)>>> {
|
|
49
|
+
try {
|
|
50
|
+
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
51
|
+
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
52
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
53
|
+
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSkeletonSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
|
|
54
|
+
} catch (const std::exception& exc) {
|
|
55
|
+
throw std::runtime_error(std::string("Skeleton.hybridRef: ") + exc.what());
|
|
56
|
+
}
|
|
57
|
+
}()) { }
|
|
58
|
+
|
|
59
|
+
HybridSkeletonProps::HybridSkeletonProps(const HybridSkeletonProps& other):
|
|
60
|
+
react::ViewProps(),
|
|
61
|
+
shimmerSpeed(other.shimmerSpeed),
|
|
62
|
+
shimmerGradientColors(other.shimmerGradientColors),
|
|
63
|
+
hybridRef(other.hybridRef) { }
|
|
64
|
+
|
|
65
|
+
bool HybridSkeletonProps::filterObjectKeys(const std::string& propName) {
|
|
66
|
+
switch (hashString(propName)) {
|
|
67
|
+
case hashString("shimmerSpeed"): return true;
|
|
68
|
+
case hashString("shimmerGradientColors"): return true;
|
|
69
|
+
case hashString("hybridRef"): return true;
|
|
70
|
+
default: return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
HybridSkeletonComponentDescriptor::HybridSkeletonComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
75
|
+
: ConcreteComponentDescriptor(parameters,
|
|
76
|
+
react::RawPropsParser(/* enableJsiParser */ true)) {}
|
|
77
|
+
|
|
78
|
+
std::shared_ptr<const react::Props> HybridSkeletonComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
79
|
+
const std::shared_ptr<const react::Props>& props,
|
|
80
|
+
react::RawProps rawProps) const {
|
|
81
|
+
// 1. Prepare raw props parser
|
|
82
|
+
rawProps.parse(rawPropsParser_);
|
|
83
|
+
// 2. Copy props with Nitro's cached copy constructor
|
|
84
|
+
return HybridSkeletonShadowNode::Props(context, /* & */ rawProps, props);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#ifdef ANDROID
|
|
88
|
+
void HybridSkeletonComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
89
|
+
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
90
|
+
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
91
|
+
auto& concreteShadowNode = dynamic_cast<HybridSkeletonShadowNode&>(shadowNode);
|
|
92
|
+
const HybridSkeletonProps& props = concreteShadowNode.getConcreteProps();
|
|
93
|
+
HybridSkeletonState state;
|
|
94
|
+
state.setProps(props);
|
|
95
|
+
concreteShadowNode.setStateData(std::move(state));
|
|
96
|
+
}
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
} // namespace margelo::nitro::skeleton::views
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonComponent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 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 <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <vector>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include "HybridSkeletonSpec.hpp"
|
|
24
|
+
#include <functional>
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::skeleton::views {
|
|
27
|
+
|
|
28
|
+
using namespace facebook;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The name of the actual native View.
|
|
32
|
+
*/
|
|
33
|
+
extern const char HybridSkeletonComponentName[];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Props for the "Skeleton" View.
|
|
37
|
+
*/
|
|
38
|
+
class HybridSkeletonProps final: public react::ViewProps {
|
|
39
|
+
public:
|
|
40
|
+
HybridSkeletonProps() = default;
|
|
41
|
+
HybridSkeletonProps(const HybridSkeletonProps&);
|
|
42
|
+
HybridSkeletonProps(const react::PropsParserContext& context,
|
|
43
|
+
const HybridSkeletonProps& sourceProps,
|
|
44
|
+
const react::RawProps& rawProps);
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
CachedProp<std::optional<double>> shimmerSpeed;
|
|
48
|
+
CachedProp<std::optional<std::vector<std::string>>> shimmerGradientColors;
|
|
49
|
+
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSkeletonSpec>& /* ref */)>>> hybridRef;
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* State for the "Skeleton" View.
|
|
57
|
+
*/
|
|
58
|
+
class HybridSkeletonState final {
|
|
59
|
+
public:
|
|
60
|
+
HybridSkeletonState() = default;
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
void setProps(const HybridSkeletonProps& props) { _props.emplace(props); }
|
|
64
|
+
const std::optional<HybridSkeletonProps>& getProps() const { return _props; }
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
#ifdef ANDROID
|
|
68
|
+
HybridSkeletonState(const HybridSkeletonState& /* previousState */, folly::dynamic /* data */) {}
|
|
69
|
+
folly::dynamic getDynamic() const {
|
|
70
|
+
throw std::runtime_error("HybridSkeletonState does not support folly!");
|
|
71
|
+
}
|
|
72
|
+
react::MapBuffer getMapBuffer() const {
|
|
73
|
+
throw std::runtime_error("HybridSkeletonState does not support MapBuffer!");
|
|
74
|
+
};
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
std::optional<HybridSkeletonProps> _props;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The Shadow Node for the "Skeleton" View.
|
|
83
|
+
*/
|
|
84
|
+
using HybridSkeletonShadowNode = react::ConcreteViewShadowNode<HybridSkeletonComponentName /* "HybridSkeleton" */,
|
|
85
|
+
HybridSkeletonProps /* custom props */,
|
|
86
|
+
react::ViewEventEmitter /* default */,
|
|
87
|
+
HybridSkeletonState /* custom state */>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The Component Descriptor for the "Skeleton" View.
|
|
91
|
+
*/
|
|
92
|
+
class HybridSkeletonComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridSkeletonShadowNode> {
|
|
93
|
+
public:
|
|
94
|
+
HybridSkeletonComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
95
|
+
|
|
96
|
+
public:
|
|
97
|
+
/**
|
|
98
|
+
* A faster path for cloning props - reuses the caching logic from `HybridSkeletonProps`.
|
|
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 "Skeleton" needs to be implemented in platform-specific code. */
|
|
109
|
+
|
|
110
|
+
} // namespace margelo::nitro::skeleton::views
|