1"use strict"; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6exports.createLegacyPlugin = createLegacyPlugin; 7 8function _configPlugins() { 9 const data = require("@expo/config-plugins"); 10 11 _configPlugins = function () { 12 return data; 13 }; 14 15 return data; 16} 17 18const toCamelCase = s => s.replace(/-./g, x => x.toUpperCase()[1]); 19 20function isModuleExcluded(config, packageName) { 21 var _config$_internal; 22 23 // Skip using the versioned plugin when autolinking is enabled 24 // and doesn't link the native module. 25 return ((_config$_internal = config._internal) === null || _config$_internal === void 0 ? void 0 : _config$_internal.autolinkedModules) && !config._internal.autolinkedModules.includes(packageName); 26} 27 28function createLegacyPlugin({ 29 packageName, 30 fallback 31}) { 32 let withFallback; 33 34 if (Array.isArray(fallback)) { 35 withFallback = config => (0, _configPlugins().withPlugins)(config, fallback); 36 } else { 37 withFallback = fallback; 38 } 39 40 const withUnknown = config => { 41 // Skip using the versioned plugin when autolinking is enabled 42 // and doesn't link the native module. 43 if (isModuleExcluded(config, packageName)) { 44 return (0, _configPlugins().createRunOncePlugin)(withFallback, packageName)(config); 45 } 46 47 return (0, _configPlugins().withStaticPlugin)(config, { 48 _isLegacyPlugin: true, 49 plugin: packageName, 50 // If the static plugin isn't found, use the unversioned one. 51 fallback: (0, _configPlugins().createRunOncePlugin)(withFallback, packageName) 52 }); 53 }; 54 55 const methodName = toCamelCase(`with-${packageName}`); 56 Object.defineProperty(withUnknown, 'name', { 57 value: methodName 58 }); 59 return withUnknown; 60} 61//# sourceMappingURL=createLegacyPlugin.js.map