@amabeth/repeating-wheel-picker 1.1.0 → 1.2.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 (258) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +57 -57
  3. package/example/index.ts +8 -0
  4. package/example/node_modules/@expo/cli/static/template/+html.tsx +28 -0
  5. package/example/node_modules/@expo/cli/static/template/+native-intent.ts +9 -0
  6. package/example/node_modules/@expo/cli/static/template/[...rsc]+api.ts +16 -0
  7. package/example/node_modules/ansi-styles/index.d.ts +345 -0
  8. package/example/node_modules/chalk/index.d.ts +415 -0
  9. package/example/node_modules/commander/typings/index.d.ts +627 -0
  10. package/example/node_modules/expo/Expo.podspec +108 -0
  11. package/example/node_modules/expo/build/Expo.d.ts +8 -0
  12. package/example/node_modules/expo/build/Expo.fx.d.ts +4 -0
  13. package/example/node_modules/expo/build/Expo.fx.web.d.ts +3 -0
  14. package/example/node_modules/expo/build/devtools/DevToolsPluginClient.d.ts +72 -0
  15. package/example/node_modules/expo/build/devtools/DevToolsPluginClientFactory.d.ts +16 -0
  16. package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplApp.d.ts +15 -0
  17. package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplBrowser.d.ts +14 -0
  18. package/example/node_modules/expo/build/devtools/MessageFramePacker.d.ts +50 -0
  19. package/example/node_modules/expo/build/devtools/ProtocolVersion.d.ts +7 -0
  20. package/example/node_modules/expo/build/devtools/WebSocketBackingStore.d.ts +10 -0
  21. package/example/node_modules/expo/build/devtools/WebSocketWithReconnect.d.ts +81 -0
  22. package/example/node_modules/expo/build/devtools/devtools.types.d.ts +42 -0
  23. package/example/node_modules/expo/build/devtools/getConnectionInfo.d.ts +6 -0
  24. package/example/node_modules/expo/build/devtools/getConnectionInfo.native.d.ts +6 -0
  25. package/example/node_modules/expo/build/devtools/index.d.ts +12 -0
  26. package/example/node_modules/expo/build/devtools/logger.d.ts +6 -0
  27. package/example/node_modules/expo/build/dom/base.d.ts +5 -0
  28. package/example/node_modules/expo/build/dom/dom-entry.d.ts +3 -0
  29. package/example/node_modules/expo/build/dom/dom-hooks.d.ts +8 -0
  30. package/example/node_modules/expo/build/dom/dom.d.ts +5 -0
  31. package/example/node_modules/expo/build/dom/dom.types.d.ts +34 -0
  32. package/example/node_modules/expo/build/dom/dom.web.d.ts +3 -0
  33. package/example/node_modules/expo/build/dom/global-events.d.ts +4 -0
  34. package/example/node_modules/expo/build/dom/injection.d.ts +9 -0
  35. package/example/node_modules/expo/build/dom/internal.d.ts +3 -0
  36. package/example/node_modules/expo/build/dom/internal.web.d.ts +2 -0
  37. package/example/node_modules/expo/build/dom/marshal.d.ts +4 -0
  38. package/example/node_modules/expo/build/dom/webview/ExpoDOMWebView.d.ts +6 -0
  39. package/example/node_modules/expo/build/dom/webview/RNWebView.d.ts +7 -0
  40. package/example/node_modules/expo/build/dom/webview/useDebugZeroHeight.d.ts +12 -0
  41. package/example/node_modules/expo/build/dom/webview-wrapper.d.ts +16 -0
  42. package/example/node_modules/expo/build/environment/DevLoadingView.d.ts +3 -0
  43. package/example/node_modules/expo/build/environment/DevLoadingView.web.d.ts +3 -0
  44. package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.d.ts +9 -0
  45. package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.native.d.ts +3 -0
  46. package/example/node_modules/expo/build/environment/ExpoGo.d.ts +31 -0
  47. package/example/node_modules/expo/build/environment/ExpoGo.web.d.ts +3 -0
  48. package/example/node_modules/expo/build/environment/getInitialSafeArea.d.ts +7 -0
  49. package/example/node_modules/expo/build/environment/getInitialSafeArea.native.d.ts +11 -0
  50. package/example/node_modules/expo/build/errors/AppEntryNotFound.d.ts +2 -0
  51. package/example/node_modules/expo/build/errors/ExpoErrorManager.d.ts +8 -0
  52. package/example/node_modules/expo/build/errors/ExpoErrorManager.native.d.ts +4 -0
  53. package/example/node_modules/expo/build/hooks/useEvent.d.ts +59 -0
  54. package/example/node_modules/expo/build/launch/registerRootComponent.d.ts +30 -0
  55. package/example/node_modules/expo/build/launch/withDevTools.d.ts +3 -0
  56. package/example/node_modules/expo/build/launch/withDevTools.ios.d.ts +7 -0
  57. package/example/node_modules/expo/build/launch/withDevTools.web.d.ts +3 -0
  58. package/example/node_modules/expo/build/timer/polyfillNextTick.d.ts +6 -0
  59. package/example/node_modules/expo/build/utils/blobUtils.d.ts +9 -0
  60. package/example/node_modules/expo/build/utils/getBundleUrl.d.ts +2 -0
  61. package/example/node_modules/expo/build/utils/getBundleUrl.native.d.ts +2 -0
  62. package/example/node_modules/expo/build/utils/getBundleUrl.web.d.ts +2 -0
  63. package/example/node_modules/expo/build/winter/FormData.d.ts +49 -0
  64. package/example/node_modules/expo/build/winter/ImportMetaRegistry.d.ts +9 -0
  65. package/example/node_modules/expo/build/winter/TextDecoder.d.ts +20 -0
  66. package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.d.ts +2 -0
  67. package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.web.d.ts +10 -0
  68. package/example/node_modules/expo/build/winter/fetch/FetchErrors.d.ts +8 -0
  69. package/example/node_modules/expo/build/winter/fetch/FetchResponse.d.ts +31 -0
  70. package/example/node_modules/expo/build/winter/fetch/NativeRequest.d.ts +30 -0
  71. package/example/node_modules/expo/build/winter/fetch/RequestUtils.d.ts +21 -0
  72. package/example/node_modules/expo/build/winter/fetch/convertFormData.d.ts +19 -0
  73. package/example/node_modules/expo/build/winter/fetch/fetch.d.ts +4 -0
  74. package/example/node_modules/expo/build/winter/fetch/fetch.types.d.ts +16 -0
  75. package/example/node_modules/expo/build/winter/fetch/fetch.web.d.ts +2 -0
  76. package/example/node_modules/expo/build/winter/fetch/index.d.ts +3 -0
  77. package/example/node_modules/expo/build/winter/index.d.ts +2 -0
  78. package/example/node_modules/expo/build/winter/runtime.d.ts +2 -0
  79. package/example/node_modules/expo/build/winter/runtime.native.d.ts +2 -0
  80. package/example/node_modules/expo/build/winter/url.d.ts +23 -0
  81. package/example/node_modules/expo/config-plugins.d.ts +1 -0
  82. package/example/node_modules/expo/config.d.ts +1 -0
  83. package/example/node_modules/expo/devtools.d.ts +1 -0
  84. package/example/node_modules/expo/dom/global.d.ts +1 -0
  85. package/example/node_modules/expo/dom/index.d.ts +1 -0
  86. package/example/node_modules/expo/dom/internal.d.ts +1 -0
  87. package/example/node_modules/expo/fetch.d.ts +1 -0
  88. package/example/node_modules/expo/fingerprint.d.ts +1 -0
  89. package/example/node_modules/expo/metro-config.d.ts +1 -0
  90. package/example/node_modules/expo/react-native.config.js +50 -0
  91. package/example/node_modules/expo/src/Expo.fx.tsx +53 -0
  92. package/example/node_modules/expo/src/Expo.fx.web.tsx +21 -0
  93. package/example/node_modules/expo/src/Expo.ts +30 -0
  94. package/example/node_modules/expo/src/devtools/DevToolsPluginClient.ts +240 -0
  95. package/example/node_modules/expo/src/devtools/DevToolsPluginClientFactory.ts +73 -0
  96. package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplApp.ts +56 -0
  97. package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplBrowser.ts +38 -0
  98. package/example/node_modules/expo/src/devtools/MessageFramePacker.ts +235 -0
  99. package/example/node_modules/expo/src/devtools/ProtocolVersion.ts +6 -0
  100. package/example/node_modules/expo/src/devtools/WebSocketBackingStore.ts +10 -0
  101. package/example/node_modules/expo/src/devtools/WebSocketWithReconnect.ts +318 -0
  102. package/example/node_modules/expo/src/devtools/devtools.types.ts +50 -0
  103. package/example/node_modules/expo/src/devtools/getConnectionInfo.native.ts +18 -0
  104. package/example/node_modules/expo/src/devtools/getConnectionInfo.ts +16 -0
  105. package/example/node_modules/expo/src/devtools/index.ts +53 -0
  106. package/example/node_modules/expo/src/devtools/logger.ts +29 -0
  107. package/example/node_modules/expo/src/dom/base.ts +62 -0
  108. package/example/node_modules/expo/src/dom/dom-entry.tsx +128 -0
  109. package/example/node_modules/expo/src/dom/dom-hooks.ts +46 -0
  110. package/example/node_modules/expo/src/dom/dom.ts +8 -0
  111. package/example/node_modules/expo/src/dom/dom.types.ts +39 -0
  112. package/example/node_modules/expo/src/dom/dom.web.ts +6 -0
  113. package/example/node_modules/expo/src/dom/global-events.ts +16 -0
  114. package/example/node_modules/expo/src/dom/injection.ts +42 -0
  115. package/example/node_modules/expo/src/dom/internal.ts +5 -0
  116. package/example/node_modules/expo/src/dom/internal.web.ts +1 -0
  117. package/example/node_modules/expo/src/dom/marshal.tsx +116 -0
  118. package/example/node_modules/expo/src/dom/webview/ExpoDOMWebView.ts +10 -0
  119. package/example/node_modules/expo/src/dom/webview/RNWebView.ts +12 -0
  120. package/example/node_modules/expo/src/dom/webview/useDebugZeroHeight.ts +62 -0
  121. package/example/node_modules/expo/src/dom/webview-wrapper.tsx +253 -0
  122. package/example/node_modules/expo/src/environment/DevLoadingView.tsx +123 -0
  123. package/example/node_modules/expo/src/environment/DevLoadingView.web.tsx +135 -0
  124. package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.native.ts +3 -0
  125. package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.ts +7 -0
  126. package/example/node_modules/expo/src/environment/ExpoGo.ts +53 -0
  127. package/example/node_modules/expo/src/environment/ExpoGo.web.ts +7 -0
  128. package/example/node_modules/expo/src/environment/getInitialSafeArea.native.ts +16 -0
  129. package/example/node_modules/expo/src/environment/getInitialSafeArea.ts +8 -0
  130. package/example/node_modules/expo/src/errors/AppEntryNotFound.tsx +35 -0
  131. package/example/node_modules/expo/src/errors/ExpoErrorManager.native.ts +51 -0
  132. package/example/node_modules/expo/src/errors/ExpoErrorManager.ts +11 -0
  133. package/example/node_modules/expo/src/hooks/useEvent.ts +112 -0
  134. package/example/node_modules/expo/src/launch/registerRootComponent.tsx +64 -0
  135. package/example/node_modules/expo/src/launch/withDevTools.ios.tsx +47 -0
  136. package/example/node_modules/expo/src/launch/withDevTools.tsx +30 -0
  137. package/example/node_modules/expo/src/launch/withDevTools.web.tsx +23 -0
  138. package/example/node_modules/expo/src/timer/polyfillNextTick.ts +10 -0
  139. package/example/node_modules/expo/src/ts-declarations/console.d.ts +47 -0
  140. package/example/node_modules/expo/src/ts-declarations/global.d.ts +12 -0
  141. package/example/node_modules/expo/src/ts-declarations/react-native.d.ts +34 -0
  142. package/example/node_modules/expo/src/ts-declarations/whatwg-url-without-unicode.d.ts +186 -0
  143. package/example/node_modules/expo/src/utils/blobUtils.ts +23 -0
  144. package/example/node_modules/expo/src/utils/getBundleUrl.native.ts +17 -0
  145. package/example/node_modules/expo/src/utils/getBundleUrl.ts +5 -0
  146. package/example/node_modules/expo/src/utils/getBundleUrl.web.ts +21 -0
  147. package/example/node_modules/expo/src/winter/FormData.ts +222 -0
  148. package/example/node_modules/expo/src/winter/ImportMetaRegistry.ts +14 -0
  149. package/example/node_modules/expo/src/winter/TextDecoder.ts +429 -0
  150. package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.ts +3 -0
  151. package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.web.ts +7 -0
  152. package/example/node_modules/expo/src/winter/fetch/FetchErrors.ts +11 -0
  153. package/example/node_modules/expo/src/winter/fetch/FetchResponse.ts +146 -0
  154. package/example/node_modules/expo/src/winter/fetch/NativeRequest.ts +38 -0
  155. package/example/node_modules/expo/src/winter/fetch/RequestUtils.ts +124 -0
  156. package/example/node_modules/expo/src/winter/fetch/convertFormData.ts +92 -0
  157. package/example/node_modules/expo/src/winter/fetch/fetch.ts +59 -0
  158. package/example/node_modules/expo/src/winter/fetch/fetch.types.ts +17 -0
  159. package/example/node_modules/expo/src/winter/fetch/fetch.web.ts +1 -0
  160. package/example/node_modules/expo/src/winter/fetch/index.ts +2 -0
  161. package/example/node_modules/expo/src/winter/index.ts +1 -0
  162. package/example/node_modules/expo/src/winter/runtime.native.ts +41 -0
  163. package/example/node_modules/expo/src/winter/runtime.ts +5 -0
  164. package/example/node_modules/expo/src/winter/url.ts +116 -0
  165. package/example/node_modules/expo/types/global.d.ts +38 -0
  166. package/example/node_modules/expo/types/index.d.ts +3 -0
  167. package/example/node_modules/expo/types/metro-require.d.ts +52 -0
  168. package/example/node_modules/expo/types/react-native-web.d.ts +291 -0
  169. package/example/node_modules/expo-modules-autolinking/build/ExpoModuleConfig.d.ts +85 -0
  170. package/example/node_modules/expo-modules-autolinking/build/autolinking/findModules.d.ts +5 -0
  171. package/example/node_modules/expo-modules-autolinking/build/autolinking/generatePackageList.d.ts +11 -0
  172. package/example/node_modules/expo-modules-autolinking/build/autolinking/getConfiguration.d.ts +2 -0
  173. package/example/node_modules/expo-modules-autolinking/build/autolinking/index.d.ts +17 -0
  174. package/example/node_modules/expo-modules-autolinking/build/autolinking/mergeLinkingOptions.d.ts +21 -0
  175. package/example/node_modules/expo-modules-autolinking/build/autolinking/resolveModules.d.ts +9 -0
  176. package/example/node_modules/expo-modules-autolinking/build/autolinking/utils.d.ts +6 -0
  177. package/example/node_modules/expo-modules-autolinking/build/autolinking/verifySearchResults.d.ts +5 -0
  178. package/example/node_modules/expo-modules-autolinking/build/fileUtils.d.ts +18 -0
  179. package/example/node_modules/expo-modules-autolinking/build/index.d.ts +1 -0
  180. package/example/node_modules/expo-modules-autolinking/build/platforms/android.d.ts +38 -0
  181. package/example/node_modules/expo-modules-autolinking/build/platforms/apple.d.ts +15 -0
  182. package/example/node_modules/expo-modules-autolinking/build/platforms/devtools.d.ts +3 -0
  183. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/androidResolver.d.ts +20 -0
  184. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/config.d.ts +5 -0
  185. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/index.d.ts +2 -0
  186. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/iosResolver.d.ts +2 -0
  187. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.d.ts +13 -0
  188. package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.types.d.ts +95 -0
  189. package/example/node_modules/expo-modules-autolinking/build/types.d.ts +319 -0
  190. package/example/node_modules/expo-modules-autolinking/e2e/TestUtils.ts +53 -0
  191. package/example/node_modules/expo-modules-autolinking/exports.d.ts +1 -0
  192. package/example/node_modules/expo-modules-autolinking/src/ExpoModuleConfig.ts +181 -0
  193. package/example/node_modules/expo-modules-autolinking/src/autolinking/findModules.ts +259 -0
  194. package/example/node_modules/expo-modules-autolinking/src/autolinking/generatePackageList.ts +46 -0
  195. package/example/node_modules/expo-modules-autolinking/src/autolinking/getConfiguration.ts +7 -0
  196. package/example/node_modules/expo-modules-autolinking/src/autolinking/index.ts +45 -0
  197. package/example/node_modules/expo-modules-autolinking/src/autolinking/mergeLinkingOptions.ts +127 -0
  198. package/example/node_modules/expo-modules-autolinking/src/autolinking/resolveModules.ts +46 -0
  199. package/example/node_modules/expo-modules-autolinking/src/autolinking/utils.ts +37 -0
  200. package/example/node_modules/expo-modules-autolinking/src/autolinking/verifySearchResults.ts +33 -0
  201. package/example/node_modules/expo-modules-autolinking/src/fileUtils.ts +64 -0
  202. package/example/node_modules/expo-modules-autolinking/src/index.ts +262 -0
  203. package/example/node_modules/expo-modules-autolinking/src/platforms/android.ts +303 -0
  204. package/example/node_modules/expo-modules-autolinking/src/platforms/apple.ts +292 -0
  205. package/example/node_modules/expo-modules-autolinking/src/platforms/devtools.ts +25 -0
  206. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/androidResolver.ts +264 -0
  207. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/config.ts +67 -0
  208. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/index.ts +2 -0
  209. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/iosResolver.ts +37 -0
  210. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.ts +245 -0
  211. package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.types.ts +107 -0
  212. package/example/node_modules/expo-modules-autolinking/src/types.ts +384 -0
  213. package/example/node_modules/find-up/index.d.ts +138 -0
  214. package/example/node_modules/glob/dist/commonjs/glob.d.ts +388 -0
  215. package/example/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
  216. package/example/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
  217. package/example/node_modules/glob/dist/commonjs/index.d.ts +97 -0
  218. package/example/node_modules/glob/dist/commonjs/pattern.d.ts +76 -0
  219. package/example/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
  220. package/example/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
  221. package/example/node_modules/glob/dist/esm/glob.d.ts +388 -0
  222. package/example/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
  223. package/example/node_modules/glob/dist/esm/ignore.d.ts +24 -0
  224. package/example/node_modules/glob/dist/esm/index.d.ts +97 -0
  225. package/example/node_modules/glob/dist/esm/pattern.d.ts +76 -0
  226. package/example/node_modules/glob/dist/esm/processor.d.ts +59 -0
  227. package/example/node_modules/glob/dist/esm/walker.d.ts +97 -0
  228. package/example/node_modules/locate-path/index.d.ts +83 -0
  229. package/example/node_modules/log-symbols/node_modules/chalk/types/index.d.ts +97 -0
  230. package/example/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  231. package/example/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
  232. package/example/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  233. package/example/node_modules/minimatch/dist/commonjs/escape.d.ts +12 -0
  234. package/example/node_modules/minimatch/dist/commonjs/index.d.ts +94 -0
  235. package/example/node_modules/minimatch/dist/commonjs/unescape.d.ts +17 -0
  236. package/example/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  237. package/example/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
  238. package/example/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  239. package/example/node_modules/minimatch/dist/esm/escape.d.ts +12 -0
  240. package/example/node_modules/minimatch/dist/esm/index.d.ts +94 -0
  241. package/example/node_modules/minimatch/dist/esm/unescape.d.ts +17 -0
  242. package/example/node_modules/ora/index.d.ts +257 -0
  243. package/example/node_modules/ora/node_modules/chalk/types/index.d.ts +97 -0
  244. package/example/node_modules/ora/node_modules/strip-ansi/index.d.ts +15 -0
  245. package/example/node_modules/p-locate/index.d.ts +53 -0
  246. package/example/node_modules/path-exists/index.d.ts +28 -0
  247. package/example/package.json +29 -0
  248. package/example/src/constants/styles.ts +43 -0
  249. package/example/src/hooks/useComponentHeight.ts +13 -0
  250. package/example/src/scenes/app.tsx +33 -0
  251. package/example/src/scenes/booleanPicker.tsx +60 -0
  252. package/example/src/scenes/customTypePicker.tsx +83 -0
  253. package/example/src/scenes/numberPicker.tsx +75 -0
  254. package/example/src/scenes/stringPicker.tsx +64 -0
  255. package/lib/module/index.js +6 -6
  256. package/lib/module/index.js.map +1 -1
  257. package/package.json +168 -183
  258. package/src/index.tsx +0 -507
