expo-modules-autolinking 3.0.0 → 3.0.2

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 (101) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/autolinking/findModules.d.ts +11 -5
  3. package/build/autolinking/findModules.js +8 -16
  4. package/build/autolinking/findModules.js.map +1 -1
  5. package/build/autolinking/generatePackageList.d.ts +16 -10
  6. package/build/autolinking/generatePackageList.js +13 -28
  7. package/build/autolinking/generatePackageList.js.map +1 -1
  8. package/build/autolinking/getConfiguration.d.ts +9 -2
  9. package/build/autolinking/getConfiguration.js +9 -4
  10. package/build/autolinking/getConfiguration.js.map +1 -1
  11. package/build/autolinking/index.d.ts +22 -17
  12. package/build/autolinking/index.js +23 -47
  13. package/build/autolinking/index.js.map +1 -1
  14. package/build/autolinking/resolveModules.d.ts +13 -9
  15. package/build/autolinking/resolveModules.js +21 -18
  16. package/build/autolinking/resolveModules.js.map +1 -1
  17. package/build/commands/autolinkingOptions.d.ts +50 -0
  18. package/build/commands/autolinkingOptions.js +168 -0
  19. package/build/commands/autolinkingOptions.js.map +1 -0
  20. package/build/commands/generateModulesProviderCommand.d.ts +3 -0
  21. package/build/commands/generateModulesProviderCommand.js +35 -0
  22. package/build/commands/generateModulesProviderCommand.js.map +1 -0
  23. package/build/commands/generatePackageListCommand.d.ts +6 -0
  24. package/build/commands/generatePackageListCommand.js +39 -0
  25. package/build/commands/generatePackageListCommand.js.map +1 -0
  26. package/build/commands/reactNativeConfigCommand.d.ts +3 -0
  27. package/build/commands/reactNativeConfigCommand.js +36 -0
  28. package/build/commands/reactNativeConfigCommand.js.map +1 -0
  29. package/build/commands/resolveCommand.d.ts +3 -0
  30. package/build/commands/resolveCommand.js +63 -0
  31. package/build/commands/resolveCommand.js.map +1 -0
  32. package/build/commands/searchCommand.d.ts +2 -0
  33. package/build/commands/searchCommand.js +27 -0
  34. package/build/commands/searchCommand.js.map +1 -0
  35. package/build/{autolinking/verifySearchResults.d.ts → commands/verifyCommand.d.ts} +4 -2
  36. package/build/{autolinking/verifySearchResults.js → commands/verifyCommand.js} +24 -3
  37. package/build/commands/verifyCommand.js.map +1 -0
  38. package/build/dependencies/CachedDependenciesLinker.d.ts +2 -1
  39. package/build/dependencies/CachedDependenciesLinker.js +23 -9
  40. package/build/dependencies/CachedDependenciesLinker.js.map +1 -1
  41. package/build/exports.d.ts +17 -1
  42. package/build/exports.js +48 -1
  43. package/build/exports.js.map +1 -1
  44. package/build/index.js +18 -162
  45. package/build/index.js.map +1 -1
  46. package/build/platforms/{android.d.ts → android/android.d.ts} +7 -2
  47. package/build/platforms/{android.js → android/android.js} +1 -5
  48. package/build/platforms/android/android.js.map +1 -0
  49. package/build/platforms/android/index.d.ts +1 -0
  50. package/build/platforms/android/index.js +9 -0
  51. package/build/platforms/android/index.js.map +1 -0
  52. package/build/platforms/{apple.d.ts → apple/apple.d.ts} +6 -6
  53. package/build/platforms/{apple.js → apple/apple.js} +5 -7
  54. package/build/platforms/apple/apple.js.map +1 -0
  55. package/build/platforms/apple/index.d.ts +1 -0
  56. package/build/platforms/apple/index.js +8 -0
  57. package/build/platforms/apple/index.js.map +1 -0
  58. package/build/platforms/index.d.ts +15 -0
  59. package/build/{autolinking/utils.js → platforms/index.js} +6 -1
  60. package/build/platforms/index.js.map +1 -0
  61. package/build/reactNativeConfig/reactNativeConfig.d.ts +11 -2
  62. package/build/reactNativeConfig/reactNativeConfig.js +13 -15
  63. package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
  64. package/build/reactNativeConfig/reactNativeConfig.types.d.ts +4 -33
  65. package/build/reactNativeConfig/reactNativeConfig.types.js.map +1 -1
  66. package/build/types.d.ts +1 -58
  67. package/build/types.js.map +1 -1
  68. package/package.json +3 -3
  69. package/src/autolinking/findModules.ts +18 -16
  70. package/src/autolinking/generatePackageList.ts +30 -31
  71. package/src/autolinking/getConfiguration.ts +16 -5
  72. package/src/autolinking/index.ts +48 -41
  73. package/src/autolinking/resolveModules.ts +47 -34
  74. package/src/commands/autolinkingOptions.ts +265 -0
  75. package/src/commands/generateModulesProviderCommand.ts +60 -0
  76. package/src/commands/generatePackageListCommand.ts +67 -0
  77. package/src/commands/reactNativeConfigCommand.ts +50 -0
  78. package/src/commands/resolveCommand.ts +101 -0
  79. package/src/commands/searchCommand.ts +35 -0
  80. package/src/{autolinking/verifySearchResults.ts → commands/verifyCommand.ts} +48 -6
  81. package/src/dependencies/CachedDependenciesLinker.ts +30 -12
  82. package/src/exports.ts +65 -0
  83. package/src/index.ts +18 -286
  84. package/src/platforms/{android.ts → android/android.ts} +10 -12
  85. package/src/platforms/android/index.ts +6 -0
  86. package/src/platforms/{apple.ts → apple/apple.ts} +10 -11
  87. package/src/platforms/apple/index.ts +5 -0
  88. package/src/platforms/index.ts +49 -0
  89. package/src/reactNativeConfig/reactNativeConfig.ts +25 -28
  90. package/src/reactNativeConfig/reactNativeConfig.types.ts +4 -35
  91. package/src/types.ts +10 -70
  92. package/build/autolinking/mergeLinkingOptions.d.ts +0 -27
  93. package/build/autolinking/mergeLinkingOptions.js +0 -112
  94. package/build/autolinking/mergeLinkingOptions.js.map +0 -1
  95. package/build/autolinking/utils.d.ts +0 -2
  96. package/build/autolinking/utils.js.map +0 -1
  97. package/build/autolinking/verifySearchResults.js.map +0 -1
  98. package/build/platforms/android.js.map +0 -1
  99. package/build/platforms/apple.js.map +0 -1
  100. package/src/autolinking/mergeLinkingOptions.ts +0 -146
  101. package/src/autolinking/utils.ts +0 -15
