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 rawConfig; 15 constructor(rawConfig) { 16 this.rawConfig = rawConfig; 17 } 18 /** 19 * Whether the module supports given platform. 20 */ 21 supportsPlatform(platform) { 22 return this.rawConfig.platforms?.includes(platform) ?? 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 const iosConfig = this.rawConfig.ios; 29 // `modulesClassNames` is a legacy name for the same config. 30 return iosConfig?.modules ?? iosConfig?.modulesClassNames ?? []; 31 } 32 /** 33 * Returns a list of names of Swift classes that receives AppDelegate life-cycle events. 34 */ 35 iosAppDelegateSubscribers() { 36 return this.rawConfig.ios?.appDelegateSubscribers ?? []; 37 } 38 /** 39 * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`. 40 */ 41 iosReactDelegateHandlers() { 42 return this.rawConfig.ios?.reactDelegateHandlers ?? []; 43 } 44 /** 45 * Returns podspec paths defined by the module author. 46 */ 47 iosPodspecPaths() { 48 return arrayize(this.rawConfig.ios?.podspecPath); 49 } 50 /** 51 * Returns the product module names, if defined by the module author. 52 */ 53 iosSwiftModuleNames() { 54 return arrayize(this.rawConfig.ios?.swiftModuleName); 55 } 56 /** 57 * Returns whether this module will be added only to the debug configuration 58 */ 59 iosDebugOnly() { 60 return this.rawConfig.ios?.debugOnly ?? false; 61 } 62 /** 63 * Returns a list of names of Kotlin native modules classes to put to the generated package provider file. 64 */ 65 androidModules() { 66 const androidConfig = this.rawConfig.android; 67 // `modulesClassNames` is a legacy name for the same config. 68 return androidConfig?.modules ?? androidConfig?.modulesClassNames ?? []; 69 } 70 /** 71 * Returns build.gradle file paths defined by the module author. 72 */ 73 androidGradlePaths() { 74 return arrayize(this.rawConfig.android?.gradlePath ?? []); 75 } 76 /** 77 * Returns gradle plugins descriptors defined by the module author. 78 */ 79 androidGradlePlugins() { 80 return arrayize(this.rawConfig.android?.gradlePlugins ?? []); 81 } 82 /** 83 * Returns serializable raw config. 84 */ 85 toJSON() { 86 return this.rawConfig; 87 } 88} 89exports.ExpoModuleConfig = ExpoModuleConfig; 90/** 91 * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class. 92 */ 93function requireAndResolveExpoModuleConfig(path) { 94 // TODO: Validate the raw config against a schema. 95 // TODO: Support for `*.js` files, not only static `*.json`. 96 return new ExpoModuleConfig(require(path)); 97} 98exports.requireAndResolveExpoModuleConfig = requireAndResolveExpoModuleConfig; 99//# sourceMappingURL=ExpoModuleConfig.js.map