@symbiote-native/angular 0.0.0-canary-20260724081123

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 (276) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/babel-linker.cjs +7 -0
  4. package/babel-register-composed.cjs +127 -0
  5. package/bin/symbiote-angular-dev.cjs +93 -0
  6. package/build/angular/anchor-host-registry.d.ts +2 -0
  7. package/build/angular/anchor-host-registry.js +84 -0
  8. package/build/angular/anchor-host-registry.js.map +1 -0
  9. package/build/angular/bootstrap.d.ts +7 -0
  10. package/build/angular/bootstrap.js +15 -0
  11. package/build/angular/bootstrap.js.map +1 -0
  12. package/build/angular/components/activity-indicator/index.android.d.ts +12 -0
  13. package/build/angular/components/activity-indicator/index.android.js +21 -0
  14. package/build/angular/components/activity-indicator/index.android.js.map +1 -0
  15. package/build/angular/components/activity-indicator/index.d.ts +1 -0
  16. package/build/angular/components/activity-indicator/index.ios.d.ts +8 -0
  17. package/build/angular/components/activity-indicator/index.ios.js +21 -0
  18. package/build/angular/components/activity-indicator/index.ios.js.map +1 -0
  19. package/build/angular/components/activity-indicator/index.js +4 -0
  20. package/build/angular/components/activity-indicator/index.js.map +1 -0
  21. package/build/angular/components/activity-indicator/shared.d.ts +67 -0
  22. package/build/angular/components/activity-indicator/shared.js +260 -0
  23. package/build/angular/components/activity-indicator/shared.js.map +1 -0
  24. package/build/angular/components/button.d.ts +63 -0
  25. package/build/angular/components/button.js +332 -0
  26. package/build/angular/components/button.js.map +1 -0
  27. package/build/angular/components/flat-list/index.d.ts +122 -0
  28. package/build/angular/components/flat-list/index.js +688 -0
  29. package/build/angular/components/flat-list/index.js.map +1 -0
  30. package/build/angular/components/image/index.android.d.ts +10 -0
  31. package/build/angular/components/image/index.android.js +59 -0
  32. package/build/angular/components/image/index.android.js.map +1 -0
  33. package/build/angular/components/image/index.d.ts +1 -0
  34. package/build/angular/components/image/index.ios.d.ts +10 -0
  35. package/build/angular/components/image/index.ios.js +59 -0
  36. package/build/angular/components/image/index.ios.js.map +1 -0
  37. package/build/angular/components/image/index.js +3 -0
  38. package/build/angular/components/image/index.js.map +1 -0
  39. package/build/angular/components/image/shared.d.ts +101 -0
  40. package/build/angular/components/image/shared.js +406 -0
  41. package/build/angular/components/image/shared.js.map +1 -0
  42. package/build/angular/components/image-background.d.ts +81 -0
  43. package/build/angular/components/image-background.js +418 -0
  44. package/build/angular/components/image-background.js.map +1 -0
  45. package/build/angular/components/input-accessory-view/index.d.ts +60 -0
  46. package/build/angular/components/input-accessory-view/index.js +251 -0
  47. package/build/angular/components/input-accessory-view/index.js.map +1 -0
  48. package/build/angular/components/keyboard-avoiding-view/index.d.ts +82 -0
  49. package/build/angular/components/keyboard-avoiding-view/index.js +358 -0
  50. package/build/angular/components/keyboard-avoiding-view/index.js.map +1 -0
  51. package/build/angular/components/modal/index.d.ts +92 -0
  52. package/build/angular/components/modal/index.js +360 -0
  53. package/build/angular/components/modal/index.js.map +1 -0
  54. package/build/angular/components/pressable/index.d.ts +123 -0
  55. package/build/angular/components/pressable/index.js +420 -0
  56. package/build/angular/components/pressable/index.js.map +1 -0
  57. package/build/angular/components/refresh-control/index.d.ts +86 -0
  58. package/build/angular/components/refresh-control/index.js +342 -0
  59. package/build/angular/components/refresh-control/index.js.map +1 -0
  60. package/build/angular/components/safe-area-view/index.d.ts +57 -0
  61. package/build/angular/components/safe-area-view/index.js +248 -0
  62. package/build/angular/components/safe-area-view/index.js.map +1 -0
  63. package/build/angular/components/scroll-view/index.android.d.ts +21 -0
  64. package/build/angular/components/scroll-view/index.android.js +235 -0
  65. package/build/angular/components/scroll-view/index.android.js.map +1 -0
  66. package/build/angular/components/scroll-view/index.d.ts +3 -0
  67. package/build/angular/components/scroll-view/index.ios.d.ts +9 -0
  68. package/build/angular/components/scroll-view/index.ios.js +86 -0
  69. package/build/angular/components/scroll-view/index.ios.js.map +1 -0
  70. package/build/angular/components/scroll-view/index.js +6 -0
  71. package/build/angular/components/scroll-view/index.js.map +1 -0
  72. package/build/angular/components/scroll-view/projection.d.ts +32 -0
  73. package/build/angular/components/scroll-view/projection.js +334 -0
  74. package/build/angular/components/scroll-view/projection.js.map +1 -0
  75. package/build/angular/components/scroll-view/shared.d.ts +230 -0
  76. package/build/angular/components/scroll-view/shared.js +682 -0
  77. package/build/angular/components/scroll-view/shared.js.map +1 -0
  78. package/build/angular/components/scroll-view/sticky-header.d.ts +40 -0
  79. package/build/angular/components/scroll-view/sticky-header.js +225 -0
  80. package/build/angular/components/scroll-view/sticky-header.js.map +1 -0
  81. package/build/angular/components/section-list/index.d.ts +116 -0
  82. package/build/angular/components/section-list/index.js +641 -0
  83. package/build/angular/components/section-list/index.js.map +1 -0
  84. package/build/angular/components/switch/index.android.d.ts +20 -0
  85. package/build/angular/components/switch/index.android.js +70 -0
  86. package/build/angular/components/switch/index.android.js.map +1 -0
  87. package/build/angular/components/switch/index.d.ts +1 -0
  88. package/build/angular/components/switch/index.ios.d.ts +19 -0
  89. package/build/angular/components/switch/index.ios.js +69 -0
  90. package/build/angular/components/switch/index.ios.js.map +1 -0
  91. package/build/angular/components/switch/index.js +4 -0
  92. package/build/angular/components/switch/index.js.map +1 -0
  93. package/build/angular/components/switch/shared.d.ts +40 -0
  94. package/build/angular/components/switch/shared.js +127 -0
  95. package/build/angular/components/switch/shared.js.map +1 -0
  96. package/build/angular/components/text-input.d.ts +153 -0
  97. package/build/angular/components/text-input.js +599 -0
  98. package/build/angular/components/text-input.js.map +1 -0
  99. package/build/angular/components/touchable/index.d.ts +245 -0
  100. package/build/angular/components/touchable/index.js +1186 -0
  101. package/build/angular/components/touchable/index.js.map +1 -0
  102. package/build/angular/components/touchable-native-feedback/index.d.ts +83 -0
  103. package/build/angular/components/touchable-native-feedback/index.js +371 -0
  104. package/build/angular/components/touchable-native-feedback/index.js.map +1 -0
  105. package/build/angular/components/virtualized-list/directives.d.ts +54 -0
  106. package/build/angular/components/virtualized-list/directives.js +153 -0
  107. package/build/angular/components/virtualized-list/directives.js.map +1 -0
  108. package/build/angular/components/virtualized-list/index.d.ts +253 -0
  109. package/build/angular/components/virtualized-list/index.js +1031 -0
  110. package/build/angular/components/virtualized-list/index.js.map +1 -0
  111. package/build/angular/components/virtualized-section-list/directives.d.ts +37 -0
  112. package/build/angular/components/virtualized-section-list/directives.js +76 -0
  113. package/build/angular/components/virtualized-section-list/directives.js.map +1 -0
  114. package/build/angular/components/virtualized-section-list/index.d.ts +178 -0
  115. package/build/angular/components/virtualized-section-list/index.js +720 -0
  116. package/build/angular/components/virtualized-section-list/index.js.map +1 -0
  117. package/build/angular/components.d.ts +39 -0
  118. package/build/angular/components.js +38 -0
  119. package/build/angular/components.js.map +1 -0
  120. package/build/angular/create-portal/index.d.ts +22 -0
  121. package/build/angular/create-portal/index.js +74 -0
  122. package/build/angular/create-portal/index.js.map +1 -0
  123. package/build/angular/create-tunnel/index.d.ts +34 -0
  124. package/build/angular/create-tunnel/index.js +126 -0
  125. package/build/angular/create-tunnel/index.js.map +1 -0
  126. package/build/angular/descriptor-to-angular/index.d.ts +22 -0
  127. package/build/angular/descriptor-to-angular/index.js +142 -0
  128. package/build/angular/descriptor-to-angular/index.js.map +1 -0
  129. package/build/angular/host-instance/index.d.ts +2 -0
  130. package/build/angular/host-instance/index.js +37 -0
  131. package/build/angular/host-instance/index.js.map +1 -0
  132. package/build/angular/index.d.ts +22 -0
  133. package/build/angular/index.js +46 -0
  134. package/build/angular/index.js.map +1 -0
  135. package/build/angular/modules/animated/animated-leaf-binder/index.d.ts +14 -0
  136. package/build/angular/modules/animated/animated-leaf-binder/index.js +91 -0
  137. package/build/angular/modules/animated/animated-leaf-binder/index.js.map +1 -0
  138. package/build/angular/modules/animated/animated-leaf-binder.d.ts +14 -0
  139. package/build/angular/modules/animated/animated-leaf-binder.js +91 -0
  140. package/build/angular/modules/animated/animated-leaf-binder.js.map +1 -0
  141. package/build/angular/modules/animated/create-animated-component.d.ts +59 -0
  142. package/build/angular/modules/animated/create-animated-component.js +364 -0
  143. package/build/angular/modules/animated/create-animated-component.js.map +1 -0
  144. package/build/angular/modules/animated/index.d.ts +51 -0
  145. package/build/angular/modules/animated/index.js +59 -0
  146. package/build/angular/modules/animated/index.js.map +1 -0
  147. package/build/angular/modules/app-registry/index.d.ts +7 -0
  148. package/build/angular/modules/app-registry/index.js +23 -0
  149. package/build/angular/modules/app-registry/index.js.map +1 -0
  150. package/build/angular/modules/status-bar/index.d.ts +20 -0
  151. package/build/angular/modules/status-bar/index.js +59 -0
  152. package/build/angular/modules/status-bar/index.js.map +1 -0
  153. package/build/angular/primitives/index.d.ts +63 -0
  154. package/build/angular/primitives/index.js +189 -0
  155. package/build/angular/primitives/index.js.map +1 -0
  156. package/build/angular/primitives/shared.d.ts +88 -0
  157. package/build/angular/primitives/shared.js +171 -0
  158. package/build/angular/primitives/shared.js.map +1 -0
  159. package/build/angular/render/index.d.ts +11 -0
  160. package/build/angular/render/index.js +171 -0
  161. package/build/angular/render/index.js.map +1 -0
  162. package/build/angular/renderer/index.d.ts +37 -0
  163. package/build/angular/renderer/index.js +301 -0
  164. package/build/angular/renderer/index.js.map +1 -0
  165. package/build/angular/services/color-scheme.service.d.ts +16 -0
  166. package/build/angular/services/color-scheme.service.js +31 -0
  167. package/build/angular/services/color-scheme.service.js.map +1 -0
  168. package/build/angular/services/index.d.ts +2 -0
  169. package/build/angular/services/index.js +3 -0
  170. package/build/angular/services/index.js.map +1 -0
  171. package/build/angular/services/window-dimensions.service.d.ts +16 -0
  172. package/build/angular/services/window-dimensions.service.js +42 -0
  173. package/build/angular/services/window-dimensions.service.js.map +1 -0
  174. package/metro-config.cjs +48 -0
  175. package/metro-css-parser.cjs +13 -0
  176. package/package.json +80 -0
  177. package/src/__tests__/responder-change-detection.test.ts +102 -0
  178. package/src/__tests__/responder-nested-cd.test.ts +113 -0
  179. package/src/anchor-host-registry.ts +88 -0
  180. package/src/angular-gaps.test.ts +142 -0
  181. package/src/angular-imports.test.ts +100 -0
  182. package/src/bootstrap.ts +26 -0
  183. package/src/components/activity-indicator/activity-indicator-class-style.test.ts +44 -0
  184. package/src/components/activity-indicator/activity-indicator.test.ts +131 -0
  185. package/src/components/activity-indicator/index.android.ts +16 -0
  186. package/src/components/activity-indicator/index.ios.ts +17 -0
  187. package/src/components/activity-indicator/index.ts +4 -0
  188. package/src/components/activity-indicator/shared.ts +206 -0
  189. package/src/components/button.ts +193 -0
  190. package/src/components/flat-list/column-wrapper-style-class.test.ts +116 -0
  191. package/src/components/flat-list/flat-list-array-style.test.ts +131 -0
  192. package/src/components/flat-list/flat-list-class-style.test.ts +74 -0
  193. package/src/components/flat-list/flat-list-scroll-containment.test.ts +107 -0
  194. package/src/components/flat-list/flat-list.test.ts +99 -0
  195. package/src/components/flat-list/index.ts +574 -0
  196. package/src/components/image/image-class-style.test.ts +46 -0
  197. package/src/components/image/index.android.ts +48 -0
  198. package/src/components/image/index.ios.ts +48 -0
  199. package/src/components/image/index.ts +3 -0
  200. package/src/components/image/shared.ts +479 -0
  201. package/src/components/image-background-class-style.test.ts +48 -0
  202. package/src/components/image-background-style-class.test.ts +79 -0
  203. package/src/components/image-background.ts +270 -0
  204. package/src/components/input-accessory-view/index.ts +185 -0
  205. package/src/components/input-accessory-view/input-accessory-view.test.ts +43 -0
  206. package/src/components/keyboard-avoiding-view/index.ts +303 -0
  207. package/src/components/keyboard-avoiding-view/keyboard-avoiding-view.test.ts +54 -0
  208. package/src/components/modal/index.ts +299 -0
  209. package/src/components/modal/modal.test.ts +43 -0
  210. package/src/components/pressable/index.ts +373 -0
  211. package/src/components/pressable/pressable.test.ts +85 -0
  212. package/src/components/refresh-control/index.ts +284 -0
  213. package/src/components/refresh-control/refresh-control.test.ts +41 -0
  214. package/src/components/safe-area-view/index.ts +177 -0
  215. package/src/components/safe-area-view/safe-area-view.test.ts +43 -0
  216. package/src/components/scroll-view/android-scroll-view-axis-projection.test.ts +123 -0
  217. package/src/components/scroll-view/content-container-style-class.test.ts +75 -0
  218. package/src/components/scroll-view/index.android.ts +190 -0
  219. package/src/components/scroll-view/index.ios.ts +79 -0
  220. package/src/components/scroll-view/index.ts +7 -0
  221. package/src/components/scroll-view/projection.ts +414 -0
  222. package/src/components/scroll-view/scroll-view-class-style.test.ts +134 -0
  223. package/src/components/scroll-view/scroll-view-projection.test.ts +194 -0
  224. package/src/components/scroll-view/shared.ts +844 -0
  225. package/src/components/scroll-view/sticky-header.ts +255 -0
  226. package/src/components/section-list/index.ts +445 -0
  227. package/src/components/switch/android-switch-class.test.ts +42 -0
  228. package/src/components/switch/index.android.ts +61 -0
  229. package/src/components/switch/index.ios.ts +60 -0
  230. package/src/components/switch/index.ts +4 -0
  231. package/src/components/switch/shared.ts +197 -0
  232. package/src/components/switch/switch.test.ts +92 -0
  233. package/src/components/text-input-class-style.test.ts +54 -0
  234. package/src/components/text-input.ts +531 -0
  235. package/src/components/touchable/index.ts +629 -0
  236. package/src/components/touchable/touchable.test.ts +102 -0
  237. package/src/components/touchable-native-feedback/index.ts +254 -0
  238. package/src/components/touchable-native-feedback/touchable-native-feedback.test.ts +49 -0
  239. package/src/components/virtualized-list/directives.ts +168 -0
  240. package/src/components/virtualized-list/index.ts +992 -0
  241. package/src/components/virtualized-list/virtualized-list-class-style.test.ts +76 -0
  242. package/src/components/virtualized-section-list/directives.ts +90 -0
  243. package/src/components/virtualized-section-list/index.ts +601 -0
  244. package/src/components/virtualized-section-list/virtualized-section-list-class-style.test.ts +60 -0
  245. package/src/components.ts +149 -0
  246. package/src/create-portal/create-portal.test.ts +90 -0
  247. package/src/create-portal/index.ts +74 -0
  248. package/src/create-tunnel/create-tunnel.test.ts +120 -0
  249. package/src/create-tunnel/index.ts +136 -0
  250. package/src/descriptor-to-angular/descriptor-outlet.test.ts +94 -0
  251. package/src/descriptor-to-angular/index.ts +190 -0
  252. package/src/host-instance/host-instance.test.ts +49 -0
  253. package/src/host-instance/index.ts +36 -0
  254. package/src/index.ts +261 -0
  255. package/src/modules/animated/animated-leaf-binder/animated-leaf-binder.test.ts +116 -0
  256. package/src/modules/animated/animated-leaf-binder/index.ts +101 -0
  257. package/src/modules/animated/animated-leaf-binder.test.ts +116 -0
  258. package/src/modules/animated/animated-leaf-binder.ts +101 -0
  259. package/src/modules/animated/animated-scroll-view.test.ts +102 -0
  260. package/src/modules/animated/create-animated-component.ts +365 -0
  261. package/src/modules/animated/index.ts +105 -0
  262. package/src/modules/app-registry/app-registry.test.ts +106 -0
  263. package/src/modules/app-registry/index.ts +60 -0
  264. package/src/modules/status-bar/index.ts +57 -0
  265. package/src/modules/status-bar/status-bar.test.ts +50 -0
  266. package/src/primitives/index.ts +119 -0
  267. package/src/primitives/shared.ts +190 -0
  268. package/src/render/index.ts +235 -0
  269. package/src/render/render.test.ts +147 -0
  270. package/src/renderer/index.ts +347 -0
  271. package/src/renderer/renderer.test.ts +203 -0
  272. package/src/services/color-scheme.service.ts +27 -0
  273. package/src/services/index.ts +2 -0
  274. package/src/services/services.test.ts +163 -0
  275. package/src/services/window-dimensions.service.ts +41 -0
  276. package/tsconfig.angular.base.json +30 -0
