@onekeyfe/react-native-native-list 6.8.0-3 → 6.8.0-30

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 (62) hide show
  1. package/android/build.gradle +3 -0
  2. package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +18 -4
  3. package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +12 -1
  4. package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +166 -36
  5. package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +3 -2
  6. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +8 -1
  7. package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +6 -3
  8. package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +21 -4
  9. package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +24 -3
  10. package/android/src/main/java/com/onekey/nativelist/NativeListRowUpdates.kt +34 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +11 -4
  12. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentLayout.kt +71 -0
  13. package/android/src/main/java/com/onekey/nativelist/NativeListTitleSegmentsView.kt +126 -0
  14. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +84 -9
  15. package/android/src/main/res/values/native_scroll_coordinator_ids.xml +1 -0
  16. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentitySubtitleBindingTest.kt +177 -0
  17. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +2 -0
  18. package/android/src/test/java/com/margelo/nitro/nativelist/NativeListTitleSegmentLayoutTest.kt +130 -0
  19. package/docs/ROW_TEMPLATES.md +8 -1
  20. package/docs/SPEC.md +312 -5
  21. package/docs/STYLE_SPEC.md +7 -1
  22. package/ios/NativeListAccessoryStack.swift +22 -0
  23. package/ios/NativeListActivityDetailsView.swift +45 -1
  24. package/ios/NativeListDataRowRenderer.swift +12 -5
  25. package/ios/NativeListIdentityRenderer.swift +145 -66
  26. package/ios/NativeListLeadingVisual.swift +8 -0
  27. package/ios/NativeListMarketRenderer.swift +6 -2
  28. package/ios/NativeListModels.swift +7 -0
  29. package/ios/NativeListResolvedText.swift +9 -7
  30. package/ios/NativeListSectionHeaderRenderer.swift +9 -43
  31. package/ios/NativeListTextStyles.swift +72 -12
  32. package/ios/NativeListTitleSegmentLayout.swift +72 -0
  33. package/ios/NativeListTitleSegmentsLabel.swift +92 -0
  34. package/ios/RNCNativeListView.swift +203 -45
  35. package/ios/tests/NativeListActivityPresentationTests.swift +137 -0
  36. package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +155 -0
  37. package/ios/tests/NativeListLifecycleTests.swift +298 -24
  38. package/ios/tests/NativeListMediaVisibilityTests.swift +2 -1
  39. package/lib/module/models.js +2 -0
  40. package/lib/module/validation.js +96 -13
  41. package/lib/module/web/NativeListWebEngine.js +427 -100
  42. package/lib/module/web/templates/ActivityRowRenderer.js +1 -1
  43. package/lib/module/web/templates/IdentityRowRenderer.js +134 -3
  44. package/lib/module/web/templates/MarketRowRenderer.js +2 -0
  45. package/lib/module/web/templates/MediaTileRowRenderer.js +1 -0
  46. package/lib/module/web/templates/RowElements.js +2 -2
  47. package/lib/module/web/templates/RowText.js +2 -0
  48. package/lib/typescript/src/models.d.ts +35 -1
  49. package/lib/typescript/src/web/NativeListWebEngine.d.ts +17 -2
  50. package/lib/typescript/src/web/templates/RowRendererRegistry.d.ts +6 -2
  51. package/lib/typescript/src/web/templates/RowVisual.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/src/models.ts +38 -0
  54. package/src/validation.ts +196 -6
  55. package/src/web/NativeListWebEngine.ts +671 -112
  56. package/src/web/templates/ActivityRowRenderer.ts +1 -1
  57. package/src/web/templates/IdentityRowRenderer.ts +208 -3
  58. package/src/web/templates/MarketRowRenderer.ts +2 -0
  59. package/src/web/templates/MediaTileRowRenderer.ts +1 -0
  60. package/src/web/templates/RowElements.ts +3 -2
  61. package/src/web/templates/RowText.ts +6 -0
  62. package/src/web/templates/RowVisual.ts +2 -1
