expo-modules-autolinking 0.5.2 → 0.6.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 (54) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -2
  3. package/build/ExpoModuleConfig.d.ts +2 -2
  4. package/build/ExpoModuleConfig.js +8 -4
  5. package/build/ExpoModuleConfig.js.map +1 -1
  6. package/build/ReactImportsPatcher.js +18 -1
  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/platforms/android.js +3 -3
  27. package/build/platforms/android.js.map +1 -1
  28. package/build/platforms/ios.js +3 -3
  29. package/build/platforms/ios.js.map +1 -1
  30. package/build/types.d.ts +11 -0
  31. package/build/types.js.map +1 -1
  32. package/package.json +3 -3
  33. package/scripts/ios/autolinking_manager.rb +3 -1
  34. package/scripts/ios/cocoapods/pod_target.rb +50 -0
  35. package/scripts/ios/cocoapods/sandbox.rb +0 -19
  36. package/scripts/ios/cocoapods/umbrella_header_generator.rb +22 -0
  37. package/scripts/ios/package.rb +2 -2
  38. package/scripts/ios/react_import_patcher.rb +2 -8
  39. package/src/ExpoModuleConfig.ts +10 -4
  40. package/src/ReactImportsPatcher.ts +24 -1
  41. package/src/autolinking/findModules.ts +245 -0
  42. package/src/autolinking/generatePackageList.ts +22 -0
  43. package/src/autolinking/index.ts +12 -0
  44. package/src/autolinking/mergeLinkingOptions.ts +98 -0
  45. package/src/autolinking/resolveModules.ts +32 -0
  46. package/src/autolinking/verifySearchResults.ts +33 -0
  47. package/src/platforms/android.ts +3 -3
  48. package/src/platforms/ios.ts +3 -3
  49. package/src/types.ts +13 -0
  50. package/build/autolinking.d.ts +0 -34
  51. package/build/autolinking.js +0 -237
  52. package/build/autolinking.js.map +0 -1
  53. package/scripts/ios/React-Core.modulemap +0 -6
  54. package/src/autolinking.ts +0 -300
