@onekeyfe/react-native-chart-webview 3.0.39

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.
Files changed (132) hide show
  1. package/ChartWebview.podspec +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +31 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +131 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/chartwebview/ChartWebview.kt +331 -0
  9. package/android/src/main/java/com/margelo/nitro/chartwebview/ChartWebviewPackage.kt +29 -0
  10. package/android/src/main/java/com/margelo/nitro/chartwebview/PooledChartWebView.kt +385 -0
  11. package/ios/ChartWebview.swift +747 -0
  12. package/lib/module/ChartWebview.nitro.js +4 -0
  13. package/lib/module/ChartWebview.nitro.js.map +1 -0
  14. package/lib/module/bridge.js +30 -0
  15. package/lib/module/bridge.js.map +1 -0
  16. package/lib/module/index.js +19 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/package.json +1 -0
  19. package/lib/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  20. package/lib/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  21. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +186 -0
  22. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +88 -0
  23. package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +96 -0
  24. package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +49 -0
  25. package/lib/nitrogen/generated/android/chartwebview+autolinking.cmake +83 -0
  26. package/lib/nitrogen/generated/android/chartwebview+autolinking.gradle +27 -0
  27. package/lib/nitrogen/generated/android/chartwebviewOnLoad.cpp +50 -0
  28. package/lib/nitrogen/generated/android/chartwebviewOnLoad.hpp +25 -0
  29. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void.kt +80 -0
  30. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void_std__string.kt +80 -0
  31. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +153 -0
  32. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/chartwebviewOnLoad.kt +35 -0
  33. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +50 -0
  34. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +23 -0
  35. package/lib/nitrogen/generated/ios/ChartWebview+autolinking.rb +60 -0
  36. package/lib/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.cpp +49 -0
  37. package/lib/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.hpp +158 -0
  38. package/lib/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Umbrella.hpp +46 -0
  39. package/lib/nitrogen/generated/ios/ChartWebviewAutolinking.mm +33 -0
  40. package/lib/nitrogen/generated/ios/ChartWebviewAutolinking.swift +25 -0
  41. package/lib/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.cpp +11 -0
  42. package/lib/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +164 -0
  43. package/lib/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +146 -0
  44. package/lib/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  45. package/lib/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  46. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +68 -0
  47. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +450 -0
  48. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +45 -0
  49. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +87 -0
  50. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +207 -0
  51. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +118 -0
  52. package/lib/nitrogen/generated/shared/json/ChartWebviewConfig.json +20 -0
  53. package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  54. package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  55. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +186 -0
  56. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +88 -0
  57. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +96 -0
  58. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +49 -0
  59. package/lib/nitrogen/nitrogen/generated/android/chartwebview+autolinking.cmake +83 -0
  60. package/lib/nitrogen/nitrogen/generated/android/chartwebview+autolinking.gradle +27 -0
  61. package/lib/nitrogen/nitrogen/generated/android/chartwebviewOnLoad.cpp +50 -0
  62. package/lib/nitrogen/nitrogen/generated/android/chartwebviewOnLoad.hpp +25 -0
  63. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void.kt +80 -0
  64. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void_std__string.kt +80 -0
  65. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +153 -0
  66. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/chartwebviewOnLoad.kt +35 -0
  67. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +50 -0
  68. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +23 -0
  69. package/lib/nitrogen/nitrogen/generated/ios/ChartWebview+autolinking.rb +60 -0
  70. package/lib/nitrogen/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.cpp +49 -0
  71. package/lib/nitrogen/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.hpp +158 -0
  72. package/lib/nitrogen/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Umbrella.hpp +46 -0
  73. package/lib/nitrogen/nitrogen/generated/ios/ChartWebviewAutolinking.mm +33 -0
  74. package/lib/nitrogen/nitrogen/generated/ios/ChartWebviewAutolinking.swift +25 -0
  75. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.cpp +11 -0
  76. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +164 -0
  77. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +146 -0
  78. package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  79. package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  80. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +68 -0
  81. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +450 -0
  82. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +45 -0
  83. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +87 -0
  84. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +207 -0
  85. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +118 -0
  86. package/lib/nitrogen/nitrogen/generated/shared/json/ChartWebviewConfig.json +20 -0
  87. package/lib/typescript/package.json +1 -0
  88. package/lib/typescript/src/ChartWebview.nitro.d.ts +21 -0
  89. package/lib/typescript/src/ChartWebview.nitro.d.ts.map +1 -0
  90. package/lib/typescript/src/bridge.d.ts +2 -0
  91. package/lib/typescript/src/bridge.d.ts.map +1 -0
  92. package/lib/typescript/src/index.d.ts +145 -0
  93. package/lib/typescript/src/index.d.ts.map +1 -0
  94. package/nitro.json +17 -0
  95. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  96. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  97. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +186 -0
  98. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +88 -0
  99. package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +96 -0
  100. package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.hpp +49 -0
  101. package/nitrogen/generated/android/chartwebview+autolinking.cmake +83 -0
  102. package/nitrogen/generated/android/chartwebview+autolinking.gradle +27 -0
  103. package/nitrogen/generated/android/chartwebviewOnLoad.cpp +50 -0
  104. package/nitrogen/generated/android/chartwebviewOnLoad.hpp +25 -0
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void.kt +80 -0
  106. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/Func_void_std__string.kt +80 -0
  107. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +153 -0
  108. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/chartwebviewOnLoad.kt +35 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewManager.kt +50 -0
  110. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/views/HybridChartWebviewStateUpdater.kt +23 -0
  111. package/nitrogen/generated/ios/ChartWebview+autolinking.rb +60 -0
  112. package/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.cpp +49 -0
  113. package/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Bridge.hpp +158 -0
  114. package/nitrogen/generated/ios/ChartWebview-Swift-Cxx-Umbrella.hpp +46 -0
  115. package/nitrogen/generated/ios/ChartWebviewAutolinking.mm +33 -0
  116. package/nitrogen/generated/ios/ChartWebviewAutolinking.swift +25 -0
  117. package/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.cpp +11 -0
  118. package/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +164 -0
  119. package/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +146 -0
  120. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  121. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  122. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +68 -0
  123. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +450 -0
  124. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +45 -0
  125. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +87 -0
  126. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +207 -0
  127. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +118 -0
  128. package/nitrogen/generated/shared/json/ChartWebviewConfig.json +20 -0
  129. package/package.json +170 -0
  130. package/src/ChartWebview.nitro.ts +59 -0
  131. package/src/bridge.ts +27 -0
  132. package/src/index.tsx +20 -0
