@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,262 @@
1
+ import commander from 'commander';
2
+ import path from 'path';
3
+
4
+ import {
5
+ findModulesAsync,
6
+ generateModulesProviderAsync,
7
+ generatePackageListAsync,
8
+ getConfiguration,
9
+ getProjectPackageJsonPathAsync,
10
+ mergeLinkingOptionsAsync,
11
+ resolveExtraBuildDependenciesAsync,
12
+ resolveModulesAsync,
13
+ verifySearchResults,
14
+ } from './autolinking';
15
+ import { type RNConfigCommandOptions, createReactNativeConfigAsync } from './reactNativeConfig';
16
+ import type {
17
+ ModuleDescriptor,
18
+ CommonNativeModuleDescriptor,
19
+ GenerateModulesProviderOptions,
20
+ GenerateOptions,
21
+ ResolveOptions,
22
+ SearchOptions,
23
+ SearchResults,
24
+ ModuleDescriptorAndroid,
25
+ ModuleDescriptorIos,
26
+ } from './types';
27
+
28
+ function hasCoreFeatures(
29
+ module: ModuleDescriptor
30
+ ): module is ModuleDescriptorAndroid | ModuleDescriptorIos {
31
+ return (module as CommonNativeModuleDescriptor).coreFeatures !== undefined;
32
+ }
33
+
34
+ /**
35
+ * Registers a command that only searches for available expo modules.
36
+ */
37
+ function registerSearchCommand<OptionsType extends SearchOptions>(
38
+ commandName: string,
39
+ fn: (search: SearchResults, options: OptionsType) => any
40
+ ) {
41
+ return commander
42
+ .command(`${commandName} [paths...]`)
43
+ .option<string[] | null>(
44
+ '-i, --ignore-paths <ignorePaths...>',
45
+ 'Paths to ignore when looking up for modules.',
46
+ (value, previous) => (previous ?? []).concat(value)
47
+ )
48
+ .option<string[] | null>(
49
+ '-e, --exclude <exclude...>',
50
+ 'Package names to exclude when looking up for modules.',
51
+ (value, previous) => (previous ?? []).concat(value)
52
+ )
53
+ .option(
54
+ '-p, --platform [platform]',
55
+ 'The platform that the resulting modules must support. Available options: "apple", "android"',
56
+ 'apple'
57
+ )
58
+ .option('--silent', 'Silence resolution warnings')
59
+ .addOption(
60
+ new commander.Option(
61
+ '--project-root <projectRoot>',
62
+ 'The path to the root of the project'
63
+ ).default(process.cwd(), 'process.cwd()')
64
+ )
65
+ .option(
66
+ '--only-project-deps',
67
+ 'For a monorepo, include only modules that are the project dependencies.',
68
+ true
69
+ )
70
+ .option('--no-only-project-deps', 'Opposite of --only-project-deps', false)
71
+ .action(async (searchPaths, providedOptions) => {
72
+ const options = await mergeLinkingOptionsAsync<OptionsType>(
73
+ searchPaths.length > 0
74
+ ? {
75
+ ...providedOptions,
76
+ searchPaths,
77
+ }
78
+ : providedOptions
79
+ );
80
+ const searchResults = await findModulesAsync(options);
81
+ return await fn(searchResults, options);
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Registers a command that searches for modules and then resolves them for specific platform.
87
+ */
88
+ function registerResolveCommand<OptionsType extends ResolveOptions>(
89
+ commandName: string,
90
+ fn: (search: SearchResults, options: OptionsType) => any
91
+ ) {
92
+ return registerSearchCommand<OptionsType>(commandName, fn);
93
+ }
94
+
95
+ /**
96
+ * Registry the `react-native-config` command.
97
+ */
98
+ function registerReactNativeConfigCommand() {
99
+ return commander
100
+ .command('react-native-config [paths...]')
101
+ .option(
102
+ '-p, --platform [platform]',
103
+ 'The platform that the resulting modules must support. Available options: "android", "ios"',
104
+ 'ios'
105
+ )
106
+ .option(
107
+ '--transitive-linking-dependencies <transitiveLinkingDependencies...>',
108
+ 'The transitive dependencies to include in autolinking. Internally used by fingerprint and only supported react-native-edge-to-edge.'
109
+ )
110
+ .addOption(
111
+ new commander.Option(
112
+ '--project-root <projectRoot>',
113
+ 'The path to the root of the project'
114
+ ).default(process.cwd(), 'process.cwd()')
115
+ )
116
+ .option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false)
117
+ .action(async (searchPaths, providedOptions) => {
118
+ if (!['android', 'ios'].includes(providedOptions.platform)) {
119
+ throw new Error(`Unsupported platform: ${providedOptions.platform}`);
120
+ }
121
+ const projectRoot = path.dirname(
122
+ await getProjectPackageJsonPathAsync(providedOptions.projectRoot)
123
+ );
124
+ const linkingOptions = await mergeLinkingOptionsAsync<SearchOptions>(
125
+ searchPaths.length > 0
126
+ ? {
127
+ ...providedOptions,
128
+ projectRoot,
129
+ searchPaths,
130
+ }
131
+ : {
132
+ ...providedOptions,
133
+ projectRoot,
134
+ }
135
+ );
136
+ const transitiveLinkingDependencies = providedOptions.transitiveLinkingDependencies ?? [];
137
+ const options: RNConfigCommandOptions = {
138
+ platform: linkingOptions.platform,
139
+ projectRoot,
140
+ searchPaths: linkingOptions.searchPaths,
141
+ transitiveLinkingDependencies,
142
+ };
143
+ const results = await createReactNativeConfigAsync(options);
144
+ if (providedOptions.json) {
145
+ console.log(JSON.stringify(results));
146
+ } else {
147
+ console.log(require('util').inspect(results, false, null, true));
148
+ }
149
+ });
150
+ }
151
+
152
+ module.exports = async function (args: string[]) {
153
+ // Searches for available expo modules.
154
+ registerSearchCommand<SearchOptions & { json?: boolean }>('search', async (results, options) => {
155
+ if (options.json) {
156
+ console.log(JSON.stringify(results));
157
+ } else {
158
+ console.log(require('util').inspect(results, false, null, true));
159
+ }
160
+ }).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);
161
+
162
+ // Checks whether there are no resolving issues in the current setup.
163
+ registerSearchCommand('verify', (results, options) => {
164
+ const numberOfDuplicates = verifySearchResults(results, options);
165
+ if (!numberOfDuplicates) {
166
+ console.log('✅ Everything is fine!');
167
+ }
168
+ });
169
+
170
+ // Searches for available expo modules and resolves the results for given platform.
171
+ registerResolveCommand('resolve', async (results, options) => {
172
+ const modules = await resolveModulesAsync(results, options);
173
+ const extraDependencies = await resolveExtraBuildDependenciesAsync(options);
174
+ const configuration = getConfiguration(options);
175
+
176
+ const coreFeatures = [
177
+ ...modules.reduce<Set<string>>((acc, module) => {
178
+ if (hasCoreFeatures(module)) {
179
+ const features = module.coreFeatures ?? [];
180
+ for (const feature of features) {
181
+ acc.add(feature);
182
+ }
183
+ return acc;
184
+ }
185
+
186
+ return acc;
187
+ }, new Set()),
188
+ ];
189
+ if (options.json) {
190
+ console.log(
191
+ JSON.stringify({
192
+ extraDependencies,
193
+ coreFeatures,
194
+ modules,
195
+ ...(configuration ? { configuration } : {}),
196
+ })
197
+ );
198
+ } else {
199
+ console.log(
200
+ require('util').inspect(
201
+ {
202
+ extraDependencies,
203
+ coreFeatures,
204
+ modules,
205
+ ...(configuration ? { configuration } : {}),
206
+ },
207
+ false,
208
+ null,
209
+ true
210
+ )
211
+ );
212
+ }
213
+ }).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);
214
+
215
+ // Generates a source file listing all packages to link.
216
+ // It's deprecated for apple platforms, use `generate-modules-provider` instead.
217
+ registerResolveCommand<GenerateOptions>('generate-package-list', async (results, options) => {
218
+ const modules = options.empty ? [] : await resolveModulesAsync(results, options);
219
+ generatePackageListAsync(modules, options);
220
+ })
221
+ .option(
222
+ '-t, --target <path>',
223
+ 'Path to the target file, where the package list should be written to.'
224
+ )
225
+ .option(
226
+ '-n, --namespace <namespace>',
227
+ 'Java package name under which the package list should be placed.'
228
+ )
229
+ .option(
230
+ '--empty',
231
+ 'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.',
232
+ false
233
+ );
234
+
235
+ // Generates a source file listing all packages to link in the runtime.
236
+ registerResolveCommand<GenerateModulesProviderOptions>(
237
+ 'generate-modules-provider',
238
+ async (results, options) => {
239
+ const packages = options.packages ?? [];
240
+ const modules = await resolveModulesAsync(results, options);
241
+ const filteredModules = modules.filter((module) => packages.includes(module.packageName));
242
+
243
+ generateModulesProviderAsync(filteredModules, options);
244
+ }
245
+ )
246
+ .option(
247
+ '-t, --target <path>',
248
+ 'Path to the target file, where the package list should be written to.'
249
+ )
250
+ .option('--entitlement <path>', 'Path to the Apple code signing entitlements file.')
251
+ .option(
252
+ '-p, --packages <packages...>',
253
+ 'Names of the packages to include in the generated modules provider.'
254
+ );
255
+
256
+ registerReactNativeConfigCommand();
257
+
258
+ await commander
259
+ .version(require('expo-modules-autolinking/package.json').version)
260
+ .description('CLI command that searches for Expo modules to autolink them.')
261
+ .parseAsync(args, { from: 'user' });
262
+ };
@@ -0,0 +1,303 @@
1
+ import fs from 'fs';
2
+ import { glob } from 'glob';
3
+ import path from 'path';
4
+
5
+ import type {
6
+ ExtraDependencies,
7
+ ModuleDescriptorAndroid,
8
+ PackageRevision,
9
+ ResolveOptions,
10
+ } from '../types';
11
+
12
+ const ANDROID_PROPERTIES_FILE = 'gradle.properties';
13
+ const ANDROID_EXTRA_BUILD_DEPS_KEY = 'android.extraMavenRepos';
14
+
15
+ export function getConfiguration(options: ResolveOptions): Record<string, any> | undefined {
16
+ const buildFromSource = options.android?.buildFromSource;
17
+ if (buildFromSource) {
18
+ return { buildFromSource };
19
+ }
20
+ return undefined;
21
+ }
22
+
23
+ /**
24
+ * Generates Java file that contains all autolinked packages.
25
+ */
26
+ export async function generatePackageListAsync(
27
+ modules: ModuleDescriptorAndroid[],
28
+ targetPath: string,
29
+ namespace: string
30
+ ): Promise<void> {
31
+ const generatedFileContent = await generatePackageListFileContentAsync(modules, namespace);
32
+ const parentPath = path.dirname(targetPath);
33
+ if (!fs.existsSync(parentPath)) {
34
+ await fs.promises.mkdir(parentPath, { recursive: true });
35
+ }
36
+ await fs.promises.writeFile(targetPath, generatedFileContent, 'utf8');
37
+ }
38
+
39
+ export function isAndroidProject(projectRoot: string): boolean {
40
+ return (
41
+ fs.existsSync(path.join(projectRoot, 'build.gradle')) ||
42
+ fs.existsSync(path.join(projectRoot, 'build.gradle.kts'))
43
+ );
44
+ }
45
+
46
+ export async function resolveModuleAsync(
47
+ packageName: string,
48
+ revision: PackageRevision
49
+ ): Promise<ModuleDescriptorAndroid | null> {
50
+ // TODO: Relative source dir should be configurable through the module config.
51
+
52
+ // Don't link itself... :D
53
+ if (packageName === '@unimodules/react-native-adapter') {
54
+ return null;
55
+ }
56
+
57
+ const plugins = (revision.config?.androidGradlePlugins() ?? []).map(
58
+ ({ id, group, sourceDir, applyToRootProject }) => ({
59
+ id,
60
+ group,
61
+ sourceDir: path.join(revision.path, sourceDir),
62
+ applyToRootProject: applyToRootProject ?? true,
63
+ })
64
+ );
65
+
66
+ const defaultProjectName = convertPackageToProjectName(packageName);
67
+
68
+ const androidProjects = revision.config
69
+ ?.androidProjects(defaultProjectName)
70
+ ?.filter((project) => {
71
+ return !project.isDefault || isAndroidProject(path.join(revision.path, project.path));
72
+ });
73
+
74
+ // Just in case where the module doesn't have its own `build.gradle`/`settings.gradle`.
75
+ if (!androidProjects?.length) {
76
+ if (!plugins.length) {
77
+ return null;
78
+ }
79
+
80
+ return {
81
+ packageName,
82
+ plugins,
83
+ };
84
+ }
85
+
86
+ const projects = androidProjects.map((project) => {
87
+ const projectPath = path.join(revision.path, project.path);
88
+
89
+ const aarProjects = (project.gradleAarProjects ?? [])?.map((aarProject) => {
90
+ const projectName = `${defaultProjectName}$${aarProject.name}`;
91
+ const projectDir = path.join(projectPath, 'build', projectName);
92
+ return {
93
+ name: projectName,
94
+ aarFilePath: path.join(revision.path, aarProject.aarFilePath),
95
+ projectDir,
96
+ };
97
+ });
98
+
99
+ const { publication } = project;
100
+ const shouldUsePublicationScriptPath = project.shouldUsePublicationScriptPath
101
+ ? path.join(revision.path, project.shouldUsePublicationScriptPath)
102
+ : undefined;
103
+
104
+ return {
105
+ name: project.name,
106
+ sourceDir: projectPath,
107
+ modules: project.modules ?? [],
108
+ ...(shouldUsePublicationScriptPath ? { shouldUsePublicationScriptPath } : {}),
109
+ ...(publication ? { publication } : {}),
110
+ ...(aarProjects?.length > 0 ? { aarProjects } : {}),
111
+ };
112
+ });
113
+
114
+ const coreFeatures = revision.config?.coreFeatures() ?? [];
115
+
116
+ return {
117
+ packageName,
118
+ projects,
119
+ ...(plugins?.length > 0 ? { plugins } : {}),
120
+ ...(coreFeatures.length > 0 ? { coreFeatures } : {}),
121
+ };
122
+ }
123
+
124
+ export async function resolveExtraBuildDependenciesAsync(
125
+ projectNativeRoot: string
126
+ ): Promise<ExtraDependencies | null> {
127
+ const extraMavenReposString = await resolveGradlePropertyAsync(
128
+ projectNativeRoot,
129
+ ANDROID_EXTRA_BUILD_DEPS_KEY
130
+ );
131
+ if (extraMavenReposString) {
132
+ try {
133
+ return JSON.parse(extraMavenReposString);
134
+ } catch {}
135
+ }
136
+ return null;
137
+ }
138
+
139
+ export async function resolveGradlePropertyAsync(
140
+ projectNativeRoot: string,
141
+ propertyKey: string
142
+ ): Promise<string | null> {
143
+ const propsFile = path.join(projectNativeRoot, ANDROID_PROPERTIES_FILE);
144
+ try {
145
+ const contents = await fs.promises.readFile(propsFile, 'utf8');
146
+ const propertyValue = searchGradlePropertyFirst(contents, propertyKey);
147
+ if (propertyValue) {
148
+ return propertyValue;
149
+ }
150
+ } catch {}
151
+ return null;
152
+ }
153
+
154
+ /**
155
+ * Generates the string to put into the generated package list.
156
+ */
157
+ async function generatePackageListFileContentAsync(
158
+ modules: ModuleDescriptorAndroid[],
159
+ namespace: string
160
+ ): Promise<string> {
161
+ // TODO: Instead of ignoring `expo` here, make the package class paths configurable from `expo-module.config.json`.
162
+ const packagesClasses = await findAndroidPackagesAsync(
163
+ modules.filter((module) => module.packageName !== 'expo')
164
+ );
165
+
166
+ const modulesClasses = await findAndroidModules(modules);
167
+
168
+ return `package ${namespace};
169
+
170
+ import java.util.Arrays;
171
+ import java.util.List;
172
+ import expo.modules.core.interfaces.Package;
173
+ import expo.modules.kotlin.modules.Module;
174
+ import expo.modules.kotlin.ModulesProvider;
175
+
176
+ public class ExpoModulesPackageList implements ModulesProvider {
177
+ private static class LazyHolder {
178
+ static final List<Package> packagesList = Arrays.<Package>asList(
179
+ ${packagesClasses.map((packageClass) => ` new ${packageClass}()`).join(',\n')}
180
+ );
181
+
182
+ static final List<Class<? extends Module>> modulesList = Arrays.<Class<? extends Module>>asList(
183
+ ${modulesClasses.map((moduleClass) => ` ${moduleClass}.class`).join(',\n')}
184
+ );
185
+ }
186
+
187
+ public static List<Package> getPackageList() {
188
+ return LazyHolder.packagesList;
189
+ }
190
+
191
+ @Override
192
+ public List<Class<? extends Module>> getModulesList() {
193
+ return LazyHolder.modulesList;
194
+ }
195
+ }
196
+ `;
197
+ }
198
+
199
+ function findAndroidModules(modules: ModuleDescriptorAndroid[]): string[] {
200
+ const projects = modules.flatMap((module) => module.projects ?? []);
201
+
202
+ const modulesToProvide = projects.filter((project) => project.modules?.length > 0);
203
+ const classNames = ([] as string[]).concat(...modulesToProvide.map((module) => module.modules));
204
+ return classNames;
205
+ }
206
+
207
+ async function findAndroidPackagesAsync(modules: ModuleDescriptorAndroid[]): Promise<string[]> {
208
+ const classes: string[] = [];
209
+
210
+ const flattenedSourceDirList: string[] = [];
211
+ for (const module of modules) {
212
+ for (const project of module.projects ?? []) {
213
+ flattenedSourceDirList.push(project.sourceDir);
214
+ }
215
+ }
216
+
217
+ await Promise.all(
218
+ flattenedSourceDirList.map(async (sourceDir) => {
219
+ const files = await glob('**/*Package.{java,kt}', {
220
+ cwd: sourceDir,
221
+ });
222
+
223
+ for (const file of files) {
224
+ const fileContent = await fs.promises.readFile(path.join(sourceDir, file), 'utf8');
225
+
226
+ const packageRegex = (() => {
227
+ if (process.env.EXPO_SHOULD_USE_LEGACY_PACKAGE_INTERFACE) {
228
+ return /\bimport\s+org\.unimodules\.core\.(interfaces\.Package|BasePackage)\b/;
229
+ } else {
230
+ return /\bimport\s+expo\.modules\.core\.(interfaces\.Package|BasePackage)\b/;
231
+ }
232
+ })();
233
+
234
+ // Very naive check to skip non-expo packages
235
+ if (!packageRegex.test(fileContent)) {
236
+ continue;
237
+ }
238
+
239
+ const classPathMatches = fileContent.match(/^package ([\w.]+)\b/m);
240
+
241
+ if (classPathMatches) {
242
+ const basename = path.basename(file, path.extname(file));
243
+ classes.push(`${classPathMatches[1]}.${basename}`);
244
+ }
245
+ }
246
+ })
247
+ );
248
+ return classes.sort();
249
+ }
250
+
251
+ /**
252
+ * Converts the package name to Android's project name.
253
+ * `/` path will transform as `-`
254
+ *
255
+ * Example: `@expo/example` + `android/build.gradle` → `expo-example`
256
+ */
257
+ export function convertPackageToProjectName(packageName: string): string {
258
+ return packageName.replace(/^@/g, '').replace(/\W+/g, '-');
259
+ }
260
+
261
+ /**
262
+ * Converts the package name and gradle file path to Android's project name.
263
+ * `$` to indicate subprojects
264
+ * `/` path will transform as `-`
265
+ *
266
+ * Example: `@expo/example` + `android/build.gradle` → `expo-example`
267
+ *
268
+ * Example: multiple projects
269
+ * - `expo-test` + `android/build.gradle` → `react-native-third-party`
270
+ * - `expo-test` + `subproject/build.gradle` → `react-native-third-party$subproject`
271
+ */
272
+ export function convertPackageWithGradleToProjectName(
273
+ packageName: string,
274
+ buildGradleFile: string
275
+ ): string {
276
+ const name = convertPackageToProjectName(packageName);
277
+ const baseDir = path.dirname(buildGradleFile).replace(/\//g, '-');
278
+ return baseDir === 'android' ? name : `${name}$${baseDir}`;
279
+ }
280
+
281
+ /**
282
+ * Given the contents of a `gradle.properties` file,
283
+ * searches for a property with the given name.
284
+ *
285
+ * This function will return the first property found with the given name.
286
+ * The implementation follows config-plugins and
287
+ * tries to align the behavior with the `withGradleProperties` plugin.
288
+ */
289
+ export function searchGradlePropertyFirst(contents: string, propertyName: string): string | null {
290
+ const lines = contents.split('\n');
291
+ for (let i = 0; i < lines.length; i++) {
292
+ const line = lines[i].trim();
293
+ if (line && !line.startsWith('#')) {
294
+ const eok = line.indexOf('=');
295
+ const key = line.slice(0, eok);
296
+ if (key === propertyName) {
297
+ const value = line.slice(eok + 1, line.length);
298
+ return value;
299
+ }
300
+ }
301
+ }
302
+ return null;
303
+ }