package/src/types.ts CHANGED
@@ -4,76 +4,16 @@ type Required<T, K extends keyof T> = T & { [P in K]-?: T[P] };
4
4
 
5
5
  type WithRequired<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & Required<T, K>;
6
6
 
7
- export type SupportedPlatform = 'apple' | 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';
8
-
9
- /**
10
- * Options that can be passed through `expo.autolinking` config in the package.json file.
11
- */
12
- export type AutolinkingOptions = {
13
- /** Only scan direct "dependencies" of a project for React Native modules, rather than including transitive dependencies.
14
- * @remarks
15
- * Before SDK 54, React Native modules would only be linked if they were listed as dependencies
16
- * of a project. However, in SDK 54+ transitive React Native modules dependencies are also
17
- * auto-linked, unless this flag is enabled.
18
- */
19
- legacy_shallowReactNativeLinking?: boolean;
20
- searchPaths?: string[] | null;
21
- ignorePaths?: string[] | null;
22
- exclude?: string[] | null;
23
- flags?: Record<string, any>;
24
- };
25
-
26
- export type AndroidAutolinkingOptions = AutolinkingOptions & {
27
- buildFromSource?: string[] | null;
28
- };
29
-
30
- export type BaseAutolinkingOptions = AutolinkingOptions & {
31
- [key in SupportedPlatform]?: AutolinkingOptions;
32
- };
33
-
34
- export interface PlatformAutolinkingOptions extends BaseAutolinkingOptions {
35
- android?: AndroidAutolinkingOptions;
36
- }
37
-
38
- export interface SearchOptions {
39
- // Available in the CLI
40
- searchPaths?: string[];
41
- ignorePaths?: string[] | null;
42
- exclude?: string[] | null;
43
- platform: SupportedPlatform;
44
- silent?: boolean;
45
- nativeModulesDir?: string | null;
46
- projectRoot: string;
47
- /**
48
- * Filter the search results to only include the project dependencies.
49
- * In a monorepo, you may like to set this to false and link all modules from the monorepo.
50
- * @default true
51
- */
52
- onlyProjectDeps?: boolean;
53
-
54
- // Scratched from project's config
55
- flags?: Record<string, any>;
56
-
57
- android?: {
58
- buildFromSource?: string[] | null;
59
- };
60
- }
61
-
62
- export interface ResolveOptions extends SearchOptions {
63
- json?: boolean;
64
- }
65
-
66
- export interface GenerateOptions extends ResolveOptions {
67
- target: string;
68
- namespace?: string;
69
- empty?: boolean;
70
- }
71
-
72
- export interface GenerateModulesProviderOptions extends ResolveOptions {
73
- target: string;
74
- entitlement?: string;
75
- packages: string[];
76
- }
7
+ // NOTE(@kitten): Our code has never guaranteed this to be exhaustive, hence the `| (string & {})` addition
8
+ export type SupportedPlatform =
9
+ | 'apple'
10
+ | 'ios'
11
+ | 'android'
12
+ | 'web'
13
+ | 'macos'
14
+ | 'tvos'
15
+ | 'devtools'
16
+ | (string & {});
77
17
 
