expo-modules-autolinking 0.7.0 → 0.8.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 +24 -0
- package/build/ExpoModuleConfig.d.ts +4 -0
- package/build/ExpoModuleConfig.js +7 -0
- package/build/ExpoModuleConfig.js.map +1 -1
- package/build/autolinking/mergeLinkingOptions.js +4 -0
- package/build/autolinking/mergeLinkingOptions.js.map +1 -1
- package/build/platforms/ios.js +52 -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/cocoapods/user_project_integrator.rb +1 -0
- package/scripts/ios/package.rb +4 -0
- package/scripts/ios/project_integrator.rb +30 -0
- package/src/ExpoModuleConfig.ts +7 -0
- package/src/autolinking/mergeLinkingOptions.ts +5 -0
- package/src/platforms/ios.ts +93 -7
- package/src/types.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,30 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.8.1 — 2022-05-12
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed an infinite loop when the **package.json** is placed at the root path. ([#17440](https://github.com/expo/expo/pull/17440) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
- Fix iOS build if project config name is other than RELEASE or DEBUG ([#17439](https://github.com/expo/expo/pull/17439) by [@uloco](https://github.com/uloco))
|
|
19
|
+
|
|
20
|
+
## 0.8.0 — 2022-05-06
|
|
21
|
+
|
|
22
|
+
### 🎉 New features
|
|
23
|
+
|
|
24
|
+
- Add `ios.debugOnly` to module config. ([#17331](https://github.com/expo/expo/pull/17331) by [@lukmccall](https://github.com/lukmccall))
|
|
25
|
+
- Setting `EXPO_CONFIGURATION_DEBUG` or `EXPO_CONFIGURATION_RELEASE` Swift flags on project targets. ([#17378](https://github.com/expo/expo/pull/17378) by [@tsapeta](https://github.com/tsapeta))
|
|
26
|
+
|
|
27
|
+
### 🐛 Bug fixes
|
|
28
|
+
|
|
29
|
+
- Fix debug-only modules weren't installed if the `DEBUG` flag wasn't present in `OTHER_SWIFT_FLAGS`. ([#17383](https://github.com/expo/expo/pull/17383) by [@lukmccall](https://github.com/lukmccall))
|
|
30
|
+
|
|
31
|
+
## 0.7.1 — 2022-05-05
|
|
32
|
+
|
|
33
|
+
### 🎉 New features
|
|
34
|
+
|
|
35
|
+
- Add `ios.debugOnly` to module config. ([#17331](https://github.com/expo/expo/pull/17331) by [@lukmccall](https://github.com/lukmccall))
|
|
36
|
+
|
|
13
37
|
## 0.7.0 — 2022-04-18
|
|
14
38
|
|
|
15
39
|
- 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;IAClE,CAAC;IAED;;OAEG;IACH,yBAAyB;;QACvB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,sBAAsB,mCAAI,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,qBAAqB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG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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"]}
|
|
@@ -53,6 +53,10 @@ async function findDefaultPathsAsync(cwd) {
|
|
|
53
53
|
while ((pkgJsonPath = await (0, find_up_1.default)('package.json', { cwd: dir }))) {
|
|
54
54
|
dir = path_1.default.dirname(path_1.default.dirname(pkgJsonPath));
|
|
55
55
|
paths.push(path_1.default.join(pkgJsonPath, '..', 'node_modules'));
|
|
56
|
+
// This stops the infinite loop when the package.json is placed at the root dir.
|
|
57
|
+
if (path_1.default.dirname(dir) === dir) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
return paths;
|
|
58
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLinkingOptions.js","sourceRoot":"","sources":["../../src/autolinking/mergeLinkingOptions.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;GAEG;AACU,QAAA,sBAAsB,GAAG,iBAAM,CAAC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YAC7B,MAAM;SACP;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,4BAA4B,CACzC,gBAA2C,EAC3C,GAAW;IAEX,uCAAuC;IACvC,IAAI,gBAAgB,EAAE;QACpB,MAAM,oBAAoB,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACjE,IAAI,MAAM,kBAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YAC7C,OAAO,oBAAoB,CAAC;SAC7B;KACF;IAED,4DAA4D;IAC5D,MAAM,EAAE,GAAG,MAAM,IAAA,iBAAM,EAAC,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,EAAE;QACP,OAAO,IAAI,CAAC;KACb;IACD,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,gBAAgB,IAAI,SAAS,CAAC,CAAC;IACxE,OAAO,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC","sourcesContent":["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { SearchOptions } from '../types';\n\n/**\n * Path to the `package.json` of the closest project in the current working dir.\n */\nexport const projectPackageJsonPath = findUp.sync('package.json', { cwd: process.cwd() }) as string;\n\n// This won't happen in usual scenarios, but we need to unwrap the optional path :)\nif (!projectPackageJsonPath) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${process.cwd()}\"`);\n}\n\n/**\n * Merges autolinking options from different sources (the later the higher priority)\n * - options defined in package.json's `expo.autolinking` field\n * - platform-specific options from the above (e.g. `expo.autolinking.ios`)\n * - options provided to the CLI command\n */\nexport async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(\n providedOptions: OptionsType\n): Promise<OptionsType> {\n const packageJson = require(projectPackageJsonPath);\n const baseOptions = packageJson.expo?.autolinking;\n const platformOptions = providedOptions.platform && baseOptions?.[providedOptions.platform];\n const finalOptions = Object.assign(\n {},\n baseOptions,\n platformOptions,\n providedOptions\n ) as OptionsType;\n\n // Makes provided paths absolute or falls back to default paths if none was provided.\n finalOptions.searchPaths = await resolveSearchPathsAsync(finalOptions.searchPaths, process.cwd());\n\n finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(\n finalOptions.nativeModulesDir,\n process.cwd()\n );\n\n return finalOptions;\n}\n\n/**\n * Resolves autolinking search paths. If none is provided, it accumulates all node_modules when\n * going up through the path components. This makes workspaces work out-of-the-box without any configs.\n */\nexport async function resolveSearchPathsAsync(\n searchPaths: string[] | null,\n cwd: string\n): Promise<string[]> {\n return searchPaths && searchPaths.length > 0\n ? searchPaths.map((searchPath) => path.resolve(cwd, searchPath))\n : await findDefaultPathsAsync(cwd);\n}\n\n/**\n * Looks up for workspace's `node_modules` paths.\n */\nasync function findDefaultPathsAsync(cwd: string): Promise<string[]> {\n const paths = [];\n let dir = cwd;\n let pkgJsonPath: string | undefined;\n\n while ((pkgJsonPath = await findUp('package.json', { cwd: dir }))) {\n dir = path.dirname(path.dirname(pkgJsonPath));\n paths.push(path.join(pkgJsonPath, '..', 'node_modules'));\n\n // 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 * @returns resolved native modules directory or `null` if it is not found or doesn't exist.\n */\nasync function resolveNativeModulesDirAsync(\n nativeModulesDir: string | null | undefined,\n cwd: string\n): Promise<string | null> {\n // first try resolving the provided dir\n if (nativeModulesDir) {\n const nativeModulesDirPath = path.resolve(cwd, nativeModulesDir);\n if (await fs.pathExists(nativeModulesDirPath)) {\n return nativeModulesDirPath;\n }\n }\n\n // if not found, try to find it relative to the package.json\n const up = await findUp('package.json', { cwd });\n if (!up) {\n return null;\n }\n const resolvedPath = path.join(up, '..', nativeModulesDir || 'modules');\n return fs.existsSync(resolvedPath) ? resolvedPath : null;\n}\n"]}
|
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,58 @@ 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}`).join('\n');
|
|
119
|
+
}
|
|
120
|
+
function generateDebugOnlyImportList(swiftModules) {
|
|
121
|
+
if (!swiftModules.length) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
return (wrapInDebugConfigurationCheck(0, swiftModules.map((moduleName) => `import ${moduleName}`).join('\n')) + '\n');
|
|
125
|
+
}
|
|
126
|
+
function generateModuleClasses(classNames, debugOnlyClassName) {
|
|
127
|
+
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
128
|
+
if (debugOnlyClassName.length > 0) {
|
|
129
|
+
return wrapInDebugConfigurationCheck(2, `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`, `return ${commonClassNames}`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
104
135
|
/**
|
|
105
136
|
* Formats an array of class names to Swift's array containing these classes.
|
|
106
137
|
*/
|
|
107
138
|
function formatArrayOfClassNames(classNames) {
|
|
108
|
-
const indent = ' ';
|
|
109
139
|
return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
|
|
110
140
|
${indent.repeat(2)}]`;
|
|
111
141
|
}
|
|
142
|
+
function generateReactDelegateHandlers(module, debugOnlyModules) {
|
|
143
|
+
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
144
|
+
if (debugOnlyModules.length > 0) {
|
|
145
|
+
return wrapInDebugConfigurationCheck(2, `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`, `return ${commonModules}`);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return `${indent.repeat(2)}return ${commonModules}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
112
151
|
/**
|
|
113
152
|
* Formats an array of modules to Swift's array containing ReactDelegateHandlers
|
|
114
153
|
*/
|
|
@@ -119,9 +158,14 @@ function formatArrayOfReactDelegateHandler(modules) {
|
|
|
119
158
|
values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
|
|
120
159
|
}
|
|
121
160
|
}
|
|
122
|
-
const indent = ' ';
|
|
123
161
|
return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
|
|
124
162
|
${indent.repeat(2)}]`;
|
|
125
163
|
}
|
|
126
164
|
exports.formatArrayOfReactDelegateHandler = formatArrayOfReactDelegateHandler;
|
|
165
|
+
function wrapInDebugConfigurationCheck(indentationLevel, debugBlock, releaseBlock = null) {
|
|
166
|
+
if (releaseBlock) {
|
|
167
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(indentationLevel)}${debugBlock}\n${indent.repeat(indentationLevel)}#else\n${indent.repeat(indentationLevel)}${releaseBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
168
|
+
}
|
|
169
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(indentationLevel)}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
170
|
+
}
|
|
127
171
|
//# sourceMappingURL=ios.js.map
|
|
@@ -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,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;IAED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U,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC5F,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,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,MAAM,MAAM,GAAG,IAAI,CAAC;IACpB,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;AAVD,8EAUC","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\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,IAA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M,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AATD,8EASC;AAED,SAAS,6BAA6B,CACpC,gBAAwB,EACxB,UAAkB,EAClB,eAA8B,IAAI;IAElC,IAAI,YAAY,EAAE;QAChB,OAAO,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?.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"]}
|
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.
|
|
3
|
+
"version": "0.8.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": "98e9664e2c37baa2b71a8bc3c43f8f9e24a391c3"
|
|
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.
|
|
@@ -44,6 +44,7 @@ module Pod
|
|
|
44
44
|
|
|
45
45
|
Expo::ProjectIntegrator::integrate_targets_in_project(project_targets, project)
|
|
46
46
|
Expo::ProjectIntegrator::remove_nils_from_source_files(project)
|
|
47
|
+
Expo::ProjectIntegrator::set_autolinking_configuration(project)
|
|
47
48
|
|
|
48
49
|
# CocoaPods saves the projects to integrate at the next step,
|
|
49
50
|
# but in some cases we're modifying other projects as well.
|
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
|
|
@@ -3,6 +3,9 @@ module Expo
|
|
|
3
3
|
module ProjectIntegrator
|
|
4
4
|
include Pod
|
|
5
5
|
|
|
6
|
+
CONFIGURATION_FLAG_PREFIX = 'EXPO_CONFIGURATION_'
|
|
7
|
+
SWIFT_FLAGS = 'OTHER_SWIFT_FLAGS'
|
|
8
|
+
|
|
6
9
|
# Integrates targets in the project and generates modules providers.
|
|
7
10
|
def self.integrate_targets_in_project(targets, project)
|
|
8
11
|
# Find the targets that use expo modules and need the modules provider
|
|
@@ -98,5 +101,32 @@ module Expo
|
|
|
98
101
|
project.main_group.find_subpath(Constants::GENERATED_GROUP_NAME, autocreate)
|
|
99
102
|
end
|
|
100
103
|
|
|
104
|
+
# Sets EXPO_CONFIGURATION_* compiler flag for Swift.
|
|
105
|
+
def self.set_autolinking_configuration(project)
|
|
106
|
+
project.native_targets.each do |native_target|
|
|
107
|
+
native_target.build_configurations.each do |build_configuration|
|
|
108
|
+
configuration_flag = "-D #{CONFIGURATION_FLAG_PREFIX}#{build_configuration.debug? ? "DEBUG" : "RELEASE"}"
|
|
109
|
+
build_settings = build_configuration.build_settings
|
|
110
|
+
|
|
111
|
+
# For some targets it might be `nil` by default which is an equivalent to `$(inherited)`
|
|
112
|
+
if build_settings[SWIFT_FLAGS].nil?
|
|
113
|
+
build_settings[SWIFT_FLAGS] ||= '$(inherited)'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# If the correct flag is not set yet
|
|
117
|
+
if !build_settings[SWIFT_FLAGS].include?(configuration_flag)
|
|
118
|
+
# Remove existing flag to make sure we don't put another one each time
|
|
119
|
+
build_settings[SWIFT_FLAGS] = build_settings[SWIFT_FLAGS].gsub(/\b-D\s+#{Regexp.quote(CONFIGURATION_FLAG_PREFIX)}\w+/, '')
|
|
120
|
+
|
|
121
|
+
# Add the correct flag
|
|
122
|
+
build_settings[SWIFT_FLAGS] << ' ' << configuration_flag
|
|
123
|
+
|
|
124
|
+
# Make sure the project will be saved as we did some changes
|
|
125
|
+
project.mark_dirty!
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
101
131
|
end # module ExpoAutolinkingExtension
|
|
102
132
|
end # module Expo
|
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
|
*/
|
|
@@ -68,6 +68,11 @@ async function findDefaultPathsAsync(cwd: string): Promise<string[]> {
|
|
|
68
68
|
while ((pkgJsonPath = await findUp('package.json', { cwd: dir }))) {
|
|
69
69
|
dir = path.dirname(path.dirname(pkgJsonPath));
|
|
70
70
|
paths.push(path.join(pkgJsonPath, '..', 'node_modules'));
|
|
71
|
+
|
|
72
|
+
// This stops the infinite loop when the package.json is placed at the root dir.
|
|
73
|
+
if (path.dirname(dir) === dir) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
return paths;
|
|
73
78
|
}
|
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,79 @@ 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}`).join('\n');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function generateDebugOnlyImportList(swiftModules: string[]): string {
|
|
165
|
+
if (!swiftModules.length) {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
wrapInDebugConfigurationCheck(
|
|
171
|
+
0,
|
|
172
|
+
swiftModules.map((moduleName) => `import ${moduleName}`).join('\n')
|
|
173
|
+
) + '\n'
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {
|
|
178
|
+
const commonClassNames = formatArrayOfClassNames(classNames);
|
|
179
|
+
if (debugOnlyClassName.length > 0) {
|
|
180
|
+
return wrapInDebugConfigurationCheck(
|
|
181
|
+
2,
|
|
182
|
+
`return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,
|
|
183
|
+
`return ${commonClassNames}`
|
|
184
|
+
);
|
|
185
|
+
} else {
|
|
186
|
+
return `${indent.repeat(2)}return ${commonClassNames}`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
136
190
|
/**
|
|
137
191
|
* Formats an array of class names to Swift's array containing these classes.
|
|
138
192
|
*/
|
|
139
193
|
function formatArrayOfClassNames(classNames: string[]): string {
|
|
140
|
-
const indent = ' ';
|
|
141
194
|
return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
|
|
142
195
|
${indent.repeat(2)}]`;
|
|
143
196
|
}
|
|
144
197
|
|
|
198
|
+
function generateReactDelegateHandlers(
|
|
199
|
+
module: ModuleDescriptorIos[],
|
|
200
|
+
debugOnlyModules: ModuleDescriptorIos[]
|
|
201
|
+
): string {
|
|
202
|
+
const commonModules = formatArrayOfReactDelegateHandler(module);
|
|
203
|
+
if (debugOnlyModules.length > 0) {
|
|
204
|
+
return wrapInDebugConfigurationCheck(
|
|
205
|
+
2,
|
|
206
|
+
`return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,
|
|
207
|
+
`return ${commonModules}`
|
|
208
|
+
);
|
|
209
|
+
} else {
|
|
210
|
+
return `${indent.repeat(2)}return ${commonModules}`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
145
214
|
/**
|
|
146
215
|
* Formats an array of modules to Swift's array containing ReactDelegateHandlers
|
|
147
216
|
*/
|
|
@@ -152,7 +221,24 @@ export function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]
|
|
|
152
221
|
values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
|
|
153
222
|
}
|
|
154
223
|
}
|
|
155
|
-
const indent = ' ';
|
|
156
224
|
return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
|
|
157
225
|
${indent.repeat(2)}]`;
|
|
158
226
|
}
|
|
227
|
+
|
|
228
|
+
function wrapInDebugConfigurationCheck(
|
|
229
|
+
indentationLevel: number,
|
|
230
|
+
debugBlock: string,
|
|
231
|
+
releaseBlock: string | null = null
|
|
232
|
+
) {
|
|
233
|
+
if (releaseBlock) {
|
|
234
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
|
|
235
|
+
indentationLevel
|
|
236
|
+
)}${debugBlock}\n${indent.repeat(indentationLevel)}#else\n${indent.repeat(
|
|
237
|
+
indentationLevel
|
|
238
|
+
)}${releaseBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\n${indent.repeat(
|
|
242
|
+
indentationLevel
|
|
243
|
+
)}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
244
|
+
}
|
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
|
/**
|