@onekeyfe/react-native-perp-depth-bar 3.0.49 → 3.0.52

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 (51) hide show
  1. package/android/src/main/java/com/margelo/nitro/perpdepthbar/HybridPerpDepthBars.kt +98 -11
  2. package/android/src/main/java/com/margelo/nitro/perpdepthbar/HybridPerpSideRatio.kt +17 -6
  3. package/ios/HybridPerpDepthBars.swift +56 -5
  4. package/ios/HybridPerpSideRatio.swift +7 -1
  5. package/ios/PerpColorParser.swift +10 -1
  6. package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +40 -0
  7. package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +5 -0
  8. package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +8 -0
  9. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +16 -0
  10. package/lib/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +19 -0
  11. package/lib/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +10 -0
  12. package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +3 -0
  13. package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +33 -0
  14. package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +5 -0
  15. package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +5 -0
  16. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +24 -0
  17. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +2 -0
  18. package/lib/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +2 -0
  19. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +40 -0
  20. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +5 -0
  21. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +8 -0
  22. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +16 -0
  23. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +19 -0
  24. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +10 -0
  25. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +3 -0
  26. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +33 -0
  27. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +5 -0
  28. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +5 -0
  29. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +24 -0
  30. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +2 -0
  31. package/lib/nitrogen/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +2 -0
  32. package/lib/typescript/src/PerpDepthBars.nitro.d.ts +64 -3
  33. package/lib/typescript/src/PerpDepthBars.nitro.d.ts.map +1 -1
  34. package/lib/typescript/src/PerpSideRatio.nitro.d.ts +12 -2
  35. package/lib/typescript/src/PerpSideRatio.nitro.d.ts.map +1 -1
  36. package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +40 -0
  37. package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +5 -0
  38. package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +8 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +16 -0
  40. package/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +19 -0
  41. package/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +10 -0
  42. package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +3 -0
  43. package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +33 -0
  44. package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +5 -0
  45. package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +5 -0
  46. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +24 -0
  47. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +2 -0
  48. package/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +2 -0
  49. package/package.json +1 -1
  50. package/src/PerpDepthBars.nitro.ts +66 -8
  51. package/src/PerpSideRatio.nitro.ts +12 -2
@@ -159,6 +159,19 @@ namespace margelo::nitro::perpdepthbar {
159
159
  inline void setTextInset(double textInset) noexcept override {
160
160
  _swiftPart.setTextInset(std::forward<decltype(textInset)>(textInset));
161
161
  }
162
+ inline std::string getPlaceholderText() noexcept override {
163
+ auto __result = _swiftPart.getPlaceholderText();
164
+ return __result;
165
+ }
166
+ inline void setPlaceholderText(const std::string& placeholderText) noexcept override {
167
+ _swiftPart.setPlaceholderText(placeholderText);
168
+ }
169
+ inline double getPlaceholderRows() noexcept override {
170
+ return _swiftPart.getPlaceholderRows();
171
+ }
172
+ inline void setPlaceholderRows(double placeholderRows) noexcept override {
173
+ _swiftPart.setPlaceholderRows(std::forward<decltype(placeholderRows)>(placeholderRows));
174
+ }
162
175
  inline std::optional<std::function<void(double /* rowIndex */)>> getOnRowPress() noexcept override {
163
176
  auto __result = _swiftPart.getOnRowPress();
164
177
  return __result;
@@ -175,6 +188,12 @@ namespace margelo::nitro::perpdepthbar {
175
188
  std::rethrow_exception(__result.error());
176
189
  }
177
190
  }
191
+ inline void setText(const std::vector<std::string>& prices, const std::vector<std::string>& sizes) override {
192
+ auto __result = _swiftPart.setText(prices, sizes);
193
+ if (__result.hasError()) [[unlikely]] {
194
+ std::rethrow_exception(__result.error());
195
+ }
196
+ }
178
197
 
179
198
  private:
180
199
  PerpDepthBar::HybridPerpDepthBarsSpec_cxx _swiftPart;
@@ -146,6 +146,16 @@ using namespace margelo::nitro::perpdepthbar::views;
146
146
  swiftPart.setTextInset(newViewProps.textInset.value);
147
147
  newViewProps.textInset.isDirty = false;
148
148
  }
