@onekeyfe/react-native-native-list 3.0.179 → 3.0.180

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 (111) hide show
  1. package/LICENSE +36 -0
  2. package/README.md +32 -3
  3. package/android/build.gradle +0 -1
  4. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +22 -1
  5. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +8 -8
  6. package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +5 -5
  7. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +4 -4
  8. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +6 -6
  9. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +6 -1
  10. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +11 -11
  11. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +20 -20
  12. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +5 -4
  13. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +7 -7
  14. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +5 -5
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +8 -7
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +14 -14
  17. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +28 -15
  18. package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +4 -4
  19. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +3 -3
  20. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +3 -2
  21. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +5 -4
  22. package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +1 -1
  23. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +20 -20
  24. package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +3 -3
  25. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +104 -18
  26. package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +6 -5
  27. package/docs/SPEC.md +69 -0
  28. package/docs/STYLE_SPEC.md +12 -2
  29. package/ios/HybridNativeList.swift +18 -6
  30. package/ios/NativeListAccessoryStack.swift +14 -10
  31. package/ios/NativeListActionRenderer.swift +7 -4
  32. package/ios/NativeListActivityDetailsView.swift +63 -24
  33. package/ios/NativeListActivityRenderer.swift +19 -10
  34. package/ios/NativeListDataRowRenderer.swift +23 -19
  35. package/ios/NativeListDesignAssets.swift +43 -34
  36. package/ios/NativeListIdentityRenderer.swift +23 -19
  37. package/ios/NativeListLeadingVisual.swift +9 -4
  38. package/ios/NativeListMarketRenderer.swift +19 -11
  39. package/ios/NativeListMediaTileRenderer.swift +11 -7
  40. package/ios/NativeListMessageRenderer.swift +20 -10
  41. package/ios/NativeListMetricCardRenderer.swift +16 -12
  42. package/ios/NativeListRailRenderer.swift +9 -7
  43. package/ios/NativeListRendererCell.swift +6 -4
  44. package/ios/NativeListRendererRegistry.swift +8 -3
  45. package/ios/NativeListResolvedText.swift +3 -3
  46. package/ios/NativeListRowHost.swift +7 -2
  47. package/ios/NativeListSectionHeaderRenderer.swift +22 -19
  48. package/ios/NativeListSystemRenderer.swift +18 -16
  49. package/ios/NativeListTextStyles.swift +18 -12
  50. package/ios/NativeListWalletGroupRenderer.swift +6 -4
  51. package/ios/RNCNativeListView.swift +38 -5
  52. package/ios/tests/NativeListActivityPresentationTests.swift +5 -3
  53. package/ios/tests/NativeListLifecycleTests.swift +77 -2
  54. package/lib/module/NativeList.js +3 -0
  55. package/lib/module/NativeList.web.js +8 -1
  56. package/lib/module/fonts.js +44 -0
  57. package/lib/module/index.js +1 -0
  58. package/lib/module/web/NativeListWebEngine.js +48 -24
  59. package/lib/module/web/templates/ActionRowRenderer.js +2 -1
  60. package/lib/module/web/templates/IdentityRowRenderer.js +4 -3
  61. package/lib/module/web/templates/MarketRowRenderer.js +2 -1
  62. package/lib/module/web/templates/RowText.js +13 -3
  63. package/lib/module/web/templates/SectionHeaderRowRenderer.js +3 -2
  64. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
  65. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
  66. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
  67. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
  68. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
  69. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
  70. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
  71. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
  72. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
  73. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
  74. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
  75. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
  76. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
  77. package/lib/typescript/src/NativeList.nitro.d.ts +1 -0
  78. package/lib/typescript/src/fonts.d.ts +10 -0
  79. package/lib/typescript/src/index.d.ts +2 -0
  80. package/lib/typescript/src/web/NativeListWebEngine.d.ts +4 -1
  81. package/lib/typescript/src/web/templates/RowText.d.ts +1 -0
  82. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +9 -0
  83. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +2 -0
  84. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +5 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +6 -0
  86. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +7 -0
  87. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +6 -0
  88. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +1 -0
  89. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +11 -0
  90. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +2 -0
  91. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +2 -0
  92. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +2 -0
  93. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +3 -0
  94. package/nitrogen/generated/shared/json/NativeListConfig.json +1 -0
  95. package/package.json +4 -5
  96. package/react-native-native-list.podspec +0 -1
  97. package/src/NativeList.nitro.ts +1 -0
  98. package/src/NativeList.tsx +3 -0
  99. package/src/NativeList.web.tsx +10 -1
  100. package/src/fonts.ts +64 -0
  101. package/src/index.ts +3 -0
  102. package/src/web/NativeListWebEngine.ts +53 -24
  103. package/src/web/templates/ActionRowRenderer.ts +2 -1
  104. package/src/web/templates/IdentityRowRenderer.ts +4 -3
  105. package/src/web/templates/MarketRowRenderer.ts +4 -2
  106. package/src/web/templates/RowText.ts +15 -3
  107. package/src/web/templates/SectionHeaderRowRenderer.ts +6 -3
  108. package/common/fonts/Roobert-Bold.ttf +0 -0
  109. package/common/fonts/Roobert-Medium.ttf +0 -0
  110. package/common/fonts/Roobert-Regular.ttf +0 -0
  111. package/common/fonts/Roobert-SemiBold.ttf +0 -0
