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