1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.serializeAfterStaticPlugins = serializeAfterStaticPlugins; 7exports.serializeAndEvaluate = serializeAndEvaluate; 8exports.serializeSkippingMods = serializeSkippingMods; 9function _Errors() { 10 const data = require("./Errors"); 11 _Errors = function () { 12 return data; 13 }; 14 return data; 15} 16function serializeAndEvaluate(val) { 17 if (['undefined', 'string', 'boolean', 'number', 'bigint'].includes(typeof val)) { 18 return val; 19 } else if (typeof val === 'function') { 20 // TODO: Bacon: Should we support async methods? 21 return val(); 22 } else if (Array.isArray(val)) { 23 return val.map(serializeAndEvaluate); 24 } else if (typeof val === 'object') { 25 const output = {}; 26 for (const property in val) { 27 if (val.hasOwnProperty(property)) { 28 output[property] = serializeAndEvaluate(val[property]); 29 } 30 } 31 return output; 32 } 33 // symbol 34 throw new (_Errors().ConfigError)(`Expo config doesn't support \`Symbols\`: ${val}`, 'INVALID_CONFIG'); 35} 36function serializeSkippingMods(val) { 37 if (typeof val === 'object' && !Array.isArray(val)) { 38 const output = {}; 39 for (const property in val) { 40 if (val.hasOwnProperty(property)) { 41 if (property === 'mods' || property === 'plugins') { 42 // Don't serialize mods or plugins 43 output[property] = val[property]; 44 } else { 45 output[property] = serializeAndEvaluate(val[property]); 46 } 47 } 48 } 49 return output; 50 } 51 return serializeAndEvaluate(val); 52} 53function serializeAndEvaluatePlugin(val) { 54 if (['undefined', 'string', 'boolean', 'number', 'bigint'].includes(typeof val)) { 55 return val; 56 } else if (typeof val === 'function') { 57 var _val$name; 58 return (_val$name = val.name) !== null && _val$name !== void 0 ? _val$name : 'withAnonymous'; 59 } else if (Array.isArray(val)) { 60 return val.map(serializeAndEvaluatePlugin); 61 } else if (typeof val === 'object') { 62 const output = {}; 63 for (const property in val) { 64 if (val.hasOwnProperty(property)) { 65 output[property] = serializeAndEvaluatePlugin(val[property]); 66 } 67 } 68 return output; 69 } 70 // symbol 71 throw new (_Errors().ConfigError)(`Expo config doesn't support \`Symbols\`: ${val}`, 'INVALID_CONFIG'); 72} 73function serializeAfterStaticPlugins(val) { 74 if (typeof val === 'object' && !Array.isArray(val)) { 75 const output = {}; 76 for (const property in val) { 77 if (val.hasOwnProperty(property)) { 78 if (property === 'mods') { 79 // Don't serialize mods 80 output[property] = val[property]; 81 } else if (property === 'plugins' && Array.isArray(val[property])) { 82 // Serialize the mods by removing any config plugins 83 output[property] = val[property].map(serializeAndEvaluatePlugin); 84 } else { 85 output[property] = serializeAndEvaluate(val[property]); 86 } 87 } 88 } 89 return output; 90 } 91 return serializeAndEvaluate(val); 92} 93//# sourceMappingURL=Serialize.js.map