expo-modules-autolinking 1.10.0 → 1.10.1
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.
- package/CHANGELOG.md +6 -0
- package/build/ExpoModuleConfig.d.ts +11 -7
- package/build/ExpoModuleConfig.js +27 -14
- package/build/ExpoModuleConfig.js.map +1 -1
- package/build/autolinking/mergeLinkingOptions.d.ts +1 -1
- package/build/autolinking/mergeLinkingOptions.js +11 -2
- package/build/autolinking/mergeLinkingOptions.js.map +1 -1
- package/build/autolinking/utils.js +1 -0
- package/build/autolinking/utils.js.map +1 -1
- package/build/index.js +11 -1
- package/build/index.js.map +1 -1
- package/build/platforms/apple.js +6 -6
- package/build/platforms/apple.js.map +1 -1
- package/build/types.d.ts +61 -36
- package/build/types.js.map +1 -1
- package/package.json +2 -2
- package/scripts/ios/autolinking_manager.rb +17 -28
- package/scripts/ios/package.rb +17 -0
- package/scripts/ios/project_integrator.rb +10 -3
- package/src/ExpoModuleConfig.ts +35 -15
- package/src/autolinking/mergeLinkingOptions.ts +17 -4
- package/src/autolinking/utils.ts +1 -0
- package/src/index.ts +30 -3
- package/src/platforms/apple.ts +6 -6
- package/src/types.ts +69 -40
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.10.1 — 2024-01-18
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Introduced a universal `"apple"` platform as a replacement for `"ios"`, `"macos"` and `"tvos"`. ([#26398](https://github.com/expo/expo/pull/26398) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
|
|
13
19
|
## 1.10.0 — 2024-01-10
|
|
14
20
|
|
|
15
21
|
### 🎉 New features
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AndroidGradlePluginDescriptor, RawExpoModuleConfig, SupportedPlatform } from './types';
|
|
1
|
+
import { AndroidGradlePluginDescriptor, RawExpoModuleConfig, RawModuleConfigApple, SupportedPlatform } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* A class that wraps the raw config (`expo-module.json` or `unimodule.json`).
|
|
4
4
|
*/
|
|
@@ -9,30 +9,34 @@ export declare class ExpoModuleConfig {
|
|
|
9
9
|
* Whether the module supports given platform.
|
|
10
10
|
*/
|
|
11
11
|
supportsPlatform(platform: SupportedPlatform): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.
|
|
14
|
+
*/
|
|
15
|
+
getAppleConfig(): RawModuleConfigApple | null;
|
|
12
16
|
/**
|
|
13
17
|
* Returns a list of names of Swift native modules classes to put to the generated modules provider file.
|
|
14
18
|
*/
|
|
15
|
-
|
|
19
|
+
appleModules(): string[];
|
|
16
20
|
/**
|
|
17
21
|
* Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
|
|
18
22
|
*/
|
|
19
|
-
|
|
23
|
+
appleAppDelegateSubscribers(): string[];
|
|
20
24
|
/**
|
|
21
25
|
* Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
|
|
22
26
|
*/
|
|
23
|
-
|
|
27
|
+
appleReactDelegateHandlers(): string[];
|
|
24
28
|
/**
|
|
25
29
|
* Returns podspec paths defined by the module author.
|
|
26
30
|
*/
|
|
27
|
-
|
|
31
|
+
applePodspecPaths(): string[];
|
|
28
32
|
/**
|
|
29
33
|
* Returns the product module names, if defined by the module author.
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
appleSwiftModuleNames(): string[];
|
|
32
36
|
/**
|
|
33
37
|
* Returns whether this module will be added only to the debug configuration
|
|
34
38
|
*/
|
|
35
|
-
|
|
39
|
+
appleDebugOnly(): boolean;
|
|
36
40
|
/**
|
|
37
41
|
* Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
|
|
38
42
|
*/
|
|
@@ -19,45 +19,58 @@ class ExpoModuleConfig {
|
|
|
19
19
|
* Whether the module supports given platform.
|
|
20
20
|
*/
|
|
21
21
|
supportsPlatform(platform) {
|
|
22
|
-
|
|
22
|
+
const supportedPlatforms = this.rawConfig.platforms ?? [];
|
|
23
|
+
if (platform === 'apple') {
|
|
24
|
+
// Apple platform is supported when any of iOS, macOS and tvOS is supported.
|
|
25
|
+
return supportedPlatforms.some((supportedPlatform) => {
|
|
26
|
+
return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return supportedPlatforms.includes(platform);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.
|
|
33
|
+
*/
|
|
34
|
+
getAppleConfig() {
|
|
35
|
+
return this.rawConfig.apple ?? this.rawConfig.ios ?? null;
|
|
23
36
|
}
|
|
24
37
|
/**
|
|
25
38
|
* Returns a list of names of Swift native modules classes to put to the generated modules provider file.
|
|
26
39
|
*/
|
|
27
|
-
|
|
28
|
-
const
|
|
40
|
+
appleModules() {
|
|
41
|
+
const appleConfig = this.getAppleConfig();
|
|
29
42
|
// `modulesClassNames` is a legacy name for the same config.
|
|
30
|
-
return
|
|
43
|
+
return appleConfig?.modules ?? appleConfig?.modulesClassNames ?? [];
|
|
31
44
|
}
|
|
32
45
|
/**
|
|
33
46
|
* Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
|
|
34
47
|
*/
|
|
35
|
-
|
|
36
|
-
return this.
|
|
48
|
+
appleAppDelegateSubscribers() {
|
|
49
|
+
return this.getAppleConfig()?.appDelegateSubscribers ?? [];
|
|
37
50
|
}
|
|
38
51
|
/**
|
|
39
52
|
* Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
|
|
40
53
|
*/
|
|
41
|
-
|
|
42
|
-
return this.
|
|
54
|
+
appleReactDelegateHandlers() {
|
|
55
|
+
return this.getAppleConfig()?.reactDelegateHandlers ?? [];
|
|
43
56
|
}
|
|
44
57
|
/**
|
|
45
58
|
* Returns podspec paths defined by the module author.
|
|
46
59
|
*/
|
|
47
|
-
|
|
48
|
-
return arrayize(this.
|
|
60
|
+
applePodspecPaths() {
|
|
61
|
+
return arrayize(this.getAppleConfig()?.podspecPath);
|
|
49
62
|
}
|
|
50
63
|
/**
|
|
51
64
|
* Returns the product module names, if defined by the module author.
|
|
52
65
|
*/
|
|
53
|
-
|
|
54
|
-
return arrayize(this.
|
|
66
|
+
appleSwiftModuleNames() {
|
|
67
|
+
return arrayize(this.getAppleConfig()?.swiftModuleName);
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
57
70
|
* Returns whether this module will be added only to the debug configuration
|
|
58
71
|
*/
|
|
59
|
-
|
|
60
|
-
return this.
|
|
72
|
+
appleDebugOnly() {
|
|
73
|
+
return this.getAppleConfig()?.debugOnly ?? false;
|
|
61
74
|
}
|
|
62
75
|
/**
|
|
63
76
|
* Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAOA,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAa,gBAAgB;IACN;IAArB,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;QAC1C,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,EAAE,CAA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AAC,SAAS,CAAC,OAAO,CAAC;QAE7C,4DAA4D;QAC5D,OAAO,aAAa,EAAE,OAAO,IAAI,aAAa,EAAE,iBAAiB,IAAI,EAAE,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,oBAAoB;QAClB,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AApGD,4CAoGC;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 {\n AndroidGradlePluginDescriptor,\n RawExpoModuleConfig,\n RawModuleConfigApple,\n SupportedPlatform,\n} from './types';\n\nfunction arrayize<T>(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n const supportedPlatforms = this.rawConfig.platforms ?? [];\n\n if (platform === 'apple') {\n // Apple platform is supported when any of iOS, macOS and tvOS is supported.\n return supportedPlatforms.some((supportedPlatform) => {\n return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);\n });\n }\n return supportedPlatforms.includes(platform);\n }\n\n /**\n * Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.\n */\n getAppleConfig(): RawModuleConfigApple | null {\n return this.rawConfig.apple ?? this.rawConfig.ios ?? null;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n appleModules() {\n const appleConfig = this.getAppleConfig();\n\n // `modulesClassNames` is a legacy name for the same config.\n return appleConfig?.modules ?? appleConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n appleAppDelegateSubscribers(): string[] {\n return this.getAppleConfig()?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n appleReactDelegateHandlers(): string[] {\n return this.getAppleConfig()?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n applePodspecPaths(): string[] {\n return arrayize(this.getAppleConfig()?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n appleSwiftModuleNames(): string[] {\n return arrayize(this.getAppleConfig()?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n appleDebugOnly(): boolean {\n return this.getAppleConfig()?.debugOnly ?? false;\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModules() {\n const androidConfig = this.rawConfig.android;\n\n // `modulesClassNames` is a legacy name for the same config.\n return androidConfig?.modules ?? androidConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns build.gradle file paths defined by the module author.\n */\n androidGradlePaths(): string[] {\n return arrayize(this.rawConfig.android?.gradlePath ?? []);\n }\n\n /**\n * Returns gradle plugins descriptors defined by the module author.\n */\n androidGradlePlugins(): AndroidGradlePluginDescriptor[] {\n return arrayize(this.rawConfig.android?.gradlePlugins ?? []);\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"]}
|
|
@@ -6,7 +6,7 @@ export declare function getProjectPackageJsonPathAsync(projectRoot: string): Pro
|
|
|
6
6
|
/**
|
|
7
7
|
* Merges autolinking options from different sources (the later the higher priority)
|
|
8
8
|
* - options defined in package.json's `expo.autolinking` field
|
|
9
|
-
* - platform-specific options from the above (e.g. `expo.autolinking.
|
|
9
|
+
* - platform-specific options from the above (e.g. `expo.autolinking.apple`)
|
|
10
10
|
* - options provided to the CLI command
|
|
11
11
|
*/
|
|
12
12
|
export declare function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(providedOptions: OptionsType): Promise<OptionsType>;
|
|
@@ -21,13 +21,13 @@ exports.getProjectPackageJsonPathAsync = getProjectPackageJsonPathAsync;
|
|
|
21
21
|
/**
|
|
22
22
|
* Merges autolinking options from different sources (the later the higher priority)
|
|
23
23
|
* - options defined in package.json's `expo.autolinking` field
|
|
24
|
-
* - platform-specific options from the above (e.g. `expo.autolinking.
|
|
24
|
+
* - platform-specific options from the above (e.g. `expo.autolinking.apple`)
|
|
25
25
|
* - options provided to the CLI command
|
|
26
26
|
*/
|
|
27
27
|
async function mergeLinkingOptionsAsync(providedOptions) {
|
|
28
28
|
const packageJson = require(await getProjectPackageJsonPathAsync(providedOptions.projectRoot));
|
|
29
29
|
const baseOptions = packageJson.expo?.autolinking;
|
|
30
|
-
const platformOptions = providedOptions.platform
|
|
30
|
+
const platformOptions = getPlatformOptions(providedOptions.platform, baseOptions);
|
|
31
31
|
const finalOptions = Object.assign({}, baseOptions, platformOptions, providedOptions);
|
|
32
32
|
// Makes provided paths absolute or falls back to default paths if none was provided.
|
|
33
33
|
finalOptions.searchPaths = await resolveSearchPathsAsync(finalOptions.searchPaths, providedOptions.projectRoot);
|
|
@@ -79,4 +79,13 @@ async function resolveNativeModulesDirAsync(nativeModulesDir, cwd) {
|
|
|
79
79
|
const resolvedPath = path_1.default.resolve(projectRoot, nativeModulesDir || 'modules');
|
|
80
80
|
return fs_extra_1.default.existsSync(resolvedPath) ? resolvedPath : null;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Gets the platform-specific autolinking options from the base options.
|
|
84
|
+
*/
|
|
85
|
+
function getPlatformOptions(platform, options) {
|
|
86
|
+
if (platform === 'apple') {
|
|
87
|
+
return options?.apple ?? options?.ios ?? {};
|
|
88
|
+
}
|
|
89
|
+
return options?.[platform] ?? {};
|
|
90
|
+
}
|
|
82
91
|
//# sourceMappingURL=mergeLinkingOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLinkingOptions.js","sourceRoot":"","sources":["../../src/autolinking/mergeLinkingOptions.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;GAEG;AACI,KAAK,UAAU,8BAA8B,CAAC,WAAmB;IACtE,MAAM,MAAM,GAAG,MAAM,IAAA,iBAAM,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,8CAA8C,WAAW,GAAG,CAAC,CAAC;KAC/E;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,wEAMC;AAED;;;;;GAKG;AACI,KAAK,UAAU,wBAAwB,CAC5C,eAA4B;IAE5B,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,8BAA8B,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/F,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"mergeLinkingOptions.js","sourceRoot":"","sources":["../../src/autolinking/mergeLinkingOptions.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,wDAA0B;AAC1B,g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QAA2B,EAC3B,OAA4B;IAE5B,IAAI,QAAQ,KAAK,OAAO,EAAE;QACxB,OAAO,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;KAC7C;IACD,OAAO,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { AutolinkingOptions, SearchOptions, SupportedPlatform } from '../types';\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 * 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 const packageJson = require(await getProjectPackageJsonPathAsync(providedOptions.projectRoot));\n const baseOptions = packageJson.expo?.autolinking as AutolinkingOptions;\n const platformOptions = getPlatformOptions(providedOptions.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 = await resolveSearchPathsAsync(\n finalOptions.searchPaths,\n providedOptions.projectRoot\n );\n\n finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(\n finalOptions.nativeModulesDir,\n providedOptions.projectRoot\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 // This stops the infinite loop when the package.json is placed at the root dir.\n if (path.dirname(dir) === dir) {\n break;\n }\n }\n return paths;\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?: AutolinkingOptions\n): AutolinkingOptions {\n if (platform === 'apple') {\n return options?.apple ?? options?.ios ?? {};\n }\n return options?.[platform] ?? {};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/autolinking/utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mCAAmC,CAAC,QAA2B;IAC7E,QAAQ,QAAQ,EAAE;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/autolinking/utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mCAAmC,CAAC,QAA2B;IAC7E,QAAQ,QAAQ,EAAE;QAChB,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;KAC3C;AACH,CAAC;AAZD,kFAYC","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"]}
|
package/build/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function registerSearchCommand(commandName, fn) {
|
|
|
15
15
|
.command(`${commandName} [paths...]`)
|
|
16
16
|
.option('-i, --ignore-paths <ignorePaths...>', 'Paths to ignore when looking up for modules.', (value, previous) => (previous ?? []).concat(value))
|
|
17
17
|
.option('-e, --exclude <exclude...>', 'Package names to exclude when looking up for modules.', (value, previous) => (previous ?? []).concat(value))
|
|
18
|
-
.option('-p, --platform [platform]', 'The platform that the resulting modules must support. Available options: "
|
|
18
|
+
.option('-p, --platform [platform]', 'The platform that the resulting modules must support. Available options: "apple", "android"', 'apple')
|
|
19
19
|
.option('--silent', 'Silence resolution warnings')
|
|
20
20
|
.addOption(new commander_1.default.Option('--project-root <projectRoot>', 'The path to the root of the project').default(process.cwd(), 'process.cwd()'))
|
|
21
21
|
.option('--only-project-deps', 'For a monorepo, include only modules that are the project dependencies.', true)
|
|
@@ -72,6 +72,7 @@ module.exports = async function (args) {
|
|
|
72
72
|
}
|
|
73
73
|
}).option('-j, --json', 'Output results in the plain JSON format.', () => true, false);
|
|
74
74
|
// Generates a source file listing all packages to link.
|
|
75
|
+
// It's deprecated, use `generate-modules-provider` instead.
|
|
75
76
|
registerResolveCommand('generate-package-list', async (results, options) => {
|
|
76
77
|
const modules = options.empty ? [] : await (0, autolinking_1.resolveModulesAsync)(results, options);
|
|
77
78
|
(0, autolinking_1.generatePackageListAsync)(modules, options);
|
|
@@ -79,6 +80,15 @@ module.exports = async function (args) {
|
|
|
79
80
|
.option('-t, --target <path>', 'Path to the target file, where the package list should be written to.')
|
|
80
81
|
.option('-n, --namespace <namespace>', 'Java package name under which the package list should be placed.')
|
|
81
82
|
.option('--empty', 'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.', false);
|
|
83
|
+
// Generates a source file listing all packages to link in the runtime.
|
|
84
|
+
registerResolveCommand('generate-modules-provider', async (results, options) => {
|
|
85
|
+
const packages = options.packages ?? [];
|
|
86
|
+
const modules = await (0, autolinking_1.resolveModulesAsync)(results, options);
|
|
87
|
+
const filteredModules = modules.filter((module) => packages.includes(module.packageName));
|
|
88
|
+
(0, autolinking_1.generatePackageListAsync)(filteredModules, options);
|
|
89
|
+
})
|
|
90
|
+
.option('-t, --target <path>', 'Path to the target file, where the package list should be written to.')
|
|
91
|
+
.option('-p, --packages <packages...>', 'Names of the packages to include in the generated modules provider.');
|
|
82
92
|
registerPatchReactImportsCommand();
|
|
83
93
|
await commander_1.default
|
|
84
94
|
.version(require('expo-modules-autolinking/package.json').version)
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,+DAA+D;AAC/D,+CAMuB;AACvB,uEAAgF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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AAM,IAAA,iCAAmB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;QAE1F,IAAA,sCAAwB,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC,CACF;SACE,MAAM,CACL,qBAAqB,EACrB,uEAAuE,CACxE;SACA,MAAM,CACL,8BAA8B,EAC9B,qEAAqE,CACtE,CAAC;IAEJ,gCAAgC,EAAE,CAAC;IAEnC,MAAM,mBAAS;SACZ,OAAO,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC,OAAO,CAAC;SACjE,WAAW,CAAC,8DAA8D,CAAC;SAC3E,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import commander from 'commander';\n\nimport { patchReactImportsAsync } from './ReactImportsPatcher';\nimport {\n findModulesAsync,\n resolveModulesAsync,\n verifySearchResults,\n generatePackageListAsync,\n mergeLinkingOptionsAsync,\n} from './autolinking';\nimport { resolveExtraDependenciesAsync } from './autolinking/extraDependencies';\nimport {\n GenerateModulesProviderOptions,\n GenerateOptions,\n ResolveOptions,\n SearchOptions,\n SearchResults,\n} from './types';\n\n/**\n * Registers a command that only searches for available expo modules.\n */\nfunction registerSearchCommand<OptionsType extends SearchOptions>(\n commandName: string,\n fn: (search: SearchResults, options: OptionsType) => any\n) {\n return commander\n .command(`${commandName} [paths...]`)\n .option<string[] | null>(\n '-i, --ignore-paths <ignorePaths...>',\n 'Paths to ignore when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option('--silent', 'Silence resolution warnings')\n .addOption(\n new commander.Option(\n '--project-root <projectRoot>',\n 'The path to the root of the project'\n ).default(process.cwd(), 'process.cwd()')\n )\n .option(\n '--only-project-deps',\n 'For a monorepo, include only modules that are the project dependencies.',\n true\n )\n .option('--no-only-project-deps', 'Opposite of --only-project-deps', false)\n .action(async (searchPaths, providedOptions) => {\n const options = await mergeLinkingOptionsAsync<OptionsType>({\n ...providedOptions,\n searchPaths,\n });\n const searchResults = await findModulesAsync(options);\n return await fn(searchResults, options);\n });\n}\n\n/**\n * Registers a command that searches for modules and then resolves them for specific platform.\n */\nfunction registerResolveCommand<OptionsType extends ResolveOptions>(\n commandName: string,\n fn: (search: SearchResults, options: OptionsType) => any\n) {\n return registerSearchCommand<OptionsType>(commandName, fn);\n}\n\n// Register for `patch-react-imports` command\nfunction registerPatchReactImportsCommand() {\n return commander\n .command('patch-react-imports [paths...]')\n .requiredOption('--pods-root <podsRoot>', 'The path to `Pods` directory')\n .option('--dry-run', 'Only list files without writing changes to the file system')\n .action(patchReactImportsAsync);\n}\n\nmodule.exports = async function (args: string[]) {\n // Searches for available expo modules.\n registerSearchCommand<SearchOptions & { json?: boolean }>('search', async (results, options) => {\n if (options.json) {\n console.log(JSON.stringify(results));\n } else {\n console.log(require('util').inspect(results, false, null, true));\n }\n }).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);\n\n // Checks whether there are no resolving issues in the current setup.\n registerSearchCommand('verify', (results, options) => {\n const numberOfDuplicates = verifySearchResults(results, options);\n if (!numberOfDuplicates) {\n console.log('✅ Everything is fine!');\n }\n });\n\n // Searches for available expo modules and resolves the results for given platform.\n registerResolveCommand('resolve', async (results, options) => {\n const modules = await resolveModulesAsync(results, options);\n const extraDependencies = await resolveExtraDependenciesAsync(options.projectRoot);\n\n if (options.json) {\n console.log(JSON.stringify({ extraDependencies, modules }));\n } else {\n console.log(require('util').inspect({ extraDependencies, modules }, false, null, true));\n }\n }).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);\n\n // Generates a source file listing all packages to link.\n // It's deprecated, use `generate-modules-provider` instead.\n registerResolveCommand<GenerateOptions>('generate-package-list', async (results, options) => {\n const modules = options.empty ? [] : await resolveModulesAsync(results, options);\n generatePackageListAsync(modules, options);\n })\n .option(\n '-t, --target <path>',\n 'Path to the target file, where the package list should be written to.'\n )\n .option(\n '-n, --namespace <namespace>',\n 'Java package name under which the package list should be placed.'\n )\n .option(\n '--empty',\n 'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.',\n false\n );\n\n // Generates a source file listing all packages to link in the runtime.\n registerResolveCommand<GenerateModulesProviderOptions>(\n 'generate-modules-provider',\n async (results, options) => {\n const packages = options.packages ?? [];\n const modules = await resolveModulesAsync(results, options);\n const filteredModules = modules.filter((module) => packages.includes(module.packageName));\n\n generatePackageListAsync(filteredModules, options);\n }\n )\n .option(\n '-t, --target <path>',\n 'Path to the target file, where the package list should be written to.'\n )\n .option(\n '-p, --packages <packages...>',\n 'Names of the packages to include in the generated modules provider.'\n );\n\n registerPatchReactImportsCommand();\n\n await commander\n .version(require('expo-modules-autolinking/package.json').version)\n .description('CLI command that searches for Expo modules to autolink them.')\n .parseAsync(args, { from: 'user' });\n};\n"]}
|
package/build/platforms/apple.js
CHANGED
|
@@ -9,7 +9,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const indent = ' ';
|
|
11
11
|
async function findPodspecFiles(revision) {
|
|
12
|
-
const configPodspecPaths = revision.config?.
|
|
12
|
+
const configPodspecPaths = revision.config?.applePodspecPaths();
|
|
13
13
|
if (configPodspecPaths && configPodspecPaths.length) {
|
|
14
14
|
return configPodspecPaths;
|
|
15
15
|
}
|
|
@@ -39,16 +39,16 @@ async function resolveModuleAsync(packageName, revision, options) {
|
|
|
39
39
|
podName: path_1.default.basename(podspecFile, path_1.default.extname(podspecFile)),
|
|
40
40
|
podspecDir: path_1.default.dirname(path_1.default.join(revision.path, podspecFile)),
|
|
41
41
|
}));
|
|
42
|
-
const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.
|
|
42
|
+
const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.appleSwiftModuleNames());
|
|
43
43
|
return {
|
|
44
44
|
packageName,
|
|
45
45
|
pods,
|
|
46
46
|
swiftModuleNames,
|
|
47
47
|
flags: options.flags,
|
|
48
|
-
modules: revision.config?.
|
|
49
|
-
appDelegateSubscribers: revision.config?.
|
|
50
|
-
reactDelegateHandlers: revision.config?.
|
|
51
|
-
debugOnly: revision.config?.
|
|
48
|
+
modules: revision.config?.appleModules() ?? [],
|
|
49
|
+
appDelegateSubscribers: revision.config?.appleAppDelegateSubscribers() ?? [],
|
|
50
|
+
reactDelegateHandlers: revision.config?.appleReactDelegateHandlers() ?? [],
|
|
51
|
+
debugOnly: revision.config?.appleDebugOnly() ?? false,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
exports.resolveModuleAsync = resolveModuleAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple.js","sourceRoot":"","sources":["../../src/platforms/apple.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AASxB,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,KAAK,UAAU,gBAAgB,CAAC,QAAyB;IACvD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC9D,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,EAAE;QACnD,OAAO,kBAAkB,CAAC;KAC3B;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAI,EAAC,aAAa,EAAE;QAC7C,GAAG,EAAE,QAAQ,CAAC,IAAI;QAClB,MAAM,EAAE,CAAC,oBAAoB,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,YAAY,CA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AU,MAAM,CAAC,MAAM,CACvE,gBAAgB,CACjB,GAAG,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise<string[]> {\n const configPodspecPaths = revision.config?.iosPodspecPaths();\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?.iosSwiftModuleNames());\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.iosModules() ?? [],\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.iosDebugOnly() ?? false,\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\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): 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`;\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"]}
|
|
1
|
+
{"version":3,"file":"apple.js","sourceRoot":"","sources":["../../src/platforms/apple.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AASxB,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;QACnD,OAAO,kBAAkB,CAAC;KAC3B;IAED,MAAM,YAAY,GAAG,MA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O,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,MAAM,CAAC,MAAM,CACvE,gBAAgB,CACjB,GAAG,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\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\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 };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\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): 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`;\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"]}
|
package/build/types.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { ExpoModuleConfig } from './ExpoModuleConfig';
|
|
2
|
-
export type SupportedPlatform = 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';
|
|
2
|
+
export type SupportedPlatform = 'apple' | 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';
|
|
3
|
+
/**
|
|
4
|
+
* Options that can be passed through `expo.autolinking` config in the package.json file.
|
|
5
|
+
*/
|
|
6
|
+
export type AutolinkingOptions = {
|
|
7
|
+
searchPaths?: string[] | null;
|
|
8
|
+
ignorePaths?: string[] | null;
|
|
9
|
+
exclude?: string[] | null;
|
|
10
|
+
flags?: Record<string, any>;
|
|
11
|
+
} & {
|
|
12
|
+
[key in SupportedPlatform]?: AutolinkingOptions;
|
|
13
|
+
};
|
|
3
14
|
export interface SearchOptions {
|
|
4
15
|
searchPaths: string[];
|
|
5
16
|
ignorePaths?: string[] | null;
|
|
@@ -24,6 +35,10 @@ export interface GenerateOptions extends ResolveOptions {
|
|
|
24
35
|
namespace?: string;
|
|
25
36
|
empty?: boolean;
|
|
26
37
|
}
|
|
38
|
+
export interface GenerateModulesProviderOptions extends ResolveOptions {
|
|
39
|
+
target: string;
|
|
40
|
+
packages: string[];
|
|
41
|
+
}
|
|
27
42
|
export interface PatchReactImportsOptions {
|
|
28
43
|
podsRoot: string;
|
|
29
44
|
dryRun: boolean;
|
|
@@ -85,6 +100,43 @@ export interface AndroidGradlePluginDescriptor {
|
|
|
85
100
|
*/
|
|
86
101
|
sourceDir: string;
|
|
87
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Represents a raw config specific to Apple platforms.
|
|
105
|
+
*/
|
|
106
|
+
export type RawModuleConfigApple = {
|
|
107
|
+
/**
|
|
108
|
+
* Names of Swift native modules classes to put to the generated modules provider file.
|
|
109
|
+
*/
|
|
110
|
+
modules?: string[];
|
|
111
|
+
/**
|
|
112
|
+
* Names of Swift native modules classes to put to the generated modules provider file.
|
|
113
|
+
* @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.
|
|
114
|
+
*/
|
|
115
|
+
modulesClassNames?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.
|
|
118
|
+
*/
|
|
119
|
+
appDelegateSubscribers?: string[];
|
|
120
|
+
/**
|
|
121
|
+
* Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.
|
|
122
|
+
*/
|
|
123
|
+
reactDelegateHandlers?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Podspec relative path.
|
|
126
|
+
* To have multiple podspecs, string array type is also supported.
|
|
127
|
+
*/
|
|
128
|
+
podspecPath?: string | string[];
|
|
129
|
+
/**
|
|
130
|
+
* Swift product module name. If empty, the pod name is used for Swift imports.
|
|
131
|
+
* To have multiple modules, string array is also supported.
|
|
132
|
+
*/
|
|
133
|
+
swiftModuleName?: string | string[];
|
|
134
|
+
/**
|
|
135
|
+
* Whether this module will be added only to the debug configuration.
|
|
136
|
+
* Defaults to false.
|
|
137
|
+
*/
|
|
138
|
+
debugOnly?: boolean;
|
|
139
|
+
};
|
|
88
140
|
/**
|
|
89
141
|
* Represents a raw config from `expo-module.json`.
|
|
90
142
|
*/
|
|
@@ -94,42 +146,15 @@ export interface RawExpoModuleConfig {
|
|
|
94
146
|
*/
|
|
95
147
|
platforms?: SupportedPlatform[];
|
|
96
148
|
/**
|
|
97
|
-
*
|
|
149
|
+
* A config for all Apple platforms.
|
|
98
150
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.
|
|
107
|
-
*/
|
|
108
|
-
modulesClassNames?: string[];
|
|
109
|
-
/**
|
|
110
|
-
* Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.
|
|
111
|
-
*/
|
|
112
|
-
appDelegateSubscribers?: string[];
|
|
113
|
-
/**
|
|
114
|
-
* Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.
|
|
115
|
-
*/
|
|
116
|
-
reactDelegateHandlers?: string[];
|
|
117
|
-
/**
|
|
118
|
-
* Podspec relative path.
|
|
119
|
-
* To have multiple podspecs, string array type is also supported.
|
|
120
|
-
*/
|
|
121
|
-
podspecPath?: string | string[];
|
|
122
|
-
/**
|
|
123
|
-
* Swift product module name. If empty, the pod name is used for Swift imports.
|
|
124
|
-
* To have multiple modules, string array is also supported.
|
|
125
|
-
*/
|
|
126
|
-
swiftModuleName?: string | string[];
|
|
127
|
-
/**
|
|
128
|
-
* Whether this module will be added only to the debug configuration.
|
|
129
|
-
* Defaults to false.
|
|
130
|
-
*/
|
|
131
|
-
debugOnly?: boolean;
|
|
132
|
-
};
|
|
151
|
+
apple?: RawModuleConfigApple;
|
|
152
|
+
/**
|
|
153
|
+
* The legacy config previously used for iOS platform. For backwards compatibility it's used as the fallback for `apple`.
|
|
154
|
+
* Also due to backwards compatibility, it includes the deprecated `modulesClassNames` field.
|
|
155
|
+
* @deprecated As the module can now support more than iOS platform, use the generic `apple` config instead.
|
|
156
|
+
*/
|
|
157
|
+
ios?: RawModuleConfigApple;
|
|
133
158
|
/**
|
|
134
159
|
* Android-specific config.
|
|
135
160
|
*/
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n nativeModulesDir?: string | null;\n projectRoot: string;\n /**\n * Filter the search results to only include the project dependencies.\n * In a monorepo, you may like to set this to false and link all modules from the monorepo.\n * @default true\n */\n onlyProjectDeps?: boolean;\n\n // Scratched from project's config\n flags?: Record<string, any>;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport interface PatchReactImportsOptions {\n podsRoot: string;\n dryRun: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport interface ModuleAndroidProjectInfo {\n name: string;\n sourceDir: string;\n}\n\nexport interface ModuleAndroidPluginInfo {\n id: string;\n sourceDir: string;\n}\n\nexport interface ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\n plugins?: ModuleAndroidPluginInfo[];\n modules: string[];\n}\n\nexport interface ModuleIosPodspecInfo {\n podName: string;\n podspecDir: string;\n}\nexport interface ModuleDescriptorIos {\n packageName: string;\n pods: ModuleIosPodspecInfo[];\n flags: Record<string, any> | undefined;\n swiftModuleNames: string[];\n modules: string[];\n appDelegateSubscribers: string[];\n reactDelegateHandlers: string[];\n debugOnly: boolean;\n}\n\nexport interface ModuleDescriptorDevTools {\n packageName: string;\n packageRoot: string;\n webpageRoot: string;\n}\n\nexport type ModuleDescriptor =\n | ModuleDescriptorAndroid\n | ModuleDescriptorIos\n | ModuleDescriptorDevTools;\n\nexport interface AndroidGradlePluginDescriptor {\n /**\n * Gradle plugin ID\n */\n id: string;\n\n /**\n * Artifact group\n */\n group: string;\n\n /**\n * Relative path to the gradle plugin directory\n */\n sourceDir: string;\n}\n\n/**\n * Represents a raw config
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'apple' | 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';\n\n/**\n * Options that can be passed through `expo.autolinking` config in the package.json file.\n */\nexport type AutolinkingOptions = {\n searchPaths?: string[] | null;\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n flags?: Record<string, any>;\n} & {\n [key in SupportedPlatform]?: AutolinkingOptions;\n};\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n nativeModulesDir?: string | null;\n projectRoot: string;\n /**\n * Filter the search results to only include the project dependencies.\n * In a monorepo, you may like to set this to false and link all modules from the monorepo.\n * @default true\n */\n onlyProjectDeps?: boolean;\n\n // Scratched from project's config\n flags?: Record<string, any>;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport interface GenerateModulesProviderOptions extends ResolveOptions {\n target: string;\n packages: string[];\n}\n\nexport interface PatchReactImportsOptions {\n podsRoot: string;\n dryRun: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport interface ModuleAndroidProjectInfo {\n name: string;\n sourceDir: string;\n}\n\nexport interface ModuleAndroidPluginInfo {\n id: string;\n sourceDir: string;\n}\n\nexport interface ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\n plugins?: ModuleAndroidPluginInfo[];\n modules: string[];\n}\n\nexport interface ModuleIosPodspecInfo {\n podName: string;\n podspecDir: string;\n}\nexport interface ModuleDescriptorIos {\n packageName: string;\n pods: ModuleIosPodspecInfo[];\n flags: Record<string, any> | undefined;\n swiftModuleNames: string[];\n modules: string[];\n appDelegateSubscribers: string[];\n reactDelegateHandlers: string[];\n debugOnly: boolean;\n}\n\nexport interface ModuleDescriptorDevTools {\n packageName: string;\n packageRoot: string;\n webpageRoot: string;\n}\n\nexport type ModuleDescriptor =\n | ModuleDescriptorAndroid\n | ModuleDescriptorIos\n | ModuleDescriptorDevTools;\n\nexport interface AndroidGradlePluginDescriptor {\n /**\n * Gradle plugin ID\n */\n id: string;\n\n /**\n * Artifact group\n */\n group: string;\n\n /**\n * Relative path to the gradle plugin directory\n */\n sourceDir: string;\n}\n\n/**\n * Represents a raw config specific to Apple platforms.\n */\nexport type RawModuleConfigApple = {\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n */\n modules?: string[];\n\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.\n */\n appDelegateSubscribers?: string[];\n\n /**\n * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.\n */\n reactDelegateHandlers?: string[];\n\n /**\n * Podspec relative path.\n * To have multiple podspecs, string array type is also supported.\n */\n podspecPath?: string | string[];\n\n /**\n * Swift product module name. If empty, the pod name is used for Swift imports.\n * To have multiple modules, string array is also supported.\n */\n swiftModuleName?: string | string[];\n\n /**\n * Whether this module will be added only to the debug configuration.\n * Defaults to false.\n */\n debugOnly?: boolean;\n};\n\n/**\n * Represents a raw config from `expo-module.json`.\n */\nexport interface RawExpoModuleConfig {\n /**\n * An array of supported platforms.\n */\n platforms?: SupportedPlatform[];\n\n /**\n * A config for all Apple platforms.\n */\n apple?: RawModuleConfigApple;\n\n /**\n * The legacy config previously used for iOS platform. For backwards compatibility it's used as the fallback for `apple`.\n * Also due to backwards compatibility, it includes the deprecated `modulesClassNames` field.\n * @deprecated As the module can now support more than iOS platform, use the generic `apple` config instead.\n */\n ios?: RawModuleConfigApple;\n\n /**\n * Android-specific config.\n */\n android?: {\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n */\n modules?: string[];\n\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * build.gradle relative path.\n * To have multiple build.gradle projects, string array type is also supported.\n */\n gradlePath?: string | string[];\n\n /**\n * Gradle plugins.\n */\n gradlePlugins?: AndroidGradlePluginDescriptor[];\n };\n\n /**\n * DevTools-specific config.\n */\n devtools?: {\n /**\n * The webpage root directory for Expo CLI DevTools to serve the web resources.\n */\n webpageRoot: string;\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"find-up": "^5.0.0",
|
|
49
49
|
"fs-extra": "^9.1.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "102899632731658eecba006c0d1c79b98ba8f5f7"
|
|
52
52
|
}
|
|
@@ -46,10 +46,8 @@ module Expo
|
|
|
46
46
|
next
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
podspec = get_podspec_for_pod(pod)
|
|
50
|
-
|
|
51
49
|
# Skip if the podspec doesn't include the platform for the current target.
|
|
52
|
-
unless
|
|
50
|
+
unless pod.supports_platform?(@target_definition.platform)
|
|
53
51
|
UI.message '- ' << package.name.green << " doesn't support #{@target_definition.platform.string_name} platform".yellow
|
|
54
52
|
next
|
|
55
53
|
end
|
|
@@ -59,7 +57,7 @@ module Expo
|
|
|
59
57
|
# `:modular_headers => true` is not used for this particular dependency.
|
|
60
58
|
# The latter require adding transitive dependencies to user's Podfile that we'd rather like to avoid.
|
|
61
59
|
if package.has_swift_modules_to_link?
|
|
62
|
-
use_modular_headers_for_dependencies(
|
|
60
|
+
use_modular_headers_for_dependencies(pod.spec.all_dependencies)
|
|
63
61
|
end
|
|
64
62
|
|
|
65
63
|
podspec_dir_path = Pathname.new(pod.podspec_dir).relative_path_from(project_directory).to_path
|
|
@@ -70,8 +68,8 @@ module Expo
|
|
|
70
68
|
}.merge(global_flags, package.flags)
|
|
71
69
|
|
|
72
70
|
if tests_only || include_tests
|
|
73
|
-
test_specs_names =
|
|
74
|
-
test_spec.name.delete_prefix(
|
|
71
|
+
test_specs_names = pod.spec.test_specs.map { |test_spec|
|
|
72
|
+
test_spec.name.delete_prefix(pod.spec.name + "/")
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
# Jump to the next package when it doesn't have any test specs (except interfaces, they're required)
|
|
@@ -113,9 +111,9 @@ module Expo
|
|
|
113
111
|
self
|
|
114
112
|
end
|
|
115
113
|
|
|
116
|
-
# Spawns `expo-module-autolinking generate-
|
|
117
|
-
public def
|
|
118
|
-
Process.wait IO.popen(
|
|
114
|
+
# Spawns `expo-module-autolinking generate-modules-provider` command.
|
|
115
|
+
public def generate_modules_provider(target_name, target_path)
|
|
116
|
+
Process.wait IO.popen(generate_modules_provider_command_args(target_path)).pid
|
|
119
117
|
end
|
|
120
118
|
|
|
121
119
|
# If there is any package to autolink.
|
|
@@ -196,7 +194,7 @@ module Expo
|
|
|
196
194
|
'require(require.resolve(\'expo-modules-autolinking\', { paths: [\'' + __dir__ + '\'] }))(process.argv.slice(1))',
|
|
197
195
|
command_name,
|
|
198
196
|
'--platform',
|
|
199
|
-
|
|
197
|
+
'apple'
|
|
200
198
|
]
|
|
201
199
|
return eval_command_args.concat(base_command_args())
|
|
202
200
|
end
|
|
@@ -205,16 +203,15 @@ module Expo
|
|
|
205
203
|
node_command_args('resolve').concat(['--json'])
|
|
206
204
|
end
|
|
207
205
|
|
|
208
|
-
public def
|
|
209
|
-
node_command_args('generate-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return Pod::Specification.from_file(podspec_file_path)
|
|
206
|
+
public def generate_modules_provider_command_args(target_path)
|
|
207
|
+
node_command_args('generate-modules-provider').concat(
|
|
208
|
+
[
|
|
209
|
+
'--target',
|
|
210
|
+
target_path,
|
|
211
|
+
'--packages'
|
|
212
|
+
],
|
|
213
|
+
packages_to_generate.map(&:name)
|
|
214
|
+
)
|
|
218
215
|
end
|
|
219
216
|
|
|
220
217
|
private def use_modular_headers_for_dependencies(dependencies)
|
|
@@ -246,13 +243,5 @@ module Expo
|
|
|
246
243
|
end
|
|
247
244
|
end
|
|
248
245
|
|
|
249
|
-
# Checks whether the podspec declares support for the given platform.
|
|
250
|
-
# It compares not only the platform name, but also the deployment target.
|
|
251
|
-
private def podspec_supports_platform?(podspec, platform)
|
|
252
|
-
return platform && podspec.available_platforms().any? do |available_platform|
|
|
253
|
-
next platform.supports?(available_platform)
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
246
|
end # class AutolinkingManager
|
|
258
247
|
end # module Expo
|
package/scripts/ios/package.rb
CHANGED
|
@@ -9,9 +9,21 @@ module Expo
|
|
|
9
9
|
# The directory where the podspec is
|
|
10
10
|
attr_reader :podspec_dir
|
|
11
11
|
|
|
12
|
+
# Specification of the pod.
|
|
13
|
+
attr_reader :spec
|
|
14
|
+
|
|
12
15
|
def initialize(json)
|
|
13
16
|
@pod_name = json['podName']
|
|
14
17
|
@podspec_dir = json['podspecDir']
|
|
18
|
+
@spec = get_podspec_for_pod(self)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Checks whether the podspec declares support for the given platform.
|
|
22
|
+
# It compares not only the platform name, but also the deployment target.
|
|
23
|
+
def supports_platform?(platform)
|
|
24
|
+
return platform && @spec.available_platforms().any? do |available_platform|
|
|
25
|
+
next platform.supports?(available_platform)
|
|
26
|
+
end
|
|
15
27
|
end
|
|
16
28
|
|
|
17
29
|
end # class PackagePod
|
|
@@ -52,3 +64,8 @@ module Expo
|
|
|
52
64
|
end # class Package
|
|
53
65
|
|
|
54
66
|
end # module Expo
|
|
67
|
+
|
|
68
|
+
private def get_podspec_for_pod(pod)
|
|
69
|
+
podspec_file_path = File.join(pod.podspec_dir, pod.pod_name + ".podspec")
|
|
70
|
+
return Pod::Specification.from_file(podspec_file_path)
|
|
71
|
+
end
|
|
@@ -45,7 +45,7 @@ module Expo
|
|
|
45
45
|
modules_provider_path = autolinking_manager.modules_provider_path(target)
|
|
46
46
|
|
|
47
47
|
# Run `expo-modules-autolinking` command to generate the file
|
|
48
|
-
autolinking_manager.
|
|
48
|
+
autolinking_manager.generate_modules_provider(target_name, modules_provider_path)
|
|
49
49
|
|
|
50
50
|
# PBXGroup for generated files per target
|
|
51
51
|
generated_target_group = generated_group.find_subpath(target_name, true)
|
|
@@ -212,8 +212,9 @@ module Expo
|
|
|
212
212
|
|
|
213
213
|
# Generates the support script that is executed by the build script phase.
|
|
214
214
|
def self.generate_support_script(autolinking_manager, modules_provider_path)
|
|
215
|
-
args = autolinking_manager.base_command_args.map { |arg| "\"#{arg}\"" }
|
|
215
|
+
args = autolinking_manager.base_command_args.map { |arg| "\"#{arg}\"" }
|
|
216
216
|
platform = autolinking_manager.platform_name.downcase
|
|
217
|
+
package_names = autolinking_manager.packages_to_generate.map { |package| "\"#{package.name}\"" }
|
|
217
218
|
|
|
218
219
|
<<~SUPPORT_SCRIPT
|
|
219
220
|
#!/usr/bin/env bash
|
|
@@ -259,7 +260,13 @@ module Expo
|
|
|
259
260
|
fi
|
|
260
261
|
}
|
|
261
262
|
|
|
262
|
-
with_node
|
|
263
|
+
with_node \\
|
|
264
|
+
--no-warnings \\
|
|
265
|
+
--eval "require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))" \\
|
|
266
|
+
generate-modules-provider #{args.join(' ')} \\
|
|
267
|
+
--target "#{modules_provider_path}" \\
|
|
268
|
+
--platform "apple" \\
|
|
269
|
+
--packages #{package_names.join(' ')}
|
|
263
270
|
SUPPORT_SCRIPT
|
|
264
271
|
end
|
|
265
272
|
|
package/src/ExpoModuleConfig.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AndroidGradlePluginDescriptor,
|
|
3
|
+
RawExpoModuleConfig,
|
|
4
|
+
RawModuleConfigApple,
|
|
5
|
+
SupportedPlatform,
|
|
6
|
+
} from './types';
|
|
2
7
|
|
|
3
8
|
function arrayize<T>(value: T[] | T | undefined): T[] {
|
|
4
9
|
if (Array.isArray(value)) {
|
|
@@ -17,52 +22,67 @@ export class ExpoModuleConfig {
|
|
|
17
22
|
* Whether the module supports given platform.
|
|
18
23
|
*/
|
|
19
24
|
supportsPlatform(platform: SupportedPlatform): boolean {
|
|
20
|
-
|
|
25
|
+
const supportedPlatforms = this.rawConfig.platforms ?? [];
|
|
26
|
+
|
|
27
|
+
if (platform === 'apple') {
|
|
28
|
+
// Apple platform is supported when any of iOS, macOS and tvOS is supported.
|
|
29
|
+
return supportedPlatforms.some((supportedPlatform) => {
|
|
30
|
+
return ['apple', 'ios', 'macos', 'tvos'].includes(supportedPlatform);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return supportedPlatforms.includes(platform);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the generic config for all Apple platforms with a fallback to the legacy iOS config.
|
|
38
|
+
*/
|
|
39
|
+
getAppleConfig(): RawModuleConfigApple | null {
|
|
40
|
+
return this.rawConfig.apple ?? this.rawConfig.ios ?? null;
|
|
21
41
|
}
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
44
|
* Returns a list of names of Swift native modules classes to put to the generated modules provider file.
|
|
25
45
|
*/
|
|
26
|
-
|
|
27
|
-
const
|
|
46
|
+
appleModules() {
|
|
47
|
+
const appleConfig = this.getAppleConfig();
|
|
28
48
|
|
|
29
49
|
// `modulesClassNames` is a legacy name for the same config.
|
|
30
|
-
return
|
|
50
|
+
return appleConfig?.modules ?? appleConfig?.modulesClassNames ?? [];
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
/**
|
|
34
54
|
* Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
|
|
35
55
|
*/
|
|
36
|
-
|
|
37
|
-
return this.
|
|
56
|
+
appleAppDelegateSubscribers(): string[] {
|
|
57
|
+
return this.getAppleConfig()?.appDelegateSubscribers ?? [];
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
/**
|
|
41
61
|
* Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
|
|
42
62
|
*/
|
|
43
|
-
|
|
44
|
-
return this.
|
|
63
|
+
appleReactDelegateHandlers(): string[] {
|
|
64
|
+
return this.getAppleConfig()?.reactDelegateHandlers ?? [];
|
|
45
65
|
}
|
|
46
66
|
|
|
47
67
|
/**
|
|
48
68
|
* Returns podspec paths defined by the module author.
|
|
49
69
|
*/
|
|
50
|
-
|
|
51
|
-
return arrayize(this.
|
|
70
|
+
applePodspecPaths(): string[] {
|
|
71
|
+
return arrayize(this.getAppleConfig()?.podspecPath);
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
/**
|
|
55
75
|
* Returns the product module names, if defined by the module author.
|
|
56
76
|
*/
|
|
57
|
-
|
|
58
|
-
return arrayize(this.
|
|
77
|
+
appleSwiftModuleNames(): string[] {
|
|
78
|
+
return arrayize(this.getAppleConfig()?.swiftModuleName);
|
|
59
79
|
}
|
|
60
80
|
|
|
61
81
|
/**
|
|
62
82
|
* Returns whether this module will be added only to the debug configuration
|
|
63
83
|
*/
|
|
64
|
-
|
|
65
|
-
return this.
|
|
84
|
+
appleDebugOnly(): boolean {
|
|
85
|
+
return this.getAppleConfig()?.debugOnly ?? false;
|
|
66
86
|
}
|
|
67
87
|
|
|
68
88
|
/**
|
|
@@ -2,7 +2,7 @@ import findUp from 'find-up';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
|
|
5
|
-
import { SearchOptions } from '../types';
|
|
5
|
+
import { AutolinkingOptions, SearchOptions, SupportedPlatform } from '../types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Find the path to the `package.json` of the closest project in the given project root.
|
|
@@ -18,15 +18,15 @@ export async function getProjectPackageJsonPathAsync(projectRoot: string): Promi
|
|
|
18
18
|
/**
|
|
19
19
|
* Merges autolinking options from different sources (the later the higher priority)
|
|
20
20
|
* - options defined in package.json's `expo.autolinking` field
|
|
21
|
-
* - platform-specific options from the above (e.g. `expo.autolinking.
|
|
21
|
+
* - platform-specific options from the above (e.g. `expo.autolinking.apple`)
|
|
22
22
|
* - options provided to the CLI command
|
|
23
23
|
*/
|
|
24
24
|
export async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(
|
|
25
25
|
providedOptions: OptionsType
|
|
26
26
|
): Promise<OptionsType> {
|
|
27
27
|
const packageJson = require(await getProjectPackageJsonPathAsync(providedOptions.projectRoot));
|
|
28
|
-
const baseOptions = packageJson.expo?.autolinking;
|
|
29
|
-
const platformOptions = providedOptions.platform
|
|
28
|
+
const baseOptions = packageJson.expo?.autolinking as AutolinkingOptions;
|
|
29
|
+
const platformOptions = getPlatformOptions(providedOptions.platform, baseOptions);
|
|
30
30
|
const finalOptions = Object.assign(
|
|
31
31
|
{},
|
|
32
32
|
baseOptions,
|
|
@@ -101,3 +101,16 @@ async function resolveNativeModulesDirAsync(
|
|
|
101
101
|
const resolvedPath = path.resolve(projectRoot, nativeModulesDir || 'modules');
|
|
102
102
|
return fs.existsSync(resolvedPath) ? resolvedPath : null;
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Gets the platform-specific autolinking options from the base options.
|
|
107
|
+
*/
|
|
108
|
+
function getPlatformOptions(
|
|
109
|
+
platform: SupportedPlatform,
|
|
110
|
+
options?: AutolinkingOptions
|
|
111
|
+
): AutolinkingOptions {
|
|
112
|
+
if (platform === 'apple') {
|
|
113
|
+
return options?.apple ?? options?.ios ?? {};
|
|
114
|
+
}
|
|
115
|
+
return options?.[platform] ?? {};
|
|
116
|
+
}
|
package/src/autolinking/utils.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -9,7 +9,13 @@ import {
|
|
|
9
9
|
mergeLinkingOptionsAsync,
|
|
10
10
|
} from './autolinking';
|
|
11
11
|
import { resolveExtraDependenciesAsync } from './autolinking/extraDependencies';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
GenerateModulesProviderOptions,
|
|
14
|
+
GenerateOptions,
|
|
15
|
+
ResolveOptions,
|
|
16
|
+
SearchOptions,
|
|
17
|
+
SearchResults,
|
|
18
|
+
} from './types';
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* Registers a command that only searches for available expo modules.
|
|
@@ -32,8 +38,8 @@ function registerSearchCommand<OptionsType extends SearchOptions>(
|
|
|
32
38
|
)
|
|
33
39
|
.option(
|
|
34
40
|
'-p, --platform [platform]',
|
|
35
|
-
'The platform that the resulting modules must support. Available options: "
|
|
36
|
-
'
|
|
41
|
+
'The platform that the resulting modules must support. Available options: "apple", "android"',
|
|
42
|
+
'apple'
|
|
37
43
|
)
|
|
38
44
|
.option('--silent', 'Silence resolution warnings')
|
|
39
45
|
.addOption(
|
|
@@ -108,6 +114,7 @@ module.exports = async function (args: string[]) {
|
|
|
108
114
|
}).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);
|
|
109
115
|
|
|
110
116
|
// Generates a source file listing all packages to link.
|
|
117
|
+
// It's deprecated, use `generate-modules-provider` instead.
|
|
111
118
|
registerResolveCommand<GenerateOptions>('generate-package-list', async (results, options) => {
|
|
112
119
|
const modules = options.empty ? [] : await resolveModulesAsync(results, options);
|
|
113
120
|
generatePackageListAsync(modules, options);
|
|
@@ -126,6 +133,26 @@ module.exports = async function (args: string[]) {
|
|
|
126
133
|
false
|
|
127
134
|
);
|
|
128
135
|
|
|
136
|
+
// Generates a source file listing all packages to link in the runtime.
|
|
137
|
+
registerResolveCommand<GenerateModulesProviderOptions>(
|
|
138
|
+
'generate-modules-provider',
|
|
139
|
+
async (results, options) => {
|
|
140
|
+
const packages = options.packages ?? [];
|
|
141
|
+
const modules = await resolveModulesAsync(results, options);
|
|
142
|
+
const filteredModules = modules.filter((module) => packages.includes(module.packageName));
|
|
143
|
+
|
|
144
|
+
generatePackageListAsync(filteredModules, options);
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
.option(
|
|
148
|
+
'-t, --target <path>',
|
|
149
|
+
'Path to the target file, where the package list should be written to.'
|
|
150
|
+
)
|
|
151
|
+
.option(
|
|
152
|
+
'-p, --packages <packages...>',
|
|
153
|
+
'Names of the packages to include in the generated modules provider.'
|
|
154
|
+
);
|
|
155
|
+
|
|
129
156
|
registerPatchReactImportsCommand();
|
|
130
157
|
|
|
131
158
|
await commander
|
package/src/platforms/apple.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
const indent = ' ';
|
|
13
13
|
|
|
14
14
|
async function findPodspecFiles(revision: PackageRevision): Promise<string[]> {
|
|
15
|
-
const configPodspecPaths = revision.config?.
|
|
15
|
+
const configPodspecPaths = revision.config?.applePodspecPaths();
|
|
16
16
|
if (configPodspecPaths && configPodspecPaths.length) {
|
|
17
17
|
return configPodspecPaths;
|
|
18
18
|
}
|
|
@@ -54,17 +54,17 @@ export async function resolveModuleAsync(
|
|
|
54
54
|
podspecDir: path.dirname(path.join(revision.path, podspecFile)),
|
|
55
55
|
}));
|
|
56
56
|
|
|
57
|
-
const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.
|
|
57
|
+
const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.appleSwiftModuleNames());
|
|
58
58
|
|
|
59
59
|
return {
|
|
60
60
|
packageName,
|
|
61
61
|
pods,
|
|
62
62
|
swiftModuleNames,
|
|
63
63
|
flags: options.flags,
|
|
64
|
-
modules: revision.config?.
|
|
65
|
-
appDelegateSubscribers: revision.config?.
|
|
66
|
-
reactDelegateHandlers: revision.config?.
|
|
67
|
-
debugOnly: revision.config?.
|
|
64
|
+
modules: revision.config?.appleModules() ?? [],
|
|
65
|
+
appDelegateSubscribers: revision.config?.appleAppDelegateSubscribers() ?? [],
|
|
66
|
+
reactDelegateHandlers: revision.config?.appleReactDelegateHandlers() ?? [],
|
|
67
|
+
debugOnly: revision.config?.appleDebugOnly() ?? false,
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { ExpoModuleConfig } from './ExpoModuleConfig';
|
|
2
2
|
|
|
3
|
-
export type SupportedPlatform = 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';
|
|
3
|
+
export type SupportedPlatform = 'apple' | 'ios' | 'android' | 'web' | 'macos' | 'tvos' | 'devtools';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options that can be passed through `expo.autolinking` config in the package.json file.
|
|
7
|
+
*/
|
|
8
|
+
export type AutolinkingOptions = {
|
|
9
|
+
searchPaths?: string[] | null;
|
|
10
|
+
ignorePaths?: string[] | null;
|
|
11
|
+
exclude?: string[] | null;
|
|
12
|
+
flags?: Record<string, any>;
|
|
13
|
+
} & {
|
|
14
|
+
[key in SupportedPlatform]?: AutolinkingOptions;
|
|
15
|
+
};
|
|
4
16
|
|
|
5
17
|
export interface SearchOptions {
|
|
6
18
|
// Available in the CLI
|
|
@@ -32,6 +44,11 @@ export interface GenerateOptions extends ResolveOptions {
|
|
|
32
44
|
empty?: boolean;
|
|
33
45
|
}
|
|
34
46
|
|
|
47
|
+
export interface GenerateModulesProviderOptions extends ResolveOptions {
|
|
48
|
+
target: string;
|
|
49
|
+
packages: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
export interface PatchReactImportsOptions {
|
|
36
53
|
podsRoot: string;
|
|
37
54
|
dryRun: boolean;
|
|
@@ -109,57 +126,69 @@ export interface AndroidGradlePluginDescriptor {
|
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
/**
|
|
112
|
-
* Represents a raw config
|
|
129
|
+
* Represents a raw config specific to Apple platforms.
|
|
113
130
|
*/
|
|
114
|
-
export
|
|
131
|
+
export type RawModuleConfigApple = {
|
|
115
132
|
/**
|
|
116
|
-
*
|
|
133
|
+
* Names of Swift native modules classes to put to the generated modules provider file.
|
|
117
134
|
*/
|
|
118
|
-
|
|
135
|
+
modules?: string[];
|
|
119
136
|
|
|
120
137
|
/**
|
|
121
|
-
*
|
|
138
|
+
* Names of Swift native modules classes to put to the generated modules provider file.
|
|
139
|
+
* @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.
|
|
122
140
|
*/
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Names of Swift native modules classes to put to the generated modules provider file.
|
|
126
|
-
*/
|
|
127
|
-
modules?: string[];
|
|
141
|
+
modulesClassNames?: string[];
|
|
128
142
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
modulesClassNames?: string[];
|
|
143
|
+
/**
|
|
144
|
+
* Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.
|
|
145
|
+
*/
|
|
146
|
+
appDelegateSubscribers?: string[];
|
|
134
147
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.
|
|
150
|
+
*/
|
|
151
|
+
reactDelegateHandlers?: string[];
|
|
139
152
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Podspec relative path.
|
|
155
|
+
* To have multiple podspecs, string array type is also supported.
|
|
156
|
+
*/
|
|
157
|
+
podspecPath?: string | string[];
|
|
144
158
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Swift product module name. If empty, the pod name is used for Swift imports.
|
|
161
|
+
* To have multiple modules, string array is also supported.
|
|
162
|
+
*/
|
|
163
|
+
swiftModuleName?: string | string[];
|
|
150
164
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Whether this module will be added only to the debug configuration.
|
|
167
|
+
* Defaults to false.
|
|
168
|
+
*/
|
|
169
|
+
debugOnly?: boolean;
|
|
170
|
+
};
|
|
156
171
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Represents a raw config from `expo-module.json`.
|
|
174
|
+
*/
|
|
175
|
+
export interface RawExpoModuleConfig {
|
|
176
|
+
/**
|
|
177
|
+
* An array of supported platforms.
|
|
178
|
+
*/
|
|
179
|
+
platforms?: SupportedPlatform[];
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A config for all Apple platforms.
|
|
183
|
+
*/
|
|
184
|
+
apple?: RawModuleConfigApple;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The legacy config previously used for iOS platform. For backwards compatibility it's used as the fallback for `apple`.
|
|
188
|
+
* Also due to backwards compatibility, it includes the deprecated `modulesClassNames` field.
|
|
189
|
+
* @deprecated As the module can now support more than iOS platform, use the generic `apple` config instead.
|
|
190
|
+
*/
|
|
191
|
+
ios?: RawModuleConfigApple;
|
|
163
192
|
|
|
164
193
|
/**
|
|
165
194
|
* Android-specific config.
|