@onekeyfe/react-native-chart-webview 3.0.63 → 3.0.64

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 (49) hide show
  1. package/ChartWebview.podspec +3 -0
  2. package/android/src/main/java/com/margelo/nitro/chartwebview/ChartWebview.kt +85 -18
  3. package/android/src/main/java/com/margelo/nitro/chartwebview/PooledChartWebView.kt +253 -26
  4. package/ios/ChartWebview.swift +190 -31
  5. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +18 -0
  6. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +4 -0
  7. package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +8 -0
  8. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +12 -0
  9. package/lib/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +14 -0
  10. package/lib/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +10 -0
  11. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +2 -0
  12. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +48 -0
  13. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +4 -0
  14. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +4 -0
  15. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +24 -0
  16. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +2 -0
  17. package/lib/nitrogen/generated/shared/json/ChartWebviewConfig.json +2 -0
  18. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +18 -0
  19. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +4 -0
  20. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +8 -0
  21. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +12 -0
  22. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +14 -0
  23. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +10 -0
  24. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +2 -0
  25. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +48 -0
  26. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +4 -0
  27. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +4 -0
  28. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +24 -0
  29. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +2 -0
  30. package/lib/nitrogen/nitrogen/generated/shared/json/ChartWebviewConfig.json +2 -0
  31. package/lib/typescript/src/ChartWebview.nitro.d.ts +2 -0
  32. package/lib/typescript/src/ChartWebview.nitro.d.ts.map +1 -1
  33. package/lib/typescript/src/index.d.ts +2 -0
  34. package/lib/typescript/src/index.d.ts.map +1 -1
  35. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +18 -0
  36. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +4 -0
  37. package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +8 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +12 -0
  39. package/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +14 -0
  40. package/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +10 -0
  41. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +2 -0
  42. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +48 -0
  43. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +4 -0
  44. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +4 -0
  45. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +24 -0
  46. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +2 -0
  47. package/nitrogen/generated/shared/json/ChartWebviewConfig.json +2 -0
  48. package/package.json +1 -1
  49. package/src/ChartWebview.nitro.ts +18 -0
@@ -91,6 +91,11 @@ using namespace margelo::nitro::chartwebview::views;
91
91
  swiftPart.setParamsJson(newViewProps.paramsJson.value);
92
92
  newViewProps.paramsJson.isDirty = false;
93
93
  }
94
+ // assetHost: optional
95
+ if (newViewProps.assetHost.isDirty) {
96
+ swiftPart.setAssetHost(newViewProps.assetHost.value);
97
+ newViewProps.assetHost.isDirty = false;
98
+ }
94
99
  // bridgeScript: optional
95
100
  if (newViewProps.bridgeScript.isDirty) {
96
101
  swiftPart.setBridgeScript(newViewProps.bridgeScript.value);
@@ -111,6 +116,11 @@ using namespace margelo::nitro::chartwebview::views;
111
116
  swiftPart.setActive(newViewProps.active.value);
112
117
  newViewProps.active.isDirty = false;
113
118
  }
119
+ // webviewDebuggingEnabled: optional
120
+ if (newViewProps.webviewDebuggingEnabled.isDirty) {
121
+ swiftPart.setWebviewDebuggingEnabled(newViewProps.webviewDebuggingEnabled.value);
122
+ newViewProps.webviewDebuggingEnabled.isDirty = false;
123
+ }
114
124
  // onMessage: optional
