1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.requireAndResolveExpoModuleConfig = exports.ExpoModuleConfig = void 0; 4function arrayize(value) { 5 if (Array.isArray(value)) { 6 return value; 7 } 8 return value != null ? [value] : []; 9} 10/** 11 * A class that wraps the raw config (`expo-module.json` or `unimodule.json`). 12 */ 13class ExpoModuleConfig { 14 constructor(rawConfig) { 15 this.rawConfig = rawConfig; 16 } 17 /** 18 * Whether the module supports given platform. 19 */ 20 supportsPlatform(platform) { 21 var _a, _b; 22 return (_b = (_a = this.rawConfig.platforms) === null || _a === void 0 ? void 0 : _a.includes(platform)) !== null && _b !== void 0 ? _b : false; 23 } 24 /** 25 * Returns a list of names of Swift native modules classes to put to the generated modules provider file. 26 */ 27 iosModules() { 28 var _a, _b; 29 const iosConfig = this.rawConfig.ios; 30 // `modulesClassNames` is a legacy name for the same config. 31 return (_b = (_a = iosConfig === null || iosConfig === void 0 ? void 0 : iosConfig.modules) !== null && _a !== void 0 ? _a : iosConfig === null || iosConfig === void 0 ? void 0 : iosConfig.modulesClassNames) !== null && _b !== void 0 ? _b : []; 32 } 33 /** 34 * Returns a list of names of Swift classes that receives AppDelegate life-cycle events. 35 */ 36 iosAppDelegateSubscribers() { 37 var _a, _b; 38 return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.appDelegateSubscribers) !== null && _b !== void 0 ? _b : []; 39 } 40 /** 41 * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`. 42 */ 43 iosReactDelegateHandlers() { 44 var _a, _b; 45 return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.reactDelegateHandlers) !== null && _b !== void 0 ? _b : []; 46 } 47 /** 48 * Returns podspec paths defined by the module author. 49 */ 50 iosPodspecPaths() { 51 var _a; 52 return arrayize((_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.podspecPath); 53 } 54 /** 55 * Returns the product module names, if defined by the module author. 56 */ 57 iosSwiftModuleNames() { 58 var _a; 59 return arrayize((_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.swiftModuleName); 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 } 68 /** 69 * Returns a list of names of Kotlin native modules classes to put to the generated package provider file. 70 */ 71 androidModules() { 72 var _a, _b; 73 const androidConfig = this.rawConfig.android; 74 // `modulesClassNames` is a legacy name for the same config. 75 return (_b = (_a = androidConfig === null || androidConfig === void 0 ? void 0 : androidConfig.modules) !== null && _a !== void 0 ? _a : androidConfig === null || androidConfig === void 0 ? void 0 : androidConfig.modulesClassNames) !== null && _b !== void 0 ? _b : []; 76 } 77 /** 78 * Returns build.gradle file paths defined by the module author. 79 */ 80 androidGradlePaths() { 81 var _a, _b; 82 return arrayize((_b = (_a = this.rawConfig.android) === null || _a === void 0 ? void 0 : _a.gradlePath) !== null && _b !== void 0 ? _b : []); 83 } 84 /** 85 * Returns serializable raw config. 86 */ 87 toJSON() { 88 return this.rawConfig; 89 } 90} 91exports.ExpoModuleConfig = ExpoModuleConfig; 92/** 93 * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class. 94 */ 95function requireAndResolveExpoModuleConfig(path) { 96 // TODO: Validate the raw config against a schema. 97 // TODO: Support for `*.js` files, not only static `*.json`. 98 return new ExpoModuleConfig(require(path)); 99} 100exports.requireAndResolveExpoModuleConfig = requireAndResolveExpoModuleConfig; 101//# sourceMappingURL=ExpoModuleConfig.js.map