@@ -0,0 +1,292 @@
1
+ import spawnAsync from '@expo/spawn-async';
2
+ import fs from 'fs';
3
+ import { glob } from 'glob';
4
+ import path from 'path';
5
+
6
+ import { fileExistsAsync } from '../fileUtils';
7
+ import type {
8
+ AppleCodeSignEntitlements,
9
+ ExtraDependencies,
10
+ ModuleDescriptorIos,
11
+ ModuleIosPodspecInfo,
12
+ PackageRevision,
13
+ SearchOptions,
14
+ } from '../types';
15
+
16
+ const APPLE_PROPERTIES_FILE = 'Podfile.properties.json';
17
+ const APPLE_EXTRA_BUILD_DEPS_KEY = 'apple.extraPods';
18
+
19
+ const indent = ' ';
20
+
21
+ async function findPodspecFiles(revision: PackageRevision): Promise<string[]> {
22
+ const configPodspecPaths = revision.config?.applePodspecPaths();
23
+ if (configPodspecPaths && configPodspecPaths.length) {
24
+ return configPodspecPaths;
25
+ }
26
+
27
+ const podspecFiles = await glob('*/*.podspec', {
28
+ cwd: revision.path,
29
+ ignore: ['**/node_modules/**'],
30
+ });
31
+
32
+ return podspecFiles;
33
+ }
34
+
35
+ export function getSwiftModuleNames(
36
+ pods: ModuleIosPodspecInfo[],
37
+ swiftModuleNames: string[] | undefined
38
+ ): string[] {
39
+ if (swiftModuleNames && swiftModuleNames.length) {
40
+ return swiftModuleNames;
41
+ }
42
+ // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name
43
+ return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));
44
+ }
45
+
46
+ /**
47
+ * Resolves module search result with additional details required for iOS platform.
48
+ */
49
+ export async function resolveModuleAsync(
50
+ packageName: string,
51
+ revision: PackageRevision,
52
+ options: SearchOptions
53
+ ): Promise<ModuleDescriptorIos | null> {
54
+ const podspecFiles = await findPodspecFiles(revision);
55
+ if (!podspecFiles.length) {
56
+ return null;
57
+ }
58
+
59
+ const pods = podspecFiles.map((podspecFile) => ({
60
+ podName: path.basename(podspecFile, path.extname(podspecFile)),
61
+ podspecDir: path.dirname(path.join(revision.path, podspecFile)),
62
+ }));
63
+
64
+ const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.appleSwiftModuleNames());
65
+ const coreFeatures = revision.config?.coreFeatures() ?? [];
66
+
67
+ return {
68
+ packageName,
69
+ pods,
70
+ swiftModuleNames,
71
+ flags: options.flags,
72
+ modules: revision.config?.appleModules() ?? [],
73
+ appDelegateSubscribers: revision.config?.appleAppDelegateSubscribers() ?? [],
74
+ reactDelegateHandlers: revision.config?.appleReactDelegateHandlers() ?? [],
75
+ debugOnly: revision.config?.appleDebugOnly() ?? false,
76
+ ...(coreFeatures.length > 0 ? { coreFeatures } : {}),
77
+ };
78
+ }
79
+
80
+ export async function resolveExtraBuildDependenciesAsync(
81
+ projectNativeRoot: string
82
+ ): Promise<ExtraDependencies | null> {
83
+ const propsFile = path.join(projectNativeRoot, APPLE_PROPERTIES_FILE);
84
+ try {
85
+ const contents = await fs.promises.readFile(propsFile, 'utf8');
86
+ const podfileJson = JSON.parse(contents);
87
+ if (podfileJson[APPLE_EXTRA_BUILD_DEPS_KEY]) {
88
+ // expo-build-properties would serialize the extraPods as JSON string, we should parse it again.
89
+ const extraPods = JSON.parse(podfileJson[APPLE_EXTRA_BUILD_DEPS_KEY]);
90
+ return extraPods;
91
+ }
92
+ } catch {}
93
+ return null;
94
+ }
95
+
96
+ /**
97
+ * Generates Swift file that contains all autolinked Swift packages.
98
+ */
99
+ export async function generateModulesProviderAsync(
100
+ modules: ModuleDescriptorIos[],
101
+ targetPath: string,
102
+ entitlementPath: string
103
+ ): Promise<void> {
104
+ const className = path.basename(targetPath, path.extname(targetPath));
105
+ const entitlements = await parseEntitlementsAsync(entitlementPath);
106
+ const generatedFileContent = await generatePackageListFileContentAsync(
107
+ modules,
108
+ className,
109
+ entitlements
110
+ );
111
+ const parentPath = path.dirname(targetPath);
112
+ await fs.promises.mkdir(parentPath, { recursive: true });
113
+ await fs.promises.writeFile(targetPath, generatedFileContent, 'utf8');
114
+ }
115
+
116
+ /**
117
+ * Generates the string to put into the generated package list.
118
+ */
119
+ async function generatePackageListFileContentAsync(
120
+ modules: ModuleDescriptorIos[],
121
+ className: string,
122
+ entitlements: AppleCodeSignEntitlements
123
+ ): Promise<string> {
124
+ const iosModules = modules.filter(
125
+ (module) =>
126
+ module.modules.length ||
127
+ module.appDelegateSubscribers.length ||
128
+ module.reactDelegateHandlers.length
129
+ );
130
+
131
+ const modulesToImport = iosModules.filter((module) => !module.debugOnly);
132
+ const debugOnlyModules = iosModules.filter((module) => module.debugOnly);
133
+
134
+ const swiftModules = ([] as string[])
135
+ .concat(...modulesToImport.map((module) => module.swiftModuleNames))
136
+ .filter(Boolean);
137
+
138
+ const debugOnlySwiftModules = ([] as string[])
139
+ .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))
140
+ .filter(Boolean);
141
+
142
+ const modulesClassNames = ([] as string[])
143
+ .concat(...modulesToImport.map((module) => module.modules))
144
+ .filter(Boolean);
145
+
146
+ const debugOnlyModulesClassNames = ([] as string[])
147
+ .concat(...debugOnlyModules.map((module) => module.modules))
148
+ .filter(Boolean);
149
+
150
+ const appDelegateSubscribers = ([] as string[]).concat(
151
+ ...modulesToImport.map((module) => module.appDelegateSubscribers)
152
+ );
153
+
154
+ const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(
155
+ ...debugOnlyModules.map((module) => module.appDelegateSubscribers)
156
+ );
157
+
158
+ const reactDelegateHandlerModules = modulesToImport.filter(
159
+ (module) => !!module.reactDelegateHandlers.length
160
+ );
161
+
162
+ const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(
163
+ (module) => !!module.reactDelegateHandlers.length
164
+ );
165
+
166
+ return `/**
167
+ * Automatically generated by expo-modules-autolinking.
168
+ *
169
+ * This autogenerated class provides a list of classes of native Expo modules,
170
+ * but only these that are written in Swift and use the new API for creating Expo modules.
171
+ */
172
+
173
+ import ExpoModulesCore
174
+ ${generateCommonImportList(swiftModules)}
175
+ ${generateDebugOnlyImportList(debugOnlySwiftModules)}
176
+ @objc(${className})
177
+ public class ${className}: ModulesProvider {
178
+ public override func getModuleClasses() -> [AnyModule.Type] {
179
+ ${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}
180
+ }
181
+
182
+ public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
183
+ ${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}
184
+ }
185
+
186
+ public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
187
+ ${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}
188
+ }
189
+
190
+ public override func getAppCodeSignEntitlements() -> AppCodeSignEntitlements {
191
+ return AppCodeSignEntitlements.from(json: #"${JSON.stringify(entitlements)}"#)
192
+ }
193
+ }
194
+ `;
195
+ }
196
+
197
+ function generateCommonImportList(swiftModules: string[]): string {
198
+ return swiftModules.map((moduleName) => `import ${moduleName}`).join('\n');
199
+ }
200
+
201
+ function generateDebugOnlyImportList(swiftModules: string[]): string {
202
+ if (!swiftModules.length) {
203
+ return '';
204
+ }
205
+
206
+ return (
207
+ wrapInDebugConfigurationCheck(
208
+ 0,
209
+ swiftModules.map((moduleName) => `import ${moduleName}`).join('\n')
210
+ ) + '\n'
211
+ );
212
+ }
213
+
214
+ function generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {
215
+ const commonClassNames = formatArrayOfClassNames(classNames);
216
+ if (debugOnlyClassName.length > 0) {
217
+ return wrapInDebugConfigurationCheck(
218
+ 2,
219
+ `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,
220
+ `return ${commonClassNames}`
221
+ );
222
+ } else {
223
+ return `${indent.repeat(2)}return ${commonClassNames}`;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Formats an array of class names to Swift's array containing these classes.
229
+ */
230
+ function formatArrayOfClassNames(classNames: string[]): string {
231
+ return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
232
+ ${indent.repeat(2)}]`;
233
+ }
234
+
235
+ function generateReactDelegateHandlers(
236
+ module: ModuleDescriptorIos[],
237
+ debugOnlyModules: ModuleDescriptorIos[]
238
+ ): string {
239
+ const commonModules = formatArrayOfReactDelegateHandler(module);
240
+ if (debugOnlyModules.length > 0) {
241
+ return wrapInDebugConfigurationCheck(
242
+ 2,
243
+ `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,
244
+ `return ${commonModules}`
245
+ );
246
+ } else {
247
+ return `${indent.repeat(2)}return ${commonModules}`;
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Formats an array of modules to Swift's array containing ReactDelegateHandlers
253
+ */
254
+ export function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {
255
+ const values: string[] = [];
256
+ for (const module of modules) {
257
+ for (const handler of module.reactDelegateHandlers) {
258
+ values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
259
+ }
260
+ }
261
+ return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
262
+ ${indent.repeat(2)}]`;
263
+ }
264
+
265
+ function wrapInDebugConfigurationCheck(
266
+ indentationLevel: number,
267
+ debugBlock: string,
268
+ releaseBlock: string | null = null
269
+ ) {
270
+ if (releaseBlock) {
271
+ return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
272
+ indentationLevel
273
+ )}${debugBlock}\n${indent.repeat(indentationLevel)}#else\n${indent.repeat(
274
+ indentationLevel
275
+ )}${releaseBlock}\n${indent.repeat(indentationLevel)}#endif`;
276
+ }
277
+
278
+ return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
279
+ indentationLevel
280
+ )}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
281
+ }
282
+
283
+ async function parseEntitlementsAsync(entitlementPath: string): Promise<AppleCodeSignEntitlements> {
284
+ if (!(await fileExistsAsync(entitlementPath))) {
285
+ return {};
286
+ }
287
+ const { stdout } = await spawnAsync('plutil', ['-convert', 'json', '-o', '-', entitlementPath]);
288
+ const entitlementsJson = JSON.parse(stdout);
289
+ return {
290
+ appGroups: entitlementsJson['com.apple.security.application-groups'] || undefined,
291
+ };
292
+ }
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+
3
+ import type { ExtraDependencies, ModuleDescriptorDevTools, PackageRevision } from '../types';
4
+
5
+ export async function resolveModuleAsync(
6
+ packageName: string,
7
+ revision: PackageRevision
8
+ ): Promise<ModuleDescriptorDevTools | null> {
9
+ const devtoolsConfig = revision.config?.toJSON().devtools;
10
+ if (devtoolsConfig == null) {
11
+ return null;
12
+ }
13
+
14
+ return {
15
+ packageName,
16
+ packageRoot: revision.path,
17
+ webpageRoot: path.join(revision.path, devtoolsConfig.webpageRoot),
18
+ };
19
+ }
20
+
21
+ export async function resolveExtraBuildDependenciesAsync(
22
+ _projectNativeRoot: string
23
+ ): Promise<ExtraDependencies | null> {
24
+ return null;
25
+ }
@@ -0,0 +1,264 @@
1
+ import fs from 'fs/promises';
2
+ import { glob } from 'glob';
3
+ import path from 'path';
4
+
5
+ import type {
6
+ RNConfigDependencyAndroid,
7
+ RNConfigReactNativePlatformsConfigAndroid,
8
+ } from './reactNativeConfig.types';
9
+ import {
10
+ fileExistsAsync,
11
+ globMatchFunctorAllAsync,
12
+ globMatchFunctorFirstAsync,
13
+ } from '../fileUtils';
14
+
15
+ export async function resolveDependencyConfigImplAndroidAsync(
16
+ packageRoot: string,
17
+ reactNativeConfig: RNConfigReactNativePlatformsConfigAndroid | null | undefined
18
+ ): Promise<RNConfigDependencyAndroid | null> {
19
+ if (reactNativeConfig === null) {
20
+ // Skip autolinking for this package.
21
+ return null;
22
+ }
23
+ const sourceDir = reactNativeConfig?.sourceDir || 'android';
24
+ const androidDir = path.join(packageRoot, sourceDir);
25
+ const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: true });
26
+ if (!manifest && !gradle) {
27
+ return null;
28
+ }
29
+
30
+ const packageName =
31
+ reactNativeConfig?.packageName || (await parsePackageNameAsync(androidDir, manifest, gradle));
32
+ if (!packageName) {
33
+ return null;
34
+ }
35
+ const nativePackageClassName = await parseNativePackageClassNameAsync(packageRoot, androidDir);
36
+ if (!nativePackageClassName) {
37
+ return null;
38
+ }
39
+
40
+ const packageJson = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));
41
+ const packageImportPath =
42
+ reactNativeConfig?.packageImportPath || `import ${packageName}.${nativePackageClassName};`;
43
+ const packageInstance = reactNativeConfig?.packageInstance || `new ${nativePackageClassName}()`;
44
+ const buildTypes = reactNativeConfig?.buildTypes || [];
45
+ const dependencyConfiguration = reactNativeConfig?.dependencyConfiguration;
46
+ const libraryName =
47
+ reactNativeConfig?.libraryName || (await parseLibraryNameAsync(androidDir, packageJson));
48
+ const componentDescriptors =
49
+ reactNativeConfig?.componentDescriptors ||
50
+ (await parseComponentDescriptorsAsync(packageRoot, packageJson));
51
+ let cmakeListsPath = reactNativeConfig?.cmakeListsPath
52
+ ? path.join(androidDir, reactNativeConfig?.cmakeListsPath)
53
+ : path.join(androidDir, 'build/generated/source/codegen/jni/CMakeLists.txt');
54
+ const cxxModuleCMakeListsModuleName = reactNativeConfig?.cxxModuleCMakeListsModuleName || null;
55
+ const cxxModuleHeaderName = reactNativeConfig?.cxxModuleHeaderName || null;
56
+ let cxxModuleCMakeListsPath = reactNativeConfig?.cxxModuleCMakeListsPath
57
+ ? path.join(androidDir, reactNativeConfig?.cxxModuleCMakeListsPath)
58
+ : null;
59
+ if (process.platform === 'win32') {
60
+ cmakeListsPath = cmakeListsPath.replace(/\\/g, '/');
61
+ if (cxxModuleCMakeListsPath) {
62
+ cxxModuleCMakeListsPath = cxxModuleCMakeListsPath.replace(/\\/g, '/');
63
+ }
64
+ }
65
+
66
+ const result: RNConfigDependencyAndroid = {
67
+ sourceDir: androidDir,
68
+ packageImportPath,
69
+ packageInstance,
70
+ dependencyConfiguration,
71
+ buildTypes,
72
+ libraryName,
73
+ componentDescriptors,
74
+ cmakeListsPath,
75
+ cxxModuleCMakeListsModuleName,
76
+ cxxModuleCMakeListsPath,
77
+ cxxModuleHeaderName,
78
+ };
79
+ if (!result.libraryName) {
80
+ delete result.libraryName;
81
+ }
82
+ if (!result.dependencyConfiguration) {
83
+ delete result.dependencyConfiguration;
84
+ }
85
+ return result;
86
+ }
87
+
88
+ /**
89
+ * Parse the `RNConfigDependencyAndroid.packageName`
90
+ */
91
+ export async function parsePackageNameAsync(
92
+ androidDir: string,
93
+ manifestPath: string | null,
94
+ gradlePath: string | null
95
+ ): Promise<string | null> {
96
+ if (gradlePath) {
97
+ const gradleContents = await fs.readFile(path.join(androidDir, gradlePath), 'utf8');
98
+ const match = gradleContents.match(/namespace\s*[=]*\s*["'](.+?)["']/);
99
+ if (match) {
100
+ return match[1];
101
+ }
102
+ }
103
+ if (manifestPath) {
104
+ const manifestContents = await fs.readFile(path.join(androidDir, manifestPath), 'utf8');
105
+ const match = manifestContents.match(/package="(.+?)"/);
106
+ if (match) {
107
+ return match[1];
108
+ }
109
+ }
110
+ return null;
111
+ }
112
+
113
+ /**
114
+ * Parse the Java or Kotlin class name to for `ReactPackage` or `(Base|Turbo)ReactPackage`.
115
+ */
116
+ export async function parseNativePackageClassNameAsync(
117
+ packageRoot: string,
118
+ androidDir: string
119
+ ): Promise<string | null> {
120
+ const matched = await globMatchFunctorFirstAsync(
121
+ '**/*Package.{java,kt}',
122
+ matchNativePackageClassName,
123
+ { cwd: androidDir }
124
+ );
125
+ if (matched) {
126
+ return matched;
127
+ }
128
+
129
+ // Early return if the module is an Expo module
130
+ if (await fileExistsAsync(path.join(packageRoot, 'expo-module.config.json'))) {
131
+ return null;
132
+ }
133
+
134
+ return await globMatchFunctorFirstAsync('**/*.{java,kt}', matchNativePackageClassName, {
135
+ cwd: androidDir,
136
+ });
137
+ }
138
+
139
+ let lazyReactPackageRegex: RegExp | null = null;
140
+ let lazyTurboReactPackageRegex: RegExp | null = null;
141
+ export function matchNativePackageClassName(_filePath: string, contents: Buffer): string | null {
142
+ const fileContents = contents.toString();
143
+
144
+ // [0] Match ReactPackage
145
+ if (!lazyReactPackageRegex) {
146
+ lazyReactPackageRegex =
147
+ /class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/;
148
+ }
149
+ const matchReactPackage = fileContents.match(lazyReactPackageRegex);
150
+ if (matchReactPackage) {
151
+ return matchReactPackage[1];
152
+ }
153
+
154
+ // [1] Match (Base|Turbo)ReactPackage
155
+ if (!lazyTurboReactPackageRegex) {
156
+ lazyTurboReactPackageRegex =
157
+ /class\s+(\w+[^(\s]*)[\s\w():]*(\s+extends\s+|:)[\s\w():,]*[^{]*(Base|Turbo)ReactPackage/;
158
+ }
159
+ const matchTurboReactPackage = fileContents.match(lazyTurboReactPackageRegex);
160
+ if (matchTurboReactPackage) {
161
+ return matchTurboReactPackage[1];
162
+ }
163
+
164
+ return null;
165
+ }
166
+
167
+ export async function parseLibraryNameAsync(
168
+ androidDir: string,
169
+ packageJson: any
170
+ ): Promise<string | null> {
171
+ // [0] `codegenConfig.name` from package.json
172
+ if (packageJson.codegenConfig?.name) {
173
+ return packageJson.codegenConfig.name;
174
+ }
175
+
176
+ const libraryNameRegExp = /libraryName = ["'](.+)["']/;
177
+ const gradlePath = path.join(androidDir, 'build.gradle');
178
+ // [1] `libraryName` from build.gradle
179
+ if (await fileExistsAsync(gradlePath)) {
180
+ const buildGradleContents = await fs.readFile(gradlePath, 'utf8');
181
+ const match = buildGradleContents.match(libraryNameRegExp);
182
+ if (match) {
183
+ return match[1];
184
+ }
185
+ }
186
+
187
+ // [2] `libraryName` from build.gradle.kts
188
+ const gradleKtsPath = path.join(androidDir, 'build.gradle.kts');
189
+ if (await fileExistsAsync(gradleKtsPath)) {
190
+ const buildGradleContents = await fs.readFile(gradleKtsPath, 'utf8');
191
+ const match = buildGradleContents.match(libraryNameRegExp);
192
+ if (match) {
193
+ return match[1];
194
+ }
195
+ }
196
+
197
+ return null;
198
+ }
199
+
200
+ export async function parseComponentDescriptorsAsync(
201
+ packageRoot: string,
202
+ packageJson: any
203
+ ): Promise<string[]> {
204
+ const jsRoot = packageJson?.codegenConfig?.jsSrcsDir
205
+ ? path.join(packageRoot, packageJson.codegenConfig.jsSrcsDir)
206
+ : packageRoot;
207
+ const results = await globMatchFunctorAllAsync(
208
+ '**/*.{js,jsx,ts,tsx}',
209
+ matchComponentDescriptors,
210
+ {
211
+ cwd: jsRoot,
212
+ ignore: ['**/node_modules/**'],
213
+ }
214
+ );
215
+
216
+ // Filter out duplicates as it happens that libraries contain multiple outputs due to package publishing.
217
+ // TODO: consider using "codegenConfig" to avoid this.
218
+ return Array.from(new Set(results));
219
+ }
220
+
221
+ let lazyCodegenComponentRegex: RegExp | null = null;
222
+ function matchComponentDescriptors(filePath: string, contents: Buffer): string | null {
223
+ const fileContents = contents.toString();
224
+
225
+ if (!lazyCodegenComponentRegex) {
226
+ lazyCodegenComponentRegex =
227
+ /codegenNativeComponent(<.*>)?\s*\(\s*["'`](\w+)["'`](,?[\s\S]+interfaceOnly:\s*(\w+))?/m;
228
+ }
229
+ const match = fileContents.match(lazyCodegenComponentRegex);
230
+ if (!(match?.[4] === 'true') && match?.[2]) {
231
+ return `${match[2]}ComponentDescriptor`;
232
+ }
233
+ return null;
234
+ }
235
+
236
+ export async function findGradleAndManifestAsync({
237
+ androidDir,
238
+ isLibrary,
239
+ }: {
240
+ androidDir: string;
241
+ isLibrary: boolean;
242
+ }): Promise<{ gradle: string | null; manifest: string | null }> {
243
+ const globExcludes = [
244
+ 'node_modules/**',
245
+ '**/build/**',
246
+ '**/debug/**',
247
+ 'Examples/**',
248
+ 'examples/**',
249
+ '**/Pods/**',
250
+ '**/sdks/hermes/android/**',
251
+ '**/src/androidTest/**',
252
+ '**/src/test/**',
253
+ ];
254
+ const gradlePattern = isLibrary ? 'build.gradle{,.kts}' : 'app/build.gradle{,.kts}';
255
+ const [manifests, gradles] = await Promise.all([
256
+ glob('**/AndroidManifest.xml', { cwd: androidDir, ignore: globExcludes }),
257
+ glob(gradlePattern, { cwd: androidDir, ignore: globExcludes }),
258
+ ]);
259
+ const manifest =
260
+ manifests.find((manifest) => manifest.includes('src/main/')) ??
261
+ manifests.sort((a, b) => a.localeCompare(b))[0];
262
+ const gradle = gradles.sort((a, b) => a.localeCompare(b))[0];
263
+ return { gradle: gradle || null, manifest: manifest || null };
264
+ }
@@ -0,0 +1,67 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import requireFromString from 'require-from-string';
4
+ import resolveFrom from 'resolve-from';
5
+
6
+ import type { RNConfigReactNativeConfig } from './reactNativeConfig.types';
7
+ import { fileExistsAsync } from '../fileUtils';
8
+
9
+ let tsMain: typeof import('typescript') | null | undefined = undefined;
10
+
11
+ const mockedNativeModules = path.join(__dirname, '..', '..', 'node_modules_mock');
12
+
13
+ /**
14
+ * Load the `react-native.config.js` or `react-native.config.ts` from the package.
15
+ */
16
+ export async function loadConfigAsync<T extends RNConfigReactNativeConfig>(
17
+ packageRoot: string
18
+ ): Promise<T | null> {
19
+ const configJsPath = path.join(packageRoot, 'react-native.config.js');
20
+ if (await fileExistsAsync(configJsPath)) {
21
+ return requireConfig(configJsPath, await fs.readFile(configJsPath, 'utf8'));
22
+ }
23
+
24
+ const configTsPath = path.join(packageRoot, 'react-native.config.ts');
25
+ if (await fileExistsAsync(configTsPath)) {
26
+ if (tsMain === undefined) {
27
+ const tsPath = resolveFrom.silent(packageRoot, 'typescript');
28
+ if (tsPath) {
29
+ tsMain = require(tsPath);
30
+ }
31
+ } else if (tsMain == null) {
32
+ return null;
33
+ }
34
+
35
+ const configContents = await fs.readFile(configTsPath, 'utf8');
36
+ const transpiledContents = tsMain?.transpileModule(configContents, {
37
+ compilerOptions: {
38
+ module: tsMain.ModuleKind.NodeNext,
39
+ moduleResolution: tsMain.ModuleResolutionKind.NodeNext,
40
+ target: tsMain.ScriptTarget.ESNext,
41
+ },
42
+ });
43
+ const outputText = transpiledContents?.outputText;
44
+
45
+ if (outputText) {
46
+ return requireConfig(configTsPath, outputText);
47
+ }
48
+ }
49
+
50
+ return null;
51
+ }
52
+
53
+ /**
54
+ * Temporarily, we need to mock the community CLI, because
55
+ * some packages are checking the version of the CLI in the `react-native.config.js` file.
56
+ * We can remove this once we remove this check from packages.
57
+ */
58
+ function requireConfig(filepath: string, configContents: string) {
59
+ try {
60
+ const config = requireFromString(configContents, filepath, {
61
+ prependPaths: [mockedNativeModules],
62
+ });
63
+ return config.default ?? config ?? null;
64
+ } catch {
65
+ return null;
66
+ }
67
+ }
@@ -0,0 +1,2 @@
1
+ export * from './reactNativeConfig';
2
+ export * from './reactNativeConfig.types';
@@ -0,0 +1,37 @@
1
+ import fs from 'fs/promises';
2
+ import { glob } from 'glob';
3
+ import path from 'path';
4
+
5
+ import type {
6
+ RNConfigDependencyIos,
7
+ RNConfigReactNativePlatformsConfigIos,
8
+ } from './reactNativeConfig.types';
9
+
10
+ export async function resolveDependencyConfigImplIosAsync(
11
+ packageRoot: string,
12
+ reactNativeConfig: RNConfigReactNativePlatformsConfigIos | null | undefined
13
+ ): Promise<RNConfigDependencyIos | null> {
14
+ if (reactNativeConfig === null) {
15
+ // Skip autolinking for this package.
16
+ return null;
17
+ }
18
+
19
+ const podspecs = await glob('*.podspec', { cwd: packageRoot });
20
+ if (!podspecs?.length) {
21
+ return null;
22
+ }
23
+ const mainPackagePodspec = path.basename(packageRoot) + '.podspec';
24
+ const podspecFile = podspecs.includes(mainPackagePodspec)
25
+ ? mainPackagePodspec
26
+ : podspecs.sort((a, b) => a.localeCompare(b))[0];
27
+ const podspecPath = path.join(packageRoot, podspecFile);
28
+
29
+ const packageJson = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));
30
+
31
+ return {
32
+ podspecPath,
33
+ version: packageJson.version,
34
+ configurations: reactNativeConfig?.configurations || [],
35
+ scriptPhases: reactNativeConfig?.scriptPhases || [],
36
+ };
37
+ }