expo-modules-autolinking 0.5.4 → 0.7.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 (60) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +3 -3
  3. package/build/ExpoModuleConfig.d.ts +12 -4
  4. package/build/ExpoModuleConfig.js +31 -7
  5. package/build/ExpoModuleConfig.js.map +1 -1
  6. package/build/ReactImportsPatcher.js +3 -3
  7. package/build/ReactImportsPatcher.js.map +1 -1
  8. package/build/autolinking/findModules.d.ts +5 -0
  9. package/build/autolinking/findModules.js +207 -0
  10. package/build/autolinking/findModules.js.map +1 -0
  11. package/build/autolinking/generatePackageList.d.ts +6 -0
  12. package/build/autolinking/generatePackageList.js +23 -0
  13. package/build/autolinking/generatePackageList.js.map +1 -0
  14. package/build/autolinking/index.d.ts +5 -0
  15. package/build/autolinking/index.js +17 -0
  16. package/build/autolinking/index.js.map +1 -0
  17. package/build/autolinking/mergeLinkingOptions.d.ts +17 -0
  18. package/build/autolinking/mergeLinkingOptions.js +79 -0
  19. package/build/autolinking/mergeLinkingOptions.js.map +1 -0
  20. package/build/autolinking/resolveModules.d.ts +5 -0
  21. package/build/autolinking/resolveModules.js +23 -0
  22. package/build/autolinking/resolveModules.js.map +1 -0
  23. package/build/autolinking/verifySearchResults.d.ts +5 -0
  24. package/build/autolinking/verifySearchResults.js +34 -0
  25. package/build/autolinking/verifySearchResults.js.map +1 -0
  26. package/build/index.js +1 -1
  27. package/build/index.js.map +1 -1
  28. package/build/platforms/android.d.ts +15 -3
  29. package/build/platforms/android.js +51 -20
  30. package/build/platforms/android.js.map +1 -1
  31. package/build/platforms/ios.d.ts +5 -4
  32. package/build/platforms/ios.js +36 -23
  33. package/build/platforms/ios.js.map +1 -1
  34. package/build/types.d.ts +46 -2
  35. package/build/types.js.map +1 -1
  36. package/package.json +4 -3
  37. package/scripts/android/autolinking_implementation.gradle +51 -26
  38. package/scripts/ios/autolinking_manager.rb +21 -17
  39. package/scripts/ios/cocoapods/pod_target.rb +53 -0
  40. package/scripts/ios/cocoapods/sandbox.rb +0 -19
  41. package/scripts/ios/cocoapods/umbrella_header_generator.rb +22 -0
  42. package/scripts/ios/package.rb +22 -9
  43. package/scripts/ios/react_import_patcher.rb +3 -3
  44. package/src/ExpoModuleConfig.ts +34 -7
  45. package/src/ReactImportsPatcher.ts +3 -3
  46. package/src/autolinking/findModules.ts +244 -0
  47. package/src/autolinking/generatePackageList.ts +22 -0
  48. package/src/autolinking/index.ts +12 -0
  49. package/src/autolinking/mergeLinkingOptions.ts +98 -0
  50. package/src/autolinking/resolveModules.ts +32 -0
  51. package/src/autolinking/verifySearchResults.ts +33 -0
  52. package/src/index.ts +1 -1
  53. package/src/platforms/android.ts +63 -25
  54. package/src/platforms/ios.ts +52 -28
  55. package/src/types.ts +53 -2
  56. package/build/autolinking.d.ts +0 -34
  57. package/build/autolinking.js +0 -237
  58. package/build/autolinking.js.map +0 -1
  59. package/scripts/ios/React-Core.modulemap +0 -6
  60. package/src/autolinking.ts +0 -300