149
+ // placeholderText: string
150
+ if (newViewProps.placeholderText.isDirty) {
151
+ swiftPart.setPlaceholderText(newViewProps.placeholderText.value);
152
+ newViewProps.placeholderText.isDirty = false;
153
+ }
154
+ // placeholderRows: number
155
+ if (newViewProps.placeholderRows.isDirty) {
156
+ swiftPart.setPlaceholderRows(newViewProps.placeholderRows.value);
157
+ newViewProps.placeholderRows.isDirty = false;
158
+ }
149
159
  // onRowPress: optional
150
160
  if (newViewProps.onRowPress.isDirty) {
151
161
  swiftPart.setOnRowPress(newViewProps.onRowPress.value);
@@ -26,10 +26,13 @@ public protocol HybridPerpDepthBarsSpec_protocol: HybridObject, HybridView {
26
26
  var priceFontSize: Double { get set }
27
27
  var sizeFontSize: Double { get set }
28
28
  var textInset: Double { get set }
29
+ var placeholderText: String { get set }
30
+ var placeholderRows: Double { get set }
29
31
  var onRowPress: ((_ rowIndex: Double) -> Void)? { get set }
30
32
 
31
33
  // Methods
32
34
  func setDepth(buffer: ArrayBuffer) throws -> Void
35
+ func setText(prices: [String], sizes: [String]) throws -> Void
33
36
  }
34
37
 
35
38
  public extension HybridPerpDepthBarsSpec_protocol {
@@ -297,6 +297,28 @@ open class HybridPerpDepthBarsSpec_cxx {
297
297
  }
298
298
  }
299
299
 
300
+ public final var placeholderText: std.string {
301
+ @inline(__always)
302
+ get {
303
+ return std.string(self.__implementation.placeholderText)
304
+ }
305
+ @inline(__always)
306
+ set {
307
+ self.__implementation.placeholderText = String(newValue)
308
+ }
309
+ }
310
+
311
+ public final var placeholderRows: Double {
312
+ @inline(__always)
313
+ get {
314
+ return self.__implementation.placeholderRows
315
+ }
316
+ @inline(__always)
317
+ set {
318
+ self.__implementation.placeholderRows = newValue
319
+ }
320
+ }
321
+
300
322
  public final var onRowPress: bridge.std__optional_std__function_void_double____rowIndex______ {
301
323
  @inline(__always)
302
324
  get {
@@ -341,6 +363,17 @@ open class HybridPerpDepthBarsSpec_cxx {
341
363
  }
342
364
  }
343
365
 
366
+ @inline(__always)
367
+ public final func setText(prices: bridge.std__vector_std__string_, sizes: bridge.std__vector_std__string_) -> bridge.Result_void_ {
368
+ do {
369
+ try self.__implementation.setText(prices: prices.map({ __item in String(__item) }), sizes: sizes.map({ __item in String(__item) }))
370
+ return bridge.create_Result_void_()
371
+ } catch (let __error) {
372
+ let __exceptionPtr = __error.toCpp()
373
+ return bridge.create_Result_void_(__exceptionPtr)
374
+ }
375
+ }
376
+
344
377
  public final func getView() -> UnsafeMutableRawPointer {
345
378
  return Unmanaged.passRetained(__implementation.view).toOpaque()
346
379
  }
@@ -44,9 +44,14 @@ namespace margelo::nitro::perpdepthbar {
44
44
  prototype.registerHybridSetter("sizeFontSize", &HybridPerpDepthBarsSpec::setSizeFontSize);
45
45
  prototype.registerHybridGetter("textInset", &HybridPerpDepthBarsSpec::getTextInset);
46
46
  prototype.registerHybridSetter("textInset", &HybridPerpDepthBarsSpec::setTextInset);
47
+ prototype.registerHybridGetter("placeholderText", &HybridPerpDepthBarsSpec::getPlaceholderText);
48
+ prototype.registerHybridSetter("placeholderText", &HybridPerpDepthBarsSpec::setPlaceholderText);
49
+ prototype.registerHybridGetter("placeholderRows", &HybridPerpDepthBarsSpec::getPlaceholderRows);
50
+ prototype.registerHybridSetter("placeholderRows", &HybridPerpDepthBarsSpec::setPlaceholderRows);
47
51
  prototype.registerHybridGetter("onRowPress", &HybridPerpDepthBarsSpec::getOnRowPress);
48
52
  prototype.registerHybridSetter("onRowPress", &HybridPerpDepthBarsSpec::setOnRowPress);
49
53
  prototype.registerHybridMethod("setDepth", &HybridPerpDepthBarsSpec::setDepth);
54
+ prototype.registerHybridMethod("setText", &HybridPerpDepthBarsSpec::setText);
50
55
  });
51
56
  }
