@onekeyfe/react-native-skeleton 3.0.81 → 3.0.82
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/lib/nitrogen/generated/android/c++/JHybridSkeletonSpec.cpp +24 -23
- package/lib/nitrogen/generated/android/c++/JHybridSkeletonSpec.hpp +20 -22
- package/lib/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.cpp +20 -20
- package/lib/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.hpp +4 -4
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/HybridSkeletonSpec.kt +17 -19
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/skeletonOnLoad.kt +1 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonManager.kt +40 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonStateUpdater.kt +1 -1
- package/lib/nitrogen/generated/android/skeleton+autolinking.cmake +1 -1
- package/lib/nitrogen/generated/android/skeleton+autolinking.gradle +1 -1
- package/lib/nitrogen/generated/android/skeletonOnLoad.cpp +28 -18
- package/lib/nitrogen/generated/android/skeletonOnLoad.hpp +14 -5
- package/lib/nitrogen/generated/ios/Skeleton+autolinking.rb +2 -2
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.cpp +1 -1
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.hpp +3 -3
- package/lib/nitrogen/generated/ios/Skeleton-Swift-Cxx-Umbrella.hpp +1 -1
- package/lib/nitrogen/generated/ios/SkeletonAutolinking.mm +1 -1
- package/lib/nitrogen/generated/ios/SkeletonAutolinking.swift +9 -8
- package/lib/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.cpp +1 -1
- package/lib/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.hpp +7 -1
- package/lib/nitrogen/generated/ios/c++/views/HybridSkeletonComponent.mm +27 -1
- package/lib/nitrogen/generated/ios/swift/HybridSkeletonSpec.swift +3 -4
- package/lib/nitrogen/generated/ios/swift/HybridSkeletonSpec_cxx.swift +26 -3
- package/lib/nitrogen/generated/shared/c++/HybridSkeletonSpec.cpp +1 -1
- package/lib/nitrogen/generated/shared/c++/HybridSkeletonSpec.hpp +1 -1
- package/lib/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.cpp +7 -12
- package/lib/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.hpp +9 -6
- package/nitrogen/generated/android/c++/JHybridSkeletonSpec.cpp +24 -23
- package/nitrogen/generated/android/c++/JHybridSkeletonSpec.hpp +20 -22
- package/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.cpp +20 -20
- package/nitrogen/generated/android/c++/views/JHybridSkeletonStateUpdater.hpp +4 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/HybridSkeletonSpec.kt +17 -19
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/skeletonOnLoad.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonManager.kt +40 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonStateUpdater.kt +1 -1
- package/nitrogen/generated/android/skeleton+autolinking.cmake +1 -1
- package/nitrogen/generated/android/skeleton+autolinking.gradle +1 -1
- package/nitrogen/generated/android/skeletonOnLoad.cpp +28 -18
- package/nitrogen/generated/android/skeletonOnLoad.hpp +14 -5
- package/nitrogen/generated/ios/Skeleton+autolinking.rb +2 -2
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Bridge.hpp +3 -3
- package/nitrogen/generated/ios/Skeleton-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/SkeletonAutolinking.mm +1 -1
- package/nitrogen/generated/ios/SkeletonAutolinking.swift +9 -8
- package/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridSkeletonSpecSwift.hpp +7 -1
- package/nitrogen/generated/ios/c++/views/HybridSkeletonComponent.mm +27 -1
- package/nitrogen/generated/ios/swift/HybridSkeletonSpec.swift +3 -4
- package/nitrogen/generated/ios/swift/HybridSkeletonSpec_cxx.swift +26 -3
- package/nitrogen/generated/shared/c++/HybridSkeletonSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridSkeletonSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.cpp +7 -12
- package/nitrogen/generated/shared/c++/views/HybridSkeletonComponent.hpp +9 -6
- package/package.json +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonSpec.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.skeleton
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.skeleton
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.HybridObject
|
|
13
14
|
import com.margelo.nitro.views.HybridView
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -24,23 +25,6 @@ import com.margelo.nitro.views.HybridView
|
|
|
24
25
|
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
26
|
)
|
|
26
27
|
abstract class HybridSkeletonSpec: HybridView() {
|
|
27
|
-
@DoNotStrip
|
|
28
|
-
private var mHybridData: HybridData = initHybrid()
|
|
29
|
-
|
|
30
|
-
init {
|
|
31
|
-
super.updateNative(mHybridData)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun updateNative(hybridData: HybridData) {
|
|
35
|
-
mHybridData = hybridData
|
|
36
|
-
super.updateNative(hybridData)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Default implementation of `HybridObject.toString()`
|
|
40
|
-
override fun toString(): String {
|
|
41
|
-
return "[HybridObject Skeleton]"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
28
|
// Properties
|
|
45
29
|
@get:DoNotStrip
|
|
46
30
|
@get:Keep
|
|
@@ -57,7 +41,21 @@ abstract class HybridSkeletonSpec: HybridView() {
|
|
|
57
41
|
// Methods
|
|
58
42
|
|
|
59
43
|
|
|
60
|
-
|
|
44
|
+
// Default implementation of `HybridObject.toString()`
|
|
45
|
+
override fun toString(): String {
|
|
46
|
+
return "[HybridObject Skeleton]"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// C++ backing class
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
protected open class CxxPart(javaPart: HybridSkeletonSpec): HybridObject.CxxPart(javaPart) {
|
|
53
|
+
// C++ JHybridSkeletonSpec::CxxPart::initHybrid(...)
|
|
54
|
+
external override fun initHybrid(): HybridData
|
|
55
|
+
}
|
|
56
|
+
override fun createCxxPart(): CxxPart {
|
|
57
|
+
return CxxPart(this)
|
|
58
|
+
}
|
|
61
59
|
|
|
62
60
|
companion object {
|
|
63
61
|
protected const val TAG = "HybridSkeletonSpec"
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/skeleton/views/HybridSkeletonManager.kt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonManager.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.skeleton.views
|
|
@@ -12,13 +12,20 @@ import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
|
12
12
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
13
|
import com.facebook.react.uimanager.StateWrapper
|
|
14
14
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
+
import com.margelo.nitro.R.id.associated_hybrid_view_tag
|
|
16
|
+
import com.margelo.nitro.views.RecyclableView
|
|
15
17
|
import com.margelo.nitro.skeleton.*
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Represents the React Native `ViewManager` for the "Skeleton" Nitro HybridView.
|
|
19
21
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
public class HybridSkeletonManager: SimpleViewManager<View>() {
|
|
23
|
+
init {
|
|
24
|
+
if (RecyclableView::class.java.isAssignableFrom(HybridSkeleton::class.java)) {
|
|
25
|
+
// Enable view recycling
|
|
26
|
+
super.setupViewRecycling()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
override fun getName(): String {
|
|
24
31
|
return "Skeleton"
|
|
@@ -27,17 +34,13 @@ open class HybridSkeletonManager: SimpleViewManager<View>() {
|
|
|
27
34
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
35
|
val hybridView = HybridSkeleton(reactContext)
|
|
29
36
|
val view = hybridView.view
|
|
30
|
-
|
|
37
|
+
view.setTag(associated_hybrid_view_tag, hybridView)
|
|
31
38
|
return view
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
override fun onDropViewInstance(view: View) {
|
|
35
|
-
super.onDropViewInstance(view)
|
|
36
|
-
views.remove(view)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
41
|
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
-
val hybridView =
|
|
42
|
+
val hybridView = getHybridView(view)
|
|
43
|
+
?: throw Error("Couldn't find view $view in local views table!")
|
|
41
44
|
|
|
42
45
|
// 1. Update each prop individually
|
|
43
46
|
hybridView.beforeUpdate()
|
|
@@ -47,4 +50,31 @@ open class HybridSkeletonManager: SimpleViewManager<View>() {
|
|
|
47
50
|
// 2. Continue in base View props
|
|
48
51
|
return super.updateState(view, props, stateWrapper)
|
|
49
52
|
}
|
|
53
|
+
|
|
54
|
+
override fun onDropViewInstance(view: View) {
|
|
55
|
+
val hybridView = getHybridView(view)
|
|
56
|
+
hybridView?.onDropView()
|
|
57
|
+
return super.onDropViewInstance(view)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
|
|
61
|
+
super.prepareToRecycleView(reactContext, view)
|
|
62
|
+
val hybridView = getHybridView(view)
|
|
63
|
+
?: return null
|
|
64
|
+
|
|
65
|
+
@Suppress("USELESS_IS_CHECK")
|
|
66
|
+
if (hybridView is RecyclableView) {
|
|
67
|
+
// Recycle in it's implementation
|
|
68
|
+
hybridView.prepareForRecycle()
|
|
69
|
+
|
|
70
|
+
// Maybe update the view if it changed
|
|
71
|
+
return hybridView.view
|
|
72
|
+
} else {
|
|
73
|
+
return null
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private fun getHybridView(view: View): HybridSkeleton? {
|
|
78
|
+
return view.getTag(associated_hybrid_view_tag) as? HybridSkeleton
|
|
79
|
+
}
|
|
50
80
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonStateUpdater.kt
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
package com.margelo.nitro.skeleton.views
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# skeleton+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// skeleton+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// skeletonOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_SKELETON_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -22,25 +22,35 @@
|
|
|
22
22
|
namespace margelo::nitro::skeleton {
|
|
23
23
|
|
|
24
24
|
int initialize(JavaVM* vm) {
|
|
25
|
+
return facebook::jni::initialize(vm, []() {
|
|
26
|
+
::margelo::nitro::skeleton::registerAllNatives();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
struct JHybridSkeletonSpecImpl: public jni::JavaClass<JHybridSkeletonSpecImpl, JHybridSkeletonSpec::JavaPart> {
|
|
31
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/skeleton/HybridSkeleton;";
|
|
32
|
+
static std::shared_ptr<JHybridSkeletonSpec> create() {
|
|
33
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridSkeletonSpecImpl::javaobject()>();
|
|
34
|
+
jni::local_ref<JHybridSkeletonSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
35
|
+
return javaPart->getJHybridSkeletonSpec();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
void registerAllNatives() {
|
|
25
40
|
using namespace margelo::nitro;
|
|
26
41
|
using namespace margelo::nitro::skeleton;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
auto instance = object.create();
|
|
40
|
-
return instance->cthis()->shared();
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
});
|
|
42
|
+
|
|
43
|
+
// Register native JNI methods
|
|
44
|
+
margelo::nitro::skeleton::JHybridSkeletonSpec::CxxPart::registerNatives();
|
|
45
|
+
margelo::nitro::skeleton::views::JHybridSkeletonStateUpdater::registerNatives();
|
|
46
|
+
|
|
47
|
+
// Register Nitro Hybrid Objects
|
|
48
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
49
|
+
"Skeleton",
|
|
50
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
51
|
+
return JHybridSkeletonSpecImpl::create();
|
|
52
|
+
}
|
|
53
|
+
);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
} // namespace margelo::nitro::skeleton
|
|
@@ -2,24 +2,33 @@
|
|
|
2
2
|
/// skeletonOnLoad.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
9
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::skeleton {
|
|
12
13
|
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`)
|
|
18
|
+
* Register the native (C++) part of skeleton, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
16
21
|
* Example:
|
|
17
22
|
* ```cpp (cpp-adapter.cpp)
|
|
18
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all skeleton HybridObjects
|
|
26
|
+
* margelo::nitro::skeleton::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
20
29
|
* }
|
|
21
30
|
* ```
|
|
22
31
|
*/
|
|
23
|
-
|
|
32
|
+
void registerAllNatives();
|
|
24
33
|
|
|
25
34
|
} // namespace margelo::nitro::skeleton
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Skeleton+autolinking.rb
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a Ruby script that adds all files generated by Nitrogen
|
|
@@ -52,7 +52,7 @@ def add_nitrogen_files(spec)
|
|
|
52
52
|
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
53
|
# Use C++ 20
|
|
54
54
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
-
# Enables C++ <-> Swift interop (by default it's only
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// Skeleton-Swift-Cxx-Bridge.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "Skeleton-Swift-Cxx-Bridge.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// Skeleton-Swift-Cxx-Bridge.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -40,7 +40,7 @@ namespace margelo::nitro::skeleton::bridge::swift {
|
|
|
40
40
|
return optional.has_value();
|
|
41
41
|
}
|
|
42
42
|
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
43
|
-
return
|
|
43
|
+
return optional.value();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// pragma MARK: std::vector<std::string>
|
|
@@ -66,7 +66,7 @@ namespace margelo::nitro::skeleton::bridge::swift {
|
|
|
66
66
|
return optional.has_value();
|
|
67
67
|
}
|
|
68
68
|
inline std::vector<std::string> get_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
|
|
69
|
-
return
|
|
69
|
+
return optional.value();
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// pragma MARK: std::shared_ptr<HybridSkeletonSpec>
|
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
/// SkeletonAutolinking.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
8
12
|
public final class SkeletonAutolinking {
|
|
9
13
|
public typealias bridge = margelo.nitro.skeleton.bridge.swift
|
|
10
14
|
|
|
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
15
|
public static func createSkeleton() -> bridge.std__shared_ptr_HybridSkeletonSpec_ {
|
|
19
16
|
let hybridObject = HybridSkeleton()
|
|
20
17
|
return { () -> bridge.std__shared_ptr_HybridSkeletonSpec_ in
|
|
@@ -22,4 +19,8 @@ public final class SkeletonAutolinking {
|
|
|
22
19
|
return __cxxWrapped.getCxxPart()
|
|
23
20
|
}()
|
|
24
21
|
}
|
|
22
|
+
|
|
23
|
+
public static func isSkeletonRecyclable() -> Bool {
|
|
24
|
+
return HybridSkeleton.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
25
26
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonSpecSwift.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridSkeletonSpecSwift.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonSpecSwift.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -49,6 +49,12 @@ namespace margelo::nitro::skeleton {
|
|
|
49
49
|
inline size_t getExternalMemorySize() noexcept override {
|
|
50
50
|
return _swiftPart.getMemorySize();
|
|
51
51
|
}
|
|
52
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
53
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridSkeletonSpecSwift>(other)) {
|
|
54
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
52
58
|
void dispose() noexcept override {
|
|
53
59
|
_swiftPart.dispose();
|
|
54
60
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonComponent.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#import "HybridSkeletonComponent.hpp"
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
#import "HybridSkeletonSpecSwift.hpp"
|
|
18
18
|
#import "Skeleton-Swift-Cxx-Umbrella.hpp"
|
|
19
19
|
|
|
20
|
+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
|
|
21
|
+
#include <cxxreact/ReactNativeVersion.h>
|
|
22
|
+
#if REACT_NATIVE_VERSION_MINOR >= 82
|
|
23
|
+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
20
27
|
using namespace facebook;
|
|
21
28
|
using namespace margelo::nitro::skeleton;
|
|
22
29
|
using namespace margelo::nitro::skeleton::views;
|
|
@@ -25,6 +32,7 @@ using namespace margelo::nitro::skeleton::views;
|
|
|
25
32
|
* Represents the React Native View holder for the Nitro "Skeleton" HybridView.
|
|
26
33
|
*/
|
|
27
34
|
@interface HybridSkeletonComponent: RCTViewComponentView
|
|
35
|
+
+ (BOOL)shouldBeRecycled;
|
|
28
36
|
@end
|
|
29
37
|
|
|
30
38
|
@implementation HybridSkeletonComponent {
|
|
@@ -98,4 +106,22 @@ using namespace margelo::nitro::skeleton::views;
|
|
|
98
106
|
[super updateProps:props oldProps:oldProps];
|
|
99
107
|
}
|
|
100
108
|
|
|
109
|
+
+ (BOOL)shouldBeRecycled {
|
|
110
|
+
return Skeleton::SkeletonAutolinking::isSkeletonRecyclable();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (void)prepareForRecycle {
|
|
114
|
+
[super prepareForRecycle];
|
|
115
|
+
Skeleton::HybridSkeletonSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
116
|
+
swiftPart.maybePrepareForRecycle();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
120
|
+
- (void)invalidate {
|
|
121
|
+
Skeleton::HybridSkeletonSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
122
|
+
swiftPart.onDropView();
|
|
123
|
+
[super invalidate];
|
|
124
|
+
}
|
|
125
|
+
#endif
|
|
126
|
+
|
|
101
127
|
@end
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
/// HybridSkeletonSpec.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/// See ``HybridSkeletonSpec``
|
|
@@ -31,14 +30,14 @@ open class HybridSkeletonSpec_base {
|
|
|
31
30
|
public init() { }
|
|
32
31
|
public func getCxxWrapper() -> HybridSkeletonSpec_cxx {
|
|
33
32
|
#if DEBUG
|
|
34
|
-
guard self is HybridSkeletonSpec else {
|
|
33
|
+
guard self is any HybridSkeletonSpec else {
|
|
35
34
|
fatalError("`self` is not a `HybridSkeletonSpec`! Did you accidentally inherit from `HybridSkeletonSpec_base` instead of `HybridSkeletonSpec`?")
|
|
36
35
|
}
|
|
37
36
|
#endif
|
|
38
37
|
if let cxxWrapper = self.cxxWrapper {
|
|
39
38
|
return cxxWrapper
|
|
40
39
|
} else {
|
|
41
|
-
let cxxWrapper = HybridSkeletonSpec_cxx(self as! HybridSkeletonSpec)
|
|
40
|
+
let cxxWrapper = HybridSkeletonSpec_cxx(self as! any HybridSkeletonSpec)
|
|
42
41
|
self.cxxWrapper = cxxWrapper
|
|
43
42
|
return cxxWrapper
|
|
44
43
|
}
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
/// HybridSkeletonSpec_cxx.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -96,6 +95,14 @@ open class HybridSkeletonSpec_cxx {
|
|
|
96
95
|
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridSkeletonSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
/**
|
|
100
107
|
* Call dispose() on the Swift class.
|
|
101
108
|
* This _may_ be called manually from JS.
|
|
@@ -127,7 +134,14 @@ open class HybridSkeletonSpec_cxx {
|
|
|
127
134
|
}
|
|
128
135
|
@inline(__always)
|
|
129
136
|
set {
|
|
130
|
-
self.__implementation.shimmerSpeed =
|
|
137
|
+
self.__implementation.shimmerSpeed = { () -> Double? in
|
|
138
|
+
if bridge.has_value_std__optional_double_(newValue) {
|
|
139
|
+
let __unwrapped = bridge.get_std__optional_double_(newValue)
|
|
140
|
+
return __unwrapped
|
|
141
|
+
} else {
|
|
142
|
+
return nil
|
|
143
|
+
}
|
|
144
|
+
}()
|
|
131
145
|
}
|
|
132
146
|
}
|
|
133
147
|
|
|
@@ -173,4 +187,13 @@ open class HybridSkeletonSpec_cxx {
|
|
|
173
187
|
public final func afterUpdate() {
|
|
174
188
|
__implementation.afterUpdate()
|
|
175
189
|
}
|
|
190
|
+
|
|
191
|
+
public final func maybePrepareForRecycle() {
|
|
192
|
+
guard let recyclable = __implementation as? any RecyclableView else { return }
|
|
193
|
+
recyclable.prepareForRecycle()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public final func onDropView() {
|
|
197
|
+
__implementation.onDropView()
|
|
198
|
+
}
|
|
176
199
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridSkeletonComponent.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridSkeletonComponent.hpp"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <utility>
|
|
13
13
|
#include <NitroModules/NitroDefines.hpp>
|
|
14
14
|
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
15
16
|
#include <react/renderer/core/RawValue.h>
|
|
16
17
|
#include <react/renderer/core/ShadowNode.h>
|
|
17
18
|
#include <react/renderer/core/ComponentDescriptor.h>
|
|
@@ -50,18 +51,12 @@ namespace margelo::nitro::skeleton::views {
|
|
|
50
51
|
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
51
52
|
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
52
53
|
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
|
+
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSkeletonSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
54
55
|
} catch (const std::exception& exc) {
|
|
55
56
|
throw std::runtime_error(std::string("Skeleton.hybridRef: ") + exc.what());
|
|
56
57
|
}
|
|
57
58
|
}()) { }
|
|
58
59
|
|
|
59
|
-
HybridSkeletonProps::HybridSkeletonProps(const HybridSkeletonProps& other):
|
|
60
|
-
react::ViewProps(),
|
|
61
|
-
shimmerSpeed(other.shimmerSpeed),
|
|
62
|
-
shimmerGradientColors(other.shimmerGradientColors),
|
|
63
|
-
hybridRef(other.hybridRef) { }
|
|
64
|
-
|
|
65
60
|
bool HybridSkeletonProps::filterObjectKeys(const std::string& propName) {
|
|
66
61
|
switch (hashString(propName)) {
|
|
67
62
|
case hashString("shimmerSpeed"): return true;
|
|
@@ -88,10 +83,10 @@ namespace margelo::nitro::skeleton::views {
|
|
|
88
83
|
void HybridSkeletonComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
89
84
|
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
90
85
|
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
91
|
-
auto& concreteShadowNode =
|
|
92
|
-
const HybridSkeletonProps
|
|
93
|
-
|
|
94
|
-
state
|
|
86
|
+
auto& concreteShadowNode = static_cast<HybridSkeletonShadowNode&>(shadowNode);
|
|
87
|
+
const std::shared_ptr<const HybridSkeletonProps>& constProps = concreteShadowNode.getConcreteSharedProps();
|
|
88
|
+
const std::shared_ptr<HybridSkeletonProps>& props = std::const_pointer_cast<HybridSkeletonProps>(constProps);
|
|
89
|
+
HybridSkeletonState state{props};
|
|
95
90
|
concreteShadowNode.setStateData(std::move(state));
|
|
96
91
|
}
|
|
97
92
|
#endif
|