@@ -6,6 +6,7 @@ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-nativ
6
6
  */
7
7
  export interface NativeListNativeProps extends HybridViewProps {
8
8
  snapshotJson: string;
9
+ fontFamiliesJson: string;
9
10
  containerSlotHeightsJson: string;
10
11
  topScrollEdgeHard: boolean;
11
12
  topOverlayHeight: number;
@@ -0,0 +1,10 @@
1
+ export type NativeListFontFamilies = Readonly<{
2
+ regular?: string;
3
+ medium?: string;
4
+ semibold?: string;
5
+ bold?: string;
6
+ }>;
7
+ /** Configure names already provided by the host in this JavaScript runtime. */
8
+ export declare function configureNativeListFonts(families: NativeListFontFamilies): void;
9
+ export declare function useNativeListFontFamiliesJson(): string;
10
+ //# sourceMappingURL=fonts.d.ts.map
@@ -4,4 +4,6 @@ export type * from './models';
4
4
  export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot, } from './validation';
5
5
  export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot, } from './selection';
6
6
  export type { SelectionAction, SelectionResult, SelectionState, } from './selection';
7
+ export { configureNativeListFonts } from './fonts';
8
+ export type { NativeListFontFamilies } from './fonts';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -144,7 +144,10 @@ export declare class NativeListWebEngine {
144
144
  private measuredRendererHeights;
145
145
  private notifyScrollCommandAccepted;
146
146
  private readonly handlePagerScrollCommandCancel;
147
- constructor(host: HTMLElement, snapshot: NativeListSnapshot, callbacks: NativeListWebCallbacks, virtualizationEnabled?: boolean, sectionIndexContainer?: HTMLElement | null);
147
+ constructor(host: HTMLElement, snapshot: NativeListSnapshot, callbacks: NativeListWebCallbacks, virtualizationEnabled?: boolean, sectionIndexContainer?: HTMLElement | null, fontFamiliesJson?: string);
148
+ private fontFamiliesJson;
149
+ private applyFontFamilies;
150
+ setFontFamiliesJson(json: string): void;
148
151
  updateCallbacks(callbacks: NativeListWebCallbacks): void;
149
152
  setVirtualizationEnabled(enabled: boolean): void;
150
153
  applySnapshot(snapshot: NativeListSnapshot): void;
@@ -6,4 +6,5 @@ export declare function applyValueSegments(element: HTMLElement, segments: reado
6
6
  export declare function applyTextLayout(element: HTMLElement, style: NativeListTextStyle, defaultLines?: number): void;
7
7
  export declare function applyTextStyleToSlot(element: HTMLElement, style: NativeListTextStyle, defaultLines?: number): void;
8
8
  export declare function fontWeight(value: NativeListTextStyle['fontWeight'] | undefined, fallback: number): number;
9
+ export declare function applyTextWeight(element: HTMLElement, weight: string | number): void;
9
10
  //# sourceMappingURL=RowText.d.ts.map
@@ -66,6 +66,15 @@ namespace margelo::nitro::nativelist {
66
66
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* snapshotJson */)>("setSnapshotJson");
67
67
  method(_javaPart, jni::make_jstring(snapshotJson));
68
68
  }
69
+ std::string JHybridNativeListSpec::getFontFamiliesJson() {
70
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getFontFamiliesJson");
71
+ auto __result = method(_javaPart);
72
+ return __result->toStdString();
73
+ }
74
+ void JHybridNativeListSpec::setFontFamiliesJson(const std::string& fontFamiliesJson) {
75
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* fontFamiliesJson */)>("setFontFamiliesJson");
76
+ method(_javaPart, jni::make_jstring(fontFamiliesJson));
77
+ }
69
78
  std::string JHybridNativeListSpec::getContainerSlotHeightsJson() {
70
79
  static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getContainerSlotHeightsJson");
71
80
  auto __result = method(_javaPart);
@@ -52,6 +52,8 @@ namespace margelo::nitro::nativelist {
52
52
  // Properties
53
53
  std::string getSnapshotJson() override;
54
54
  void setSnapshotJson(const std::string& snapshotJson) override;
55
+ std::string getFontFamiliesJson() override;
56
+ void setFontFamiliesJson(const std::string& fontFamiliesJson) override;
55
57
  std::string getContainerSlotHeightsJson() override;
56
58
  void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) override;
57
59
  bool getTopScrollEdgeHard() override;
@@ -58,6 +58,11 @@ void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>
58
58
  : !newProps->snapshotJson.hasSameValue(oldProps->snapshotJson)) {
59
59
  hybridView->setSnapshotJson(newProps->snapshotJson.get());
60
60
  }