52
57
 
@@ -78,12 +78,17 @@ namespace margelo::nitro::perpdepthbar {
78
78
  virtual void setSizeFontSize(double sizeFontSize) = 0;
79
79
  virtual double getTextInset() = 0;
80
80
  virtual void setTextInset(double textInset) = 0;
81
+ virtual std::string getPlaceholderText() = 0;
82
+ virtual void setPlaceholderText(const std::string& placeholderText) = 0;
83
+ virtual double getPlaceholderRows() = 0;
84
+ virtual void setPlaceholderRows(double placeholderRows) = 0;
81
85
  virtual std::optional<std::function<void(double /* rowIndex */)>> getOnRowPress() = 0;
82
86
  virtual void setOnRowPress(const std::optional<std::function<void(double /* rowIndex */)>>& onRowPress) = 0;
83
87
 
84
88
  public:
85
89
  // Methods
86
90
  virtual void setDepth(const std::shared_ptr<ArrayBuffer>& buffer) = 0;
91
+ virtual void setText(const std::vector<std::string>& prices, const std::vector<std::string>& sizes) = 0;
87
92
 
88
93
  protected:
89
94
  // Hybrid Setup
@@ -175,6 +175,26 @@ namespace margelo::nitro::perpdepthbar::views {
175
175
  throw std::runtime_error(std::string("PerpDepthBars.textInset: ") + exc.what());
176
176
  }
177
177
  }()),