78
18
  export type PackageRevision = {
79
19
  name: string;
@@ -1,27 +0,0 @@
1
- import type { SearchOptions, SupportedPlatform } from '../types';
2
- /**
3
- * Find the path to the `package.json` of the closest project in the given project root.
4
- */
5
- export declare function getProjectPackageJsonPathAsync(projectRoot: string): Promise<string>;
6
- /**
7
- * Synchronous version of {@link getProjectPackageJsonPathAsync}.
8
- */
9
- export declare function getProjectPackageJsonPathSync(projectRoot: string): string;
10
- interface LinkingOptionsFactory<OptionsType extends SearchOptions> {
11
- getProjectRoot(): Promise<string>;
12
- getPlatformOptions(platform?: SupportedPlatform): Promise<OptionsType>;
13
- }
14
- export declare function createLinkingOptionsFactory<OptionsType extends SearchOptions>(providedOptions: OptionsType): LinkingOptionsFactory<OptionsType>;
15
- /**
16
- * Merges autolinking options from different sources (the later the higher priority)
17
- * - options defined in package.json's `expo.autolinking` field
18
- * - platform-specific options from the above (e.g. `expo.autolinking.apple`)
19
- * - options provided to the CLI command
20
- */
21
- export declare function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(providedOptions: OptionsType): Promise<OptionsType>;
22
- /**
23
- * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
24
- * going up through the path components. This makes workspaces work out-of-the-box without any configs.
25
- */
26
- export declare function resolveSearchPaths(searchPaths: string[] | null, cwd: string): string[];
27
- export {};
@@ -1,112 +0,0 @@
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.getProjectPackageJsonPathAsync = getProjectPackageJsonPathAsync;
7
- exports.getProjectPackageJsonPathSync = getProjectPackageJsonPathSync;
8
- exports.createLinkingOptionsFactory = createLinkingOptionsFactory;
9
- exports.mergeLinkingOptionsAsync = mergeLinkingOptionsAsync;
10
- exports.resolveSearchPaths = resolveSearchPaths;
11
- const find_up_1 = __importDefault(require("find-up"));
12
- const fs_1 = __importDefault(require("fs"));
13
- const path_1 = __importDefault(require("path"));
14
- async function loadPackageJSONAsync(packageJsonPath) {
15
- const packageJsonText = await fs_1.default.promises.readFile(packageJsonPath, 'utf8');
16
- return JSON.parse(packageJsonText);
17
- }
18
- /**
19
- * Find the path to the `package.json` of the closest project in the given project root.
20
- */
21
- async function getProjectPackageJsonPathAsync(projectRoot) {
22
- const result = await (0, find_up_1.default)('package.json', { cwd: projectRoot });
23
- if (!result) {
24
- throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
25
- }
26
- return result;
27
- }
28
- /**
29
- * Synchronous version of {@link getProjectPackageJsonPathAsync}.
30
- */
31
- function getProjectPackageJsonPathSync(projectRoot) {
32
- const result = find_up_1.default.sync('package.json', { cwd: projectRoot });
33
- if (!result) {
34
- throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
35
- }
36
- return result;
37
- }
38
- function createLinkingOptionsFactory(providedOptions) {
39
- let _packageJsonPath;
40
- const getPackageJsonPath = async () => {
41
- return (_packageJsonPath ||
42
- (_packageJsonPath = getProjectPackageJsonPathAsync(providedOptions.projectRoot)));
43
- };
44
- let _baseOptions;
45
- const getBaseOptions = async () => {
46
- if (!_baseOptions) {
47
- _baseOptions = loadPackageJSONAsync(await getPackageJsonPath()).then((packageJson) => {
48
- return packageJson.expo?.autolinking;
49
- });
50
- }
51
- return _baseOptions;
52
- };
53
- return {
54
- async getProjectRoot() {
55
- return path_1.default.dirname(await getPackageJsonPath());
56
- },
57
- async getPlatformOptions(platform = providedOptions.platform) {
58
- const baseOptions = await getBaseOptions();
59
- const platformOptions = getPlatformOptions(platform, baseOptions);
60
- const finalOptions = Object.assign({}, baseOptions, platformOptions, providedOptions);
61
- // Makes provided paths absolute or falls back to default paths if none was provided.
62
- finalOptions.searchPaths = resolveSearchPaths(finalOptions.searchPaths || [], providedOptions.projectRoot);
63
- finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(finalOptions.nativeModulesDir, providedOptions.projectRoot);
64
- // We shouldn't assume that `projectRoot` (which typically is CWD) is already at the project root
65
- finalOptions.projectRoot = await this.getProjectRoot();
66
- return finalOptions;
67
- },
68
- };
69
- }
70
- /**
71
- * Merges autolinking options from different sources (the later the higher priority)
72
- * - options defined in package.json's `expo.autolinking` field
73
- * - platform-specific options from the above (e.g. `expo.autolinking.apple`)
74
- * - options provided to the CLI command
75
- */
76
- async function mergeLinkingOptionsAsync(providedOptions) {
77
- return await createLinkingOptionsFactory(providedOptions).getPlatformOptions();
78
- }
79
- /**
80
- * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
81
- * going up through the path components. This makes workspaces work out-of-the-box without any configs.
82
- */
83
- function resolveSearchPaths(searchPaths, cwd) {
84
- return searchPaths?.map((searchPath) => path_1.default.resolve(cwd, searchPath)) || [];
85
- }
86
- /**
87
- * Finds the real path to custom native modules directory.
88
- * - When {@link cwd} is inside the project directory, the path is searched relatively
89
- * to the project root (directory with the `package.json` file).
90
- * - When {@link cwd} is outside project directory (no `package.json` found), it is relative to
91
- * the current working directory (the {@link cwd} param).
92
- *
93
- * @param nativeModulesDir path to custom native modules directory. Defaults to `"./modules"` if null.
94
- * @param cwd current working directory
95
- * @returns resolved native modules directory or `null` if it is not found or doesn't exist.
96
- */
97
- async function resolveNativeModulesDirAsync(nativeModulesDir, cwd) {
98
- const packageJsonPath = await (0, find_up_1.default)('package.json', { cwd });
99
- const projectRoot = packageJsonPath != null ? path_1.default.join(packageJsonPath, '..') : cwd;
100
- const resolvedPath = path_1.default.resolve(projectRoot, nativeModulesDir || 'modules');
101
- return fs_1.default.existsSync(resolvedPath) ? resolvedPath : null;
102
- }
103
- /**
104
- * Gets the platform-specific autolinking options from the base options.
105
- */
106
- function getPlatformOptions(platform, options) {
107
- if (platform === 'apple') {
108
- return options?.apple ?? options?.ios ?? {};
109
- }
110
- return options?.[platform] ?? {};
111
- }
112
- //# sourceMappingURL=mergeLinkingOptions.js.map
@@ -1 +0,0 @@
1
-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,EAAE,CAAC;AACjF,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,WAA4B,EAAE,GAAW;IAC1E,OAAO,WAAW,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,4BAA4B,CACzC,gBAA2C,EAC3C,GAAW;IAEX,MAAM,eAAe,GAAG,MAAM,IAAA,iBAAM,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACrF,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,SAAS,CAAC,CAAC;IAC9E,OAAO,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CACzB,QAA2B,EAC3B,OAAoC;IAEpC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import findUp from 'find-up';\nimport fs from 'fs';\nimport path from 'path';\n\nimport type { PlatformAutolinkingOptions, SearchOptions, SupportedPlatform } from '../types';\n\nasync function loadPackageJSONAsync(packageJsonPath: string) {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n}\n\n/**\n * Find the path to the `package.json` of the closest project in the given project root.\n */\nexport async function getProjectPackageJsonPathAsync(projectRoot: string): Promise<string> {\n const result = await findUp('package.json', { cwd: projectRoot });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${projectRoot}\"`);\n }\n return result;\n}\n\n/**\n * Synchronous version of {@link getProjectPackageJsonPathAsync}.\n */\nexport function getProjectPackageJsonPathSync(projectRoot: string): string {\n const result = findUp.sync('package.json', { cwd: projectRoot });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${projectRoot}\"`);\n }\n return result;\n}\n\ninterface LinkingOptionsFactory<OptionsType extends SearchOptions> {\n getProjectRoot(): Promise<string>;\n getPlatformOptions(platform?: SupportedPlatform): Promise<OptionsType>;\n}\n\nexport function createLinkingOptionsFactory<OptionsType extends SearchOptions>(\n providedOptions: OptionsType\n): LinkingOptionsFactory<OptionsType> {\n let _packageJsonPath: Promise<string> | undefined;\n const getPackageJsonPath = async () => {\n return (\n _packageJsonPath ||\n (_packageJsonPath = getProjectPackageJsonPathAsync(providedOptions.projectRoot))\n );\n };\n\n let _baseOptions: Promise<PlatformAutolinkingOptions> | undefined;\n const getBaseOptions = async () => {\n if (!_baseOptions) {\n _baseOptions = loadPackageJSONAsync(await getPackageJsonPath()).then((packageJson) => {\n return packageJson.expo?.autolinking as PlatformAutolinkingOptions;\n });\n }\n return _baseOptions;\n };\n\n return {\n async getProjectRoot() {\n return path.dirname(await getPackageJsonPath());\n },\n async getPlatformOptions(platform = providedOptions.platform) {\n const baseOptions = await getBaseOptions();\n\n const platformOptions = getPlatformOptions(platform, baseOptions);\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 = resolveSearchPaths(\n finalOptions.searchPaths || [],\n providedOptions.projectRoot\n );\n\n finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(\n finalOptions.nativeModulesDir,\n providedOptions.projectRoot\n );\n\n // We shouldn't assume that `projectRoot` (which typically is CWD) is already at the project root\n finalOptions.projectRoot = await this.getProjectRoot();\n\n return finalOptions;\n },\n };\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.apple`)\n * - options provided to the CLI command\n */\nexport async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(\n providedOptions: OptionsType\n): Promise<OptionsType> {\n return await createLinkingOptionsFactory(providedOptions).getPlatformOptions();\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 function resolveSearchPaths(searchPaths: string[] | null, cwd: string): string[] {\n return searchPaths?.map((searchPath) => path.resolve(cwd, searchPath)) || [];\n}\n\n/**\n * Finds the real path to custom native modules directory.\n * - When {@link cwd} is inside the project directory, the path is searched relatively\n * to the project root (directory with the `package.json` file).\n * - When {@link cwd} is outside project directory (no `package.json` found), it is relative to\n * the current working directory (the {@link cwd} param).\n *\n * @param nativeModulesDir path to custom native modules directory. Defaults to `\"./modules\"` if null.\n * @param cwd current working 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 const packageJsonPath = await findUp('package.json', { cwd });\n const projectRoot = packageJsonPath != null ? path.join(packageJsonPath, '..') : cwd;\n const resolvedPath = path.resolve(projectRoot, nativeModulesDir || 'modules');\n return fs.existsSync(resolvedPath) ? resolvedPath : null;\n}\n\n/**\n * Gets the platform-specific autolinking options from the base options.\n */\nfunction getPlatformOptions(\n platform: SupportedPlatform,\n options?: PlatformAutolinkingOptions\n): PlatformAutolinkingOptions {\n if (platform === 'apple') {\n return options?.apple ?? options?.ios ?? {};\n }\n return options?.[platform] ?? {};\n}\n"]}
@@ -1,2 +0,0 @@
1
- import { SupportedPlatform } from '../types';
2
- export declare function getLinkingImplementationForPlatform(platform: SupportedPlatform): any;
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/autolinking/utils.ts"],"names":[],"mappings":";;AAEA,kFAYC;AAZD,SAAgB,mCAAmC,CAAC,QAA2B;IAC7E,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvC,KAAK,SAAS;YACZ,OAAO,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACzC,KAAK,UAAU;YACb,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["import { SupportedPlatform } from '../types';\n\nexport function getLinkingImplementationForPlatform(platform: SupportedPlatform) {\n switch (platform) {\n case 'ios':\n case 'macos':\n case 'tvos':\n case 'apple':\n return require('../platforms/apple');\n case 'android':\n return require('../platforms/android');\n case 'devtools':\n return require('../platforms/devtools');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verifySearchResults.js","sourceRoot":"","sources":["../../src/autolinking/verifySearchResults.ts"],"names":[],"mappings":";;;;;AA2BA,kDAsGC;AAjID,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAsBxB;;GAEG;AACI,KAAK,UAAU,mBAAmB,CACvC,OAAyB,EACzB,OAAsB;IAEtB,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEhC,KAAK,UAAU,0BAA0B,CAAC,UAAoC;QAC5E,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,MAAM,WAAW,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAC5C,cAAI,CAAC,IAAI,CAAC,UAAU,C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C,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAC7B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,yCAAyC,eAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpF,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;YAC7D,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBAChD,MAAM,MAAM,GAAG,GAAG,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,MAAM,0BAA0B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CACV,qGAAqG;YACnG,4HAA4H,CAC/H,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport {\n BaseDependencyResolution,\n DependencyResolution,\n DependencyResolutionSource,\n ResolutionResult,\n} from '../dependencies';\n\ninterface VerifyOptions {\n projectRoot: string;\n verbose?: boolean;\n json?: boolean;\n}\n\ninterface VerifyGroups {\n reactNativeProjectConfig: DependencyResolution[];\n searchPaths: DependencyResolution[];\n dependencies: DependencyResolution[];\n duplicates: DependencyResolution[];\n}\n\n/**\n * Verifies the search results by checking whether there are no duplicates.\n */\nexport async function verifySearchResults(\n results: ResolutionResult,\n options: VerifyOptions\n): Promise<void> {\n const { projectRoot } = options;\n\n async function getHumanReadableDependency(dependency: BaseDependencyResolution): Promise<string> {\n let version = dependency.version || null;\n if (!version) {\n try {\n const pkgContents = await fs.promises.readFile(\n path.join(dependency.path, 'package.json'),\n 'utf8'\n );\n const pkg: unknown = JSON.parse(pkgContents);\n if (pkg && typeof pkg === 'object' && 'version' in pkg && typeof pkg.version === 'string') {\n version = pkg.version;\n }\n } catch (error) {\n version = null;\n }\n }\n const relative = path.relative(projectRoot, dependency.originPath);\n return version\n ? `${dependency.name}@${version} (at: ${relative})`\n : `${dependency.name} at: ${relative}`;\n }\n\n const groups: VerifyGroups = {\n reactNativeProjectConfig: [],\n searchPaths: [],\n dependencies: [],\n duplicates: [],\n };\n\n for (const moduleName in results) {\n const revision = results[moduleName];\n if (!revision) {\n continue;\n } else if (revision.duplicates?.length) {\n groups.duplicates.push(revision);\n } else {\n switch (revision.source) {\n case DependencyResolutionSource.RN_CLI_LOCAL:\n groups.reactNativeProjectConfig.push(revision);\n break;\n case DependencyResolutionSource.SEARCH_PATH:\n groups.searchPaths.push(revision);\n break;\n case DependencyResolutionSource.RECURSIVE_RESOLUTION:\n groups.dependencies.push(revision);\n break;\n }\n }\n }\n\n if (options.json) {\n console.log(JSON.stringify(groups));\n return;\n }\n\n if (options.verbose) {\n if (groups.reactNativeProjectConfig.length) {\n console.log(\n `🔎 Found ${groups.reactNativeProjectConfig.length} modules from React Native project config`\n );\n for (const revision of groups.reactNativeProjectConfig) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n if (groups.searchPaths.length) {\n console.log(`🔎 Found ${groups.searchPaths.length} modules in search paths`);\n for (const revision of groups.searchPaths) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n console.log(`🔎 Found ${groups.dependencies.length} modules in dependencies`);\n for (const revision of groups.dependencies) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n if (groups.duplicates.length) {\n for (const revision of groups.duplicates) {\n console.warn(`⚠️ Found duplicate installations for ${chalk.green(revision.name)}`);\n const revisions = [revision, ...(revision.duplicates ?? [])];\n for (let idx = 0; idx < revisions.length; idx++) {\n const prefix = idx !== revisions.length - 1 ? '├─' : '└─';\n const duplicate = revisions[idx];\n console.log(` ${prefix} ${await getHumanReadableDependency(duplicate)}`);\n }\n }\n\n console.warn(\n '⚠️ Multiple versions of the same module may introduce some side effects or compatibility issues.\\n' +\n `Resolve your dependency issues and deduplicate your dependencies. Learn more: https://expo.fyi/resolving-dependency-issues`\n );\n } else {\n console.log('✅ Everything is fine!');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/platforms/android.ts"],"names":[],"mappings":";;;;;AAcA,4CAMC;AAKD,4DAWC;AAED,4CAKC;AAED,gDA4EC;AAED,gFAaC;AAED,gEAaC;AAyGD,kEAEC;AAaD,sFAOC;AAUD,8DAcC;AA9SD,4CAAoB;AACpB,+BAA4B;AAC5B,gDAAwB;AASxB,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AACpD,MAAM,4BAA4B,GAAG,yBAAyB,CAAC;AAE/D,SAAgB,gBAAgB,CAAC,OAAuB;IACtD,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC;IACzD,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,wBAAwB,CAC5C,OAAkC,EAClC,UAAkB,EAClB,SAAiB;IAEjB,MAAM,oBAAoB,GAAG,MAAM,mCAAmC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC3F,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,IAAI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CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAC/B,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC/C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import fs from 'fs';\nimport { glob } from 'glob';\nimport path from 'path';\n\nimport type {\n ExtraDependencies,\n ModuleDescriptorAndroid,\n PackageRevision,\n ResolveOptions,\n} from '../types';\n\nconst ANDROID_PROPERTIES_FILE = 'gradle.properties';\nconst ANDROID_EXTRA_BUILD_DEPS_KEY = 'android.extraMavenRepos';\n\nexport function getConfiguration(options: ResolveOptions): Record<string, any> | undefined {\n const buildFromSource = options.android?.buildFromSource;\n if (buildFromSource) {\n return { buildFromSource };\n }\n return undefined;\n}\n\n/**\n * Generates Java file that contains all autolinked packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorAndroid[],\n targetPath: string,\n namespace: string\n): Promise<void> {\n const generatedFileContent = await generatePackageListFileContentAsync(modules, namespace);\n const parentPath = path.dirname(targetPath);\n if (!fs.existsSync(parentPath)) {\n await fs.promises.mkdir(parentPath, { recursive: true });\n }\n await fs.promises.writeFile(targetPath, generatedFileContent, 'utf8');\n}\n\nexport function isAndroidProject(projectRoot: string): boolean {\n return (\n fs.existsSync(path.join(projectRoot, 'build.gradle')) ||\n fs.existsSync(path.join(projectRoot, 'build.gradle.kts'))\n );\n}\n\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision\n): Promise<ModuleDescriptorAndroid | null> {\n // TODO: Relative source dir should be configurable through the module config.\n\n // Don't link itself... :D\n if (packageName === '@unimodules/react-native-adapter') {\n return null;\n }\n\n const plugins = (revision.config?.androidGradlePlugins() ?? []).map(\n ({ id, group, sourceDir, applyToRootProject }) => ({\n id,\n group,\n sourceDir: path.join(revision.path, sourceDir),\n applyToRootProject: applyToRootProject ?? true,\n })\n );\n\n const defaultProjectName = convertPackageToProjectName(packageName);\n\n const androidProjects = revision.config\n ?.androidProjects(defaultProjectName)\n ?.filter((project) => {\n return !project.isDefault || isAndroidProject(path.join(revision.path, project.path));\n });\n\n // Just in case where the module doesn't have its own `build.gradle`/`settings.gradle`.\n if (!androidProjects?.length) {\n if (!plugins.length) {\n return null;\n }\n\n return {\n packageName,\n plugins,\n };\n }\n\n const projects = androidProjects.map((project) => {\n const projectPath = path.join(revision.path, project.path);\n\n const aarProjects = (project.gradleAarProjects ?? [])?.map((aarProject) => {\n const projectName = `${defaultProjectName}$${aarProject.name}`;\n const projectDir = path.join(projectPath, 'build', projectName);\n return {\n name: projectName,\n aarFilePath: path.join(revision.path, aarProject.aarFilePath),\n projectDir,\n };\n });\n\n const { publication } = project;\n const shouldUsePublicationScriptPath = project.shouldUsePublicationScriptPath\n ? path.join(revision.path, project.shouldUsePublicationScriptPath)\n : undefined;\n\n return {\n name: project.name,\n sourceDir: projectPath,\n modules: project.modules ?? [],\n ...(shouldUsePublicationScriptPath ? { shouldUsePublicationScriptPath } : {}),\n ...(publication ? { publication } : {}),\n ...(aarProjects?.length > 0 ? { aarProjects } : {}),\n };\n });\n\n const coreFeatures = revision.config?.coreFeatures() ?? [];\n\n return {\n packageName,\n projects,\n ...(plugins?.length > 0 ? { plugins } : {}),\n ...(coreFeatures.length > 0 ? { coreFeatures } : {}),\n };\n}\n\nexport async function resolveExtraBuildDependenciesAsync(\n projectNativeRoot: string\n): Promise<ExtraDependencies | null> {\n const extraMavenReposString = await resolveGradlePropertyAsync(\n projectNativeRoot,\n ANDROID_EXTRA_BUILD_DEPS_KEY\n );\n if (extraMavenReposString) {\n try {\n return JSON.parse(extraMavenReposString);\n } catch {}\n }\n return null;\n}\n\nexport async function resolveGradlePropertyAsync(\n projectNativeRoot: string,\n propertyKey: string\n): Promise<string | null> {\n const propsFile = path.join(projectNativeRoot, ANDROID_PROPERTIES_FILE);\n try {\n const contents = await fs.promises.readFile(propsFile, 'utf8');\n const propertyValue = searchGradlePropertyFirst(contents, propertyKey);\n if (propertyValue) {\n return propertyValue;\n }\n } catch {}\n return null;\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorAndroid[],\n namespace: string\n): Promise<string> {\n // TODO: Instead of ignoring `expo` here, make the package class paths configurable from `expo-module.config.json`.\n const packagesClasses = await findAndroidPackagesAsync(\n modules.filter((module) => module.packageName !== 'expo')\n );\n\n const modulesClasses = await findAndroidModules(modules);\n\n return `package ${namespace};\n\nimport java.util.Arrays;\nimport java.util.List;\nimport expo.modules.core.interfaces.Package;\nimport expo.modules.kotlin.modules.Module;\nimport expo.modules.kotlin.ModulesProvider;\n\npublic class ExpoModulesPackageList implements ModulesProvider {\n private static class LazyHolder {\n static final List<Package> packagesList = Arrays.<Package>asList(\n${packagesClasses.map((packageClass) => ` new ${packageClass}()`).join(',\\n')}\n );\n\n static final List<Class<? extends Module>> modulesList = Arrays.<Class<? extends Module>>asList(\n ${modulesClasses.map((moduleClass) => ` ${moduleClass}.class`).join(',\\n')}\n );\n }\n\n public static List<Package> getPackageList() {\n return LazyHolder.packagesList;\n }\n\n @Override\n public List<Class<? extends Module>> getModulesList() {\n return LazyHolder.modulesList;\n }\n}\n`;\n}\n\nfunction findAndroidModules(modules: ModuleDescriptorAndroid[]): string[] {\n const projects = modules.flatMap((module) => module.projects ?? []);\n\n const modulesToProvide = projects.filter((project) => project.modules?.length > 0);\n const classNames = ([] as string[]).concat(...modulesToProvide.map((module) => module.modules));\n return classNames;\n}\n\nasync function findAndroidPackagesAsync(modules: ModuleDescriptorAndroid[]): Promise<string[]> {\n const classes: string[] = [];\n\n const flattenedSourceDirList: string[] = [];\n for (const module of modules) {\n for (const project of module.projects ?? []) {\n flattenedSourceDirList.push(project.sourceDir);\n }\n }\n\n await Promise.all(\n flattenedSourceDirList.map(async (sourceDir) => {\n const files = await glob('**/*Package.{java,kt}', {\n cwd: sourceDir,\n });\n\n for (const file of files) {\n const fileContent = await fs.promises.readFile(path.join(sourceDir, file), 'utf8');\n\n const packageRegex = (() => {\n if (process.env.EXPO_SHOULD_USE_LEGACY_PACKAGE_INTERFACE) {\n return /\\bimport\\s+org\\.unimodules\\.core\\.(interfaces\\.Package|BasePackage)\\b/;\n } else {\n return /\\bimport\\s+expo\\.modules\\.core\\.(interfaces\\.Package|BasePackage)\\b/;\n }\n })();\n\n // Very naive check to skip non-expo packages\n if (!packageRegex.test(fileContent)) {\n continue;\n }\n\n const classPathMatches = fileContent.match(/^package ([\\w.]+)\\b/m);\n\n if (classPathMatches) {\n const basename = path.basename(file, path.extname(file));\n classes.push(`${classPathMatches[1]}.${basename}`);\n }\n }\n })\n );\n return classes.sort();\n}\n\n/**\n * Converts the package name to Android's project name.\n * `/` path will transform as `-`\n *\n * Example: `@expo/example` + `android/build.gradle` → `expo-example`\n */\nexport function convertPackageToProjectName(packageName: string): string {\n return packageName.replace(/^@/g, '').replace(/\\W+/g, '-');\n}\n\n/**\n * Converts the package name and gradle file path to Android's project name.\n * `$` to indicate subprojects\n * `/` path will transform as `-`\n *\n * Example: `@expo/example` + `android/build.gradle` → `expo-example`\n *\n * Example: multiple projects\n * - `expo-test` + `android/build.gradle` → `react-native-third-party`\n * - `expo-test` + `subproject/build.gradle` → `react-native-third-party$subproject`\n */\nexport function convertPackageWithGradleToProjectName(\n packageName: string,\n buildGradleFile: string\n): string {\n const name = convertPackageToProjectName(packageName);\n const baseDir = path.dirname(buildGradleFile).replace(/\\//g, '-');\n return baseDir === 'android' ? name : `${name}$${baseDir}`;\n}\n\n/**\n * Given the contents of a `gradle.properties` file,\n * searches for a property with the given name.\n *\n * This function will return the first property found with the given name.\n * The implementation follows config-plugins and\n * tries to align the behavior with the `withGradleProperties` plugin.\n */\nexport function searchGradlePropertyFirst(contents: string, propertyName: string): string | null {\n const lines = contents.split('\\n');\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim();\n if (line && !line.startsWith('#')) {\n const eok = line.indexOf('=');\n const key = line.slice(0, eok);\n if (key === propertyName) {\n const value = line.slice(eok + 1, line.length);\n return value;\n }\n }\n }\n return null;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"apple.js","sourceRoot":"","sources":["../../src/platforms/apple.ts"],"names":[],"mappings":";;;;;AAkCA,kDASC;AAKD,gDA6BC;AAED,gFAcC;AAKD,oEAeC;AA4ID,8EASC;AAtQD,oEAA2C;AAC3C,4CAAoB;AACpB,+BAA4B;AAC5B,gDAAwB;AAExB,4CAA+C;AAU/C,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AACxD,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAErD,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,KAAK,UAAU,gBAAgB,CAAC,QAAyB;IACvD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAChE,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,WAAI,EAAC,aAAa,EAAE;QAC7C,GAAG,EAAE,QAAQ,CAAC,IAAI;QAClB,MAAM,EAAE,CAAC,oBAAoB,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,mBAAmB,CACjC,IAA4B,EAC5B,gBAAsC;IAEtC,IAAI,gBAAgB,IAAI,gB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C,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,eAAuB;IAC3D,IAAI,CAAC,CAAC,MAAM,IAAA,2BAAe,EAAC,eAAe,CAAC,CAAC,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAU,EAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;IAChG,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO;QACL,SAAS,EAAE,gBAAgB,CAAC,uCAAuC,CAAC,IAAI,SAAS;KAClF,CAAC;AACJ,CAAC","sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport fs from 'fs';\nimport { glob } from 'glob';\nimport path from 'path';\n\nimport { fileExistsAsync } from '../fileUtils';\nimport type {\n AppleCodeSignEntitlements,\n ExtraDependencies,\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst APPLE_PROPERTIES_FILE = 'Podfile.properties.json';\nconst APPLE_EXTRA_BUILD_DEPS_KEY = 'apple.extraPods';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise<string[]> {\n const configPodspecPaths = revision.config?.applePodspecPaths();\n if (configPodspecPaths && configPodspecPaths.length) {\n return configPodspecPaths;\n }\n\n const podspecFiles = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n return podspecFiles;\n}\n\nexport function getSwiftModuleNames(\n pods: ModuleIosPodspecInfo[],\n swiftModuleNames: string[] | undefined\n): string[] {\n if (swiftModuleNames && swiftModuleNames.length) {\n return swiftModuleNames;\n }\n // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name\n return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));\n}\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise<ModuleDescriptorIos | null> {\n const podspecFiles = await findPodspecFiles(revision);\n if (!podspecFiles.length) {\n return null;\n }\n\n const pods = podspecFiles.map((podspecFile) => ({\n podName: path.basename(podspecFile, path.extname(podspecFile)),\n podspecDir: path.dirname(path.join(revision.path, podspecFile)),\n }));\n\n const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.appleSwiftModuleNames());\n const coreFeatures = revision.config?.coreFeatures() ?? [];\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.appleModules() ?? [],\n appDelegateSubscribers: revision.config?.appleAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.appleReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.appleDebugOnly() ?? false,\n ...(coreFeatures.length > 0 ? { coreFeatures } : {}),\n };\n}\n\nexport async function resolveExtraBuildDependenciesAsync(\n projectNativeRoot: string\n): Promise<ExtraDependencies | null> {\n const propsFile = path.join(projectNativeRoot, APPLE_PROPERTIES_FILE);\n try {\n const contents = await fs.promises.readFile(propsFile, 'utf8');\n const podfileJson = JSON.parse(contents);\n if (podfileJson[APPLE_EXTRA_BUILD_DEPS_KEY]) {\n // expo-build-properties would serialize the extraPods as JSON string, we should parse it again.\n const extraPods = JSON.parse(podfileJson[APPLE_EXTRA_BUILD_DEPS_KEY]);\n return extraPods;\n }\n } catch {}\n return null;\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generateModulesProviderAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string,\n entitlementPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const entitlements = await parseEntitlementsAsync(entitlementPath);\n const generatedFileContent = await generatePackageListFileContentAsync(\n modules,\n className,\n entitlements\n );\n const parentPath = path.dirname(targetPath);\n await fs.promises.mkdir(parentPath, { recursive: true });\n await fs.promises.writeFile(targetPath, generatedFileContent, 'utf8');\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorIos[],\n className: string,\n entitlements: AppleCodeSignEntitlements\n): Promise<string> {\n const iosModules = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n\n const modulesToImport = iosModules.filter((module) => !module.debugOnly);\n const debugOnlyModules = iosModules.filter((module) => module.debugOnly);\n\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const debugOnlySwiftModules = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const modulesClassNames = ([] as string[])\n .concat(...modulesToImport.map((module) => module.modules))\n .filter(Boolean);\n\n const debugOnlyModulesClassNames = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.modules))\n .filter(Boolean);\n\n const appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(\n ...debugOnlyModules.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${generateCommonImportList(swiftModules)}\n${generateDebugOnlyImportList(debugOnlySwiftModules)}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}\n }\n\n public override func getAppCodeSignEntitlements() -> AppCodeSignEntitlements {\n return AppCodeSignEntitlements.from(json: #\"${JSON.stringify(entitlements)}\"#)\n }\n}\n`;\n}\n\nfunction generateCommonImportList(swiftModules: string[]): string {\n return swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return (\n wrapInDebugConfigurationCheck(\n 0,\n swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n')\n ) + '\\n'\n );\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,\n `return ${commonClassNames}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonClassNames}`;\n }\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction generateReactDelegateHandlers(\n module: ModuleDescriptorIos[],\n debugOnlyModules: ModuleDescriptorIos[]\n): string {\n const commonModules = formatArrayOfReactDelegateHandler(module);\n if (debugOnlyModules.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,\n `return ${commonModules}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonModules}`;\n }\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction wrapInDebugConfigurationCheck(\n indentationLevel: number,\n debugBlock: string,\n releaseBlock: string | null = null\n) {\n if (releaseBlock) {\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#else\\n${indent.repeat(\n indentationLevel\n )}${releaseBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n }\n\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n}\n\nasync function parseEntitlementsAsync(entitlementPath: string): Promise<AppleCodeSignEntitlements> {\n if (!(await fileExistsAsync(entitlementPath))) {\n return {};\n }\n const { stdout } = await spawnAsync('plutil', ['-convert', 'json', '-o', '-', entitlementPath]);\n const entitlementsJson = JSON.parse(stdout);\n return {\n appGroups: entitlementsJson['com.apple.security.application-groups'] || undefined,\n };\n}\n"]}
@@ -1,146 +0,0 @@
1
- import findUp from 'find-up';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- import type { PlatformAutolinkingOptions, SearchOptions, SupportedPlatform } from '../types';
6
-
7
- async function loadPackageJSONAsync(packageJsonPath: string) {
8
- const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');
9
- return JSON.parse(packageJsonText);
10
- }
11
-
12
- /**
13
- * Find the path to the `package.json` of the closest project in the given project root.
14
- */
15
- export async function getProjectPackageJsonPathAsync(projectRoot: string): Promise<string> {
16
- const result = await findUp('package.json', { cwd: projectRoot });
17
- if (!result) {
18
- throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
19
- }
20
- return result;
21
- }
22
-
23
- /**
24
- * Synchronous version of {@link getProjectPackageJsonPathAsync}.
25
- */
26
- export function getProjectPackageJsonPathSync(projectRoot: string): string {
27
- const result = findUp.sync('package.json', { cwd: projectRoot });
28
- if (!result) {
29
- throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
30
- }
31
- return result;
32
- }
33
-
34
- interface LinkingOptionsFactory<OptionsType extends SearchOptions> {
35
- getProjectRoot(): Promise<string>;
36
- getPlatformOptions(platform?: SupportedPlatform): Promise<OptionsType>;
37
- }
38
-
39
- export function createLinkingOptionsFactory<OptionsType extends SearchOptions>(
40
- providedOptions: OptionsType
41
- ): LinkingOptionsFactory<OptionsType> {
42
- let _packageJsonPath: Promise<string> | undefined;
43
- const getPackageJsonPath = async () => {
44
- return (
45
- _packageJsonPath ||
46
- (_packageJsonPath = getProjectPackageJsonPathAsync(providedOptions.projectRoot))
47
- );
48
- };
49
-
50
- let _baseOptions: Promise<PlatformAutolinkingOptions> | undefined;
51
- const getBaseOptions = async () => {
52
- if (!_baseOptions) {
53
- _baseOptions = loadPackageJSONAsync(await getPackageJsonPath()).then((packageJson) => {
54
- return packageJson.expo?.autolinking as PlatformAutolinkingOptions;
55
- });
56
- }
57
- return _baseOptions;
58
- };
59
-
60
- return {
61
- async getProjectRoot() {
62
- return path.dirname(await getPackageJsonPath());
63
- },
64
- async getPlatformOptions(platform = providedOptions.platform) {
65
- const baseOptions = await getBaseOptions();
66
-
67
- const platformOptions = getPlatformOptions(platform, baseOptions);
68
- const finalOptions = Object.assign(
69
- {},
70
- baseOptions,
71
- platformOptions,
72
- providedOptions
73
- ) as OptionsType;
74
-
75
- // Makes provided paths absolute or falls back to default paths if none was provided.
76
- finalOptions.searchPaths = resolveSearchPaths(
77
- finalOptions.searchPaths || [],
78
- providedOptions.projectRoot
79
- );
80
-
81
- finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(
82
- finalOptions.nativeModulesDir,
83
- providedOptions.projectRoot
84
- );
85
-
86
- // We shouldn't assume that `projectRoot` (which typically is CWD) is already at the project root
87
- finalOptions.projectRoot = await this.getProjectRoot();
88
-
89
- return finalOptions;
90
- },
91
- };
92
- }
93
-
94
- /**
95
- * Merges autolinking options from different sources (the later the higher priority)
96
- * - options defined in package.json's `expo.autolinking` field
97
- * - platform-specific options from the above (e.g. `expo.autolinking.apple`)
98
- * - options provided to the CLI command
99
- */
100
- export async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(
101
- providedOptions: OptionsType
102
- ): Promise<OptionsType> {
103
- return await createLinkingOptionsFactory(providedOptions).getPlatformOptions();
104
- }
105
-
106
- /**
107
- * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
108
- * going up through the path components. This makes workspaces work out-of-the-box without any configs.
109
- */
110
- export function resolveSearchPaths(searchPaths: string[] | null, cwd: string): string[] {
111
- return searchPaths?.map((searchPath) => path.resolve(cwd, searchPath)) || [];
112
- }
113
-
114
- /**
115
- * Finds the real path to custom native modules directory.
116
- * - When {@link cwd} is inside the project directory, the path is searched relatively
117
- * to the project root (directory with the `package.json` file).
118
- * - When {@link cwd} is outside project directory (no `package.json` found), it is relative to
119
- * the current working directory (the {@link cwd} param).
120
- *
121
- * @param nativeModulesDir path to custom native modules directory. Defaults to `"./modules"` if null.
122
- * @param cwd current working directory
123
- * @returns resolved native modules directory or `null` if it is not found or doesn't exist.
124
- */
125
- async function resolveNativeModulesDirAsync(
126
- nativeModulesDir: string | null | undefined,
127
- cwd: string
128
- ): Promise<string | null> {
129
- const packageJsonPath = await findUp('package.json', { cwd });
130
- const projectRoot = packageJsonPath != null ? path.join(packageJsonPath, '..') : cwd;
131
- const resolvedPath = path.resolve(projectRoot, nativeModulesDir || 'modules');
132
- return fs.existsSync(resolvedPath) ? resolvedPath : null;
133
- }
134
-
135
- /**
136
- * Gets the platform-specific autolinking options from the base options.
137
- */
138
- function getPlatformOptions(
139
- platform: SupportedPlatform,
140
- options?: PlatformAutolinkingOptions
141
- ): PlatformAutolinkingOptions {
142
- if (platform === 'apple') {
143
- return options?.apple ?? options?.ios ?? {};
144
- }
145
- return options?.[platform] ?? {};
146
- }
@@ -1,15 +0,0 @@
1
- import { SupportedPlatform } from '../types';
2
-
3
- export function getLinkingImplementationForPlatform(platform: SupportedPlatform) {
4
- switch (platform) {
5
- case 'ios':
6
- case 'macos':
7
- case 'tvos':
8
- case 'apple':
9
- return require('../platforms/apple');
10
- case 'android':
11
- return require('../platforms/android');
12
- case 'devtools':
13
- return require('../platforms/devtools');
14
- }
15
- }