@@ -0,0 +1,992 @@
1
+ // VirtualizedList, the Angular lifecycle half. The windowing engine (offset table, window
2
+ // compute, batch throttle, viewability, edge-reached, the child PLAN, the imperative-handle
3
+ // geometry) lives in @symbiote-native/components/state, shared verbatim with the React and Vue adapters
4
+ // so every adapter keeps the same feature surface. Here Angular supplies only the lifecycle: plain fields
5
+ // for scroll offset / viewport / measurement bumps, a once-per-CD metrics + view recompute in
6
+ // ngDoCheck (the Angular twin of React render / Vue `computed` — it owns the controlled
7
+ // committedWindow throttle and assembles the windowed cells before the template bindings are read),
8
+ // and the after-commit work (batch fill, onEndReached/onStartReached, viewability, initialScroll, MVCP)
9
+ // in ngAfterViewChecked. OnPush + ChangeDetectorRef.markForCheck() drives re-render off the native
10
+ // scroll/layout/measure callbacks (they fire outside Angular's own event bindings, so they must
11
+ // mark the view dirty). This is the Angular twin of the React useReducer/useEffect and Vue
12
+ // ref/computed/watch over the same shared functions. It composes the Angular ScrollView, exactly
13
+ // as the React/Vue lists drive their ScrollView.
14
+ //
15
+ // Per-item rendering is TEMPLATES, not a callback: React/Vue `renderItem: (info) => element` does
16
+ // not translate to Angular. The app supplies the cell via `<ng-template vListItem>` (and the
17
+ // header/footer/empty/separator slots via vListHeader/vListFooter/vListEmpty/vListSeparator); the
18
+ // list captures them with @ContentChild and stamps the WINDOWED slice through VListOutletDirective
19
+ // (a core-only NgTemplateOutlet twin — @angular/common is not a dependency). See ./directives.ts.
20
+ // Every React/Vue behavior is present (windowing, onEndReached, viewability, headers/footers/empty/
21
+ // separators, refresh, imperative scroll, horizontal, inverted, MVCP); only the cell AUTHORING
22
+ // shape differs, since a callback prop returning an element has no Angular equivalent.
23
+ //
24
+ // Lists have no Descriptor render fn — the cell content is the framework's own children.
25
+ // Cells/spacers are plain symbiote-view host elements.
26
+
27
+ import {
28
+ CUSTOM_ELEMENTS_SCHEMA,
29
+ ChangeDetectionStrategy,
30
+ ChangeDetectorRef,
31
+ Component,
32
+ ContentChild,
33
+ ElementRef,
34
+ EventEmitter,
35
+ Input,
36
+ Output,
37
+ ViewChild,
38
+ inject,
39
+ type AfterViewChecked,
40
+ type DoCheck,
41
+ type OnDestroy,
42
+ } from '@angular/core';
43
+ import {
44
+ DEFAULT_END_REACHED_THRESHOLD,
45
+ DEFAULT_INITIAL_NUM_TO_RENDER,
46
+ DEFAULT_MAX_TO_RENDER_PER_BATCH,
47
+ DEFAULT_START_REACHED_THRESHOLD,
48
+ DEFAULT_UPDATE_CELLS_BATCHING_PERIOD,
49
+ DEFAULT_WINDOW_SIZE,
50
+ EMPTY_OFFSET,
51
+ FIRST_INDEX,
52
+ INVERTED_X_STYLE,
53
+ INVERTED_Y_STYLE,
54
+ buildListPlan,
55
+ buildViewabilityPairs,
56
+ createInitialListState,
57
+ isSeparatorGapInRange,
58
+ listEffectSignature,
59
+ readLayoutLength,
60
+ readScrollOffset,
61
+ reduceList,
62
+ resolveAccessibilityProps,
63
+ resolveItemKey,
64
+ type IAccessibilityProps,
65
+ type IAccessibilityStateValue,
66
+ type IAriaProps,
67
+ type IListAction,
68
+ type IListEffect,
69
+ type IListReducerInputs,
70
+ type IListState,
71
+ type ISeparatorProps,
72
+ type ISeparators,
73
+ type IScrollViewHandle,
74
+ type IViewabilityConfig,
75
+ type IViewabilityConfigCallbackPair,
76
+ type IViewableItemsChangedInfo,
77
+ type IVirtualizedListHandle,
78
+ } from '@symbiote-native/components';
79
+ import {
80
+ dlog,
81
+ flattenStyle,
82
+ type IStyleProp,
83
+ type ISymbioteEvent,
84
+ type ISymbioteNode,
85
+ type IViewStyle,
86
+ } from '@symbiote-native/engine';
87
+ import { ScrollView } from '../scroll-view';
88
+ import { RefreshControl } from '../refresh-control';
89
+ import { anchorHostStyle, ViewHost } from '../../primitives';
90
+ import {
91
+ VListEmptyDirective,
92
+ VListFooterDirective,
93
+ VListHeaderDirective,
94
+ VListItemDirective,
95
+ VListOutletDirective,
96
+ VListSeparatorDirective,
97
+ type IVListItemContext,
98
+ type IVListSeparatorContext,
99
+ } from './directives';
100
+
101
+ // Re-export the shared list types + the authoring directives so flat-list / section-list keep
102
+ // importing them from '../virtualized-list', exactly as the React/Vue adapters re-export them.
103
+ export type {
104
+ ICellLayout,
105
+ ISeparators,
106
+ ISeparatorProps,
107
+ IViewToken,
108
+ IViewableItemsChangedInfo,
109
+ IViewabilityConfig,
110
+ IViewabilityConfigCallbackPair,
111
+ IVirtualizedListHandle,
112
+ } from '@symbiote-native/components';
113
+ export {
114
+ VListEmptyDirective,
115
+ VListFooterDirective,
116
+ VListHeaderDirective,
117
+ VListItemDirective,
118
+ VListSeparatorDirective,
119
+ } from './directives';
120
+ export type { IVListItemContext, IVListSeparatorContext } from './directives';
121
+
122
+ // The Angular VirtualizedList prop surface. Mirrors React/Vue's IVirtualizedListProps MINUS the
123
+ // element-returning props (renderItem, ListHeader/Footer/Empty Component, ItemSeparatorComponent):
124
+ // those are the per-adapter children/render fields and become `<ng-template>` directives in Angular.
125
+ // Everything agnostic is the SAME surface.
126
+ export interface IVirtualizedListProps<ItemT> extends IAccessibilityProps, IAriaProps {
127
+ data: unknown;
128
+ getItem: (data: unknown, index: number) => ItemT;
129
+ getItemCount: (data: unknown) => number;
130
+ keyExtractor?: (item: ItemT, index: number) => string;
131
+ getItemLayout?: (
132
+ data: unknown,
133
+ index: number,
134
+ ) => { length: number; offset: number; index: number };
135
+ horizontal?: boolean;
136
+ inverted?: boolean;
137
+ extraData?: unknown;
138
+ onEndReached?: (info: { distanceFromEnd: number }) => void;
139
+ onEndReachedThreshold?: number;
140
+ onStartReached?: (info: { distanceFromStart: number }) => void;
141
+ onStartReachedThreshold?: number;
142
+ onRefresh?: () => void;
143
+ refreshing?: boolean | null;
144
+ progressViewOffset?: number;
145
+ onViewableItemsChanged?: (info: IViewableItemsChangedInfo<ItemT>) => void;
146
+ viewabilityConfig?: IViewabilityConfig;
147
+ viewabilityConfigCallbackPairs?: IViewabilityConfigCallbackPair<ItemT>[];
148
+ onScrollToIndexFailed?: (info: {
149
+ index: number;
150
+ highestMeasuredFrameIndex: number;
151
+ averageItemLength: number;
152
+ }) => void;
153
+ initialNumToRender?: number;
154
+ initialScrollIndex?: number;
155
+ maxToRenderPerBatch?: number;
156
+ updateCellsBatchingPeriod?: number;
157
+ windowSize?: number;
158
+ stickyHeaderIndices?: number[];
159
+ maintainVisibleContentPosition?: {
160
+ minIndexForVisible: number;
161
+ autoscrollToTopThreshold?: number;
162
+ };
163
+ onScroll?: (event: ISymbioteEvent) => void;
164
+ onScrollBeginDrag?: (event: ISymbioteEvent) => void;
165
+ onScrollEndDrag?: (event: ISymbioteEvent) => void;
166
+ onMomentumScrollBegin?: (event: ISymbioteEvent) => void;
167
+ onMomentumScrollEnd?: (event: ISymbioteEvent) => void;
168
+ scrollEventThrottle?: number;
169
+ keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled';
170
+ keyboardDismissMode?: 'none' | 'on-drag' | 'interactive';
171
+ style?: IStyleProp<IViewStyle>;
172
+ contentContainerStyle?: IStyleProp<IViewStyle>;
173
+ }
174
+
175
+ // What the VirtualizedList component itself takes as plain @Input()s: the full surface minus the
176
+ // events it exposes as real @Output() EventEmitters instead (see the class below), mirroring how
177
+ // pressable/index.ts derives IAngularPressableInputs from IAngularPressableProps.
178
+ export type IVirtualizedListInputs<ItemT> = Omit<
179
+ IVirtualizedListProps<ItemT>,
180
+ | 'onEndReached'
181
+ | 'onStartReached'
182
+ | 'onRefresh'
183
+ | 'onViewableItemsChanged'
184
+ | 'onScrollToIndexFailed'
185
+ | 'onAccessibilityAction'
186
+ | 'onAccessibilityTap'
187
+ | 'onMagicTap'
188
+ | 'onAccessibilityEscape'
189
+ >;
190
+
191
+ // One in-window cell, assembled in ngDoCheck and stamped by the template's @for. The
192
+ // context object is fresh each pass; VListOutletDirective folds it onto the live embedded view, so
193
+ // the cell view is reused (the windowing recompute does not tear cells down).
194
+ interface IWindowCell<ItemT> {
195
+ key: string;
196
+ index: number;
197
+ context: IVListItemContext<ItemT>;
198
+ measure: (event: ISymbioteEvent) => void;
199
+ separatorContext?: IVListSeparatorContext<ItemT>;
200
+ }
201
+
202
+ @Component({
203
+ selector: 'VirtualizedList',
204
+ standalone: true,
205
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
206
+ imports: [ScrollView, RefreshControl, VListOutletDirective, ViewHost],
207
+ changeDetection: ChangeDetectionStrategy.OnPush,
208
+ template: `
209
+ <ScrollView
210
+ [horizontal]="isHorizontal"
211
+ [style]="resolvedStyle"
212
+ [contentContainerStyle]="resolvedContentContainerStyle"
213
+ [testID]="foldedAccessibility.testID"
214
+ [nativeID]="foldedAccessibility.nativeID"
215
+ [accessible]="foldedAccessibility.accessible"
216
+ [accessibilityLabel]="foldedAccessibility.accessibilityLabel"
217
+ [accessibilityHint]="foldedAccessibility.accessibilityHint"
218
+ [accessibilityRole]="foldedAccessibility.accessibilityRole"
219
+ [accessibilityState]="foldedAccessibility.accessibilityState"
220
+ [accessibilityValue]="foldedAccessibility.accessibilityValue"
221
+ [accessibilityActions]="foldedAccessibility.accessibilityActions"
222
+ [accessibilityLabelledBy]="foldedAccessibility.accessibilityLabelledBy"
223
+ [importantForAccessibility]="foldedAccessibility.importantForAccessibility"
224
+ [accessibilityLiveRegion]="foldedAccessibility.accessibilityLiveRegion"
225
+ [screenReaderFocusable]="foldedAccessibility.screenReaderFocusable"
226
+ [accessibilityViewIsModal]="foldedAccessibility.accessibilityViewIsModal"
227
+ [accessibilityElementsHidden]="foldedAccessibility.accessibilityElementsHidden"
228
+ [accessibilityIgnoresInvertColors]="foldedAccessibility.accessibilityIgnoresInvertColors"
229
+ [accessibilityLanguage]="foldedAccessibility.accessibilityLanguage"
230
+ [accessibilityRespondsToUserInteraction]="
231
+ foldedAccessibility.accessibilityRespondsToUserInteraction
232
+ "
233
+ [accessibilityShowsLargeContentViewer]="
234
+ foldedAccessibility.accessibilityShowsLargeContentViewer
235
+ "
236
+ [accessibilityLargeContentTitle]="foldedAccessibility.accessibilityLargeContentTitle"
237
+ (accessibilityAction)="accessibilityActionTick($event)"
238
+ (accessibilityTap)="accessibilityTapTick($event)"
239
+ (magicTap)="magicTapTick($event)"
240
+ (accessibilityEscape)="accessibilityEscapeTick($event)"
241
+ [onScroll]="onScrollTick"
242
+ (layout)="onLayoutTick($event)"
243
+ [onScrollBeginDrag]="onScrollBeginDrag"
244
+ [onScrollEndDrag]="onScrollEndDrag"
245
+ [onMomentumScrollBegin]="onMomentumScrollBegin"
246
+ [onMomentumScrollEnd]="onMomentumScrollEnd"
247
+ [scrollEventThrottle]="scrollEventThrottle"
248
+ [keyboardShouldPersistTaps]="keyboardShouldPersistTaps"
249
+ [keyboardDismissMode]="keyboardDismissMode"
250
+ [contentOffset]="commandedOffset"
251
+ [stickyHeaderIndices]="renderedStickyIndices"
252
+ [maintainVisibleContentPosition]="resolvedMaintainVisibleContentPosition"
253
+ >
254
+ @if (shouldRenderRefreshControl) {
255
+ <RefreshControl
256
+ [refreshing]="refreshing ?? false"
257
+ (refresh)="handleRefresh()"
258
+ [progressViewOffset]="progressViewOffset"
259
+ />
260
+ }
261
+
262
+ @if (headerDir !== undefined) {
263
+ <symbiote-view>
264
+ <ng-container [vListOutlet]="headerDir.templateRef"></ng-container>
265
+ </symbiote-view>
266
+ }
267
+
268
+ @if (itemCount === 0) {
269
+ @if (emptyDir !== undefined) {
270
+ <symbiote-view>
271
+ <ng-container [vListOutlet]="emptyDir.templateRef"></ng-container>
272
+ </symbiote-view>
273
+ }
274
+ } @else {
275
+ @if (leadingSpacerStyle !== null) {
276
+ <symbiote-view [style]="leadingSpacerStyle"></symbiote-view>
277
+ }
278
+ @for (cell of windowCells; track cell.key) {
279
+ <symbiote-view (layout)="handleCellLayout(cell.measure, $event)" [style]="cellStyle">
280
+ <ng-container
281
+ [vListOutlet]="itemDir?.templateRef"
282
+ [vListOutletContext]="cell.context"
283
+ ></ng-container>
284
+ </symbiote-view>
285
+ @if (cell.separatorContext !== undefined) {
286
+ <symbiote-view>
287
+ <ng-container
288
+ [vListOutlet]="separatorDir?.templateRef"
289
+ [vListOutletContext]="cell.separatorContext"
290
+ ></ng-container>
291
+ </symbiote-view>
292
+ }
293
+ }
294
+ @if (trailingSpacerStyle !== null) {
295
+ <symbiote-view [style]="trailingSpacerStyle"></symbiote-view>
296
+ }
297
+ }
298
+
299
+ @if (footerDir !== undefined) {
300
+ <symbiote-view>
301
+ <ng-container [vListOutlet]="footerDir.templateRef"></ng-container>
302
+ </symbiote-view>
303
+ }
304
+ </ScrollView>
305
+ `,
306
+ })
307
+ export class VirtualizedList<ItemT = unknown>
308
+ implements
309
+ IVirtualizedListInputs<ItemT>,
310
+ IVirtualizedListHandle,
311
+ DoCheck,
312
+ AfterViewChecked,
313
+ OnDestroy
314
+ {
315
+ // The list's edge/viewability/failure events as real Angular events: `(endReached)="…"`, not
316
+ // `[onEndReached]="…"`. See handleRefresh/accessibility*Tick below for how the still-callback-
317
+ // shaped ScrollView/RefreshControl @Input()s are fed from these.
318
+ @Output() readonly endReached = new EventEmitter<{ distanceFromEnd: number }>();
319
+ @Output() readonly startReached = new EventEmitter<{ distanceFromStart: number }>();
320
+ @Output() readonly refresh = new EventEmitter<void>();
321
+ @Output() readonly viewableItemsChanged = new EventEmitter<IViewableItemsChangedInfo<ItemT>>();
322
+ @Output() readonly scrollToIndexFailed = new EventEmitter<{
323
+ index: number;
324
+ highestMeasuredFrameIndex: number;
325
+ averageItemLength: number;
326
+ }>();
327
+ @Output() readonly accessibilityAction = new EventEmitter<ISymbioteEvent>();
328
+ @Output() readonly accessibilityTap = new EventEmitter<ISymbioteEvent>();
329
+ @Output() readonly magicTap = new EventEmitter<ISymbioteEvent>();
330
+ @Output() readonly accessibilityEscape = new EventEmitter<ISymbioteEvent>();
331
+ @Input({ required: true }) data!: unknown;
332
+ @Input({ required: true }) getItem!: (data: unknown, index: number) => ItemT;
333
+ @Input({ required: true }) getItemCount!: (data: unknown) => number;
334
+ @Input() keyExtractor?: (item: ItemT, index: number) => string;
335
+ @Input() getItemLayout?: (
336
+ data: unknown,
337
+ index: number,
338
+ ) => { length: number; offset: number; index: number };
339
+ @Input() horizontal?: boolean;
340
+ @Input() inverted?: boolean;
341
+ @Input() extraData?: unknown;
342
+ @Input() onEndReachedThreshold?: number;
343
+ @Input() onStartReachedThreshold?: number;
344
+ @Input() refreshing?: boolean | null;
345
+ @Input() progressViewOffset?: number;
346
+ // Set explicitly by a wrapper (FlatList/VirtualizedSectionList) that ALWAYS binds
347
+ // `(refresh)="refresh.emit()"` on this component to re-forward the event outward — that binding
348
+ // itself makes `this.refresh.observed` permanently true (Angular subscribes unconditionally the
349
+ // moment a template writes `(refresh)="…"`, regardless of what the handler does), so `.observed`
350
+ // can no longer tell "the app actually wants pull-to-refresh" from "a wrapper is just forwarding
351
+ // the event". A wrapper passes its OWN public `refresh.observed` here instead; direct usage
352
+ // (no wrapper) falls back to this component's own `.observed`, unchanged from before.
353
+ @Input() refreshRequested?: boolean;
354
+ @Input() viewabilityConfig?: IViewabilityConfig;
355
+ @Input() viewabilityConfigCallbackPairs?: IViewabilityConfigCallbackPair<ItemT>[];
356
+ @Input() initialNumToRender?: number;
357
+ @Input() initialScrollIndex?: number;
358
+ @Input() maxToRenderPerBatch?: number;
359
+ @Input() updateCellsBatchingPeriod?: number;
360
+ @Input() windowSize?: number;
361
+ @Input() stickyHeaderIndices?: number[];
362
+ @Input() maintainVisibleContentPosition?: {
363
+ minIndexForVisible: number;
364
+ autoscrollToTopThreshold?: number;
365
+ };
366
+ @Input() onScroll?: (event: ISymbioteEvent) => void;
367
+ @Input() onScrollBeginDrag?: (event: ISymbioteEvent) => void;
368
+ @Input() onScrollEndDrag?: (event: ISymbioteEvent) => void;
369
+ @Input() onMomentumScrollBegin?: (event: ISymbioteEvent) => void;
370
+ @Input() onMomentumScrollEnd?: (event: ISymbioteEvent) => void;
371
+ @Input() scrollEventThrottle?: number;
372
+ @Input() keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled';
373
+ @Input() keyboardDismissMode?: 'none' | 'on-drag' | 'interactive';
374
+ @Input() style?: IStyleProp<IViewStyle>;
375
+ @Input() contentContainerStyle?: IStyleProp<IViewStyle>;
376
+ @Input() testID?: string;
377
+ @Input() nativeID?: string;
378
+ @Input() accessible?: boolean;
379
+ @Input() accessibilityLabel?: string;
380
+ @Input() accessibilityHint?: string;
381
+ @Input() accessibilityRole?: IAccessibilityProps['accessibilityRole'];
382
+ @Input() accessibilityState?: IAccessibilityStateValue;
383
+ @Input() accessibilityValue?: IAccessibilityProps['accessibilityValue'];
384
+ @Input() accessibilityActions?: IAccessibilityProps['accessibilityActions'];
385
+ @Input() accessibilityLabelledBy?: string | string[];
386
+ @Input() importantForAccessibility?: IAccessibilityProps['importantForAccessibility'];
387
+ @Input() accessibilityLiveRegion?: IAccessibilityProps['accessibilityLiveRegion'];
388
+ @Input() screenReaderFocusable?: boolean;
389
+ @Input() accessibilityViewIsModal?: boolean;
390
+ @Input() accessibilityElementsHidden?: boolean;
391
+ @Input() accessibilityIgnoresInvertColors?: boolean;
392
+ @Input() accessibilityLanguage?: string;
393
+ @Input() accessibilityRespondsToUserInteraction?: boolean;
394
+ @Input() accessibilityShowsLargeContentViewer?: boolean;
395
+ @Input() accessibilityLargeContentTitle?: string;
396
+ @Input() role?: IAriaProps['role'];
397
+ @Input() ariaLabel?: string;
398
+ @Input() ariaLabelledBy?: string;
399
+ @Input() ariaLive?: IAriaProps['aria-live'];
400
+ @Input() ariaHidden?: boolean;
401
+ @Input() ariaBusy?: boolean;
402
+ @Input() ariaChecked?: boolean | 'mixed';
403
+ @Input() ariaDisabled?: boolean;
404
+ @Input() ariaExpanded?: boolean;
405
+ @Input() ariaSelected?: boolean;
406
+ @Input() ariaModal?: boolean;
407
+ @Input() ariaValueMax?: number;
408
+ @Input() ariaValueMin?: number;
409
+ @Input() ariaValueNow?: number;
410
+ @Input() ariaValueText?: string;
411
+
412
+ // The cell + slot templates the app authors (the Angular twin of renderItem / ListHeaderComponent
413
+ // / ListFooterComponent / ListEmptyComponent / ItemSeparatorComponent), captured from projected
414
+ // <ng-template> content. Resolved by ngAfterContentInit, read each ngDoCheck (from the 2nd CD on).
415
+ @ContentChild(VListItemDirective) itemDir?: VListItemDirective<ItemT>;
416
+ @ContentChild(VListHeaderDirective) headerDir?: VListHeaderDirective;
417
+ @ContentChild(VListFooterDirective) footerDir?: VListFooterDirective;
418
+ @ContentChild(VListEmptyDirective) emptyDir?: VListEmptyDirective;
419
+ @ContentChild(VListSeparatorDirective) separatorDir?: VListSeparatorDirective<ItemT>;
420
+
421
+ // The composed inner scroll view. Its instance IS an IScrollViewHandle (scrollTo / scrollToEnd /
422
+ // flashScrollIndicators / getScrollNode), so the imperative handle delegates straight to it.
423
+ // Available from ngAfterViewInit on; the handle reads the node lazily and no-ops before commit.
424
+ @ViewChild(ScrollView) private scrollView?: ScrollView;
425
+
426
+ // --- template-bound view state, assembled in ngDoCheck (recomputeView) ---
427
+ itemCount = EMPTY_OFFSET;
428
+ windowCells: IWindowCell<ItemT>[] = [];
429
+ leadingSpacerStyle: IViewStyle | null = null;
430
+ trailingSpacerStyle: IViewStyle | null = null;
431
+ cellStyle: IViewStyle | undefined = undefined;
432
+ renderedStickyIndices: number[] | undefined = undefined;
433
+ // Bound to the template's `[style]="resolvedStyle"`, which Angular compiles to the built-in
434
+ // ɵɵstyleMap instruction — it only understands a flat object, never an array (RN's own
435
+ // `style={[a, b]}` composition idiom crashes deep inside Angular's styling engine), so this
436
+ // is always pre-flattened via the engine's own flattenStyle, never left as an array.
437
+ resolvedStyle: IViewStyle | undefined = undefined;
438
+ resolvedContentContainerStyle: IStyleProp<IViewStyle> | undefined = undefined;
439
+ resolvedMaintainVisibleContentPosition:
440
+ { minIndexForVisible: number; autoscrollToTopThreshold?: number } | undefined = undefined;
441
+ // The offset we are imperatively driving native to before the scroll handle attaches (rides down
442
+ // as contentOffset). A fresh object identity each push so the commit re-applies a repeated value.
443
+ commandedOffset: { x: number; y: number } | undefined = undefined;
444
+
445
+ // The one folded state cell (the Angular twin of React's stateRef): scroll offset, viewport,
446
+ // measured lengths, committed window, edge/viewability dedup, MVCP anchor — all in IListState,
447
+ // driven by the shared reduceList. `renderVersion` bumps whenever a transition changes render
448
+ // state, so ngDoCheck's recompute-dedup can detect it (listState is a plain object, not tracked).
449
+ private readonly listState: IListState<ItemT> = createInitialListState<ItemT>();
450
+ private renderVersion = EMPTY_OFFSET;
451
+
452
+ private readonly cellMeasures = new Map<number, (event: ISymbioteEvent) => void>();
453
+ private readonly separatorOverrides = new Map<number, Partial<ISeparatorProps<unknown>>>();
454
+ // The adapter-owned debounce (minimumViewTime) and incremental-fill timers; the reducer only
455
+ // hands back a delay.
456
+ private viewableTimer: ReturnType<typeof setTimeout> | null = null;
457
+ private batchTimer: ReturnType<typeof setTimeout> | null = null;
458
+ // Dedupes the after-commit effects: they run only when the windowing signature changed.
459
+ private lastEffectSignature = '';
460
+ // Dedupes ngDoCheck's own recompute. WITHOUT this, recomputeView() unconditionally rebuilds
461
+ // windowCells (and each cell's `separators` handle — fresh closures every call) on EVERY CD pass,
462
+ // including ones triggered by something else entirely in the app. A fresh context object flows
463
+ // into VListOutletDirective, which (correctly) sees its `context` @Input() change and calls
464
+ // `viewRef.markForCheck()` — which reschedules ANOTHER change-detection tick via the zoneless
465
+ // scheduler (adapters/angular/src/render.ts). Recomputing unconditionally therefore free-runs
466
+ // forever the moment a list actually has cells to stamp (a real, previously-dormant bug only
467
+ // exposed once flat-list.test.ts's projection fix let cells render for the first time — see that
468
+ // test's comment). Guarding recompute behind "did anything relevant actually change" breaks the
469
+ // cycle: unrelated CD passes reuse the same windowCells/context identities, so
470
+ // VListOutletDirective's ngOnChanges sees no change and never reschedules.
471
+ private lastRecompute: unknown[] | undefined = undefined;
472
+
473
+ private readonly cdr = inject(ChangeDetectorRef);
474
+ // This component's OWN host — the non-painting anchor `class="..."` at the use site resolves
475
+ // onto (see anchorHostStyle's doc comment) — NOT `scrollView` above, which targets the real
476
+ // inner `<ScrollView>` one level down (itself its own separate anchor host).
477
+ private readonly elementRef = inject(ElementRef);
478
+
479
+ get foldedAccessibility(): IAccessibilityProps & IAriaProps & Record<string, unknown> {
480
+ return resolveAccessibilityProps({
481
+ testID: this.testID,
482
+ nativeID: this.nativeID,
483
+ accessible: this.accessible,
484
+ accessibilityLabel: this.accessibilityLabel,
485
+ accessibilityHint: this.accessibilityHint,
486
+ accessibilityRole: this.accessibilityRole,
487
+ accessibilityState: this.accessibilityState,
488
+ accessibilityValue: this.accessibilityValue,
489
+ accessibilityActions: this.accessibilityActions,
490
+ accessibilityLabelledBy: this.accessibilityLabelledBy,
491
+ importantForAccessibility: this.importantForAccessibility,
492
+ accessibilityLiveRegion: this.accessibilityLiveRegion,
493
+ screenReaderFocusable: this.screenReaderFocusable,
494
+ accessibilityViewIsModal: this.accessibilityViewIsModal,
495
+ accessibilityElementsHidden: this.accessibilityElementsHidden,
496
+ accessibilityIgnoresInvertColors: this.accessibilityIgnoresInvertColors,
497
+ accessibilityLanguage: this.accessibilityLanguage,
498
+ accessibilityRespondsToUserInteraction: this.accessibilityRespondsToUserInteraction,
499
+ accessibilityShowsLargeContentViewer: this.accessibilityShowsLargeContentViewer,
500
+ accessibilityLargeContentTitle: this.accessibilityLargeContentTitle,
501
+ role: this.role,
502
+ 'aria-label': this.ariaLabel,
503
+ 'aria-labelledby': this.ariaLabelledBy,
504
+ 'aria-live': this.ariaLive,
505
+ 'aria-hidden': this.ariaHidden,
506
+ 'aria-busy': this.ariaBusy,
507
+ 'aria-checked': this.ariaChecked,
508
+ 'aria-disabled': this.ariaDisabled,
509
+ 'aria-expanded': this.ariaExpanded,
510
+ 'aria-selected': this.ariaSelected,
511
+ 'aria-modal': this.ariaModal,
512
+ 'aria-valuemax': this.ariaValueMax,
513
+ 'aria-valuemin': this.ariaValueMin,
514
+ 'aria-valuenow': this.ariaValueNow,
515
+ 'aria-valuetext': this.ariaValueText,
516
+ });
517
+ }
518
+
519
+ get shouldRenderRefreshControl(): boolean {
520
+ return this.refreshRequested ?? this.refresh.observed;
521
+ }
522
+
523
+ get isHorizontal(): boolean {
524
+ return this.horizontal === true;
525
+ }
526
+ private get isInverted(): boolean {
527
+ return this.inverted === true;
528
+ }
529
+ private get windowSizeValue(): number {
530
+ return this.windowSize ?? DEFAULT_WINDOW_SIZE;
531
+ }
532
+ private get initialNumToRenderValue(): number {
533
+ return this.initialNumToRender ?? DEFAULT_INITIAL_NUM_TO_RENDER;
534
+ }
535
+ private get maxToRenderPerBatchValue(): number {
536
+ return this.maxToRenderPerBatch ?? DEFAULT_MAX_TO_RENDER_PER_BATCH;
537
+ }
538
+ private get updateCellsBatchingPeriodValue(): number {
539
+ return this.updateCellsBatchingPeriod ?? DEFAULT_UPDATE_CELLS_BATCHING_PERIOD;
540
+ }
541
+ private get onEndReachedThresholdValue(): number {
542
+ return this.onEndReachedThreshold ?? DEFAULT_END_REACHED_THRESHOLD;
543
+ }
544
+ private get onStartReachedThresholdValue(): number {
545
+ return this.onStartReachedThreshold ?? DEFAULT_START_REACHED_THRESHOLD;
546
+ }
547
+
548
+ // ScrollView's onScroll stays an @Input() callback (an Animated.event(...) target must be able to
549
+ // flow through it, which an @Output() can't carry), so this is a stable arrow field passed
550
+ // straight to [onScroll]. onLayout is a real @Output() now, bound via (layout)="onLayoutTick($event)".
551
+ onScrollTick = (event: ISymbioteEvent): void => {
552
+ const offset = readScrollOffset(event, this.isHorizontal);
553
+ if (offset === undefined) return;
554
+ dlog(`Angular VirtualizedList onScroll offset=${offset}`);
555
+ // A real native scroll supersedes any pending commanded offset.
556
+ this.commandedOffset = undefined;
557
+ this.dispatch({ kind: 'scroll', offset });
558
+ // Compose, don't clobber: internal windowing ran first, now the user's onScroll.
559
+ this.onScroll?.(event);
560
+ };
561
+
562
+ onLayoutTick = (event: ISymbioteEvent): void => {
563
+ const length = readLayoutLength(event, this.isHorizontal);
564
+ if (length === undefined) return;
565
+ dlog(`Angular VirtualizedList onLayout viewport=${length}`);
566
+ this.dispatch({ kind: 'layout', length });
567
+ };
568
+
569
+ // RefreshControl's refresh and ScrollView's accessibility events are real @Output()s now, bound
570
+ // via (refresh)="handleRefresh()" / (accessibilityAction)="accessibilityActionTick($event)" etc.
571
+ // — these fields just adapt VirtualizedList's own @Output() into a plain re-emit callback.
572
+ handleRefresh = (): void => {
573
+ this.refresh.emit();
574
+ };
575
+
576
+ accessibilityActionTick = (event: ISymbioteEvent): void => {
577
+ this.accessibilityAction.emit(event);
578
+ };
579
+
580
+ accessibilityTapTick = (event: ISymbioteEvent): void => {
581
+ this.accessibilityTap.emit(event);
582
+ };
583
+
584
+ magicTapTick = (event: ISymbioteEvent): void => {
585
+ this.magicTap.emit(event);
586
+ };
587
+
588
+ accessibilityEscapeTick = (event: ISymbioteEvent): void => {
589
+ this.accessibilityEscape.emit(event);
590
+ };
591
+
592
+ private keyFor = (index: number): string => {
593
+ const item = this.getItem(this.data, index);
594
+ return resolveItemKey(item, index, this.keyExtractor);
595
+ };
596
+
597
+ // The reducer inputs, folded off the @Input()s each call. The edge/viewability listeners map to
598
+ // `.observed` (Angular's "is anyone bound to this @Output()"), so the reducer emits only when the
599
+ // consumer listens — the same on-demand gating the prop-callback era had.
600
+ private buildInputs(): IListReducerInputs<ItemT> {
601
+ return {
602
+ data: this.data,
603
+ getItem: this.getItem,
604
+ getItemCount: this.getItemCount,
605
+ keyExtractor: this.keyExtractor,
606
+ getItemLayout: this.getItemLayout,
607
+ horizontal: this.isHorizontal,
608
+ windowSize: this.windowSizeValue,
609
+ initialNumToRender: this.initialNumToRenderValue,
610
+ maxToRenderPerBatch: this.maxToRenderPerBatchValue,
611
+ updateCellsBatchingPeriod: this.updateCellsBatchingPeriodValue,
612
+ onEndReachedThreshold: this.onEndReachedThresholdValue,
613
+ onStartReachedThreshold: this.onStartReachedThresholdValue,
614
+ onEndReachedActive: this.endReached.observed,
615
+ onStartReachedActive: this.startReached.observed,
616
+ viewabilityPairs: buildViewabilityPairs(
617
+ this.viewableItemsChanged.observed
618
+ ? (info: IViewableItemsChangedInfo<ItemT>): void => this.viewableItemsChanged.emit(info)
619
+ : undefined,
620
+ this.viewabilityConfig,
621
+ this.viewabilityConfigCallbackPairs,
622
+ ),
623
+ maintainVisibleContentPosition: this.maintainVisibleContentPosition,
624
+ initialScrollIndex: this.initialScrollIndex,
625
+ };
626
+ }
627
+
628
+ // Map a native event / imperative call to an action, run the returned effects, and mark the view
629
+ // dirty when render state changed (the native callbacks fire outside Angular's own bindings).
630
+ private dispatch(action: IListAction<ItemT>): void {
631
+ const inputs = this.buildInputs();
632
+ const result = reduceList(this.listState, action, inputs);
633
+ this.runEffects(result.effects, inputs);
634
+ if (result.changed) {
635
+ this.renderVersion += 1;
636
+ this.cdr.markForCheck();
637
+ }
638
+ }
639
+
640
+ private runEffects(effects: IListEffect<ItemT>[], inputs: IListReducerInputs<ItemT>): void {
641
+ for (const effect of effects) {
642
+ switch (effect.kind) {
643
+ case 'scroll-to':
644
+ this.scrollToPixel(effect.offset, effect.animated);
645
+ break;
646
+ case 'fire-end-reached':
647
+ this.endReached.emit({ distanceFromEnd: effect.distanceFromEnd });
648
+ break;
649
+ case 'fire-start-reached':
650
+ this.startReached.emit({ distanceFromStart: effect.distanceFromStart });
651
+ break;
652
+ case 'fire-scroll-to-index-failed':
653
+ this.scrollToIndexFailed.emit({
654
+ index: effect.index,
655
+ highestMeasuredFrameIndex: effect.highestMeasuredFrameIndex,
656
+ averageItemLength: effect.averageItemLength,
657
+ });
658
+ break;
659
+ case 'schedule-refill': {
660
+ if (this.batchTimer !== null) clearTimeout(this.batchTimer);
661
+ this.batchTimer = setTimeout(() => {
662
+ this.batchTimer = null;
663
+ this.dispatch({ kind: 'batch-tick' });
664
+ }, effect.delay);
665
+ break;
666
+ }
667
+ case 'fire-viewable': {
668
+ const pairs = inputs.viewabilityPairs;
669
+ const info = effect.info;
670
+ const map = effect.map;
671
+ const fire = (): void => {
672
+ for (const pair of pairs) pair.onViewableItemsChanged(info);
673
+ this.dispatch({ kind: 'viewable-fired', map });
674
+ };
675
+ if (this.viewableTimer !== null) {
676
+ clearTimeout(this.viewableTimer);
677
+ this.viewableTimer = null;
678
+ }
679
+ if (effect.delay > EMPTY_OFFSET) {
680
+ this.viewableTimer = setTimeout(() => {
681
+ this.viewableTimer = null;
682
+ fire();
683
+ }, effect.delay);
684
+ } else {
685
+ fire();
686
+ }
687
+ break;
688
+ }
689
+ }
690
+ }
691
+ }
692
+
693
+ // Once-per-CD recompute, BEFORE the template bindings are read (so the freshly computed
694
+ // template-bound fields render this pass — computing them in ngAfterContentChecked instead would
695
+ // trip ExpressionChangedAfterItHasBeenChecked). The dedup guard runs refresh-metrics (which owns
696
+ // the controlled committedWindow throttle) only when something relevant changed, so the window
697
+ // grows exactly one step per meaningful CD. The projected templates (ContentChild) are resolved
698
+ // from the second CD on; the first paint (count/viewport still 0) corrects on the layout-driven CD.
699
+ ngDoCheck(): void {
700
+ const recomputeInputs: unknown[] = [
701
+ this.data,
702
+ this.extraData,
703
+ this.getItemLayout,
704
+ this.keyExtractor,
705
+ this.isHorizontal,
706
+ this.isInverted,
707
+ this.windowSizeValue,
708
+ this.initialNumToRenderValue,
709
+ this.maxToRenderPerBatchValue,
710
+ this.stickyHeaderIndices,
711
+ this.maintainVisibleContentPosition,
712
+ this.style,
713
+ this.contentContainerStyle,
714
+ // Folds scroll / layout / measure / batch-tick: dispatch bumps renderVersion on any change.
715
+ this.renderVersion,
716
+ this.headerDir !== undefined,
717
+ this.footerDir !== undefined,
718
+ this.emptyDir !== undefined,
719
+ this.separatorDir !== undefined,
720
+ ];
721
+ const previous = this.lastRecompute;
722
+ this.lastRecompute = recomputeInputs;
723
+ if (
724
+ previous !== undefined &&
725
+ previous.length === recomputeInputs.length &&
726
+ previous.every((value, index) => value === recomputeInputs[index])
727
+ ) {
728
+ return;
729
+ }
730
+ // The single derive-per-CD: recompute the window off the current state before the view reads it.
731
+ reduceList(this.listState, { kind: 'refresh-metrics' }, this.buildInputs());
732
+ this.recomputeView();
733
+ }
734
+
735
+ ngAfterViewChecked(): void {
736
+ const signature = listEffectSignature(this.listState);
737
+ if (signature === this.lastEffectSignature) return;
738
+ this.lastEffectSignature = signature;
739
+ const inputs = this.buildInputs();
740
+ const result = reduceList(this.listState, { kind: 'commit' }, inputs);
741
+ this.runEffects(result.effects, inputs);
742
+ }
743
+
744
+ ngOnDestroy(): void {
745
+ if (this.viewableTimer !== null) clearTimeout(this.viewableTimer);
746
+ if (this.batchTimer !== null) clearTimeout(this.batchTimer);
747
+ }
748
+
749
+ private recomputeView(): void {
750
+ const m = this.listState.metrics;
751
+ this.itemCount = m.count;
752
+ const hasHeader = this.headerDir !== undefined;
753
+ const hasSeparators = this.separatorDir !== undefined;
754
+ const stickySet =
755
+ this.stickyHeaderIndices !== undefined ? new Set(this.stickyHeaderIndices) : undefined;
756
+
757
+ this.resolvedContentContainerStyle = this.isHorizontal
758
+ ? [this.contentContainerStyle, { width: m.total }]
759
+ : this.contentContainerStyle;
760
+ this.resolvedStyle = flattenStyle([
761
+ anchorHostStyle(this.elementRef),
762
+ this.isInverted
763
+ ? [this.style, this.isHorizontal ? INVERTED_X_STYLE : INVERTED_Y_STYLE]
764
+ : this.style,
765
+ ]);
766
+ this.cellStyle = this.isInverted
767
+ ? this.isHorizontal
768
+ ? INVERTED_X_STYLE
769
+ : INVERTED_Y_STYLE
770
+ : undefined;
771
+ this.resolvedMaintainVisibleContentPosition =
772
+ this.maintainVisibleContentPosition === undefined
773
+ ? undefined
774
+ : {
775
+ ...this.maintainVisibleContentPosition,
776
+ minIndexForVisible:
777
+ this.maintainVisibleContentPosition.minIndexForVisible + (hasHeader ? 1 : 0),
778
+ };
779
+
780
+ if (m.count === FIRST_INDEX) {
781
+ this.windowCells = [];
782
+ this.leadingSpacerStyle = null;
783
+ this.trailingSpacerStyle = null;
784
+ this.renderedStickyIndices = undefined;
785
+ dlog(`Angular VirtualizedList empty (viewport=${this.listState.viewportLength})`);
786
+ return;
787
+ }
788
+
789
+ const plan = buildListPlan({
790
+ count: m.count,
791
+ first: m.first,
792
+ last: m.last,
793
+ offsets: m.offsets,
794
+ lengths: m.lengths,
795
+ total: m.total,
796
+ keyFor: this.keyFor,
797
+ stickyIndices: stickySet,
798
+ hasHeader,
799
+ hasSeparators,
800
+ });
801
+ this.leadingSpacerStyle =
802
+ plan.leadingExtent > EMPTY_OFFSET ? this.spacerStyle(plan.leadingExtent) : null;
803
+ this.trailingSpacerStyle =
804
+ plan.trailingExtent > EMPTY_OFFSET ? this.spacerStyle(plan.trailingExtent) : null;
805
+ this.renderedStickyIndices =
806
+ stickySet !== undefined && plan.stickyChildPositions.length > 0
807
+ ? plan.stickyChildPositions
808
+ : undefined;
809
+
810
+ const cells: IWindowCell<ItemT>[] = [];
811
+ for (const planned of plan.cells) {
812
+ const item = this.getItem(this.data, planned.index);
813
+ const context: IVListItemContext<ItemT> = {
814
+ $implicit: item,
815
+ index: planned.index,
816
+ separators: this.makeSeparators(planned.index),
817
+ };
818
+ let separatorContext: IVListSeparatorContext<ItemT> | undefined;
819
+ if (hasSeparators && planned.index < m.last) {
820
+ separatorContext = this.buildSeparatorContext(planned.index, item);
821
+ }
822
+ cells.push({
823
+ key: planned.key,
824
+ index: planned.index,
825
+ context,
826
+ measure: this.cellMeasure(planned.index),
827
+ separatorContext,
828
+ });
829
+ }
830
+ this.windowCells = cells;
831
+
832
+ dlog(
833
+ `Angular VirtualizedList window [${m.first}, ${m.last}] of ${m.count} ` +
834
+ `(offset=${this.listState.scrollOffset}, viewport=${this.listState.viewportLength}, rendered=${cells.length})`,
835
+ );
836
+ }
837
+
838
+ private buildSeparatorContext(index: number, item: ItemT): IVListSeparatorContext<ItemT> {
839
+ const overrides = this.separatorOverrides.get(index);
840
+ const highlighted = overrides?.highlighted ?? false;
841
+ const context: IVListSeparatorContext<ItemT> = {
842
+ $implicit: highlighted,
843
+ highlighted,
844
+ leadingItem: item,
845
+ trailingItem: this.getItem(this.data, index + 1),
846
+ };
847
+ // Fold any custom updateProps keys through the context's index signature (RN lets a row drive
848
+ // arbitrary separator props); the typed fields above stay authoritative.
849
+ if (overrides !== undefined) {
850
+ for (const key of Object.keys(overrides)) {
851
+ if (key === 'highlighted' || key === 'leadingItem' || key === 'trailingItem') continue;
852
+ context[key] = overrides[key];
853
+ }
854
+ }
855
+ return context;
856
+ }
857
+
858
+ private spacerStyle(extent: number): IViewStyle {
859
+ return this.isHorizontal ? { width: extent } : { height: extent };
860
+ }
861
+
862
+ private cellMeasure(index: number): (event: ISymbioteEvent) => void {
863
+ const existing = this.cellMeasures.get(index);
864
+ if (existing !== undefined) return existing;
865
+ const measure = (event: ISymbioteEvent): void => {
866
+ const length = readLayoutLength(event, this.isHorizontal);
867
+ if (length === undefined) return;
868
+ dlog(`Angular VirtualizedList cell ${index} measured length=${length}`);
869
+ // The reducer guards a fixed getItemLayout and a repeated length; a no-op leaves state and the
870
+ // view untouched (dispatch marks for check only when something changed).
871
+ this.dispatch({ kind: 'measure', index, length });
872
+ };
873
+ this.cellMeasures.set(index, measure);
874
+ return measure;
875
+ }
876
+
877
+ // Per-cell onLayout rides the engine's structural (layout) event channel — Angular forbids an
878
+ // [onLayout] property binding (NG8002). $event arrives untyped, narrowed before reaching measure.
879
+ handleCellLayout(measure: (event: ISymbioteEvent) => void, event: unknown): void {
880
+ if (this.isSymbioteEvent(event)) measure(event);
881
+ }
882
+
883
+ private isSymbioteEvent(value: unknown): value is ISymbioteEvent {
884
+ return typeof value === 'object' && value !== null && 'nativeEvent' in value;
885
+ }
886
+
887
+ private mergeSeparator(gapIndex: number, patch: Partial<ISeparatorProps<unknown>>): void {
888
+ const count = this.listState.metrics.count;
889
+ if (!isSeparatorGapInRange(gapIndex, count)) return;
890
+ this.separatorOverrides.set(gapIndex, { ...this.separatorOverrides.get(gapIndex), ...patch });
891
+ this.cdr.markForCheck();
892
+ }
893
+
894
+ private makeSeparators(index: number): ISeparators {
895
+ return {
896
+ highlight: (): void => {
897
+ dlog(`Angular VirtualizedList separator highlight cell=${index}`);
898
+ this.mergeSeparator(index - 1, { highlighted: true });
899
+ this.mergeSeparator(index, { highlighted: true });
900
+ },
901
+ unhighlight: (): void => {
902
+ dlog(`Angular VirtualizedList separator unhighlight cell=${index}`);
903
+ this.mergeSeparator(index - 1, { highlighted: false });
904
+ this.mergeSeparator(index, { highlighted: false });
905
+ },
906
+ updateProps: (select: 'leading' | 'trailing', newProps: Record<string, unknown>): void => {
907
+ this.mergeSeparator(select === 'leading' ? index - 1 : index, newProps);
908
+ },
909
+ };
910
+ }
911
+
912
+ // ---- imperative handle (the shared IVirtualizedListHandle surface) ----
913
+ // Each scroll resolves to an offset (or a scroll-to-index failure) inside the reducer, then rides
914
+ // the scroll-to effect through scrollToPixel.
915
+
916
+ scrollToOffset(params: { offset: number; animated?: boolean }): void {
917
+ this.dispatch({
918
+ kind: 'scroll-to-offset',
919
+ offset: params.offset,
920
+ animated: params.animated ?? true,
921
+ });
922
+ }
923
+
924
+ scrollToIndex(params: {
925
+ index: number;
926
+ animated?: boolean;
927
+ viewOffset?: number;
928
+ viewPosition?: number;
929
+ }): void {
930
+ this.dispatch({
931
+ kind: 'scroll-to-index',
932
+ index: params.index,
933
+ animated: params.animated ?? true,
934
+ viewPosition: params.viewPosition ?? FIRST_INDEX,
935
+ viewOffset: params.viewOffset ?? EMPTY_OFFSET,
936
+ });
937
+ }
938
+
939
+ scrollToItem(params: { item: unknown; animated?: boolean; viewPosition?: number }): void {
940
+ this.dispatch({
941
+ kind: 'scroll-to-item',
942
+ item: params.item,
943
+ animated: params.animated ?? true,
944
+ viewPosition: params.viewPosition ?? FIRST_INDEX,
945
+ });
946
+ }
947
+
948
+ scrollToEnd(params?: { animated?: boolean }): void {
949
+ this.dispatch({ kind: 'scroll-to-end', animated: params?.animated ?? true });
950
+ }
951
+
952
+ flashScrollIndicators(): void {
953
+ this.scrollView?.flashScrollIndicators();
954
+ }
955
+
956
+ getNativeScrollRef(): IScrollViewHandle | null {
957
+ return this.scrollView ?? null;
958
+ }
959
+
960
+ getScrollableNode(): IScrollViewHandle | null {
961
+ return this.scrollView ?? null;
962
+ }
963
+
964
+ getScrollResponder(): IScrollViewHandle | null {
965
+ return this.scrollView ?? null;
966
+ }
967
+
968
+ getScrollNode(): ISymbioteNode | null {
969
+ return this.scrollView?.getScrollNode() ?? null;
970
+ }
971
+
972
+ recordInteraction(): void {
973
+ this.dispatch({ kind: 'record-interaction' });
974
+ }
975
+
976
+ private scrollToPixel(offset: number, animated: boolean): void {
977
+ const clamped = Math.max(EMPTY_OFFSET, offset);
978
+ const target = this.isHorizontal
979
+ ? { x: clamped, y: EMPTY_OFFSET }
980
+ : { x: EMPTY_OFFSET, y: clamped };
981
+ if (this.scrollView !== undefined) {
982
+ dlog(
983
+ `Angular VirtualizedList scrollTo offset=${clamped} animated=${animated} (horizontal=${this.isHorizontal})`,
984
+ );
985
+ this.scrollView.scrollTo({ x: target.x, y: target.y, animated });
986
+ return;
987
+ }
988
+ dlog(`Angular VirtualizedList scrollTo offset=${clamped} pending-ref`);
989
+ this.commandedOffset = target;
990
+ this.cdr.markForCheck();
991
+ }
992
+ }