@onekeyfe/react-native-native-list 3.0.158 → 3.0.160

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 (199) hide show
  1. package/README.md +21 -5
  2. package/android/build.gradle +7 -0
  3. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +20 -0
  4. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +711 -0
  5. package/android/src/main/java/com/onekey/nativelist/NativeListActionRenderer.kt +169 -0
  6. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +179 -0
  7. package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +264 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +20 -6
  9. package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +53 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +487 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListEndAlignment.kt +5 -0
  12. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +820 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListImageSlot.kt +147 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +453 -0
  15. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +997 -0
  16. package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +268 -0
  17. package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +243 -0
  18. package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +232 -0
  19. package/android/src/main/java/com/onekey/nativelist/NativeListMetricCardRenderer.kt +551 -0
  20. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +27 -1
  21. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +475 -0
  22. package/android/src/main/java/com/onekey/nativelist/NativeListRailRenderer.kt +143 -0
  23. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +42 -0
  24. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +415 -0
  25. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +163 -0
  26. package/android/src/main/java/com/onekey/nativelist/NativeListRowHost.kt +70 -0
  27. package/android/src/main/java/com/onekey/nativelist/NativeListScrollPositionTracker.kt +59 -0
  28. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +763 -0
  29. package/android/src/main/java/com/onekey/nativelist/NativeListSystemRenderer.kt +464 -0
  30. package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +25 -0
  31. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +432 -124
  32. package/android/src/main/java/com/onekey/nativelist/NativeListWalletGroupRenderer.kt +407 -0
  33. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +5 -0
  34. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListEndAlignmentTest.kt +34 -0
  35. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListScrollPositionTrackerTest.kt +44 -0
  36. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListSelectorBackgroundColorTest.kt +34 -0
  37. package/docs/DESIGN.md +520 -9
  38. package/docs/MIGRATION_BASELINE.md +117 -0
  39. package/docs/ROW_TEMPLATES.md +404 -0
  40. package/docs/SPEC.md +621 -0
  41. package/docs/STYLE_SPEC.md +988 -0
  42. package/docs/images/list-capabilities.svg +39 -0
  43. package/docs/images/row-action.svg +17 -0
  44. package/docs/images/row-activity.svg +24 -0
  45. package/docs/images/row-data.svg +24 -0
  46. package/docs/images/row-identity.svg +25 -0
  47. package/docs/images/row-market.svg +23 -0
  48. package/docs/images/row-media-tile.svg +26 -0
  49. package/docs/images/row-message.svg +20 -0
  50. package/docs/images/row-metric-card.svg +33 -0
  51. package/docs/images/row-rail.svg +18 -0
  52. package/docs/images/row-section-header.svg +19 -0
  53. package/docs/images/row-style-regions.svg +30 -0
  54. package/docs/images/row-system.svg +30 -0
  55. package/docs/images/row-wallet-group.svg +26 -0
  56. package/ios/HybridNativeList.swift +30 -0
  57. package/ios/NativeListAccessoryStack.swift +680 -0
  58. package/ios/NativeListActionRenderer.swift +108 -0
  59. package/ios/NativeListActivityDetailsView.swift +291 -0
  60. package/ios/NativeListActivityRenderer.swift +201 -0
  61. package/ios/NativeListDataRowRenderer.swift +444 -0
  62. package/ios/NativeListIdentityRenderer.swift +685 -0
  63. package/ios/NativeListImageSlot.swift +140 -0
  64. package/ios/NativeListLeadingVisual.swift +372 -0
  65. package/ios/NativeListMarketRenderer.swift +698 -0
  66. package/ios/NativeListMediaPreviewSlot.swift +259 -0
  67. package/ios/NativeListMediaTileRenderer.swift +190 -0
  68. package/ios/NativeListMessageRenderer.swift +168 -0
  69. package/ios/NativeListMetricCardRenderer.swift +420 -0
  70. package/ios/NativeListModels.swift +36 -1
  71. package/ios/NativeListRailRenderer.swift +152 -0
  72. package/ios/NativeListRendererCell.swift +311 -0
  73. package/ios/NativeListRendererRegistry.swift +50 -0
  74. package/ios/NativeListResolvedText.swift +130 -0
  75. package/ios/NativeListRowHost.swift +63 -0
  76. package/ios/NativeListScrollPositionTracker.swift +30 -0
  77. package/ios/NativeListSectionHeaderRenderer.swift +734 -0
  78. package/ios/NativeListSystemRenderer.swift +568 -0
  79. package/ios/NativeListTextLabel.swift +42 -0
  80. package/ios/NativeListTextStyles.swift +236 -0
  81. package/ios/NativeListWalletGroupRenderer.swift +255 -0
  82. package/ios/RNCNativeListView.swift +282 -184
  83. package/ios/tests/NativeListActivityPresentationTests.swift +97 -0
  84. package/ios/tests/NativeListLifecycleTests.swift +241 -0
  85. package/ios/tests/NativeListMediaVisibilityTests.swift +109 -0
  86. package/ios/tests/NativeListScrollPositionTrackerTests.swift +25 -0
  87. package/lib/module/NativeList.js +56 -3
  88. package/lib/module/NativeList.web.js +5 -0
  89. package/lib/module/models.js +54 -0
  90. package/lib/module/validation.js +386 -28
  91. package/lib/module/web/NativeListWebEngine.js +148 -936
  92. package/lib/module/web/templates/ActionRowRenderer.js +97 -0
  93. package/lib/module/web/templates/ActivityRowRenderer.js +95 -0
  94. package/lib/module/web/templates/DataRowRenderer.js +145 -0
  95. package/lib/module/web/templates/IdentityRowRenderer.js +289 -0
  96. package/lib/module/web/templates/MarketRowRenderer.js +310 -0
  97. package/lib/module/web/templates/MediaTileRowRenderer.js +132 -0
  98. package/lib/module/web/templates/MessageRowRenderer.js +165 -0
  99. package/lib/module/web/templates/MetricCardRowRenderer.js +172 -0
  100. package/lib/module/web/templates/RailRowRenderer.js +98 -0
  101. package/lib/module/web/templates/RowContainerStyle.js +100 -0
  102. package/lib/module/web/templates/RowElements.js +93 -0
  103. package/lib/module/web/templates/RowRendererRegistry.js +70 -0
  104. package/lib/module/web/templates/RowText.js +121 -0
  105. package/lib/module/web/templates/RowVisual.js +43 -0
  106. package/lib/module/web/templates/SectionHeaderRowRenderer.js +146 -0
  107. package/lib/module/web/templates/SystemRowRenderer.js +161 -0
  108. package/lib/module/web/templates/WalletGroupRowRenderer.js +96 -0
  109. package/lib/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  110. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  111. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  112. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  113. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  114. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  115. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  116. package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  117. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  118. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  119. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  120. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  121. package/lib/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  122. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  123. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  124. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  125. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  126. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  127. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  128. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  129. package/lib/typescript/src/NativeList.nitro.d.ts +3 -0
  130. package/lib/typescript/src/NativeList.types.d.ts +14 -1
  131. package/lib/typescript/src/models.d.ts +199 -18
  132. package/lib/typescript/src/web/NativeListWebEngine.d.ts +18 -16
  133. package/lib/typescript/src/web/templates/ActionRowRenderer.d.ts +15 -0
  134. package/lib/typescript/src/web/templates/ActivityRowRenderer.d.ts +15 -0
  135. package/lib/typescript/src/web/templates/DataRowRenderer.d.ts +15 -0
  136. package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +16 -0
  137. package/lib/typescript/src/web/templates/MarketRowRenderer.d.ts +30 -0
  138. package/lib/typescript/src/web/templates/MediaTileRowRenderer.d.ts +15 -0
  139. package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +44 -0
  140. package/lib/typescript/src/web/templates/MetricCardRowRenderer.d.ts +15 -0
  141. package/lib/typescript/src/web/templates/RailRowRenderer.d.ts +28 -0
  142. package/lib/typescript/src/web/templates/RowContainerStyle.d.ts +9 -0
  143. package/lib/typescript/src/web/templates/RowElements.d.ts +38 -0
  144. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +83 -0
  145. package/lib/typescript/src/web/templates/RowText.d.ts +9 -0
  146. package/lib/typescript/src/web/templates/RowVisual.d.ts +20 -0
  147. package/lib/typescript/src/web/templates/SectionHeaderRowRenderer.d.ts +15 -0
  148. package/lib/typescript/src/web/templates/SystemRowRenderer.d.ts +16 -0
  149. package/lib/typescript/src/web/templates/WalletGroupRowRenderer.d.ts +20 -0
  150. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
  151. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +39 -3
  152. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +6 -0
  153. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +15 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_bool.kt +78 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +26 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +24 -9
  157. package/nitrogen/generated/android/nativelistOnLoad.cpp +2 -0
  158. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +8 -0
  159. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +37 -0
  160. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +23 -2
  161. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +32 -0
  162. package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
  163. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +3 -0
  164. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +54 -0
  165. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +6 -0
  166. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +8 -2
  167. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +6 -0
  168. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +11 -2
  169. package/nitrogen/generated/shared/json/NativeListConfig.json +3 -0
  170. package/package.json +7 -6
  171. package/react-native-native-list.podspec +6 -0
  172. package/scripts/enable-container-slots.mjs +58 -0
  173. package/scripts/enable-container-slots.test.mjs +58 -0
  174. package/src/NativeList.nitro.ts +3 -0
  175. package/src/NativeList.tsx +84 -2
  176. package/src/NativeList.types.ts +14 -1
  177. package/src/NativeList.web.tsx +5 -0
  178. package/src/models.ts +320 -20
  179. package/src/validation.ts +641 -49
  180. package/src/web/NativeListWebEngine.ts +361 -1932
  181. package/src/web/templates/ActionRowRenderer.ts +123 -0
  182. package/src/web/templates/ActivityRowRenderer.ts +159 -0
  183. package/src/web/templates/DataRowRenderer.ts +212 -0
  184. package/src/web/templates/IdentityRowRenderer.ts +527 -0
  185. package/src/web/templates/MarketRowRenderer.ts +467 -0
  186. package/src/web/templates/MediaTileRowRenderer.ts +182 -0
  187. package/src/web/templates/MessageRowRenderer.ts +306 -0
  188. package/src/web/templates/MetricCardRowRenderer.ts +337 -0
  189. package/src/web/templates/RailRowRenderer.ts +136 -0
  190. package/src/web/templates/RowContainerStyle.ts +131 -0
  191. package/src/web/templates/RowElements.ts +160 -0
  192. package/src/web/templates/RowRendererRegistry.ts +111 -0
  193. package/src/web/templates/RowText.ts +181 -0
  194. package/src/web/templates/RowVisual.ts +115 -0
  195. package/src/web/templates/SectionHeaderRowRenderer.ts +243 -0
  196. package/src/web/templates/SystemRowRenderer.ts +282 -0
  197. package/src/web/templates/WalletGroupRowRenderer.ts +131 -0
  198. package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +0 -4538
  199. package/ios/NativeListCell.swift +0 -4300
