@oxyhq/bloom 1.13.0 → 1.14.1

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 (114) hide show
  1. package/README.md +1 -1
  2. package/docs/avatar.mdx +46 -5
  3. package/docs/index.mdx +1 -1
  4. package/docs/media-flight.mdx +15 -6
  5. package/docs/tab-bar.mdx +35 -0
  6. package/lib/commonjs/avatar/Avatar.js +24 -8
  7. package/lib/commonjs/avatar/Avatar.js.map +1 -1
  8. package/lib/commonjs/avatar/AvatarRing.js +13 -12
  9. package/lib/commonjs/avatar/AvatarRing.js.map +1 -1
  10. package/lib/commonjs/avatar/index.js +19 -0
  11. package/lib/commonjs/avatar/index.js.map +1 -1
  12. package/lib/commonjs/avatar/resolve-shape.js +43 -0
  13. package/lib/commonjs/avatar/resolve-shape.js.map +1 -0
  14. package/lib/commonjs/avatar/shape-paths.js +174 -0
  15. package/lib/commonjs/avatar/shape-paths.js.map +1 -0
  16. package/lib/commonjs/media-flight/MediaSurface.js +51 -10
  17. package/lib/commonjs/media-flight/MediaSurface.js.map +1 -1
  18. package/lib/commonjs/media-flight/constants.js +32 -7
  19. package/lib/commonjs/media-flight/constants.js.map +1 -1
  20. package/lib/commonjs/tab-bar/TabBarBase.js +87 -13
  21. package/lib/commonjs/tab-bar/TabBarBase.js.map +1 -1
  22. package/lib/commonjs/tab-bar/expo-router/RouterTabBar.js +5 -0
  23. package/lib/commonjs/tab-bar/expo-router/RouterTabBar.js.map +1 -1
  24. package/lib/commonjs/theme/color-scope/ColorScope.js +42 -12
  25. package/lib/commonjs/theme/color-scope/ColorScope.js.map +1 -1
  26. package/lib/commonjs/theme/color-scope/ColorScope.web.js +2 -8
  27. package/lib/commonjs/theme/color-scope/ColorScope.web.js.map +1 -1
  28. package/lib/module/avatar/Avatar.js +24 -8
  29. package/lib/module/avatar/Avatar.js.map +1 -1
  30. package/lib/module/avatar/AvatarRing.js +13 -12
  31. package/lib/module/avatar/AvatarRing.js.map +1 -1
  32. package/lib/module/avatar/index.js +1 -0
  33. package/lib/module/avatar/index.js.map +1 -1
  34. package/lib/module/avatar/resolve-shape.js +40 -0
  35. package/lib/module/avatar/resolve-shape.js.map +1 -0
  36. package/lib/module/avatar/shape-paths.js +170 -0
  37. package/lib/module/avatar/shape-paths.js.map +1 -0
  38. package/lib/module/media-flight/MediaSurface.js +52 -11
  39. package/lib/module/media-flight/MediaSurface.js.map +1 -1
  40. package/lib/module/media-flight/constants.js +31 -6
  41. package/lib/module/media-flight/constants.js.map +1 -1
  42. package/lib/module/tab-bar/TabBarBase.js +89 -15
  43. package/lib/module/tab-bar/TabBarBase.js.map +1 -1
  44. package/lib/module/tab-bar/expo-router/RouterTabBar.js +5 -0
  45. package/lib/module/tab-bar/expo-router/RouterTabBar.js.map +1 -1
  46. package/lib/module/theme/color-scope/ColorScope.js +45 -13
  47. package/lib/module/theme/color-scope/ColorScope.js.map +1 -1
  48. package/lib/module/theme/color-scope/ColorScope.web.js +3 -9
  49. package/lib/module/theme/color-scope/ColorScope.web.js.map +1 -1
  50. package/lib/typescript/commonjs/avatar/Avatar.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/avatar/AvatarRing.d.ts +4 -3
  52. package/lib/typescript/commonjs/avatar/AvatarRing.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/avatar/index.d.ts +3 -1
  54. package/lib/typescript/commonjs/avatar/index.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/avatar/resolve-shape.d.ts +17 -0
  56. package/lib/typescript/commonjs/avatar/resolve-shape.d.ts.map +1 -0
  57. package/lib/typescript/commonjs/avatar/shape-paths.d.ts +27 -0
  58. package/lib/typescript/commonjs/avatar/shape-paths.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/avatar/types.d.ts +30 -3
  60. package/lib/typescript/commonjs/avatar/types.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/media-flight/MediaSurface.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/media-flight/constants.d.ts +30 -6
  63. package/lib/typescript/commonjs/media-flight/constants.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/media-flight/types.d.ts +7 -2
  65. package/lib/typescript/commonjs/media-flight/types.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/tab-bar/TabBarBase.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/tab-bar/expo-router/RouterTabBar.d.ts +5 -0
  68. package/lib/typescript/commonjs/tab-bar/expo-router/RouterTabBar.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/tab-bar/types.d.ts +36 -5
  70. package/lib/typescript/commonjs/tab-bar/types.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/theme/color-scope/ColorScope.d.ts +36 -2
  72. package/lib/typescript/commonjs/theme/color-scope/ColorScope.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/theme/color-scope/ColorScope.web.d.ts +6 -2
  74. package/lib/typescript/commonjs/theme/color-scope/ColorScope.web.d.ts.map +1 -1
  75. package/lib/typescript/module/avatar/Avatar.d.ts.map +1 -1
  76. package/lib/typescript/module/avatar/AvatarRing.d.ts +4 -3
  77. package/lib/typescript/module/avatar/AvatarRing.d.ts.map +1 -1
  78. package/lib/typescript/module/avatar/index.d.ts +3 -1
  79. package/lib/typescript/module/avatar/index.d.ts.map +1 -1
  80. package/lib/typescript/module/avatar/resolve-shape.d.ts +17 -0
  81. package/lib/typescript/module/avatar/resolve-shape.d.ts.map +1 -0
  82. package/lib/typescript/module/avatar/shape-paths.d.ts +27 -0
  83. package/lib/typescript/module/avatar/shape-paths.d.ts.map +1 -0
  84. package/lib/typescript/module/avatar/types.d.ts +30 -3
  85. package/lib/typescript/module/avatar/types.d.ts.map +1 -1
  86. package/lib/typescript/module/media-flight/MediaSurface.d.ts.map +1 -1
  87. package/lib/typescript/module/media-flight/constants.d.ts +30 -6
  88. package/lib/typescript/module/media-flight/constants.d.ts.map +1 -1
  89. package/lib/typescript/module/media-flight/types.d.ts +7 -2
  90. package/lib/typescript/module/media-flight/types.d.ts.map +1 -1
  91. package/lib/typescript/module/tab-bar/TabBarBase.d.ts.map +1 -1
  92. package/lib/typescript/module/tab-bar/expo-router/RouterTabBar.d.ts +5 -0
  93. package/lib/typescript/module/tab-bar/expo-router/RouterTabBar.d.ts.map +1 -1
  94. package/lib/typescript/module/tab-bar/types.d.ts +36 -5
  95. package/lib/typescript/module/tab-bar/types.d.ts.map +1 -1
  96. package/lib/typescript/module/theme/color-scope/ColorScope.d.ts +36 -2
  97. package/lib/typescript/module/theme/color-scope/ColorScope.d.ts.map +1 -1
  98. package/lib/typescript/module/theme/color-scope/ColorScope.web.d.ts +6 -2
  99. package/lib/typescript/module/theme/color-scope/ColorScope.web.d.ts.map +1 -1
  100. package/package.json +1 -1
  101. package/src/avatar/Avatar.tsx +27 -10
  102. package/src/avatar/AvatarRing.tsx +21 -14
  103. package/src/avatar/index.ts +7 -0
  104. package/src/avatar/resolve-shape.ts +33 -0
  105. package/src/avatar/shape-paths.ts +150 -0
  106. package/src/avatar/types.ts +32 -3
  107. package/src/media-flight/MediaSurface.tsx +60 -14
  108. package/src/media-flight/constants.ts +31 -6
  109. package/src/media-flight/types.ts +7 -2
  110. package/src/tab-bar/TabBarBase.tsx +110 -17
  111. package/src/tab-bar/expo-router/RouterTabBar.tsx +5 -0
  112. package/src/tab-bar/types.ts +36 -5
  113. package/src/theme/color-scope/ColorScope.tsx +53 -12
  114. package/src/theme/color-scope/ColorScope.web.tsx +10 -8
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Named avatar outlines.
5
+ *
6
+ * Each entry is an SVG path drawn in a 100×100 square coordinate space, scaled
7
+ * at render time to the avatar's pixel size. That space is declared once in
8
+ * {@link NAMED_SHAPE_VIEW_BOX} rather than baked into the numbers, so the paths
9
+ * can be read and edited at human-friendly magnitudes. The built-in squircle
10
+ * lives in `squircle-path.ts` and uses a 0–1 space; both are supported because
11
+ * {@link AvatarShapePath} carries its own `viewBox`.
12
+ *
13
+ * `circle` is deliberately absent: a circular avatar is rendered with
14
+ * `borderRadius` and never reaches the SVG renderer.
15
+ */
16
+
17
+ /** Side length of the coordinate space every path below is drawn in. */
18
+ export const NAMED_SHAPE_VIEW_BOX = 100;
19
+ export const AVATAR_SHAPE_PATHS = {
20
+ // --- Basic ---
21
+ square: 'M12 0H88Q100 0 100 12V88Q100 100 88 100H12Q0 100 0 88V12Q0 0 12 0Z',
22
+ slanted: 'M22 0H88Q100 0 100 12V78Q100 100 78 100H12Q0 100 0 88V22Q0 0 22 0Z',
23
+ arch: 'M50 0Q100 0 100 50V88Q100 100 88 100H12Q0 100 0 88V50Q0 0 50 0Z',
24
+ semicircle: 'M0 50A50 50 0 0 1 100 50V88Q100 100 88 100H12Q0 100 0 88Z',
25
+ // --- Organic ---
26
+ oval: 'M50 2C78 2 96 22 96 50S78 98 50 98S4 78 4 50S22 2 50 2Z',
27
+ pill: 'M34 4H66Q96 4 96 34V66Q96 96 66 96H34Q4 96 4 66V34Q4 4 34 4Z',
28
+ triangle: 'M50 5L95 90Q97 95 92 95H8Q3 95 5 90Z',
29
+ arrow: 'M50 0L100 45Q100 52 94 52H68V92Q68 100 58 100H42Q32 100 32 92V52H6Q0 52 0 45Z',
30
+ fan: 'M50 8Q90 8 96 48Q100 78 70 96Q50 108 30 96Q0 78 4 48Q10 8 50 8Z',
31
+ // --- Geometric ---
32
+ diamond: 'M50 2L96 50L50 98L4 50Z',
33
+ clamshell: 'M10 20Q10 4 26 4H74Q90 4 90 20V60Q90 96 50 96Q10 96 10 60Z',
34
+ pentagon: 'M50 2L97 36L79 96H21L3 36Z',
35
+ gem: 'M30 4H70L98 36L50 98L2 36Z',
36
+ // --- Sunny/Cookie ---
37
+ 'very-sunny': 'M50 0L58 20L78 6L72 28L96 22L82 42L100 50L82 58L96 78L72 72L78 94L58 80L50 100L42 80L22 94L28 72L4 78L18 58L0 50L18 42L4 22L28 28L22 6L42 20Z',
38
+ sunny: 'M50 4L60 24L80 10L74 32L98 28L84 48L100 50L84 52L98 72L74 68L80 90L60 76L50 96L40 76L20 90L26 68L2 72L16 52L0 50L16 48L2 28L26 32L20 10L40 24Z',
39
+ '4-sided-cookie': 'M50 2Q76 22 76 50Q76 78 50 98Q24 78 24 50Q24 22 50 2Z',
40
+ '6-sided-cookie': 'M50 2Q72 10 82 30Q92 52 80 74Q66 96 44 96Q22 96 10 74Q-2 52 10 30Q22 10 50 2Z',
41
+ '7-sided-cookie': 'M50 2Q70 6 84 22Q96 40 94 62Q90 82 74 94Q56 102 38 96Q20 88 10 70Q2 50 8 32Q18 10 50 2Z',
42
+ '9-sided-cookie': 'M50 2Q64 4 76 14Q86 26 92 42Q94 58 88 72Q78 86 64 94Q50 98 36 94Q22 86 12 72Q6 58 8 42Q14 26 24 14Q36 4 50 2Z',
43
+ '12-sided-cookie': 'M50 2L62 6L74 14L84 26L90 40L92 54L88 68L80 80L68 88L54 92L40 90L28 84L18 72L10 58L8 44L12 30L20 18L32 10L44 4Z',
44
+ // --- Nature ---
45
+ '4-leaf-clover': 'M50 4Q70 4 70 26Q96 26 96 50Q96 74 70 74Q70 96 50 96Q30 96 30 74Q4 74 4 50Q4 26 30 26Q30 4 50 4Z',
46
+ '8-leaf-clover': 'M50 2Q60 16 72 8Q84 16 80 30Q96 32 92 46Q100 60 86 66Q92 80 78 84Q76 98 60 92Q52 100 42 92Q28 98 24 84Q10 80 16 66Q2 60 10 46Q6 32 22 30Q18 16 30 8Q42 16 50 2Z',
47
+ burst: 'M50 0L56 30L80 6L62 34L100 26L70 44L100 50L70 56L100 74L62 66L80 94L56 70L50 100L44 70L20 94L38 66L0 74L30 56L0 50L30 44L0 26L38 34L20 6L44 30Z',
48
+ 'soft-burst': 'M50 4L58 28L78 8L66 32L96 24L76 44L98 50L76 56L96 76L66 68L78 92L58 72L50 96L42 72L22 92L34 68L4 76L24 56L2 50L24 44L4 24L34 32L22 8L42 28Z',
49
+ boom: 'M50 0L54 18L62 2L60 20L76 6L68 24L88 14L76 30L98 24L82 38L100 38L86 46L100 50L86 54L100 62L82 62L98 76L76 70L88 86L68 76L76 94L60 80L62 98L54 82L50 100L46 82L38 98L40 80L24 94L32 76L12 86L24 70L2 76L18 62L0 62L14 54L0 50L14 46L0 38L18 38L2 24L24 30L12 14L32 24L24 6L40 20L38 2L46 18Z',
50
+ 'soft-boom': 'M50 4L56 22L68 6L64 26L82 14L74 32L94 24L82 40L100 36L86 48L100 50L86 52L100 64L82 60L94 76L74 68L82 86L64 74L68 94L56 78L50 96L44 78L32 94L36 74L18 86L26 68L6 76L18 60L0 64L14 52L0 50L14 48L0 36L18 40L6 24L26 32L18 14L36 26L32 6L44 22Z',
51
+ flower: 'M50 4Q62 18 72 10Q82 18 76 32Q90 30 88 44Q98 50 88 56Q90 70 76 68Q82 82 72 90Q62 82 50 96Q38 82 28 90Q18 82 24 68Q10 70 12 56Q2 50 12 44Q10 30 24 32Q18 18 28 10Q38 18 50 4Z',
52
+ puffy: 'M34 6Q50-4 66 6Q84 6 90 22Q104 34 96 50Q104 66 90 78Q84 94 66 94Q50 104 34 94Q16 94 10 78Q-4 66 4 50Q-4 34 10 22Q16 6 34 6Z',
53
+ 'puffy-diamond': 'M50 2Q66 10 72 4Q86 12 84 28Q98 32 94 48Q100 64 86 70Q88 86 72 88Q62 98 48 94Q34 100 26 86Q12 88 8 72Q-2 62 6 48Q0 32 16 28Q14 12 28 4Q38 10 50 2Z',
54
+ // --- Fun ---
55
+ 'ghost-ish': 'M20 96V40Q20 4 50 4Q80 4 80 40V96L70 86L60 96L50 86L40 96L30 86Z',
56
+ 'pixel-circle': 'M30 4H70V4H86V14H96V30H100V70H96V86H86V96H70V100H30V96H14V86H4V70H0V30H4V14H14V4H30Z',
57
+ 'pixel-triangle': 'M42 4H58V18H70V32H82V46H94V60H100V100H0V60H6V46H18V32H30V18H42Z',
58
+ bun: 'M12 54Q-4 24 20 8Q44-6 68 8Q92 22 94 50Q96 72 76 88Q56 100 36 96Q14 90 12 54Z',
59
+ heart: 'M50 90C25 70 2 55 2 32Q2 10 24 6Q40 2 50 18Q60 2 76 6Q98 10 98 32Q98 55 75 70Z'
60
+ };
61
+
62
+ /**
63
+ * Display labels for the named shapes, in the order a picker should show them.
64
+ * Exported so consumers building a shape picker do not re-derive the order (or
65
+ * the capitalisation) themselves.
66
+ */
67
+ export const AVATAR_SHAPE_LABELS = [{
68
+ name: 'square',
69
+ label: 'Square'
70
+ }, {
71
+ name: 'slanted',
72
+ label: 'Slanted'
73
+ }, {
74
+ name: 'arch',
75
+ label: 'Arch'
76
+ }, {
77
+ name: 'semicircle',
78
+ label: 'Semicircle'
79
+ }, {
80
+ name: 'oval',
81
+ label: 'Oval'
82
+ }, {
83
+ name: 'pill',
84
+ label: 'Pill'
85
+ }, {
86
+ name: 'triangle',
87
+ label: 'Triangle'
88
+ }, {
89
+ name: 'arrow',
90
+ label: 'Arrow'
91
+ }, {
92
+ name: 'fan',
93
+ label: 'Fan'
94
+ }, {
95
+ name: 'diamond',
96
+ label: 'Diamond'
97
+ }, {
98
+ name: 'clamshell',
99
+ label: 'Clamshell'
100
+ }, {
101
+ name: 'pentagon',
102
+ label: 'Pentagon'
103
+ }, {
104
+ name: 'gem',
105
+ label: 'Gem'
106
+ }, {
107
+ name: 'very-sunny',
108
+ label: 'Very Sunny'
109
+ }, {
110
+ name: 'sunny',
111
+ label: 'Sunny'
112
+ }, {
113
+ name: '4-sided-cookie',
114
+ label: '4-Sided Cookie'
115
+ }, {
116
+ name: '6-sided-cookie',
117
+ label: '6-Sided Cookie'
118
+ }, {
119
+ name: '7-sided-cookie',
120
+ label: '7-Sided Cookie'
121
+ }, {
122
+ name: '9-sided-cookie',
123
+ label: '9-Sided Cookie'
124
+ }, {
125
+ name: '12-sided-cookie',
126
+ label: '12-Sided Cookie'
127
+ }, {
128
+ name: '4-leaf-clover',
129
+ label: '4-Leaf Clover'
130
+ }, {
131
+ name: '8-leaf-clover',
132
+ label: '8-Leaf Clover'
133
+ }, {
134
+ name: 'burst',
135
+ label: 'Burst'
136
+ }, {
137
+ name: 'soft-burst',
138
+ label: 'Soft Burst'
139
+ }, {
140
+ name: 'boom',
141
+ label: 'Boom'
142
+ }, {
143
+ name: 'soft-boom',
144
+ label: 'Soft Boom'
145
+ }, {
146
+ name: 'flower',
147
+ label: 'Flower'
148
+ }, {
149
+ name: 'puffy',
150
+ label: 'Puffy'
151
+ }, {
152
+ name: 'puffy-diamond',
153
+ label: 'Puffy Diamond'
154
+ }, {
155
+ name: 'ghost-ish',
156
+ label: 'Ghost-ish'
157
+ }, {
158
+ name: 'pixel-circle',
159
+ label: 'Pixel Circle'
160
+ }, {
161
+ name: 'pixel-triangle',
162
+ label: 'Pixel Triangle'
163
+ }, {
164
+ name: 'bun',
165
+ label: 'Bun'
166
+ }, {
167
+ name: 'heart',
168
+ label: 'Heart'
169
+ }];
170
+ //# sourceMappingURL=shape-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NAMED_SHAPE_VIEW_BOX","AVATAR_SHAPE_PATHS","square","slanted","arch","semicircle","oval","pill","triangle","arrow","fan","diamond","clamshell","pentagon","gem","sunny","burst","boom","flower","puffy","bun","heart","AVATAR_SHAPE_LABELS","name","label"],"sourceRoot":"../../../src","sources":["avatar/shape-paths.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMA,oBAAoB,GAAG,GAAG;AAYvC,OAAO,MAAMC,kBAAmD,GAAG;EACjE;EACAC,MAAM,EACJ,oEAAoE;EACtEC,OAAO,EACL,oEAAoE;EACtEC,IAAI,EACF,iEAAiE;EACnEC,UAAU,EACR,2DAA2D;EAE7D;EACAC,IAAI,EACF,yDAAyD;EAC3DC,IAAI,EACF,8DAA8D;EAChEC,QAAQ,EACN,sCAAsC;EACxCC,KAAK,EACH,+EAA+E;EACjFC,GAAG,EACD,iEAAiE;EAEnE;EACAC,OAAO,EACL,yBAAyB;EAC3BC,SAAS,EACP,4DAA4D;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ACjC;EAAED,IAAI,EAAE,eAAe;EAAEC,KAAK,EAAE;AAAgB,CAAC,EACjD;EAAED,IAAI,EAAE,WAAW;EAAEC,KAAK,EAAE;AAAY,CAAC,EACzC;EAAED,IAAI,EAAE,cAAc;EAAEC,KAAK,EAAE;AAAe,CAAC,EAC/C;EAAED,IAAI,EAAE,gBAAgB;EAAEC,KAAK,EAAE;AAAiB,CAAC,EACnD;EAAED,IAAI,EAAE,KAAK;EAAEC,KAAK,EAAE;AAAM,CAAC,EAC7B;EAAED,IAAI,EAAE,OAAO;EAAEC,KAAK,EAAE;AAAQ,CAAC,CAClC","ignoreList":[]}
@@ -19,7 +19,7 @@ import { memo, useCallback, useEffect, useRef, useState } from 'react';
19
19
  import { Platform, StyleSheet, View } from 'react-native';
