@onekeyfe/react-native-chart-webview 3.0.56 → 3.0.57

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 (48) hide show
  1. package/android/src/main/java/com/margelo/nitro/chartwebview/ChartWebview.kt +13 -4
  2. package/android/src/main/java/com/margelo/nitro/chartwebview/PooledChartWebView.kt +46 -10
  3. package/ios/ChartWebview.swift +5 -0
  4. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +9 -0
  5. package/lib/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +2 -0
  6. package/lib/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +4 -0
  7. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +6 -0
  8. package/lib/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +7 -0
  9. package/lib/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +5 -0
  10. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +1 -0
  11. package/lib/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +24 -0
  12. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +2 -0
  13. package/lib/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +2 -0
  14. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +12 -0
  15. package/lib/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +1 -0
  16. package/lib/nitrogen/generated/shared/json/ChartWebviewConfig.json +1 -0
  17. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +9 -0
  18. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +2 -0
  19. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +4 -0
  20. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +6 -0
  21. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +7 -0
  22. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +5 -0
  23. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +1 -0
  24. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +24 -0
  25. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +2 -0
  26. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +2 -0
  27. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +12 -0
  28. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +1 -0
  29. package/lib/nitrogen/nitrogen/generated/shared/json/ChartWebviewConfig.json +1 -0
  30. package/lib/typescript/src/ChartWebview.nitro.d.ts +1 -0
  31. package/lib/typescript/src/ChartWebview.nitro.d.ts.map +1 -1
  32. package/lib/typescript/src/index.d.ts +1 -0
  33. package/lib/typescript/src/index.d.ts.map +1 -1
  34. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.cpp +9 -0
  35. package/nitrogen/generated/android/c++/JHybridChartWebviewSpec.hpp +2 -0
  36. package/nitrogen/generated/android/c++/views/JHybridChartWebviewStateUpdater.cpp +4 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/chartwebview/HybridChartWebviewSpec.kt +6 -0
  38. package/nitrogen/generated/ios/c++/HybridChartWebviewSpecSwift.hpp +7 -0
  39. package/nitrogen/generated/ios/c++/views/HybridChartWebviewComponent.mm +5 -0
  40. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec.swift +1 -0
  41. package/nitrogen/generated/ios/swift/HybridChartWebviewSpec_cxx.swift +24 -0
  42. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.cpp +2 -0
  43. package/nitrogen/generated/shared/c++/HybridChartWebviewSpec.hpp +2 -0
  44. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.cpp +12 -0
  45. package/nitrogen/generated/shared/c++/views/HybridChartWebviewComponent.hpp +1 -0
  46. package/nitrogen/generated/shared/json/ChartWebviewConfig.json +1 -0
  47. package/package.json +1 -1
  48. package/src/ChartWebview.nitro.ts +8 -0
@@ -123,6 +123,15 @@ class HybridChartWebview(val context: ThemedReactContext) : HybridChartWebviewSp
123
123
  get() = _paramsJson
124
124
  set(value) { _paramsJson = value; applySource() }
125
125
 
126
+ // ANDROID: the host the offline `localBundle` is served under. When set, the
127
+ // offline bundle is served from https://<assetHost>/ so the WebView reuses the
128
+ // real chart origin's same-origin storage (zero migration). Falls back to the
129
+ // built-in appassets host in the pool when null. (iOS ignores this prop.)
130
+ private var _assetHost: String? = null
131
+ override var assetHost: String?
132
+ get() = _assetHost
133
+ set(value) { _assetHost = value; applySource() }
134
+
126
135
  // Document-start bridge JS (single source of truth in the TS layer). Stored and
127
136
  // handed to the pooled WebView when we claim it, before its first load.
128
137
  private var _bridgeScript: String? = null
@@ -259,7 +268,7 @@ class HybridChartWebview(val context: ThemedReactContext) : HybridChartWebviewSp
259
268
  if (!bs.isNullOrEmpty()) {
260
269
  entry.setBridgeScript(bs)
261
270
  entry.warmDriver = this
262
- entry.setSource(_uri, _localBundle, _entry, _paramsJson)
271
+ entry.setSource(_uri, _localBundle, _entry, _paramsJson, _assetHost)
263
272
  }
