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 return val.name || 'withAnonymous'; 58 } else if (Array.isArray(val)) { 59 return val.map(serializeAndEvaluatePlugin); 60 } else if (typeof val === 'object') { 61 const output = {}; 62 for (const property in val) { 63 if (val.hasOwnProperty(property)) { 64 output[property] = serializeAndEvaluatePlugin(val[property]); 65 } 66 } 67 return output; 68 } 69 // symbol 70 throw new (_Errors().ConfigError)(`Expo config doesn't support \`Symbols\`: ${val}`, 'INVALID_CONFIG'); 71} 72function serializeAfterStaticPlugins(val) { 73 if (typeof val === 'object' && !Array.isArray(val)) { 74 const output = {}; 75 for (const property in val) { 76 if (val.hasOwnProperty(property)) { 77 if (property === 'mods') { 78 // Don't serialize mods 79 output[property] = val[property]; 80 } else if (property === 'plugins' && Array.isArray(val[property])) { 81 // Serialize the mods by removing any config plugins 82 output[property] = val[property].map(serializeAndEvaluatePlugin); 83 } else { 84 output[property] = serializeAndEvaluate(val[property]); 85 } 86 } 87 } 88 return output; 89 } 90 return serializeAndEvaluate(val); 91} 92//# sourceMappingURL=Serialize.js.map