package/CHANGELOG.md CHANGED
@@ -10,6 +10,33 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.7.0 — 2022-04-18
14
+
15
+ - Update require logic to find transitive deps that would not be hoisted at the top of the monorepo ([#16419](https://github.com/expo/expo/pull/16419) by [@Titozzz](https://github.com/Titozzz))
16
+ - Fix `cannot cast object 'ExpoAutolinkingManager@' with class 'ExpoAutolinkingManager' to class 'ExpoAutolinkingManager'` on Android when a project is using `buildSrc`. ([#16545](https://github.com/expo/expo/pull/16545) by [@lukmccall](https://github.com/lukmccall))
17
+
18
+ ### 🎉 New features
19
+
20
+ - Add `ios.swiftModuleName` to module config. ([#16260](https://github.com/expo/expo/pull/16260) by [@esamelson](https://github.com/esamelson))
21
+ - Added support for linking multiple podspecs and Gradle projects in a package. ([#16511](https://github.com/expo/expo/pull/16511) by [@kudo](https://github.com/kudo))
22
+
23
+ ### 🐛 Bug fixes
24
+
25
+ - Fixed `expo_patch_react_imports!` not work when the app project is in a folder with spaces. ([#16794](https://github.com/expo/expo/pull/16794) by [@Kudo](https://github.com/Kudo))
26
+
27
+ ## 0.6.0 — 2022-01-26
28
+
29
+ ### ⚠️ Notices
30
+
31
+ - Expose `findModulesAsync` from `expo-modules-autolinking/build/autolinking` again. ([#15950](https://github.com/expo/expo/pull/15950) by [@EvanBacon](https://github.com/EvanBacon))
32
+ - Deprecated `modulesClassNames` in favor of `modules` in the Expo module config. ([#15852](https://github.com/expo/expo/pull/15852) by [@tsapeta](https://github.com/tsapeta))
33
+
34
+ ## 0.5.5 — 2022-01-05
35
+
36
+ ### 🐛 Bug fixes
37
+
38
+ - Fix `umbrella directory '../../Public/React-Core/React' not found` build error when in `use_frameworks!` mode. ([#15773](https://github.com/expo/expo/pull/15773) by [@kudo](https://github.com/kudo))
39
+
13
40
  ## 0.5.4 — 2021-12-29
14
41
 
15
42
  ### 🐛 Bug fixes
@@ -37,6 +64,7 @@ _This version does not introduce any user-facing changes._
37
64
  ### 🎉 New features
38
65
 
39
66
  - Patch React podspecs on the fly to support Swift integration. ([#15299](https://github.com/expo/expo/pull/15299) by [@kudo](https://github.com/kudo))
67
+ - Add `nativeModulesDir` option to specify app's custom native modules location. ([#15415](https://github.com/expo/expo/pull/15415) by [@barthap](https://github.com/barthap))
40
68
 
41
69
  ## 0.4.0 — 2021-11-17
42
70
 
package/README.md CHANGED
@@ -4,12 +4,12 @@ Scripts that autolink Expo modules.
4
4
 
5
5
  # API documentation
6
6
 
7
- - [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/module-autolinking.md)
8
- - [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/module-autolinking/)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/module-autolinking.md)
8
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/module-autolinking/)
9
9
 
10
10
  # Installation in managed Expo projects
11
11
 
12
- For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
12
+ For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
@@ -12,7 +12,7 @@ export declare class ExpoModuleConfig {
12
12
  /**
13
13
  * Returns a list of names of Swift native modules classes to put to the generated modules provider file.
14
14
  */
15
- iosModulesClassNames(): string[];
15
+ iosModules(): string[];
16
16
  /**
17
17
  * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
18
18
  */
@@ -22,13 +22,21 @@ export declare class ExpoModuleConfig {
22
22
  */
23
23
  iosReactDelegateHandlers(): string[];
24
24
  /**
25
- * Returns a podspec path defined by the module author.
25
+ * Returns podspec paths defined by the module author.
26
26
  */
27
- iosPodspecPath(): string | undefined;
27
+ iosPodspecPaths(): string[];
28
+ /**
29
+ * Returns the product module names, if defined by the module author.
30
+ */
31
+ iosSwiftModuleNames(): string[];
28
32
  /**
29
33
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
30
34
  */
31
- androidModulesClassNames(): string[];
35
+ androidModules(): string[];
36
+ /**
37
+ * Returns build.gradle file paths defined by the module author.
38
+ */
39
+ androidGradlePaths(): string[];
32
40
  /**
33
41
  * Returns serializable raw config.
34
42
  */
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireAndResolveExpoModuleConfig = exports.ExpoModuleConfig = void 0;
4
+ function arrayize(value) {
5
+ if (Array.isArray(value)) {
6
+ return value;
7
+ }
8
+ return value != null ? [value] : [];
9
+ }
4
10
  /**
5
11
  * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).
6
12
  */
@@ -18,9 +24,11 @@ class ExpoModuleConfig {
18
24
  /**
19
25
  * Returns a list of names of Swift native modules classes to put to the generated modules provider file.
20
26
  */
21
- iosModulesClassNames() {
27
+ iosModules() {
22
28
  var _a, _b;
23
- return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.modulesClassNames) !== null && _b !== void 0 ? _b : [];
29
+ const iosConfig = this.rawConfig.ios;
30
+ // `modulesClassNames` is a legacy name for the same config.
31
+ return (_b = (_a = iosConfig === null || iosConfig === void 0 ? void 0 : iosConfig.modules) !== null && _a !== void 0 ? _a : iosConfig === null || iosConfig === void 0 ? void 0 : iosConfig.modulesClassNames) !== null && _b !== void 0 ? _b : [];
24
32
  }
25
33
  /**
26
34
  * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
@@ -37,18 +45,34 @@ class ExpoModuleConfig {
37
45
  return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.reactDelegateHandlers) !== null && _b !== void 0 ? _b : [];
38
46
  }
39
47
  /**
40
- * Returns a podspec path defined by the module author.
48
+ * Returns podspec paths defined by the module author.
49
+ */
50
+ iosPodspecPaths() {
51
+ var _a;
52
+ return arrayize((_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.podspecPath);
53
+ }
54
+ /**
55
+ * Returns the product module names, if defined by the module author.
41
56
  */
42
- iosPodspecPath() {
57
+ iosSwiftModuleNames() {
43
58
  var _a;
44
- return (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.podspecPath;
59
+ return arrayize((_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.swiftModuleName);
45
60
  }
46
61
  /**
47
62
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
48
63
  */
49
- androidModulesClassNames() {
64
+ androidModules() {
65
+ var _a, _b;
66
+ const androidConfig = this.rawConfig.android;
67
+ // `modulesClassNames` is a legacy name for the same config.
68
+ return (_b = (_a = androidConfig === null || androidConfig === void 0 ? void 0 : androidConfig.modules) !== null && _a !== void 0 ? _a : androidConfig === null || androidConfig === void 0 ? void 0 : androidConfig.modulesClassNames) !== null && _b !== void 0 ? _b : [];
69
+ }
70
+ /**
71
+ * Returns build.gradle file paths defined by the module author.
72
+ */
73
+ androidGradlePaths() {
50
74
  var _a, _b;
51
- return (_b = (_a = this.rawConfig.android) === null || _a === void 0 ? void 0 : _a.modulesClassNames) !== null && _b !== void 0 ? _b : [];
75
+ return arrayize((_b = (_a = this.rawConfig.android) === null || _a === void 0 ? void 0 : _a.gradlePath) !== null && _b !== void 0 ? _b : []);
52
76
  }
53
77
  /**
54
78
  * Returns serializable raw config.
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,oBAAoB;;QAClB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,yBAAyB;;QACvB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,sBAAsB,mCAAI,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,qBAAqB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,cAAc;;QACZ,OAAO,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,WAAW,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAnDD,4CAmDC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,kDAAkD;IAClD,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { RawExpoModuleConfig, SupportedPlatform } from './types';\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModulesClassNames() {\n return this.rawConfig.ios?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns a podspec path defined by the module author.\n */\n iosPodspecPath(): string | undefined {\n return this.rawConfig.ios?.podspecPath;\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModulesClassNames() {\n return this.rawConfig.android?.modulesClassNames ?? [];\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]}
1
+ {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU;;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAErC,4DAA4D;QAC5D,OAAO,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,mCAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,mCAAI,EAAE,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,yBAAyB;;QACvB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,sBAAsB,mCAAI,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,qBAAqB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,eAAe;;QACb,OAAO,QAAQ,CAAC,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,WAAW,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,mBAAmB;;QACjB,OAAO,QAAQ,CAAC,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,eAAe,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,cAAc;;QACZ,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAE7C,4DAA4D;QAC5D,OAAO,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,iBAAiB,mCAAI,EAAE,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,kBAAkB;;QAChB,OAAO,QAAQ,CAAC,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,0CAAE,UAAU,mCAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAvED,4CAuEC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,kDAAkD;IAClD,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { RawExpoModuleConfig, SupportedPlatform } from './types';\n\nfunction arrayize<T>(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModules() {\n const iosConfig = this.rawConfig.ios;\n\n // `modulesClassNames` is a legacy name for the same config.\n return iosConfig?.modules ?? iosConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n iosPodspecPaths(): string[] {\n return arrayize(this.rawConfig.ios?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n iosSwiftModuleNames(): string[] {\n return arrayize(this.rawConfig.ios?.swiftModuleName);\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModules() {\n const androidConfig = this.rawConfig.android;\n\n // `modulesClassNames` is a legacy name for the same config.\n return androidConfig?.modules ?? androidConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns build.gradle file paths defined by the module author.\n */\n androidGradlePaths(): string[] {\n return arrayize(this.rawConfig.android?.gradlePath ?? []);\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]}
@@ -70,9 +70,9 @@ async function patchFileAsync(headerSet, file, dryRun) {
70
70
  });
71
71
  if (changed) {
72
72
  console.log(`Patching imports for file: ${file}`);
73
- }
74
- if (!dryRun) {
75
- await fs_extra_1.default.writeFile(file, transformContent);
73
+ if (!dryRun) {
74
+ await fs_extra_1.default.writeFile(file, transformContent);
75
+ }
76
76
  }
77
77
  }
78
78
  exports.patchFileAsync = patchFileAsync;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactImportsPatcher.js","sourceRoot":"","sources":["../src/ReactImportsPatcher.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;;;;AAE9D,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAAC,IAAc,EAAE,OAAiC;IAC5F,MAAM,SAAS,GAAG,MAAM,2BAA2B,CACjD,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CACxE,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AALD,wDAKC;AAED;;GAEG;AACH,KAAK,UAAU,2BAA2B,CAAC,cAAsB;IAC/D,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAI,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC;IACzD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAAC,SAAsB,EAAE,IAAY,EAAE,MAAe;IACxF,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,IAAI,gBAAgB,GAAG,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AAE,CAAC,CAAC;KACnD;IACD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;KAC5C;AACH,CAAC;AAvDD,wCAuDC;AAED;;;;;GAKG;AACH,KAAK,UAAU,aAAa,CAAC,SAAsB,EAAE,GAAW,EAAE,MAAe;IAC/E,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAI,EAAC,eAAe,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC","sourcesContent":["// Copyright 2018-present 650 Industries. All rights reserved.\n\nimport glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { PatchReactImportsOptions } from './types';\n\n/**\n * Remove all double-quoted react header imports\n * @param dirs target directories to patch\n * @param options PatchReactImportsOptions\n */\nexport async function patchReactImportsAsync(dirs: string[], options: PatchReactImportsOptions) {\n const headerSet = await generateReactHeaderSetAsync(\n path.join(options.podsRoot, 'Headers', 'Public', 'React-Core', 'React')\n );\n await Promise.all(dirs.map((dir) => patchDirAsync(headerSet, dir, options.dryRun)));\n}\n\n/**\n * Generate `React-Core` public header names as a set, will transform necessary headers based on this set.\n */\nasync function generateReactHeaderSetAsync(reactHeaderDir: string): Promise<Set<string>> {\n const files = await glob('*.h', { cwd: reactHeaderDir });\n return new Set(files);\n}\n\n/**\n * Patch imports from a file\n * @param headerSet prebuilt React-Core header set\n * @param file target patch file\n * @param dryRun true if not writing changes to file\n */\nexport async function patchFileAsync(headerSet: Set<string>, file: string, dryRun: boolean) {\n let changed = false;\n const content = await fs.readFile(file, 'utf-8');\n let transformContent = content.replace(\n /^#import\\s+\"(.+)\"$/gm,\n (match: string, headerName: string): string => {\n // `#import \"RCTBridge.h\"` -> `#import <React/RCTBridge.h>`\n if (headerSet.has(headerName)) {\n changed = true;\n return `#import <React/${headerName}>`;\n }\n\n // `#import \"React/RCTBridge.h\"` -> `#import <React/RCTBridge.h>`\n if (headerName.startsWith('React/')) {\n const name = headerName.substring(6);\n if (headerSet.has(name)) {\n changed = true;\n return `#import <React/${name}>`;\n }\n }\n\n // Otherwise, return original import\n return match;\n }\n );\n\n transformContent = transformContent.replace(\n /^#(if|elif)\\s+__has_include\\(\"(.+)\"\\)$/gm,\n (match: string, ifPrefix: string, headerName: string): string => {\n // `#if __has_include(\"RCTBridge.h\")` -> `#if __has_include(<React/RCTBridge.h>)`\n if (headerSet.has(headerName)) {\n changed = true;\n return `#${ifPrefix} __has_include(<React/${headerName}>)`;\n }\n\n // `#if __has_include(\"React/RCTBridge.h\")` -> `#if __has_include(<React/RCTBridge.h>)`\n if (headerName.startsWith('React/')) {\n const name = headerName.substring(6);\n if (headerSet.has(name)) {\n changed = true;\n return `#${ifPrefix} __has_include(<React/${name}>)`;\n }\n }\n\n // Otherwise, return original import\n return match;\n }\n );\n\n if (changed) {\n console.log(`Patching imports for file: ${file}`);\n }\n if (!dryRun) {\n await fs.writeFile(file, transformContent);\n }\n}\n\n/**\n * Patch imports from a directory\n * @param headerSet prebuilt React-Core header set\n * @param file target patch file\n * @param dryRun true if not writing changes to file\n */\nasync function patchDirAsync(headerSet: Set<string>, dir: string, dryRun: boolean) {\n const files = await glob('**/*.{h,m,mm}', { cwd: dir, absolute: true });\n return Promise.all(files.map((file) => patchFileAsync(headerSet, file, dryRun)));\n}\n"]}
1
+ {"version":3,"file":"ReactImportsPatcher.js","sourceRoot":"","sources":["../src/ReactImportsPatcher.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;;;;AAE9D,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;;;GAIG;AACI,KAAK,UAAU,sBAAsB,CAAC,IAA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AI,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC","sourcesContent":["// Copyright 2018-present 650 Industries. All rights reserved.\n\nimport glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { PatchReactImportsOptions } from './types';\n\n/**\n * Remove all double-quoted react header imports\n * @param dirs target directories to patch\n * @param options PatchReactImportsOptions\n */\nexport async function patchReactImportsAsync(dirs: string[], options: PatchReactImportsOptions) {\n const headerSet = await generateReactHeaderSetAsync(\n path.join(options.podsRoot, 'Headers', 'Public', 'React-Core', 'React')\n );\n await Promise.all(dirs.map((dir) => patchDirAsync(headerSet, dir, options.dryRun)));\n}\n\n/**\n * Generate `React-Core` public header names as a set, will transform necessary headers based on this set.\n */\nasync function generateReactHeaderSetAsync(reactHeaderDir: string): Promise<Set<string>> {\n const files = await glob('*.h', { cwd: reactHeaderDir });\n return new Set(files);\n}\n\n/**\n * Patch imports from a file\n * @param headerSet prebuilt React-Core header set\n * @param file target patch file\n * @param dryRun true if not writing changes to file\n */\nexport async function patchFileAsync(headerSet: Set<string>, file: string, dryRun: boolean) {\n let changed = false;\n const content = await fs.readFile(file, 'utf-8');\n let transformContent = content.replace(\n /^#import\\s+\"(.+)\"$/gm,\n (match: string, headerName: string): string => {\n // `#import \"RCTBridge.h\"` -> `#import <React/RCTBridge.h>`\n if (headerSet.has(headerName)) {\n changed = true;\n return `#import <React/${headerName}>`;\n }\n\n // `#import \"React/RCTBridge.h\"` -> `#import <React/RCTBridge.h>`\n if (headerName.startsWith('React/')) {\n const name = headerName.substring(6);\n if (headerSet.has(name)) {\n changed = true;\n return `#import <React/${name}>`;\n }\n }\n\n // Otherwise, return original import\n return match;\n }\n );\n\n transformContent = transformContent.replace(\n /^#(if|elif)\\s+__has_include\\(\"(.+)\"\\)$/gm,\n (match: string, ifPrefix: string, headerName: string): string => {\n // `#if __has_include(\"RCTBridge.h\")` -> `#if __has_include(<React/RCTBridge.h>)`\n if (headerSet.has(headerName)) {\n changed = true;\n return `#${ifPrefix} __has_include(<React/${headerName}>)`;\n }\n\n // `#if __has_include(\"React/RCTBridge.h\")` -> `#if __has_include(<React/RCTBridge.h>)`\n if (headerName.startsWith('React/')) {\n const name = headerName.substring(6);\n if (headerSet.has(name)) {\n changed = true;\n return `#${ifPrefix} __has_include(<React/${name}>)`;\n }\n }\n\n // Otherwise, return original import\n return match;\n }\n );\n\n if (changed) {\n console.log(`Patching imports for file: ${file}`);\n if (!dryRun) {\n await fs.writeFile(file, transformContent);\n }\n }\n}\n\n/**\n * Patch imports from a directory\n * @param headerSet prebuilt React-Core header set\n * @param file target patch file\n * @param dryRun true if not writing changes to file\n */\nasync function patchDirAsync(headerSet: Set<string>, dir: string, dryRun: boolean) {\n const files = await glob('**/*.{h,m,mm}', { cwd: dir, absolute: true });\n return Promise.all(files.map((file) => patchFileAsync(headerSet, file, dryRun)));\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { SearchOptions, SearchResults } from '../types';
2
+ /**
3
+ * Searches for modules to link based on given config.
4
+ */
5
+ export declare function findModulesAsync(providedOptions: SearchOptions): Promise<SearchResults>;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findModulesAsync = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fast_glob_1 = __importDefault(require("fast-glob"));
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const module_1 = require("module");
11
+ const path_1 = __importDefault(require("path"));
12
+ const ExpoModuleConfig_1 = require("../ExpoModuleConfig");
13
+ const mergeLinkingOptions_1 = require("./mergeLinkingOptions");
14
+ // Names of the config files. From lowest to highest priority.
15
+ const EXPO_MODULE_CONFIG_FILENAMES = ['unimodule.json', 'expo-module.config.json'];
16
+ /**
17
+ * Searches for modules to link based on given config.
18
+ */
19
+ async function findModulesAsync(providedOptions) {
20
+ var _a;
21
+ const options = await (0, mergeLinkingOptions_1.mergeLinkingOptionsAsync)(providedOptions);
22
+ const results = new Map();
23
+ const nativeModuleNames = new Set();
24
+ // custom native modules should be resolved first so that they can override other modules
25
+ const searchPaths = options.nativeModulesDir && fs_extra_1.default.existsSync(options.nativeModulesDir)
26
+ ? [options.nativeModulesDir, ...options.searchPaths]
27
+ : options.searchPaths;
28
+ for (const searchPath of searchPaths) {
29
+ const isNativeModulesDir = searchPath === options.nativeModulesDir;
30
+ const packageConfigPaths = await findPackagesConfigPathsAsync(searchPath);
31
+ for (const packageConfigPath of packageConfigPaths) {
32
+ const packagePath = await fs_extra_1.default.realpath(path_1.default.join(searchPath, path_1.default.dirname(packageConfigPath)));
33
+ const expoModuleConfig = (0, ExpoModuleConfig_1.requireAndResolveExpoModuleConfig)(path_1.default.join(packagePath, path_1.default.basename(packageConfigPath)));
34
+ const { name, version } = resolvePackageNameAndVersion(packagePath, {
35
+ fallbackToDirName: isNativeModulesDir,
36
+ });
37
+ // we ignore the `exclude` option for custom native modules
38
+ if ((!isNativeModulesDir && ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(name))) ||
39
+ !expoModuleConfig.supportsPlatform(options.platform)) {
40
+ continue;
41
+ }
42
+ // add the current revision to the results
43
+ const currentRevision = {
44
+ path: packagePath,
45
+ version,
46
+ config: expoModuleConfig,
47
+ };
48
+ addRevisionToResults(results, name, currentRevision);
49
+ // if the module is a native module, we need to add it to the nativeModuleNames set
50
+ if (isNativeModulesDir && !nativeModuleNames.has(name)) {
51
+ nativeModuleNames.add(name);
52
+ }
53
+ }
54
+ }
55
+ const searchResults = Object.fromEntries(results.entries());
56
+ // It doesn't make much sense to strip modules if there is only one search path.
57
+ // (excluding custom native modules path)
58
+ // Workspace root usually doesn't specify all its dependencies (see Expo Go),
59
+ // so in this case we should link everything.
60
+ if (options.searchPaths.length <= 1) {
61
+ return searchResults;
62
+ }
63
+ return filterToProjectDependencies(searchResults, {
64
+ ...providedOptions,
65
+ // Custom native modules are not filtered out
66
+ // when they're not specified in package.json dependencies.
67
+ alwaysIncludedPackagesNames: nativeModuleNames,
68
+ });
69
+ }
70
+ exports.findModulesAsync = findModulesAsync;
71
+ /**
72
+ * Returns the priority of the config at given path. Higher number means higher priority.
73
+ */
74
+ function configPriority(fullpath) {
75
+ return EXPO_MODULE_CONFIG_FILENAMES.indexOf(path_1.default.basename(fullpath));
76
+ }
77
+ /**
78
+ * Adds {@link revision} to the {@link results} map
79
+ * or to package duplicates if it already exists.
80
+ * @param results [mutable] yet resolved packages map
81
+ * @param name resolved package name
82
+ * @param revision resolved package revision
83
+ */
84
+ function addRevisionToResults(results, name, revision) {
85
+ var _a, _b, _c, _d, _e;
86
+ if (!results.has(name)) {
87
+ // The revision that was found first will be the main one.
88
+ // An array of duplicates and the config are needed only here.
89
+ results.set(name, {
90
+ ...revision,
91
+ duplicates: [],
92
+ });
93
+ }
94
+ else if (((_a = results.get(name)) === null || _a === void 0 ? void 0 : _a.path) !== revision.path &&
95
+ ((_c = (_b = results.get(name)) === null || _b === void 0 ? void 0 : _b.duplicates) === null || _c === void 0 ? void 0 : _c.every(({ path }) => path !== revision.path))) {
96
+ const { config, duplicates, ...duplicateEntry } = revision;
97
+ (_e = (_d = results.get(name)) === null || _d === void 0 ? void 0 : _d.duplicates) === null || _e === void 0 ? void 0 : _e.push(duplicateEntry);
98
+ }
99
+ }
100
+ /**
101
+ * Returns paths to the highest priority config files, relative to the {@link searchPath}.
102
+ * @example
103
+ * ```
104
+ * // Given the following file exists: /foo/myapp/modules/mymodule/expo-module.config.json
105
+ * await findPackagesConfigPathsAsync('/foo/myapp/modules');
106
+ * // returns ['mymodule/expo-module.config.json']
107
+ * ```
108
+ */
109
+ async function findPackagesConfigPathsAsync(searchPath) {
110
+ const bracedFilenames = '{' + EXPO_MODULE_CONFIG_FILENAMES.join(',') + '}';
111
+ const paths = await (0, fast_glob_1.default)([`*/${bracedFilenames}`, `@*/*/${bracedFilenames}`], {
112
+ cwd: searchPath,
113
+ });
114
+ // If the package has multiple configs (e.g. `unimodule.json` and `expo-module.config.json` during the transition time)
115
+ // then we want to give `expo-module.config.json` the priority.
116
+ return Object.values(paths.reduce((acc, configPath) => {
117
+ const dirname = path_1.default.dirname(configPath);
118
+ if (!acc[dirname] || configPriority(configPath) > configPriority(acc[dirname])) {
119
+ acc[dirname] = configPath;
120
+ }
121
+ return acc;
122
+ }, {}));
123
+ }
124
+ /**
125
+ * Resolves package name and version for the given {@link packagePath} from its `package.json`.
126
+ * if {@link fallbackToDirName} is true, it returns the dir name when `package.json` doesn't exist.
127
+ * @returns object with `name` and `version` properties. `version` falls back to `UNVERSIONED` if cannot be resolved.
128
+ */
129
+ function resolvePackageNameAndVersion(packagePath, { fallbackToDirName } = {}) {
130
+ try {
131
+ const { name, version } = require(path_1.default.join(packagePath, 'package.json'));
132
+ return { name, version: version || 'UNVERSIONED' };
133
+ }
134
+ catch (e) {
135
+ if (fallbackToDirName) {
136
+ // we don't have the package.json name, so we'll use the directory name
137
+ return {
138
+ name: path_1.default.basename(packagePath),
139
+ version: 'UNVERSIONED',
140
+ };
141
+ }
142
+ else {
143
+ throw e;
144
+ }
145
+ }
146
+ }
147
+ /**
148
+ * Filters out packages that are not the dependencies of the project.
149
+ */
150
+ function filterToProjectDependencies(results, options = {}) {
151
+ var _a;
152
+ const filteredResults = {};
153
+ const visitedPackages = new Set();
154
+ // iterate through always included package names and add them to the visited packages
155
+ // if the results contains them
156
+ for (const name of (_a = options.alwaysIncludedPackagesNames) !== null && _a !== void 0 ? _a : []) {
157
+ if (results[name] && !visitedPackages.has(name)) {
158
+ filteredResults[name] = results[name];
159
+ visitedPackages.add(name);
160
+ }
161
+ }
162
+ // Helper for traversing the dependency hierarchy.
163
+ function visitPackage(packageJsonPath) {
164
+ const packageJson = require(packageJsonPath);
165
+ // Prevent getting into the recursive loop.
166
+ if (visitedPackages.has(packageJson.name)) {
167
+ return;
168
+ }
169
+ visitedPackages.add(packageJson.name);
170
+ // Iterate over the dependencies to find transitive modules.
171
+ for (const dependencyName in packageJson.dependencies) {
172
+ const dependencyResult = results[dependencyName];
173
+ if (!filteredResults[dependencyName]) {
174
+ let dependencyPackageJsonPath;
175
+ if (dependencyResult) {
176
+ filteredResults[dependencyName] = dependencyResult;
177
+ dependencyPackageJsonPath = path_1.default.join(dependencyResult.path, 'package.json');
178
+ }
179
+ else {
180
+ try {
181
+ /**
182
+ * Custom `require` that resolves from the current working dir instead of this script path.
183
+ * **Requires Node v12.2.0**
184
+ */
185
+ const projectRequire = (0, module_1.createRequire)(packageJsonPath);
186
+ dependencyPackageJsonPath = projectRequire.resolve(`${dependencyName}/package.json`);
187
+ }
188
+ catch (error) {
189
+ // Some packages don't include package.json in its `exports` field,
190
+ // but none of our packages do that, so it seems fine to just ignore that type of error.
191
+ // Related issue: https://github.com/react-native-community/cli/issues/1168
192
+ if (!options.silent && error.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
193
+ console.warn(chalk_1.default.yellow(`⚠️ Cannot resolve the path to "${dependencyName}" package.`));
194
+ }
195
+ continue;
196
+ }
197
+ }
198
+ // Visit the dependency package.
199
+ visitPackage(dependencyPackageJsonPath);
200
+ }
201
+ }
202
+ }
203
+ // Visit project's package.
204
+ visitPackage(mergeLinkingOptions_1.projectPackageJsonPath);
205
+ return filteredResults;
206
+ }
207
+ //# sourceMappingURL=findModules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findModules.js","sourceRoot":"","sources":["../../src/autolinking/findModules.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,0DAA6B;AAC7B,wDAA0B;AAC1B,mCAAuC;AACvC,gDAAwB;AAExB,0DAAwE;AAExE,+DAAyF;AAEzF,8DAA8D;AAC9D,MAAM,4BAA4B,GAAG,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;AAEnF;;GAEG;AACI,KA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AC;QAEtC,4DAA4D;QAC5D,KAAK,MAAM,cAAc,IAAI,WAAW,CAAC,YAAY,EAAE;YACrD,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;YAEjD,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE;gBACpC,IAAI,yBAAiC,CAAC;gBAEtC,IAAI,gBAAgB,EAAE;oBACpB,eAAe,CAAC,cAAc,CAAC,GAAG,gBAAgB,CAAC;oBACnD,yBAAyB,GAAG,cAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;iBAC9E;qBAAM;oBACL,IAAI;wBACF;;;2BAGG;wBACH,MAAM,cAAc,GAAG,IAAA,sBAAa,EAAC,eAAe,CAAC,CAAC;wBACtD,yBAAyB,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,cAAc,eAAe,CAAC,CAAC;qBACtF;oBAAC,OAAO,KAAU,EAAE;wBACnB,mEAAmE;wBACnE,wFAAwF;wBACxF,2EAA2E;wBAC3E,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,+BAA+B,EAAE;4BACrE,OAAO,CAAC,IAAI,CACV,eAAK,CAAC,MAAM,CAAC,mCAAmC,cAAc,YAAY,CAAC,CAC5E,CAAC;yBACH;wBACD,SAAS;qBACV;iBACF;gBAED,gCAAgC;gBAChC,YAAY,CAAC,yBAAyB,CAAC,CAAC;aACzC;SACF;IACH,CAAC;IAED,2BAA2B;IAC3B,YAAY,CAAC,4CAAsB,CAAC,CAAC;IAErC,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import chalk from 'chalk';\nimport glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport { createRequire } from 'module';\nimport path from 'path';\n\nimport { requireAndResolveExpoModuleConfig } from '../ExpoModuleConfig';\nimport { PackageRevision, SearchOptions, SearchResults } from '../types';\nimport { mergeLinkingOptionsAsync, projectPackageJsonPath } from './mergeLinkingOptions';\n\n// Names of the config files. From lowest to highest priority.\nconst EXPO_MODULE_CONFIG_FILENAMES = ['unimodule.json', 'expo-module.config.json'];\n\n/**\n * Searches for modules to link based on given config.\n */\nexport async function findModulesAsync(providedOptions: SearchOptions): Promise<SearchResults> {\n const options = await mergeLinkingOptionsAsync(providedOptions);\n const results: Map<string, PackageRevision> = new Map();\n\n const nativeModuleNames = new Set<string>();\n\n // custom native modules should be resolved first so that they can override other modules\n const searchPaths =\n options.nativeModulesDir && fs.existsSync(options.nativeModulesDir)\n ? [options.nativeModulesDir, ...options.searchPaths]\n : options.searchPaths;\n\n for (const searchPath of searchPaths) {\n const isNativeModulesDir = searchPath === options.nativeModulesDir;\n\n const packageConfigPaths = await findPackagesConfigPathsAsync(searchPath);\n\n for (const packageConfigPath of packageConfigPaths) {\n const packagePath = await fs.realpath(path.join(searchPath, path.dirname(packageConfigPath)));\n const expoModuleConfig = requireAndResolveExpoModuleConfig(\n path.join(packagePath, path.basename(packageConfigPath))\n );\n\n const { name, version } = resolvePackageNameAndVersion(packagePath, {\n fallbackToDirName: isNativeModulesDir,\n });\n\n // we ignore the `exclude` option for custom native modules\n if (\n (!isNativeModulesDir && options.exclude?.includes(name)) ||\n !expoModuleConfig.supportsPlatform(options.platform)\n ) {\n continue;\n }\n\n // add the current revision to the results\n const currentRevision: PackageRevision = {\n path: packagePath,\n version,\n config: expoModuleConfig,\n };\n addRevisionToResults(results, name, currentRevision);\n\n // if the module is a native module, we need to add it to the nativeModuleNames set\n if (isNativeModulesDir && !nativeModuleNames.has(name)) {\n nativeModuleNames.add(name);\n }\n }\n }\n\n const searchResults: SearchResults = Object.fromEntries(results.entries());\n\n // It doesn't make much sense to strip modules if there is only one search path.\n // (excluding custom native modules path)\n // Workspace root usually doesn't specify all its dependencies (see Expo Go),\n // so in this case we should link everything.\n if (options.searchPaths.length <= 1) {\n return searchResults;\n }\n\n return filterToProjectDependencies(searchResults, {\n ...providedOptions,\n // Custom native modules are not filtered out\n // when they're not specified in package.json dependencies.\n alwaysIncludedPackagesNames: nativeModuleNames,\n });\n}\n\n/**\n * Returns the priority of the config at given path. Higher number means higher priority.\n */\nfunction configPriority(fullpath: string): number {\n return EXPO_MODULE_CONFIG_FILENAMES.indexOf(path.basename(fullpath));\n}\n\n/**\n * Adds {@link revision} to the {@link results} map\n * or to package duplicates if it already exists.\n * @param results [mutable] yet resolved packages map\n * @param name resolved package name\n * @param revision resolved package revision\n */\nfunction addRevisionToResults(\n results: Map<string, PackageRevision>,\n name: string,\n revision: PackageRevision\n): void {\n if (!results.has(name)) {\n // The revision that was found first will be the main one.\n // An array of duplicates and the config are needed only here.\n results.set(name, {\n ...revision,\n duplicates: [],\n });\n } else if (\n results.get(name)?.path !== revision.path &&\n results.get(name)?.duplicates?.every(({ path }) => path !== revision.path)\n ) {\n const { config, duplicates, ...duplicateEntry } = revision;\n results.get(name)?.duplicates?.push(duplicateEntry);\n }\n}\n\n/**\n * Returns paths to the highest priority config files, relative to the {@link searchPath}.\n * @example\n * ```\n * // Given the following file exists: /foo/myapp/modules/mymodule/expo-module.config.json\n * await findPackagesConfigPathsAsync('/foo/myapp/modules');\n * // returns ['mymodule/expo-module.config.json']\n * ```\n */\nasync function findPackagesConfigPathsAsync(searchPath: string): Promise<string[]> {\n const bracedFilenames = '{' + EXPO_MODULE_CONFIG_FILENAMES.join(',') + '}';\n const paths = await glob([`*/${bracedFilenames}`, `@*/*/${bracedFilenames}`], {\n cwd: searchPath,\n });\n\n // If the package has multiple configs (e.g. `unimodule.json` and `expo-module.config.json` during the transition time)\n // then we want to give `expo-module.config.json` the priority.\n return Object.values(\n paths.reduce<Record<string, string>>((acc, configPath) => {\n const dirname = path.dirname(configPath);\n\n if (!acc[dirname] || configPriority(configPath) > configPriority(acc[dirname])) {\n acc[dirname] = configPath;\n }\n return acc;\n }, {})\n );\n}\n\n/**\n * Resolves package name and version for the given {@link packagePath} from its `package.json`.\n * if {@link fallbackToDirName} is true, it returns the dir name when `package.json` doesn't exist.\n * @returns object with `name` and `version` properties. `version` falls back to `UNVERSIONED` if cannot be resolved.\n */\nfunction resolvePackageNameAndVersion(\n packagePath: string,\n { fallbackToDirName }: { fallbackToDirName?: boolean } = {}\n): { name: string; version: string } {\n try {\n const { name, version } = require(path.join(packagePath, 'package.json'));\n return { name, version: version || 'UNVERSIONED' };\n } catch (e) {\n if (fallbackToDirName) {\n // we don't have the package.json name, so we'll use the directory name\n return {\n name: path.basename(packagePath),\n version: 'UNVERSIONED',\n };\n } else {\n throw e;\n }\n }\n}\n\n/**\n * Filters out packages that are not the dependencies of the project.\n */\nfunction filterToProjectDependencies(\n results: SearchResults,\n options: Pick<SearchOptions, 'silent'> & { alwaysIncludedPackagesNames?: Set<string> } = {}\n) {\n const filteredResults: SearchResults = {};\n const visitedPackages = new Set<string>();\n\n // iterate through always included package names and add them to the visited packages\n // if the results contains them\n for (const name of options.alwaysIncludedPackagesNames ?? []) {\n if (results[name] && !visitedPackages.has(name)) {\n filteredResults[name] = results[name];\n visitedPackages.add(name);\n }\n }\n\n // Helper for traversing the dependency hierarchy.\n function visitPackage(packageJsonPath: string) {\n const packageJson = require(packageJsonPath);\n\n // Prevent getting into the recursive loop.\n if (visitedPackages.has(packageJson.name)) {\n return;\n }\n visitedPackages.add(packageJson.name);\n\n // Iterate over the dependencies to find transitive modules.\n for (const dependencyName in packageJson.dependencies) {\n const dependencyResult = results[dependencyName];\n\n if (!filteredResults[dependencyName]) {\n let dependencyPackageJsonPath: string;\n\n if (dependencyResult) {\n filteredResults[dependencyName] = dependencyResult;\n dependencyPackageJsonPath = path.join(dependencyResult.path, 'package.json');\n } else {\n try {\n /**\n * Custom `require` that resolves from the current working dir instead of this script path.\n * **Requires Node v12.2.0**\n */\n const projectRequire = createRequire(packageJsonPath);\n dependencyPackageJsonPath = projectRequire.resolve(`${dependencyName}/package.json`);\n } catch (error: any) {\n // Some packages don't include package.json in its `exports` field,\n // but none of our packages do that, so it seems fine to just ignore that type of error.\n // Related issue: https://github.com/react-native-community/cli/issues/1168\n if (!options.silent && error.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') {\n console.warn(\n chalk.yellow(`⚠️ Cannot resolve the path to \"${dependencyName}\" package.`)\n );\n }\n continue;\n }\n }\n\n // Visit the dependency package.\n visitPackage(dependencyPackageJsonPath);\n }\n }\n }\n\n // Visit project's package.\n visitPackage(projectPackageJsonPath);\n\n return filteredResults;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { GenerateOptions, ModuleDescriptor } from '../types';
2
+ /**
3
+ * Generates a source file listing all packages to link.
4
+ * Right know it works only for Android platform.
5
+ */
6
+ export declare function generatePackageListAsync(modules: ModuleDescriptor[], options: GenerateOptions): Promise<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generatePackageListAsync = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ /**
9
+ * Generates a source file listing all packages to link.
10
+ * Right know it works only for Android platform.
11
+ */
12
+ async function generatePackageListAsync(modules, options) {
13
+ try {
14
+ const platformLinking = require(`../platforms/${options.platform}`);
15
+ await platformLinking.generatePackageListAsync(modules, options.target, options.namespace);
16
+ }
17
+ catch (e) {
18
+ console.error(chalk_1.default.red(`Generating package list is not available for platform: ${options.platform}`));
19
+ throw e;
20
+ }
21
+ }
22
+ exports.generatePackageListAsync = generatePackageListAsync;
23
+ //# sourceMappingURL=generatePackageList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatePackageList.js","sourceRoot":"","sources":["../../src/autolinking/generatePackageList.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAC5C,OAA2B,EAC3B,OAAwB;IAExB,IAAI;QACF,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACpE,MAAM,eAAe,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;KAC5F;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CACX,eAAK,CAAC,GAAG,CAAC,0DAA0D,OAAO,CAAC,QAAQ,EAAE,CAAC,CACxF,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAbD,4DAaC","sourcesContent":["import chalk from 'chalk';\n\nimport { GenerateOptions, ModuleDescriptor } from '../types';\n\n/**\n * Generates a source file listing all packages to link.\n * Right know it works only for Android platform.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptor[],\n options: GenerateOptions\n) {\n try {\n const platformLinking = require(`../platforms/${options.platform}`);\n await platformLinking.generatePackageListAsync(modules, options.target, options.namespace);\n } catch (e) {\n console.error(\n chalk.red(`Generating package list is not available for platform: ${options.platform}`)\n );\n throw e;\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export { findModulesAsync, } from './findModules';
2
+ export { resolveSearchPathsAsync, mergeLinkingOptionsAsync, } from './mergeLinkingOptions';
3
+ export { generatePackageListAsync } from './generatePackageList';
4
+ export { resolveModulesAsync } from './resolveModules';
5
+ export { verifySearchResults } from './verifySearchResults';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifySearchResults = exports.resolveModulesAsync = exports.generatePackageListAsync = exports.mergeLinkingOptionsAsync = exports.resolveSearchPathsAsync = exports.findModulesAsync = void 0;
4
+ var findModules_1 = require("./findModules");
5
+ // NOTE(evanbacon): Used in @expo/prebuild-config
6
+ Object.defineProperty(exports, "findModulesAsync", { enumerable: true, get: function () { return findModules_1.findModulesAsync; } });
7
+ var mergeLinkingOptions_1 = require("./mergeLinkingOptions");
8
+ // NOTE(evanbacon): Used in @expo/prebuild-config
9
+ Object.defineProperty(exports, "resolveSearchPathsAsync", { enumerable: true, get: function () { return mergeLinkingOptions_1.resolveSearchPathsAsync; } });
10
+ Object.defineProperty(exports, "mergeLinkingOptionsAsync", { enumerable: true, get: function () { return mergeLinkingOptions_1.mergeLinkingOptionsAsync; } });
11
+ var generatePackageList_1 = require("./generatePackageList");
12
+ Object.defineProperty(exports, "generatePackageListAsync", { enumerable: true, get: function () { return generatePackageList_1.generatePackageListAsync; } });
13
+ var resolveModules_1 = require("./resolveModules");
14
+ Object.defineProperty(exports, "resolveModulesAsync", { enumerable: true, get: function () { return resolveModules_1.resolveModulesAsync; } });
15
+ var verifySearchResults_1 = require("./verifySearchResults");
16
+ Object.defineProperty(exports, "verifySearchResults", { enumerable: true, get: function () { return verifySearchResults_1.verifySearchResults; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/autolinking/index.ts"],"names":[],"mappings":";;;AAAA,6CAGuB;AAFrB,iDAAiD;AACjD,+GAAA,gBAAgB,OAAA;AAElB,6DAI+B;AAH7B,iDAAiD;AACjD,8HAAA,uBAAuB,OAAA;AACvB,+HAAA,wBAAwB,OAAA;AAE1B,6DAAiE;AAAxD,+HAAA,wBAAwB,OAAA;AACjC,mDAAuD;AAA9C,qHAAA,mBAAmB,OAAA;AAC5B,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA","sourcesContent":["export {\n // NOTE(evanbacon): Used in @expo/prebuild-config\n findModulesAsync,\n} from './findModules';\nexport {\n // NOTE(evanbacon): Used in @expo/prebuild-config\n resolveSearchPathsAsync,\n mergeLinkingOptionsAsync,\n} from './mergeLinkingOptions';\nexport { generatePackageListAsync } from './generatePackageList';\nexport { resolveModulesAsync } from './resolveModules';\nexport { verifySearchResults } from './verifySearchResults';\n"]}
@@ -0,0 +1,17 @@
1
+ import { SearchOptions } from '../types';
2
+ /**
3
+ * Path to the `package.json` of the closest project in the current working dir.
4
+ */
5
+ export declare const projectPackageJsonPath: string;
6
+ /**
7
+ * Merges autolinking options from different sources (the later the higher priority)
8
+ * - options defined in package.json's `expo.autolinking` field
9
+ * - platform-specific options from the above (e.g. `expo.autolinking.ios`)
10
+ * - options provided to the CLI command
11
+ */
12
+ export declare function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(providedOptions: OptionsType): Promise<OptionsType>;
13
+ /**
14
+ * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
15
+ * going up through the path components. This makes workspaces work out-of-the-box without any configs.
16
+ */
17
+ export declare function resolveSearchPathsAsync(searchPaths: string[] | null, cwd: string): Promise<string[]>;