20
20
  import { Image } from 'expo-image';
21
21
  import Animated from 'react-native-reanimated';
22
- import { SLOT_IDENTITY_CHURN_LIMIT } from "./constants.js";
22
+ import { SLOT_IDENTITY_CHURN_LIMIT, SLOT_IDENTITY_CHURN_WINDOW_MS } from "./constants.js";
23
23
  import { handOffFlight } from "./store.js";
24
24
  import { loadExpoVideo, warnExpoVideoUnavailable } from "./expo-video-module.js";
25
25
 
@@ -69,17 +69,58 @@ export const MediaSurface = /*#__PURE__*/memo(function MediaSurface({
69
69
  // supports.
70
70
  const [mountedSurfaceType] = useState(surfaceType);
71
71
 
72
- // A slot rebuilt on every render republishes this surface to the layer on
73
- // every render, which nothing at runtime reports the picture is correct and
74
- // the app is doing work in proportion to how often its rows re-render. The
75
- // counter lives in an effect rather than in render: a render-phase ref write
76
- // makes the React Compiler bail on the whole component.
77
- const slotChurn = useRef(0);
72
+ // A slot rebuilt on every render re-renders this surface and on web
73
+ // republishes the shared node every time the row it lives in renders, which
74
+ // nothing at runtime reports: the picture is correct and the app is just
75
+ // doing work in proportion to its render count.
76
+ //
77
+ // What is counted is a RUN of consecutive commits that each carried a new
78
+ // slot, NOT how many times the slot has ever changed. The lifetime count
79
+ // cannot tell the defect from a correctly memoised slot: Bloom's own
80
+ // documented example lists `isWatched` in its deps, so its identity changes
81
+ // once per activation of a long-lived surface, and any such consumer reaches
82
+ // any fixed lifetime total eventually. It would then be told to do the thing
83
+ // it is already doing, with no way to make the warning stop — which is worse
84
+ // than not warning, because the advice is unsatisfiable. A slot rebuilt per
85
+ // render is different in kind: it is new on EVERY commit, including the ones
86
+ // where nothing it reads changed.
87
+ //
88
+ // The run must also be FAST, and that second condition is what covers the
89
+ // consumer who memoised everything else too. With `content` and the rest
90
+ // stable, `memo` skips the renders where only the parent changed, so this
91
+ // component commits ONLY when the slot changes — every commit carries a new
92
+ // slot and the run never breaks, even though there is nothing to fix and no
93
+ // cost to pay. Rate is what tells them apart, and it is what the warning was
94
+ // ever about: a slot rebuilt per render churns as fast as its row renders,
95
+ // while one rebuilt when its state changes moves at the speed of a finger.
96
+ //
97
+ // All three refs are written from effects rather than in render: a
98
+ // render-phase ref write makes the React Compiler bail on the whole
99
+ // component. The first effect fires only when the identity changed, and the
100
+ // second — declared after it, and with no dependency array, so it runs on
101
+ // every commit — is what reads that mark and either extends the run or
102
+ // clears it.
103
+ const slotChangedInCommit = useRef(false);
104
+ const slotChurnRun = useRef(0);
105
+ const slotChurnRunStartedAt = useRef(0);
78
106
  useEffect(() => {
79
- if (renderVideo === undefined) return;
80
- slotChurn.current += 1;
81
- if (slotChurn.current === SLOT_IDENTITY_CHURN_LIMIT) warnSlotNotMemoised();
107
+ slotChangedInCommit.current = true;
82
108
  }, [renderVideo]);
109
+ useEffect(() => {
110
+ if (renderVideo === undefined || !slotChangedInCommit.current) {
111
+ slotChurnRun.current = 0;
112
+ return;
113
+ }
114
+ slotChangedInCommit.current = false;
115
+ const now = Date.now();
116
+ if (slotChurnRun.current === 0 || now - slotChurnRunStartedAt.current > SLOT_IDENTITY_CHURN_WINDOW_MS) {
117
+ slotChurnRun.current = 1;
118
+ slotChurnRunStartedAt.current = now;
119
+ return;
120
+ }
121
+ slotChurnRun.current += 1;
122
+ if (slotChurnRun.current === SLOT_IDENTITY_CHURN_LIMIT) warnSlotNotMemoised();
123
+ });
83
124
 
84
125
  // Both arms report the same fact — "there is a picture here now" — because the
85
126
  // destination of a flight can be either, and a caller should not have to know
@@ -164,7 +205,7 @@ function warnSlotNotMemoised() {
164
205
  if (process.env.NODE_ENV === 'production' || hasWarnedAboutSlotChurn) return;
165
206
  hasWarnedAboutSlotChurn = true;
166
207
  // eslint-disable-next-line no-console
167
- console.warn(`[Bloom] A \`renderVideo\` slot changed identity ${SLOT_IDENTITY_CHURN_LIMIT} times. ` + 'It is part of what a media host publishes to the flight layer and is compared by ' + 'identity, so a slot rebuilt on every render republishes the surface on every render. ' + 'Wrap it in `useCallback` with the props it actually reads.');
208
+ console.warn(`[Bloom] A \`renderVideo\` slot was a NEW function on ${SLOT_IDENTITY_CHURN_LIMIT} ` + 'consecutive renders, including ones where nothing it reads changed. The slot is ' + 'compared by identity — on web it is part of what a media host publishes to the ' + 'flight layer — so one rebuilt per render re-renders the surface per render. Wrap ' + 'it in `useCallback` with the props it actually reads. A slot that changes when ' + 'those props change is fine and does not reach this.');
168
209
  }
169
210
 
170
211
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["memo","useCallback","useEffect","useRef","useState","Platform","StyleSheet","View","Image","Animated","SLOT_IDENTITY_CHURN_LIMIT","handOffFlight","loadExpoVideo","warnExpoVideoUnavailable","jsx","_jsx","jsxs","_jsxs","webDraggableProps","OS","draggable","MediaSurface","content","style","contentFit","surfaceType","renderVideo","nativeControls","accessibilityLabel","pointerEvents","flightId","detached","mountedSurfaceType","slotChurn","undefined","current","warnSlotNotMemoised","reportLive","still","kind","poster","uri","expoVideo","styles","box","children","source","absoluteFill","transition","onLoad","player","fillReplaced","VideoView","onFirstFrameRender","displayName","hasWarnedAboutSlotChurn","process","env","NODE_ENV","console","warn","MediaPoster","EmptyMediaSurface","empty","create","width","height","overflow","backgroundColor"],"sourceRoot":"../../../src","sources":["media-flight/MediaSurface.tsx"],"mappings":";;AAAA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ACA;AACA;AACA,OAAO,SAASmD,WAAWA,CAAC;EAC1BvC,OAAO;EACPC,KAAK;EACLC,UAAU,GAAG,OAAO;EACpBI;AAMF,CAAC,EAAE;EACD,MAAMa,GAAG,GAAGnB,OAAO,CAACiB,IAAI,KAAK,OAAO,GAAGjB,OAAO,CAACkB,MAAM,GAAGlB,OAAO,CAACmB,GAAG;EACnE,IAAIA,GAAG,KAAKP,SAAS,EAAE,oBAAOnB,IAAA,CAAC+C,iBAAiB;IAACvC,KAAK,EAAEA;EAAM,CAAE,CAAC;EACjE,oBACER,IAAA,CAACP,KAAK;IACJsC,MAAM,EAAE;MAAEL;IAAI,CAAE;IAChBjB,UAAU,EAAEA,UAAW;IACvBD,KAAK,EAAEA,KAAM;IACbyB,UAAU,EAAE,CAAE;IACdpB,kBAAkB,EAAEA,kBAAmB;IAAA,GACnCV;EAAiB,CACtB,CAAC;AAEN;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAAS4C,iBAAiBA,CAAC;EAAEvC;AAAoC,CAAC,EAAE;EACzE,oBAAOR,IAAA,CAACR,IAAI;IAACgB,KAAK,EAAE,CAACoB,MAAM,CAACoB,KAAK,EAAExC,KAAK,CAAE;IAACM,aAAa,EAAC;EAAM,CAAE,CAAC;AACpE;AAEA,MAAMc,MAAM,GAAGrC,UAAU,CAAC0D,MAAM,CAAC;EAC/B;AACF;AACA;AACA;EACEb,YAAY,EAAE;IACZc,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDtB,GAAG,EAAE;IACH;IACA;IACAuB,QAAQ,EAAE;EACZ,CAAC;EACDJ,KAAK,EAAE;IACLK,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["memo","useCallback","useEffect","useRef","useState","Platform","StyleSheet","View","Image","Animated","SLOT_IDENTITY_CHURN_LIMIT","SLOT_IDENTITY_CHURN_WINDOW_MS","handOffFlight","loadExpoVideo","warnExpoVideoUnavailable","jsx","_jsx","jsxs","_jsxs","webDraggableProps","OS","draggable","MediaSurface","content","style","contentFit","surfaceType","renderVideo","nativeControls","accessibilityLabel","pointerEvents","flightId","detached","mountedSurfaceType","slotChangedInCommit","slotChurnRun","slotChurnRunStartedAt","current","undefined","now","Date","warnSlotNotMemoised","reportLive","still","kind","poster","uri","expoVideo","styles","box","children","source","absoluteFill","transition","onLoad","player","fillReplaced","VideoView","onFirstFrameRender","displayName","hasWarnedAboutSlotChurn","process","env","NODE_ENV","console","warn","MediaPoster","EmptyMediaSurface","empty","create","width","height","overflow","backgroundColor"],"sourceRoot":"../../../src","sources":["media-flight/MediaSurface.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAA6B,OAAO;AAC3F,SACEC,QAAQ,EACRC,UAAU,EACVC,IAAI,QAIC,cAAc;AACrB,SAASC,KAAK,QAAQ,YAAY;AAClC,OAAOC,QAAQ,MAAM,yBAAyB;AAE9C,SAASC,yBAAyB,EAAEC,6BAA6B,QAAQ,gBAAa;AACtF,SAASC,aAAa,QAAQ,YAAS;AAEvC,SACEC,aAAa,EACbC,wBAAwB,QAEnB,wBAAqB;;AAE5B;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGd,QAAQ,CAACe,EAAE,KAAK,KAAK,GAAG;EAAEC,SAAS,EAAE;AAAM,CAAC,GAAG,CAAC,CAAC;AAsE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,gBAAGtB,IAAI,CAAC,SAASsB,YAAYA,CAAC;EACrDC,OAAO;EACPC,KAAK;EACLC,UAAU,GAAG,SAAS;EAC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;EACpBI;AAMF,CAAC,EAAE;EACD,MAAMiB,GAAG,GAAGvB,OAAO,CAACqB,IAAI,KAAK,OAAO,GAAGrB,OAAO,CAACsB,MAAM,GAAGtB,OAAO,CAACuB,GAAG;EACnE,IAAIA,GAAG,KAAKR,SAAS,EAAE,oBAAOtB,IAAA,CAACmD,iBAAiB;IAAC3C,KAAK,EAAEA;EAAM,CAAE,CAAC;EACjE,oBACER,IAAA,CAACR,KAAK;IACJ2C,MAAM,EAAE;MAAEL;IAAI,CAAE;IAChBrB,UAAU,EAAEA,UAAW;IACvBD,KAAK,EAAEA,KAAM;IACb6B,UAAU,EAAE,CAAE;IACdxB,kBAAkB,EAAEA,kBAAmB;IAAA,GACnCV;EAAiB,CACtB,CAAC;AAEN;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASgD,iBAAiBA,CAAC;EAAE3C;AAAoC,CAAC,EAAE;EACzE,oBAAOR,IAAA,CAACT,IAAI;IAACiB,KAAK,EAAE,CAACwB,MAAM,CAACoB,KAAK,EAAE5C,KAAK,CAAE;IAACM,aAAa,EAAC;EAAM,CAAE,CAAC;AACpE;AAEA,MAAMkB,MAAM,GAAG1C,UAAU,CAAC+D,MAAM,CAAC;EAC/B;AACF;AACA;AACA;EACEb,YAAY,EAAE;IACZc,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EACDtB,GAAG,EAAE;IACH;IACA;IACAuB,QAAQ,EAAE;EACZ,CAAC;EACDJ,KAAK,EAAE;IACLK,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -34,16 +34,41 @@ export const SURFACE_MOUNT_TIMEOUT_MS = 250;
34
34
  */
35
35
 
36
36
  /**
37
- * How many times a video slot may change identity before Bloom says so.
37
+ * How many CONSECUTIVE renders a video slot may arrive new on before Bloom says
38
+ * so.
38
39
  *
39
- * `renderVideo` is part of what a host publishes to the layer and is compared
40
- * by identity, so an unmemoised slot republishes on every render of the row it
41
- * lives in silently, and only under load. Five is well past any legitimate
42
- * cause (a mute toggle, a fit change) and far below the churn of a slot rebuilt
43
- * per render in a scrolling feed.
40
+ * `renderVideo` is compared by identity and on web it is part of what a host
41
+ * publishes to the layer — so an unmemoised slot re-renders the surface on
42
+ * every render of the row it lives in, silently and only under load.
43
+ *
44
+ * Consecutive, never a lifetime total. A correctly memoised slot changes
45
+ * identity whenever the state it reads changes (`isWatched` on a reel slide,
46
+ * say), so ANY fixed lifetime total is reached eventually by a consumer with
47
+ * nothing to fix — and the warning's own advice, `useCallback` over the props
48
+ * the slot reads, is what such a consumer already wrote. Five in a row is
49
+ * unreachable that way: it takes five commits where nothing the slot reads
50
+ * changed and the slot was rebuilt anyway.
44
51
  */
45
52
  export const SLOT_IDENTITY_CHURN_LIMIT = 5;
46
53
 
54
+ /**
55
+ * How long a run of {@link SLOT_IDENTITY_CHURN_LIMIT} new slots may take and
56
+ * still be reported (ms).
57
+ *
58
+ * "Consecutive" alone is not enough for the consumer who memoised the surface's
59
+ * other props as well: `memo` then skips every render where only the parent
60
+ * changed, so the surface commits ONLY when the slot changes and the run never
61
+ * breaks — with nothing to fix and, because the renders were skipped, no cost
62
+ * paid either.
63
+ *
64
+ * Rate is what separates them, and it is what the warning was always about. A
65
+ * slot rebuilt per render changes as fast as its row renders, which in a
66
+ * scrolling feed is five times in a fraction of a frame budget. A slot rebuilt
67
+ * when the state it reads changes moves at the speed of a finger, and half a
68
+ * second is far too short for five activations of ONE surface.
69
+ */
70
+ export const SLOT_IDENTITY_CHURN_WINDOW_MS = 500;
71
+
47
72
  /**
48
73
  * How far a media element may sit from the box it is supposed to fill, in px,
49
74
  * before Bloom says so.
@@ -1 +1 @@
1
- {"version":3,"names":["SURFACE_MOUNT_TIMEOUT_MS","SLOT_IDENTITY_CHURN_LIMIT","SLOT_FILL_TOLERANCE_PX"],"sourceRoot":"../../../src","sources":["media-flight/constants.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,wBAAwB,GAAG,GAAG;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,CAAC;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["SURFACE_MOUNT_TIMEOUT_MS","SLOT_IDENTITY_CHURN_LIMIT","SLOT_IDENTITY_CHURN_WINDOW_MS","SLOT_FILL_TOLERANCE_PX"],"sourceRoot":"../../../src","sources":["media-flight/constants.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,wBAAwB,GAAG,GAAG;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,CAAC;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAG,GAAG;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,CAAC","ignoreList":[]}
@@ -16,9 +16,9 @@
16
16
  * consumer's type-check.
17
17
  */
18
18
  import { Children, createContext, useCallback, useContext, useEffect, useMemo } from 'react';
19
- import { Pressable, StyleSheet, useWindowDimensions, View } from 'react-native';
19
+ import { Platform, Pressable, StyleSheet, useWindowDimensions, View } from 'react-native';
20
20
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
21
- import Animated, { Extrapolation, interpolate, interpolateColor, runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
21
+ import Animated, { Extrapolation, interpolate, interpolateColor, runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
22
22
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
23
23
  import { useHaptics } from "../hooks/use-haptics.js";
24
24
  import { useClaimBottomEdge } from "../layout/bottom-edge.js";
@@ -42,6 +42,7 @@ function TabBarBody({
42
42
  Blur,
43
43
  children,
44
44
  activeIndex,
45
+ activeProgress,
45
46
  onIndexChange,
46
47
  onIndexLongPress,
47
48
  theme: themeOverrides,
@@ -121,6 +122,28 @@ function TabBarBody({
121
122
  // a legitimate effect (external-system sync), the same shape `Tabs` uses for
122
123
  // its underline. The focus-driven path is handled per-button instead — see
123
124
  // `TabBarButtonBody`.
125
+ // DRIVEN path: a pager owns the highlight's position and writes it every
126
+ // frame, so the position is COPIED rather than sprung — a spring chasing a
127
+ // per-frame value lags behind the finger, which is the whole thing this path
128
+ // exists to avoid.
129
+ //
130
+ // `useAnimatedReaction` cannot be called conditionally, so an unsupplied
131
+ // `activeProgress` is stood in for by a shared value nothing ever writes and
132
+ // the reaction returns early. `driven` changing flips the identity of `source`
133
+ // too, and both are in the deps array, so the reaction re-registers either
134
+ // way.
135
+ //
136
+ // Scrubbing still wins: a finger on the BAR is a direct manipulation of the
137
+ // bar and must not be fought by the pager's settle animation.
138
+ // (Deps: see the CRITICAL note below.)
139
+ const idleProgress = useSharedValue(0);
140
+ const driven = activeProgress !== undefined;
141
+ const source = activeProgress ?? idleProgress;
142
+ useAnimatedReaction(() => source.value, value => {
143
+ if (!driven) return;
144
+ if (isDragging.value) return;
145
+ slideIndex.value = value;
146
+ }, [source, driven, isDragging, slideIndex]);
124
147
  useEffect(() => {
125
148
  if (activeIndex === undefined) return;
126
149
  // While scrubbing the finger owns the highlight; never fight it.
@@ -141,15 +164,28 @@ function TabBarBody({
141
164
  // stale index would animate out of a position the user never saw, and would
142
165
  // light up every tab in between on the way. Interrupted mid-fade it is
143
166
  // still on screen, so from there it slides as it always does.
144
- slideIndex.value = highlightOpacity.value === 0 ? activeIndex : withSpring(activeIndex, SLIDE_SPRING);
167
+ //
168
+ // On the DRIVEN path this effect keeps owning visibility and gives up the
169
+ // position: the driver is already writing `slideIndex` every frame, and a
170
+ // spring started here would drag the capsule across the bar between two of
171
+ // its writes.
172
+ if (!driven) {
173
+ slideIndex.value = highlightOpacity.value === 0 ? activeIndex : withSpring(activeIndex, SLIDE_SPRING);
174
+ }
145
175
  highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
146
- }, [activeIndex, hasSelection, slideIndex, highlightOpacity, isDragging]);
176
+ }, [activeIndex, hasSelection, driven, slideIndex, highlightOpacity, isDragging]);
147
177
 
148
178
  // Scrubbing: the highlight tracks the finger 1:1 while dragging (no spring —
149
179
  // it must feel attached), haptic ticks fire on boundary crossings, and
150
180
  // navigation happens only on release. Taps are handled by a Tap gesture
151
- // racing the pan — the detector consumes the bar's touches, so the inner
152
- // Pressables never receive them.
181
+ // racing the pan.
182
+ //
183
+ // THE DETECTOR DOES NOT CONSUME THE PRESS, which this file assumed for a long
184
+ // time. A `Tap` gesture activates on RELEASE, by which point the inner
185
+ // `Pressable` has already fired `onPress`, and RNGH's cancellation of the RN
186
+ // responder comes too late to stop it. Measured on a Pixel 10 Pro: ONE tap
187
+ // produced both, ~600ms apart on a busy JS thread, so every consumer got two
188
+ // selections per tap. `TabBarButtonBody` is where that is resolved.
153
189
  const gesture = useMemo(() => {
154
190
  const indexAtX = (x, minimizedValue) => {
155
191
  'worklet';
@@ -209,7 +245,14 @@ function TabBarBody({
209
245
  const index = Math.round(indexAtX(event.x, progress.value));
210
246
  // Same rule as the controlled path above: appear at the tapped tab when
211
247
  // hidden, slide to it when already on screen.
212
- slideIndex.value = highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
248
+ //
249
+ // A tap is a discrete writer, so on the DRIVEN path it stands down like
250
+ // the others and the driver carries the highlight to the tapped tab.
251
+ // The scrub is the one gesture that does not: a finger dragging the
252
+ // pill is manipulating the bar itself, not asking for a page.
253
+ if (!driven) {
254
+ slideIndex.value = highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
255
+ }
213
256
  highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
214
257
  setMinimized(minimized, 0);
215
258
  runOnJS(selectIndex)(index);
@@ -229,7 +272,7 @@ function TabBarBody({
229
272
  runOnJS(longPressIndex)(Math.round(indexAtX(event.x, progress.value)));
230
273
  });
231
274
  return Gesture.Race(pan, tap, longPress);
232
- }, [barOuterWidth, tabCount, selectIndex, hasLongPress, longPressIndex, tick, isDragging, lastTicked, slideIndex, highlightOpacity, minimized, progress]);
275
+ }, [barOuterWidth, tabCount, selectIndex, hasLongPress, longPressIndex, tick, driven, isDragging, lastTicked, slideIndex, highlightOpacity, minimized, progress]);
233
276
 
234
277
  // CRITICAL — every shared value and every scalar a mapper READS must appear
235
278
  // in its dependency array. On web WITHOUT the react-native-worklets babel
@@ -333,8 +376,9 @@ function TabBarBody({
333
376
  isDragging,
334
377
  theme,
335
378
  activeIndex,
379
+ driven,
336
380
  selectIndex
337
- }), [slideIndex, highlightOpacity, isDragging, theme, activeIndex, selectIndex]);
381
+ }), [slideIndex, highlightOpacity, isDragging, theme, activeIndex, driven, selectIndex]);
338
382
  return /*#__PURE__*/_jsxs(View, {
339
383
  ...viewProps,
340
384
  pointerEvents: "box-none",
@@ -379,6 +423,10 @@ function TabBarBody({
379
423
  });
380
424
  }
381
425
  /** One tab trigger: icon + label that fades out when the bar minimizes. */
426
+ /** Stable identity: a new array each render would re-send the actions to the OS. */
427
+ const ACTIVATE_ACTIONS = [{
428
+ name: 'activate'
429
+ }];
382
430
  function TabBarButtonBody({
383
431
  Glyph,
384
432
  item,
@@ -408,6 +456,10 @@ function TabBarButtonBody({
408
456
  useEffect(() => {
409
457
  if (isFocused === undefined || !isFocused || !bar) return;
410
458
  if (bar.isDragging.value) return;
459
+ // A driver owns the position — see `TabBarProps.activeProgress`. It is
460
+ // already tracking this same focus change; springing from here as well would
461
+ // be a second writer on one shared value.
462
+ if (bar.driven) return;
411
463
  bar.slideIndex.value = withSpring(index, SLIDE_SPRING);
412
464
  }, [isFocused, index, bar]);
413
465
 
@@ -464,20 +516,42 @@ function TabBarButtonBody({
464
516
  "aria-selected": focused,
465
517
  accessibilityLabel: item.label,
466
518
  ...pressableProps,
519
+ // ASSISTIVE TECHNOLOGY, on native, is the one activation the bar's gesture
520
+ // cannot see: TalkBack and VoiceOver activate a view without ever
521
+ // producing a touch, so the `Tap` gesture never runs and the selection has
522
+ // to come from here.
523
+ accessibilityActions: ACTIVATE_ACTIONS,
524
+ onAccessibilityAction: event => {
525
+ if (event.nativeEvent.actionName !== 'activate') return;
526
+ if (isFocused === undefined) bar?.selectIndex(index);
527
+ },
467
528
  onPress: event => {
468
529
  // The bar's GestureDetector normally consumes touches; this still fires
469
530
  // for assistive-technology activation (VoiceOver) and keyboard focus.
470
531
  if (bar) {
471
532
  // Appear at the tab when hidden, slide to it when visible — the same
472
- // rule the tap gesture and the controlled path follow.
473
- bar.slideIndex.value = bar.highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
533
+ // rule the tap gesture and the controlled path follow. Skipped on the
534
+ // driven path, where the position belongs to the driver and this
535
+ // press will reach it as an ordinary selection.
536
+ if (!bar.driven) {
537
+ bar.slideIndex.value = bar.highlightOpacity.value === 0 ? index : withSpring(index, SLIDE_SPRING);
538
+ }
474
539
  bar.highlightOpacity.value = withTiming(1, HIGHLIGHT_FADE);
475
540
  }
476
541
  setMinimized(minimized, 0);
477
- // Controlled path only. On the focus-driven path the trigger's own
478
- // `onPress` below performs the navigation, so reporting the selection
479
- // here as well would navigate twice.
480
- if (isFocused === undefined) bar?.selectIndex(index);
542
+ // Controlled path only, and NOT on Android. On the focus-driven path the
543
+ // trigger's own `onPress` below performs the navigation, so reporting
544
+ // the selection here as well would navigate twice.
545
+ //
546
+ // ANDROID IS THE ONE PLATFORM THAT DOUBLES. RNGH sets
547
+ // `cancelsTouchesInView` on iOS, so a recognised tap cancels this press
548
+ // and the gesture above is the only reporter there; react-native-web
549
+ // likewise routes a keyboard Enter or Space through this press and
550
+ // nothing else. Android cancels nothing — measured on a Pixel 10 Pro,
551
+ // one tap produced `PRESSABLE selectIndex(1)` AND `GESTURE tap
552
+ // selectIndex(1)` ~600ms apart on a busy JS thread — so there, and only
553
+ // there, this press stands down.
554
+ if (isFocused === undefined && Platform.OS !== 'android') bar?.selectIndex(index);
481
555
  onPress?.(event);
482
556
  }
483
557
  // `Pressable`'s `style` also accepts a function of the press state; both