@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,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Skeleton-Swift-Cxx-Bridge.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridSkeletonSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::skeleton { class HybridSkeletonSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridSkeletonSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace Skeleton { class HybridSkeletonSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridSkeletonSpec.hpp"
|
|
20
|
+
#include <memory>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
27
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
28
|
+
*/
|
|
29
|
+
namespace margelo::nitro::skeleton::bridge::swift {
|
|
30
|
+
|
|
31
|
+
// pragma MARK: std::optional<double>
|
|
32
|
+
/**
|
|
33
|
+
* Specialized version of `std::optional<double>`.
|
|
34
|
+
*/
|
|
35
|
+
using std__optional_double_ = std::optional<double>;
|
|
36
|
+
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
|
|
37
|
+
return std::optional<double>(value);
|
|
38
|
+
}
|
|
39
|
+
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
40
|
+
return optional.has_value();
|
|
41
|
+
}
|
|
42
|
+
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
43
|
+
return *optional;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// pragma MARK: std::vector<std::string>
|
|
47
|
+
/**
|
|
48
|
+
* Specialized version of `std::vector<std::string>`.
|
|
49
|
+
*/
|
|
50
|
+
using std__vector_std__string_ = std::vector<std::string>;
|
|
51
|
+
inline std::vector<std::string> create_std__vector_std__string_(size_t size) noexcept {
|
|
52
|
+
std::vector<std::string> vector;
|
|
53
|
+
vector.reserve(size);
|
|
54
|
+
return vector;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// pragma MARK: std::optional<std::vector<std::string>>
|
|
58
|
+
/**
|
|
59
|
+
* Specialized version of `std::optional<std::vector<std::string>>`.
|
|
60
|
+
*/
|
|
61
|
+
using std__optional_std__vector_std__string__ = std::optional<std::vector<std::string>>;
|
|
62
|
+
inline std::optional<std::vector<std::string>> create_std__optional_std__vector_std__string__(const std::vector<std::string>& value) noexcept {
|
|
63
|
+
return std::optional<std::vector<std::string>>(value);
|
|
64
|
+
}
|
|
65
|
+
inline bool has_value_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
|
|
66
|
+
return optional.has_value();
|
|
67
|
+
}
|
|
68
|
+
inline std::vector<std::string> get_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
|
|
69
|
+
return *optional;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// pragma MARK: std::shared_ptr<HybridSkeletonSpec>
|
|
73
|
+
/**
|
|
74
|
+
* Specialized version of `std::shared_ptr<HybridSkeletonSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
using std__shared_ptr_HybridSkeletonSpec_ = std::shared_ptr<HybridSkeletonSpec>;
|
|
77
|
+
std::shared_ptr<HybridSkeletonSpec> create_std__shared_ptr_HybridSkeletonSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
78
|
+
void* NON_NULL get_std__shared_ptr_HybridSkeletonSpec_(std__shared_ptr_HybridSkeletonSpec_ cppType);
|
|
79
|
+
|
|
80
|
+
// pragma MARK: std::weak_ptr<HybridSkeletonSpec>
|
|
81
|
+
using std__weak_ptr_HybridSkeletonSpec_ = std::weak_ptr<HybridSkeletonSpec>;
|
|
82
|
+
inline std__weak_ptr_HybridSkeletonSpec_ weakify_std__shared_ptr_HybridSkeletonSpec_(const std::shared_ptr<HybridSkeletonSpec>& strong) noexcept { return strong; }
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::skeleton::bridge::swift
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Skeleton-Swift-Cxx-Umbrella.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridSkeletonSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::skeleton { class HybridSkeletonSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridSkeletonSpec.hpp"
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
// C++ helpers for Swift
|
|
22
|
+
#include "Skeleton-Swift-Cxx-Bridge.hpp"
|
|
23
|
+
|
|
24
|
+
// Common C++ types used in Swift
|
|
25
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
26
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
27
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
28
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
29
|
+
|
|
30
|
+
// Forward declarations of Swift defined types
|
|
31
|
+
// Forward declaration of `HybridSkeletonSpec_cxx` to properly resolve imports.
|
|
32
|
+
namespace Skeleton { class HybridSkeletonSpec_cxx; }
|
|
33
|
+
|
|
34
|
+
// Include Swift defined types
|
|
35
|
+
#if __has_include("Skeleton-Swift.h")
|
|
36
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
37
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "Skeleton".
|
|
38
|
+
#include "Skeleton-Swift.h"
|
|
39
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
40
|
+
#elif __has_include(<Skeleton/Skeleton-Swift.h>)
|
|
41
|
+
#include <Skeleton/Skeleton-Swift.h>
|
|
42
|
+
#else
|
|
43
|
+
#error Skeleton's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "Skeleton", and try building the app first.
|
|
44
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SkeletonAutolinking.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 <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "Skeleton-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridSkeletonSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface SkeletonAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation SkeletonAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::skeleton;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"Skeleton",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridSkeletonSpec> hybridObject = Skeleton::SkeletonAutolinking::createSkeleton();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SkeletonAutolinking.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
|
+
public final class SkeletonAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.skeleton.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridSkeletonSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridSkeletonSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridSkeleton`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createSkeleton() -> bridge.std__shared_ptr_HybridSkeletonSpec_ {
|
|
19
|
+
let hybridObject = HybridSkeleton()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridSkeletonSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpecSwift.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 "HybridSkeletonSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::skeleton {
|
|
11
|
+
} // namespace margelo::nitro::skeleton
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSkeletonSpecSwift.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 "HybridSkeletonSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridSkeletonSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace Skeleton { class HybridSkeletonSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "Skeleton-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::skeleton {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridSkeletonSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridSkeletonSpecSwift (C++) accesses HybridSkeletonSpec_cxx (Swift), and might
|
|
29
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
30
|
+
*
|
|
31
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
32
|
+
* the future, HybridSkeletonSpec_cxx can directly inherit from the C++ class HybridSkeletonSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridSkeletonSpecSwift: public virtual HybridSkeletonSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridSkeletonSpecSwift(const Skeleton::HybridSkeletonSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridSkeletonSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline Skeleton::HybridSkeletonSpec_cxx& getSwiftPart() noexcept {
|
|
45
|
+
return _swiftPart;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
50
|
+
return _swiftPart.getMemorySize();
|
|
51
|
+
}
|
|
52
|
+
void dispose() noexcept override {
|
|
53
|
+
_swiftPart.dispose();
|
|
54
|
+
}
|
|
55
|
+
std::string toString() override {
|
|
56
|
+
return _swiftPart.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Properties
|
|
61
|
+
inline std::optional<double> getShimmerSpeed() noexcept override {
|
|
62
|
+
auto __result = _swiftPart.getShimmerSpeed();
|
|
63
|
+
return __result;
|
|
64
|
+
}
|
|
65
|
+
inline void setShimmerSpeed(std::optional<double> shimmerSpeed) noexcept override {
|
|
66
|
+
_swiftPart.setShimmerSpeed(shimmerSpeed);
|
|
67
|
+
}
|
|
68
|
+
inline std::optional<std::vector<std::string>> getShimmerGradientColors() noexcept override {
|
|
69
|
+
auto __result = _swiftPart.getShimmerGradientColors();
|
|
70
|
+
return __result;
|
|
71
|
+
}
|
|
72
|
+
inline void setShimmerGradientColors(const std::optional<std::vector<std::string>>& shimmerGradientColors) noexcept override {
|
|
73
|
+
_swiftPart.setShimmerGradientColors(shimmerGradientColors);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public:
|
|
77
|
+
// Methods
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
Skeleton::HybridSkeletonSpec_cxx _swiftPart;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::skeleton
|
|
@@ -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
|