@amazon-devices/react-native-safe-area-context 2.0.1759135970 → 8.0.9000000000

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 (258) hide show
  1. package/README.md +6 -302
  2. package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.bundle +7373 -0
  3. package/SystemBundles/3e1c492419a85957481898df760cf9cf3bd38d3e26ef2e78822fb256fdee0153.map +2780 -0
  4. package/SystemModules/amzn__react-native-safe-area-context-8.modules.txt +7 -0
  5. package/SystemModules/amzn__react-native-safe-area-context-8.private.modules.txt +61 -0
  6. package/SystemModules/keplerscript-system-bundle-config.json +3 -3
  7. package/android/build.gradle +103 -25
  8. package/android/gradle.properties +1 -0
  9. package/android/spotless.gradle +24 -0
  10. package/android/src/fabric/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +25 -0
  11. package/android/src/fabric/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +14 -0
  12. package/android/src/main/AndroidManifest.xml +1 -2
  13. package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.kt +3 -0
  14. package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.kt +3 -0
  15. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt +32 -0
  16. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.kt +41 -0
  17. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.kt +47 -0
  18. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.kt +41 -0
  19. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.kt +102 -0
  20. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.kt +155 -0
  21. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.kt +16 -0
  22. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.kt +7 -0
  23. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.kt +73 -0
  24. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.kt +6 -0
  25. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.kt +170 -0
  26. package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.kt +39 -0
  27. package/android/src/main/jni/CMakeLists.txt +87 -0
  28. package/android/src/main/jni/safeareacontext.h +17 -0
  29. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.java +31 -0
  30. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerInterface.java +16 -0
  31. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerDelegate.java +41 -0
  32. package/android/src/paper/java/com/facebook/react/viewmanagers/RNCSafeAreaViewManagerInterface.java +20 -0
  33. package/android/src/paper/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.kt +29 -0
  34. package/android/src/paper/java/com/th3rdwave/safeareacontext/NativeSafeAreaContextSpec.java +56 -0
  35. package/android/src/paper/java/com/th3rdwave/safeareacontext/UIManagerHelperCompat.kt +20 -0
  36. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewComponentDescriptor.h +25 -0
  37. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp +131 -0
  38. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.h +36 -0
  39. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.cpp +23 -0
  40. package/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewState.h +56 -0
  41. package/ios/Fabric/RNCSafeAreaProviderComponentView.h +13 -0
  42. package/ios/Fabric/RNCSafeAreaProviderComponentView.mm +129 -0
  43. package/ios/Fabric/RNCSafeAreaViewComponentView.h +11 -0
  44. package/ios/Fabric/RNCSafeAreaViewComponentView.mm +153 -0
  45. package/ios/RNCSafeAreaContext.h +9 -0
  46. package/ios/RNCSafeAreaContext.mm +85 -0
  47. package/ios/{SafeAreaView/RNCSafeAreaProvider.h → RNCSafeAreaProvider.h} +4 -0
  48. package/ios/RNCSafeAreaProvider.m +102 -0
  49. package/ios/RNCSafeAreaProviderManager.m +20 -0
  50. package/ios/{SafeAreaView/RNCSafeAreaShadowView.m → RNCSafeAreaShadowView.m} +50 -36
  51. package/ios/RNCSafeAreaUtils.h +22 -0
  52. package/ios/RNCSafeAreaUtils.m +41 -0
  53. package/ios/{SafeAreaView/RNCSafeAreaView.h → RNCSafeAreaView.h} +8 -4
  54. package/ios/RNCSafeAreaView.m +168 -0
  55. package/ios/RNCSafeAreaViewEdgeMode.h +12 -0
  56. package/ios/RNCSafeAreaViewEdgeMode.m +16 -0
  57. package/ios/RNCSafeAreaViewEdges.h +15 -0
  58. package/ios/RNCSafeAreaViewEdges.m +36 -0
  59. package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.h → RNCSafeAreaViewLocalData.h} +12 -1
  60. package/ios/{SafeAreaView/RNCSafeAreaViewLocalData.m → RNCSafeAreaViewLocalData.m} +4 -0
  61. package/ios/{SafeAreaView/RNCSafeAreaViewManager.m → RNCSafeAreaViewManager.m} +5 -1
  62. package/ios/RNCSafeAreaViewMode.m +15 -0
  63. package/ios/{SafeAreaView.xcodeproj → RNSafeAreaContext.xcodeproj}/project.pbxproj +70 -56
  64. package/jest/mock.tsx +59 -0
  65. package/kepler-compatibility.json +2 -2
  66. package/lib/commonjs/CompatNativeSafeAreaProvider.js +7 -8
  67. package/lib/commonjs/CompatNativeSafeAreaProvider.js.map +1 -1
  68. package/lib/commonjs/InitialWindow.js.map +1 -1
  69. package/lib/commonjs/InitialWindow.kepler.js +1 -1
  70. package/lib/commonjs/InitialWindow.kepler.js.map +1 -1
  71. package/lib/commonjs/InitialWindow.native.js +4 -4
  72. package/lib/commonjs/InitialWindow.native.js.map +1 -1
  73. package/lib/commonjs/NativeSafeAreaProvider.js +7 -125
  74. package/lib/commonjs/NativeSafeAreaProvider.js.map +1 -1
  75. package/lib/commonjs/NativeSafeAreaProvider.kepler.js +6 -2
  76. package/lib/commonjs/NativeSafeAreaProvider.kepler.js.map +1 -1
  77. package/lib/commonjs/NativeSafeAreaProvider.web.js +135 -0
  78. package/lib/commonjs/NativeSafeAreaProvider.web.js.map +1 -0
  79. package/lib/commonjs/NativeSafeAreaProvider.windows.js +6 -2
  80. package/lib/commonjs/NativeSafeAreaProvider.windows.js.map +1 -1
  81. package/lib/commonjs/SafeArea.types.js.map +1 -1
  82. package/lib/commonjs/SafeAreaContext.js +56 -36
  83. package/lib/commonjs/SafeAreaContext.js.map +1 -1
  84. package/lib/commonjs/SafeAreaView.js +40 -73
  85. package/lib/commonjs/SafeAreaView.js.map +1 -1
  86. package/lib/commonjs/SafeAreaView.kepler.js.map +1 -1
  87. package/lib/commonjs/SafeAreaView.web.js +91 -0
  88. package/lib/commonjs/SafeAreaView.web.js.map +1 -0
  89. package/lib/commonjs/SafeAreaView.windows.js.map +1 -1
  90. package/lib/commonjs/index.js +1 -0
  91. package/lib/commonjs/index.js.map +1 -1
  92. package/lib/commonjs/package.json +1 -0
  93. package/lib/commonjs/specs/NativeSafeAreaContext.js +9 -0
  94. package/lib/commonjs/specs/NativeSafeAreaContext.js.map +1 -0
  95. package/lib/commonjs/specs/NativeSafeAreaProvider.js +10 -0
  96. package/lib/commonjs/specs/NativeSafeAreaProvider.js.map +1 -0
  97. package/lib/commonjs/specs/NativeSafeAreaView.js +12 -0
  98. package/lib/commonjs/specs/NativeSafeAreaView.js.map +1 -0
  99. package/lib/module/CompatNativeSafeAreaProvider.js +8 -5
  100. package/lib/module/CompatNativeSafeAreaProvider.js.map +1 -1
  101. package/lib/module/InitialWindow.js +2 -0
  102. package/lib/module/InitialWindow.js.map +1 -1
  103. package/lib/module/InitialWindow.kepler.js +3 -1
  104. package/lib/module/InitialWindow.kepler.js.map +1 -1
  105. package/lib/module/InitialWindow.native.js +5 -4
  106. package/lib/module/InitialWindow.native.js.map +1 -1
  107. package/lib/module/NativeSafeAreaProvider.js +3 -122
  108. package/lib/module/NativeSafeAreaProvider.js.map +1 -1
  109. package/lib/module/NativeSafeAreaProvider.kepler.js +3 -2
  110. package/lib/module/NativeSafeAreaProvider.kepler.js.map +1 -1
  111. package/lib/module/NativeSafeAreaProvider.web.js +130 -0
  112. package/lib/module/NativeSafeAreaProvider.web.js.map +1 -0
  113. package/lib/module/NativeSafeAreaProvider.windows.js +3 -2
  114. package/lib/module/NativeSafeAreaProvider.windows.js.map +1 -1
  115. package/lib/module/SafeArea.types.js +2 -0
  116. package/lib/module/SafeArea.types.js.map +1 -1
  117. package/lib/module/SafeAreaContext.js +57 -33
  118. package/lib/module/SafeAreaContext.js.map +1 -1
  119. package/lib/module/SafeAreaView.js +38 -69
  120. package/lib/module/SafeAreaView.js.map +1 -1
  121. package/lib/module/SafeAreaView.kepler.js +2 -0
  122. package/lib/module/SafeAreaView.kepler.js.map +1 -1
  123. package/lib/module/SafeAreaView.web.js +86 -0
  124. package/lib/module/SafeAreaView.web.js.map +1 -0
  125. package/lib/module/SafeAreaView.windows.js +2 -0
  126. package/lib/module/SafeAreaView.windows.js.map +1 -1
  127. package/lib/module/index.js +3 -0
  128. package/lib/module/index.js.map +1 -1
  129. package/lib/module/specs/NativeSafeAreaContext.js +5 -0
  130. package/lib/module/specs/NativeSafeAreaContext.js.map +1 -0
  131. package/lib/module/specs/NativeSafeAreaProvider.js +5 -0
  132. package/lib/module/specs/NativeSafeAreaProvider.js.map +1 -0
  133. package/lib/module/specs/NativeSafeAreaView.js +7 -0
  134. package/lib/module/specs/NativeSafeAreaView.js.map +1 -0
  135. package/lib/typescript/CompatNativeSafeAreaProvider.d.ts +4 -0
  136. package/lib/typescript/CompatNativeSafeAreaProvider.d.ts.map +1 -0
  137. package/lib/typescript/{src/InitialWindow.d.ts → InitialWindow.d.ts} +2 -1
  138. package/lib/typescript/InitialWindow.d.ts.map +1 -0
  139. package/lib/typescript/{src/InitialWindow.kepler.d.ts → InitialWindow.kepler.d.ts} +1 -0
  140. package/lib/typescript/InitialWindow.kepler.d.ts.map +1 -0
  141. package/lib/typescript/{src/InitialWindow.native.d.ts → InitialWindow.native.d.ts} +2 -1
  142. package/lib/typescript/InitialWindow.native.d.ts.map +1 -0
  143. package/lib/typescript/NativeSafeAreaProvider.d.ts +3 -0
  144. package/lib/typescript/NativeSafeAreaProvider.d.ts.map +1 -0
  145. package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts +2 -0
  146. package/lib/typescript/NativeSafeAreaProvider.kepler.d.ts.map +1 -0
  147. package/lib/typescript/NativeSafeAreaProvider.web.d.ts +4 -0
  148. package/lib/typescript/NativeSafeAreaProvider.web.d.ts.map +1 -0
  149. package/lib/typescript/NativeSafeAreaProvider.windows.d.ts +2 -0
  150. package/lib/typescript/NativeSafeAreaProvider.windows.d.ts.map +1 -0
  151. package/lib/typescript/SafeArea.types.d.ts +36 -0
  152. package/lib/typescript/SafeArea.types.d.ts.map +1 -0
  153. package/lib/typescript/{src/SafeAreaContext.d.ts → SafeAreaContext.d.ts} +9 -6
  154. package/lib/typescript/SafeAreaContext.d.ts.map +1 -0
  155. package/lib/typescript/SafeAreaView.d.ts +5 -0
  156. package/lib/typescript/SafeAreaView.d.ts.map +1 -0
  157. package/lib/typescript/{src/SafeAreaView.kepler.d.ts → SafeAreaView.kepler.d.ts} +1 -0
  158. package/lib/typescript/SafeAreaView.kepler.d.ts.map +1 -0
  159. package/lib/typescript/SafeAreaView.web.d.ts +4 -0
  160. package/lib/typescript/SafeAreaView.web.d.ts.map +1 -0
  161. package/lib/typescript/SafeAreaView.windows.d.ts +3 -0
  162. package/lib/typescript/SafeAreaView.windows.d.ts.map +1 -0
  163. package/lib/typescript/{src/index.d.ts → index.d.ts} +1 -0
  164. package/lib/typescript/index.d.ts.map +1 -0
  165. package/lib/typescript/specs/NativeSafeAreaContext.d.ts +23 -0
  166. package/lib/typescript/specs/NativeSafeAreaContext.d.ts.map +1 -0
  167. package/lib/typescript/specs/NativeSafeAreaProvider.d.ts +22 -0
  168. package/lib/typescript/specs/NativeSafeAreaProvider.d.ts.map +1 -0
  169. package/lib/typescript/specs/NativeSafeAreaView.d.ts +14 -0
  170. package/lib/typescript/specs/NativeSafeAreaView.d.ts.map +1 -0
  171. package/package.json +1 -1
  172. package/react-native-safe-area-context.podspec +26 -4
  173. package/react-native.config.js +8 -0
  174. package/src/CompatNativeSafeAreaProvider.tsx +2 -3
  175. package/src/InitialWindow.kepler.ts +1 -1
  176. package/src/InitialWindow.native.ts +5 -11
  177. package/src/InitialWindow.ts +1 -1
  178. package/src/NativeSafeAreaProvider.kepler.tsx +1 -3
  179. package/src/NativeSafeAreaProvider.tsx +2 -128
  180. package/src/NativeSafeAreaProvider.web.tsx +127 -0
  181. package/src/NativeSafeAreaProvider.windows.tsx +1 -3
  182. package/src/SafeArea.types.ts +15 -11
  183. package/src/SafeAreaContext.tsx +66 -43
  184. package/src/SafeAreaView.tsx +47 -82
  185. package/src/SafeAreaView.web.tsx +123 -0
  186. package/src/SafeAreaView.windows.tsx +2 -1
  187. package/src/index.tsx +2 -0
  188. package/src/specs/NativeSafeAreaContext.ts +23 -0
  189. package/src/specs/NativeSafeAreaProvider.ts +29 -0
  190. package/src/specs/NativeSafeAreaView.ts +17 -0
  191. package/SystemBundles/e3c0cdeab56b8b622d4f0fd5a80812eafe199fa2287d0e3a09c5e573a1035350.bundle +0 -11031
  192. package/SystemBundles/e3c0cdeab56b8b622d4f0fd5a80812eafe199fa2287d0e3a09c5e573a1035350.map +0 -1
  193. package/SystemModules/amzn__react-native-safe-area-context-2.modules.txt +0 -55
  194. package/SystemModules/amzn__react-native-safe-area-context-2.private.modules.txt +0 -91
  195. package/THIRD_PARTY_NOTICES.txt +0 -24
  196. package/android/src/main/java/com/th3rdwave/safeareacontext/EdgeInsets.java +0 -22
  197. package/android/src/main/java/com/th3rdwave/safeareacontext/InsetsChangeEvent.java +0 -33
  198. package/android/src/main/java/com/th3rdwave/safeareacontext/Rect.java +0 -22
  199. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextPackage.java +0 -31
  200. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProvider.java +0 -66
  201. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaProviderManager.java +0 -94
  202. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.java +0 -82
  203. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaView.java +0 -159
  204. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewEdges.java +0 -8
  205. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewLocalData.java +0 -27
  206. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewManager.java +0 -72
  207. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewMode.java +0 -6
  208. package/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaViewShadowNode.java +0 -201
  209. package/android/src/main/java/com/th3rdwave/safeareacontext/SerializationUtils.java +0 -52
  210. package/ios/SafeAreaView/RCTView+SafeAreaCompat.h +0 -16
  211. package/ios/SafeAreaView/RCTView+SafeAreaCompat.m +0 -57
  212. package/ios/SafeAreaView/RNCSafeAreaProvider.m +0 -65
  213. package/ios/SafeAreaView/RNCSafeAreaProviderManager.m +0 -61
  214. package/ios/SafeAreaView/RNCSafeAreaView.m +0 -118
  215. package/ios/SafeAreaView/RNCSafeAreaViewEdges.h +0 -9
  216. package/ios/SafeAreaView/RNCSafeAreaViewEdges.m +0 -13
  217. package/ios/SafeAreaView/RNCSafeAreaViewMode.m +0 -11
  218. package/lib/commonjs/NativeSafeAreaProvider.macos.js +0 -9
  219. package/lib/commonjs/NativeSafeAreaProvider.macos.js.map +0 -1
  220. package/lib/commonjs/NativeSafeAreaProvider.native.js +0 -9
  221. package/lib/commonjs/NativeSafeAreaProvider.native.js.map +0 -1
  222. package/lib/commonjs/SafeAreaView.macos.js +0 -9
  223. package/lib/commonjs/SafeAreaView.macos.js.map +0 -1
  224. package/lib/commonjs/SafeAreaView.native.js +0 -9
  225. package/lib/commonjs/SafeAreaView.native.js.map +0 -1
  226. package/lib/commonjs/useWindowDimensions.js +0 -32
  227. package/lib/commonjs/useWindowDimensions.js.map +0 -1
  228. package/lib/module/NativeSafeAreaProvider.macos.js +0 -3
  229. package/lib/module/NativeSafeAreaProvider.macos.js.map +0 -1
  230. package/lib/module/NativeSafeAreaProvider.native.js +0 -3
  231. package/lib/module/NativeSafeAreaProvider.native.js.map +0 -1
  232. package/lib/module/SafeAreaView.macos.js +0 -3
  233. package/lib/module/SafeAreaView.macos.js.map +0 -1
  234. package/lib/module/SafeAreaView.native.js +0 -3
  235. package/lib/module/SafeAreaView.native.js.map +0 -1
  236. package/lib/module/useWindowDimensions.js +0 -26
  237. package/lib/module/useWindowDimensions.js.map +0 -1
  238. package/lib/typescript/src/CompatNativeSafeAreaProvider.d.ts +0 -2
  239. package/lib/typescript/src/NativeSafeAreaProvider.d.ts +0 -2
  240. package/lib/typescript/src/NativeSafeAreaProvider.kepler.d.ts +0 -2
  241. package/lib/typescript/src/NativeSafeAreaProvider.macos.d.ts +0 -2
  242. package/lib/typescript/src/NativeSafeAreaProvider.native.d.ts +0 -3
  243. package/lib/typescript/src/NativeSafeAreaProvider.windows.d.ts +0 -2
  244. package/lib/typescript/src/SafeArea.types.d.ts +0 -31
  245. package/lib/typescript/src/SafeAreaView.d.ts +0 -2
  246. package/lib/typescript/src/SafeAreaView.macos.d.ts +0 -2
  247. package/lib/typescript/src/SafeAreaView.native.d.ts +0 -2
  248. package/lib/typescript/src/SafeAreaView.windows.d.ts +0 -2
  249. package/lib/typescript/src/useWindowDimensions.d.ts +0 -8
  250. package/src/NativeSafeAreaProvider.macos.tsx +0 -3
  251. package/src/NativeSafeAreaProvider.native.tsx +0 -6
  252. package/src/SafeAreaView.macos.tsx +0 -3
  253. package/src/SafeAreaView.native.tsx +0 -6
  254. package/src/useWindowDimensions.tsx +0 -35
  255. /package/ios/{SafeAreaView/RNCSafeAreaProviderManager.h → RNCSafeAreaProviderManager.h} +0 -0
  256. /package/ios/{SafeAreaView/RNCSafeAreaShadowView.h → RNCSafeAreaShadowView.h} +0 -0
  257. /package/ios/{SafeAreaView/RNCSafeAreaViewManager.h → RNCSafeAreaViewManager.h} +0 -0
  258. /package/ios/{SafeAreaView/RNCSafeAreaViewMode.h → RNCSafeAreaViewMode.h} +0 -0
