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 a list of names of Kotlin native modules classes to put to the generated package provider file. 63 */ 64 androidModules() { 65 var _a, _b; 66 const androidConfig = this.rawConfig.android; 67 // `modulesClassNames` is a legacy name for the same config. 68 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 : []; 69 } 70 /** 71 * Returns build.gradle file paths defined by the module author. 72 */ 73 androidGradlePaths() { 74 var _a, _b; 75 return arrayize((_b = (_a = this.rawConfig.android) === null || _a === void 0 ? void 0 : _a.gradlePath) !== null && _b !== void 0 ? _b : []); 76 } 77 /** 78 * Returns serializable raw config. 79 */ 80 toJSON() { 81 return this.rawConfig; 82 } 83} 84exports.ExpoModuleConfig = ExpoModuleConfig; 85/** 86 * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class. 87 */ 88function requireAndResolveExpoModuleConfig(path) { 89 // TODO: Validate the raw config against a schema. 90 // TODO: Support for `*.js` files, not only static `*.json`. 91 return new ExpoModuleConfig(require(path)); 92} 93exports.requireAndResolveExpoModuleConfig = requireAndResolveExpoModuleConfig; 94//# sourceMappingURL=ExpoModuleConfig.js.map