264
273
  if (wantsOwnership()) {
265
274
  entry.owner = this
@@ -299,7 +308,7 @@ class HybridChartWebview(val context: ThemedReactContext) : HybridChartWebviewSp
299
308
  pooled.owner = this
300
309
  pooled.setBridgeScript(_bridgeScript ?: "")
301
310
  pooled.attachTo(container)
302
- pooled.setSource(_uri, _localBundle, _entry, _paramsJson)
311
+ pooled.setSource(_uri, _localBundle, _entry, _paramsJson, _assetHost)
303
312
  }
304
313
 
305
314
  // Apply the source synchronously when a source/bridge prop changes. For a
@@ -315,10 +324,10 @@ class HybridChartWebview(val context: ThemedReactContext) : HybridChartWebviewSp
315
324
  if (isPooled() && !bs.isNullOrEmpty()) {
316
325
  pooled.setBridgeScript(bs)
317
326
  pooled.warmDriver = this
318
- pooled.setSource(_uri, _localBundle, _entry, _paramsJson)
327
+ pooled.setSource(_uri, _localBundle, _entry, _paramsJson, _assetHost)
319
328
  } else if (pooled.owner == this) {
320
329
  pooled.setBridgeScript(_bridgeScript ?: "")
321
- pooled.setSource(_uri, _localBundle, _entry, _paramsJson)
330
+ pooled.setSource(_uri, _localBundle, _entry, _paramsJson, _assetHost)
322
331
  }
323
332
  }
324
333
 
@@ -126,12 +126,12 @@ class PooledChartWebView private constructor(
126
126
  }
127
127
 
128
128
  // The trusted origin set for the current source: the offline asset origin
129
- // (https://appassets.androidplatform.net) always, plus the online/fallback
130
- // `uri` origin when running in online mode. computeTargetUrl serves offline
131
- // content from ASSET_HOST and online content from `uri`, so these are exactly
132
- // the origins the privileged bridge legitimately runs in.
129
+ // (https://<assetHost>, default appassets.androidplatform.net) always, plus the
130
+ // online/fallback `uri` origin when running in online mode. computeTargetUrl
131
+ // serves offline content from `assetHost` and online content from `uri`, so
132
+ // these are exactly the origins the privileged bridge legitimately runs in.
133
133
  private fun trustedOriginsFor(uri: String?): Set<String> {
134
- val origins = linkedSetOf("https://$ASSET_HOST")
134
+ val origins = linkedSetOf("https://$assetHost")
135
135
  originOf(uri)?.let { origins.add(it) }
136
136
  return origins
137
137
  }
