aix 0.0.14 → 0.1.0-alpha.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 (239) hide show
  1. package/Aix.podspec +32 -0
  2. package/LICENSE +2 -2
  3. package/README.md +165 -33
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  10. package/android/src/main/java/com/aix/AixPackage.kt +29 -0
  11. package/android/src/main/java/com/aix/HybridAix.kt +27 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridAix.swift +1072 -0
  14. package/ios/HybridAixCellView.swift +174 -0
  15. package/ios/HybridAixComposer.swift +119 -0
  16. package/lib/commonjs/aix.js +25 -0
  17. package/lib/commonjs/aix.js.map +1 -0
  18. package/lib/commonjs/fade-in/createUsePool.js +50 -0
  19. package/lib/commonjs/fade-in/createUsePool.js.map +1 -0
  20. package/lib/commonjs/fade-in/createUseStaggered.js +82 -0
  21. package/lib/commonjs/fade-in/createUseStaggered.js.map +1 -0
  22. package/lib/commonjs/fade-in/index.js +78 -0
  23. package/lib/commonjs/fade-in/index.js.map +1 -0
  24. package/lib/commonjs/footer.js +28 -0
  25. package/lib/commonjs/footer.js.map +1 -0
  26. package/lib/commonjs/index.js +48 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/package.json +1 -0
  29. package/lib/commonjs/views/aix.nitro.js +6 -0
  30. package/lib/commonjs/views/aix.nitro.js.map +1 -0
  31. package/lib/module/aix.js +20 -0
  32. package/lib/module/aix.js.map +1 -0
  33. package/lib/module/fade-in/createUsePool.js +46 -0
  34. package/lib/module/fade-in/createUsePool.js.map +1 -0
  35. package/lib/module/fade-in/createUseStaggered.js +79 -0
  36. package/lib/module/fade-in/createUseStaggered.js.map +1 -0
  37. package/lib/module/fade-in/index.js +74 -0
  38. package/lib/module/fade-in/index.js.map +1 -0
  39. package/lib/module/footer.js +23 -0
  40. package/lib/module/footer.js.map +1 -0
  41. package/lib/module/index.js +13 -0
  42. package/lib/module/index.js.map +1 -0
  43. package/lib/module/package.json +1 -0
  44. package/lib/module/views/aix.nitro.js +4 -0
  45. package/lib/module/views/aix.nitro.js.map +1 -0
  46. package/lib/typescript/src/aix.d.ts +14 -0
  47. package/lib/typescript/src/aix.d.ts.map +1 -0
  48. package/lib/typescript/src/fade-in/createUsePool.d.ts +5 -0
  49. package/lib/typescript/src/fade-in/createUsePool.d.ts.map +1 -0
  50. package/lib/typescript/src/fade-in/createUseStaggered.d.ts +2 -0
  51. package/lib/typescript/src/fade-in/createUseStaggered.d.ts.map +1 -0
  52. package/lib/typescript/src/fade-in/index.d.ts +5 -0
  53. package/lib/typescript/src/fade-in/index.d.ts.map +1 -0
  54. package/lib/typescript/src/footer.d.ts +5 -0
  55. package/lib/typescript/src/footer.d.ts.map +1 -0
  56. package/lib/typescript/src/index.d.ts +10 -0
  57. package/lib/typescript/src/index.d.ts.map +1 -0
  58. package/lib/typescript/src/views/aix.nitro.d.ts +101 -0
  59. package/lib/typescript/src/views/aix.nitro.d.ts.map +1 -0
  60. package/nitro.json +26 -0
  61. package/nitrogen/generated/.gitattributes +1 -0
  62. package/nitrogen/generated/android/Aix+autolinking.cmake +91 -0
  63. package/nitrogen/generated/android/Aix+autolinking.gradle +27 -0
  64. package/nitrogen/generated/android/AixOnLoad.cpp +70 -0
  65. package/nitrogen/generated/android/AixOnLoad.hpp +25 -0
  66. package/nitrogen/generated/android/c++/JAixAdditionalContentInsets.hpp +61 -0
  67. package/nitrogen/generated/android/c++/JAixAdditionalContentInsetsProp.hpp +63 -0
  68. package/nitrogen/generated/android/c++/JAixScrollIndicatorInsetValue.hpp +61 -0
  69. package/nitrogen/generated/android/c++/JAixScrollIndicatorInsets.hpp +63 -0
  70. package/nitrogen/generated/android/c++/JAixScrollOnFooterSizeUpdate.hpp +65 -0
  71. package/nitrogen/generated/android/c++/JHybridAixCellViewSpec.cpp +65 -0
  72. package/nitrogen/generated/android/c++/JHybridAixCellViewSpec.hpp +68 -0
  73. package/nitrogen/generated/android/c++/JHybridAixComposerSpec.cpp +48 -0
  74. package/nitrogen/generated/android/c++/JHybridAixComposerSpec.hpp +65 -0
  75. package/nitrogen/generated/android/c++/JHybridAixSpec.cpp +137 -0
  76. package/nitrogen/generated/android/c++/JHybridAixSpec.hpp +79 -0
  77. package/nitrogen/generated/android/c++/views/JHybridAixCellViewStateUpdater.cpp +60 -0
  78. package/nitrogen/generated/android/c++/views/JHybridAixCellViewStateUpdater.hpp +49 -0
  79. package/nitrogen/generated/android/c++/views/JHybridAixComposerStateUpdater.cpp +53 -0
  80. package/nitrogen/generated/android/c++/views/JHybridAixComposerStateUpdater.hpp +49 -0
  81. package/nitrogen/generated/android/c++/views/JHybridAixStateUpdater.cpp +80 -0
  82. package/nitrogen/generated/android/c++/views/JHybridAixStateUpdater.hpp +49 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixAdditionalContentInsets.kt +41 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixAdditionalContentInsetsProp.kt +41 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixOnLoad.kt +35 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixScrollIndicatorInsetValue.kt +41 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixScrollIndicatorInsets.kt +41 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/AixScrollOnFooterSizeUpdate.kt +44 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/HybridAixCellViewSpec.kt +65 -0
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/HybridAixComposerSpec.kt +55 -0
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/HybridAixSpec.kt +101 -0
  92. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixCellViewManager.kt +50 -0
  93. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixCellViewStateUpdater.kt +23 -0
  94. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixComposerManager.kt +50 -0
  95. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixComposerStateUpdater.kt +23 -0
  96. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixManager.kt +50 -0
  97. package/nitrogen/generated/android/kotlin/com/margelo/nitro/aix/views/HybridAixStateUpdater.kt +23 -0
  98. package/nitrogen/generated/ios/Aix+autolinking.rb +60 -0
  99. package/nitrogen/generated/ios/Aix-Swift-Cxx-Bridge.cpp +67 -0
  100. package/nitrogen/generated/ios/Aix-Swift-Cxx-Bridge.hpp +222 -0
  101. package/nitrogen/generated/ios/Aix-Swift-Cxx-Umbrella.hpp +70 -0
  102. package/nitrogen/generated/ios/AixAutolinking.mm +49 -0
  103. package/nitrogen/generated/ios/AixAutolinking.swift +55 -0
  104. package/nitrogen/generated/ios/c++/HybridAixCellViewSpecSwift.cpp +11 -0
  105. package/nitrogen/generated/ios/c++/HybridAixCellViewSpecSwift.hpp +80 -0
  106. package/nitrogen/generated/ios/c++/HybridAixComposerSpecSwift.cpp +11 -0
  107. package/nitrogen/generated/ios/c++/HybridAixComposerSpecSwift.hpp +69 -0
  108. package/nitrogen/generated/ios/c++/HybridAixSpecSwift.cpp +11 -0
  109. package/nitrogen/generated/ios/c++/HybridAixSpecSwift.hpp +142 -0
  110. package/nitrogen/generated/ios/c++/views/HybridAixCellViewComponent.mm +101 -0
  111. package/nitrogen/generated/ios/c++/views/HybridAixComponent.mm +126 -0
  112. package/nitrogen/generated/ios/c++/views/HybridAixComposerComponent.mm +92 -0
  113. package/nitrogen/generated/ios/swift/AixAdditionalContentInsets.swift +47 -0
  114. package/nitrogen/generated/ios/swift/AixAdditionalContentInsetsProp.swift +71 -0
  115. package/nitrogen/generated/ios/swift/AixScrollIndicatorInsetValue.swift +47 -0
  116. package/nitrogen/generated/ios/swift/AixScrollIndicatorInsets.swift +71 -0
  117. package/nitrogen/generated/ios/swift/AixScrollOnFooterSizeUpdate.swift +89 -0
  118. package/nitrogen/generated/ios/swift/HybridAixCellViewSpec.swift +57 -0
  119. package/nitrogen/generated/ios/swift/HybridAixCellViewSpec_cxx.swift +151 -0
  120. package/nitrogen/generated/ios/swift/HybridAixComposerSpec.swift +56 -0
  121. package/nitrogen/generated/ios/swift/HybridAixComposerSpec_cxx.swift +131 -0
  122. package/nitrogen/generated/ios/swift/HybridAixSpec.swift +63 -0
  123. package/nitrogen/generated/ios/swift/HybridAixSpec_cxx.swift +292 -0
  124. package/nitrogen/generated/shared/c++/AixAdditionalContentInsets.hpp +79 -0
  125. package/nitrogen/generated/shared/c++/AixAdditionalContentInsetsProp.hpp +81 -0
  126. package/nitrogen/generated/shared/c++/AixScrollIndicatorInsetValue.hpp +79 -0
  127. package/nitrogen/generated/shared/c++/AixScrollIndicatorInsets.hpp +81 -0
  128. package/nitrogen/generated/shared/c++/AixScrollOnFooterSizeUpdate.hpp +83 -0
  129. package/nitrogen/generated/shared/c++/HybridAixCellViewSpec.cpp +24 -0
  130. package/nitrogen/generated/shared/c++/HybridAixCellViewSpec.hpp +65 -0
  131. package/nitrogen/generated/shared/c++/HybridAixComposerSpec.cpp +21 -0
  132. package/nitrogen/generated/shared/c++/HybridAixComposerSpec.hpp +62 -0
  133. package/nitrogen/generated/shared/c++/HybridAixSpec.cpp +36 -0
  134. package/nitrogen/generated/shared/c++/HybridAixSpec.hpp +85 -0
  135. package/nitrogen/generated/shared/c++/views/HybridAixCellViewComponent.cpp +99 -0
  136. package/nitrogen/generated/shared/c++/views/HybridAixCellViewComponent.hpp +108 -0
  137. package/nitrogen/generated/shared/c++/views/HybridAixComponent.cpp +159 -0
  138. package/nitrogen/generated/shared/c++/views/HybridAixComponent.hpp +117 -0
  139. package/nitrogen/generated/shared/c++/views/HybridAixComposerComponent.cpp +75 -0
  140. package/nitrogen/generated/shared/c++/views/HybridAixComposerComponent.hpp +106 -0
  141. package/nitrogen/generated/shared/json/AixCellViewConfig.json +11 -0
  142. package/nitrogen/generated/shared/json/AixComposerConfig.json +9 -0
  143. package/nitrogen/generated/shared/json/AixConfig.json +16 -0
  144. package/package.json +115 -12
  145. package/src/aix.tsx +43 -0
  146. package/src/fade-in/createUsePool.ts +46 -0
  147. package/src/fade-in/createUseStaggered.ts +82 -0
  148. package/src/fade-in/index.tsx +97 -0
  149. package/src/footer.tsx +30 -0
  150. package/src/index.ts +20 -16
  151. package/src/views/aix.nitro.ts +148 -0
  152. package/docs/API.md +0 -193
  153. package/jest.config.js +0 -17
  154. package/lib/__tests__/deferredIterable.test.d.ts +0 -1
  155. package/lib/__tests__/deferredIterable.test.js +0 -111
  156. package/lib/__tests__/filter.test.d.ts +0 -1
  157. package/lib/__tests__/filter.test.js +0 -56
  158. package/lib/__tests__/flatMap.test.d.ts +0 -1
  159. package/lib/__tests__/flatMap.test.js +0 -80
  160. package/lib/__tests__/lookahead.test.d.ts +0 -1
  161. package/lib/__tests__/lookahead.test.js +0 -60
  162. package/lib/__tests__/map.test.d.ts +0 -1
  163. package/lib/__tests__/map.test.js +0 -56
  164. package/lib/__tests__/merge.test.d.ts +0 -1
  165. package/lib/__tests__/merge.test.js +0 -58
  166. package/lib/__tests__/reduce.test.d.ts +0 -1
  167. package/lib/__tests__/reduce.test.js +0 -55
  168. package/lib/__tests__/spanAll.test.d.ts +0 -1
  169. package/lib/__tests__/spanAll.test.js +0 -123
  170. package/lib/concat.d.ts +0 -5
  171. package/lib/concat.js +0 -127
  172. package/lib/deferred.d.ts +0 -10
  173. package/lib/deferred.js +0 -19
  174. package/lib/deferredIterable.d.ts +0 -23
  175. package/lib/deferredIterable.js +0 -112
  176. package/lib/filter.d.ts +0 -8
  177. package/lib/filter.js +0 -100
  178. package/lib/flatMap.d.ts +0 -2
  179. package/lib/flatMap.js +0 -120
  180. package/lib/fromEvent.d.ts +0 -6
  181. package/lib/fromEvent.js +0 -17
  182. package/lib/index.d.ts +0 -16
  183. package/lib/index.js +0 -34
  184. package/lib/insert.d.ts +0 -5
  185. package/lib/insert.js +0 -114
  186. package/lib/interval.d.ts +0 -5
  187. package/lib/interval.js +0 -68
  188. package/lib/iterableToArray.d.ts +0 -2
  189. package/lib/iterableToArray.js +0 -88
  190. package/lib/iteratorToIterable.d.ts +0 -7
  191. package/lib/iteratorToIterable.js +0 -71
  192. package/lib/lookahead.d.ts +0 -11
  193. package/lib/lookahead.js +0 -82
  194. package/lib/map.d.ts +0 -5
  195. package/lib/map.js +0 -99
  196. package/lib/merge.d.ts +0 -7
  197. package/lib/merge.js +0 -25
  198. package/lib/reduce.d.ts +0 -5
  199. package/lib/reduce.js +0 -93
  200. package/lib/restToIterable.d.ts +0 -5
  201. package/lib/restToIterable.js +0 -74
  202. package/lib/spanAll.d.ts +0 -2
  203. package/lib/spanAll.js +0 -34
  204. package/lib/tap.d.ts +0 -5
  205. package/lib/tap.js +0 -97
  206. package/lib/toCallbacks.d.ts +0 -12
  207. package/lib/toCallbacks.js +0 -98
  208. package/lib/zip.d.ts +0 -5
  209. package/lib/zip.js +0 -76
  210. package/src/__tests__/deferredIterable.test.ts +0 -22
  211. package/src/__tests__/filter.test.ts +0 -10
  212. package/src/__tests__/flatMap.test.ts +0 -12
  213. package/src/__tests__/lookahead.test.ts +0 -9
  214. package/src/__tests__/map.test.ts +0 -10
  215. package/src/__tests__/merge.test.ts +0 -9
  216. package/src/__tests__/reduce.test.ts +0 -10
  217. package/src/__tests__/spanAll.test.ts +0 -17
  218. package/src/concat.ts +0 -13
  219. package/src/deferred.ts +0 -15
  220. package/src/deferredIterable.ts +0 -111
  221. package/src/filter.ts +0 -16
  222. package/src/flatMap.ts +0 -9
  223. package/src/fromEvent.ts +0 -16
  224. package/src/insert.ts +0 -13
  225. package/src/interval.ts +0 -20
  226. package/src/iterableToArray.ts +0 -7
  227. package/src/iteratorToIterable.ts +0 -12
  228. package/src/lookahead.ts +0 -27
  229. package/src/map.ts +0 -11
  230. package/src/merge.ts +0 -16
  231. package/src/of.ts +0 -4
  232. package/src/reduce.ts +0 -12
  233. package/src/restToIterable.ts +0 -8
  234. package/src/spanAll.ts +0 -26
  235. package/src/tap.ts +0 -11
  236. package/src/toCallbacks.ts +0 -27
  237. package/src/zip.ts +0 -19
  238. package/tsconfig.json +0 -63
  239. package/yarn.lock +0 -3514