178
+ placeholderText([&]() -> CachedProp<std::string> {
179
+ try {
180
+ const react::RawValue* rawValue = rawProps.at("placeholderText", nullptr, nullptr);
181
+ if (rawValue == nullptr) return sourceProps.placeholderText;
182
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
183
+ return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.placeholderText);
184
+ } catch (const std::exception& exc) {
185
+ throw std::runtime_error(std::string("PerpDepthBars.placeholderText: ") + exc.what());
186
+ }
187
+ }()),
188
+ placeholderRows([&]() -> CachedProp<double> {
189
+ try {
190
+ const react::RawValue* rawValue = rawProps.at("placeholderRows", nullptr, nullptr);
191
+ if (rawValue == nullptr) return sourceProps.placeholderRows;
192
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
193
+ return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.placeholderRows);
194
+ } catch (const std::exception& exc) {
195
+ throw std::runtime_error(std::string("PerpDepthBars.placeholderRows: ") + exc.what());
196
+ }
197
+ }()),
178
198
  onRowPress([&]() -> CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> {
179
199
  try {
180
200
  const react::RawValue* rawValue = rawProps.at("onRowPress", nullptr, nullptr);
@@ -213,6 +233,8 @@ namespace margelo::nitro::perpdepthbar::views {
213
233
  priceFontSize(other.priceFontSize),
214
234
  sizeFontSize(other.sizeFontSize),
215
235
  textInset(other.textInset),
236
+ placeholderText(other.placeholderText),
237
+ placeholderRows(other.placeholderRows),
216
238
  onRowPress(other.onRowPress),
217
239
  hybridRef(other.hybridRef) { }
218
240
 
@@ -233,6 +255,8 @@ namespace margelo::nitro::perpdepthbar::views {
233
255
  case hashString("priceFontSize"): return true;
234
256
  case hashString("sizeFontSize"): return true;
235
257
  case hashString("textInset"): return true;
258
+ case hashString("placeholderText"): return true;
259
+ case hashString("placeholderRows"): return true;
236
260
  case hashString("onRowPress"): return true;
237
261
  case hashString("hybridRef"): return true;
238
262
  default: return false;
@@ -59,6 +59,8 @@ namespace margelo::nitro::perpdepthbar::views {
59
59
  CachedProp<double> priceFontSize;
60
60
  CachedProp<double> sizeFontSize;
61
61
  CachedProp<double> textInset;
62
+ CachedProp<std::string> placeholderText;
63
+ CachedProp<double> placeholderRows;
62
64
  CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> onRowPress;
63
65
  CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> hybridRef;
64
66
 
@@ -19,6 +19,8 @@
19
19
  "priceFontSize": true,
20
20
  "sizeFontSize": true,
21
21
  "textInset": true,
22
+ "placeholderText": true,
23
+ "placeholderRows": true,
22
24
  "onRowPress": true,
23
25
  "hybridRef": true
24
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-perp-depth-bar",
3
- "version": "3.0.49",
3
+ "version": "3.0.52",
4
4
  "description": "react-native-perp-depth-bar",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -16,7 +16,17 @@ import type {
16
16
  * All values are in points (DIP); the native side quantizes to physical pixels.
17
17
  */
18
18
  export interface PerpDepthBarsProps extends HybridViewProps {
19
- /** Depth percentage per row, 0..100. Length == number of rows on this side. */
19
+ /**
20
+ * Depth percentage per row, 0..100. Length == number of rows on this side.
21
+ *
22
+ * INITIAL VALUE ONLY when using the imperative path. The first
23
+ * `setDepth(buffer)` call switches the view into imperative mode; from then on
24
+ * this prop is IGNORED on every prop-update transaction (so unrelated
25
+ * high-frequency prop commits like `prices`/`sizes` can't wipe the bars —
26
+ * REACT-NATIVE-1JZ). For high-frequency depth updates ALWAYS call `setDepth`;
27
+ * do NOT keep writing this prop at tick rate. Callers that never call
28
+ * `setDepth` may drive the bars purely through this prop (each write retargets).
29
+ */
20
30
  percents: number[];
21
31
  /** Row height in points (matches the sibling RN text row height). */
22
32
  rowHeight: number;
@@ -36,14 +46,28 @@ export interface PerpDepthBarsProps extends HybridViewProps {
36
46
  */
37
47
  epoch: number;
38
48
 
39
- // --- Per-row text (optional). When `prices`/`sizes` are empty the view
40
- // renders bars only (backward compatible). When provided they are drawn
41
- // natively per row price left-aligned, size right-aligned, vertically
42
- // centred so the order-book ladder needs NO sibling RN <Text> rows.
43
- // Each array is parallel to `percents` (same length / order).
44
- /** Formatted price string per row (e.g. "1981.4"). */
49
+ /**
50
+ * Per-row price text, parallel to `percents` (same length / order). Drawn
51
+ * natively per row (price left-aligned), so the order-book ladder needs NO
52
+ * sibling RN <Text> rows. Empty => the view renders bars only.
53
+ *
54
+ * INITIAL VALUE ONLY for high-frequency callers: the first `setText` call
55
+ * switches the text layer into imperative mode and this prop is then IGNORED on
56
+ * every prop-update transaction. For high-frequency text updates ALWAYS call
57
+ * `setText`; do NOT keep writing this prop at tick rate (string-array prop
58
+ * commits are the heaviest part of the Fabric props + JSI path — exactly what
59
+ * REACT-NATIVE-1JZ avoids). Callers that update infrequently may drive it
60
+ * purely through this prop.
61
+ */
45
62
  prices: string[];
46
- /** Formatted size string per row (e.g. "389.04"). */
63
+ /**
64
+ * Per-row size text, parallel to `percents`. Drawn natively per row (size
65
+ * right-aligned). Empty => bars only.
66
+ *
67
+ * INITIAL VALUE ONLY for high-frequency callers: update via `setText`; this
68
+ * prop is IGNORED once `setText` has been called (see `prices` —
69
+ * REACT-NATIVE-1JZ).
70
+ */
47
71
  sizes: string[];
48
72
  /** Price text color: hex or rgba()/rgb(). */
49
73
  priceColor: string;
@@ -56,6 +80,24 @@ export interface PerpDepthBarsProps extends HybridViewProps {
56
80
  /** Horizontal text inset in points (price padding-left, size padding-right). */
57
81
  textInset: number;
58
82
 
83
+ /**
84
+ * Per-row placeholder text drawn while the column has NO real data (no rows
85
+ * from `percents`/`setDepth` and no `prices`/`sizes`/`setText`), e.g. "--".
86
+ * Empty string disables the placeholder. This replaces any RN skeleton/overlay:
87
+ * the view draws the placeholder itself, then atomically swaps to real numbers
88
+ * the moment data lands — so there is never a blank frame between the two
89
+ * (the old overlay approach removed the JS skeleton a few frames before the
90
+ * native view had painted, flashing blank). Drawn in `priceColor` (left) and
91
+ * `sizeColor` (right); no bar fill.
92
+ */
93
+ placeholderText: string;
94
+ /**
95
+ * How many placeholder rows to draw when `placeholderText` is shown. Match the
96
+ * order book's rows-per-side so the column reserves a stable height before any
97
+ * data arrives. Ignored once real data is present.
98
+ */
99
+ placeholderRows: number;
100
+
59
101
  /**
60
102
  * Fired natively when a row is tapped. `rowIndex` is the 0-based row
61
103
  * (top→bottom, parallel to `percents`/`prices`/`sizes`). The view handles
@@ -82,6 +124,22 @@ export interface PerpDepthBarsMethods extends HybridViewMethods {
82
124
  * use either path.
83
125
  */
84
126
  setDepth(buffer: ArrayBuffer): void;
127
+
128
+ /**
129
+ * Imperatively update the per-row price/size text, bypassing the
130
+ * high-frequency `prices`/`sizes` prop write path (and its props/JSICache lock
131
+ * contention — REACT-NATIVE-1JZ). Companion to [setDepth] for the text layer.
132
+ *
133
+ * `prices[i]` / `sizes[i]` are the formatted strings for row `i`, parallel to
134
+ * the depth buffer pushed via `setDepth` (same length / order). Pass `[]` for a
135
+ * side that draws bars only. Call this in the SAME frame/effect as `setDepth`
136
+ * so the bar fill and its row text always come from one source frame (no
137
+ * fill-vs-text misalignment).
138
+ *
139
+ * The `prices`/`sizes` props are retained for backward compatibility; callers
140
+ * may use either path.
141
+ */
142
+ setText(prices: string[], sizes: string[]): void;
85
143
  }
86
144
 
87
145
  export type PerpDepthBars = HybridView<PerpDepthBarsProps, PerpDepthBarsMethods>;
@@ -11,9 +11,19 @@ import type {
11
11
  * alignment risk is low.
12
12
  */
13
13
  export interface PerpSideRatioProps extends HybridViewProps {
14
- /** Bid (long) share, 0..100. */
14
+ /**
15
+ * Bid (long) share, 0..100. INITIAL VALUE ONLY for high-frequency callers:
16
+ * the first `setRatio` call switches the view into imperative mode and this
17
+ * prop is then ignored, so unrelated prop commits can't reset the split to the
18
+ * static initial value (REACT-NATIVE-1JZ). Update via `setRatio`. Callers that
19
+ * update infrequently may drive it purely through this prop.
20
+ */
15
21
  bidPercentage: number;
16
- /** Ask (short) share, 0..100. */
22
+ /**
23
+ * Ask (short) share, 0..100. INITIAL VALUE ONLY for high-frequency callers:
24
+ * this prop is IGNORED once `setRatio` has been called; update via `setRatio`
25
+ * (see `bidPercentage` — REACT-NATIVE-1JZ).
26
+ */
17
27
  askPercentage: number;
18
28
  /** Resolved long (bid) color. */
19
29
  longColor: string;