61
+ if (oldProps == nullptr
62
+ ? newProps->fontFamiliesJson.isProvided()
63
+ : !newProps->fontFamiliesJson.hasSameValue(oldProps->fontFamiliesJson)) {
64
+ hybridView->setFontFamiliesJson(newProps->fontFamiliesJson.get());
65
+ }
61
66
  if (oldProps == nullptr
62
67
  ? newProps->containerSlotHeightsJson.isProvided()
63
68
  : !newProps->containerSlotHeightsJson.hasSameValue(oldProps->containerSlotHeightsJson)) {
@@ -33,6 +33,12 @@ abstract class HybridNativeListSpec: HybridView() {
33
33
  @set:Keep
34
34
  abstract var snapshotJson: String
35
35
 
36
+ @get:DoNotStrip
37
+ @get:Keep
38
+ @set:DoNotStrip
39
+ @set:Keep
40
+ abstract var fontFamiliesJson: String
41
+
36
42
  @get:DoNotStrip
37
43
  @get:Keep
38
44
  @set:DoNotStrip
@@ -79,6 +79,13 @@ namespace margelo::nitro::nativelist {
79
79
  inline void setSnapshotJson(const std::string& snapshotJson) noexcept override {
80
80
  _swiftPart.setSnapshotJson(snapshotJson);
81
81
  }
82
+ inline std::string getFontFamiliesJson() noexcept override {
83
+ auto __result = _swiftPart.getFontFamiliesJson();
84
+ return __result;
85
+ }
86
+ inline void setFontFamiliesJson(const std::string& fontFamiliesJson) noexcept override {
87
+ _swiftPart.setFontFamiliesJson(fontFamiliesJson);
88
+ }
82
89
  inline std::string getContainerSlotHeightsJson() noexcept override {
83
90
  auto __result = _swiftPart.getContainerSlotHeightsJson();
84
91
  return __result;
@@ -118,6 +118,12 @@ using namespace margelo::nitro::nativelist::views;
118
118
  : !newViewProps.snapshotJson.hasSameValue(oldViewProps->snapshotJson)) {
119
119
  swiftPart.setSnapshotJson(newViewProps.snapshotJson.get());
120
120
  }
121
+ // fontFamiliesJson: string
122
+ if (oldViewProps == nullptr
123
+ ? newViewProps.fontFamiliesJson.isProvided()
124
+ : !newViewProps.fontFamiliesJson.hasSameValue(oldViewProps->fontFamiliesJson)) {
125
+ swiftPart.setFontFamiliesJson(newViewProps.fontFamiliesJson.get());
126
+ }
121
127
  // containerSlotHeightsJson: string
122
128
  if (oldViewProps == nullptr
123
129
  ? newViewProps.containerSlotHeightsJson.isProvided()
@@ -11,6 +11,7 @@ import NitroModules
11
11
  public protocol HybridNativeListSpec_protocol: HybridObject, HybridView {
12
12
  // Properties
13
13
  var snapshotJson: String { get set }
14
+ var fontFamiliesJson: String { get set }
14
15
  var containerSlotHeightsJson: String { get set }
15
16
  var topScrollEdgeHard: Bool { get set }
16
17
  var topOverlayHeight: Double { get set }
@@ -132,6 +132,17 @@ open class HybridNativeListSpec_cxx {
132
132
  }
133
133
  }
134
134
 
135
+ public final var fontFamiliesJson: std.string {
136
+ @inline(__always)
137
+ get {
138
+ return std.string(self.__implementation.fontFamiliesJson)
139
+ }
140
+ @inline(__always)
141
+ set {
142
+ self.__implementation.fontFamiliesJson = String(newValue)
143
+ }
144
+ }
145
+
135
146
  public final var containerSlotHeightsJson: std.string {
136
147
  @inline(__always)
137
148
  get {
@@ -16,6 +16,8 @@ namespace margelo::nitro::nativelist {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridGetter("snapshotJson", &HybridNativeListSpec::getSnapshotJson);
18
18
  prototype.registerHybridSetter("snapshotJson", &HybridNativeListSpec::setSnapshotJson);
19
+ prototype.registerHybridGetter("fontFamiliesJson", &HybridNativeListSpec::getFontFamiliesJson);
20
+ prototype.registerHybridSetter("fontFamiliesJson", &HybridNativeListSpec::setFontFamiliesJson);
19
21
  prototype.registerHybridGetter("containerSlotHeightsJson", &HybridNativeListSpec::getContainerSlotHeightsJson);
20
22
  prototype.registerHybridSetter("containerSlotHeightsJson", &HybridNativeListSpec::setContainerSlotHeightsJson);
21
23
  prototype.registerHybridGetter("topScrollEdgeHard", &HybridNativeListSpec::getTopScrollEdgeHard);
@@ -56,6 +56,8 @@ namespace margelo::nitro::nativelist {
56
56
  // Properties
57
57
  virtual std::string getSnapshotJson() = 0;
58
58
  virtual void setSnapshotJson(const std::string& snapshotJson) = 0;
59
+ virtual std::string getFontFamiliesJson() = 0;
60
+ virtual void setFontFamiliesJson(const std::string& fontFamiliesJson) = 0;
59
61
  virtual std::string getContainerSlotHeightsJson() = 0;
60
62
  virtual void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) = 0;
61
63
  virtual bool getTopScrollEdgeHard() = 0;
@@ -21,6 +21,7 @@ namespace margelo::nitro::nativelist::views {
21
21
  const react::RawProps& rawProps):
22
22
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
23
23
  snapshotJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "snapshotJson", rawProps, sourceProps.snapshotJson)),
24
+ fontFamiliesJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "fontFamiliesJson", rawProps, sourceProps.fontFamiliesJson)),
24
25
  containerSlotHeightsJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "containerSlotHeightsJson", rawProps, sourceProps.containerSlotHeightsJson)),
25
26
  topScrollEdgeHard(nitro::ReactProp<bool>::fromRawValue("NativeList", "topScrollEdgeHard", rawProps, sourceProps.topScrollEdgeHard)),
26
27
  topOverlayHeight(nitro::ReactProp<double>::fromRawValue("NativeList", "topOverlayHeight", rawProps, sourceProps.topOverlayHeight)),
@@ -39,6 +40,7 @@ namespace margelo::nitro::nativelist::views {
39
40
  bool HybridNativeListProps::filterObjectKeys(const std::string& propName) {
40
41
  switch (hashString(propName)) {
41
42
  case hashString("snapshotJson"): return true;
43
+ case hashString("fontFamiliesJson"): return true;
42
44
  case hashString("containerSlotHeightsJson"): return true;
43
45
  case hashString("topScrollEdgeHard"): return true;
44
46
  case hashString("topOverlayHeight"): return true;
@@ -46,6 +46,7 @@ namespace margelo::nitro::nativelist::views {
46
46
 
47
47
  public:
48
48
  nitro::ReactProp<std::string> snapshotJson;
49
+ nitro::ReactProp<std::string> fontFamiliesJson;
49
50
  nitro::ReactProp<std::string> containerSlotHeightsJson;
50
51
  nitro::ReactProp<bool> topScrollEdgeHard;
51
52
  nitro::ReactProp<double> topOverlayHeight;
@@ -64,6 +65,7 @@ namespace margelo::nitro::nativelist::views {
64
65
  [[nodiscard]]
65
66
  bool hasSameProps(const HybridNativeListProps& other) const noexcept {
66
67
  return snapshotJson.hasSameValue(other.snapshotJson) &&
68
+ fontFamiliesJson.hasSameValue(other.fontFamiliesJson) &&
67
69
  containerSlotHeightsJson.hasSameValue(other.containerSlotHeightsJson) &&
68
70
  topScrollEdgeHard.hasSameValue(other.topScrollEdgeHard) &&
69
71
  topOverlayHeight.hasSameValue(other.topOverlayHeight) &&
@@ -83,6 +85,7 @@ namespace margelo::nitro::nativelist::views {
83
85
  [[nodiscard]]
84
86
  bool hasAnyProvidedProps() const noexcept {
85
87
  return snapshotJson.isProvided() ||
88
+ fontFamiliesJson.isProvided() ||
86
89
  containerSlotHeightsJson.isProvided() ||
87
90
  topScrollEdgeHard.isProvided() ||
88
91
  topOverlayHeight.isProvided() ||
@@ -5,6 +5,7 @@
5
5
  "directEventTypes": {},
6
6
  "validAttributes": {
7
7
  "snapshotJson": true,
8
+ "fontFamiliesJson": true,
8
9
  "containerSlotHeightsJson": true,
9
10
  "topScrollEdgeHard": true,
10
11
  "topOverlayHeight": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-list",
3
- "version": "3.0.179",
3
+ "version": "3.0.180",
4
4
  "description": "Template-driven native RecyclerView and UICollectionView for React Native",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",
@@ -19,7 +19,6 @@
19
19
  "lib",
20
20
  "android",
21
21
  "ios",
22
- "common",
23
22
  "cpp",
24
23
  "nitrogen",
25
24
  "nitro.json",
@@ -59,7 +58,7 @@
59
58
  "url": "https://github.com/OneKeyHQ/app-modules/issues"
60
59
  },
61
60
  "homepage": "https://github.com/OneKeyHQ/app-modules/tree/main/native-views/react-native-native-list#readme",
62
- "license": "MIT",
61
+ "license": "SEE LICENSE IN LICENSE",
63
62
  "publishConfig": {
64
63
  "registry": "https://registry.npmjs.org/",
65
64
  "access": "public"
@@ -87,8 +86,8 @@
87
86
  "typescript": "^5.9.2"
88
87
  },
89
88
  "peerDependencies": {
90
- "@onekeyfe/react-native-image": "3.0.179",
91
- "@onekeyfe/react-native-native-logger": "3.0.179",
89
+ "@onekeyfe/react-native-image": "3.0.180",
90
+ "@onekeyfe/react-native-native-logger": "3.0.180",
92
91
  "react": "*",
93
92
  "react-native": "*",
94
93
  "react-native-nitro-modules": "0.37.0"
@@ -16,7 +16,6 @@ Pod::Spec.new do |s|
16
16
  s.exclude_files = "ios/tests/**/*"
17
17
  s.resource_bundles = {
18
18
  "NativeListResources" => [
19
- "common/fonts/*.ttf",
20
19
  "ios/Resources/NativeListIcons.xcassets"
21
20
  ]
22
21
  }
@@ -11,6 +11,7 @@ import type {
11
11
  */
12
12
  export interface NativeListNativeProps extends HybridViewProps {
13
13
  snapshotJson: string;
14
+ fontFamiliesJson: string;
14
15
  containerSlotHeightsJson: string;
15
16
  topScrollEdgeHard: boolean;
16
17
  topOverlayHeight: number;
@@ -1,3 +1,4 @@
1
+ import { useNativeListFontFamiliesJson } from './fonts';
1
2
  import React, {
2
3
  forwardRef,
3
4
  useEffect,
@@ -125,6 +126,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
125
126
  },
126
127
  forwardedRef
127
128
  ) {
129
+ const fontFamiliesJson = useNativeListFontFamiliesJson();
128
130
  const [slotHeights, setSlotHeights] = useState([0, 0, 0]);
129
131
  const [topOverlayHeight, setTopOverlayHeight] = useState(0);
130
132
  const hasTopOverlay =
@@ -512,6 +514,7 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
512
514
  <NativeListHost
513
515
  {...viewProps}
514
516
  {...nativeCallbacks}
517
+ fontFamiliesJson={fontFamiliesJson}
515
518
  snapshotJson={snapshotJson}
516
519
  containerSlotHeightsJson={containerSlotHeightsJson}
517
520
  topScrollEdgeHard={hasTopOverlay}
@@ -1,3 +1,4 @@
1
+ import { useNativeListFontFamiliesJson } from './fonts';
1
2
  import React, {
2
3
  forwardRef,
3
4
  useCallback,
@@ -109,6 +110,9 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
109
110
  },
110
111
  forwardedRef
111
112
  ) {
113
+ const fontFamiliesJson = useNativeListFontFamiliesJson();
114
+ const fontFamiliesJsonRef = useRef(fontFamiliesJson);
115
+ fontFamiliesJsonRef.current = fontFamiliesJson;
112
116
  const [host, setHost] = useState<HTMLElement | null>(null);
113
117
  const engineRef = useRef<NativeListWebEngine | undefined>(undefined);
114
118
  const webVirtualizationEnabledRef = useRef(webVirtualizationEnabled);
@@ -184,7 +188,8 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
184
188
  snapshotRef.current,
185
189
  callbacksRef.current,
186
190
  webVirtualizationEnabledRef.current,
187
- webSectionIndexContainerRef?.current as unknown as HTMLElement | null
191
+ webSectionIndexContainerRef?.current as unknown as HTMLElement | null,
192
+ fontFamiliesJsonRef.current
188
193
  );
189
194
  engineRef.current = engine;
190
195
  appliedSnapshotRef.current = snapshotRef.current;
@@ -206,6 +211,10 @@ export const NativeList = forwardRef<NativeListRef, NativeListProps>(
206
211
  };
207
212
  }, [host, webSectionIndexContainerRef]);
208
213
 
214
+ useEffect(() => {
215
+ engineRef.current?.setFontFamiliesJson(fontFamiliesJson);
216
+ }, [fontFamiliesJson]);
217
+
209
218
  useEffect(() => {
210
219
  engineRef.current?.setVirtualizationEnabled(webVirtualizationEnabled);
211
220
  }, [webVirtualizationEnabled]);
package/src/fonts.ts ADDED
@@ -0,0 +1,64 @@
1
+ import { useSyncExternalStore } from 'react';
2
+
3
+ export type NativeListFontFamilies = Readonly<{
4
+ regular?: string;
5
+ medium?: string;
6
+ semibold?: string;
7
+ bold?: string;
8
+ }>;
9
+
10
+ const weights = ['regular', 'medium', 'semibold', 'bold'] as const;
11
+ let configuration = '{}';
12
+ const listeners = new Set<() => void>();
13
+
14
+ /** Configure names already provided by the host in this JavaScript runtime. */
15
+ export function configureNativeListFonts(
16
+ families: NativeListFontFamilies
17
+ ): void {
18
+ if (!families || typeof families !== 'object' || Array.isArray(families)) {
19
+ throw new TypeError('NativeList font families must be an object');
20
+ }
21
+ if (
22
+ Object.keys(families).some(
23
+ (key) => !weights.includes(key as (typeof weights)[number])
24
+ )
25
+ ) {
26
+ throw new TypeError('Unknown NativeList font weight');
27
+ }
28
+ const normalized: Record<string, string> = {};
29
+ for (const weight of weights) {
30
+ const name = families[weight];
31
+ if (name === undefined) continue;
32
+ if (
33
+ typeof name !== 'string' ||
34
+ Array.from(name).some(
35
+ (character) =>
36
+ character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127
37
+ )
38
+ ) {
39
+ throw new TypeError(`Invalid NativeList ${weight} font family`);
40
+ }
41
+ const trimmed = name.trim();
42
+ if (trimmed.length === 0 || trimmed.length > 128) {
43
+ throw new TypeError(`Invalid NativeList ${weight} font family`);
44
+ }
45
+ normalized[weight] = trimmed;
46
+ }
47
+ const next = JSON.stringify(normalized);
48
+ if (next === configuration) return;
49
+ configuration = next;
50
+ listeners.forEach((listener) => listener());
51
+ }
52
+
53
+ function subscribe(listener: () => void): () => void {
54
+ listeners.add(listener);
55
+ return () => listeners.delete(listener);
56
+ }
57
+
58
+ function getSnapshot(): string {
59
+ return configuration;
60
+ }
61
+
62
+ export function useNativeListFontFamiliesJson(): string {
63
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
64
+ }
package/src/index.ts CHANGED
@@ -35,3 +35,6 @@ export type {
35
35
  SelectionResult,
36
36
  SelectionState,
37
37
  } from './selection';
38
+
39
+ export { configureNativeListFonts } from './fonts';
40
+ export type { NativeListFontFamilies } from './fonts';