@leonsilicon/react-native-wishlist 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/MGWishList.podspec +40 -0
- package/README.md +281 -0
- package/android/CMakeLists.txt +86 -0
- package/android/build.gradle +72 -0
- package/android/gradle.properties +5 -0
- package/android/spotless.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/wishlist/ContentContainer.kt +22 -0
- package/android/src/main/java/com/wishlist/Orchestrator.kt +38 -0
- package/android/src/main/java/com/wishlist/TemplateContainer.kt +30 -0
- package/android/src/main/java/com/wishlist/TemplateContainerViewManager.kt +65 -0
- package/android/src/main/java/com/wishlist/TemplateInterceptor.kt +29 -0
- package/android/src/main/java/com/wishlist/TemplateInterceptorViewManager.kt +23 -0
- package/android/src/main/java/com/wishlist/UIScheduler.kt +15 -0
- package/android/src/main/java/com/wishlist/Wishlist.kt +135 -0
- package/android/src/main/java/com/wishlist/WishlistManagerModule.kt +51 -0
- package/android/src/main/java/com/wishlist/WishlistPackage.kt +47 -0
- package/android/src/main/java/com/wishlist/WishlistSoLoader.kt +17 -0
- package/android/src/main/java/com/wishlist/WishlistViewManager.kt +69 -0
- package/android/src/main/jni/ErrorHandlerAndroid.cpp +16 -0
- package/android/src/main/jni/ErrorHandlerAndroid.h +13 -0
- package/android/src/main/jni/JNIStateRegistry.cpp +22 -0
- package/android/src/main/jni/JNIStateRegistry.h +23 -0
- package/android/src/main/jni/OnLoad.cpp +12 -0
- package/android/src/main/jni/Orchestrator.cpp +167 -0
- package/android/src/main/jni/Orchestrator.hpp +78 -0
- package/android/src/main/jni/UISchedulerAndroid.cpp +20 -0
- package/android/src/main/jni/UISchedulerAndroid.h +18 -0
- package/android/src/main/jni/WishlistManagerModule.cpp +91 -0
- package/android/src/main/jni/WishlistManagerModule.hpp +43 -0
- package/android/src/main/jni/wishlist.h +19 -0
- package/cpp/ContentContainer/MGContentContainerComponentDescriptor.h +40 -0
- package/cpp/ContentContainer/MGContentContainerShadowNode.cpp +21 -0
- package/cpp/ContentContainer/MGContentContainerShadowNode.h +30 -0
- package/cpp/ContentContainer/MGContentContainerState.cpp +31 -0
- package/cpp/ContentContainer/MGContentContainerState.h +39 -0
- package/cpp/DataBinding/MGBindingProvider.hpp +21 -0
- package/cpp/DataBinding/MGDataBinding.hpp +23 -0
- package/cpp/DataBinding/MGDataBindingImpl.cpp +112 -0
- package/cpp/DataBinding/MGDataBindingImpl.hpp +35 -0
- package/cpp/DependencyInjection/MGDI.hpp +33 -0
- package/cpp/DependencyInjection/MGDIImpl.cpp +65 -0
- package/cpp/DependencyInjection/MGDIImpl.hpp +45 -0
- package/cpp/DependencyInjection/MGUIManagerHolder.cpp +21 -0
- package/cpp/DependencyInjection/MGUIManagerHolder.h +24 -0
- package/cpp/ItemProvider/ComponentsPool.cpp +91 -0
- package/cpp/ItemProvider/ComponentsPool.h +49 -0
- package/cpp/ItemProvider/ItemProvider.cpp +60 -0
- package/cpp/ItemProvider/ItemProvider.h +67 -0
- package/cpp/ItemProvider/ShadowNodeBinding.cpp +356 -0
- package/cpp/ItemProvider/ShadowNodeBinding.h +59 -0
- package/cpp/ItemProvider/ShadowNodeCopyMachine.cpp +95 -0
- package/cpp/ItemProvider/ShadowNodeCopyMachine.h +25 -0
- package/cpp/MGErrorHandler.h +12 -0
- package/cpp/MGViewportCarer/MGVSyncRequester.hpp +18 -0
- package/cpp/MGViewportCarer/MGViewportCarer.hpp +42 -0
- package/cpp/MGViewportCarer/MGViewportCarerImpl.cpp +453 -0
- package/cpp/MGViewportCarer/MGViewportCarerImpl.h +80 -0
- package/cpp/MGViewportCarer/MGViewportCarerListener.hpp +27 -0
- package/cpp/TemplateContainer/MGTemplateContainerComponentDescriptor.h +15 -0
- package/cpp/TemplateContainer/MGTemplateContainerShadowNode.cpp +43 -0
- package/cpp/TemplateContainer/MGTemplateContainerShadowNode.h +42 -0
- package/cpp/TemplateContainer/MGTemplateContainerState.cpp +37 -0
- package/cpp/TemplateContainer/MGTemplateContainerState.h +39 -0
- package/cpp/UIScheduler/MGUIScheduler.cpp +8 -0
- package/cpp/UIScheduler/MGUIScheduler.hpp +18 -0
- package/cpp/Wishlist/MGWishlistComponentDescriptor.h +14 -0
- package/cpp/Wishlist/MGWishlistShadowNode.cpp +49 -0
- package/cpp/Wishlist/MGWishlistShadowNode.h +37 -0
- package/cpp/Wishlist/MGWishlistState.cpp +57 -0
- package/cpp/Wishlist/MGWishlistState.h +42 -0
- package/cpp/WishlistDefine.h +3 -0
- package/cpp/WishlistJsRuntime.cpp +139 -0
- package/cpp/WishlistJsRuntime.h +59 -0
- package/ios/MGContentContainerComponent.h +9 -0
- package/ios/MGContentContainerComponent.mm +34 -0
- package/ios/MGErrorHandlerIOS.h +13 -0
- package/ios/MGErrorHandlerIOS.mm +12 -0
- package/ios/MGObjCJSIUtils.h +63 -0
- package/ios/MGTemplateContainerComponent.h +12 -0
- package/ios/MGTemplateContainerComponent.mm +105 -0
- package/ios/MGTemplateInterceptorComponent.h +9 -0
- package/ios/MGTemplateInterceptorComponent.mm +72 -0
- package/ios/MGWishListComponent.h +17 -0
- package/ios/MGWishListComponent.mm +187 -0
- package/ios/MGWishlistManager.h +21 -0
- package/ios/MGWishlistManager.mm +319 -0
- package/ios/MGWishlistQueue.h +11 -0
- package/ios/MGWishlistQueue.m +34 -0
- package/ios/Orchestrator/MGOrchestrator.h +35 -0
- package/ios/Orchestrator/MGOrchestrator.mm +139 -0
- package/ios/Orchestrator/MGOrchestratorCppAdapter.cpp +25 -0
- package/ios/Orchestrator/MGOrchestratorCppAdapter.hpp +32 -0
- package/ios/UIScheduleriOS/MGUIScheduleriOS.hpp +19 -0
- package/ios/UIScheduleriOS/MGUIScheduleriOS.mm +21 -0
- package/lib/commonjs/Colors.js +399 -0
- package/lib/commonjs/Colors.js.map +1 -0
- package/lib/commonjs/ComponentPool.js +28 -0
- package/lib/commonjs/ComponentPool.js.map +1 -0
- package/lib/commonjs/Components/ForEach.js +21 -0
- package/lib/commonjs/Components/ForEach.js.map +1 -0
- package/lib/commonjs/Components/ForEachBase.js +19 -0
- package/lib/commonjs/Components/ForEachBase.js.map +1 -0
- package/lib/commonjs/Components/IF.js +34 -0
- package/lib/commonjs/Components/IF.js.map +1 -0
- package/lib/commonjs/Components/Pressable.js +73 -0
- package/lib/commonjs/Components/Pressable.js.map +1 -0
- package/lib/commonjs/Components/Switch.js +52 -0
- package/lib/commonjs/Components/Switch.js.map +1 -0
- package/lib/commonjs/Components/WishlistImage.js +29 -0
- package/lib/commonjs/Components/WishlistImage.js.map +1 -0
- package/lib/commonjs/Components/WishlistText.js +24 -0
- package/lib/commonjs/Components/WishlistText.js.map +1 -0
- package/lib/commonjs/Components/WishlistView.js +10 -0
- package/lib/commonjs/Components/WishlistView.js.map +1 -0
- package/lib/commonjs/EventHandler.js +72 -0
- package/lib/commonjs/EventHandler.js.map +1 -0
- package/lib/commonjs/InflatorRepository.js +155 -0
- package/lib/commonjs/InflatorRepository.js.map +1 -0
- package/lib/commonjs/OrchestratorBinding.js +12 -0
- package/lib/commonjs/OrchestratorBinding.js.map +1 -0
- package/lib/commonjs/Specs/NativeContentContainer.js +12 -0
- package/lib/commonjs/Specs/NativeContentContainer.js.map +1 -0
- package/lib/commonjs/Specs/NativeTemplateContainer.js +12 -0
- package/lib/commonjs/Specs/NativeTemplateContainer.js.map +1 -0
- package/lib/commonjs/Specs/NativeTemplateInterceptor.js +10 -0
- package/lib/commonjs/Specs/NativeTemplateInterceptor.js.map +1 -0
- package/lib/commonjs/Specs/NativeWishlist.js +16 -0
- package/lib/commonjs/Specs/NativeWishlist.js.map +1 -0
- package/lib/commonjs/Specs/NativeWishlistManager.js +9 -0
- package/lib/commonjs/Specs/NativeWishlistManager.js.map +1 -0
- package/lib/commonjs/TemplateContext.js +17 -0
- package/lib/commonjs/TemplateContext.js.map +1 -0
- package/lib/commonjs/TemplateItem.js +2 -0
- package/lib/commonjs/TemplateItem.js.map +1 -0
- package/lib/commonjs/TemplateValue.js +68 -0
- package/lib/commonjs/TemplateValue.js.map +1 -0
- package/lib/commonjs/Utils.js +20 -0
- package/lib/commonjs/Utils.js.map +1 -0
- package/lib/commonjs/Wishlist.js +290 -0
- package/lib/commonjs/Wishlist.js.map +1 -0
- package/lib/commonjs/WishlistContext.js +17 -0
- package/lib/commonjs/WishlistContext.js.map +1 -0
- package/lib/commonjs/WishlistData.js +149 -0
- package/lib/commonjs/WishlistData.js.map +1 -0
- package/lib/commonjs/WishlistDataCopy.js +115 -0
- package/lib/commonjs/WishlistDataCopy.js.map +1 -0
- package/lib/commonjs/WishlistJsRuntime.android.js +22 -0
- package/lib/commonjs/WishlistJsRuntime.android.js.map +1 -0
- package/lib/commonjs/WishlistJsRuntime.js +42 -0
- package/lib/commonjs/WishlistJsRuntime.js.map +1 -0
- package/lib/commonjs/createTemplateComponent.js +196 -0
- package/lib/commonjs/createTemplateComponent.js.map +1 -0
- package/lib/commonjs/global.d.js +2 -0
- package/lib/commonjs/global.d.js.map +1 -0
- package/lib/commonjs/index.js +83 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/renderTemplate.js +14 -0
- package/lib/commonjs/renderTemplate.js.map +1 -0
- package/lib/module/Colors.js +395 -0
- package/lib/module/Colors.js.map +1 -0
- package/lib/module/ComponentPool.js +24 -0
- package/lib/module/ComponentPool.js.map +1 -0
- package/lib/module/Components/ForEach.js +17 -0
- package/lib/module/Components/ForEach.js.map +1 -0
- package/lib/module/Components/ForEachBase.js +14 -0
- package/lib/module/Components/ForEachBase.js.map +1 -0
- package/lib/module/Components/IF.js +29 -0
- package/lib/module/Components/IF.js.map +1 -0
- package/lib/module/Components/Pressable.js +68 -0
- package/lib/module/Components/Pressable.js.map +1 -0
- package/lib/module/Components/Switch.js +45 -0
- package/lib/module/Components/Switch.js.map +1 -0
- package/lib/module/Components/WishlistImage.js +25 -0
- package/lib/module/Components/WishlistImage.js.map +1 -0
- package/lib/module/Components/WishlistText.js +20 -0
- package/lib/module/Components/WishlistText.js.map +1 -0
- package/lib/module/Components/WishlistView.js +6 -0
- package/lib/module/Components/WishlistView.js.map +1 -0
- package/lib/module/EventHandler.js +66 -0
- package/lib/module/EventHandler.js.map +1 -0
- package/lib/module/InflatorRepository.js +149 -0
- package/lib/module/InflatorRepository.js.map +1 -0
- package/lib/module/OrchestratorBinding.js +8 -0
- package/lib/module/OrchestratorBinding.js.map +1 -0
- package/lib/module/Specs/NativeContentContainer.js +7 -0
- package/lib/module/Specs/NativeContentContainer.js.map +1 -0
- package/lib/module/Specs/NativeTemplateContainer.js +7 -0
- package/lib/module/Specs/NativeTemplateContainer.js.map +1 -0
- package/lib/module/Specs/NativeTemplateInterceptor.js +5 -0
- package/lib/module/Specs/NativeTemplateInterceptor.js.map +1 -0
- package/lib/module/Specs/NativeWishlist.js +11 -0
- package/lib/module/Specs/NativeWishlist.js.map +1 -0
- package/lib/module/Specs/NativeWishlistManager.js +5 -0
- package/lib/module/Specs/NativeWishlistManager.js.map +1 -0
- package/lib/module/TemplateContext.js +12 -0
- package/lib/module/TemplateContext.js.map +1 -0
- package/lib/module/TemplateItem.js +2 -0
- package/lib/module/TemplateItem.js.map +1 -0
- package/lib/module/TemplateValue.js +63 -0
- package/lib/module/TemplateValue.js.map +1 -0
- package/lib/module/Utils.js +15 -0
- package/lib/module/Utils.js.map +1 -0
- package/lib/module/Wishlist.js +284 -0
- package/lib/module/Wishlist.js.map +1 -0
- package/lib/module/WishlistContext.js +12 -0
- package/lib/module/WishlistContext.js.map +1 -0
- package/lib/module/WishlistData.js +144 -0
- package/lib/module/WishlistData.js.map +1 -0
- package/lib/module/WishlistDataCopy.js +111 -0
- package/lib/module/WishlistDataCopy.js.map +1 -0
- package/lib/module/WishlistJsRuntime.android.js +16 -0
- package/lib/module/WishlistJsRuntime.android.js.map +1 -0
- package/lib/module/WishlistJsRuntime.js +35 -0
- package/lib/module/WishlistJsRuntime.js.map +1 -0
- package/lib/module/createTemplateComponent.js +191 -0
- package/lib/module/createTemplateComponent.js.map +1 -0
- package/lib/module/global.d.js +2 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/renderTemplate.js +10 -0
- package/lib/module/renderTemplate.js.map +1 -0
- package/lib/typescript/Colors.d.ts +7 -0
- package/lib/typescript/Colors.d.ts.map +1 -0
- package/lib/typescript/ComponentPool.d.ts +10 -0
- package/lib/typescript/ComponentPool.d.ts.map +1 -0
- package/lib/typescript/Components/ForEach.d.ts +2 -0
- package/lib/typescript/Components/ForEach.d.ts.map +1 -0
- package/lib/typescript/Components/ForEachBase.d.ts +3 -0
- package/lib/typescript/Components/ForEachBase.d.ts.map +1 -0
- package/lib/typescript/Components/IF.d.ts +3 -0
- package/lib/typescript/Components/IF.d.ts.map +1 -0
- package/lib/typescript/Components/Pressable.d.ts +15 -0
- package/lib/typescript/Components/Pressable.d.ts.map +1 -0
- package/lib/typescript/Components/Switch.d.ts +17 -0
- package/lib/typescript/Components/Switch.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistImage.d.ts +3 -0
- package/lib/typescript/Components/WishlistImage.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistText.d.ts +3 -0
- package/lib/typescript/Components/WishlistText.d.ts.map +1 -0
- package/lib/typescript/Components/WishlistView.d.ts +3 -0
- package/lib/typescript/Components/WishlistView.d.ts.map +1 -0
- package/lib/typescript/EventHandler.d.ts +9 -0
- package/lib/typescript/EventHandler.d.ts.map +1 -0
- package/lib/typescript/InflatorRepository.d.ts +28 -0
- package/lib/typescript/InflatorRepository.d.ts.map +1 -0
- package/lib/typescript/OrchestratorBinding.d.ts +13 -0
- package/lib/typescript/OrchestratorBinding.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeContentContainer.d.ts +6 -0
- package/lib/typescript/Specs/NativeContentContainer.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeTemplateContainer.d.ts +9 -0
- package/lib/typescript/Specs/NativeTemplateContainer.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeTemplateInterceptor.d.ts +6 -0
- package/lib/typescript/Specs/NativeTemplateInterceptor.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeWishlist.d.ts +22 -0
- package/lib/typescript/Specs/NativeWishlist.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeWishlistManager.d.ts +7 -0
- package/lib/typescript/Specs/NativeWishlistManager.d.ts.map +1 -0
- package/lib/typescript/TemplateContext.d.ts +9 -0
- package/lib/typescript/TemplateContext.d.ts.map +1 -0
- package/lib/typescript/TemplateItem.d.ts +13 -0
- package/lib/typescript/TemplateItem.d.ts.map +1 -0
- package/lib/typescript/TemplateValue.d.ts +16 -0
- package/lib/typescript/TemplateValue.d.ts.map +1 -0
- package/lib/typescript/Utils.d.ts +3 -0
- package/lib/typescript/Utils.d.ts.map +1 -0
- package/lib/typescript/Wishlist.d.ts +59 -0
- package/lib/typescript/Wishlist.d.ts.map +1 -0
- package/lib/typescript/WishlistContext.d.ts +11 -0
- package/lib/typescript/WishlistContext.d.ts.map +1 -0
- package/lib/typescript/WishlistData.d.ts +20 -0
- package/lib/typescript/WishlistData.d.ts.map +1 -0
- package/lib/typescript/WishlistDataCopy.d.ts +25 -0
- package/lib/typescript/WishlistDataCopy.d.ts.map +1 -0
- package/lib/typescript/WishlistJsRuntime.android.d.ts +4 -0
- package/lib/typescript/WishlistJsRuntime.android.d.ts.map +1 -0
- package/lib/typescript/WishlistJsRuntime.d.ts +6 -0
- package/lib/typescript/WishlistJsRuntime.d.ts.map +1 -0
- package/lib/typescript/createTemplateComponent.d.ts +35 -0
- package/lib/typescript/createTemplateComponent.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/renderTemplate.d.ts +3 -0
- package/lib/typescript/renderTemplate.d.ts.map +1 -0
- package/package.json +195 -0
- package/src/Colors.ts +474 -0
- package/src/ComponentPool.ts +33 -0
- package/src/Components/ForEach.tsx +22 -0
- package/src/Components/ForEachBase.tsx +8 -0
- package/src/Components/IF.tsx +20 -0
- package/src/Components/Pressable.tsx +111 -0
- package/src/Components/Switch.tsx +49 -0
- package/src/Components/WishlistImage.tsx +25 -0
- package/src/Components/WishlistText.tsx +14 -0
- package/src/Components/WishlistView.tsx +4 -0
- package/src/EventHandler.ts +78 -0
- package/src/InflatorRepository.ts +231 -0
- package/src/OrchestratorBinding.ts +15 -0
- package/src/Specs/NativeContentContainer.ts +9 -0
- package/src/Specs/NativeTemplateContainer.ts +13 -0
- package/src/Specs/NativeTemplateInterceptor.ts +8 -0
- package/src/Specs/NativeWishlist.ts +42 -0
- package/src/Specs/NativeWishlistManager.ts +7 -0
- package/src/TemplateContext.tsx +14 -0
- package/src/TemplateItem.ts +15 -0
- package/src/TemplateValue.tsx +101 -0
- package/src/Utils.ts +15 -0
- package/src/Wishlist.tsx +417 -0
- package/src/WishlistContext.tsx +15 -0
- package/src/WishlistData.ts +179 -0
- package/src/WishlistDataCopy.ts +138 -0
- package/src/WishlistJsRuntime.android.ts +20 -0
- package/src/WishlistJsRuntime.ts +59 -0
- package/src/createTemplateComponent.tsx +263 -0
- package/src/global.d.ts +1 -0
- package/src/index.ts +17 -0
- package/src/renderTemplate.ts +22 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MGDIImpl.cpp
|
|
3
|
+
// MGWishList
|
|
4
|
+
//
|
|
5
|
+
// Created by Szymon on 13/01/2023.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#include "MGDIImpl.hpp"
|
|
9
|
+
|
|
10
|
+
#include <iostream>
|
|
11
|
+
|
|
12
|
+
namespace Wishlist {
|
|
13
|
+
|
|
14
|
+
std::shared_ptr<MGDataBinding> MGDIImpl::getDataBinding() {
|
|
15
|
+
return dataBinding_;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
std::shared_ptr<MGVSyncRequester> MGDIImpl::getVSyncRequester() {
|
|
19
|
+
return vSyncRequester_;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
std::shared_ptr<MGViewportCarer> MGDIImpl::getViewportCarer() {
|
|
23
|
+
return viewportCarer_;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
std::shared_ptr<MGUIScheduler> MGDIImpl::getUIScheduler() {
|
|
27
|
+
return uiScheduler_;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<MGErrorHandler> MGDIImpl::getErrorHandler() {
|
|
31
|
+
return errorHandler_;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void MGDIImpl::setDataBinding(const std::shared_ptr<MGDataBinding> &db) {
|
|
35
|
+
dataBinding_ = db;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void MGDIImpl::setVSyncRequester(const std::shared_ptr<MGVSyncRequester> &vr) {
|
|
39
|
+
vSyncRequester_ = vr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void MGDIImpl::setPushChildrenListener(
|
|
43
|
+
const std::shared_ptr<MGViewportCarerListener> &pcl) {
|
|
44
|
+
pushChildrenListener_ = pcl;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void MGDIImpl::setViewportCarer(const std::shared_ptr<MGViewportCarer> &vc) {
|
|
48
|
+
viewportCarer_ = vc;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void MGDIImpl::setUIScheduler(const std::shared_ptr<MGUIScheduler> &us) {
|
|
52
|
+
uiScheduler_ = us;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void MGDIImpl::setErrorHandler(const std::shared_ptr<MGErrorHandler> &eh) {
|
|
56
|
+
errorHandler_ = eh;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
std::weak_ptr<MGDI> MGDIImpl::getWeak() {
|
|
60
|
+
return weak_from_this();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
MGDIImpl::~MGDIImpl() {}
|
|
64
|
+
|
|
65
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MGDIImpl.hpp
|
|
3
|
+
// MGWishList
|
|
4
|
+
//
|
|
5
|
+
// Created by Szymon on 13/01/2023.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <stdio.h>
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include "MGDI.hpp"
|
|
13
|
+
|
|
14
|
+
namespace Wishlist {
|
|
15
|
+
|
|
16
|
+
class MGDIImpl : public MGDI, public std::enable_shared_from_this<MGDIImpl> {
|
|
17
|
+
public:
|
|
18
|
+
std::shared_ptr<MGDataBinding> getDataBinding() override;
|
|
19
|
+
std::shared_ptr<MGVSyncRequester> getVSyncRequester() override;
|
|
20
|
+
std::shared_ptr<MGViewportCarer> getViewportCarer() override;
|
|
21
|
+
std::shared_ptr<MGUIScheduler> getUIScheduler() override;
|
|
22
|
+
std::shared_ptr<MGErrorHandler> getErrorHandler() override;
|
|
23
|
+
|
|
24
|
+
void setDataBinding(const std::shared_ptr<MGDataBinding> &db);
|
|
25
|
+
void setVSyncRequester(const std::shared_ptr<MGVSyncRequester> &vr);
|
|
26
|
+
void setPushChildrenListener(
|
|
27
|
+
const std::shared_ptr<MGViewportCarerListener> &pcl);
|
|
28
|
+
void setViewportCarer(const std::shared_ptr<MGViewportCarer> &vc);
|
|
29
|
+
void setUIScheduler(const std::shared_ptr<MGUIScheduler> &us);
|
|
30
|
+
void setErrorHandler(const std::shared_ptr<MGErrorHandler> &eh);
|
|
31
|
+
|
|
32
|
+
std::weak_ptr<MGDI> getWeak();
|
|
33
|
+
|
|
34
|
+
virtual ~MGDIImpl();
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
std::shared_ptr<MGDataBinding> dataBinding_;
|
|
38
|
+
std::shared_ptr<MGVSyncRequester> vSyncRequester_;
|
|
39
|
+
std::shared_ptr<MGViewportCarerListener> pushChildrenListener_;
|
|
40
|
+
std::shared_ptr<MGViewportCarer> viewportCarer_;
|
|
41
|
+
std::shared_ptr<MGUIScheduler> uiScheduler_;
|
|
42
|
+
std::shared_ptr<MGErrorHandler> errorHandler_;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#include "MGUIManagerHolder.h"
|
|
2
|
+
|
|
3
|
+
namespace Wishlist {
|
|
4
|
+
|
|
5
|
+
MGUIManagerHolder &MGUIManagerHolder::getInstance() {
|
|
6
|
+
static MGUIManagerHolder instance;
|
|
7
|
+
return instance;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
MGUIManagerHolder::MGUIManagerHolder() : uiManager_(nullptr) {}
|
|
11
|
+
|
|
12
|
+
std::shared_ptr<UIManager> MGUIManagerHolder::getUIManager() const {
|
|
13
|
+
return uiManager_;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
void MGUIManagerHolder::setUIManager(
|
|
17
|
+
const std::shared_ptr<UIManager> &uiManager) {
|
|
18
|
+
uiManager_ = uiManager;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/uimanager/UIManager.h>
|
|
4
|
+
|
|
5
|
+
using namespace facebook::react;
|
|
6
|
+
|
|
7
|
+
namespace Wishlist {
|
|
8
|
+
|
|
9
|
+
class MGUIManagerHolder {
|
|
10
|
+
public:
|
|
11
|
+
static MGUIManagerHolder &getInstance();
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<UIManager> getUIManager() const;
|
|
14
|
+
void setUIManager(const std::shared_ptr<UIManager> &uiManager);
|
|
15
|
+
|
|
16
|
+
private:
|
|
17
|
+
MGUIManagerHolder();
|
|
18
|
+
MGUIManagerHolder(const MGUIManagerHolder &) = delete;
|
|
19
|
+
MGUIManagerHolder &operator=(const MGUIManagerHolder &) = delete;
|
|
20
|
+
|
|
21
|
+
std::shared_ptr<UIManager> uiManager_;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#include "ComponentsPool.h"
|
|
2
|
+
|
|
3
|
+
#include <iostream>
|
|
4
|
+
|
|
5
|
+
using namespace facebook::react;
|
|
6
|
+
using namespace jsi;
|
|
7
|
+
|
|
8
|
+
namespace Wishlist {
|
|
9
|
+
|
|
10
|
+
void ComponentsPool::setNames(const std::vector<std::string> &names) {
|
|
11
|
+
nameToIndex_.clear();
|
|
12
|
+
for (int i = 0; i < names.size(); ++i) {
|
|
13
|
+
nameToIndex_[names[i]] = i;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void ComponentsPool::setRegisteredViews(
|
|
18
|
+
std::vector<std::shared_ptr<ShadowNode const>> registeredViews) {
|
|
19
|
+
registeredViews_ = registeredViews;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void ComponentsPool::returnToPool(std::shared_ptr<ShadowNode const> sn) {
|
|
23
|
+
if (sn == nullptr) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
ShadowNodeCopyMachine::clearParent(sn);
|
|
27
|
+
std::string type = tagToType_[sn->getTag()];
|
|
28
|
+
reusable_[type].push_back(sn);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void ComponentsPool::templatesUpdated() {
|
|
32
|
+
// optimise by reusing some of elements if they are
|
|
33
|
+
// the same
|
|
34
|
+
tagToType_.clear();
|
|
35
|
+
reusable_.clear();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
std::shared_ptr<ShadowNode const> ComponentsPool::getNodeForType(const std::string &type) {
|
|
39
|
+
if (reusable_[type].size() > 0) {
|
|
40
|
+
auto res = reusable_[type].back();
|
|
41
|
+
reusable_[type].pop_back();
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
auto templateNode = registeredViews_[nameToIndex_[type]];
|
|
46
|
+
auto deepCopy = ShadowNodeCopyMachine::copyShadowSubtree(templateNode);
|
|
47
|
+
tagToType_[deepCopy->getTag()] = type;
|
|
48
|
+
return deepCopy;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
jsi::Object ComponentsPool::prepareProxy(jsi::Runtime &rt) {
|
|
52
|
+
if (proxy_ == nullptr) {
|
|
53
|
+
proxy_ = std::static_pointer_cast<jsi::HostObject>(
|
|
54
|
+
std::make_shared<ComponentsPool::Proxy>(shared_from_this()));
|
|
55
|
+
}
|
|
56
|
+
return jsi::Object::createFromHostObject(rt, proxy_);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ComponentsPool::Proxy::Proxy(std::weak_ptr<ComponentsPool> wcp) : wcp(wcp) {}
|
|
60
|
+
|
|
61
|
+
Value ComponentsPool::Proxy::get(Runtime &rt, const PropNameID &nameProp) {
|
|
62
|
+
std::string name = nameProp.utf8(rt);
|
|
63
|
+
|
|
64
|
+
if (name == "getComponent") {
|
|
65
|
+
std::weak_ptr<ComponentsPool> blockWcp = this->wcp;
|
|
66
|
+
return jsi::Function::createFromHostFunction(
|
|
67
|
+
rt,
|
|
68
|
+
nameProp,
|
|
69
|
+
1,
|
|
70
|
+
[blockWcp](
|
|
71
|
+
Runtime &rt, const Value &thisVal, const Value *args, size_t count)
|
|
72
|
+
-> Value {
|
|
73
|
+
std::string type = args[0].asString(rt).utf8(rt);
|
|
74
|
+
auto sn = blockWcp.lock()->getNodeForType(type);
|
|
75
|
+
|
|
76
|
+
return jsi::Object::createFromHostObject(
|
|
77
|
+
rt, std::make_shared<ShadowNodeBinding>(sn, blockWcp, type, ""));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return jsi::Value::undefined();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
void ComponentsPool::Proxy::set(
|
|
85
|
+
Runtime &rt,
|
|
86
|
+
const PropNameID &name,
|
|
87
|
+
const Value &value) {
|
|
88
|
+
throw jsi::JSError(rt, "set hasn't been implemented yet");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
#include "ShadowNodeBinding.h"
|
|
9
|
+
#include "ShadowNodeCopyMachine.h"
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react;
|
|
12
|
+
using namespace facebook::jsi;
|
|
13
|
+
|
|
14
|
+
namespace Wishlist {
|
|
15
|
+
|
|
16
|
+
class ComponentsPool : public std::enable_shared_from_this<ComponentsPool> {
|
|
17
|
+
public:
|
|
18
|
+
void setNames(const std::vector<std::string> &names);
|
|
19
|
+
|
|
20
|
+
void setRegisteredViews(std::vector<std::shared_ptr<ShadowNode const>> registeredViews);
|
|
21
|
+
|
|
22
|
+
void returnToPool(std::shared_ptr<ShadowNode const> sn);
|
|
23
|
+
|
|
24
|
+
void templatesUpdated();
|
|
25
|
+
|
|
26
|
+
std::shared_ptr<ShadowNode const> getNodeForType(const std::string &type);
|
|
27
|
+
|
|
28
|
+
Object prepareProxy(Runtime &rt);
|
|
29
|
+
|
|
30
|
+
class Proxy : public HostObject {
|
|
31
|
+
public:
|
|
32
|
+
std::weak_ptr<ComponentsPool> wcp;
|
|
33
|
+
|
|
34
|
+
Proxy(std::weak_ptr<ComponentsPool> wcp);
|
|
35
|
+
|
|
36
|
+
virtual Value get(Runtime &rt, const PropNameID &nameProp);
|
|
37
|
+
|
|
38
|
+
virtual void set(Runtime &rt, const PropNameID &name, const Value &value);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
std::map<std::string, int> nameToIndex_;
|
|
43
|
+
std::map<int, std::string> tagToType_;
|
|
44
|
+
std::map<std::string, std::vector<std::shared_ptr<ShadowNode const>>> reusable_;
|
|
45
|
+
std::vector<std::shared_ptr<ShadowNode const>> registeredViews_;
|
|
46
|
+
std::shared_ptr<HostObject> proxy_;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#include "ItemProvider.h"
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/uimanager/UIManager.h>
|
|
4
|
+
#include <react/renderer/uimanager/primitives.h>
|
|
5
|
+
#include "WishlistJsRuntime.h"
|
|
6
|
+
|
|
7
|
+
namespace Wishlist {
|
|
8
|
+
|
|
9
|
+
WishItem WorkletItemProvider::provide(
|
|
10
|
+
int index,
|
|
11
|
+
const std::shared_ptr<ShadowNodeBinding> &prevSn) {
|
|
12
|
+
WishItem wishItem;
|
|
13
|
+
|
|
14
|
+
auto &rt = WishlistJsRuntime::getInstance().getRuntime();
|
|
15
|
+
|
|
16
|
+
jsi::Function inflateItem =
|
|
17
|
+
rt.global()
|
|
18
|
+
.getPropertyAsObject(rt, "global")
|
|
19
|
+
.getPropertyAsObject(rt, "__wishlistInflatorRegistry")
|
|
20
|
+
.getPropertyAsFunction(rt, "inflateItem");
|
|
21
|
+
|
|
22
|
+
jsi::Value returnedValue;
|
|
23
|
+
try {
|
|
24
|
+
returnedValue = inflateItem.call(
|
|
25
|
+
rt,
|
|
26
|
+
jsi::String::createFromUtf8(rt, tag),
|
|
27
|
+
jsi::Value(index),
|
|
28
|
+
cp->prepareProxy(rt),
|
|
29
|
+
prevSn ? jsi::Object::createFromHostObject(rt, prevSn)
|
|
30
|
+
: jsi::Value::null());
|
|
31
|
+
} catch (std::exception &error) {
|
|
32
|
+
di.lock()->getErrorHandler()->reportError(error.what());
|
|
33
|
+
return wishItem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (returnedValue.isUndefined()) {
|
|
37
|
+
return wishItem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::shared_ptr<ShadowNodeBinding> shadowNodeWrapper =
|
|
41
|
+
returnedValue.asObject(rt).getHostObject<ShadowNodeBinding>(rt);
|
|
42
|
+
|
|
43
|
+
auto sn = shadowNodeWrapper->getShadowNode();
|
|
44
|
+
|
|
45
|
+
auto affected = std::vector<const LayoutableShadowNode *>();
|
|
46
|
+
this->lc.affectedNodes = &affected;
|
|
47
|
+
// better use layoutTree instead of measure (will be persistant)
|
|
48
|
+
std::shared_ptr<YogaLayoutableShadowNode> ysn =
|
|
49
|
+
std::static_pointer_cast<YogaLayoutableShadowNode>(sn->clone({}));
|
|
50
|
+
facebook::react::Size sz = ysn->measure(this->lc, this->lcc);
|
|
51
|
+
|
|
52
|
+
wishItem.sn = std::static_pointer_cast<ShadowNode>(ysn);
|
|
53
|
+
wishItem.height = sz.height;
|
|
54
|
+
wishItem.index = index;
|
|
55
|
+
wishItem.key = shadowNodeWrapper->getKey();
|
|
56
|
+
wishItem.type = shadowNodeWrapper->getType();
|
|
57
|
+
return wishItem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}; // namespace Wishlist
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/uimanager/primitives.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include "ComponentsPool.h"
|
|
7
|
+
#include "MGDI.hpp"
|
|
8
|
+
|
|
9
|
+
using namespace facebook::react;
|
|
10
|
+
|
|
11
|
+
namespace Wishlist {
|
|
12
|
+
|
|
13
|
+
struct WishItem {
|
|
14
|
+
float offset;
|
|
15
|
+
int index;
|
|
16
|
+
std::string key;
|
|
17
|
+
std::string type;
|
|
18
|
+
float height;
|
|
19
|
+
bool dirty = false;
|
|
20
|
+
std::shared_ptr<ShadowNode> sn;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class ItemProvider {
|
|
24
|
+
public:
|
|
25
|
+
float maxWidth = 0;
|
|
26
|
+
LayoutConstraints lcc;
|
|
27
|
+
LayoutContext lc;
|
|
28
|
+
|
|
29
|
+
ItemProvider(float maxWidth, LayoutContext lc) {
|
|
30
|
+
this->maxWidth = maxWidth;
|
|
31
|
+
this->lc = lc;
|
|
32
|
+
lcc.layoutDirection = facebook::react::LayoutDirection::LeftToRight;
|
|
33
|
+
lcc.maximumSize.width = maxWidth;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
virtual void setComponentsPool(std::shared_ptr<ComponentsPool> pool) = 0;
|
|
37
|
+
|
|
38
|
+
virtual WishItem provide(
|
|
39
|
+
int index,
|
|
40
|
+
const std::shared_ptr<ShadowNodeBinding> &prevSn) = 0;
|
|
41
|
+
|
|
42
|
+
virtual ~ItemProvider() {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
struct WorkletItemProvider : ItemProvider {
|
|
46
|
+
std::shared_ptr<ComponentsPool> cp;
|
|
47
|
+
std::string tag;
|
|
48
|
+
std::weak_ptr<MGDI> di;
|
|
49
|
+
|
|
50
|
+
WorkletItemProvider(
|
|
51
|
+
std::weak_ptr<MGDI> di,
|
|
52
|
+
float maxWidth,
|
|
53
|
+
LayoutContext lc,
|
|
54
|
+
std::string tag)
|
|
55
|
+
: ItemProvider(maxWidth, lc), di(di) {
|
|
56
|
+
this->tag = tag;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void setComponentsPool(std::shared_ptr<ComponentsPool> pool) override {
|
|
60
|
+
cp = pool;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
WishItem provide(int index, const std::shared_ptr<ShadowNodeBinding> &prevSn)
|
|
64
|
+
override;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
}; // namespace Wishlist
|