@@ -184,7 +184,7 @@ function assertTextStyle(style, path, additionalKeys = []) {
184
184
  if (typeof style !== 'object' || style === null || Array.isArray(style)) {
185
185
  fail(path, 'must be an object');
186
186
  }
187
- assertUnknownKeys(style, ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', ...additionalKeys], path, 'text style key');
187
+ assertUnknownKeys(style, ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', 'letterSpacing', 'tabularNumbers', ...additionalKeys], path, 'text style key');
188
188
  if (style.color !== undefined && (typeof style.color !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(style.color))) {
189
189
  fail(`${path}.color`, 'must be #RRGGBB or #RRGGBBAA');
190
190
  }
@@ -209,6 +209,8 @@ function assertTextStyle(style, path, additionalKeys = []) {
209
209
  fail(`${path}.verticalAlignment`, 'must be top, center, or bottom');
210
210
  }
211
211
  assertBoundedStyleNumber(style.offsetY, `${path}.offsetY`, -8, 8);
212
+ assertBoundedStyleNumber(style.letterSpacing, `${path}.letterSpacing`, -4, 10);
213
+ if (style.tabularNumbers !== undefined && typeof style.tabularNumbers !== 'boolean') fail(`${path}.tabularNumbers`, 'must be a boolean');
212
214
  }
213
215
  function assertBoxStyle(style, path) {
214
216
  const container = style.container;
@@ -702,6 +704,68 @@ function assertButtonGroup(row, path) {
702
704
  }
703
705
  });
704
706
  }
707
+ const MAX_TITLE_SEGMENTS = 4;
708
+ const HEX_COLOR_PATTERN = /^#[0-9a-f]{6}([0-9a-f]{2})?$/i;
709
+ function assertTitleSegments(value, path) {
710
+ if (!Array.isArray(value) || value.length === 0 || value.length > MAX_TITLE_SEGMENTS) fail(path, `must hold 1...${MAX_TITLE_SEGMENTS} segments`);
711
+ let shrinking = 0;
712
+ // Array.from also visits holes, so a sparse list is rejected here and the
713
+ // production sanitizer drops it before protocol validation walks it.
714
+ Array.from(value).forEach((item, index) => {
715
+ const segmentPath = `${path}[${index}]`;
716
+ const segment = protocolObject(item, segmentPath);
717
+ assertUnknownKeys(segment, ['text', 'tone', 'fontWeight', 'shrink', 'maxWidthRatio'], segmentPath, 'title segment key');
718
+ const {
719
+ text,
720
+ tone,
721
+ fontWeight,
722
+ shrink,
723
+ maxWidthRatio
724
+ } = segment;
725
+ if (typeof text !== 'string' || !text.trim()) fail(`${segmentPath}.text`, 'must be non-blank');
726
+ assertText(text, `${segmentPath}.text`);
727
+ if (tone !== undefined && tone !== 'primary' && tone !== 'secondary') fail(`${segmentPath}.tone`, 'must be primary or secondary');
728
+ if (fontWeight !== undefined && fontWeight !== 'regular' && fontWeight !== 'medium') fail(`${segmentPath}.fontWeight`, 'must be regular or medium');
729
+ if (shrink !== undefined && typeof shrink !== 'boolean') fail(`${segmentPath}.shrink`, 'must be a boolean');
730
+ if (shrink) shrinking += 1;
731
+ if (maxWidthRatio !== undefined && (typeof maxWidthRatio !== 'number' || !Number.isFinite(maxWidthRatio) || maxWidthRatio <= 0 || maxWidthRatio > 1)) fail(`${segmentPath}.maxWidthRatio`, 'must be finite within (0, 1]');
732
+ });
733
+ if (shrinking > 1) fail(path, 'allows at most one shrinking segment');
734
+ }
735
+ function assertTitleLeadingIcon(value, path) {
736
+ const icon = protocolObject(value, path);
737
+ assertUnknownKeys(icon, ['name', 'tintColor', 'accessibilityLabel'], path, 'title leading icon key');
738
+ const {
739
+ name,
740
+ tintColor,
741
+ accessibilityLabel
742
+ } = icon;
743
+ if (typeof name !== 'string' || !name.trim()) fail(`${path}.name`, 'must be non-blank');
744
+ if (tintColor !== undefined && (typeof tintColor !== 'string' || !HEX_COLOR_PATTERN.test(tintColor))) fail(`${path}.tintColor`, 'must be #RRGGBB or #RRGGBBAA');
745
+ if (accessibilityLabel !== undefined && typeof accessibilityLabel !== 'string') fail(`${path}.accessibilityLabel`, 'must be a string');
746
+ }
747
+ function assertIdentityTitleRuns(row, path) {
748
+ if (row.titleSegments !== undefined) {
749
+ assertTitleSegments(row.titleSegments, `${path}.titleSegments`);
750
+ // titleMatch ranges index `title`, which the runs replace on screen.
751
+ if (row.titleMatch?.length) fail(`${path}.titleMatch`, 'cannot be combined with titleSegments');
752
+ if (row.presentation === 'walletSidebar') fail(`${path}.titleSegments`, 'is not supported with walletSidebar');
753
+ }
754
+ if (row.titleLeadingIcon !== undefined) {
755
+ assertTitleLeadingIcon(row.titleLeadingIcon, `${path}.titleLeadingIcon`);
756
+ if (row.presentation === 'walletSidebar') fail(`${path}.titleLeadingIcon`, 'is not supported with walletSidebar');
757
+ }
758
+ }
759
+
760
+ /** Production keeps decorative title runs only when they pass the rules. */
761
+ function passesTitleRunRules(check) {
762
+ try {
763
+ check();
764
+ return true;
765
+ } catch {
766
+ return false;
767
+ }
768
+ }
705
769
 
