aix 0.0.15 → 0.1.0

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 (241) 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 +113 -14
  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 -288
  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 -108
  156. package/lib/__tests__/filter.test.d.ts +0 -1
  157. package/lib/__tests__/filter.test.js +0 -53
  158. package/lib/__tests__/flatMap.test.d.ts +0 -1
  159. package/lib/__tests__/flatMap.test.js +0 -77
  160. package/lib/__tests__/lookahead.test.d.ts +0 -1
  161. package/lib/__tests__/lookahead.test.js +0 -57
  162. package/lib/__tests__/map.test.d.ts +0 -1
  163. package/lib/__tests__/map.test.js +0 -53
  164. package/lib/__tests__/merge.test.d.ts +0 -1
  165. package/lib/__tests__/merge.test.js +0 -55
  166. package/lib/__tests__/reduce.test.d.ts +0 -1
  167. package/lib/__tests__/reduce.test.js +0 -52
  168. package/lib/__tests__/spanAll.test.d.ts +0 -1
  169. package/lib/__tests__/spanAll.test.js +0 -120
  170. package/lib/concat.d.ts +0 -4
  171. package/lib/concat.js +0 -126
  172. package/lib/deferred.d.ts +0 -9
  173. package/lib/deferred.js +0 -18
  174. package/lib/deferredIterable.d.ts +0 -22
  175. package/lib/deferredIterable.js +0 -111
  176. package/lib/filter.d.ts +0 -7
  177. package/lib/filter.js +0 -99
  178. package/lib/flatMap.d.ts +0 -1
  179. package/lib/flatMap.js +0 -119
  180. package/lib/fromEvent.d.ts +0 -5
  181. package/lib/fromEvent.js +0 -13
  182. package/lib/index.d.ts +0 -16
  183. package/lib/index.js +0 -34
  184. package/lib/insert.d.ts +0 -4
  185. package/lib/insert.js +0 -113
  186. package/lib/interval.d.ts +0 -4
  187. package/lib/interval.js +0 -64
  188. package/lib/iterableToArray.d.ts +0 -1
  189. package/lib/iterableToArray.js +0 -87
  190. package/lib/iteratorToIterable.d.ts +0 -6
  191. package/lib/iteratorToIterable.js +0 -70
  192. package/lib/lookahead.d.ts +0 -10
  193. package/lib/lookahead.js +0 -78
  194. package/lib/map.d.ts +0 -4
  195. package/lib/map.js +0 -98
  196. package/lib/merge.d.ts +0 -6
  197. package/lib/merge.js +0 -21
  198. package/lib/of.d.ts +0 -3
  199. package/lib/of.js +0 -5
  200. package/lib/reduce.d.ts +0 -4
  201. package/lib/reduce.js +0 -92
  202. package/lib/restToIterable.d.ts +0 -4
  203. package/lib/restToIterable.js +0 -73
  204. package/lib/spanAll.d.ts +0 -1
  205. package/lib/spanAll.js +0 -29
  206. package/lib/tap.d.ts +0 -4
  207. package/lib/tap.js +0 -96
  208. package/lib/toCallbacks.d.ts +0 -11
  209. package/lib/toCallbacks.js +0 -97
  210. package/lib/zip.d.ts +0 -4
  211. package/lib/zip.js +0 -75
  212. package/src/__tests__/deferredIterable.test.ts +0 -22
  213. package/src/__tests__/filter.test.ts +0 -10
  214. package/src/__tests__/flatMap.test.ts +0 -12
  215. package/src/__tests__/lookahead.test.ts +0 -9
  216. package/src/__tests__/map.test.ts +0 -10
  217. package/src/__tests__/merge.test.ts +0 -9
  218. package/src/__tests__/reduce.test.ts +0 -10
  219. package/src/__tests__/spanAll.test.ts +0 -17
  220. package/src/concat.ts +0 -13
  221. package/src/deferred.ts +0 -16
  222. package/src/deferredIterable.ts +0 -111
  223. package/src/filter.ts +0 -16
  224. package/src/flatMap.ts +0 -9
  225. package/src/fromEvent.ts +0 -16
  226. package/src/insert.ts +0 -13
  227. package/src/interval.ts +0 -20
  228. package/src/iterableToArray.ts +0 -7
  229. package/src/iteratorToIterable.ts +0 -12
  230. package/src/lookahead.ts +0 -27
  231. package/src/map.ts +0 -11
  232. package/src/merge.ts +0 -18
  233. package/src/of.ts +0 -4
  234. package/src/reduce.ts +0 -12
  235. package/src/restToIterable.ts +0 -8
  236. package/src/spanAll.ts +0 -26
  237. package/src/tap.ts +0 -11
  238. package/src/toCallbacks.ts +0 -27
  239. package/src/zip.ts +0 -19
  240. package/tsconfig.json +0 -63
  241. 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,288 +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