@@ -1,21 +1,23 @@
1
1
  import * as React from 'react';
2
- import { StyleProp, ViewStyle } from 'react-native';
3
- import { EdgeInsets, Metrics, Rect } from './SafeArea.types';
2
+ import { type ViewProps } from 'react-native';
3
+ import type { EdgeInsets, Metrics, Rect } from './SafeArea.types';
4
4
  export declare const SafeAreaInsetsContext: React.Context<EdgeInsets | null>;
5
5
  export declare const SafeAreaFrameContext: React.Context<Rect | null>;
6
- export interface SafeAreaViewProps {
6
+ export interface SafeAreaProviderProps extends ViewProps {
7
7
  children?: React.ReactNode;
8
8
  initialMetrics?: Metrics | null;
9
9
  /**
10
10
  * @deprecated
11
11
  */
12
12
  initialSafeAreaInsets?: EdgeInsets | null;
13
- style?: StyleProp<ViewStyle>;
14
13
  }
15
- export declare function SafeAreaProvider({ children, initialMetrics, initialSafeAreaInsets, style, }: SafeAreaViewProps): JSX.Element;
14
+ export declare function SafeAreaProvider({ children, initialMetrics, initialSafeAreaInsets, style, ...others }: SafeAreaProviderProps): React.JSX.Element;
16
15
  export declare function useSafeAreaInsets(): EdgeInsets;
17
16
  export declare function useSafeAreaFrame(): Rect;
18
- export declare function withSafeAreaInsets<T>(WrappedComponent: React.ComponentType<T>): React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<T>>;
17
+ export type WithSafeAreaInsetsProps = {
18
+ insets: EdgeInsets;
19
+ };
20
+ export declare function withSafeAreaInsets<T>(WrappedComponent: React.ComponentType<(React.PropsWithoutRef<T> | T) & WithSafeAreaInsetsProps>): React.ForwardRefExoticComponent<React.PropsWithoutRef<T> & React.RefAttributes<unknown>>;
19
21
  /**
20
22
  * @deprecated
21
23
  */
@@ -28,3 +30,4 @@ export declare const SafeAreaConsumer: React.Consumer<EdgeInsets | null>;
28
30
  * @deprecated
29
31
  */
30
32
  export declare const SafeAreaContext: React.Context<EdgeInsets | null>;
33
+ //# sourceMappingURL=SafeAreaContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAreaContext.d.ts","sourceRoot":"","sources":["../../src/SafeAreaContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EACV,UAAU,EAEV,OAAO,EACP,IAAI,EACL,MAAM,kBAAkB,CAAC;AAI1B,eAAO,MAAM,qBAAqB,kCAEjC,CAAC;AAKF,eAAO,MAAM,oBAAoB,4BAAyC,CAAC;AAK3E,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC;;OAEG;IACH,qBAAqB,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,KAAK,EACL,GAAG,MAAM,EACV,EAAE,qBAAqB,qBAkEvB;AAiBD,wBAAgB,iBAAiB,IAAI,UAAU,CAM9C;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,gBAAgB,EAAE,KAAK,CAAC,aAAa,CACnC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,uBAAuB,CACzD,GACA,KAAK,CAAC,yBAAyB,CAChC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CACxD,CAKA;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAExC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,mCAAiC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,eAAe,kCAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { NativeSafeAreaViewProps } from './SafeArea.types';
3
+ export type SafeAreaViewProps = NativeSafeAreaViewProps;
4
+ export declare const SafeAreaView: React.ForwardRefExoticComponent<NativeSafeAreaViewProps & React.RefAttributes<React.Component<import("./specs/NativeSafeAreaView").NativeProps, {}, any> & import("react-native").NativeMethods>>;
5
+ //# sourceMappingURL=SafeAreaView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAreaView.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAKV,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAW1B,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAExD,eAAO,MAAM,YAAY,mMA6BvB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  import { View } from 'react-native';
2
2
  export declare const SafeAreaView: typeof View;
3
+ //# sourceMappingURL=SafeAreaView.kepler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAreaView.kepler.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.kepler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,eAAO,MAAM,YAAY,aAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { NativeSafeAreaViewProps } from './SafeArea.types';
3
+ export declare const SafeAreaView: React.ForwardRefExoticComponent<NativeSafeAreaViewProps & React.RefAttributes<React.Component<import("./specs/NativeSafeAreaView").NativeProps, {}, any> & import("react-native").NativeMethods>>;
4
+ //# sourceMappingURL=SafeAreaView.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAreaView.web.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AA0B1B,eAAO,MAAM,YAAY,mMAwFvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { NativeSafeAreaViewInstance } from './SafeArea.types';
2
+ export declare const SafeAreaView: NativeSafeAreaViewInstance;
3
+ //# sourceMappingURL=SafeAreaView.windows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeAreaView.windows.d.ts","sourceRoot":"","sources":["../../src/SafeAreaView.windows.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEnE,eAAO,MAAM,YAAY,EAAsB,0BAA0B,CAAC"}
@@ -2,3 +2,4 @@ export * from './SafeAreaContext';
2
2
  export * from './SafeAreaView';
3
3
  export * from './InitialWindow';
4
4
  export * from './SafeArea.types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAEA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { TurboModule } from 'react-native';
2
+ import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
3
+ export interface Spec extends TurboModule {
4
+ getConstants: () => {
5
+ initialWindowMetrics?: {
6
+ insets: {
7
+ top: Double;
8
+ right: Double;
9
+ bottom: Double;
10
+ left: Double;
11
+ };
12
+ frame: {
13
+ x: Double;
14
+ y: Double;
15
+ width: Double;
16
+ height: Double;
17
+ };
18
+ };
19
+ };
20
+ }
21
+ declare const _default: Spec | null;
22
+ export default _default;
23
+ //# sourceMappingURL=NativeSafeAreaContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeSafeAreaContext.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAExE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,YAAY,EAAE,MAAM;QAClB,oBAAoB,CAAC,EAAE;YACrB,MAAM,EAAE;gBACN,GAAG,EAAE,MAAM,CAAC;gBACZ,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;gBACf,IAAI,EAAE,MAAM,CAAC;aACd,CAAC;YACF,KAAK,EAAE;gBACL,CAAC,EAAE,MAAM,CAAC;gBACV,CAAC,EAAE,MAAM,CAAC;gBACV,KAAK,EAAE,MAAM,CAAC;gBACd,MAAM,EAAE,MAAM,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;CACH;;AAED,wBAAmE"}
@@ -0,0 +1,22 @@
1
+ import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';
2
+ import type { ViewProps, HostComponent } from 'react-native';
3
+ export type Event = Readonly<{
4
+ insets: Readonly<{
5
+ top: Double;
6
+ right: Double;
7
+ bottom: Double;
8
+ left: Double;
9
+ }>;
10
+ frame: Readonly<{
11
+ x: Double;
12
+ y: Double;
13
+ width: Double;
14
+ height: Double;
15
+ }>;
16
+ }>;
17
+ export interface NativeProps extends ViewProps {
18
+ onInsetsChange?: DirectEventHandler<Event>;
19
+ }
20
+ declare const _default: HostComponent<NativeProps>;
21
+ export default _default;
22
+ //# sourceMappingURL=NativeSafeAreaProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeSafeAreaProvider.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACP,MAAM,2CAA2C,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,KAAK,EAAE,QAAQ,CAAC;QACd,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,cAAc,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;CAC5C;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
@@ -0,0 +1,14 @@
1
+ import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
2
+ import type { ViewProps, HostComponent } from 'react-native';
3
+ export interface NativeProps extends ViewProps {
4
+ mode?: WithDefault<'padding' | 'margin', 'padding'>;
5
+ edges?: Readonly<{
6
+ top: string;
7
+ right: string;
8
+ bottom: string;
9
+ left: string;
10
+ }>;
11
+ }
12
+ declare const _default: HostComponent<NativeProps>;
13
+ export default _default;
14
+ //# sourceMappingURL=NativeSafeAreaView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeSafeAreaView.d.ts","sourceRoot":"","sources":["../../../src/specs/NativeSafeAreaView.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC,SAAS,GAAG,QAAQ,EAAE,SAAS,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,QAAQ,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;wBAIK,aAAa,CAAC,WAAW,CAAC;AAFhC,wBAEiC"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@amazon-devices/react-native-safe-area-context", "version": "2.0.1759135970+3.2.0", "description": "A flexible way to handle safe area, also works on Android and web.", "main": "lib/commonjs/index.js", "module": "lib/module/index.js", "react-native": "src/index.tsx", "types": "lib/typescript/src/index.d.ts", "sideEffects": false, "files": ["src", "lib", "android", "ios", "*.podspec", "react-native.config.js", "!**/__tests__", "kepler-compatibility.json", "!example", "SystemModules", "SystemBundles", "THIRD_PARTY_NOTICES.txt", "kepler-transformed-package-info.json"], "author": "Janic Duplessis <janicduplessis@gmail.com>", "contributors": ["Evan Bacon <bacon@expo.io> (https://github.com/evanbacon)"], "homepage": "https://github.com/th3rdwave/react-native-safe-area-context#readme", "license": "See license in LICENSE", "scripts": {"start": "react-native start", "test": "yarn validate:prettier && yarn validate:eslint && yarn validate:typescript && yarn validate:jest", "validate:eslint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"", "validate:typescript": "tsc --project ./ --noEmit", "validate:prettier": "prettier \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\" --check", "validate:jest": "jest", "example:ios": "cd ./example && react-native run-ios", "example:android": "cd ./example && react-native run-android --no-jetifier", "example:expo": "expo start --config example/app.json"}, "keywords": ["react-native", "react native", "react-native-web", "expo-web", "safe area", "view"], "kepler": {"temporary-alias-for-package": {"name": "react-native-safe-area-context", "version": "3.2.0"}}, "peerDependencies": {"react": "*", "react-native": "*"}, "dependencies": {}, "devDependencies": {"@react-native-community/async-storage": "1.11.0", "@react-native-community/bob": "0.14.5", "@react-native-community/eslint-config": "2.0.0", "@react-native-community/masked-view": "0.1.10", "@react-navigation/bottom-tabs": "5.5.2", "@react-navigation/native": "5.5.1", "@react-navigation/stack": "5.5.1", "@types/jest": "^27.0.3", "@types/react": "17.0.2", "@types/react-dom": "~17.0.2", "@types/react-test-renderer": "^16.9.2", "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", "babel-plugin-module-resolver": "4.0.0", "eslint": "7.2.0", "eslint-config-prettier": "6.11.0", "eslint-plugin-prettier": "3.1.3", "jest": "26.0.1", "metro-react-native-babel-preset": "0.59.0", "prettier": "2.0.5", "react": "17.0.2", "react-dom": "17.0.2", "react-native": "0.72.0", "react-native-gesture-handler": "~2.13.0", "@amazon-devices/keplerscript-react-native-reanimated": "^2.0.0+2.1.0", "react-native-safe-area-view": "1.1.1", "react-native-screens": "~3.20.0", "react-native-web": "0.12.3", "react-navigation": "4.3.9", "react-navigation-stack": "2.7.0", "react-navigation-tabs": "2.8.13", "react-test-renderer": "16.13.1", "typescript": "^4.9.4"}, "repository": {"type": "git", "url": "https://github.com/th3rdwave/react-native-safe-area-context.git"}, "jest": {"preset": "react-native", "testEnvironment": "node", "clearMocks": true, "modulePathIgnorePatterns": ["<rootDir>/lib/"]}, "@react-native-community/bob": {"source": "src", "output": "lib", "targets": ["commonjs", "module", "typescript"]}}
1
+ {"name": "@amazon-devices/react-native-safe-area-context", "version": "8.0.9000000000+5.2.0", "description": "A flexible way to handle safe area, also works on Android and web.", "main": "lib/commonjs/index.js", "module": "lib/module/index.js", "react-native": "src/index.tsx", "types": "lib/typescript/index.d.ts", "source": "src/index.tsx", "sideEffects": false, "files": ["src", "lib", "android", "ios", "common", "jest", "*.podspec", "react-native.config.js", "!**/__tests__", "!example", "kepler-compatibility.json", "SystemModules", "SystemBundles", "kepler-transformed-package-info.json"], "author": "Janic Duplessis <janicduplessis@gmail.com>", "contributors": ["Evan Bacon <bacon@expo.io> (https://github.com/evanbacon)"], "homepage": "https://github.com/th3rdwave/react-native-safe-area-context#readme", "license": "See license in LICENSE", "scripts": {"start": "react-native start", "test": "yarn format:check && yarn validate:eslint && yarn validate:typescript && yarn validate:jest", "validate:eslint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"", "validate:typescript": "tsc --project ./ --noEmit", "validate:jest": "jest", "format:prettier:check": "prettier \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\" --check", "format:prettier:write": "yarn format:prettier:check --write", "format:clang:check": "clang-format --dry-run --Werror --glob='{ios,android/src,common}/**/*.{h,cpp,m,mm}'", "format:clang:write": "clang-format -i --glob='{ios,android/src,common}/**/*.{h,hpp,cpp,m,mm}'", "format:spotless:check": "cd android && ./gradlew spotlessCheck", "format:spotless:write": "cd android && ./gradlew spotlessApply", "format:check": "yarn format:prettier:check && yarn format:clang:check && yarn format:spotless:check", "format:write": "yarn format:prettier:write && yarn format:clang:write && yarn format:spotless:write"}, "keywords": ["react-native", "react native", "react-native-web", "expo-web", "safe area", "view"], "kepler": {"temporary-alias-for-package": {"name": "react-native-safe-area-context", "version": "5.2.0"}}, "peerDependencies": {"react": "*", "react-native": "*"}, "devDependencies": {"@commitlint/config-conventional": "^19.2.2", "@jest/globals": "^30.0.0", "@react-native/babel-preset": "^0.74.84", "@react-native/eslint-config": "^0.74.84", "@react-native/eslint-plugin-specs": "^0.74.84", "@release-it/conventional-changelog": "^8.0.1", "@types/react": "~19.0.10", "@types/react-dom": "~19.1.3", "@types/react-test-renderer": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.14.1", "@typescript-eslint/parser": "^7.14.1", "babel-plugin-module-resolver": "^5.0.2", "clang-format": "^1.8.0", "commitlint": "19.6.1", "eslint": "^8.57.0", "eslint-plugin-jest": "^28.6.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.11", "jest": "^29.7.0", "prettier": "^3.3.2", "react": "19.0.0", "react-dom": "19.0.0", "react-native": "0.79.3", "react-native-builder-bob": "^0.40.12", "react-test-renderer": "19.0.0", "release-it": "^17.4.0", "typescript": "^5.8.3"}, "repository": {"type": "git", "url": "https://github.com/th3rdwave/react-native-safe-area-context.git"}, "jest": {"preset": "react-native", "testEnvironment": "node", "clearMocks": true, "modulePathIgnorePatterns": ["<rootDir>/lib/"]}, "commitlint": {"extends": ["@commitlint/config-conventional"]}, "react-native-builder-bob": {"source": "src", "output": "lib", "targets": ["commonjs", "module", "typescript"]}, "codegenConfig": {"android": {"javaPackageName": "com.th3rdwave.safeareacontext"}, "ios": {"componentProvider": {"RNCSafeAreaProvider": "RNCSafeAreaProviderComponentView", "RNCSafeAreaView": "RNCSafeAreaViewComponentView"}}, "name": "safeareacontext", "type": "all", "jsSrcsDir": "./src/specs"}}
@@ -1,19 +1,41 @@
1
1
  require 'json'
2
2
 
3
+ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
4
+
3
5
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
6
 
5
7
  Pod::Spec.new do |s|
6
- s.name = "@amazon-devices/react-native-safe-area-context"
8
+ s.name = "react-native-safe-area-context"
7
9
  s.version = package['version']
8
10
  s.summary = package['description']
9
11
  s.license = package['license']
10
12
 
11
13
  s.authors = package['author']
12
14
  s.homepage = package['homepage']
13
- s.platforms = { :ios => "9.0", :tvos => "9.2" }
15
+ s.ios.deployment_target = "12.4"
16
+ s.osx.deployment_target = "10.15"
17
+ s.tvos.deployment_target = "12.4"
18
+ s.visionos.deployment_target = "1.0"
14
19
 
15
20
  s.source = { :git => "https://github.com/th3rdwave/react-native-safe-area-context.git", :tag => "v#{s.version}" }
16
- s.source_files = "ios/**/*.{h,m}"
21
+ s.source_files = "ios/**/*.{h,m,mm}"
22
+ s.exclude_files = "ios/Fabric"
23
+
24
+ s.dependency "React-Core"
25
+
26
+ if fabric_enabled
27
+ install_modules_dependencies(s)
28
+
29
+ s.subspec "common" do |ss|
30
+ ss.source_files = "common/cpp/**/*.{cpp,h}"
31
+ ss.header_dir = "react/renderer/components/safeareacontext"
32
+ ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
33
+ end
17
34
 
18
- s.dependency 'React-Core'
35
+ s.subspec "fabric" do |ss|
36
+ ss.dependency "react-native-safe-area-context/common"
37
+ ss.source_files = "ios/Fabric/**/*.{h,m,mm}"
38
+ ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\"" }
39
+ end
40
+ end
19
41
  end
@@ -1,6 +1,14 @@
1
1
  module.exports = {
2
2
  dependency: {
3
3
  platforms: {
4
+ android: {
5
+ libraryName: 'safeareacontext',
6
+ componentDescriptors: [
7
+ 'RNCSafeAreaProviderComponentDescriptor',
8
+ 'RNCSafeAreaViewComponentDescriptor',
9
+ ],
10
+ cmakeListsPath: 'src/main/jni/CMakeLists.txt',
11
+ },
4
12
  macos: null,
5
13
  windows: null,
6
14
  },
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
- import { View } from 'react-native';
3
- import { NativeSafeAreaProviderProps } from './SafeArea.types';
4
- import useWindowDimensions from './useWindowDimensions';
2
+ import { useWindowDimensions, View } from 'react-native';
3
+ import type { NativeSafeAreaProviderProps } from './SafeArea.types';
5
4
 
6
5
  export function CompatNativeSafeAreaProvider({
7
6
  children,
@@ -7,4 +7,4 @@ export const initialWindowMetrics = null as Metrics | null;
7
7
  /**
8
8
  * @deprecated
9
9
  */
10
- export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
10
+ export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
@@ -1,16 +1,10 @@
1
- import { UIManager } from 'react-native';
2
- import { Metrics } from './SafeArea.types';
1
+ import type { Metrics } from './SafeArea.types';
2
+ import NativeSafeAreaContext from './specs/NativeSafeAreaContext';
3
3
 
4
- const RNCSafeAreaProviderConfig = UIManager.getViewManagerConfig(
5
- 'RNCSafeAreaProvider',
6
- ) as any;
7
-
8
- export const initialWindowMetrics = (RNCSafeAreaProviderConfig != null &&
9
- RNCSafeAreaProviderConfig.Constants != null
10
- ? RNCSafeAreaProviderConfig.Constants.initialWindowMetrics
11
- : null) as Metrics | null;
4
+ export const initialWindowMetrics = (NativeSafeAreaContext?.getConstants?.()
5
+ ?.initialWindowMetrics ?? null) as Metrics | null;
12
6
 
13
7
  /**
14
8
  * @deprecated
15
9
  */
16
- export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
10
+ export const initialWindowSafeAreaInsets = initialWindowMetrics?.insets;
@@ -1,4 +1,4 @@
1
- import { EdgeInsets, Metrics } from './SafeArea.types';
1
+ import type { EdgeInsets, Metrics } from './SafeArea.types';
2
2
 
3
3
  export const initialWindowMetrics: Metrics | null = null;
4
4
 
@@ -1,3 +1 @@
1
- import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
2
-
3
- export default CompatNativeSafeAreaProvider;
1
+ export { CompatNativeSafeAreaProvider as NativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
@@ -1,129 +1,3 @@
1
- import * as React from 'react';
2
- import { View } from 'react-native';
3
- import { NativeSafeAreaProviderProps } from './SafeArea.types';
1
+ import NativeSafeAreaProvider from './specs/NativeSafeAreaProvider';
4
2
 
5
- /**
6
- * TODO:
7
- * Currently insets and frame are based on the window and are not
8
- * relative to the provider view. This is inconsistent with iOS and Android.
9
- * However in most cases if the provider view covers the screen this is not
10
- * an issue.
11
- */
12
-
13
- const CSSTransitions: Record<string, string> = {
14
- WebkitTransition: 'webkitTransitionEnd',
15
- Transition: 'transitionEnd',
16
- MozTransition: 'transitionend',
17
- MSTransition: 'msTransitionEnd',
18
- OTransition: 'oTransitionEnd',
19
- };
20
-
21
- export default function NativeSafeAreaView({
22
- children,
23
- style,
24
- onInsetsChange,
25
- }: NativeSafeAreaProviderProps) {
26
- React.useEffect(() => {
27
- // Skip for SSR.
28
- if (typeof document === 'undefined') {
29
- return;
30
- }
31
-
32
- const element = createContextElement();
33
- document.body.appendChild(element);
34
- const onEnd = () => {
35
- const {
36
- paddingTop,
37
- paddingBottom,
38
- paddingLeft,
39
- paddingRight,
40
- } = window.getComputedStyle(element);
41
-
42
- const insets = {
43
- top: paddingTop ? parseInt(paddingTop, 10) : 0,
44
- bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
45
- left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
46
- right: paddingRight ? parseInt(paddingRight, 10) : 0,
47
- };
48
- const frame = {
49
- x: 0,
50
- y: 0,
51
- width: document.documentElement.offsetWidth,
52
- height: document.documentElement.offsetHeight,
53
- };
54
- // @ts-ignore: missing properties
55
- onInsetsChange({ nativeEvent: { insets, frame } });
56
- };
57
- element.addEventListener(getSupportedTransitionEvent(), onEnd);
58
- onEnd();
59
- return () => {
60
- document.body.removeChild(element);
61
- element.removeEventListener(getSupportedTransitionEvent(), onEnd);
62
- };
63
- }, [onInsetsChange]);
64
-
65
- return <View style={style}>{children}</View>;
66
- }
67
-
68
- let _supportedTransitionEvent: string | null = null;
69
- function getSupportedTransitionEvent(): string {
70
- if (_supportedTransitionEvent !== null) {
71
- return _supportedTransitionEvent;
72
- }
73
- const element = document.createElement('invalidtype');
74
-
75
- _supportedTransitionEvent = CSSTransitions.Transition;
76
- for (const key in CSSTransitions) {
77
- if (element.style[key as keyof CSSStyleDeclaration] !== undefined) {
78
- _supportedTransitionEvent = CSSTransitions[key];
79
- break;
80
- }
81
- }
82
- return _supportedTransitionEvent;
83
- }
84
-
85
- type CssEnv = 'constant' | 'env';
86
-
87
- let _supportedEnv: CssEnv | null = null;
88
- function getSupportedEnv(): CssEnv {
89
- if (_supportedEnv !== null) {
90
- return _supportedEnv;
91
- }
92
- const { CSS } = window;
93
- if (
94
- CSS &&
95
- CSS.supports &&
96
- CSS.supports('top: constant(safe-area-inset-top)')
97
- ) {
98
- _supportedEnv = 'constant';
99
- } else {
100
- _supportedEnv = 'env';
101
- }
102
- return _supportedEnv;
103
- }
104
-
105
- function getInset(side: string): string {
106
- return `${getSupportedEnv()}(safe-area-inset-${side})`;
107
- }
108
-
109
- function createContextElement(): HTMLElement {
110
- const element = document.createElement('div');
111
- const { style } = element;
112
- style.position = 'fixed';
113
- style.left = '0';
114
- style.top = '0';
115
- style.width = '0';
116
- style.height = '0';
117
- style.zIndex = '-1';
118
- style.overflow = 'hidden';
119
- style.visibility = 'hidden';
120
- // Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
121
- style.transitionDuration = '0.05s';
122
- style.transitionProperty = 'padding';
123
- style.transitionDelay = '0s';
124
- style.paddingTop = getInset('top');
125
- style.paddingBottom = getInset('bottom');
126
- style.paddingLeft = getInset('left');
127
- style.paddingRight = getInset('right');
128
- return element;
129
- }
3
+ export { NativeSafeAreaProvider };
@@ -0,0 +1,127 @@
1
+ /* eslint-env browser */
2
+
3
+ import * as React from 'react';
4
+ import { View } from 'react-native';
5
+ import type { NativeSafeAreaProviderProps } from './SafeArea.types';
6
+
7
+ /**
8
+ * TODO:
9
+ * Currently insets and frame are based on the window and are not
10
+ * relative to the provider view. This is inconsistent with iOS and Android.
11
+ * However in most cases if the provider view covers the screen this is not
12
+ * an issue.
13
+ */
14
+
15
+ const CSSTransitions: Record<string, string> = {
16
+ WebkitTransition: 'webkitTransitionEnd',
17
+ Transition: 'transitionEnd',
18
+ MozTransition: 'transitionend',
19
+ MSTransition: 'msTransitionEnd',
20
+ OTransition: 'oTransitionEnd',
21
+ };
22
+
23
+ export function NativeSafeAreaProvider({
24
+ children,
25
+ style,
26
+ onInsetsChange,
27
+ }: NativeSafeAreaProviderProps) {
28
+ React.useEffect(() => {
29
+ // Skip for SSR.
30
+ if (typeof document === 'undefined') {
31
+ return;
32
+ }
33
+
34
+ const element = createContextElement();
35
+ document.body.appendChild(element);
36
+ const onEnd = () => {
37
+ const { paddingTop, paddingBottom, paddingLeft, paddingRight } =
38
+ window.getComputedStyle(element);
39
+
40
+ const insets = {
41
+ top: paddingTop ? parseInt(paddingTop, 10) : 0,
42
+ bottom: paddingBottom ? parseInt(paddingBottom, 10) : 0,
43
+ left: paddingLeft ? parseInt(paddingLeft, 10) : 0,
44
+ right: paddingRight ? parseInt(paddingRight, 10) : 0,
45
+ };
46
+ const frame = {
47
+ x: 0,
48
+ y: 0,
49
+ width: document.documentElement.offsetWidth,
50
+ height: document.documentElement.offsetHeight,
51
+ };
52
+ // @ts-ignore: missing properties
53
+ onInsetsChange({ nativeEvent: { insets, frame } });
54
+ };
55
+ element.addEventListener(getSupportedTransitionEvent(), onEnd);
56
+ onEnd();
57
+ return () => {
58
+ document.body.removeChild(element);
59
+ element.removeEventListener(getSupportedTransitionEvent(), onEnd);
60
+ };
61
+ }, [onInsetsChange]);
62
+
63
+ return <View style={style}>{children}</View>;
64
+ }
65
+
66
+ let _supportedTransitionEvent: string | null | undefined = null;
67
+ function getSupportedTransitionEvent(): string {
68
+ if (_supportedTransitionEvent != null) {
69
+ return _supportedTransitionEvent;
70
+ }
71
+ const element = document.createElement('invalidtype');
72
+
73
+ _supportedTransitionEvent = CSSTransitions.Transition;
74
+ for (const key in CSSTransitions) {
75
+ if (element.style[key as keyof CSSStyleDeclaration] !== undefined) {
76
+ _supportedTransitionEvent = CSSTransitions[key];
77
+ break;
78
+ }
79
+ }
80
+ return _supportedTransitionEvent as string;
81
+ }
82
+
83
+ type CssEnv = 'constant' | 'env';
84
+
85
+ let _supportedEnv: CssEnv | null = null;
86
+ function getSupportedEnv(): CssEnv {
87
+ if (_supportedEnv !== null) {
88
+ return _supportedEnv;
89
+ }
90
+ const { CSS } = window;
91
+ if (
92
+ CSS &&
93
+ CSS.supports &&
94
+ CSS.supports('top: constant(safe-area-inset-top)')
95
+ ) {
96
+ _supportedEnv = 'constant';
97
+ } else {
98
+ _supportedEnv = 'env';
99
+ }
100
+ return _supportedEnv;
101
+ }
102
+
103
+ function getInset(side: string): string {
104
+ return `${getSupportedEnv()}(safe-area-inset-${side})`;
105
+ }
106
+
107
+ function createContextElement(): HTMLElement {
108
+ const element = document.createElement('div');
109
+ const { style } = element;
110
+ style.position = 'fixed';
111
+ style.left = '0';
112
+ style.top = '0';
113
+ style.width = '0';
114
+ style.height = '0';
115
+ style.zIndex = '-1';
116
+ style.overflow = 'hidden';
117
+ style.visibility = 'hidden';
118
+ // Bacon: Anything faster than this and the callback will be invoked too early with the wrong insets
119
+ style.transitionDuration = '0.05s';
120
+ style.transitionProperty = 'padding';
121
+ style.transitionDelay = '0s';
122
+ style.paddingTop = getInset('top');
123
+ style.paddingBottom = getInset('bottom');
124
+ style.paddingLeft = getInset('left');
125
+ style.paddingRight = getInset('right');
126
+ return element;
127
+ }
@@ -1,3 +1 @@
1
- import { CompatNativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
2
-
3
- export default CompatNativeSafeAreaProvider;
1
+ export { CompatNativeSafeAreaProvider as NativeSafeAreaProvider } from './CompatNativeSafeAreaProvider';
@@ -1,11 +1,12 @@
1
- import {
2
- NativeSyntheticEvent,
3
- StyleProp,
4
- ViewProps,
5
- ViewStyle,
6
- } from 'react-native';
1
+ import type * as React from 'react';
2
+ import type { NativeSyntheticEvent, ViewProps } from 'react-native';
3
+ import NativeSafeAreaView from './specs/NativeSafeAreaView';
7
4
 
8
5
  export type Edge = 'top' | 'right' | 'bottom' | 'left';
6
+ export type EdgeMode = 'off' | 'additive' | 'maximum';
7
+
8
+ export type EdgeRecord = Partial<Record<Edge, EdgeMode>>;
9
+ export type Edges = readonly Edge[] | Readonly<EdgeRecord>;
9
10
 
10
11
  export interface EdgeInsets {
11
12
  top: number;
@@ -30,14 +31,17 @@ export type InsetChangedEvent = NativeSyntheticEvent<Metrics>;
30
31
 
31
32
  export type InsetChangeNativeCallback = (event: InsetChangedEvent) => void;
32
33
 
33
- export interface NativeSafeAreaProviderProps {
34
+ export interface NativeSafeAreaProviderProps extends ViewProps {
34
35
  children?: React.ReactNode;
35
- style?: StyleProp<ViewStyle>;
36
36
  onInsetsChange: InsetChangeNativeCallback;
37
37
  }
38
38
 
39
- export type NativeSafeAreaViewProps = ViewProps & {
39
+ export interface NativeSafeAreaViewProps extends ViewProps {
40
40
  children?: React.ReactNode;
41
41
  mode?: 'padding' | 'margin';
42
- edges?: ReadonlyArray<Edge>;
43
- };
42
+ edges?: Edges;
43
+ }
44
+
45
+ export type NativeSafeAreaViewInstance = InstanceType<
46
+ typeof NativeSafeAreaView
47
+ >;