@@ -212,6 +212,13 @@ class PooledChartWebView private constructor(
212
212
  private var assetLoader: WebViewAssetLoader? = null
213
213
  private var lastLoadedUrl: String? = null
214
214
  private var lastLocalBundle: String? = null
215
+ // The host the offline bundle is served under. Defaults to the built-in
216
+ // appassets host (old behavior); when the app passes `assetHost` we serve the
217
+ // bundle under the real chart origin so the WebView reuses that origin's
218
+ // same-origin storage (zero migration). Tracked so an assetHost change rebuilds
219
+ // the asset loader + recomputes the target URL, same as a localBundle change.
220
+ private var assetHost: String = ASSET_HOST
221
+ private var lastAssetHost: String = ASSET_HOST
215
222
 
216
223
  // Last rendered frame, used to mask the brief blank frame while the WebView's
217
224
  // surface is torn down and recreated during a reparent (move). Kept until
@@ -515,13 +522,23 @@ class PooledChartWebView private constructor(
515
522
  * so reparenting / redundant prop re-applies never reload (which would lose
516
523
  * chart state, the whole point of pooling).
517
524
  */
518
- fun setSource(uri: String?, localBundle: String?, entry: String?, paramsJson: String?) {
525
+ fun setSource(
526
+ uri: String?,
527
+ localBundle: String?,
528
+ entry: String?,
529
+ paramsJson: String?,
530
+ assetHost: String?,
531
+ ) {
519
532
  // Never load before the document-start bridge is registered — otherwise the
520
533
  // page boots without the bridge and its first $private requests are lost. The
521
534
  // host re-calls setSource once the bridgeScript prop arrives.
522
535
  if (!bridgeRegistered) return
523
- if (localBundle != lastLocalBundle) {
536
+ // Per-instance asset host: fall back to the built-in appassets host (old
537
+ // behavior) when the app doesn't pass one. Empty string is treated as absent.
538
+ this.assetHost = assetHost?.takeIf { it.isNotEmpty() } ?: ASSET_HOST
539
+ if (localBundle != lastLocalBundle || this.assetHost != lastAssetHost) {
524
540
  lastLocalBundle = localBundle
541
+ lastAssetHost = this.assetHost
525
542
  rebuildAssetLoader(localBundle)
526
543
  }
527
544
  // Register the document-start bridge scoped to exactly the origin(s) this load
@@ -572,9 +589,28 @@ class PooledChartWebView private constructor(
572
589
  assetLoader = null
573
590
  return
574
591
  }
592
+ // Narrow the path handler to ONLY the offline bundle subtree
593
+ // (/<localBundle>/, e.g. /tradingview-assets/) instead of intercepting all of
594
+ // "/". When the bundle is served under the real chart origin (`assetHost`),
595
+ // intercepting "/" would shadow every web path on that domain; with the narrow
596
+ // handler, unmatched paths fall through to the network — so an `assetHost`
597
+ // that is a real public domain keeps behaving normally off-bundle.
598
+ // computeTargetUrl produces https://<assetHost>/<localBundle>/<entry>, which
599
+ // stays inside this handler's path. (Path built as /<localBundle>/ so a
600
+ // localBundle that already has a trailing slash doesn't double it.)
601
+ val bundleDir = localBundle.trim('/')
602
+ val bundlePath = "/$bundleDir/"
603
+ // WebViewAssetLoader strips the registered prefix before calling the handler,
604
+ // so AssetsPathHandler alone would resolve the remainder against the assets
605
+ // ROOT (assets/<entry>) and lose the bundle namespace. Re-prepend <bundleDir>/
606
+ // so we still serve from assets/<localBundle>/<entry>. Returning null on a
607
+ // miss lets WebViewAssetLoader fall through to the network.
608
+ val assets = WebViewAssetLoader.AssetsPathHandler(webView.context)
609
+ val namespacedHandler =
610
+ WebViewAssetLoader.PathHandler { suffix -> assets.handle("$bundleDir/$suffix") }
575
611
  assetLoader = WebViewAssetLoader.Builder()
576
- .setDomain(ASSET_HOST)
577
- .addPathHandler("/", WebViewAssetLoader.AssetsPathHandler(webView.context))
612
+ .setDomain(assetHost)
613
+ .addPathHandler(bundlePath, namespacedHandler)
578
614
  .build()
579
615
  }
580
616
 
@@ -590,7 +626,7 @@ class PooledChartWebView private constructor(
590
626
  val query = buildQueryFromParamsJson(paramsJson)
591
627
  return buildString {
592
628
  append("https://")
593
- append(ASSET_HOST)
629
+ append(assetHost)
594
630
  append('/')
595
631
  // Serve the offline bundle from assets/<localBundle>/ (namespaced) rather
596
632
  // than the assets root, so it doesn't collide with other bundled assets
@@ -129,6 +129,11 @@ class HybridChartWebview: HybridChartWebviewSpec {
129
129
  var localBundle: String? { didSet { applySource() } }
130
130
  var entry: String? { didSet { applySource() } }
131
131
  var paramsJson: String? { didSet { applySource() } }
132
+ // ANDROID ONLY. iOS serves offline content from the onekey-chart:// custom
133
+ // scheme (https can't be intercepted here), so this host stores the prop to
134
+ // satisfy the generated spec but never reads it — offline origin/behavior is
135
+ // unchanged on iOS.
136
+ var assetHost: String?
132
137
 
133
138
  // Document-start bridge JS (single source of truth in the TS layer). Handed to
134
139
  // the pooled WebView when we claim it, before its first load.
@@ -81,6 +81,15 @@ namespace margelo::nitro::chartwebview {
81
81
  static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* paramsJson */)>("setParamsJson");
82
82
  method(_javaPart, paramsJson.has_value() ? jni::make_jstring(paramsJson.value()) : nullptr);
83
83
  }
84
+ std::optional<std::string> JHybridChartWebviewSpec::getAssetHost() {
85
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAssetHost");
86
+ auto __result = method(_javaPart);
87
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
88
+ }
89
+ void JHybridChartWebviewSpec::setAssetHost(const std::optional<std::string>& assetHost) {
90
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* assetHost */)>("setAssetHost");
91
+ method(_javaPart, assetHost.has_value() ? jni::make_jstring(assetHost.value()) : nullptr);
92
+ }
84
93
  std::optional<std::string> JHybridChartWebviewSpec::getBridgeScript() {
85
94
  static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBridgeScript");
86
95
  auto __result = method(_javaPart);
@@ -58,6 +58,8 @@ namespace margelo::nitro::chartwebview {
58
58
  void setEntry(const std::optional<std::string>& entry) override;
59
59
  std::optional<std::string> getParamsJson() override;
60
60
  void setParamsJson(const std::optional<std::string>& paramsJson) override;
61
+ std::optional<std::string> getAssetHost() override;
62
+ void setAssetHost(const std::optional<std::string>& assetHost) override;
61
63
  std::optional<std::string> getBridgeScript() override;
62
64
  void setBridgeScript(const std::optional<std::string>& bridgeScript) override;
63
65
  std::optional<std::string> getReuseKey() override;
@@ -52,6 +52,10 @@ void JHybridChartWebviewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass
52
52
  view->setParamsJson(props.paramsJson.value);
53
53
  // TODO: Set isDirty = false
54
54
  }
55
+ if (props.assetHost.isDirty) {
56
+ view->setAssetHost(props.assetHost.value);
57
+ // TODO: Set isDirty = false
58
+ }
55
59
  if (props.bridgeScript.isDirty) {
56
60
  view->setBridgeScript(props.bridgeScript.value);
57
61
  // TODO: Set isDirty = false
@@ -66,6 +66,12 @@ abstract class HybridChartWebviewSpec: HybridView() {
66
66
  @set:Keep
67
67
  abstract var paramsJson: String?
68
68
 
69
+ @get:DoNotStrip
70
+ @get:Keep
71
+ @set:DoNotStrip
72
+ @set:Keep
73
+ abstract var assetHost: String?
74
+
69
75
  @get:DoNotStrip
70
76
  @get:Keep
71
77
  @set:DoNotStrip
@@ -86,6 +86,13 @@ namespace margelo::nitro::chartwebview {
86
86
  inline void setParamsJson(const std::optional<std::string>& paramsJson) noexcept override {
87
87
  _swiftPart.setParamsJson(paramsJson);
88
88
  }
89
+ inline std::optional<std::string> getAssetHost() noexcept override {
90
+ auto __result = _swiftPart.getAssetHost();
91
+ return __result;
92
+ }
93
+ inline void setAssetHost(const std::optional<std::string>& assetHost) noexcept override {
94
+ _swiftPart.setAssetHost(assetHost);
95
+ }
89
96
  inline std::optional<std::string> getBridgeScript() noexcept override {
90
97
  auto __result = _swiftPart.getBridgeScript();
91
98
  return __result;
@@ -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);
@@ -15,6 +15,7 @@ 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 }
@@ -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 {
@@ -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);
@@ -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;
@@ -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);
@@ -162,6 +172,7 @@ namespace margelo::nitro::chartwebview::views {
162
172
  localBundle(other.localBundle),
163
173
  entry(other.entry),
164
174
  paramsJson(other.paramsJson),
175
+ assetHost(other.assetHost),
165
176
  bridgeScript(other.bridgeScript),
166
177
  reuseKey(other.reuseKey),
167
178
  pooled(other.pooled),
@@ -178,6 +189,7 @@ namespace margelo::nitro::chartwebview::views {
178
189
  case hashString("localBundle"): return true;
179
190
  case hashString("entry"): return true;
180
191
  case hashString("paramsJson"): return true;
192
+ case hashString("assetHost"): return true;
181
193
  case hashString("bridgeScript"): return true;
182
194
  case hashString("reuseKey"): return true;
183
195
  case hashString("pooled"): return true;
@@ -47,6 +47,7 @@ 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;
@@ -8,6 +8,7 @@
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,
@@ -81,6 +81,15 @@ namespace margelo::nitro::chartwebview {
81
81
  static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* paramsJson */)>("setParamsJson");
82
82
  method(_javaPart, paramsJson.has_value() ? jni::make_jstring(paramsJson.value()) : nullptr);
83
83
  }
84
+ std::optional<std::string> JHybridChartWebviewSpec::getAssetHost() {
85
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAssetHost");
86
+ auto __result = method(_javaPart);
87
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
88
+ }
89
+ void JHybridChartWebviewSpec::setAssetHost(const std::optional<std::string>& assetHost) {
90
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* assetHost */)>("setAssetHost");
91
+ method(_javaPart, assetHost.has_value() ? jni::make_jstring(assetHost.value()) : nullptr);
92
+ }
84
93
  std::optional<std::string> JHybridChartWebviewSpec::getBridgeScript() {
85
94
  static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBridgeScript");
86
95
  auto __result = method(_javaPart);
@@ -58,6 +58,8 @@ namespace margelo::nitro::chartwebview {
58
58
  void setEntry(const std::optional<std::string>& entry) override;
59
59
  std::optional<std::string> getParamsJson() override;
60
60
  void setParamsJson(const std::optional<std::string>& paramsJson) override;
61
+ std::optional<std::string> getAssetHost() override;
62
+ void setAssetHost(const std::optional<std::string>& assetHost) override;
61
63
  std::optional<std::string> getBridgeScript() override;
62
64
  void setBridgeScript(const std::optional<std::string>& bridgeScript) override;
63
65
  std::optional<std::string> getReuseKey() override;
@@ -52,6 +52,10 @@ void JHybridChartWebviewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass
52
52
  view->setParamsJson(props.paramsJson.value);
53
53
  // TODO: Set isDirty = false
54
54
  }
55
+ if (props.assetHost.isDirty) {
56
+ view->setAssetHost(props.assetHost.value);
57
+ // TODO: Set isDirty = false
58
+ }
55
59
  if (props.bridgeScript.isDirty) {
56
60
  view->setBridgeScript(props.bridgeScript.value);
57
61
  // TODO: Set isDirty = false
@@ -66,6 +66,12 @@ abstract class HybridChartWebviewSpec: HybridView() {
66
66
  @set:Keep
67
67
  abstract var paramsJson: String?
68
68
 
69
+ @get:DoNotStrip
70
+ @get:Keep
71
+ @set:DoNotStrip
72
+ @set:Keep
73
+ abstract var assetHost: String?
74
+
69
75
  @get:DoNotStrip
70
76
  @get:Keep
71
77
  @set:DoNotStrip
@@ -86,6 +86,13 @@ namespace margelo::nitro::chartwebview {
86
86
  inline void setParamsJson(const std::optional<std::string>& paramsJson) noexcept override {
87
87
  _swiftPart.setParamsJson(paramsJson);
88
88
  }
89
+ inline std::optional<std::string> getAssetHost() noexcept override {
90
+ auto __result = _swiftPart.getAssetHost();
91
+ return __result;
92
+ }
93
+ inline void setAssetHost(const std::optional<std::string>& assetHost) noexcept override {
94
+ _swiftPart.setAssetHost(assetHost);
95
+ }
89
96
  inline std::optional<std::string> getBridgeScript() noexcept override {
90
97
  auto __result = _swiftPart.getBridgeScript();
91
98
  return __result;
@@ -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);
@@ -15,6 +15,7 @@ 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 }
@@ -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 {
@@ -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);
@@ -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;
@@ -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);
@@ -162,6 +172,7 @@ namespace margelo::nitro::chartwebview::views {
162
172
  localBundle(other.localBundle),
163
173
  entry(other.entry),
164
174
  paramsJson(other.paramsJson),
175
+ assetHost(other.assetHost),
165
176
  bridgeScript(other.bridgeScript),
166
177
  reuseKey(other.reuseKey),
167
178
  pooled(other.pooled),
@@ -178,6 +189,7 @@ namespace margelo::nitro::chartwebview::views {
178
189
  case hashString("localBundle"): return true;
179
190
  case hashString("entry"): return true;
180
191
  case hashString("paramsJson"): return true;
192
+ case hashString("assetHost"): return true;
181
193
  case hashString("bridgeScript"): return true;
182
194
  case hashString("reuseKey"): return true;
183
195
  case hashString("pooled"): return true;
@@ -47,6 +47,7 @@ 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;
@@ -8,6 +8,7 @@
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,
@@ -4,6 +4,7 @@ export interface ChartWebviewProps extends HybridViewProps {
4
4
  localBundle?: string;
5
5
  entry?: string;
6
6
  paramsJson?: string;
7
+ assetHost?: string;
7
8
  bridgeScript?: string;
8
9
  reuseKey?: string;
9
10
  pooled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ChartWebview.nitro.d.ts","sourceRoot":"","sources":["../../../src/ChartWebview.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAKpC,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IAGxD,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,OAAO,CAAC;IAMjB,MAAM,CAAC,EAAE,OAAO,CAAC;IAUjB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAIlC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAG5D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,IAAI,IAAI,CAAC;IAGf,aAAa,IAAI,IAAI,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"ChartWebview.nitro.d.ts","sourceRoot":"","sources":["../../../src/ChartWebview.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAKpC,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IAGxD,GAAG,CAAC,EAAE,MAAM,CAAC;IAIb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,UAAU,CAAC,EAAE,MAAM,CAAC;IAQpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAMnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,OAAO,CAAC;IAMjB,MAAM,CAAC,EAAE,OAAO,CAAC;IAUjB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAIlC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAG5D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,IAAI,IAAI,CAAC;IAGf,aAAa,IAAI,IAAI,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC"}
@@ -16,6 +16,7 @@ export declare function ChartWebviewView({ bridgeScript, hybridRef, onMessage, o
16
16
  localBundle?: string | undefined;
17
17
  entry?: string | undefined;
18
18
  paramsJson?: string | undefined;
19
+ assetHost?: string | undefined;
19
20
  bridgeScript?: string | undefined;
20
21
  reuseKey?: string | undefined;
21
22
  pooled?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGnF,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAO3C,KAAK,oBAAoB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,IACxD,CAAC,GACD,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAEhC,KAAK,qBAAqB,GAAG,IAAI,CAC/B,iBAAiB,EACjB,WAAW,GAAG,WAAW,GAAG,SAAS,CACtC,GACC,SAAS,GAAG;IACV,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,oBAAoB,CAAC,MAAM,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,oBAAoB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;CAC3D,CAAC;AAcJ,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACT,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGnF,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAO3C,KAAK,oBAAoB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,IACxD,CAAC,GACD,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAEhC,KAAK,qBAAqB,GAAG,IAAI,CAC/B,iBAAiB,EACjB,WAAW,GAAG,WAAW,GAAG,SAAS,CACtC,GACC,SAAS,GAAG;IACV,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,oBAAoB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,oBAAoB,CAAC,MAAM,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,oBAAoB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;CAC3D,CAAC;AAcJ,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACT,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDvB"}
@@ -81,6 +81,15 @@ namespace margelo::nitro::chartwebview {
81
81
  static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* paramsJson */)>("setParamsJson");
82
82
  method(_javaPart, paramsJson.has_value() ? jni::make_jstring(paramsJson.value()) : nullptr);
83
83
  }
84
+ std::optional<std::string> JHybridChartWebviewSpec::getAssetHost() {
85
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getAssetHost");
86
+ auto __result = method(_javaPart);
87
+ return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
88
+ }
89
+ void JHybridChartWebviewSpec::setAssetHost(const std::optional<std::string>& assetHost) {
90
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* assetHost */)>("setAssetHost");
91
+ method(_javaPart, assetHost.has_value() ? jni::make_jstring(assetHost.value()) : nullptr);
92
+ }
84
93
  std::optional<std::string> JHybridChartWebviewSpec::getBridgeScript() {
85
94
  static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getBridgeScript");
86
95
  auto __result = method(_javaPart);
@@ -58,6 +58,8 @@ namespace margelo::nitro::chartwebview {
58
58
  void setEntry(const std::optional<std::string>& entry) override;
59
59
  std::optional<std::string> getParamsJson() override;
60
60
  void setParamsJson(const std::optional<std::string>& paramsJson) override;
61
+ std::optional<std::string> getAssetHost() override;
62
+ void setAssetHost(const std::optional<std::string>& assetHost) override;
61
63
  std::optional<std::string> getBridgeScript() override;
62
64
  void setBridgeScript(const std::optional<std::string>& bridgeScript) override;
63
65
  std::optional<std::string> getReuseKey() override;
@@ -52,6 +52,10 @@ void JHybridChartWebviewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass
52
52
  view->setParamsJson(props.paramsJson.value);
53
53
  // TODO: Set isDirty = false
54
54
  }
55
+ if (props.assetHost.isDirty) {
56
+ view->setAssetHost(props.assetHost.value);
57
+ // TODO: Set isDirty = false
58
+ }
55
59
  if (props.bridgeScript.isDirty) {
56
60
  view->setBridgeScript(props.bridgeScript.value);
57
61
  // TODO: Set isDirty = false
@@ -66,6 +66,12 @@ abstract class HybridChartWebviewSpec: HybridView() {
66
66
  @set:Keep
67
67
  abstract var paramsJson: String?
68
68
 
69
+ @get:DoNotStrip
70
+ @get:Keep
71
+ @set:DoNotStrip
72
+ @set:Keep
73
+ abstract var assetHost: String?
74
+
69
75
  @get:DoNotStrip
70
76
  @get:Keep
71
77
  @set:DoNotStrip
@@ -86,6 +86,13 @@ namespace margelo::nitro::chartwebview {
86
86
  inline void setParamsJson(const std::optional<std::string>& paramsJson) noexcept override {
87
87
  _swiftPart.setParamsJson(paramsJson);
88
88
  }
89
+ inline std::optional<std::string> getAssetHost() noexcept override {
90
+ auto __result = _swiftPart.getAssetHost();
91
+ return __result;
92
+ }
93
+ inline void setAssetHost(const std::optional<std::string>& assetHost) noexcept override {
94
+ _swiftPart.setAssetHost(assetHost);
95
+ }
89
96
  inline std::optional<std::string> getBridgeScript() noexcept override {
90
97
  auto __result = _swiftPart.getBridgeScript();
91
98
  return __result;
@@ -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);
@@ -15,6 +15,7 @@ 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 }
@@ -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 {
@@ -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);
@@ -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;
@@ -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);
@@ -162,6 +172,7 @@ namespace margelo::nitro::chartwebview::views {
162
172
  localBundle(other.localBundle),
163
173
  entry(other.entry),
164
174
  paramsJson(other.paramsJson),
175
+ assetHost(other.assetHost),
165
176
  bridgeScript(other.bridgeScript),
166
177
  reuseKey(other.reuseKey),
167
178
  pooled(other.pooled),
@@ -178,6 +189,7 @@ namespace margelo::nitro::chartwebview::views {
178
189
  case hashString("localBundle"): return true;
179
190
  case hashString("entry"): return true;
180
191
  case hashString("paramsJson"): return true;
192
+ case hashString("assetHost"): return true;
181
193
  case hashString("bridgeScript"): return true;
182
194
  case hashString("reuseKey"): return true;
183
195
  case hashString("pooled"): return true;
@@ -47,6 +47,7 @@ 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;
@@ -8,6 +8,7 @@
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-chart-webview",
3
- "version": "3.0.56",
3
+ "version": "3.0.57",
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