706
770
  // A passive label: its text and two caller colors, with no action or style slot.
707
771
  function assertWebLeadingBadge(value, path) {
@@ -791,6 +855,7 @@ function assertLeadingVisual(visual, path) {
791
855
  // OneKey patch: validate optional selector overlays at the JSON boundary.
792
856
  assertText(visual.fallbackIcon?.name, `${path}.fallbackIcon.name`);
793
857
  if (visual.fallbackTextColor !== undefined && (typeof visual.fallbackTextColor !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackTextColor))) fail(`${path}.fallbackTextColor`, 'must be a hex color');
858
+ if ('borderWidth' in visual && visual.borderWidth !== undefined && (typeof visual.borderWidth !== 'number' || !Number.isFinite(visual.borderWidth) || visual.borderWidth <= 0 || visual.borderWidth > 4)) fail(`${path}.borderWidth`, 'must be within (0, 4]');
794
859
  if (visual.fallbackIcon?.size !== undefined && (!Number.isFinite(visual.fallbackIcon.size) || visual.fallbackIcon.size <= 0 || visual.fallbackIcon.size > 40)) fail(`${path}.fallbackIcon.size`, 'must be within (0, 40]');
795
860
  if (visual.fallbackIcon?.backgroundColor !== undefined && !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(visual.fallbackIcon.backgroundColor)) fail(`${path}.fallbackIcon.backgroundColor`, 'must be a hex color');
796
861
  if ((visual.overlays?.length ?? 0) > 2) fail(`${path}.overlays`, 'supports at most two overlays');
@@ -951,6 +1016,7 @@ function assertRow(row, index, path = `rows[${index}]`) {
951
1016
  if (suffix.maxWidth !== undefined && (!Number.isFinite(suffix.maxWidth) || suffix.maxWidth < 0 || suffix.maxWidth > 4096)) fail(`${path}.titleSuffixes[${index}].maxWidth`, 'must be finite within 0...4096');
952
1017
  });
953
1018
  assertIdentityExtras(row, path);
1019
+ assertIdentityTitleRuns(row, path);
954
1020
  assertText(row.subtitle, `${path}.subtitle`);
955
1021
  // OneKey patch: selector text segments truncate independently.
