@onekeyfe/react-native-chart-webview 3.0.96 → 3.0.99
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++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/lib/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +97 -67
- package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +2 -2
- package/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +116 -82
- package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +18 -175
- package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +59 -61
- package/package.json +4 -4
|
@@ -37,6 +37,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
37
37
|
|
|
38
38
|
@implementation HybridChartWebviewComponent {
|
|
39
39
|
std::shared_ptr<HybridChartWebviewSpecSwift> _hybridView;
|
|
40
|
+
BOOL _didDropView;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
+ (void) load {
|
|
@@ -50,6 +51,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
50
51
|
|
|
51
52
|
- (instancetype) init {
|
|
52
53
|
if (self = [super init]) {
|
|
54
|
+
_props = HybridChartWebviewShadowNode::defaultSharedProps();
|
|
53
55
|
std::shared_ptr<HybridChartWebviewSpec> hybridView = ChartWebview::ChartWebviewAutolinking::createChartWebview();
|
|
54
56
|
_hybridView = std::dynamic_pointer_cast<HybridChartWebviewSpecSwift>(hybridView);
|
|
55
57
|
[self updateView];
|
|
@@ -69,95 +71,127 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
69
71
|
[self setContentView:view];
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
- (void) notifyOnDropView {
|
|
75
|
+
// A recycled component can later be invalidated. Notify only once per mount.
|
|
76
|
+
if (_didDropView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
80
|
+
swiftPart.onDropView();
|
|
81
|
+
_didDropView = YES;
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
85
|
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
86
|
+
// A props update marks a newly mounted or still-active component.
|
|
87
|
+
_didDropView = NO;
|
|
88
|
+
|
|
74
89
|
// 1. Downcast props
|
|
75
|
-
const auto&
|
|
76
|
-
auto
|
|
90
|
+
const auto& newViewProps = *std::static_pointer_cast<const HybridChartWebviewProps>(props);
|
|
91
|
+
const auto* oldViewProps = static_cast<const HybridChartWebviewProps*>(oldProps.get());
|
|
77
92
|
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
93
|
|
|
79
|
-
// 2. Update
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
swiftPart.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
94
|
+
// 2. Update only props that differ from the previous Props snapshot.
|
|
95
|
+
const bool hasTransactionPropChanges = oldViewProps == nullptr
|
|
96
|
+
? newViewProps.hasAnyProvidedProps()
|
|
97
|
+
: !newViewProps.hasSameProps(*oldViewProps);
|
|
98
|
+
if (hasTransactionPropChanges) {
|
|
99
|
+
swiftPart.beforeUpdate();
|
|
100
|
+
|
|
101
|
+
// uri: optional
|
|
102
|
+
if (oldViewProps == nullptr
|
|
103
|
+
? newViewProps.uri.isProvided()
|
|
104
|
+
: !newViewProps.uri.hasSameValue(oldViewProps->uri)) {
|
|
105
|
+
swiftPart.setUri(newViewProps.uri.get());
|
|
106
|
+
}
|
|
107
|
+
// localBundle: optional
|
|
108
|
+
if (oldViewProps == nullptr
|
|
109
|
+
? newViewProps.localBundle.isProvided()
|
|
110
|
+
: !newViewProps.localBundle.hasSameValue(oldViewProps->localBundle)) {
|
|
111
|
+
swiftPart.setLocalBundle(newViewProps.localBundle.get());
|
|
112
|
+
}
|
|
113
|
+
// entry: optional
|
|
114
|
+
if (oldViewProps == nullptr
|
|
115
|
+
? newViewProps.entry.isProvided()
|
|
116
|
+
: !newViewProps.entry.hasSameValue(oldViewProps->entry)) {
|
|
117
|
+
swiftPart.setEntry(newViewProps.entry.get());
|
|
118
|
+
}
|
|
119
|
+
// paramsJson: optional
|
|
120
|
+
if (oldViewProps == nullptr
|
|
121
|
+
? newViewProps.paramsJson.isProvided()
|
|
122
|
+
: !newViewProps.paramsJson.hasSameValue(oldViewProps->paramsJson)) {
|
|
123
|
+
swiftPart.setParamsJson(newViewProps.paramsJson.get());
|
|
124
|
+
}
|
|
125
|
+
// assetHost: optional
|
|
126
|
+
if (oldViewProps == nullptr
|
|
127
|
+
? newViewProps.assetHost.isProvided()
|
|
128
|
+
: !newViewProps.assetHost.hasSameValue(oldViewProps->assetHost)) {
|
|
129
|
+
swiftPart.setAssetHost(newViewProps.assetHost.get());
|
|
130
|
+
}
|
|
131
|
+
// bridgeScript: optional
|
|
132
|
+
if (oldViewProps == nullptr
|
|
133
|
+
? newViewProps.bridgeScript.isProvided()
|
|
134
|
+
: !newViewProps.bridgeScript.hasSameValue(oldViewProps->bridgeScript)) {
|
|
135
|
+
swiftPart.setBridgeScript(newViewProps.bridgeScript.get());
|
|
136
|
+
}
|
|
137
|
+
// reuseKey: optional
|
|
138
|
+
if (oldViewProps == nullptr
|
|
139
|
+
? newViewProps.reuseKey.isProvided()
|
|
140
|
+
: !newViewProps.reuseKey.hasSameValue(oldViewProps->reuseKey)) {
|
|
141
|
+
swiftPart.setReuseKey(newViewProps.reuseKey.get());
|
|
142
|
+
}
|
|
143
|
+
// pooled: optional
|
|
144
|
+
if (oldViewProps == nullptr
|
|
145
|
+
? newViewProps.pooled.isProvided()
|
|
146
|
+
: !newViewProps.pooled.hasSameValue(oldViewProps->pooled)) {
|
|
147
|
+
swiftPart.setPooled(newViewProps.pooled.get());
|
|
148
|
+
}
|
|
149
|
+
// active: optional
|
|
150
|
+
if (oldViewProps == nullptr
|
|
151
|
+
? newViewProps.active.isProvided()
|
|
152
|
+
: !newViewProps.active.hasSameValue(oldViewProps->active)) {
|
|
153
|
+
swiftPart.setActive(newViewProps.active.get());
|
|
154
|
+
}
|
|
155
|
+
// webviewDebuggingEnabled: optional
|
|
156
|
+
if (oldViewProps == nullptr
|
|
157
|
+
? newViewProps.webviewDebuggingEnabled.isProvided()
|
|
158
|
+
: !newViewProps.webviewDebuggingEnabled.hasSameValue(oldViewProps->webviewDebuggingEnabled)) {
|
|
159
|
+
swiftPart.setWebviewDebuggingEnabled(newViewProps.webviewDebuggingEnabled.get());
|
|
160
|
+
}
|
|
161
|
+
// onMessage: optional
|
|
162
|
+
if (oldViewProps == nullptr
|
|
163
|
+
? newViewProps.onMessage.isProvided()
|
|
164
|
+
: !newViewProps.onMessage.hasSameValue(oldViewProps->onMessage)) {
|
|
165
|
+
swiftPart.setOnMessage(newViewProps.onMessage.get());
|
|
166
|
+
}
|
|
167
|
+
// onLoadEnd: optional
|
|
168
|
+
if (oldViewProps == nullptr
|
|
169
|
+
? newViewProps.onLoadEnd.isProvided()
|
|
170
|
+
: !newViewProps.onLoadEnd.hasSameValue(oldViewProps->onLoadEnd)) {
|
|
171
|
+
swiftPart.setOnLoadEnd(newViewProps.onLoadEnd.get());
|
|
172
|
+
}
|
|
173
|
+
// onError: optional
|
|
174
|
+
if (oldViewProps == nullptr
|
|
175
|
+
? newViewProps.onError.isProvided()
|
|
176
|
+
: !newViewProps.onError.hasSameValue(oldViewProps->onError)) {
|
|
177
|
+
swiftPart.setOnError(newViewProps.onError.get());
|
|
178
|
+
}
|
|
149
179
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
maybeFunc.
|
|
180
|
+
// Update hybridRef if it changed
|
|
181
|
+
if (oldViewProps == nullptr
|
|
182
|
+
? newViewProps.hybridRef.isProvided()
|
|
183
|
+
: !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
|
|
184
|
+
// hybridRef changed - call it with new this
|
|
185
|
+
const auto& maybeFunc = newViewProps.hybridRef.get();
|
|
186
|
+
if (maybeFunc.has_value()) {
|
|
187
|
+
maybeFunc.value()(_hybridView);
|
|
188
|
+
}
|
|
156
189
|
}
|
|
157
|
-
|
|
190
|
+
|
|
191
|
+
swiftPart.afterUpdate();
|
|
158
192
|
}
|
|
159
193
|
|
|
160
|
-
//
|
|
194
|
+
// 3. Continue in base class
|
|
161
195
|
[super updateProps:props oldProps:oldProps];
|
|
162
196
|
}
|
|
163
197
|
|
|
@@ -166,6 +200,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
166
200
|
}
|
|
167
201
|
|
|
168
202
|
- (void)prepareForRecycle {
|
|
203
|
+
[self notifyOnDropView];
|
|
169
204
|
[super prepareForRecycle];
|
|
170
205
|
ChartWebview::HybridChartWebviewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
171
206
|
swiftPart.maybePrepareForRecycle();
|
|
@@ -173,8 +208,7 @@ using namespace margelo::nitro::chartwebview::views;
|
|
|
173
208
|
|
|
174
209
|
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
175
210
|
- (void)invalidate {
|
|
176
|
-
|
|
177
|
-
swiftPart.onDropView();
|
|
211
|
+
[self notifyOnDropView];
|
|
178
212
|
[super invalidate];
|
|
179
213
|
}
|
|
180
214
|
#endif
|
|
@@ -7,165 +7,33 @@
|
|
|
7
7
|
|
|
8
8
|
#include "HybridChartWebviewComponent.hpp"
|
|
9
9
|
|
|
10
|
-
#include <
|
|
11
|
-
#include <
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
-
#include <NitroModules/PropNameIDCache.hpp>
|
|
16
|
-
#include <react/renderer/core/RawValue.h>
|
|
17
|
-
#include <react/renderer/core/ShadowNode.h>
|
|
18
|
-
#include <react/renderer/core/ComponentDescriptor.h>
|
|
19
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
10
|
+
#include <NitroModules/NitroHash.hpp>
|
|
11
|
+
#include <NitroModules/ReactProp.hpp>
|
|
20
12
|
|
|
21
13
|
namespace margelo::nitro::chartwebview::views {
|
|
22
14
|
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
23
17
|
extern const char HybridChartWebviewComponentName[] = "ChartWebview";
|
|
24
18
|
|
|
25
19
|
HybridChartWebviewProps::HybridChartWebviewProps(const react::PropsParserContext& context,
|
|
26
20
|
const HybridChartWebviewProps& sourceProps,
|
|
27
21
|
const react::RawProps& rawProps):
|
|
28
22
|
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
29
|
-
uri(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
44
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.localBundle);
|
|
45
|
-
} catch (const std::exception& exc) {
|
|
46
|
-
throw std::runtime_error(std::string("ChartWebview.localBundle: ") + exc.what());
|
|
47
|
-
}
|
|
48
|
-
}()),
|
|
49
|
-
entry([&]() -> CachedProp<std::optional<std::string>> {
|
|
50
|
-
try {
|
|
51
|
-
const react::RawValue* rawValue = rawProps.at("entry", nullptr, nullptr);
|
|
52
|
-
if (rawValue == nullptr) return sourceProps.entry;
|
|
53
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
54
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.entry);
|
|
55
|
-
} catch (const std::exception& exc) {
|
|
56
|
-
throw std::runtime_error(std::string("ChartWebview.entry: ") + exc.what());
|
|
57
|
-
}
|
|
58
|
-
}()),
|
|
59
|
-
paramsJson([&]() -> CachedProp<std::optional<std::string>> {
|
|
60
|
-
try {
|
|
61
|
-
const react::RawValue* rawValue = rawProps.at("paramsJson", nullptr, nullptr);
|
|
62
|
-
if (rawValue == nullptr) return sourceProps.paramsJson;
|
|
63
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
64
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.paramsJson);
|
|
65
|
-
} catch (const std::exception& exc) {
|
|
66
|
-
throw std::runtime_error(std::string("ChartWebview.paramsJson: ") + exc.what());
|
|
67
|
-
}
|
|
68
|
-
}()),
|
|
69
|
-
assetHost([&]() -> CachedProp<std::optional<std::string>> {
|
|
70
|
-
try {
|
|
71
|
-
const react::RawValue* rawValue = rawProps.at("assetHost", nullptr, nullptr);
|
|
72
|
-
if (rawValue == nullptr) return sourceProps.assetHost;
|
|
73
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
74
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.assetHost);
|
|
75
|
-
} catch (const std::exception& exc) {
|
|
76
|
-
throw std::runtime_error(std::string("ChartWebview.assetHost: ") + exc.what());
|
|
77
|
-
}
|
|
78
|
-
}()),
|
|
79
|
-
bridgeScript([&]() -> CachedProp<std::optional<std::string>> {
|
|
80
|
-
try {
|
|
81
|
-
const react::RawValue* rawValue = rawProps.at("bridgeScript", nullptr, nullptr);
|
|
82
|
-
if (rawValue == nullptr) return sourceProps.bridgeScript;
|
|
83
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
84
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.bridgeScript);
|
|
85
|
-
} catch (const std::exception& exc) {
|
|
86
|
-
throw std::runtime_error(std::string("ChartWebview.bridgeScript: ") + exc.what());
|
|
87
|
-
}
|
|
88
|
-
}()),
|
|
89
|
-
reuseKey([&]() -> CachedProp<std::optional<std::string>> {
|
|
90
|
-
try {
|
|
91
|
-
const react::RawValue* rawValue = rawProps.at("reuseKey", nullptr, nullptr);
|
|
92
|
-
if (rawValue == nullptr) return sourceProps.reuseKey;
|
|
93
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
94
|
-
return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.reuseKey);
|
|
95
|
-
} catch (const std::exception& exc) {
|
|
96
|
-
throw std::runtime_error(std::string("ChartWebview.reuseKey: ") + exc.what());
|
|
97
|
-
}
|
|
98
|
-
}()),
|
|
99
|
-
pooled([&]() -> CachedProp<std::optional<bool>> {
|
|
100
|
-
try {
|
|
101
|
-
const react::RawValue* rawValue = rawProps.at("pooled", nullptr, nullptr);
|
|
102
|
-
if (rawValue == nullptr) return sourceProps.pooled;
|
|
103
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
104
|
-
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.pooled);
|
|
105
|
-
} catch (const std::exception& exc) {
|
|
106
|
-
throw std::runtime_error(std::string("ChartWebview.pooled: ") + exc.what());
|
|
107
|
-
}
|
|
108
|
-
}()),
|
|
109
|
-
active([&]() -> CachedProp<std::optional<bool>> {
|
|
110
|
-
try {
|
|
111
|
-
const react::RawValue* rawValue = rawProps.at("active", nullptr, nullptr);
|
|
112
|
-
if (rawValue == nullptr) return sourceProps.active;
|
|
113
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
114
|
-
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.active);
|
|
115
|
-
} catch (const std::exception& exc) {
|
|
116
|
-
throw std::runtime_error(std::string("ChartWebview.active: ") + exc.what());
|
|
117
|
-
}
|
|
118
|
-
}()),
|
|
119
|
-
webviewDebuggingEnabled([&]() -> CachedProp<std::optional<bool>> {
|
|
120
|
-
try {
|
|
121
|
-
const react::RawValue* rawValue = rawProps.at("webviewDebuggingEnabled", nullptr, nullptr);
|
|
122
|
-
if (rawValue == nullptr) return sourceProps.webviewDebuggingEnabled;
|
|
123
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
124
|
-
return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.webviewDebuggingEnabled);
|
|
125
|
-
} catch (const std::exception& exc) {
|
|
126
|
-
throw std::runtime_error(std::string("ChartWebview.webviewDebuggingEnabled: ") + exc.what());
|
|
127
|
-
}
|
|
128
|
-
}()),
|
|
129
|
-
onMessage([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> {
|
|
130
|
-
try {
|
|
131
|
-
const react::RawValue* rawValue = rawProps.at("onMessage", nullptr, nullptr);
|
|
132
|
-
if (rawValue == nullptr) return sourceProps.onMessage;
|
|
133
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
134
|
-
return CachedProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onMessage);
|
|
135
|
-
} catch (const std::exception& exc) {
|
|
136
|
-
throw std::runtime_error(std::string("ChartWebview.onMessage: ") + exc.what());
|
|
137
|
-
}
|
|
138
|
-
}()),
|
|
139
|
-
onLoadEnd([&]() -> CachedProp<std::optional<std::function<void()>>> {
|
|
140
|
-
try {
|
|
141
|
-
const react::RawValue* rawValue = rawProps.at("onLoadEnd", nullptr, nullptr);
|
|
142
|
-
if (rawValue == nullptr) return sourceProps.onLoadEnd;
|
|
143
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
144
|
-
return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onLoadEnd);
|
|
145
|
-
} catch (const std::exception& exc) {
|
|
146
|
-
throw std::runtime_error(std::string("ChartWebview.onLoadEnd: ") + exc.what());
|
|
147
|
-
}
|
|
148
|
-
}()),
|
|
149
|
-
onError([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> {
|
|
150
|
-
try {
|
|
151
|
-
const react::RawValue* rawValue = rawProps.at("onError", nullptr, nullptr);
|
|
152
|
-
if (rawValue == nullptr) return sourceProps.onError;
|
|
153
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
154
|
-
return CachedProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onError);
|
|
155
|
-
} catch (const std::exception& exc) {
|
|
156
|
-
throw std::runtime_error(std::string("ChartWebview.onError: ") + exc.what());
|
|
157
|
-
}
|
|
158
|
-
}()),
|
|
159
|
-
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>> {
|
|
160
|
-
try {
|
|
161
|
-
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
162
|
-
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
163
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
164
|
-
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
165
|
-
} catch (const std::exception& exc) {
|
|
166
|
-
throw std::runtime_error(std::string("ChartWebview.hybridRef: ") + exc.what());
|
|
167
|
-
}
|
|
168
|
-
}()) { }
|
|
23
|
+
uri(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "uri", rawProps, sourceProps.uri)),
|
|
24
|
+
localBundle(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "localBundle", rawProps, sourceProps.localBundle)),
|
|
25
|
+
entry(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "entry", rawProps, sourceProps.entry)),
|
|
26
|
+
paramsJson(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "paramsJson", rawProps, sourceProps.paramsJson)),
|
|
27
|
+
assetHost(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "assetHost", rawProps, sourceProps.assetHost)),
|
|
28
|
+
bridgeScript(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "bridgeScript", rawProps, sourceProps.bridgeScript)),
|
|
29
|
+
reuseKey(nitro::ReactProp<std::optional<std::string>>::fromRawValue("ChartWebview", "reuseKey", rawProps, sourceProps.reuseKey)),
|
|
30
|
+
pooled(nitro::ReactProp<std::optional<bool>>::fromRawValue("ChartWebview", "pooled", rawProps, sourceProps.pooled)),
|
|
31
|
+
active(nitro::ReactProp<std::optional<bool>>::fromRawValue("ChartWebview", "active", rawProps, sourceProps.active)),
|
|
32
|
+
webviewDebuggingEnabled(nitro::ReactProp<std::optional<bool>>::fromRawValue("ChartWebview", "webviewDebuggingEnabled", rawProps, sourceProps.webviewDebuggingEnabled)),
|
|
33
|
+
onMessage(nitro::ReactProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue("ChartWebview", "onMessage", rawProps, sourceProps.onMessage)),
|
|
34
|
+
onLoadEnd(nitro::ReactProp<std::optional<std::function<void()>>>::fromRawValue("ChartWebview", "onLoadEnd", rawProps, sourceProps.onLoadEnd)),
|
|
35
|
+
onError(nitro::ReactProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue("ChartWebview", "onError", rawProps, sourceProps.onError)),
|
|
36
|
+
hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>>::fromRawValue("ChartWebview", "hybridRef", rawProps, sourceProps.hybridRef)) { }
|
|
169
37
|
|
|
170
38
|
bool HybridChartWebviewProps::filterObjectKeys(const std::string& propName) {
|
|
171
39
|
switch (hashString(propName)) {
|
|
@@ -187,29 +55,4 @@ namespace margelo::nitro::chartwebview::views {
|
|
|
187
55
|
}
|
|
188
56
|
}
|
|
189
57
|
|
|
190
|
-
HybridChartWebviewComponentDescriptor::HybridChartWebviewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
191
|
-
: ConcreteComponentDescriptor(parameters,
|
|
192
|
-
react::RawPropsParser()) {}
|
|
193
|
-
|
|
194
|
-
std::shared_ptr<const react::Props> HybridChartWebviewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
195
|
-
const std::shared_ptr<const react::Props>& props,
|
|
196
|
-
react::RawProps rawProps) const {
|
|
197
|
-
// 1. Prepare raw props parser
|
|
198
|
-
rawProps.parse(rawPropsParser_);
|
|
199
|
-
// 2. Copy props with Nitro's cached copy constructor
|
|
200
|
-
return HybridChartWebviewShadowNode::Props(context, /* & */ rawProps, props);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
#ifdef ANDROID
|
|
204
|
-
void HybridChartWebviewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
205
|
-
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
206
|
-
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
207
|
-
auto& concreteShadowNode = static_cast<HybridChartWebviewShadowNode&>(shadowNode);
|
|
208
|
-
const std::shared_ptr<const HybridChartWebviewProps>& constProps = concreteShadowNode.getConcreteSharedProps();
|
|
209
|
-
const std::shared_ptr<HybridChartWebviewProps>& props = std::const_pointer_cast<HybridChartWebviewProps>(constProps);
|
|
210
|
-
HybridChartWebviewState state{props};
|
|
211
|
-
concreteShadowNode.setStateData(std::move(state));
|
|
212
|
-
}
|
|
213
|
-
#endif
|
|
214
|
-
|
|
215
58
|
} // namespace margelo::nitro::chartwebview::views
|
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <
|
|
11
|
-
#include <NitroModules/
|
|
12
|
-
#include <NitroModules/
|
|
13
|
-
#include <NitroModules/CachedProp.hpp>
|
|
14
|
-
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
10
|
+
#include <NitroModules/ReactProp.hpp>
|
|
11
|
+
#include <NitroModules/ViewComponentDescriptor.hpp>
|
|
12
|
+
#include <NitroModules/ViewPropsHolderState.hpp>
|
|
16
13
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
14
|
#include <react/renderer/components/view/ViewProps.h>
|
|
15
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
+
#include <react/renderer/core/RawProps.h>
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
18
19
|
|
|
19
20
|
#include <string>
|
|
20
21
|
#include <optional>
|
|
@@ -42,20 +43,56 @@ namespace margelo::nitro::chartwebview::views {
|
|
|
42
43
|
const react::RawProps& rawProps);
|
|
43
44
|
|
|
44
45
|
public:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
nitro::ReactProp<std::optional<std::string>> uri;
|
|
47
|
+
nitro::ReactProp<std::optional<std::string>> localBundle;
|
|
48
|
+
nitro::ReactProp<std::optional<std::string>> entry;
|
|
49
|
+
nitro::ReactProp<std::optional<std::string>> paramsJson;
|
|
50
|
+
nitro::ReactProp<std::optional<std::string>> assetHost;
|
|
51
|
+
nitro::ReactProp<std::optional<std::string>> bridgeScript;
|
|
52
|
+
nitro::ReactProp<std::optional<std::string>> reuseKey;
|
|
53
|
+
nitro::ReactProp<std::optional<bool>> pooled;
|
|
54
|
+
nitro::ReactProp<std::optional<bool>> active;
|
|
55
|
+
nitro::ReactProp<std::optional<bool>> webviewDebuggingEnabled;
|
|
56
|
+
nitro::ReactProp<std::optional<std::function<void(const std::string& /* message */)>>> onMessage;
|
|
57
|
+
nitro::ReactProp<std::optional<std::function<void()>>> onLoadEnd;
|
|
58
|
+
nitro::ReactProp<std::optional<std::function<void(const std::string& /* message */)>>> onError;
|
|
59
|
+
nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>> hybridRef;
|
|
60
|
+
|
|
61
|
+
[[nodiscard]]
|
|
62
|
+
bool hasSameProps(const HybridChartWebviewProps& other) const noexcept {
|
|
63
|
+
return uri.hasSameValue(other.uri) &&
|
|
64
|
+
localBundle.hasSameValue(other.localBundle) &&
|
|
65
|
+
entry.hasSameValue(other.entry) &&
|
|
66
|
+
paramsJson.hasSameValue(other.paramsJson) &&
|
|
67
|
+
assetHost.hasSameValue(other.assetHost) &&
|
|
68
|
+
bridgeScript.hasSameValue(other.bridgeScript) &&
|
|
69
|
+
reuseKey.hasSameValue(other.reuseKey) &&
|
|
70
|
+
pooled.hasSameValue(other.pooled) &&
|
|
71
|
+
active.hasSameValue(other.active) &&
|
|
72
|
+
webviewDebuggingEnabled.hasSameValue(other.webviewDebuggingEnabled) &&
|
|
73
|
+
onMessage.hasSameValue(other.onMessage) &&
|
|
74
|
+
onLoadEnd.hasSameValue(other.onLoadEnd) &&
|
|
75
|
+
onError.hasSameValue(other.onError) &&
|
|
76
|
+
hybridRef.hasSameValue(other.hybridRef);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[[nodiscard]]
|
|
80
|
+
bool hasAnyProvidedProps() const noexcept {
|
|
81
|
+
return uri.isProvided() ||
|
|
82
|
+
localBundle.isProvided() ||
|
|
83
|
+
entry.isProvided() ||
|
|
84
|
+
paramsJson.isProvided() ||
|
|
85
|
+
assetHost.isProvided() ||
|
|
86
|
+
bridgeScript.isProvided() ||
|
|
87
|
+
reuseKey.isProvided() ||
|
|
88
|
+
pooled.isProvided() ||
|
|
89
|
+
active.isProvided() ||
|
|
90
|
+
webviewDebuggingEnabled.isProvided() ||
|
|
91
|
+
onMessage.isProvided() ||
|
|
92
|
+
onLoadEnd.isProvided() ||
|
|
93
|
+
onError.isProvided() ||
|
|
94
|
+
hybridRef.isProvided();
|
|
95
|
+
}
|
|
59
96
|
|
|
60
97
|
private:
|
|
61
98
|
static bool filterObjectKeys(const std::string& propName);
|
|
@@ -64,32 +101,7 @@ namespace margelo::nitro::chartwebview::views {
|
|
|
64
101
|
/**
|
|
65
102
|
* State for the "ChartWebview" View.
|
|
66
103
|
*/
|
|
67
|
-
|
|
68
|
-
public:
|
|
69
|
-
HybridChartWebviewState() = default;
|
|
70
|
-
explicit HybridChartWebviewState(const std::shared_ptr<HybridChartWebviewProps>& props):
|
|
71
|
-
_props(props) {}
|
|
72
|
-
|
|
73
|
-
public:
|
|
74
|
-
[[nodiscard]]
|
|
75
|
-
const std::shared_ptr<HybridChartWebviewProps>& getProps() const {
|
|
76
|
-
return _props;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public:
|
|
80
|
-
#ifdef ANDROID
|
|
81
|
-
HybridChartWebviewState(const HybridChartWebviewState& /* previousState */, folly::dynamic /* data */) {}
|
|
82
|
-
folly::dynamic getDynamic() const {
|
|
83
|
-
throw std::runtime_error("HybridChartWebviewState does not support folly!");
|
|
84
|
-
}
|
|
85
|
-
react::MapBuffer getMapBuffer() const {
|
|
86
|
-
throw std::runtime_error("HybridChartWebviewState does not support MapBuffer!");
|
|
87
|
-
};
|
|
88
|
-
#endif
|
|
89
|
-
|
|
90
|
-
private:
|
|
91
|
-
std::shared_ptr<HybridChartWebviewProps> _props;
|
|
92
|
-
};
|
|
104
|
+
using HybridChartWebviewState = nitro::ViewPropsHolderState<HybridChartWebviewProps>;
|
|
93
105
|
|
|
94
106
|
/**
|
|
95
107
|
* The Shadow Node for the "ChartWebview" View.
|
|
@@ -102,21 +114,7 @@ namespace margelo::nitro::chartwebview::views {
|
|
|
102
114
|
/**
|
|
103
115
|
* The Component Descriptor for the "ChartWebview" View.
|
|
104
116
|
*/
|
|
105
|
-
|
|
106
|
-
public:
|
|
107
|
-
explicit HybridChartWebviewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
108
|
-
|
|
109
|
-
public:
|
|
110
|
-
/**
|
|
111
|
-
* A faster path for cloning props - reuses the caching logic from `HybridChartWebviewProps`.
|
|
112
|
-
*/
|
|
113
|
-
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
|
|
114
|
-
const std::shared_ptr<const react::Props>& props,
|
|
115
|
-
react::RawProps rawProps) const override;
|
|
116
|
-
#ifdef ANDROID
|
|
117
|
-
void adopt(react::ShadowNode& shadowNode) const override;
|
|
118
|
-
#endif
|
|
119
|
-
};
|
|
117
|
+
using HybridChartWebviewComponentDescriptor = nitro::ViewComponentDescriptor<HybridChartWebviewShadowNode>;
|
|
120
118
|
|
|
121
119
|
/* The actual view for "ChartWebview" needs to be implemented in platform-specific code. */
|
|
122
120
|
|