@@ -0,0 +1,97 @@
1
+ import {
2
+ useAnimatedStyle,
3
+ useSharedValue,
4
+ withTiming,
5
+ } from 'react-native-reanimated'
6
+ import { createUsePool } from './createUsePool'
7
+ import { createUseStaggered } from './createUseStaggered'
8
+ import Animated from 'react-native-reanimated'
9
+ import { Children, memo, useState } from 'react'
10
+
11
+ const useIsAnimatedInPool = createUsePool()
12
+ const useStaggeredAnimation = createUseStaggered(32)
13
+
14
+ function FadeIn({
15
+ children,
16
+ onFadedIn,
17
+ Component = Animated.Text as any,
18
+ }: {
19
+ children: React.ReactNode
20
+ onFadedIn: () => void
21
+ Component?: React.ComponentType<any>
22
+ }) {
23
+ const progress = useSharedValue(0)
24
+
25
+ const startAnimation = () => {
26
+ progress.set(withTiming(1, { duration: 500 }))
27
+ setTimeout(onFadedIn, 500)
28
+ }
29
+
30
+ useStaggeredAnimation(startAnimation)
31
+
32
+ const animatedStyle = useAnimatedStyle(() => ({
33
+ opacity: progress.get(),
34
+ }))
35
+
36
+ return <Component style={animatedStyle}>{children}</Component>
37
+ }
38
+
39
+ const AnimatedFadeInText = memo(function AnimatedFadeInText(props: {
40
+ text: string
41
+ }) {
42
+ const chunks = props.text.split(' ')
43
+
44
+ return chunks.map((chunk, i) => {
45
+ if (i < chunks.length - 1) chunk += ' '
46
+
47
+ return <TextFadeInStaggered key={i} text={chunk} />
48
+ })
49
+ })
50
+
51
+ export const TextFadeInStaggeredIfStreaming = memo(
52
+ function TextFadeInStaggeredIfStreaming({
53
+ children: childrenProp,
54
+ disabled,
55
+ }: {
56
+ children: React.ReactNode
57
+ disabled: boolean
58
+ }) {
59
+ const [enabled] = useState(!disabled)
60
+
61
+ let children = childrenProp
62
+ if (enabled && children) {
63
+ if (Array.isArray(children)) {
64
+ children = Children.map(children, (child, i) =>
65
+ typeof child === 'string' ? (
66
+ <AnimatedFadeInText key={i} text={child} />
67
+ ) : (
68
+ child
69
+ )
70
+ )
71
+ } else if (typeof children === 'string') {
72
+ children = <AnimatedFadeInText text={children} />
73
+ }
74
+ }
75
+
76
+ return children
77
+ }
78
+ )
79
+
80
+ const TextFadeInStaggered = memo(function TextFadeInStaggered({
81
+ text,
82
+ }: {
83
+ text: string
84
+ }) {
85
+ const { isActive, evict } = useIsAnimatedInPool()
86
+ return isActive ? (
87
+ <FadeIn
88
+ onFadedIn={() => {
89
+ evict()
90
+ }}
91
+ >
92
+ {text}
93
+ </FadeIn>
94
+ ) : (
95
+ text
96
+ )
97
+ })
package/src/footer.tsx ADDED
@@ -0,0 +1,30 @@
1
+ import { getHostComponent } from 'react-native-nitro-modules'
2
+ import AixComposerConfig from '../nitrogen/generated/shared/json/AixComposerConfig.json'
3
+ import type { AixComposerProps } from './views/aix.nitro'
4
+ import { StyleSheet } from 'react-native'
5
+
6
+ const AixFooterInternal = getHostComponent<AixComposerProps, {}>(
7
+ 'AixComposer',
8
+ () => AixComposerConfig
9
+ )
10
+
11
+ export function AixFooter(
12
+ props: React.ComponentProps<typeof AixFooterInternal>
13
+ ) {
14
+ if (__DEV__) {
15
+ const flat = StyleSheet.flatten(props.style)
16
+ const broken = Object.keys({
17
+ paddingBottom: flat.paddingBottom,
18
+ padding: flat.padding,
19
+ }).filter((key) => flat[key as keyof typeof flat] !== undefined)
20
+
21
+ if (broken.length) {
22
+ console.error(
23
+ `<AixFooter /> You used ${broken.join(
24
+ ', '
25
+ )} in the style prop. Vertical padding is not supported on AixFooter directly. Please apply it to a child view instead.`
26
+ )
27
+ }
28
+ }
29
+ return <AixFooterInternal {...props} />
30
+ }
package/src/index.ts CHANGED
@@ -1,16 +1,20 @@
1
- export { DeferredIterable } from "./deferredIterable";
2
- export { restToIterable } from "./restToIterable";
3
- export { merge } from "./merge";
4
- export { lookahead } from "./lookahead";
5
- export { toCallbacks } from "./toCallbacks";
6
- export { iteratorToIterable } from "./iteratorToIterable";
7
- export { map } from "./map";
8
- export { flatMap } from "./flatMap";
9
- export { interval } from "./interval";
10
- export { insert } from "./insert";
11
- export { zip } from "./zip";
12
- export { iterableToArray } from "./iterableToArray";
13
- export { filter } from "./filter";
14
- export { concat } from "./concat";
15
- export { fromEvent } from "./fromEvent";
16
- export { tap } from "./tap";
1
+ import { getHostComponent, type HybridRef } from 'react-native-nitro-modules'
2
+ import AixCellViewConfig from '../nitrogen/generated/shared/json/AixCellViewConfig.json'
3
+ import type { AixCellViewProps } from './views/aix.nitro'
4
+ import { useRef } from 'react'
5
+ import type { AixRef } from './aix'
6
+ export * from './fade-in'
7
+
8
+ export { Aix, type AixRef } from './aix'
9
+ export { AixFooter } from './footer'
10
+
11
+ export const AixCell = getHostComponent<AixCellViewProps, {}>(
12
+ 'AixCellView',
13
+ () => AixCellViewConfig
14
+ )
15
+
16
+ export type AixCellViewRef = HybridRef<AixCellViewProps, {}>
17
+
18
+ export function useAixRef() {
19
+ return useRef<AixRef | null>(null)
20
+ }
@@ -0,0 +1,148 @@
1
+ import type {
2
+ HybridView,
3
+ HybridViewProps,
4
+ HybridViewMethods,
5
+ } from 'react-native-nitro-modules'
6
+
7
+ export interface AixAdditionalContentInsets {
8
+ whenKeyboardOpen: number
9
+ whenKeyboardClosed: number
10
+ }
11
+
12
+ export interface AixAdditionalContentInsetsProp {
13
+ top?: AixAdditionalContentInsets
14
+ bottom?: AixAdditionalContentInsets
15
+ }
16
+
17
+ export interface AixScrollIndicatorInsetValue {
18
+ whenKeyboardOpen: number
19
+ whenKeyboardClosed: number
20
+ }
21
+
22
+ export interface AixScrollIndicatorInsets {
23
+ top?: AixScrollIndicatorInsetValue
24
+ bottom?: AixScrollIndicatorInsetValue
25
+ }
26
+
27
+ export interface AixScrollOnFooterSizeUpdate {
28
+ /**
29
+ * Whether to scroll on footer size update.
30
+ *
31
+ * Default: true
32
+ */
33
+ enabled: boolean
34
+ /**
35
+ * The number of pixels from the bottom of the scroll view to the end of the content that is considered "scrolled near the end".
36
+ *
37
+ * Default: 100
38
+ */
39
+ scrolledToEndThreshold?: number
40
+ /**
41
+ * Whether to animate the scroll.
42
+ *
43
+ * Default: false
44
+ */
45
+ animated?: boolean
46
+ }
47
+
48
+ export interface AixProps extends HybridViewProps {
49
+ shouldStartAtEnd: boolean
50
+ /**
51
+ * Control the behavior of scrolling the content when footer size changes.
52
+ *
53
+ * By default, changing the height of the footer will shift content up in the scroll view.
54
+ *
55
+ * Default: { enabled: true, scrolledToEndThreshold: 100, animated: false }
56
+ */
57
+ scrollOnFooterSizeUpdate?: AixScrollOnFooterSizeUpdate
58
+ /**
59
+ * The number of pixels from the bottom of the scroll view to the end of the content that is considered "near the end".
60
+ *
61
+ * If the scroll view is scrolled to the end of the content, and the content is less than this threshold, the content will be shifted up when the keyboard is opened.
62
+ *
63
+ * By default, it will be the greater of the current blank size, or 200.
64
+ *
65
+ * TODO make this a more adaptive prop, like { strategy: 'blank-size', min: 200 } | { strategy: 'fixed', value: 200 }
66
+ *
67
+ */
68
+ scrollEndReachedThreshold?: number
69
+ /**
70
+ * Scroll end blank size threshold.
71
+ *
72
+ * If the blank size is less than this threshold, then the content will collapse to the keyboard when the keyboard is opened.
73
+ *
74
+ * You likely don't need to customize this much.
75
+ *
76
+ * Default: 0
77
+ *
78
+ * TODO we might want to implement this, but i'm not sure.
79
+ *
80
+ * By default, the content will collapse to the keyboard on opening if the blank size is less than half the size of the scroll view parent, and greater than the keyboard height.
81
+ */
82
+
83
+ additionalContentInsets?: AixAdditionalContentInsetsProp
84
+
85
+ /**
86
+ * Additional insets for the scroll indicator, added to existing safe area insets.
87
+ * Applied to verticalScrollIndicatorInsets on iOS.
88
+ */
89
+ additionalScrollIndicatorInsets?: AixScrollIndicatorInsets
90
+
91
+ /**
92
+ * The nativeID of the scroll view to use.
93
+ *
94
+ * If provided, will search for a scroll view with this accessibilityIdentifier.
95
+ * If not provided or not found, falls back to the default subview iteration logic.
96
+ */
97
+ mainScrollViewID?: string
98
+
99
+ /**
100
+ * Used to index of the second-to-last message.
101
+ *
102
+ * For AI chat apps, it should correspond to the index of the last user message.
103
+ *
104
+ * By default, it will simply be the seccond-to-last item. Specifically, it will correspond to the Cell index before the <Cell isLast />.
105
+ *
106
+ * However, if you use custom message types, you can override it with this prop.
107
+ *
108
+ * For example, if you use a "<Timestamp />" row in your LegendList or FlashList implementation, then you can set this value.
109
+ *
110
+ * This indicates which message will be scrolled into view.
111
+ *
112
+ */
113
+ penultimateCellIndex?: number
114
+ }
115
+
116
+ export interface AixMethods extends HybridViewMethods {
117
+ scrollToEnd(animated?: boolean): void
118
+ scrollToIndexWhenBlankSizeReady(
119
+ index: number,
120
+ animated?: boolean,
121
+ waitForKeyboardToEnd?: boolean
122
+ ): void
123
+ }
124
+
125
+ export type Aix = HybridView<
126
+ AixProps,
127
+ AixMethods,
128
+ { ios: 'swift'; android: 'kotlin' }
129
+ >
130
+
131
+ export interface AixCellViewProps extends HybridViewProps {
132
+ isLast: boolean
133
+ index: number
134
+ }
135
+
136
+ export type AixCellView = HybridView<
137
+ AixCellViewProps,
138
+ {},
139
+ { ios: 'swift'; android: 'kotlin' }
140
+ >
141
+
142
+ export interface AixComposerProps extends HybridViewProps {}
143
+
144
+ export type AixComposer = HybridView<
145
+ AixComposerProps,
146
+ {},
147
+ { ios: 'swift'; android: 'kotlin' }
148
+ >
package/docs/API.md DELETED
@@ -1,193 +0,0 @@
1
- # Aix API Reference
2
-
3
- ## Classes
4
-
5
- - [DeferredIterable](#deferrediterable)
6
- - [DeferredIterable.callback](#deferrediterablecallback)
7
- - [DeferredIterable.iterable](#deferrediterableiterable)
8
- - [DeferredIterable.finally](#deferrediterablefinally)
9
- - [DeferredIterable.value](#deferrediterablevalue)
10
- - [DeferredIterable.finish](#deferrediterablefinish)
11
-
12
- ## Functions
13
-
14
- - [of](#of)
15
- - [map](#map)
16
- - [filter](#filter)
17
- - [flatMap](#flatMap)
18
- - [concat](#concat)
19
-
20
- # Classes
21
-
22
- ## DeferredIterable
23
-
24
- `DeferredIterable` makes it easy to turn stream of events into an interable.
25
-
26
- You typically interact with `DeferredIterable` in 2 ways:
27
-
28
- - To send data into the `DeferredIterable` call the `callback` function to send an `IteratorResult`
29
- - To read data from the `DeferredIterable` use the `iterable` property.
30
-
31
- ### Example
32
-
33
- ```javascript
34
- import { DeferredIterable } from "aix/deferredIterable";
35
-
36
- const deferredIterable = new DeferredIterable();
37
-
38
- // set up a callback that calls value on the deferredIterable
39
- const callback = value => deferredIterable.value(value);
40
-
41
- // attach the callback to the click event
42
- document.addEventListener('click', callback);
43
-
44
- // remove the callback when / if the iterable stops
45
- deferredIterable.finally(() => document.removeEventListener('click', deferredIterable.value));
46
-
47
- // go through all the click events
48
- for await (const click of deferredIterable.iterable) {
49
- console.log('a button was clicked');
50
- }
51
- ```
52
-
53
- ### DeferredIterable.callback
54
-
55
- The callback to call to send a `IteratorResult` into the `DeferredIterable`. An `IteratorResult`
56
- has a `done` boolean property and a `value` property.
57
-
58
- ```javascript
59
- import { DeferredIterable } from "aix/deferredIterable";
60
-
61
- const deferredIterable = new DeferredIterable();
62
- deferredIterable.callback({ done: false, value: 1 });
63
- deferredIterable.callback({ done: false, value: 2 });
64
- deferredIterable.callback({ done: false, value: 3 });
65
- deferredIterable.callback({ done: true });
66
-
67
- for await (const item of deferredIterable.iterable) {
68
- console.log(item); // prints 1, 2, 3
69
- }
70
- ```
71
-
72
- ### DeferredIterable.iterable
73
-
74
- An ```AsyncIterable``` that returns values supplied by calling ```callback```.
75
-
76
- ```javascript
77
- import { DeferredIterable } from "aix/deferredIterable";
78
-
79
- const deferredIterable = new DeferredIterable();
80
- deferredIterable.callback({ done: false, value: 1 });
81
- deferredIterable.callback({ done: false, value: 2 });
82
- deferredIterable.callback({ done: false, value: 3 });
83
- deferredIterable.callback({ done: true });
84
-
85
- for await (const item of deferredIterable.iterable) {
86
- console.log(item); // prints 1, 2, 3
87
- }
88
- ```
89
-
90
- ### DeferredIterable.finally
91
-
92
- The callback supplied to ```finally``` is called when the iterable finishes either
93
- because it's run out of values, it has returned or an error was thrown.
94
-
95
- ### DeferredIterable.value
96
-
97
- A helper method to pass a value to the DeferredIterable. Calling
98
- ```deferredIterable.value('test')``` is the same as calling
99
- ```deferredIterable.callback({ done: false, value: 'test'} )```.
100
-
101
- ### DeferredIterable.finish
102
-
103
- A helper method to signal the last value to DeferredIterable. Calling
104
- ```deferredIterable.finish()``` is the same as calling
105
- ```deferredIterable.callback({ done: true} )```.
106
-
107
- # Functions
108
-
109
- ## of
110
-
111
- Construct a new async iterable from a series
112
- of values.
113
-
114
- ```javascript
115
- import { of } from "aix/of";
116
-
117
- const values = of(1, 2, 3);
118
-
119
- for await(const item of mapped) {
120
- console.log(item); // outputs 1, 2, 3
121
- }
122
- ```
123
-
124
- ## map
125
-
126
- Go through each item in the iterable and run a mapping function. The result will be a new
127
- iterable with the transformed values.
128
-
129
- ```javascript
130
- import { map } from "aix/map";
131
- import { of } from "aix/of";
132
-
133
- const mapped = map(value => value * 2)(of(1, 2, 3));
134
-
135
- for await(const item of mapped) {
136
- console.log(item); // outputs 2, 4, 6
137
- }
138
- ```
139
-
140
- ## flatMap
141
-
142
- Go through each item in the iterable and run a mapping function that returns an async iterable. The
143
- result is then flattened.
144
-
145
- ```javascript
146
- import { flatMap } from "aix/flatMap";
147
- import { of } from "aix/of";
148
-
149
- const mapped = flatMap(
150
- async function* (value) {
151
- yield value;
152
- yield value;
153
- }
154
- )(of(1, 2, 3);
155
-
156
- for await(const item of mapped) {
157
- console.log(item); // outputs 1, 1, 2, 2, 3, 3
158
- }
159
- ```
160
-
161
- ## filter
162
-
163
- Filter an iterable based on some criteria.
164
-
165
- ```javascript
166
- import { filter } from "aix/filter";
167
- import { of } from "aix/of";
168
-
169
- const filtered = filter(
170
- value => value % 2 === 0
171
- )(of(1, 2, 3, 4, 5, 6);
172
-
173
- for await(const item of filtered) {
174
- console.log(item); // outputs 2, 4, 6
175
- }
176
- ```
177
-
178
- ## concat
179
-
180
- Concatenate 2 iterables in order
181
-
182
- ```javascript
183
- import { concat } from "aix/concat";
184
- import { of } from "aix/of";
185
-
186
- const concatted = concat(
187
- of(1, 2)
188
- )(of(3, 4);
189
-
190
- for await(const item of concatted) {
191
- console.log(item); // outputs 1, 2, 3, 4
192
- }
193
- ```
package/jest.config.js DELETED
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- "roots": [
3
- "<rootDir>/src"
4
- ],
5
- "transform": {
6
- "^.+\\.tsx?$": "ts-jest"
7
- },
8
- "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
9
- "moduleFileExtensions": [
10
- "ts",
11
- "tsx",
12
- "js",
13
- "jsx",
14
- "json",
15
- "node"
16
- ],
17
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,111 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __asyncValues = (this && this.__asyncValues) || function (o) {
38
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
39
- var m = o[Symbol.asyncIterator], i;
40
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
41
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
42
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- var _this = this;
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- var deferredIterable_1 = __importDefault(require("../deferredIterable"));
50
- test("DeferredIterable", function () { return __awaiter(_this, void 0, void 0, function () {
51
- var e_1, _a, d, result, _b, _c, item, e_1_1;
52
- return __generator(this, function (_d) {
53
- switch (_d.label) {
54
- case 0:
55
- d = new deferredIterable_1.default();
56
- d.value(1);
57
- d.value(2);
58
- d.value(3);
59
- d.close();
60
- result = [];
61
- _d.label = 1;
62
- case 1:
63
- _d.trys.push([1, 6, 7, 12]);
64
- _b = __asyncValues(d.iterator);
65
- _d.label = 2;
66
- case 2: return [4 /*yield*/, _b.next()];
67
- case 3:
68
- if (!(_c = _d.sent(), !_c.done)) return [3 /*break*/, 5];
69
- item = _c.value;
70
- result.push(item);
71
- _d.label = 4;
72
- case 4: return [3 /*break*/, 2];
73
- case 5: return [3 /*break*/, 12];
74
- case 6:
75
- e_1_1 = _d.sent();
76
- e_1 = { error: e_1_1 };
77
- return [3 /*break*/, 12];
78
- case 7:
79
- _d.trys.push([7, , 10, 11]);
80
- if (!(_c && !_c.done && (_a = _b.return))) return [3 /*break*/, 9];
81
- return [4 /*yield*/, _a.call(_b)];
82
- case 8:
83
- _d.sent();
84
- _d.label = 9;
85
- case 9: return [3 /*break*/, 11];
86
- case 10:
87
- if (e_1) throw e_1.error;
88
- return [7 /*endfinally*/];
89
- case 11: return [7 /*endfinally*/];
90
- case 12:
91
- expect(result).toEqual([1, 2, 3]);
92
- return [2 /*return*/];
93
- }
94
- });
95
- }); });
96
- test("DeferredIterable", function () { return __awaiter(_this, void 0, void 0, function () {
97
- var d, iterator, _a, _b, value, done;
98
- return __generator(this, function (_c) {
99
- switch (_c.label) {
100
- case 0:
101
- d = new deferredIterable_1.default();
102
- iterator = d.iterator;
103
- return [4 /*yield*/, Promise.all([d.value(1), iterator.next()])];
104
- case 1:
105
- _a = _c.sent(), _b = _a[1], value = _b.value, done = _b.done;
106
- expect(done).toBeFalsy();
107
- expect(value).toBe(1);
108
- return [2 /*return*/];
109
- }
110
- });
111
- }); });
@@ -1 +0,0 @@
1
- export {};