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