package/src/validation.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ROW_BOX_STYLE_KEYS_BY_TYPE } from './models';
1
2
  import type {
2
3
  ActivityRow,
3
4
  IdentityRow,
@@ -5,8 +6,11 @@ import type {
5
6
  LeadingVisual,
6
7
  MarketRow,
7
8
  MarketRowStyle,
8
- MarketTextStyle,
9
+ NativeListListStyle,
9
10
  NativeListSnapshot,
11
+ NativeListTextStyle,
12
+ NativeListTypographyToken,
13
+ RowBoxStyle,
10
14
  RowModel,
11
15
  RowPatch,
12
16
  WalletGroupRow,
@@ -127,11 +131,119 @@ function assertBoundedStyleNumber(
127
131
  }
128
132
  }
129
133
 
130
- function assertMarketTextStyle(
131
- style: MarketTextStyle | undefined,
132
- path: string
134
+ /**
135
+ * The named typography scale from docs/STYLE_SPEC.md §3.2. Tokens are resolved
136
+ * to numbers here, before serialization, so the iOS, Android, and Web renderers
137
+ * never learn the vocabulary and cannot drift from it.
138
+ */
139
+ const TYPOGRAPHY_TOKENS: Readonly<
140
+ Record<
141
+ NativeListTypographyToken,
142
+ Readonly<{
143
+ fontSize: number;
144
+ lineHeight: number;
145
+ fontWeight: NonNullable<NativeListTextStyle['fontWeight']>;
146
+ }>
147
+ >
148
+ > = {
149
+ $headingXl: { fontSize: 24, lineHeight: 32, fontWeight: 'semibold' },
150
+ $headingLg: { fontSize: 20, lineHeight: 28, fontWeight: 'semibold' },
151
+ $headingMd: { fontSize: 18, lineHeight: 24, fontWeight: 'semibold' },
152
+ $headingSm: { fontSize: 16, lineHeight: 24, fontWeight: 'medium' },
153
+ $headingXs: { fontSize: 14, lineHeight: 20, fontWeight: 'semibold' },
154
+ $bodyLg: { fontSize: 16, lineHeight: 24, fontWeight: 'regular' },
155
+ $bodyMd: { fontSize: 14, lineHeight: 20, fontWeight: 'regular' },
156
+ $bodySm: { fontSize: 12, lineHeight: 16, fontWeight: 'regular' },
157
+ $bodyXs: { fontSize: 11, lineHeight: 16, fontWeight: 'regular' },
158
+ };
159
+
160
+ /** Style keys name model fields, never views. See docs/STYLE_SPEC.md §4. */
161
+ const TEXT_STYLE_KEYS_BY_ROW_TYPE: Readonly<
162
+ Record<RowModel['type'], readonly string[]>
163
+ > = {
164
+ identity: [
165
+ 'title',
166
+ 'subtitle',
167
+ 'tertiary',
168
+ 'badge',
169
+ 'value',
170
+ 'valueSecondary',
171
+ ],
172
+ walletGroup: [],
173
+ rail: ['title', 'badge', 'status'],
174
+ activity: [
175
+ 'title',
176
+ 'description',
177
+ 'status',
178
+ 'primaryAmount',
179
+ 'secondaryAmount',
180
+ ],
181
+ message: ['title', 'body', 'time'],
182
+ dataRow: ['columns', 'columnSecondary', 'index'],
183
+ market: ['title', 'subtitle', 'price', 'change'],
184
+ mediaTile: ['title', 'subtitle', 'badge'],
185
+ metricCard: ['title', 'value', 'subtitle', 'trend'],
186
+ sectionHeader: ['title', 'subtitle', 'value'],
187
+ action: ['title', 'value'],
188
+ system: ['title', 'message', 'actionText'],
189
+ };
190
+
191
+ const EXTRA_STYLE_KEYS_BY_ROW_TYPE: Readonly<
192
+ Partial<Record<RowModel['type'], readonly string[]>>
193
+ > = {
194
+ market: [
195
+ 'titleBadgeLayout',
196
+ 'contentTrailingGap',
197
+ 'subtitleTrailingPadding',
198
+ 'changeWidth',
199
+ 'changeHeight',
200
+ 'changeCornerRadius',
201
+ ],
202
+ };
203
+
204
+ function assertTextStyle(
205
+ style: NativeListTextStyle | undefined,
206
+ path: string,
207
+ additionalKeys: readonly string[] = []
133
208
  ): void {
134
- if (!style) return;
209
+ if (style === undefined) return;
210
+ if (typeof style !== 'object' || style === null || Array.isArray(style)) {
211
+ fail(path, 'must be an object');
212
+ }
213
+ assertUnknownKeys(
214
+ style as Record<string, unknown>,
215
+ [
216
+ 'token',
217
+ 'fontSize',
218
+ 'fontWeight',
219
+ 'color',
220
+ 'lineHeight',
221
+ 'lines',
222
+ 'truncate',
223
+ 'alignment',
224
+ 'verticalAlignment',
225
+ 'offsetY',
226
+ ...additionalKeys,
227
+ ],
228
+ path,
229
+ 'text style key'
230
+ );
231
+ if (
232
+ style.color !== undefined &&
233
+ (typeof style.color !== 'string' ||
234
+ !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(style.color))
235
+ ) {
236
+ fail(`${path}.color`, 'must be #RRGGBB or #RRGGBBAA');
237
+ }
238
+ if (
239
+ style.token !== undefined &&
240
+ !Object.prototype.hasOwnProperty.call(TYPOGRAPHY_TOKENS, style.token)
241
+ ) {
242
+ fail(
243
+ `${path}.token`,
244
+ `must be one of ${Object.keys(TYPOGRAPHY_TOKENS).join(', ')}`
245
+ );
246
+ }
135
247
  assertBoundedStyleNumber(style.fontSize, `${path}.fontSize`, 8, 48);
136
248
  assertBoundedStyleNumber(style.lineHeight, `${path}.lineHeight`, 8, 64);
137
249
  if (
@@ -146,44 +258,117 @@ function assertMarketTextStyle(
146
258
  ) {
147
259
  fail(`${path}.alignment`, 'must be start, center, or end');
148
260
  }
149
- if (style.lines !== undefined && ![1, 2].includes(style.lines)) {
150
- fail(`${path}.lines`, 'must be 1 or 2');
261
+ if (style.lines !== undefined && ![1, 2, 3].includes(style.lines)) {
262
+ fail(`${path}.lines`, 'must be 1, 2, or 3');
263
+ }
264
+ if (
265
+ style.truncate !== undefined &&
266
+ !['tail', 'clip'].includes(style.truncate)
267
+ ) {
268
+ fail(`${path}.truncate`, 'must be tail or clip');
269
+ }
270
+ if (
271
+ style.verticalAlignment !== undefined &&
272
+ !['top', 'center', 'bottom'].includes(style.verticalAlignment)
273
+ ) {
274
+ fail(`${path}.verticalAlignment`, 'must be top, center, or bottom');
151
275
  }
276
+ assertBoundedStyleNumber(style.offsetY, `${path}.offsetY`, -8, 8);
152
277
  }
153
278
 
154
- function assertMarketStyle(
155
- style: MarketRowStyle | undefined,
156
- path: string
157
- ): void {
158
- if (!style) return;
279
+ function assertBoxStyle(style: RowBoxStyle, path: string): void {
280
+ const container = style.container;
281
+ if (container !== undefined) {
282
+ const containerPath = `${path}.container`;
283
+ if (
284
+ typeof container !== 'object' ||
285
+ container === null ||
286
+ Array.isArray(container)
287
+ ) {
288
+ fail(containerPath, 'must be an object');
289
+ }
290
+ assertUnknownKeys(
291
+ container as Record<string, unknown>,
292
+ [
293
+ 'height',
294
+ 'backgroundColor',
295
+ 'opacity',
296
+ 'cornerRadius',
297
+ 'borderWidth',
298
+ 'borderColor',
299
+ 'contentVerticalAlignment',
300
+ ],
301
+ containerPath,
302
+ 'row container style key'
303
+ );
304
+ for (const key of ['backgroundColor', 'borderColor'] as const) {
305
+ const value = container[key];
306
+ if (
307
+ value !== undefined &&
308
+ (typeof value !== 'string' ||
309
+ !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(value))
310
+ ) {
311
+ fail(`${containerPath}.${key}`, 'must be #RRGGBB or #RRGGBBAA');
312
+ }
313
+ }
314
+ assertBoundedStyleNumber(
315
+ container.height,
316
+ `${containerPath}.height`,
317
+ 0,
318
+ 4096
319
+ );
320
+ assertBoundedStyleNumber(
321
+ container.opacity,
322
+ `${containerPath}.opacity`,
323
+ 0,
324
+ 1
325
+ );
326
+ assertBoundedStyleNumber(
327
+ container.cornerRadius,
328
+ `${containerPath}.cornerRadius`,
329
+ 0,
330
+ 80
331
+ );
332
+ assertBoundedStyleNumber(
333
+ container.borderWidth,
334
+ `${containerPath}.borderWidth`,
335
+ 0,
336
+ 8
337
+ );
338
+ if (
339
+ container.contentVerticalAlignment !== undefined &&
340
+ !['top', 'center', 'bottom'].includes(container.contentVerticalAlignment)
341
+ ) {
342
+ fail(
343
+ `${containerPath}.contentVerticalAlignment`,
344
+ 'must be top, center, or bottom'
345
+ );
346
+ }
347
+ }
159
348
  for (const field of [
160
349
  'horizontalPadding',
161
350
  'verticalPadding',
162
351
  'leadingGap',
163
352
  'titleBadgeGap',
164
353
  'trailingGap',
165
- 'contentTrailingGap',
166
- 'subtitleTrailingPadding',
167
354
  ] as const) {
168
355
  assertBoundedStyleNumber(style[field], `${path}.${field}`, 0, 64);
169
356
  }
170
- // OneKey patch: validate the opt-in Market badge layout.
171
- if (
172
- style.titleBadgeLayout !== undefined &&
173
- style.titleBadgeLayout !== 'inline'
174
- ) {
175
- fail(`${path}.titleBadgeLayout`, 'must be inline when provided');
176
- }
177
357
  assertBoundedStyleNumber(style.lineGap, `${path}.lineGap`, 0, 16);
178
- assertBoundedStyleNumber(style.changeWidth, `${path}.changeWidth`, 1, 160);
179
- assertBoundedStyleNumber(style.changeHeight, `${path}.changeHeight`, 1, 160);
180
- assertBoundedStyleNumber(
181
- style.changeCornerRadius,
182
- `${path}.changeCornerRadius`,
183
- 0,
184
- 80
185
- );
186
- if (style.image) {
358
+ if (style.image !== undefined) {
359
+ if (
360
+ typeof style.image !== 'object' ||
361
+ style.image === null ||
362
+ Array.isArray(style.image)
363
+ ) {
364
+ fail(`${path}.image`, 'must be an object');
365
+ }
366
+ assertUnknownKeys(
367
+ style.image as Record<string, unknown>,
368
+ ['width', 'height', 'shape', 'cornerRadius', 'contentFit'],
369
+ `${path}.image`,
370
+ 'image style key'
371
+ );
187
372
  assertBoundedStyleNumber(style.image.width, `${path}.image.width`, 1, 160);
188
373
  assertBoundedStyleNumber(
189
374
  style.image.height,
@@ -208,10 +393,205 @@ function assertMarketStyle(
208
393
  );
209
394
  }
210
395
  }
211
- assertMarketTextStyle(style.title, `${path}.title`);
212
- assertMarketTextStyle(style.subtitle, `${path}.subtitle`);
213
- assertMarketTextStyle(style.price, `${path}.price`);
214
- assertMarketTextStyle(style.change, `${path}.change`);
396
+ }
397
+
398
+ function assertMarketStyle(
399
+ style: MarketRowStyle | undefined,
400
+ path: string
401
+ ): void {
402
+ if (!style) return;
403
+ assertBoxStyle(style, path);
404
+ for (const field of [
405
+ 'contentTrailingGap',
406
+ 'subtitleTrailingPadding',
407
+ ] as const) {
408
+ assertBoundedStyleNumber(style[field], `${path}.${field}`, 0, 64);
409
+ }
410
+ // OneKey patch: validate the opt-in Market badge layout.
411
+ if (
412
+ style.titleBadgeLayout !== undefined &&
413
+ style.titleBadgeLayout !== 'inline'
414
+ ) {
415
+ fail(`${path}.titleBadgeLayout`, 'must be inline when provided');
416
+ }
417
+ assertBoundedStyleNumber(style.changeWidth, `${path}.changeWidth`, 1, 160);
418
+ assertBoundedStyleNumber(style.changeHeight, `${path}.changeHeight`, 1, 160);
419
+ assertBoundedStyleNumber(
420
+ style.changeCornerRadius,
421
+ `${path}.changeCornerRadius`,
422
+ 0,
423
+ 80
424
+ );
425
+ assertTextStyle(style.title, `${path}.title`);
426
+ assertTextStyle(style.subtitle, `${path}.subtitle`);
427
+ assertTextStyle(style.price, `${path}.price`);
428
+ assertTextStyle(style.change, `${path}.change`);
429
+ }
430
+
431
+ /**
432
+ * Rejects keys the template does not declare, so a style written for one
433
+ * template cannot reach a shared view through another. See docs/STYLE_SPEC.md
434
+ * §7 rule 1.
435
+ */
436
+ function assertRowStyle(row: RowModel, path: string): void {
437
+ const style = (row as { style?: unknown }).style;
438
+ if (style === undefined) return;
439
+ if (typeof style !== 'object' || style === null || Array.isArray(style)) {
440
+ fail(`${path}.style`, 'must be an object');
441
+ }
442
+ const textKeys = TEXT_STYLE_KEYS_BY_ROW_TYPE[row.type] ?? [];
443
+ const allowed = new Set([
444
+ 'container',
445
+ ...ROW_BOX_STYLE_KEYS_BY_TYPE[row.type],
446
+ ...textKeys,
447
+ ...(EXTRA_STYLE_KEYS_BY_ROW_TYPE[row.type] ?? []),
448
+ ]);
449
+ Object.keys(style as Record<string, unknown>).forEach((key) => {
450
+ if (!allowed.has(key)) {
451
+ fail(
452
+ `${path}.style.${key}`,
453
+ `is not a style key of the "${row.type}" template`
454
+ );
455
+ }
456
+ });
457
+ // Market keeps its own richer assertions, driven from assertMarketRow.
458
+ if (row.type === 'market') return;
459
+ assertBoxStyle(style as RowBoxStyle, `${path}.style`);
460
+ const slots = style as Record<string, NativeListTextStyle | undefined>;
461
+ textKeys.forEach((key) =>
462
+ assertTextStyle(slots[key], `${path}.style.${key}`)
463
+ );
464
+ }
465
+
466
+ const LIST_STYLE_KEYS: readonly string[] = ['separator', 'groupCornerRadius'];
467
+ const SEPARATOR_STYLE_KEYS: readonly string[] = ['inset', 'color'];
468
+
469
+ function assertUnknownKeys(
470
+ value: Record<string, unknown>,
471
+ allowed: readonly string[],
472
+ path: string,
473
+ subject: string
474
+ ): void {
475
+ Object.keys(value).forEach((key) => {
476
+ if (!allowed.includes(key)) fail(`${path}.${key}`, `is not a ${subject}`);
477
+ });
478
+ }
479
+
480
+ function assertListStyle(
481
+ listStyle: NativeListListStyle | undefined,
482
+ path: string
483
+ ): void {
484
+ if (listStyle === undefined) return;
485
+ if (
486
+ typeof listStyle !== 'object' ||
487
+ listStyle === null ||
488
+ Array.isArray(listStyle)
489
+ ) {
490
+ fail(path, 'must be an object');
491
+ }
492
+ assertUnknownKeys(
493
+ listStyle as Record<string, unknown>,
494
+ LIST_STYLE_KEYS,
495
+ path,
496
+ 'list style key'
497
+ );
498
+ assertBoundedStyleNumber(
499
+ listStyle.groupCornerRadius,
500
+ `${path}.groupCornerRadius`,
501
+ 0,
502
+ 40
503
+ );
504
+ const separator = listStyle.separator;
505
+ if (separator === undefined) return;
506
+ if (
507
+ typeof separator !== 'object' ||
508
+ separator === null ||
509
+ Array.isArray(separator)
510
+ ) {
511
+ fail(`${path}.separator`, 'must be an object');
512
+ }
513
+ assertUnknownKeys(
514
+ separator as Record<string, unknown>,
515
+ SEPARATOR_STYLE_KEYS,
516
+ `${path}.separator`,
517
+ 'separator style key'
518
+ );
519
+ assertBoundedStyleNumber(separator.inset, `${path}.separator.inset`, 0, 64);
520
+ // Same format as every row style color; renderers parse it directly.
521
+ if (
522
+ separator.color !== undefined &&
523
+ (typeof separator.color !== 'string' ||
524
+ !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(separator.color))
525
+ ) {
526
+ fail(`${path}.separator.color`, 'must be #RRGGBB or #RRGGBBAA');
527
+ }
528
+ }
529
+
530
+ /** Token resolution is idempotent: a resolved style carries no token. */
531
+ function resolveTextStyle(
532
+ style: NativeListTextStyle | undefined
533
+ ): NativeListTextStyle | undefined {
534
+ if (!style?.token) return style;
535
+ const { token, ...overrides } = style;
536
+ return { ...TYPOGRAPHY_TOKENS[token], ...overrides };
537
+ }
538
+
539
+ function resolveStyleTokens(
540
+ style: Record<string, unknown>,
541
+ rowType: RowModel['type']
542
+ ): Record<string, unknown> {
543
+ const textKeys = TEXT_STYLE_KEYS_BY_ROW_TYPE[rowType] ?? [];
544
+ let changed = false;
545
+ const next: Record<string, unknown> = { ...style };
546
+ textKeys.forEach((key) => {
547
+ const slot = style[key] as NativeListTextStyle | undefined;
548
+ const resolved = resolveTextStyle(slot);
549
+ if (resolved !== slot) {
550
+ next[key] = resolved;
551
+ changed = true;
552
+ }
553
+ });
554
+ return changed ? next : style;
555
+ }
556
+
557
+ function normalizeRowStyles<T extends RowModel>(row: T): T {
558
+ // Narrowing a generic does not reach the walletGroup members; go through the
559
+ // union type instead.
560
+ const model: RowModel = row;
561
+ const style = (row as { style?: Record<string, unknown> }).style;
562
+ const nextStyle = style ? resolveStyleTokens(style, row.type) : style;
563
+ const prefix = model.type === 'market' ? model.subtitlePrefix : undefined;
564
+ const nextPrefixStyle = resolveTextStyle(prefix?.style);
565
+ let nextParent: IdentityRow | undefined;
566
+ let nextChildren: readonly IdentityRow[] | undefined;
567
+ if (model.type === 'walletGroup') {
568
+ const parent = normalizeRowStyles(model.parent);
569
+ const children = model.children.map(normalizeRowStyles);
570
+ if (
571
+ parent !== model.parent ||
572
+ children.some((child, index) => child !== model.children[index])
573
+ ) {
574
+ nextParent = parent;
575
+ nextChildren = children;
576
+ }
577
+ }
578
+ if (
579
+ nextStyle === style &&
580
+ nextPrefixStyle === prefix?.style &&
581
+ nextParent === undefined
582
+ ) {
583
+ return row;
584
+ }
585
+ const next: Record<string, unknown> = { ...row };
586
+ if (nextStyle !== style) next.style = nextStyle;
587
+ if (prefix && nextPrefixStyle !== prefix.style) {
588
+ next.subtitlePrefix = { ...prefix, style: nextPrefixStyle };
589
+ }
590
+ if (nextParent !== undefined) {
591
+ next.parent = nextParent;
592
+ next.children = nextChildren;
593
+ }
594
+ return next as T;
215
595
  }
216
596
 
217
597
  function assertMarketRow(row: MarketRow, path: string): void {
@@ -235,10 +615,7 @@ function assertMarketRow(row: MarketRow, path: string): void {
235
615
  1,
236
616
  320
237
617
  );
238
- assertMarketTextStyle(
239
- row.subtitlePrefix.style,
240
- `${path}.subtitlePrefix.style`
241
- );
618
+ assertTextStyle(row.subtitlePrefix.style, `${path}.subtitlePrefix.style`);
242
619
  }
243
620
  assertText(row.price, `${path}.price`);
244
621
  assertText(row.change.text, `${path}.change.text`);
@@ -286,7 +663,17 @@ function assertMarketRow(row: MarketRow, path: string): void {
286
663
  badgeKeys.add(badge.key);
287
664
  assertText(badge.text, `${badgePath}.text`);
288
665
  // OneKey patch: share typography bounds with Market text styles.
289
- assertMarketTextStyle(badge.style, `${badgePath}.style`);
666
+ assertTextStyle(badge.style, `${badgePath}.style`, [
667
+ 'height',
668
+ 'horizontalPadding',
669
+ ]);
670
+ if (badge.style)
671
+ assertUnknownKeys(
672
+ badge.style,
673
+ ['fontSize', 'fontWeight', 'lineHeight', 'height', 'horizontalPadding'],
674
+ `${badgePath}.style`,
675
+ 'Market badge style key'
676
+ );
290
677
  assertBoundedStyleNumber(
291
678
  badge.style?.height,
292
679
  `${badgePath}.style.height`,
@@ -530,7 +917,84 @@ function assertVisual(row: RowModel, path: string): void {
530
917
  });
531
918
  }
532
919
 
533
- function assertActivity(row: ActivityRow, path: string): void {
920
+ function assertActivity(row: Partial<ActivityRow>, path: string): void {
921
+ assertText(row.title, `${path}.title`);
922
+ assertText(row.description, `${path}.description`);
923
+ if (
924
+ row.presentation !== undefined &&
925
+ !['stacked', 'table'].includes(row.presentation)
926
+ )
927
+ fail(`${path}.presentation`, 'must be stacked or table');
928
+ if (row.descriptionActionKey !== undefined)
929
+ assertKey(row.descriptionActionKey, `${path}.descriptionActionKey`);
930
+ if ((row.amounts?.length ?? 0) > 32)
931
+ fail(`${path}.amounts`, 'supports at most 32 amount lines');
932
+ const amountKeys = new Set<string>();
933
+ row.amounts?.forEach((amount, index) => {
934
+ const amountPath = `${path}.amounts[${index}]`;
935
+ assertKey(amount.key, `${amountPath}.key`);
936
+ if (amountKeys.has(amount.key)) fail(amountPath, 'duplicate amount key');
937
+ amountKeys.add(amount.key);
938
+ assertText(amount.text, `${amountPath}.text`);
939
+ assertLeadingVisual(amount.leading, `${amountPath}.leading`);
940
+ assertText(amount.secondaryText, `${amountPath}.secondaryText`);
941
+ if (
942
+ amount.tone !== undefined &&
943
+ !['primary', 'secondary', 'positive', 'negative'].includes(amount.tone)
944
+ )
945
+ fail(`${amountPath}.tone`, 'invalid text tone');
946
+ amount.textSegments?.forEach((segment, segmentIndex) => {
947
+ assertText(
948
+ segment.text,
949
+ `${amountPath}.textSegments[${segmentIndex}].text`
950
+ );
951
+ if (segment.style !== undefined && segment.style !== 'subscript')
952
+ fail(amountPath, 'invalid text segment style');
953
+ });
954
+ });
955
+ const assertActivitySegments = (
956
+ segments: readonly { text: string; style?: string }[] | undefined,
957
+ segmentPath: string
958
+ ) =>
959
+ segments?.forEach((segment, index) => {
960
+ assertText(segment.text, `${segmentPath}[${index}].text`);
961
+ if (segment.style !== undefined && segment.style !== 'subscript')
962
+ fail(segmentPath, 'invalid text segment style');
963
+ });
964
+ row.amounts?.forEach((amount, index) =>
965
+ assertActivitySegments(
966
+ amount.secondaryTextSegments,
967
+ `${path}.amounts[${index}].secondaryTextSegments`
968
+ )
969
+ );
970
+ assertActivitySegments(
971
+ row.fee?.primaryTextSegments,
972
+ `${path}.fee.primaryTextSegments`
973
+ );
974
+ assertActivitySegments(
975
+ row.fee?.secondaryTextSegments,
976
+ `${path}.fee.secondaryTextSegments`
977
+ );
978
+ assertText(row.fee?.label, `${path}.fee.label`);
979
+ assertText(row.fee?.primary, `${path}.fee.primary`);
980
+ assertText(row.fee?.secondary, `${path}.fee.secondary`);
981
+ if ((row.badges?.length ?? 0) > 4)
982
+ fail(`${path}.badges`, 'supports at most 4 activity badges');
983
+ const badgeKeys = new Set<string>();
984
+ row.badges?.forEach((badge, index) => {
985
+ assertKey(badge.key, `${path}.badges[${index}].key`);
986
+ if (badgeKeys.has(badge.key)) fail(`${path}.badges`, 'duplicate badge key');
987
+ badgeKeys.add(badge.key);
988
+ assertText(badge.text, `${path}.badges[${index}].text`);
989
+ if (
990
+ badge.tone !== undefined &&
991
+ !['neutral', 'info', 'success', 'warning', 'danger'].includes(badge.tone)
992
+ )
993
+ fail(`${path}.badges`, 'invalid badge tone');
994
+ });
995
+ if (row.fee?.hidden !== undefined && typeof row.fee.hidden !== 'boolean')
996
+ fail(`${path}.fee.hidden`, 'must be boolean');
997
+
534
998
  if ((row.footerActions?.length ?? 0) > MAX_FOOTER_ACTIONS) {
535
999
  fail(
536
1000
  `${path}.footerActions`,
@@ -571,18 +1035,31 @@ function assertWalletGroup(row: WalletGroupRow, path: string): void {
571
1035
  });
572
1036
  }
573
1037
 
1038
+ function assertRowType(
1039
+ type: unknown,
1040
+ path: string
1041
+ ): asserts type is RowModel['type'] {
1042
+ if (
1043
+ typeof type !== 'string' ||
1044
+ !Object.prototype.hasOwnProperty.call(ROW_BOX_STYLE_KEYS_BY_TYPE, type)
1045
+ ) {
1046
+ fail(`${path}.type`, 'is not supported');
1047
+ }
1048
+ }
1049
+
574
1050
  function assertRow(
575
1051
  row: RowModel,
576
1052
  index: number,
577
1053
  path = `rows[${index}]`
578
1054
  ): void {
1055
+ assertRowType(row.type, path);
579
1056
  assertKey(row.key, `${path}.key`);
580
1057
  // OneKey patch: explicit dimensions and opacity cannot corrupt list layout.
581
1058
  if (row.height !== undefined && (row.height < 0 || row.height > 4096))
582
1059
  fail(`${path}.height`, 'must be within 0...4096');
583
1060
  if (
584
1061
  row.heightRounding !== undefined &&
585
- (row.height === undefined ||
1062
+ ((row.height === undefined && row.style?.container?.height === undefined) ||
586
1063
  !['floor', 'nearest'].includes(row.heightRounding))
587
1064
  )
588
1065
  fail(
@@ -597,6 +1074,7 @@ function assertRow(
597
1074
  if (!row.groupId && row.groupPosition) {
598
1075
  fail(`${path}.groupId`, 'is required when groupPosition is present');
599
1076
  }
1077
+ assertRowStyle(row, path);
600
1078
  assertVisual(row, path);
601
1079
 
602
1080
  switch (row.type) {
@@ -685,8 +1163,8 @@ function assertRow(
685
1163
  case 'message':
686
1164
  assertText(row.title, `${path}.title`);
687
1165
  assertText(row.body, `${path}.body`);
688
- if ((row.bodyLines ?? 3) < 1 || (row.bodyLines ?? 3) > 3) {
689
- fail(`${path}.bodyLines`, 'must be within 1...3');
1166
+ if (![1, 2, 3].includes(row.bodyLines ?? 3)) {
1167
+ fail(`${path}.bodyLines`, 'must be 1, 2, or 3');
690
1168
  }
691
1169
  assertImage(row.thumbnail, `${path}.thumbnail`);
692
1170
  break;
@@ -718,6 +1196,7 @@ function assertRow(
718
1196
  assertMarketRow(row, path);
719
1197
  break;
720
1198
  case 'mediaTile':
1199
+ assertMediaPreview(row.media, `${path}.media`);
721
1200
  assertImage(row.image, `${path}.image`);
722
1201
  if (
723
1202
  row.imageState !== undefined &&
@@ -725,10 +1204,14 @@ function assertRow(
725
1204
  ) {
726
1205
  fail(`${path}.imageState`, 'must be empty or error when provided');
727
1206
  }
728
- if (row.imageState === undefined && row.image === undefined) {
1207
+ if (
1208
+ row.imageState === undefined &&
1209
+ row.image === undefined &&
1210
+ row.media === undefined
1211
+ ) {
729
1212
  fail(
730
1213
  `${path}.image`,
731
- 'is required unless imageState is empty or error'
1214
+ 'is required unless media is provided or imageState is empty or error'
732
1215
  );
733
1216
  }
734
1217
  assertImage(row.networkImage, `${path}.networkImage`);
@@ -767,6 +1250,11 @@ function assertRow(
767
1250
  }
768
1251
  break;
769
1252
  case 'sectionHeader':
1253
+ if (
1254
+ row.titleLoading !== undefined &&
1255
+ typeof row.titleLoading !== 'boolean'
1256
+ )
1257
+ fail(`${path}.titleLoading`, 'must be boolean');
770
1258
  assertKey(row.sectionKey, `${path}.sectionKey`);
771
1259
  if (
772
1260
  row.presentation !== undefined &&
@@ -891,14 +1379,57 @@ function assertGroups(rows: readonly RowModel[]): void {
891
1379
  }
892
1380
  }
893
1381
 
1382
+ function assertMediaPreview(value: unknown, path: string) {
1383
+ if (value === undefined) return;
1384
+ if (!value || typeof value !== 'object' || Array.isArray(value))
1385
+ fail(path, 'must be a media descriptor');
1386
+ const media = value as {
1387
+ source?: import('./models').ImageSource;
1388
+ probeOrder?: unknown;
1389
+ };
1390
+ assertImage(media.source, `${path}.source`);
1391
+ if (!media.source) fail(`${path}.source`, 'is required');
1392
+ const order = media.probeOrder;
1393
+ if (
1394
+ !Array.isArray(order) ||
1395
+ order.length < 1 ||
1396
+ order.length > 2 ||
1397
+ order.some((kind) => kind !== 'image' && kind !== 'video') ||
1398
+ new Set(order).size !== order.length
1399
+ ) {
1400
+ fail(
1401
+ `${path}.probeOrder`,
1402
+ 'must contain one or two distinct image/video candidates'
1403
+ );
1404
+ }
1405
+ }
1406
+
894
1407
  export function validateSnapshot(
895
1408
  snapshot: NativeListSnapshot
896
1409
  ): NativeListSnapshot {
1410
+ if (
1411
+ snapshot.capabilities?.refreshTriggerDistance !== undefined &&
1412
+ (!Number.isFinite(snapshot.capabilities.refreshTriggerDistance) ||
1413
+ snapshot.capabilities.refreshTriggerDistance <= 0)
1414
+ )
1415
+ fail(
1416
+ 'capabilities.refreshTriggerDistance',
1417
+ 'must be a positive finite number'
1418
+ );
1419
+
897
1420
  assertPlainSerializable(snapshot, 'snapshot', new Set<object>());
898
1421
  if (snapshot.schemaVersion !== 1) fail('snapshot.schemaVersion', 'must be 1');
899
1422
  if (!Number.isSafeInteger(snapshot.generation) || snapshot.generation < 0) {
900
1423
  fail('snapshot.generation', 'must be a non-negative safe integer');
901
1424
  }
1425
+ if (
1426
+ snapshot.layout.gridColumns !== undefined &&
1427
+ (!Number.isInteger(snapshot.layout.gridColumns) ||
1428
+ snapshot.layout.gridColumns < 2 ||
1429
+ snapshot.layout.gridColumns > 7)
1430
+ ) {
1431
+ fail('snapshot.layout.gridColumns', 'must be an integer from 2 to 7');
1432
+ }
902
1433
  if (snapshot.layout.kind === 'grid' && !snapshot.layout.gridColumns) {
903
1434
  fail('snapshot.layout.gridColumns', 'is required for grid layout');
904
1435
  }
@@ -964,6 +1495,8 @@ export function validateSnapshot(
964
1495
  }
965
1496
  }
966
1497
 
1498
+ assertListStyle(snapshot.listStyle, 'snapshot.listStyle');
1499
+
967
1500
  const rowKeys = new Set<string>();
968
1501
  const sectionIndexTitles = new Set<string>();
969
1502
  snapshot.rows.forEach((row, index) => {
@@ -1016,11 +1549,44 @@ export function validateSnapshot(
1016
1549
  'supports at most one key in single mode'
1017
1550
  );
1018
1551
  }
1019
- return snapshot;
1552
+ return normalizeSnapshotStyles(snapshot);
1553
+ }
1554
+
1555
+ /**
1556
+ * Resolves typography tokens to numbers. Returns the original snapshot when
1557
+ * nothing needs resolving, so the common no-style path keeps object identity.
1558
+ */
1559
+ function normalizeSnapshotStyles(
1560
+ snapshot: NativeListSnapshot
1561
+ ): NativeListSnapshot {
1562
+ let changed = false;
1563
+ const rows = snapshot.rows.map((row) => {
1564
+ const next = normalizeRowStyles(row);
1565
+ if (next !== row) changed = true;
1566
+ return next;
1567
+ });
1568
+ const emptyState = snapshot.emptyState
1569
+ ? normalizeRowStyles(snapshot.emptyState)
1570
+ : snapshot.emptyState;
1571
+ const fixedFooter = snapshot.fixedFooter
1572
+ ? normalizeRowStyles(snapshot.fixedFooter)
1573
+ : snapshot.fixedFooter;
1574
+ if (
1575
+ !changed &&
1576
+ emptyState === snapshot.emptyState &&
1577
+ fixedFooter === snapshot.fixedFooter
1578
+ ) {
1579
+ return snapshot;
1580
+ }
1581
+ return { ...snapshot, rows, emptyState, fixedFooter };
1020
1582
  }
1021
1583
 
1022
1584
  function assertPatchChanges(patch: RowPatch, index: number): void {
1023
1585
  const path = `patches[${index}].changes`;
1586
+ const patchedStyle = (patch.changes as { style?: unknown }).style;
1587
+ if (patchedStyle !== undefined) {
1588
+ assertRowStyle({ type: patch.type, style: patchedStyle } as RowModel, path);
1589
+ }
1024
1590
  // OneKey patch: partial balance updates retain a valid, current accessibility label.
1025
1591
  if ('accessibilityLabel' in patch.changes) {
1026
1592
  assertText(patch.changes.accessibilityLabel, `${path}.accessibilityLabel`);
@@ -1072,6 +1638,7 @@ function assertPatchChanges(patch: RowPatch, index: number): void {
1072
1638
  assertLeadingVisual(patch.changes.visual, `${path}.visual`);
1073
1639
  break;
1074
1640
  case 'activity':
1641
+ assertActivity(patch.changes, path);
1075
1642
  assertText(patch.changes.title, `${path}.title`);
1076
1643
  assertText(patch.changes.description, `${path}.description`);
1077
1644
  assertText(patch.changes.status, `${path}.status`);
@@ -1095,9 +1662,9 @@ function assertPatchChanges(patch: RowPatch, index: number): void {
1095
1662
  assertText(patch.changes.time, `${path}.time`);
1096
1663
  if (
1097
1664
  patch.changes.bodyLines !== undefined &&
1098
- (patch.changes.bodyLines < 1 || patch.changes.bodyLines > 3)
1665
+ ![1, 2, 3].includes(patch.changes.bodyLines)
1099
1666
  ) {
1100
- fail(`${path}.bodyLines`, 'must be within 1...3');
1667
+ fail(`${path}.bodyLines`, 'must be 1, 2, or 3');
1101
1668
  }
1102
1669
  assertImage(patch.changes.thumbnail, `${path}.thumbnail`);
1103
1670
  break;
@@ -1140,6 +1707,7 @@ function assertPatchChanges(patch: RowPatch, index: number): void {
1140
1707
  );
1141
1708
  break;
1142
1709
  case 'mediaTile':
1710
+ assertMediaPreview(patch.changes.media, `${path}.media`);
1143
1711
  assertImage(patch.changes.image, `${path}.image`);
1144
1712
  if (
1145
1713
  patch.changes.imageState !== undefined &&
@@ -1187,6 +1755,11 @@ function assertPatchChanges(patch: RowPatch, index: number): void {
1187
1755
  }
1188
1756
  break;
1189
1757
  case 'sectionHeader':
1758
+ if (
1759
+ patch.changes.titleLoading !== undefined &&
1760
+ typeof patch.changes.titleLoading !== 'boolean'
1761
+ )
1762
+ fail(`${path}.titleLoading`, 'must be boolean');
1190
1763
  assertSectionHeaderVariant(patch.changes.variant, `${path}.variant`);
1191
1764
  assertText(patch.changes.title, `${path}.title`);
1192
1765
  assertText(patch.changes.subtitle, `${path}.subtitle`);
@@ -1236,7 +1809,26 @@ export function validatePatches(
1236
1809
  }
1237
1810
  assertPatchChanges(patch, index);
1238
1811
  });
1239
- return patches;
1812
+ return normalizePatchStyles(patches);
1813
+ }
1814
+
1815
+ /** Patches reach the native side without passing through a snapshot. */
1816
+ function normalizePatchStyles(
1817
+ patches: readonly RowPatch[]
1818
+ ): readonly RowPatch[] {
1819
+ let changed = false;
1820
+ const next = patches.map((patch) => {
1821
+ const style = (patch.changes as { style?: Record<string, unknown> }).style;
1822
+ if (!style) return patch;
1823
+ const resolved = resolveStyleTokens(style, patch.type);
1824
+ if (resolved === style) return patch;
1825
+ changed = true;
1826
+ return {
1827
+ ...patch,
1828
+ changes: { ...patch.changes, style: resolved },
1829
+ } as RowPatch;
1830
+ });
1831
+ return changed ? next : patches;
1240
1832
  }
1241
1833
 
1242
1834
  export function applyRowPatches(