956
1022
  row.subtitleSegments?.forEach((segment, segmentIndex) => {
@@ -1248,7 +1314,7 @@ function assertSnapshotContract(snapshot) {
1248
1314
  }
1249
1315
  const COMMON_ROW_FIELDS = ['height', 'heightRounding', 'testID', 'opacity', 'backgroundColor', 'backgroundFullWidth', 'pressDisabled', 'key', 'revision', 'sectionKey', 'groupId', 'groupPosition', 'size', 'density', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'type', 'style'];
1250
1316
  const ROW_FIELDS = {
1251
- identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'badges', 'trailing', 'draggable'],
1317
+ identity: [...COMMON_ROW_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'presentation', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'titleSegments', 'titleLeadingIcon', 'subtitle', 'tertiary', 'tertiaryTone', 'titleLines', 'subtitleLines', 'collapseEmptyTrailing', 'badges', 'trailing', 'draggable'],
1252
1318
  walletGroup: [...COMMON_ROW_FIELDS, 'parent', 'children', 'draggable'],
1253
1319
  rail: [...COMMON_ROW_FIELDS, 'visual', 'title', 'status', 'badge', 'draggable'],
1254
1320
  activity: [...COMMON_ROW_FIELDS, 'leading', 'hideLeading', 'secondaryLeading', 'title', 'description', 'status', 'primaryAmount', 'secondaryAmount', 'amounts', 'badges', 'presentation', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
@@ -1264,7 +1330,7 @@ const ROW_FIELDS = {
1264
1330
  };
1265
1331
  const COMMON_PATCH_FIELDS = ['height', 'heightRounding', 'opacity', 'pressDisabled', 'revision', 'disabled', 'selected', 'accessibilityLabel', 'separator', 'style'];
1266
1332
  const PATCH_FIELDS = {
1267
- identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'badges', 'trailing'],
1333
+ identity: [...COMMON_PATCH_FIELDS, 'contentHeight', 'longPressActionKey', 'titleMatch', 'titleActionKey', 'titleActionOnHover', 'subtitleSegments', 'leading', 'leadingAction', 'title', 'titleSuffixes', 'titleIcon', 'secondaryTitleIcon', 'titleImage', 'titleSegments', 'titleLeadingIcon', 'subtitle', 'tertiary', 'tertiaryTone', 'subtitleLines', 'collapseEmptyTrailing', 'badges', 'trailing'],
1268
1334
  rail: [...COMMON_PATCH_FIELDS, 'title', 'visual', 'status', 'badge'],
1269
1335
  activity: [...COMMON_PATCH_FIELDS, 'presentation', 'leading', 'title', 'badges', 'status', 'hideLeading', 'secondaryLeading', 'description', 'primaryAmount', 'secondaryAmount', 'amounts', 'fee', 'descriptionActionKey', 'descriptionActionStart', 'footerActions'],
1270
1336
  message: [...COMMON_PATCH_FIELDS, 'presentation', 'title', 'unread', 'body', 'bodyLines', 'time', 'thumbnail'],
@@ -1284,8 +1350,8 @@ function protocolObject(value, path) {
1284
1350
  function protocolKey(value, path) {
1285
1351
  if (typeof value !== 'string' || value.trim().length === 0) fail(path, 'must be a non-blank string');
1286
1352
  }
1287
- const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', 'cells', 'points', 'images', 'overlays', 'badges', 'trailing', 'footerActions', 'buttons', 'amounts', 'metrics', 'children', 'subtitleSegments', 'titleMatch', 'selectedKeys', 'segments', 'hoverSecondary', 'hoverImages', 'secondaryBadges', 'fallbackUris', 'probeOrder', 'priceSegments', 'textSegments', 'secondaryTextSegments', 'primaryTextSegments']);
1288
- const PROTOCOL_NUMBER_FIELDS = new Set(['leadingContentMaxWidthRatio', 'height', 'width', 'fontSize', 'lineHeight', 'opacity', 'offsetY', 'offsetX', 'cornerRadius', 'borderWidth', 'horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'start', 'end', 'padding', 'offset', 'overscan', 'minWidth', 'flex', 'paddingStart', 'paddingEnd', 'changeWidth', 'changeHeight', 'changeCornerRadius', 'contentTrailingGap', 'subtitleTrailingPadding', 'partGap', 'contentPadding', 'contentPaddingHorizontal', 'contentPaddingTop', 'contentPaddingBottom', 'itemSpacing', 'gridColumns']);
1353
+ const PROTOCOL_ARRAY_FIELDS = new Set(['columns', 'titleSuffixes', 'titleSegments', 'cells', 'points', 'images', 'overlays', 'badges', 'trailing', 'footerActions', 'buttons', 'amounts', 'metrics', 'children', 'subtitleSegments', 'titleMatch', 'selectedKeys', 'segments', 'hoverSecondary', 'hoverImages', 'secondaryBadges', 'fallbackUris', 'probeOrder', 'priceSegments', 'textSegments', 'secondaryTextSegments', 'primaryTextSegments']);
1354
+ const PROTOCOL_NUMBER_FIELDS = new Set(['leadingContentMaxWidthRatio', 'height', 'width', 'fontSize', 'lineHeight', 'opacity', 'offsetY', 'offsetX', 'letterSpacing', 'cornerRadius', 'borderWidth', 'horizontalPadding', 'verticalPadding', 'leadingGap', 'lineGap', 'titleBadgeGap', 'trailingGap', 'start', 'end', 'padding', 'offset', 'overscan', 'minWidth', 'flex', 'paddingStart', 'paddingEnd', 'changeWidth', 'changeHeight', 'changeCornerRadius', 'contentTrailingGap', 'subtitleTrailingPadding', 'partGap', 'contentPadding', 'contentPaddingHorizontal', 'contentPaddingTop', 'contentPaddingBottom', 'itemSpacing', 'gridColumns']);
1289
1355
 
1290
1356
  /** Validate only shapes that renderers dereference, not display budgets. */
1291
1357
  function assertProtocolFields(value, path, parentField = '') {
@@ -1325,10 +1391,10 @@ function assertProtocolFields(value, path, parentField = '') {
1325
1391
  const fieldPath = `${path}.${field}`;
1326
1392
  if (!path.endsWith('.style') && PROTOCOL_ARRAY_FIELDS.has(field) && !Array.isArray(item)) fail(fieldPath, 'must be an array');
1327
1393
  if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item !== 'number') fail(fieldPath, 'must be a finite number');
1328
- if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item === 'number' && item < 0 && !['offsetX', 'offsetY'].includes(field)) fail(fieldPath, 'must be non-negative');
1394
+ if (PROTOCOL_NUMBER_FIELDS.has(field) && typeof item === 'number' && item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(field)) fail(fieldPath, 'must be non-negative');
1329
1395
  if (parentField === 'overlays' && field === 'fontWeight' && !['regular', 'medium', 'semibold', 'bold'].includes(item)) fail(fieldPath, 'must be regular, medium, semibold, or bold');
1330
1396
  if (field === 'buttonStyle' && item !== 'tertiary') fail(fieldPath, 'must be tertiary');
1331
- if (field === 'hideLeading' && typeof item !== 'boolean') fail(fieldPath, 'must be boolean');
1397
+ if ((field === 'hideLeading' || field === 'collapseEmptyTrailing') && typeof item !== 'boolean') fail(fieldPath, 'must be boolean');
1332
1398
  if (field === 'key' || field === 'sectionKey' || field === 'groupId' || field === 'actionKey' || field.endsWith('ActionKey')) protocolKey(item, fieldPath);
1333
1399
  if ((field === 'uri' || field === 'fallbackUri') && typeof item !== 'string') fail(fieldPath, 'must be a string');
1334
1400
  if (field === 'style' && !(item === 'subscript' && /[Ss]egments\[/.test(path)) || field === 'container') protocolObject(item, fieldPath);
@@ -1355,7 +1421,10 @@ function assertRowProtocol(row, path) {
1355
1421
  }
1356
1422
  if (row.height !== undefined && row.height < 0) fail(`${path}.height`, 'must be non-negative');
1357
1423
  if (row.type === 'identity') {
1358
- if (isDevelopment()) assertIdentityExtras(row, path);
1424
+ if (isDevelopment()) {
1425
+ assertIdentityExtras(row, path);
1426
+ assertIdentityTitleRuns(row, path);
1427
+ }
1359
1428
  if (row.titleSuffixes !== undefined && !Array.isArray(row.titleSuffixes)) fail(`${path}.titleSuffixes`, 'must be an array');
1360
1429
  row.titleSuffixes?.forEach((suffix, index) => {
1361
1430
  protocolObject(suffix, `${path}.titleSuffixes[${index}]`);
@@ -1425,6 +1494,10 @@ function assertRowProtocol(row, path) {
1425
1494
  }
1426
1495
  function assertSnapshotProtocol(snapshot) {
1427
1496
  protocolObject(snapshot, 'snapshot');
1497
+ const reorderActivation = snapshot.capabilities?.reorderActivation;
1498
+ if (reorderActivation !== undefined && reorderActivation !== 'row' && reorderActivation !== 'handle') {
1499
+ fail('snapshot.capabilities.reorderActivation', "must be 'row' or 'handle'");
1500
+ }
1428
1501
  if (snapshot.disclosure !== undefined) {
1429
1502
  protocolObject(snapshot.disclosure, 'snapshot.disclosure');
1430
1503
  if (typeof snapshot.disclosure.expanded !== 'boolean') fail('snapshot.disclosure.expanded', 'must be a boolean');
@@ -1473,8 +1546,8 @@ function isAllowedImageUri(value) {
1473
1546
  }
1474
1547
  const IMAGE_FIELDS = ['uri', 'width', 'height', 'headers', 'contentFit', 'cachePolicy', 'autoplay', 'optimizeTos', 'overscan', 'loadingStrategy', 'fallbackUri', 'fallbackUris', 'retryTimes'];
1475
1548
  const ICON_FIELDS = ['name', 'tintColor', 'backgroundColor', 'size', 'accessibilityLabel', 'hoverActionKey'];
1476
- const VISUAL_FIELDS = ['kind', 'name', 'image', 'images', 'networkImage', 'shape', 'tintColor', 'backgroundColor', 'fallbackIcon', 'fallbackText', 'fallbackTextColor', 'overlays', 'borderStyle', 'borderColor', 'cornerIcon'];
1477
- const TEXT_STYLE_FIELDS = ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY'];
1549
+ const VISUAL_FIELDS = ['kind', 'name', 'image', 'images', 'networkImage', 'shape', 'tintColor', 'backgroundColor', 'fallbackIcon', 'fallbackText', 'fallbackTextColor', 'overlays', 'borderStyle', 'borderColor', 'borderWidth', 'cornerIcon'];
1550
+ const TEXT_STYLE_FIELDS = ['token', 'fontSize', 'fontWeight', 'color', 'lineHeight', 'lines', 'truncate', 'alignment', 'verticalAlignment', 'offsetY', 'letterSpacing', 'tabularNumbers'];
1478
1551
  const ACCESSORY_FIELDS = {
1479
1552
  value: ['kind', 'text', 'secondary', 'textSegments'],
1480
1553
  valuePair: ['kind', 'primary', 'secondary', 'primaryFontWeight', 'primaryHelp', 'primaryTextSegments', 'secondaryTextSegments', 'primaryTone', 'secondaryTone'],
@@ -1610,6 +1683,8 @@ const NESTED_DECORATION_FIELDS = {
1610
1683
  };
1611
1684
  function sanitizeDecoration(value, field) {
1612
1685
  if (value === undefined || value === null) return undefined;
1686
+ if (field === 'titleSegments') return passesTitleRunRules(() => assertTitleSegments(value, field)) ? value : undefined;
1687
+ if (field === 'titleLeadingIcon') return passesTitleRunRules(() => assertTitleLeadingIcon(value, field)) ? value : undefined;
1613
1688
  // All or nothing: a badge without valid text and both colors is dropped, and
1614
1689
  // only its three declared fields are kept.
1615
1690
  if (field === 'webLeadingBadge') {
@@ -1635,6 +1710,7 @@ function sanitizeDecoration(value, field) {
1635
1710
  return field === 'hoverImages' ? items.map(item => item ?? null) : items.filter(item => item !== undefined);
1636
1711
  }
1637
1712
  if (!isRecord(value)) return value;
1713
+ const isLeadingVisual = ['leading', 'visual', 'secondaryLeading'].includes(field);
1638
1714
  let object = value;
1639
1715
  if (field === 'titleImage') {
1640
1716
  const image = sanitizeImage(value.image);
@@ -1651,7 +1727,7 @@ function sanitizeDecoration(value, field) {
1651
1727
  } else if (['titleIcon', 'secondaryTitleIcon', 'fallbackIcon', 'cornerIcon'].includes(field) && value.kind === undefined) {
1652
1728
  if (typeof value.name !== 'string' || !value.name.trim()) return undefined;
1653
1729
  object = pickFields(value, ICON_FIELDS);
1654
- } else if (['leading', 'visual', 'secondaryLeading'].includes(field)) {
1730
+ } else if (isLeadingVisual) {
1655
1731
  object = pickFields(value, VISUAL_FIELDS);
1656
1732
  } else if (field === 'media') {
1657
1733
  object = pickFields(value, ['source', 'probeOrder']);
@@ -1669,6 +1745,9 @@ function sanitizeDecoration(value, field) {
1669
1745
  const next = {};
1670
1746
  for (const [key, item] of Object.entries(object)) {
1671
1747
  if (item === undefined || item === null) continue;
1748
+ if (isLeadingVisual && key === 'borderWidth' && (typeof item !== 'number' || !Number.isFinite(item) || item <= 0 || item > 4)) continue;
1749
+ if (key === 'letterSpacing' && (typeof item !== 'number' || !Number.isFinite(item) || item < -4 || item > 10)) continue;
1750
+ if (key === 'tabularNumbers' && typeof item !== 'boolean') continue;
1672
1751
  if ((/color$/i.test(key) || /background$/i.test(key)) && (typeof item !== 'string' || !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(item))) continue;
1673
1752
  if (/TextSegments$/.test(key) || ['textSegments', 'priceSegments', 'subtitleSegments', 'segments'].includes(key)) {
1674
1753
  if (!Array.isArray(item) || item.some(segment => !isRecord(segment) || typeof segment.text !== 'string')) continue;
@@ -1681,7 +1760,7 @@ function sanitizeDecoration(value, field) {
1681
1760
  if (key === 'buttonStyle' && item !== 'tertiary') continue;
1682
1761
  if (key === 'hoverActionKey' && (typeof item !== 'string' || !item.trim())) continue;
1683
1762
  if (key === 'accessibilityLabel' && typeof item !== 'string') continue;
1684
- if ((field === 'style' || PROTOCOL_NUMBER_FIELDS.has(key)) && typeof item !== 'object' && typeof item === 'number' && (!Number.isFinite(item) || item < 0 && !['offsetX', 'offsetY'].includes(key))) continue;
1763
+ if ((field === 'style' || PROTOCOL_NUMBER_FIELDS.has(key)) && typeof item !== 'object' && typeof item === 'number' && (!Number.isFinite(item) || item < 0 && !['offsetX', 'offsetY', 'letterSpacing'].includes(key))) continue;
1685
1764
  if (field === 'style' && PROTOCOL_NUMBER_FIELDS.has(key) && typeof item !== 'number') continue;
1686
1765
  if (key === 'leadingContentMaxWidthRatio' && (typeof item !== 'number' || item <= 0 || item > 1)) continue;
1687
1766
  const normalized = sanitizeDecoration(item, field === 'style' && key === 'image' ? 'imageStyle' : key);
@@ -1948,6 +2027,8 @@ function assertPatchChanges(patch, index) {
1948
2027
  if (suffix.maxWidth !== undefined && (!Number.isFinite(suffix.maxWidth) || suffix.maxWidth < 0 || suffix.maxWidth > 4096)) fail(`${path}.titleSuffixes[${index}].maxWidth`, 'must be finite within 0...4096');
1949
2028
  });
1950
2029
  assertIdentityExtras(patch.changes, path);
2030
+ // A null clear never reaches here; a replacement follows the row rules.
2031
+ assertIdentityTitleRuns(patch.changes, path);
1951
2032
  assertText(patch.changes.subtitle, `${path}.subtitle`);
1952
2033
  assertText(patch.changes.tertiary, `${path}.tertiary`);
1953
2034
  if (patch.changes.tertiaryTone !== undefined && !['secondary', 'info'].includes(patch.changes.tertiaryTone)) {
@@ -2141,7 +2222,9 @@ function normalizePatch(patch, index) {
2141
2222
  continue;
2142
2223
  }
2143
2224
  const canonical = isDevelopment() ? normalized : patch.type === 'market' && field === 'metrics' ? sanitizeMarketMetrics(normalized) : sanitizeDecoration(normalized, field);
2144
- if (canonical !== undefined) changes[field] = canonical;else if (field === 'titleImage') changes[field] = null;
2225
+ if (canonical !== undefined) changes[field] = canonical;
2226
+ // A rejected title decoration clears the old one instead of leaving it drawn.
2227
+ else if (['titleImage', 'titleSegments', 'titleLeadingIcon'].includes(field)) changes[field] = null;
2145
2228
  }
2146
2229
  if (patch.type === 'market' && Array.isArray(changes.priceSegments) && changes.priceSegments.length > 0 && (typeof changes.price !== 'string' || !changes.price.trim())) fail(`${path}.changes.price`, 'is required when priceSegments is updated');
2147
2230
  if (!isDevelopment()) {