package/CHANGELOG.md CHANGED
@@ -10,6 +10,31 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.6.0 — 2022-01-26
14
+
15
+ ### ⚠️ Notices
16
+
17
+ - Expose `findModulesAsync` from `expo-modules-autolinking/build/autolinking` again. ([#15950](https://github.com/expo/expo/pull/15950) by [@EvanBacon](https://github.com/EvanBacon))
18
+ - 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))
19
+
20
+ ## 0.5.5 — 2022-01-05
21
+
22
+ ### 🐛 Bug fixes
23
+
24
+ - 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))
25
+
26
+ ## 0.5.4 — 2021-12-29
27
+
28
+ ### 🐛 Bug fixes
29
+
30
+ - Add `expo_patch_react_imports!` support for React-Native 0.66. ([#15724](https://github.com/expo/expo/pull/15724) by [@kudo](https://github.com/kudo))
31
+
32
+ ## 0.5.3 — 2021-12-28
33
+
34
+ ### 🐛 Bug fixes
35
+
36
+ - Fix `expo_patch_react_imports!` error when there are pods with absolute path. ([#15699](https://github.com/expo/expo/pull/15699) by [@kudo](https://github.com/kudo))
37
+
13
38
  ## 0.5.2 — 2021-12-22
14
39
 
15
40
  ### 🐛 Bug fixes
@@ -25,6 +50,7 @@ _This version does not introduce any user-facing changes._
25
50
  ### 🎉 New features
26
51
 
27
52
  - Patch React podspecs on the fly to support Swift integration. ([#15299](https://github.com/expo/expo/pull/15299) by [@kudo](https://github.com/kudo))
53
+ - 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))
28
54
 
29
55
  ## 0.4.0 — 2021-11-17
30
56
 
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)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/module-autolinking.md)
8
8
  - [Documentation for the latest stable release](https://docs.expo.io/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.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.
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
  */
@@ -28,7 +28,7 @@ export declare class ExpoModuleConfig {
28
28
  /**
29
29
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
30
30
  */
31
- androidModulesClassNames(): string[];
31
+ androidModules(): string[];
32
32
  /**
33
33
  * Returns serializable raw config.
34
34
  */
@@ -18,9 +18,11 @@ class ExpoModuleConfig {
18
18
  /**
19
19
  * Returns a list of names of Swift native modules classes to put to the generated modules provider file.
20
20
  */
21
- iosModulesClassNames() {
21
+ iosModules() {
22
22
  var _a, _b;
23
- return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.modulesClassNames) !== null && _b !== void 0 ? _b : [];
23
+ const iosConfig = this.rawConfig.ios;
24
+ // `modulesClassNames` is a legacy name for the same config.
25
+ 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
26
  }
25
27
  /**
26
28
  * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
@@ -46,9 +48,11 @@ class ExpoModuleConfig {
46
48
  /**
47
49
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
48
50
  */
49
- androidModulesClassNames() {
51
+ androidModules() {
50
52
  var _a, _b;
51
- return (_b = (_a = this.rawConfig.android) === null || _a === void 0 ? void 0 : _a.modulesClassNames) !== null && _b !== void 0 ? _b : [];
53
+ const androidConfig = this.rawConfig.android;
54
+ // `modulesClassNames` is a legacy name for the same config.
55
+ 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 : [];
52
56
  }
53
57
  /**
54
58
  * 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;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MA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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 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 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 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 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"]}
@@ -34,7 +34,7 @@ async function generateReactHeaderSetAsync(reactHeaderDir) {
34
34
  async function patchFileAsync(headerSet, file, dryRun) {
35
35
  let changed = false;
36
36
  const content = await fs_extra_1.default.readFile(file, 'utf-8');
37
- const transformContent = content.replace(/^#import\s+"(.+)"$/gm, (match, headerName) => {
37
+ let transformContent = content.replace(/^#import\s+"(.+)"$/gm, (match, headerName) => {
38
38
  // `#import "RCTBridge.h"` -> `#import <React/RCTBridge.h>`
39
39
  if (headerSet.has(headerName)) {
40
40
  changed = true;
@@ -51,6 +51,23 @@ async function patchFileAsync(headerSet, file, dryRun) {
51
51
  // Otherwise, return original import
52
52
  return match;
53
53
  });
54
+ transformContent = transformContent.replace(/^#(if|elif)\s+__has_include\("(.+)"\)$/gm, (match, ifPrefix, headerName) => {
55
+ // `#if __has_include("RCTBridge.h")` -> `#if __has_include(<React/RCTBridge.h>)`
56
+ if (headerSet.has(headerName)) {
57
+ changed = true;
58
+ return `#${ifPrefix} __has_include(<React/${headerName}>)`;
59
+ }
60
+ // `#if __has_include("React/RCTBridge.h")` -> `#if __has_include(<React/RCTBridge.h>)`
61
+ if (headerName.startsWith('React/')) {
62
+ const name = headerName.substring(6);
63
+ if (headerSet.has(name)) {
64
+ changed = true;
65
+ return `#${ifPrefix} __has_include(<React/${name}>)`;
66
+ }
67
+ }
68
+ // Otherwise, return original import
69
+ return match;
70
+ });
54
71
  if (changed) {
55
72
  console.log(`Patching imports for file: ${file}`);
56
73
  }
@@ -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,GA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AC,CAAC;KACnD;IACD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;KAC5C;AACH,CAAC;AAhCD,wCAgCC;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 const 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 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,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,K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C,UAAU,CAAC,QAAQ,CAAC,EAAE;YACnC,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACvB,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,IAAI,QAAQ,yBAAyB,IAAI,IAAI,CAAC;aACtD;SACF;QAED,oCAAoC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC,CACF,CAAC;IAEF,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,8BAA8B,IAAI,EAAE,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"]}
@@ -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
+ * Custom `require` that resolves from the current working dir instead of this script path.
18
+ * **Requires Node v12.2.0**
19
+ */
20
+ const projectRequire = (0, module_1.createRequire)(mergeLinkingOptions_1.projectPackageJsonPath);
21
+ /**
22
+ * Searches for modules to link based on given config.
23
+ */
24
+ async function findModulesAsync(providedOptions) {
25
+ var _a;
26
+ const options = await (0, mergeLinkingOptions_1.mergeLinkingOptionsAsync)(providedOptions);
27
+ const results = new Map();
28
+ const nativeModuleNames = new Set();
29
+ // custom native modules should be resolved first so that they can override other modules
30
+ const searchPaths = options.nativeModulesDir && fs_extra_1.default.existsSync(options.nativeModulesDir)
31
+ ? [options.nativeModulesDir, ...options.searchPaths]
32
+ : options.searchPaths;
33
+ for (const searchPath of searchPaths) {
34
+ const isNativeModulesDir = searchPath === options.nativeModulesDir;
35
+ const packageConfigPaths = await findPackagesConfigPathsAsync(searchPath);
36
+ for (const packageConfigPath of packageConfigPaths) {
37
+ const packagePath = await fs_extra_1.default.realpath(path_1.default.join(searchPath, path_1.default.dirname(packageConfigPath)));
38
+ const expoModuleConfig = (0, ExpoModuleConfig_1.requireAndResolveExpoModuleConfig)(path_1.default.join(packagePath, path_1.default.basename(packageConfigPath)));
39
+ const { name, version } = resolvePackageNameAndVersion(packagePath, {
40
+ fallbackToDirName: isNativeModulesDir,
41
+ });
42
+ // we ignore the `exclude` option for custom native modules
43
+ if ((!isNativeModulesDir && ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(name))) ||
44
+ !expoModuleConfig.supportsPlatform(options.platform)) {
45
+ continue;
46
+ }
47
+ // add the current revision to the results
48
+ const currentRevision = {
49
+ path: packagePath,
50
+ version,
51
+ config: expoModuleConfig,
52
+ };
53
+ addRevisionToResults(results, name, currentRevision);
54
+ // if the module is a native module, we need to add it to the nativeModuleNames set
55
+ if (isNativeModulesDir && !nativeModuleNames.has(name)) {
56
+ nativeModuleNames.add(name);
57
+ }
58
+ }
59
+ }
60
+ const searchResults = Object.fromEntries(results.entries());
61
+ // It doesn't make much sense to strip modules if there is only one search path.
62
+ // (excluding custom native modules path)
63
+ // Workspace root usually doesn't specify all its dependencies (see Expo Go),
64
+ // so in this case we should link everything.
65
+ if (options.searchPaths.length <= 1) {
66
+ return searchResults;
67
+ }
68
+ return filterToProjectDependencies(searchResults, {
69
+ ...providedOptions,
70
+ // Custom native modules are not filtered out
71
+ // when they're not specified in package.json dependencies.
72
+ alwaysIncludedPackagesNames: nativeModuleNames,
73
+ });
74
+ }
75
+ exports.findModulesAsync = findModulesAsync;
76
+ /**
77
+ * Returns the priority of the config at given path. Higher number means higher priority.
78
+ */
79
+ function configPriority(fullpath) {
80
+ return EXPO_MODULE_CONFIG_FILENAMES.indexOf(path_1.default.basename(fullpath));
81
+ }
82
+ /**
83
+ * Adds {@link revision} to the {@link results} map
84
+ * or to package duplicates if it already exists.
85
+ * @param results [mutable] yet resolved packages map
86
+ * @param name resolved package name
87
+ * @param revision resolved package revision
88
+ */
89
+ function addRevisionToResults(results, name, revision) {
90
+ var _a, _b, _c, _d, _e;
91
+ if (!results.has(name)) {
92
+ // The revision that was found first will be the main one.
93
+ // An array of duplicates and the config are needed only here.
94
+ results.set(name, {
95
+ ...revision,
96
+ duplicates: [],
97
+ });
98
+ }
99
+ else if (((_a = results.get(name)) === null || _a === void 0 ? void 0 : _a.path) !== revision.path &&
100
+ ((_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))) {
101
+ const { config, duplicates, ...duplicateEntry } = revision;
102
+ (_e = (_d = results.get(name)) === null || _d === void 0 ? void 0 : _d.duplicates) === null || _e === void 0 ? void 0 : _e.push(duplicateEntry);
103
+ }
104
+ }
105
+ /**
106
+ * Returns paths to the highest priority config files, relative to the {@link searchPath}.
107
+ * @example
108
+ * ```
109
+ * // Given the following file exists: /foo/myapp/modules/mymodule/expo-module.config.json
110
+ * await findPackagesConfigPathsAsync('/foo/myapp/modules');
111
+ * // returns ['mymodule/expo-module.config.json']
112
+ * ```
113
+ */
114
+ async function findPackagesConfigPathsAsync(searchPath) {
115
+ const bracedFilenames = '{' + EXPO_MODULE_CONFIG_FILENAMES.join(',') + '}';
116
+ const paths = await (0, fast_glob_1.default)([`*/${bracedFilenames}`, `@*/*/${bracedFilenames}`], {
117
+ cwd: searchPath,
118
+ });
119
+ // If the package has multiple configs (e.g. `unimodule.json` and `expo-module.config.json` during the transition time)
120
+ // then we want to give `expo-module.config.json` the priority.
121
+ return Object.values(paths.reduce((acc, configPath) => {
122
+ const dirname = path_1.default.dirname(configPath);
123
+ if (!acc[dirname] || configPriority(configPath) > configPriority(acc[dirname])) {
124
+ acc[dirname] = configPath;
125
+ }
126
+ return acc;
127
+ }, {}));
128
+ }
129
+ /**
130
+ * Resolves package name and version for the given {@link packagePath} from its `package.json`.
131
+ * if {@link fallbackToDirName} is true, it returns the dir name when `package.json` doesn't exist.
132
+ * @returns object with `name` and `version` properties. `version` falls back to `UNVERSIONED` if cannot be resolved.
133
+ */
134
+ function resolvePackageNameAndVersion(packagePath, { fallbackToDirName } = {}) {
135
+ try {
136
+ const { name, version } = require(path_1.default.join(packagePath, 'package.json'));
137
+ return { name, version: version || 'UNVERSIONED' };
138
+ }
139
+ catch (e) {
140
+ if (fallbackToDirName) {
141
+ // we don't have the package.json name, so we'll use the directory name
142
+ return {
143
+ name: path_1.default.basename(packagePath),
144
+ version: 'UNVERSIONED',
145
+ };
146
+ }
147
+ else {
148
+ throw e;
149
+ }
150
+ }
151
+ }
152
+ /**
153
+ * Filters out packages that are not the dependencies of the project.
154
+ */
155
+ function filterToProjectDependencies(results, options = {}) {
156
+ var _a;
157
+ const filteredResults = {};
158
+ const visitedPackages = new Set();
159
+ // iterate through always included package names and add them to the visited packages
160
+ // if the results contains them
161
+ for (const name of (_a = options.alwaysIncludedPackagesNames) !== null && _a !== void 0 ? _a : []) {
162
+ if (results[name] && !visitedPackages.has(name)) {
163
+ filteredResults[name] = results[name];
164
+ visitedPackages.add(name);
165
+ }
166
+ }
167
+ // Helper for traversing the dependency hierarchy.
168
+ function visitPackage(packageJsonPath) {
169
+ const packageJson = require(packageJsonPath);
170
+ // Prevent getting into the recursive loop.
171
+ if (visitedPackages.has(packageJson.name)) {
172
+ return;
173
+ }
174
+ visitedPackages.add(packageJson.name);
175
+ // Iterate over the dependencies to find transitive modules.
176
+ for (const dependencyName in packageJson.dependencies) {
177
+ const dependencyResult = results[dependencyName];
178
+ if (!filteredResults[dependencyName]) {
179
+ let dependencyPackageJsonPath;
180
+ if (dependencyResult) {
181
+ filteredResults[dependencyName] = dependencyResult;
182
+ dependencyPackageJsonPath = path_1.default.join(dependencyResult.path, 'package.json');
183
+ }
184
+ else {
185
+ try {
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;;;GAGG;AACH,MAAM,cAAc,GAAG,IAAA,sBAAa,EAAC,4CAAsB,CAAC,CAAC;AAE7D;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,eAA8B;;IACnE,MAAM,OAAO,GAAG,MAAM,IAAA,8CAAwB,EAAC,eAAe,CAAC,CAAC;IAChE,MAAM,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAExD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE5C,yFAAyF;IACzF,MAAM,WAAW,GACf,OAAO,CAAC,gBAAgB,IAAI,kBAAE,CAAC,UAAU,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACjE,CAAC,C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AC,gBAAgB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;iBAC9E;qBAAM;oBACL,IAAI;wBACF,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 * Custom `require` that resolves from the current working dir instead of this script path.\n * **Requires Node v12.2.0**\n */\nconst projectRequire = createRequire(projectPackageJsonPath);\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 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[]>;
@@ -0,0 +1,79 @@
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.resolveSearchPathsAsync = exports.mergeLinkingOptionsAsync = exports.projectPackageJsonPath = void 0;
7
+ const find_up_1 = __importDefault(require("find-up"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ /**
11
+ * Path to the `package.json` of the closest project in the current working dir.
12
+ */
13
+ exports.projectPackageJsonPath = find_up_1.default.sync('package.json', { cwd: process.cwd() });
14
+ // This won't happen in usual scenarios, but we need to unwrap the optional path :)
15
+ if (!exports.projectPackageJsonPath) {
16
+ throw new Error(`Couldn't find "package.json" up from path "${process.cwd()}"`);
17
+ }
18
+ /**
19
+ * Merges autolinking options from different sources (the later the higher priority)
20
+ * - options defined in package.json's `expo.autolinking` field
21
+ * - platform-specific options from the above (e.g. `expo.autolinking.ios`)
22
+ * - options provided to the CLI command
23
+ */
24
+ async function mergeLinkingOptionsAsync(providedOptions) {
25
+ var _a;
26
+ const packageJson = require(exports.projectPackageJsonPath);
27
+ const baseOptions = (_a = packageJson.expo) === null || _a === void 0 ? void 0 : _a.autolinking;
28
+ const platformOptions = providedOptions.platform && (baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions[providedOptions.platform]);
29
+ const finalOptions = Object.assign({}, baseOptions, platformOptions, providedOptions);
30
+ // Makes provided paths absolute or falls back to default paths if none was provided.
31
+ finalOptions.searchPaths = await resolveSearchPathsAsync(finalOptions.searchPaths, process.cwd());
32
+ finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(finalOptions.nativeModulesDir, process.cwd());
33
+ return finalOptions;
34
+ }
35
+ exports.mergeLinkingOptionsAsync = mergeLinkingOptionsAsync;
36
+ /**
37
+ * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
38
+ * going up through the path components. This makes workspaces work out-of-the-box without any configs.
39
+ */
40
+ async function resolveSearchPathsAsync(searchPaths, cwd) {
41
+ return searchPaths && searchPaths.length > 0
42
+ ? searchPaths.map((searchPath) => path_1.default.resolve(cwd, searchPath))
43
+ : await findDefaultPathsAsync(cwd);
44
+ }
45
+ exports.resolveSearchPathsAsync = resolveSearchPathsAsync;
46
+ /**
47
+ * Looks up for workspace's `node_modules` paths.
48
+ */
49
+ async function findDefaultPathsAsync(cwd) {
50
+ const paths = [];
51
+ let dir = cwd;
52
+ let pkgJsonPath;
53
+ while ((pkgJsonPath = await (0, find_up_1.default)('package.json', { cwd: dir }))) {
54
+ dir = path_1.default.dirname(path_1.default.dirname(pkgJsonPath));
55
+ paths.push(path_1.default.join(pkgJsonPath, '..', 'node_modules'));
56
+ }
57
+ return paths;
58
+ }
59
+ /**
60
+ * Finds the real path to custom native modules directory.
61
+ * @returns resolved native modules directory or `null` if it is not found or doesn't exist.
62
+ */
63
+ async function resolveNativeModulesDirAsync(nativeModulesDir, cwd) {
64
+ // first try resolving the provided dir
65
+ if (nativeModulesDir) {
66
+ const nativeModulesDirPath = path_1.default.resolve(cwd, nativeModulesDir);
67
+ if (await fs_extra_1.default.pathExists(nativeModulesDirPath)) {
68
+ return nativeModulesDirPath;
69
+ }
70
+ }
71
+ // if not found, try to find it relative to the package.json
72
+ const up = await (0, find_up_1.default)('package.json', { cwd });
73
+ if (!up) {
74
+ return null;
75
+ }
76
+ const resolvedPath = path_1.default.join(up, '..', nativeModulesDir || 'modules');
77
+ return fs_extra_1.default.existsSync(resolvedPath) ? resolvedPath : null;
78
+ }
79
+ //# sourceMappingURL=mergeLinkingOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeLinkingOptions.js","sourceRoot":"","sources":["../../src/autolinking/mergeLinkingOptions.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;GAEG;AACU,QAAA,sBAAsB,GAAG,iBAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,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K,UAAU,qBAAqB,CAAC,GAAW;IAC9C,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,IAAI,WAA+B,CAAC;IAEpC,OAAO,CAAC,WAAW,GAAG,MAAM,IAAA,iBAAM,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;QACjE,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;KAC1D;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,4BAA4B,CACzC,gBAA2C,EAC3C,GAAW;IAEX,uCAAuC;IACvC,IAAI,gBAAgB,EAAE;QACpB,MAAM,oBAAoB,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACjE,IAAI,MAAM,kBAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YAC7C,OAAO,oBAAoB,CAAC;SAC7B;KACF;IAED,4DAA4D;IAC5D,MAAM,EAAE,GAAG,MAAM,IAAA,iBAAM,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,EAAE;QACP,OAAO,IAAI,CAAC;KACb;IACD,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,gBAAgB,IAAI,SAAS,CAAC,CAAC;IACxE,OAAO,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC","sourcesContent":["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { SearchOptions } from '../types';\n\n/**\n * Path to the `package.json` of the closest project in the current working dir.\n */\nexport const projectPackageJsonPath = findUp.sync('package.json', { cwd: process.cwd() }) as string;\n\n// This won't happen in usual scenarios, but we need to unwrap the optional path :)\nif (!projectPackageJsonPath) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${process.cwd()}\"`);\n}\n\n/**\n * Merges autolinking options from different sources (the later the higher priority)\n * - options defined in package.json's `expo.autolinking` field\n * - platform-specific options from the above (e.g. `expo.autolinking.ios`)\n * - options provided to the CLI command\n */\nexport async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(\n providedOptions: OptionsType\n): Promise<OptionsType> {\n const packageJson = require(projectPackageJsonPath);\n const baseOptions = packageJson.expo?.autolinking;\n const platformOptions = providedOptions.platform && baseOptions?.[providedOptions.platform];\n const finalOptions = Object.assign(\n {},\n baseOptions,\n platformOptions,\n providedOptions\n ) as OptionsType;\n\n // Makes provided paths absolute or falls back to default paths if none was provided.\n finalOptions.searchPaths = await resolveSearchPathsAsync(finalOptions.searchPaths, process.cwd());\n\n finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(\n finalOptions.nativeModulesDir,\n process.cwd()\n );\n\n return finalOptions;\n}\n\n/**\n * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when\n * going up through the path components. This makes workspaces work out-of-the-box without any configs.\n */\nexport async function resolveSearchPathsAsync(\n searchPaths: string[] | null,\n cwd: string\n): Promise<string[]> {\n return searchPaths && searchPaths.length > 0\n ? searchPaths.map((searchPath) => path.resolve(cwd, searchPath))\n : await findDefaultPathsAsync(cwd);\n}\n\n/**\n * Looks up for workspace's `node_modules` paths.\n */\nasync function findDefaultPathsAsync(cwd: string): Promise<string[]> {\n const paths = [];\n let dir = cwd;\n let pkgJsonPath: string | undefined;\n\n while ((pkgJsonPath = await findUp('package.json', { cwd: dir }))) {\n dir = path.dirname(path.dirname(pkgJsonPath));\n paths.push(path.join(pkgJsonPath, '..', 'node_modules'));\n }\n return paths;\n}\n\n/**\n * Finds the real path to custom native modules directory.\n * @returns resolved native modules directory or `null` if it is not found or doesn't exist.\n */\nasync function resolveNativeModulesDirAsync(\n nativeModulesDir: string | null | undefined,\n cwd: string\n): Promise<string | null> {\n // first try resolving the provided dir\n if (nativeModulesDir) {\n const nativeModulesDirPath = path.resolve(cwd, nativeModulesDir);\n if (await fs.pathExists(nativeModulesDirPath)) {\n return nativeModulesDirPath;\n }\n }\n\n // if not found, try to find it relative to the package.json\n const up = await findUp('package.json', { cwd });\n if (!up) {\n return null;\n }\n const resolvedPath = path.join(up, '..', nativeModulesDir || 'modules');\n return fs.existsSync(resolvedPath) ? resolvedPath : null;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { ModuleDescriptor, ResolveOptions, SearchResults } from '../types';
2
+ /**
3
+ * Resolves search results to a list of platform-specific configuration.
4
+ */
5
+ export declare function resolveModulesAsync(searchResults: SearchResults, options: ResolveOptions): Promise<ModuleDescriptor[]>;