- - [reduce](#reduce)
20
- - [merge](#merge)
21
- - [insert](#insert)
22
- - [tap](#tap)
23
- - [zip](#zip)
24
-
25
- # Classes
26
-
27
- ## DeferredIterable
28
-
29
- `DeferredIterable` makes it easy to turn stream of events into an interable.
30
-
31
- You typically interact with `DeferredIterable` in 2 ways:
32
-
33
- - To send data into the `DeferredIterable` call the `callback` function to send an `IteratorResult`
34
- - To read data from the `DeferredIterable` use the `iterable` property.
35
-
36
- ### Example
37
-
38
- ```javascript
39
- import { DeferredIterable } from "aix/deferredIterable";
40
-
41
- const deferredIterable = new DeferredIterable();
42
-
43
- // set up a callback that calls value on the deferredIterable
44
- const callback = value => deferredIterable.value(value);
45
-
46
- // attach the callback to the click event
47
- document.addEventListener('click', callback);
48
-
49
- // remove the callback when / if the iterable stops
50
- deferredIterable.finally(() => document.removeEventListener('click', deferredIterable.value));
51
-
52
- // go through all the click events
53
- for await (const click of deferredIterable.iterable) {
54
- console.log('a button was clicked');
55
- }
56
- ```
57
-
58
- ### DeferredIterable.callback
59
-
60
- The callback to call to send a `IteratorResult` into the `DeferredIterable`. An `IteratorResult`
61
- has a `done` boolean property and a `value` property.
62
-
63
- ```javascript
64
- import { DeferredIterable } from "aix/deferredIterable";
65
-
66
- const deferredIterable = new DeferredIterable();
67
- deferredIterable.callback({ done: false, value: 1 });
68
- deferredIterable.callback({ done: false, value: 2 });
69
- deferredIterable.callback({ done: false, value: 3 });
70
- deferredIterable.callback({ done: true });
71
-
72
- for await (const item of deferredIterable.iterable) {
73
- console.log(item); // prints 1, 2, 3
74
- }
75
- ```
76
-
77
- ### DeferredIterable.iterable
78
-
79
- An ```AsyncIterable``` that returns values supplied by calling ```callback```.
80
-
81
- ```javascript
82
- import { DeferredIterable } from "aix/deferredIterable";
83
-
84
- const deferredIterable = new DeferredIterable();
85
- deferredIterable.callback({ done: false, value: 1 });
86
- deferredIterable.callback({ done: false, value: 2 });
87
- deferredIterable.callback({ done: false, value: 3 });
88
- deferredIterable.callback({ done: true });
89
-
90
- for await (const item of deferredIterable.iterable) {
91
- console.log(item); // prints 1, 2, 3
92
- }
93
- ```
94
-
95
- ### DeferredIterable.finally
96
-
97
- The callback supplied to ```finally``` is called when the iterable finishes either
98
- because it's run out of values, it has returned or an error was thrown.
99
-
100
- ### DeferredIterable.value
101
-
102
- A helper method to pass a value to the DeferredIterable. Calling
103
- ```deferredIterable.value('test')``` is the same as calling
104
- ```deferredIterable.callback({ done: false, value: 'test'} )```.
105
-
106
- ### DeferredIterable.finish
107
-
108
- A helper method to signal the last value to DeferredIterable. Calling
109
- ```deferredIterable.finish()``` is the same as calling
110
- ```deferredIterable.callback({ done: true} )```.
111
-
112
- # Functions
113
-
114
- ## of
115
-
116
- Construct a new async iterable from a series
117
- of values.
118
-
119
- ```javascript
120
- import { of } from "aix/of";
121
-
122
- const values = of(1, 2, 3);
123
-
124
- for await(const item of mapped) {
125
- console.log(item); // outputs 1, 2, 3
126
- }
127
- ```
128
-
129
- ## map
130
-
131
- Go through each item in the iterable and run a mapping function. The result will be a new
132
- iterable with the transformed values.
133
-
134
- ```javascript
135
- import { map } from "aix/map";
136
- import { of } from "aix/of";
137
-
138
- const mapped = map(value => value * 2)(of(1, 2, 3));
139
-
140
- for await(const item of mapped) {
141
- console.log(item); // outputs 2, 4, 6
142
- }
143
- ```
144
-
145
- ## flatMap
146
-
147
- Go through each item in the iterable and run a mapping function that returns an async iterable. The
148
- result is then flattened.
149
-
150
- ```javascript
151
- import { flatMap } from "aix/flatMap";
152
- import { of } from "aix/of";
153
-
154
- const mapped = flatMap(
155
- async function* (value) {
156
- yield value;
157
- yield value;
158
- }
159
- )(of(1, 2, 3);
160
-
161
- for await(const item of mapped) {
162
- console.log(item); // outputs 1, 1, 2, 2, 3, 3
163
- }
164
- ```
165
-
166
- ## filter
167
-
168
- Filter an iterable based on some criteria.
169
-
170
- ```javascript
171
- import { filter } from "aix/filter";
172
- import { of } from "aix/of";
173
-
174
- const filtered = filter(
175
- value => value % 2 === 0
176
- )(of(1, 2, 3, 4, 5, 6);
177
-
178
- for await(const item of filtered) {
179
- console.log(item); // outputs 2, 4, 6
180
- }
181
- ```
182
-
183
- ## concat
184
-
185
- Concatenate 2 iterables in order
186
-
187
- ```javascript
188
- import { concat } from "aix/concat";
189
- import { of } from "aix/of";
190
-
191
- const concatted = concat(
192
- of(1, 2)
193
- )(of(3, 4);
194
-
195
- for await(const item of concatted) {
196
- console.log(item); // outputs 1, 2, 3, 4
197
- }
198
- ```
199
-
200
- ## reduce
201
-
202
- Reduce a series of values to a single result. The series of values is
203
- reduced by a function that compbines a running total or accumulator with
204
- the next value to produce the new total or accumulator.
205
-
206
- ```javascript
207
- import { reduce } from "aix/reduce";
208
- import { of } from "aix/of";
209
-
210
- const reduced = concat(
211
- (accumulator, next) => accumulator + next, // sum the values together
212
- 0
213
- )(of(1, 2, 3));
214
-
215
- console.log(reduced); // 6
216
- ```
217
-
218
- ## merge
219
-
220
- Merge a number of async iterators into one concurrently. Order is not important.
221
-
222
- ```javascript
223
- import { merge } from "aix/merge";
224
- import { of } from "aix/of";
225
-
226
- const merged = merge(
227
- of(1, 2), of(3, 4)
228
- );
229
-
230
- for await(const item of concatted) {
231
- console.log(item); // outputs 1, 2, 3, 4 in no particular order
232
- }
233
- ```
234
-
235
- ## insert
236
-
237
- Insert values at the beginning of an async iterable.
238
-
239
- ```javascript
240
- import { insert } from "aix/insert";
241
- import { of } from "aix/of";
242
-
243
- const inserted = insert(
244
- 1, 2, 3
245
- )(of(4, 5, 6));
246
-
247
- for await(const item of concatted) {
248
- console.log(item); // outputs 1, 2, 3, 4, 5, 6
249
- }
250
- ```
251
-
252
- ## tap
253
-
254
- 'Taps' an async iterable. Allows you to run a function for
255
- every item in the iterable but doesn't do anything with the
256
- result of the function. Typically used for side effects like
257
- logging.
258
-
259
- ```javascript
260
- import { tap } from "aix/tap";
261
- import { of } from "aix/of";
262
-
263
- const tapped = tap(
264
- value => console.log(value) // prints 1, 2, 3
265
- )(of(1, 2, 3));
266
-
267
- for await(const item of concatted) {
268
- console.log(item); // prints 1, 2, 3
269
- }
270
- ```
271
-
272
- ## zip
273
-
274
- Creates a new iterable out of the two supplied by pairing up equally-positioned items from both iterables. The returned iterable is truncated to the length of the shorter of the two input iterables.
275
-
276
- ```javascript
277
- import { zip } from "aix/zip";
278
- import { of } from "aix/of";
279
-
280
- const zipped = zip(
281
- of(1, 2)
282
- )(of(1, 2));
283
-
284
- for await(const item of concatted) {
285
- console.log(item); // prints [1, 1], [2, 2]
286
- }
287
- ```
288
-
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 {};