expo-modules-autolinking 0.7.0 → 0.7.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 +4 -0
- package/build/ExpoModuleConfig.js +7 -0
- package/build/ExpoModuleConfig.js.map +1 -1
- package/build/platforms/ios.js +48 -8
- package/build/platforms/ios.js.map +1 -1
- package/build/types.d.ts +6 -0
- package/build/types.js.map +1 -1
- package/package.json +2 -2
- package/scripts/ios/autolinking_manager.rb +2 -1
- package/scripts/ios/package.rb +4 -0
- package/src/ExpoModuleConfig.ts +7 -0
- package/src/platforms/ios.ts +68 -7
- package/src/types.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.7.1 — 2022-05-05
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Add `ios.debugOnly` to module config. ([#17331](https://github.com/expo/expo/pull/17331) by [@lukmccall](https://github.com/lukmccall))
|
|
18
|
+
|
|
13
19
|
## 0.7.0 — 2022-04-18
|
|
14
20
|
|
|
15
21
|
- Update require logic to find transitive deps that would not be hoisted at the top of the monorepo ([#16419](https://github.com/expo/expo/pull/16419) by [@Titozzz](https://github.com/Titozzz))
|
|
@@ -29,6 +29,10 @@ export declare class ExpoModuleConfig {
|
|
|
29
29
|
* Returns the product module names, if defined by the module author.
|
|
30
30
|
*/
|
|
31
31
|
iosSwiftModuleNames(): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Returns whether this module will be added only to the debug configuration
|
|
34
|
+
*/
|
|
35
|
+
iosDebugOnly(): boolean;
|
|
32
36
|
/**
|
|
33
37
|
* Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
|
|
34
38
|
*/
|
|
@@ -58,6 +58,13 @@ class ExpoModuleConfig {
|
|
|
58
58
|
var _a;
|
|
59
59
|
return arrayize((_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.swiftModuleName);
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns whether this module will be added only to the debug configuration
|
|
63
|
+
*/
|
|
64
|
+
iosDebugOnly() {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.debugOnly) !== null && _b !== void 0 ? _b : false;
|
|
67
|
+
}
|
|
61
68
|
/**
|
|
62
69
|
* Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
|
|
63
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU;;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAErC,4DAA4D;QAC5D,OAAO,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,mCAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACl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QACZ,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAE7C,4DAA4D;QAC5D,OAAO,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,iBAAiB,mCAAI,EAAE,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,kBAAkB;;QAChB,OAAO,QAAQ,CAAC,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,0CAAE,UAAU,mCAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA9ED,4CA8EC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,kDAAkD;IAClD,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { RawExpoModuleConfig, SupportedPlatform } from './types';\n\nfunction arrayize<T>(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModules() {\n const iosConfig = this.rawConfig.ios;\n\n // `modulesClassNames` is a legacy name for the same config.\n return iosConfig?.modules ?? iosConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n iosPodspecPaths(): string[] {\n return arrayize(this.rawConfig.ios?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n iosSwiftModuleNames(): string[] {\n return arrayize(this.rawConfig.ios?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n iosDebugOnly(): boolean {\n return this.rawConfig.ios?.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 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"]}
|
package/build/platforms/ios.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.formatArrayOfReactDelegateHandler = exports.generatePackageListAsync = e
|
|
|
7
7
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const indent = ' ';
|
|
10
11
|
async function findPodspecFiles(revision) {
|
|
11
12
|
var _a;
|
|
12
13
|
const configPodspecPaths = (_a = revision.config) === null || _a === void 0 ? void 0 : _a.iosPodspecPaths();
|
|
@@ -31,7 +32,7 @@ exports.getSwiftModuleNames = getSwiftModuleNames;
|
|
|
31
32
|
* Resolves module search result with additional details required for iOS platform.
|
|
32
33
|
*/
|
|
33
34
|
async function resolveModuleAsync(packageName, revision, options) {
|
|
34
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
35
36
|
const podspecFiles = await findPodspecFiles(revision);
|
|
36
37
|
if (!podspecFiles.length) {
|
|
37
38
|
return null;
|
|
@@ -49,6 +50,7 @@ async function resolveModuleAsync(packageName, revision, options) {
|
|
|
49
50
|
modules: (_c = (_b = revision.config) === null || _b === void 0 ? void 0 : _b.iosModules()) !== null && _c !== void 0 ? _c : [],
|
|
50
51
|
appDelegateSubscribers: (_e = (_d = revision.config) === null || _d === void 0 ? void 0 : _d.iosAppDelegateSubscribers()) !== null && _e !== void 0 ? _e : [],
|
|
51
52
|
reactDelegateHandlers: (_g = (_f = revision.config) === null || _f === void 0 ? void 0 : _f.iosReactDelegateHandlers()) !== null && _g !== void 0 ? _g : [],
|
|
53
|
+
debugOnly: (_j = (_h = revision.config) === null || _h === void 0 ? void 0 : _h.iosDebugOnly()) !== null && _j !== void 0 ? _j : false,
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
exports.resolveModuleAsync = resolveModuleAsync;
|
|
@@ -65,17 +67,27 @@ exports.generatePackageListAsync = generatePackageListAsync;
|
|
|
65
67
|
* Generates the string to put into the generated package list.
|
|
66
68
|
*/
|
|
67
69
|
async function generatePackageListFileContentAsync(modules, className) {
|
|
68
|
-
const
|
|
70
|
+
const iosModules = modules.filter((module) => module.modules.length ||
|
|
69
71
|
module.appDelegateSubscribers.length ||
|
|
70
72
|
module.reactDelegateHandlers.length);
|
|
73
|
+
const modulesToImport = iosModules.filter((module) => !module.debugOnly);
|
|
74
|
+
const debugOnlyModules = iosModules.filter((module) => module.debugOnly);
|
|
71
75
|
const swiftModules = []
|
|
72
76
|
.concat(...modulesToImport.map((module) => module.swiftModuleNames))
|
|
73
77
|
.filter(Boolean);
|
|
78
|
+
const debugOnlySwiftModules = []
|
|
79
|
+
.concat(...debugOnlyModules.map((module) => module.swiftModuleNames))
|
|
80
|
+
.filter(Boolean);
|
|
74
81
|
const modulesClassNames = []
|
|
75
82
|
.concat(...modulesToImport.map((module) => module.modules))
|
|
76
83
|
.filter(Boolean);
|
|
84
|
+
const debugOnlyModulesClassNames = []
|
|
85
|
+
.concat(...debugOnlyModules.map((module) => module.modules))
|
|
86
|
+
.filter(Boolean);
|
|
77
87
|
const appDelegateSubscribers = [].concat(...modulesToImport.map((module) => module.appDelegateSubscribers));
|
|
88
|
+
const debugOnlyAppDelegateSubscribers = [].concat(...debugOnlyModules.map((module) => module.appDelegateSubscribers));
|
|
78
89
|
const reactDelegateHandlerModules = modulesToImport.filter((module) => !!module.reactDelegateHandlers.length);
|
|
90
|
+
const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter((module) => !!module.reactDelegateHandlers.length);
|
|
79
91
|
return `/**
|
|
80
92
|
* Automatically generated by expo-modules-autolinking.
|
|
81
93
|
*
|
|
@@ -84,31 +96,60 @@ async function generatePackageListFileContentAsync(modules, className) {
|
|
|
84
96
|
*/
|
|
85
97
|
|
|
86
98
|
import ExpoModulesCore
|
|
87
|
-
${swiftModules
|
|
99
|
+
${generateCommonImportList(swiftModules)}
|
|
100
|
+
${generateDebugOnlyImportList(debugOnlySwiftModules)}
|
|
88
101
|
@objc(${className})
|
|
89
102
|
public class ${className}: ModulesProvider {
|
|
90
103
|
public override func getModuleClasses() -> [AnyModule.Type] {
|
|
91
|
-
|
|
104
|
+
${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
|
|
95
|
-
|
|
108
|
+
${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
|
|
99
|
-
|
|
112
|
+
${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
115
|
`;
|
|
103
116
|
}
|
|
117
|
+
function generateCommonImportList(swiftModules) {
|
|
118
|
+
return swiftModules.map((moduleName) => `import ${moduleName}\n`).join('');
|
|
119
|
+
}
|
|
120
|
+
function generateDebugOnlyImportList(swiftModules) {
|
|
121
|
+
if (!swiftModules.length) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
return `#if DEBUG\n${swiftModules
|
|
125
|
+
.map((moduleName) => `import ${moduleName}\n`)
|
|
126
|
+
.join('')}#endif\n`;
|
|
127
|
+
}
|
|
128
|
+
function generateModuleClasses(classNames, debugOnlyClassName) {
|
|
129
|
+
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
130
|
+
if (debugOnlyClassName.length > 0) {
|
|
131
|
+
return `#if DEBUG\n${indent.repeat(2)}return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}\n#else\n${indent.repeat(2)}return ${commonClassNames}\n#endif`;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
104
137
|
/**
|
|
105
138
|
* Formats an array of class names to Swift's array containing these classes.
|
|
106
139
|
*/
|
|
107
140
|
function formatArrayOfClassNames(classNames) {
|
|
108
|
-
const indent = ' ';
|
|
109
141
|
return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
|
|
110
142
|
${indent.repeat(2)}]`;
|
|
111
143
|
}
|
|
144
|
+
function generateReactDelegateHandlers(module, debugOnlyModules) {
|
|
145
|
+
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
146
|
+
if (debugOnlyModules.length > 0) {
|
|
147
|
+
return `#if DEBUG\n${indent.repeat(2)}return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}\n#else\n${indent.repeat(2)}return ${commonModules}\n#endif`;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return `${indent.repeat(2)}return ${commonModules}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
112
153
|
/**
|
|
113
154
|
* Formats an array of modules to Swift's array containing ReactDelegateHandlers
|
|
114
155
|
*/
|
|
@@ -119,7 +160,6 @@ function formatArrayOfReactDelegateHandler(modules) {
|
|
|
119
160
|
values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
|
|
120
161
|
}
|
|
121
162
|
}
|
|
122
|
-
const indent = ' ';
|
|
123
163
|
return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
|
|
124
164
|
${indent.repeat(2)}]`;
|
|
125
165
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AASxB,KAAK,UAAU,gBAAgB,CAAC,QAAyB;;IACvD,MAAM,kBAAkB,GAAG,MAAA,QAAQ,CAAC,MAAM,0CAAE,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,CAAC;AACtB,CAAC;AAED,SAAgB,mBAAmB,CACjC,IAA4B,EAC5B,gBAAsC;IAEtC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MA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 '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\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 };\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 modulesToImport = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.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 appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.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${swiftModules.map((moduleName) => `import ${moduleName}\\n`).join('')}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n return ${formatArrayOfClassNames(modulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n return ${formatArrayOfClassNames(appDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n return ${formatArrayOfReactDelegateHandler(reactDelegateHandlerModules)}\n }\n}\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 const indent = ' ';\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\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 const indent = ' ';\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.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,MAAA,QAAQ,CAAC,MAAM,0CAAE,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,CAAC;AACtB,CAAC;AAED,SAAgB,mBAAmB,CACjC,IAA4B,EAC5B,gBAAsC;IAEtC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC/C,OAAO,gBAAgB,CAAC;KACzB;IACD,+FAA+F;IAC/F,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AATD,kDASC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,QAAyB,EACzB,OAAsB;;IAEtB,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACxB,OAAO,IAAI,CAAC;KACb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KACrD;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,OAA8B;IAC9E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,WAAW,eAAe,OAAO,QAAQ,CAAC,CAAC;SACjF;KACF;IACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AATD,8EASC","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}\\n`).join('');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return `#if DEBUG\\n${swiftModules\n .map((moduleName) => `import ${moduleName}\\n`)\n .join('')}#endif\\n`;\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return `#if DEBUG\\n${indent.repeat(2)}return ${formatArrayOfClassNames(\n classNames.concat(debugOnlyClassName)\n )}\\n#else\\n${indent.repeat(2)}return ${commonClassNames}\\n#endif`;\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 `#if DEBUG\\n${indent.repeat(2)}return ${formatArrayOfReactDelegateHandler(\n module.concat(debugOnlyModules)\n )}\\n#else\\n${indent.repeat(2)}return ${commonModules}\\n#endif`;\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"]}
|
package/build/types.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface ModuleDescriptorIos {
|
|
|
51
51
|
modules: string[];
|
|
52
52
|
appDelegateSubscribers: string[];
|
|
53
53
|
reactDelegateHandlers: string[];
|
|
54
|
+
debugOnly: boolean;
|
|
54
55
|
}
|
|
55
56
|
export declare type ModuleDescriptor = ModuleDescriptorAndroid | ModuleDescriptorIos;
|
|
56
57
|
/**
|
|
@@ -92,6 +93,11 @@ export interface RawExpoModuleConfig {
|
|
|
92
93
|
* To have multiple modules, string array is also supported.
|
|
93
94
|
*/
|
|
94
95
|
swiftModuleName?: string | string[];
|
|
96
|
+
/**
|
|
97
|
+
* Whether this module will be added only to the debug configuration.
|
|
98
|
+
* Defaults to false.
|
|
99
|
+
*/
|
|
100
|
+
debugOnly?: boolean;
|
|
95
101
|
};
|
|
96
102
|
/**
|
|
97
103
|
* Android-specific config.
|
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';\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\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 ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\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}\n\nexport type ModuleDescriptor = ModuleDescriptorAndroid | ModuleDescriptorIos;\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 * iOS-specific config.\n */\n ios?: {\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 /**\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"]}
|
|
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';\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\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 ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\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 type ModuleDescriptor = ModuleDescriptorAndroid | ModuleDescriptorIos;\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 * iOS-specific config.\n */\n ios?: {\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 * 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.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": "b9d655c1bed682ad8919e071dd923968773f05b5"
|
|
52
52
|
}
|
|
@@ -44,7 +44,8 @@ module Expo
|
|
|
44
44
|
|
|
45
45
|
pod_options = {
|
|
46
46
|
:path => podspec_dir_path,
|
|
47
|
-
:testspecs => tests.include?(package.name) ? ['Tests'] : []
|
|
47
|
+
:testspecs => tests.include?(package.name) ? ['Tests'] : [],
|
|
48
|
+
:configuration => package.debugOnly ? ['Debug'] : [] # An empty array means all configurations
|
|
48
49
|
}.merge(global_flags, package.flags)
|
|
49
50
|
|
|
50
51
|
# Install the pod.
|
package/scripts/ios/package.rb
CHANGED
|
@@ -33,12 +33,16 @@ module Expo
|
|
|
33
33
|
# Class names of the modules that need to be included in the generated modules provider.
|
|
34
34
|
attr_reader :modules
|
|
35
35
|
|
|
36
|
+
# Whether this module should only be added to the debug configuration.
|
|
37
|
+
attr_reader :debugOnly
|
|
38
|
+
|
|
36
39
|
def initialize(json)
|
|
37
40
|
@name = json['packageName']
|
|
38
41
|
@version = json['packageVersion']
|
|
39
42
|
@pods = json['pods'].map { |pod| PackagePod.new(pod) }
|
|
40
43
|
@flags = json.fetch('flags', {})
|
|
41
44
|
@modules = json.fetch('modules', [])
|
|
45
|
+
@debugOnly = json['debugOnly']
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
end # class Package
|
package/src/ExpoModuleConfig.ts
CHANGED
|
@@ -58,6 +58,13 @@ export class ExpoModuleConfig {
|
|
|
58
58
|
return arrayize(this.rawConfig.ios?.swiftModuleName);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Returns whether this module will be added only to the debug configuration
|
|
63
|
+
*/
|
|
64
|
+
iosDebugOnly(): boolean {
|
|
65
|
+
return this.rawConfig.ios?.debugOnly ?? false;
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
/**
|
|
62
69
|
* Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
|
|
63
70
|
*/
|
package/src/platforms/ios.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
SearchOptions,
|
|
10
10
|
} from '../types';
|
|
11
11
|
|
|
12
|
+
const indent = ' ';
|
|
13
|
+
|
|
12
14
|
async function findPodspecFiles(revision: PackageRevision): Promise<string[]> {
|
|
13
15
|
const configPodspecPaths = revision.config?.iosPodspecPaths();
|
|
14
16
|
if (configPodspecPaths && configPodspecPaths.length) {
|
|
@@ -62,6 +64,7 @@ export async function resolveModuleAsync(
|
|
|
62
64
|
modules: revision.config?.iosModules() ?? [],
|
|
63
65
|
appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],
|
|
64
66
|
reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],
|
|
67
|
+
debugOnly: revision.config?.iosDebugOnly() ?? false,
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
|
|
@@ -85,28 +88,48 @@ async function generatePackageListFileContentAsync(
|
|
|
85
88
|
modules: ModuleDescriptorIos[],
|
|
86
89
|
className: string
|
|
87
90
|
): Promise<string> {
|
|
88
|
-
const
|
|
91
|
+
const iosModules = modules.filter(
|
|
89
92
|
(module) =>
|
|
90
93
|
module.modules.length ||
|
|
91
94
|
module.appDelegateSubscribers.length ||
|
|
92
95
|
module.reactDelegateHandlers.length
|
|
93
96
|
);
|
|
97
|
+
|
|
98
|
+
const modulesToImport = iosModules.filter((module) => !module.debugOnly);
|
|
99
|
+
const debugOnlyModules = iosModules.filter((module) => module.debugOnly);
|
|
100
|
+
|
|
94
101
|
const swiftModules = ([] as string[])
|
|
95
102
|
.concat(...modulesToImport.map((module) => module.swiftModuleNames))
|
|
96
103
|
.filter(Boolean);
|
|
97
104
|
|
|
105
|
+
const debugOnlySwiftModules = ([] as string[])
|
|
106
|
+
.concat(...debugOnlyModules.map((module) => module.swiftModuleNames))
|
|
107
|
+
.filter(Boolean);
|
|
108
|
+
|
|
98
109
|
const modulesClassNames = ([] as string[])
|
|
99
110
|
.concat(...modulesToImport.map((module) => module.modules))
|
|
100
111
|
.filter(Boolean);
|
|
101
112
|
|
|
113
|
+
const debugOnlyModulesClassNames = ([] as string[])
|
|
114
|
+
.concat(...debugOnlyModules.map((module) => module.modules))
|
|
115
|
+
.filter(Boolean);
|
|
116
|
+
|
|
102
117
|
const appDelegateSubscribers = ([] as string[]).concat(
|
|
103
118
|
...modulesToImport.map((module) => module.appDelegateSubscribers)
|
|
104
119
|
);
|
|
105
120
|
|
|
121
|
+
const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(
|
|
122
|
+
...debugOnlyModules.map((module) => module.appDelegateSubscribers)
|
|
123
|
+
);
|
|
124
|
+
|
|
106
125
|
const reactDelegateHandlerModules = modulesToImport.filter(
|
|
107
126
|
(module) => !!module.reactDelegateHandlers.length
|
|
108
127
|
);
|
|
109
128
|
|
|
129
|
+
const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(
|
|
130
|
+
(module) => !!module.reactDelegateHandlers.length
|
|
131
|
+
);
|
|
132
|
+
|
|
110
133
|
return `/**
|
|
111
134
|
* Automatically generated by expo-modules-autolinking.
|
|
112
135
|
*
|
|
@@ -115,33 +138,72 @@ async function generatePackageListFileContentAsync(
|
|
|
115
138
|
*/
|
|
116
139
|
|
|
117
140
|
import ExpoModulesCore
|
|
118
|
-
${swiftModules
|
|
141
|
+
${generateCommonImportList(swiftModules)}
|
|
142
|
+
${generateDebugOnlyImportList(debugOnlySwiftModules)}
|
|
119
143
|
@objc(${className})
|
|
120
144
|
public class ${className}: ModulesProvider {
|
|
121
145
|
public override func getModuleClasses() -> [AnyModule.Type] {
|
|
122
|
-
|
|
146
|
+
${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}
|
|
123
147
|
}
|
|
124
148
|
|
|
125
149
|
public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
|
|
126
|
-
|
|
150
|
+
${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}
|
|
127
151
|
}
|
|
128
152
|
|
|
129
153
|
public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
|
|
130
|
-
|
|
154
|
+
${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}
|
|
131
155
|
}
|
|
132
156
|
}
|
|
133
157
|
`;
|
|
134
158
|
}
|
|
135
159
|
|
|
160
|
+
function generateCommonImportList(swiftModules: string[]): string {
|
|
161
|
+
return swiftModules.map((moduleName) => `import ${moduleName}\n`).join('');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function generateDebugOnlyImportList(swiftModules: string[]): string {
|
|
165
|
+
if (!swiftModules.length) {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return `#if DEBUG\n${swiftModules
|
|
170
|
+
.map((moduleName) => `import ${moduleName}\n`)
|
|
171
|
+
.join('')}#endif\n`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {
|
|
175
|
+
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
176
|
+
if (debugOnlyClassName.length > 0) {
|
|
177
|
+
return `#if DEBUG\n${indent.repeat(2)}return ${formatArrayOfClassNames(
|
|
178
|
+
classNames.concat(debugOnlyClassName)
|
|
179
|
+
)}\n#else\n${indent.repeat(2)}return ${commonClassNames}\n#endif`;
|
|
180
|
+
} else {
|
|
181
|
+
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
136
185
|
/**
|
|
137
186
|
* Formats an array of class names to Swift's array containing these classes.
|
|
138
187
|
*/
|
|
139
188
|
function formatArrayOfClassNames(classNames: string[]): string {
|
|
140
|
-
const indent = ' ';
|
|
141
189
|
return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
|
|
142
190
|
${indent.repeat(2)}]`;
|
|
143
191
|
}
|
|
144
192
|
|
|
193
|
+
function generateReactDelegateHandlers(
|
|
194
|
+
module: ModuleDescriptorIos[],
|
|
195
|
+
debugOnlyModules: ModuleDescriptorIos[]
|
|
196
|
+
): string {
|
|
197
|
+
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
198
|
+
if (debugOnlyModules.length > 0) {
|
|
199
|
+
return `#if DEBUG\n${indent.repeat(2)}return ${formatArrayOfReactDelegateHandler(
|
|
200
|
+
module.concat(debugOnlyModules)
|
|
201
|
+
)}\n#else\n${indent.repeat(2)}return ${commonModules}\n#endif`;
|
|
202
|
+
} else {
|
|
203
|
+
return `${indent.repeat(2)}return ${commonModules}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
145
207
|
/**
|
|
146
208
|
* Formats an array of modules to Swift's array containing ReactDelegateHandlers
|
|
147
209
|
*/
|
|
@@ -152,7 +214,6 @@ export function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]
|
|
|
152
214
|
values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
|
|
153
215
|
}
|
|
154
216
|
}
|
|
155
|
-
const indent = ' ';
|
|
156
217
|
return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
|
|
157
218
|
${indent.repeat(2)}]`;
|
|
158
219
|
}
|
package/src/types.ts
CHANGED
|
@@ -64,6 +64,7 @@ export interface ModuleDescriptorIos {
|
|
|
64
64
|
modules: string[];
|
|
65
65
|
appDelegateSubscribers: string[];
|
|
66
66
|
reactDelegateHandlers: string[];
|
|
67
|
+
debugOnly: boolean;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
export type ModuleDescriptor = ModuleDescriptorAndroid | ModuleDescriptorIos;
|
|
@@ -113,6 +114,12 @@ export interface RawExpoModuleConfig {
|
|
|
113
114
|
* To have multiple modules, string array is also supported.
|
|
114
115
|
*/
|
|
115
116
|
swiftModuleName?: string | string[];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Whether this module will be added only to the debug configuration.
|
|
120
|
+
* Defaults to false.
|
|
121
|
+
*/
|
|
122
|
+
debugOnly?: boolean;
|
|
116
123
|
};
|
|
117
124
|
|
|
118
125
|
/**
|