@@ -0,0 +1,207 @@
1
+ ///
2
+ /// HybridChartWebviewComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridChartWebviewComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <react/renderer/core/RawValue.h>
16
+ #include <react/renderer/core/ShadowNode.h>
17
+ #include <react/renderer/core/ComponentDescriptor.h>
18
+ #include <react/renderer/components/view/ViewProps.h>
19
+
20
+ namespace margelo::nitro::chartwebview::views {
21
+
22
+ extern const char HybridChartWebviewComponentName[] = "ChartWebview";
23
+
24
+ HybridChartWebviewProps::HybridChartWebviewProps(const react::PropsParserContext& context,
25
+ const HybridChartWebviewProps& sourceProps,
26
+ const react::RawProps& rawProps):
27
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
28
+ uri([&]() -> CachedProp<std::optional<std::string>> {
29
+ try {
30
+ const react::RawValue* rawValue = rawProps.at("uri", nullptr, nullptr);
31
+ if (rawValue == nullptr) return sourceProps.uri;
32
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
33
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.uri);
34
+ } catch (const std::exception& exc) {
35
+ throw std::runtime_error(std::string("ChartWebview.uri: ") + exc.what());
36
+ }
37
+ }()),
38
+ localBundle([&]() -> CachedProp<std::optional<std::string>> {
39
+ try {
40
+ const react::RawValue* rawValue = rawProps.at("localBundle", nullptr, nullptr);
41
+ if (rawValue == nullptr) return sourceProps.localBundle;
42
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
43
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.localBundle);
44
+ } catch (const std::exception& exc) {
45
+ throw std::runtime_error(std::string("ChartWebview.localBundle: ") + exc.what());
46
+ }
47
+ }()),
48
+ entry([&]() -> CachedProp<std::optional<std::string>> {
49
+ try {
50
+ const react::RawValue* rawValue = rawProps.at("entry", nullptr, nullptr);
51
+ if (rawValue == nullptr) return sourceProps.entry;
52
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
53
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.entry);
54
+ } catch (const std::exception& exc) {
55
+ throw std::runtime_error(std::string("ChartWebview.entry: ") + exc.what());
56
+ }
57
+ }()),
58
+ paramsJson([&]() -> CachedProp<std::optional<std::string>> {
59
+ try {
60
+ const react::RawValue* rawValue = rawProps.at("paramsJson", nullptr, nullptr);
61
+ if (rawValue == nullptr) return sourceProps.paramsJson;
62
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
63
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.paramsJson);
64
+ } catch (const std::exception& exc) {
65
+ throw std::runtime_error(std::string("ChartWebview.paramsJson: ") + exc.what());
66
+ }
67
+ }()),
68
+ bridgeScript([&]() -> CachedProp<std::optional<std::string>> {
69
+ try {
70
+ const react::RawValue* rawValue = rawProps.at("bridgeScript", nullptr, nullptr);
71
+ if (rawValue == nullptr) return sourceProps.bridgeScript;
72
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
73
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.bridgeScript);
74
+ } catch (const std::exception& exc) {
75
+ throw std::runtime_error(std::string("ChartWebview.bridgeScript: ") + exc.what());
76
+ }
77
+ }()),
78
+ reuseKey([&]() -> CachedProp<std::optional<std::string>> {
79
+ try {
80
+ const react::RawValue* rawValue = rawProps.at("reuseKey", nullptr, nullptr);
81
+ if (rawValue == nullptr) return sourceProps.reuseKey;
82
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
83
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.reuseKey);
84
+ } catch (const std::exception& exc) {
85
+ throw std::runtime_error(std::string("ChartWebview.reuseKey: ") + exc.what());
86
+ }
87
+ }()),
88
+ pooled([&]() -> CachedProp<std::optional<bool>> {
89
+ try {
90
+ const react::RawValue* rawValue = rawProps.at("pooled", nullptr, nullptr);
91
+ if (rawValue == nullptr) return sourceProps.pooled;
92
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
93
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.pooled);
94
+ } catch (const std::exception& exc) {
95
+ throw std::runtime_error(std::string("ChartWebview.pooled: ") + exc.what());
96
+ }
97
+ }()),
98
+ active([&]() -> CachedProp<std::optional<bool>> {
99
+ try {
100
+ const react::RawValue* rawValue = rawProps.at("active", nullptr, nullptr);
101
+ if (rawValue == nullptr) return sourceProps.active;
102
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
103
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.active);
104
+ } catch (const std::exception& exc) {
105
+ throw std::runtime_error(std::string("ChartWebview.active: ") + exc.what());
106
+ }
107
+ }()),
108
+ onMessage([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> {
109
+ try {
110
+ const react::RawValue* rawValue = rawProps.at("onMessage", nullptr, nullptr);
111
+ if (rawValue == nullptr) return sourceProps.onMessage;
112
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
113
+ return CachedProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onMessage);
114
+ } catch (const std::exception& exc) {
115
+ throw std::runtime_error(std::string("ChartWebview.onMessage: ") + exc.what());
116
+ }
117
+ }()),
118
+ onLoadEnd([&]() -> CachedProp<std::optional<std::function<void()>>> {
119
+ try {
120
+ const react::RawValue* rawValue = rawProps.at("onLoadEnd", nullptr, nullptr);
121
+ if (rawValue == nullptr) return sourceProps.onLoadEnd;
122
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
123
+ return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onLoadEnd);
124
+ } catch (const std::exception& exc) {
125
+ throw std::runtime_error(std::string("ChartWebview.onLoadEnd: ") + exc.what());
126
+ }
127
+ }()),
128
+ onError([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> {
129
+ try {
130
+ const react::RawValue* rawValue = rawProps.at("onError", nullptr, nullptr);
131
+ if (rawValue == nullptr) return sourceProps.onError;
132
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
133
+ return CachedProp<std::optional<std::function<void(const std::string& /* message */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onError);
134
+ } catch (const std::exception& exc) {
135
+ throw std::runtime_error(std::string("ChartWebview.onError: ") + exc.what());
136
+ }
137
+ }()),
138
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>> {
139
+ try {
140
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
141
+ if (rawValue == nullptr) return sourceProps.hybridRef;
142
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
143
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
144
+ } catch (const std::exception& exc) {
145
+ throw std::runtime_error(std::string("ChartWebview.hybridRef: ") + exc.what());
146
+ }
147
+ }()) { }
148
+
149
+ HybridChartWebviewProps::HybridChartWebviewProps(const HybridChartWebviewProps& other):
150
+ react::ViewProps(),
151
+ uri(other.uri),
152
+ localBundle(other.localBundle),
153
+ entry(other.entry),
154
+ paramsJson(other.paramsJson),
155
+ bridgeScript(other.bridgeScript),
156
+ reuseKey(other.reuseKey),
157
+ pooled(other.pooled),
158
+ active(other.active),
159
+ onMessage(other.onMessage),
160
+ onLoadEnd(other.onLoadEnd),
161
+ onError(other.onError),
162
+ hybridRef(other.hybridRef) { }
163
+
164
+ bool HybridChartWebviewProps::filterObjectKeys(const std::string& propName) {
165
+ switch (hashString(propName)) {
166
+ case hashString("uri"): return true;
167
+ case hashString("localBundle"): return true;
168
+ case hashString("entry"): return true;
169
+ case hashString("paramsJson"): return true;
170
+ case hashString("bridgeScript"): return true;
171
+ case hashString("reuseKey"): return true;
172
+ case hashString("pooled"): return true;
173
+ case hashString("active"): return true;
174
+ case hashString("onMessage"): return true;
175
+ case hashString("onLoadEnd"): return true;
176
+ case hashString("onError"): return true;
177
+ case hashString("hybridRef"): return true;
178
+ default: return false;
179
+ }
180
+ }
181
+
182
+ HybridChartWebviewComponentDescriptor::HybridChartWebviewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
183
+ : ConcreteComponentDescriptor(parameters,
184
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
185
+
186
+ std::shared_ptr<const react::Props> HybridChartWebviewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
187
+ const std::shared_ptr<const react::Props>& props,
188
+ react::RawProps rawProps) const {
189
+ // 1. Prepare raw props parser
190
+ rawProps.parse(rawPropsParser_);
191
+ // 2. Copy props with Nitro's cached copy constructor
192
+ return HybridChartWebviewShadowNode::Props(context, /* & */ rawProps, props);
193
+ }
194
+
195
+ #ifdef ANDROID
196
+ void HybridChartWebviewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
197
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
198
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
199
+ auto& concreteShadowNode = dynamic_cast<HybridChartWebviewShadowNode&>(shadowNode);
200
+ const HybridChartWebviewProps& props = concreteShadowNode.getConcreteProps();
201
+ HybridChartWebviewState state;
202
+ state.setProps(props);
203
+ concreteShadowNode.setStateData(std::move(state));
204
+ }
205
+ #endif
206
+
207
+ } // namespace margelo::nitro::chartwebview::views
@@ -0,0 +1,118 @@
1
+ ///
2
+ /// HybridChartWebviewComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <string>
20
+ #include <optional>
21
+ #include <functional>
22
+ #include <memory>
23
+ #include "HybridChartWebviewSpec.hpp"
24
+
25
+ namespace margelo::nitro::chartwebview::views {
26
+
27
+ using namespace facebook;
28
+
29
+ /**
30
+ * The name of the actual native View.
31
+ */
32
+ extern const char HybridChartWebviewComponentName[];
33
+
34
+ /**
35
+ * Props for the "ChartWebview" View.
36
+ */
37
+ class HybridChartWebviewProps final: public react::ViewProps {
38
+ public:
39
+ HybridChartWebviewProps() = default;
40
+ HybridChartWebviewProps(const HybridChartWebviewProps&);
41
+ HybridChartWebviewProps(const react::PropsParserContext& context,
42
+ const HybridChartWebviewProps& sourceProps,
43
+ const react::RawProps& rawProps);
44
+
45
+ public:
46
+ CachedProp<std::optional<std::string>> uri;
47
+ CachedProp<std::optional<std::string>> localBundle;
48
+ CachedProp<std::optional<std::string>> entry;
49
+ CachedProp<std::optional<std::string>> paramsJson;
50
+ CachedProp<std::optional<std::string>> bridgeScript;
51
+ CachedProp<std::optional<std::string>> reuseKey;
52
+ CachedProp<std::optional<bool>> pooled;
53
+ CachedProp<std::optional<bool>> active;
54
+ CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> onMessage;
55
+ CachedProp<std::optional<std::function<void()>>> onLoadEnd;
56
+ CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> onError;
57
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridChartWebviewSpec>& /* ref */)>>> hybridRef;
58
+
59
+ private:
60
+ static bool filterObjectKeys(const std::string& propName);
61
+ };
62
+
63
+ /**
64
+ * State for the "ChartWebview" View.
65
+ */
66
+ class HybridChartWebviewState final {
67
+ public:
68
+ HybridChartWebviewState() = default;
69
+
70
+ public:
71
+ void setProps(const HybridChartWebviewProps& props) { _props.emplace(props); }
72
+ const std::optional<HybridChartWebviewProps>& getProps() const { return _props; }
73
+
74
+ public:
75
+ #ifdef ANDROID
76
+ HybridChartWebviewState(const HybridChartWebviewState& /* previousState */, folly::dynamic /* data */) {}
77
+ folly::dynamic getDynamic() const {
78
+ throw std::runtime_error("HybridChartWebviewState does not support folly!");
79
+ }
80
+ react::MapBuffer getMapBuffer() const {
81
+ throw std::runtime_error("HybridChartWebviewState does not support MapBuffer!");
82
+ };
83
+ #endif
84
+
85
+ private:
86
+ std::optional<HybridChartWebviewProps> _props;
87
+ };
88
+
89
+ /**
90
+ * The Shadow Node for the "ChartWebview" View.
91
+ */
92
+ using HybridChartWebviewShadowNode = react::ConcreteViewShadowNode<HybridChartWebviewComponentName /* "HybridChartWebview" */,
93
+ HybridChartWebviewProps /* custom props */,
94
+ react::ViewEventEmitter /* default */,
95
+ HybridChartWebviewState /* custom state */>;
96
+
97
+ /**
98
+ * The Component Descriptor for the "ChartWebview" View.
99
+ */
100
+ class HybridChartWebviewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridChartWebviewShadowNode> {
101
+ public:
102
+ HybridChartWebviewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
103
+
104
+ public:
105
+ /**
106
+ * A faster path for cloning props - reuses the caching logic from `HybridChartWebviewProps`.
107
+ */
108
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
109
+ const std::shared_ptr<const react::Props>& props,
110
+ react::RawProps rawProps) const override;
111
+ #ifdef ANDROID
112
+ void adopt(react::ShadowNode& shadowNode) const override;
113
+ #endif
114
+ };
115
+
116
+ /* The actual view for "ChartWebview" needs to be implemented in platform-specific code. */
117
+
118
+ } // namespace margelo::nitro::chartwebview::views
@@ -0,0 +1,20 @@
1
+ {
2
+ "uiViewClassName": "ChartWebview",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "uri": true,
8
+ "localBundle": true,
9
+ "entry": true,
10
+ "paramsJson": true,
11
+ "bridgeScript": true,
12
+ "reuseKey": true,
13
+ "pooled": true,
14
+ "active": true,
15
+ "onMessage": true,
16
+ "onLoadEnd": true,
17
+ "onError": true,
18
+ "hybridRef": true
19
+ }
20
+ }
package/package.json ADDED
@@ -0,0 +1,170 @@
1
+ {
2
+ "name": "@onekeyfe/react-native-chart-webview",
3
+ "version": "3.0.39",
4
+ "description": "react-native-chart-webview",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "nitrogen",
22
+ "nitro.json",
23
+ "*.podspec",
24
+ "react-native.config.js",
25
+ "!ios/build",
26
+ "!android/build",
27
+ "!android/gradle",
28
+ "!android/gradlew",
29
+ "!android/gradlew.bat",
30
+ "!android/local.properties",
31
+ "!**/__tests__",
32
+ "!**/__fixtures__",
33
+ "!**/__mocks__",
34
+ "!**/.*"
35
+ ],
36
+ "scripts": {
37
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
38
+ "prepare": "bob build && cp -r nitrogen lib/nitrogen",
39
+ "nitrogen": "nitrogen",
40
+ "typecheck": "tsc",
41
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
42
+ "test": "jest",
43
+ "release": "yarn nitrogen && yarn prepare && npm whoami && npm publish --access public"
44
+ },
45
+ "keywords": [
46
+ "react-native",
47
+ "ios",
48
+ "android"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/OneKeyHQ/native-views/react-native-chart-webview.git"
53
+ },
54
+ "author": "@onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
55
+ "license": "MIT",
56
+ "bugs": {
57
+ "url": "https://github.com/OneKeyHQ/native-views/react-native-chart-webview/issues"
58
+ },
59
+ "homepage": "https://github.com/OneKeyHQ/native-views/react-native-chart-webview#readme",
60
+ "publishConfig": {
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "devDependencies": {
64
+ "@commitlint/config-conventional": "^19.8.1",
65
+ "@eslint/compat": "^1.3.2",
66
+ "@eslint/eslintrc": "^3.3.1",
67
+ "@eslint/js": "^9.35.0",
68
+ "@react-native/babel-preset": "0.83.0",
69
+ "@react-native/eslint-config": "0.83.0",
70
+ "@release-it/conventional-changelog": "^10.0.1",
71
+ "@types/jest": "^29.5.14",
72
+ "@types/react": "^19.2.0",
73
+ "commitlint": "^19.8.1",
74
+ "del-cli": "^6.0.0",
75
+ "eslint": "^9.35.0",
76
+ "eslint-config-prettier": "^10.1.8",
77
+ "eslint-plugin-prettier": "^5.5.4",
78
+ "jest": "^29.7.0",
79
+ "lefthook": "^2.0.3",
80
+ "nitrogen": "0.31.10",
81
+ "prettier": "^2.8.8",
82
+ "react": "19.2.0",
83
+ "react-native": "patch:react-native@npm%3A0.83.0#~/.yarn/patches/react-native-npm-0.83.0-577d0f2d83.patch",
84
+ "react-native-builder-bob": "^0.40.13",
85
+ "react-native-nitro-modules": "0.33.2",
86
+ "release-it": "^19.0.4",
87
+ "turbo": "^2.5.6",
88
+ "typescript": "^5.9.2"
89
+ },
90
+ "peerDependencies": {
91
+ "react": "*",
92
+ "react-native": "*",
93
+ "react-native-nitro-modules": "0.33.2"
94
+ },
95
+ "packageManager": "yarn@4.11.0",
96
+ "react-native-builder-bob": {
97
+ "source": "src",
98
+ "output": "lib",
99
+ "targets": [
100
+ [
101
+ "custom",
102
+ {
103
+ "script": "nitrogen",
104
+ "clean": "nitrogen/"
105
+ }
106
+ ],
107
+ [
108
+ "module",
109
+ {
110
+ "esm": true
111
+ }
112
+ ],
113
+ [
114
+ "typescript",
115
+ {
116
+ "project": "tsconfig.build.json"
117
+ }
118
+ ]
119
+ ]
120
+ },
121
+ "prettier": {
122
+ "quoteProps": "consistent",
123
+ "singleQuote": true,
124
+ "tabWidth": 2,
125
+ "trailingComma": "es5",
126
+ "useTabs": false
127
+ },
128
+ "jest": {
129
+ "preset": "react-native",
130
+ "modulePathIgnorePatterns": [
131
+ "<rootDir>/example/node_modules",
132
+ "<rootDir>/lib/"
133
+ ]
134
+ },
135
+ "commitlint": {
136
+ "extends": [
137
+ "@commitlint/config-conventional"
138
+ ]
139
+ },
140
+ "release-it": {
141
+ "git": {
142
+ "commitMessage": "chore: release ${version}",
143
+ "tagName": "v${version}"
144
+ },
145
+ "npm": {
146
+ "publish": true
147
+ },
148
+ "github": {
149
+ "release": true
150
+ },
151
+ "plugins": {
152
+ "@release-it/conventional-changelog": {
153
+ "preset": {
154
+ "name": "angular"
155
+ }
156
+ }
157
+ }
158
+ },
159
+ "create-react-native-library": {
160
+ "type": "nitro-view",
161
+ "languages": "kotlin-swift",
162
+ "tools": [
163
+ "eslint",
164
+ "jest",
165
+ "lefthook",
166
+ "release-it"
167
+ ],
168
+ "version": "0.56.0"
169
+ }
170
+ }
@@ -0,0 +1,59 @@
1
+ import type {
2
+ HybridView,
3
+ HybridViewMethods,
4
+ HybridViewProps,
5
+ } from 'react-native-nitro-modules';
6
+
7
+ // A dumb WebView host + message pipe. It knows nothing about TradingView: it
8
+ // loads a `source`, injects messages into the page, and surfaces messages from
9
+ // the page. All protocol/data logic lives in the JS business layer.
10
+ export interface ChartWebviewProps extends HybridViewProps {
11
+ // --- Source (exactly one mode) ---
12
+ // Remote: load this URL directly.
13
+ uri?: string;
14
+ // Offline: serve `localBundle` (a folder bundled in the app) from a virtual
15
+ // same-origin (iOS onekey-chart:// / Android appassets https) and navigate to
16
+ // `entry` (default "index.html") with `paramsJson` as the query string.
17
+ localBundle?: string;
18
+ entry?: string;
19
+ // Query params for the entry, as a JSON object string (e.g.
20
+ // '{"symbol":"BTC","type":"market","theme":"dark"}'). Kept as a string so the
21
+ // native side stays free of a structured-prop dependency.
22
+ paramsJson?: string;
23
+
24
+ // JS injected into the page at document-start (before any page JS), wiring the
25
+ // page's outbound channels to the native transport. Single source of truth in
26
+ // the TS layer (see CHART_BRIDGE_JS); the native side only adds a tiny
27
+ // platform transport shim. Defaulted by the JS wrapper so it's always present.
28
+ bridgeScript?: string;
29
+
30
+ // --- Singleton ---
31
+ // Reuse group: same key shares one live WebView (market / perps each one).
32
+ reuseKey?: string;
33
+ // Opt into the shared singleton pool. Off -> every view owns its WebView.
34
+ pooled?: boolean;
35
+ // Arbitration signal for who holds the shared WebView when multiple hosts
36
+ // share a key (from useIsFocused). Native attach claims first; this resolves
37
+ // ambiguity. NOTE: not named `isActive` — an `is`-prefixed boolean prop makes
38
+ // Kotlin emit `setActive`/`isActive` accessors while Nitro's JNI binding
39
+ // hardcodes `setIsActive`/`getIsActive`, causing a NoSuchMethodError at runtime.
40
+ active?: boolean;
41
+
42
+ // --- Events ---
43
+ // page -> JS, raw JSON string (the JS layer parses the $private payload).
44
+ onMessage?: (message: string) => void;
45
+ onLoadEnd?: () => void;
46
+ onError?: (message: string) => void;
47
+ }
48
+
49
+ export interface ChartWebviewMethods extends HybridViewMethods {
50
+ // JS -> page: injects `window.postMessage(message)`. `message` is a raw JSON
51
+ // string built by the JS business layer.
52
+ postMessage(message: string): void;
53
+ reload(): void;
54
+ // Drop the cached frame snapshot used to mask the reparent (move) flash, and
55
+ // remove any visible overlay. Call to free the bitmap or force a fresh capture.
56
+ clearSnapshot(): void;
57
+ }
58
+
59
+ export type ChartWebview = HybridView<ChartWebviewProps, ChartWebviewMethods>;
package/src/bridge.ts ADDED
@@ -0,0 +1,27 @@
1
+ // The bridge script injected at document-start into the chart WebView (before any
2
+ // page JS runs). It wires the chart's outbound channels to a single native
3
+ // transport hook, `window.__chartNativePost(payloadString)`, which each platform
4
+ // defines in a tiny shim (Android -> AndroidChartBridge, iOS -> WKScriptMessage).
5
+ //
6
+ // This is the single source of truth shared by iOS and Android — the native
7
+ // layers receive it via the `bridgeScript` prop instead of each hardcoding their
8
+ // own copy (which previously drifted between platforms).
9
+ //
10
+ // Outbound channels wired:
11
+ // - window.$onekey.$private.request(payload) (native platform path)
12
+ // - window.ReactNativeWebView.postMessage(str)
13
+ // - window 'message' events scoped to `$private`
14
+ export const CHART_BRIDGE_JS = `(function(){
15
+ if (window.__onekeyChartBridge) return; window.__onekeyChartBridge = true;
16
+ var fwd = function(m){
17
+ try { window.__chartNativePost(typeof m === 'string' ? m : JSON.stringify(m)); } catch (e) {}
18
+ };
19
+ window.$onekey = window.$onekey || {};
20
+ window.$onekey.$private = window.$onekey.$private || {};
21
+ window.$onekey.$private.request = function(m){ fwd(m); };
22
+ window.ReactNativeWebView = window.ReactNativeWebView || {};
23
+ window.ReactNativeWebView.postMessage = function(s){ fwd(String(s)); };
24
+ window.addEventListener('message', function(e){
25
+ try { var d = e && e.data; if (d && d.scope === '$private') fwd(d); } catch (err) {}
26
+ });
27
+ })();`;
package/src/index.tsx ADDED
@@ -0,0 +1,20 @@
1
+ import { createElement, type ComponentProps } from 'react';
2
+ import { getHostComponent } from 'react-native-nitro-modules';
3
+ const ChartWebviewConfig = require('../nitrogen/generated/shared/json/ChartWebviewConfig.json');
4
+ import type { ChartWebviewMethods, ChartWebviewProps } from './ChartWebview.nitro';
5
+ import { CHART_BRIDGE_JS } from './bridge';
6
+
7
+ export type { ChartWebviewMethods, ChartWebviewProps } from './ChartWebview.nitro';
8
+ export { CHART_BRIDGE_JS } from './bridge';
9
+
10
+ const NativeChartWebviewView = getHostComponent<ChartWebviewProps, ChartWebviewMethods>(
11
+ 'ChartWebview',
12
+ () => ChartWebviewConfig
13
+ );
14
+
15
+ // Default the document-start bridge script so consumers never have to know about
16
+ // it (and it's never absent — an optional string flipping to null is rejected by
17
+ // the native binding). Callers can still override `bridgeScript` to customize.
18
+ export function ChartWebviewView(props: ComponentProps<typeof NativeChartWebviewView>) {
19
+ return createElement(NativeChartWebviewView, { bridgeScript: CHART_BRIDGE_JS, ...props });
20
+ }