115
125
  if (newViewProps.onMessage.isDirty) {
116
126
  swiftPart.setOnMessage(newViewProps.onMessage.value);
@@ -15,10 +15,12 @@ public protocol HybridChartWebviewSpec_protocol: HybridObject, HybridView {
15
15
  var localBundle: String? { get set }
16
16
  var entry: String? { get set }
17
17
  var paramsJson: String? { get set }
18
+ var assetHost: String? { get set }
18
19
  var bridgeScript: String? { get set }
19
20
  var reuseKey: String? { get set }
20
21
  var pooled: Bool? { get set }
21
22
  var active: Bool? { get set }
23
+ var webviewDebuggingEnabled: Bool? { get set }
22
24
  var onMessage: ((_ message: String) -> Void)? { get set }
23
25
  var onLoadEnd: (() -> Void)? { get set }
24
26
  var onError: ((_ message: String) -> Void)? { get set }
@@ -210,6 +210,30 @@ open class HybridChartWebviewSpec_cxx {
210
210
  }
211
211
  }
212
212
 
213
+ public final var assetHost: bridge.std__optional_std__string_ {
214
+ @inline(__always)
215
+ get {
216
+ return { () -> bridge.std__optional_std__string_ in
217
+ if let __unwrappedValue = self.__implementation.assetHost {
218
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
219
+ } else {
220
+ return .init()
221
+ }
222
+ }()
223
+ }
224
+ @inline(__always)
225
+ set {
226
+ self.__implementation.assetHost = { () -> String? in
227
+ if bridge.has_value_std__optional_std__string_(newValue) {
228
+ let __unwrapped = bridge.get_std__optional_std__string_(newValue)
229
+ return String(__unwrapped)
230
+ } else {
231
+ return nil
232
+ }
233
+ }()
234
+ }
235
+ }
236
+
213
237
  public final var bridgeScript: bridge.std__optional_std__string_ {
214
238
  @inline(__always)
215
239
  get {
@@ -306,6 +330,30 @@ open class HybridChartWebviewSpec_cxx {
306
330
  }
307
331
  }
308
332
 
333
+ public final var webviewDebuggingEnabled: bridge.std__optional_bool_ {
334
+ @inline(__always)
335
+ get {
336
+ return { () -> bridge.std__optional_bool_ in
337
+ if let __unwrappedValue = self.__implementation.webviewDebuggingEnabled {
338
+ return bridge.create_std__optional_bool_(__unwrappedValue)
339
+ } else {
340
+ return .init()
341
+ }
342
+ }()
343
+ }
344
+ @inline(__always)
345
+ set {
346
+ self.__implementation.webviewDebuggingEnabled = { () -> Bool? in
347
+ if bridge.has_value_std__optional_bool_(newValue) {
348
+ let __unwrapped = bridge.get_std__optional_bool_(newValue)
349
+ return __unwrapped
350
+ } else {
351
+ return nil
352
+ }
353
+ }()
354
+ }
355
+ }
356
+
309
357
  public final var onMessage: bridge.std__optional_std__function_void_const_std__string_____message______ {
310
358
  @inline(__always)
311
359
  get {
@@ -22,6 +22,8 @@ namespace margelo::nitro::chartwebview {
22
22
  prototype.registerHybridSetter("entry", &HybridChartWebviewSpec::setEntry);
23
23
  prototype.registerHybridGetter("paramsJson", &HybridChartWebviewSpec::getParamsJson);
24
24
  prototype.registerHybridSetter("paramsJson", &HybridChartWebviewSpec::setParamsJson);
25
+ prototype.registerHybridGetter("assetHost", &HybridChartWebviewSpec::getAssetHost);
26
+ prototype.registerHybridSetter("assetHost", &HybridChartWebviewSpec::setAssetHost);
25
27
  prototype.registerHybridGetter("bridgeScript", &HybridChartWebviewSpec::getBridgeScript);
26
28
  prototype.registerHybridSetter("bridgeScript", &HybridChartWebviewSpec::setBridgeScript);
27
29
  prototype.registerHybridGetter("reuseKey", &HybridChartWebviewSpec::getReuseKey);
@@ -30,6 +32,8 @@ namespace margelo::nitro::chartwebview {
30
32
  prototype.registerHybridSetter("pooled", &HybridChartWebviewSpec::setPooled);
31
33
  prototype.registerHybridGetter("active", &HybridChartWebviewSpec::getActive);
32
34
  prototype.registerHybridSetter("active", &HybridChartWebviewSpec::setActive);
35
+ prototype.registerHybridGetter("webviewDebuggingEnabled", &HybridChartWebviewSpec::getWebviewDebuggingEnabled);
36
+ prototype.registerHybridSetter("webviewDebuggingEnabled", &HybridChartWebviewSpec::setWebviewDebuggingEnabled);
33
37
  prototype.registerHybridGetter("onMessage", &HybridChartWebviewSpec::getOnMessage);
34
38
  prototype.registerHybridSetter("onMessage", &HybridChartWebviewSpec::setOnMessage);
35
39
  prototype.registerHybridGetter("onLoadEnd", &HybridChartWebviewSpec::getOnLoadEnd);
@@ -54,6 +54,8 @@ namespace margelo::nitro::chartwebview {
54
54
  virtual void setEntry(const std::optional<std::string>& entry) = 0;
55
55
  virtual std::optional<std::string> getParamsJson() = 0;
56
56
  virtual void setParamsJson(const std::optional<std::string>& paramsJson) = 0;
57
+ virtual std::optional<std::string> getAssetHost() = 0;
58
+ virtual void setAssetHost(const std::optional<std::string>& assetHost) = 0;
57
59
  virtual std::optional<std::string> getBridgeScript() = 0;
58
60
  virtual void setBridgeScript(const std::optional<std::string>& bridgeScript) = 0;
59
61
  virtual std::optional<std::string> getReuseKey() = 0;
@@ -62,6 +64,8 @@ namespace margelo::nitro::chartwebview {
62
64
  virtual void setPooled(std::optional<bool> pooled) = 0;
63
65
  virtual std::optional<bool> getActive() = 0;
64
66
  virtual void setActive(std::optional<bool> active) = 0;
67
+ virtual std::optional<bool> getWebviewDebuggingEnabled() = 0;
68
+ virtual void setWebviewDebuggingEnabled(std::optional<bool> webviewDebuggingEnabled) = 0;
65
69
  virtual std::optional<std::function<void(const std::string& /* message */)>> getOnMessage() = 0;
66
70
  virtual void setOnMessage(const std::optional<std::function<void(const std::string& /* message */)>>& onMessage) = 0;
67
71
  virtual std::optional<std::function<void()>> getOnLoadEnd() = 0;
@@ -65,6 +65,16 @@ namespace margelo::nitro::chartwebview::views {
65
65
  throw std::runtime_error(std::string("ChartWebview.paramsJson: ") + exc.what());
66
66
  }
67
67
  }()),
68
+ assetHost([&]() -> CachedProp<std::optional<std::string>> {
69
+ try {
70
+ const react::RawValue* rawValue = rawProps.at("assetHost", nullptr, nullptr);
71
+ if (rawValue == nullptr) return sourceProps.assetHost;
72
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
73
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.assetHost);
74
+ } catch (const std::exception& exc) {
75
+ throw std::runtime_error(std::string("ChartWebview.assetHost: ") + exc.what());
76
+ }
77
+ }()),
68
78
  bridgeScript([&]() -> CachedProp<std::optional<std::string>> {
69
79
  try {
70
80
  const react::RawValue* rawValue = rawProps.at("bridgeScript", nullptr, nullptr);
@@ -105,6 +115,16 @@ namespace margelo::nitro::chartwebview::views {
105
115
  throw std::runtime_error(std::string("ChartWebview.active: ") + exc.what());
106
116
  }
107
117
  }()),
118
+ webviewDebuggingEnabled([&]() -> CachedProp<std::optional<bool>> {
119
+ try {
120
+ const react::RawValue* rawValue = rawProps.at("webviewDebuggingEnabled", nullptr, nullptr);
121
+ if (rawValue == nullptr) return sourceProps.webviewDebuggingEnabled;
122
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
123
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.webviewDebuggingEnabled);
124
+ } catch (const std::exception& exc) {
125
+ throw std::runtime_error(std::string("ChartWebview.webviewDebuggingEnabled: ") + exc.what());
126
+ }
127
+ }()),
108
128
  onMessage([&]() -> CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> {
109
129
  try {
110
130
  const react::RawValue* rawValue = rawProps.at("onMessage", nullptr, nullptr);
@@ -152,10 +172,12 @@ namespace margelo::nitro::chartwebview::views {
152
172
  localBundle(other.localBundle),
153
173
  entry(other.entry),
154
174
  paramsJson(other.paramsJson),
175
+ assetHost(other.assetHost),
155
176
  bridgeScript(other.bridgeScript),
156
177
  reuseKey(other.reuseKey),
157
178
  pooled(other.pooled),
158
179
  active(other.active),
180
+ webviewDebuggingEnabled(other.webviewDebuggingEnabled),
159
181
  onMessage(other.onMessage),
160
182
  onLoadEnd(other.onLoadEnd),
161
183
  onError(other.onError),
@@ -167,10 +189,12 @@ namespace margelo::nitro::chartwebview::views {
167
189
  case hashString("localBundle"): return true;
168
190
  case hashString("entry"): return true;
169
191
  case hashString("paramsJson"): return true;
192
+ case hashString("assetHost"): return true;
170
193
  case hashString("bridgeScript"): return true;
171
194
  case hashString("reuseKey"): return true;
172
195
  case hashString("pooled"): return true;
173
196
  case hashString("active"): return true;
197
+ case hashString("webviewDebuggingEnabled"): return true;
174
198
  case hashString("onMessage"): return true;
175
199
  case hashString("onLoadEnd"): return true;
176
200
  case hashString("onError"): return true;
@@ -47,10 +47,12 @@ namespace margelo::nitro::chartwebview::views {
47
47
  CachedProp<std::optional<std::string>> localBundle;
48
48
  CachedProp<std::optional<std::string>> entry;
49
49
  CachedProp<std::optional<std::string>> paramsJson;
50
+ CachedProp<std::optional<std::string>> assetHost;
50
51
  CachedProp<std::optional<std::string>> bridgeScript;
51
52
  CachedProp<std::optional<std::string>> reuseKey;
52
53
  CachedProp<std::optional<bool>> pooled;
53
54
  CachedProp<std::optional<bool>> active;
55
+ CachedProp<std::optional<bool>> webviewDebuggingEnabled;
54
56
  CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> onMessage;
55
57
  CachedProp<std::optional<std::function<void()>>> onLoadEnd;
56
58
  CachedProp<std::optional<std::function<void(const std::string& /* message */)>>> onError;
@@ -8,10 +8,12 @@
8
8
  "localBundle": true,
9
9
  "entry": true,
10
10
  "paramsJson": true,
11
+ "assetHost": true,
11
12
  "bridgeScript": true,
12
13
  "reuseKey": true,
13
14
  "pooled": true,
14
15
  "active": true,
16
+ "webviewDebuggingEnabled": true,
15
17
  "onMessage": true,
16
18
  "onLoadEnd": true,
17
19
  "onError": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-chart-webview",
3
- "version": "3.0.63",
3
+ "version": "3.0.64",
4
4
  "description": "react-native-chart-webview",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -20,6 +20,14 @@ export interface ChartWebviewProps extends HybridViewProps {
20
20
  // '{"symbol":"BTC","type":"market","theme":"dark"}'). Kept as a string so the
21
21
  // native side stays free of a structured-prop dependency.
22
22
  paramsJson?: string;
23
+ // ANDROID ONLY: the host the offline `localBundle` is served under, so Android
24
+ // can reuse the real TradingView origin (e.g. "tradingview.onekey.so") and read
25
+ // the existing same-origin WebView storage with zero migration. When omitted,
26
+ // Android falls back to the built-in "appassets.androidplatform.net" host
27
+ // (identical to the old behavior). IGNORED on iOS, which always serves offline
28
+ // content from the onekey-chart:// custom scheme (https can't be intercepted
29
+ // there).
30
+ assetHost?: string;
23
31
 
24
32
  // JS injected into the page at document-start (before any page JS), wiring the
25
33
  // page's outbound channels to the native transport. Single source of truth in
@@ -39,6 +47,16 @@ export interface ChartWebviewProps extends HybridViewProps {
39
47
  // hardcodes `setIsActive`/`getIsActive`, causing a NoSuchMethodError at runtime.
40
48
  active?: boolean;
41
49
 
50
+ // --- Debugging ---
51
+ // Make the backing WebView inspectable (Safari Web Inspector on iOS,
52
+ // chrome://inspect on Android). Driven by the app's "Enable Native Webview
53
+ // Debugging" dev-mode toggle, mirroring how the main react-native-webview
54
+ // honors it. When omitted, the native side defaults to its dev-build default
55
+ // (iOS DEBUG / Android leaves it off). NOTE (Android): the underlying call
56
+ // WebView.setWebContentsDebuggingEnabled is PROCESS-GLOBAL — once any WebView
57
+ // enables it, it stays enabled process-wide until the app is killed.
58
+ webviewDebuggingEnabled?: boolean;
59
+
42
60
  // --- Events ---
43
61
  // page -> JS, raw JSON string (the JS layer parses the $private payload).
44
62
  onMessage?: (message: string) => void;