description and source-codebabel-plugin-import = function (_ref) {
var types = _ref.types;
var plugins = null;
// Only for test
global.__clearBabelAntdPlugin = function () {
plugins = null;
};
function applyInstance(method, args, context) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion
= true) {
var plugin = _step.value;
if (plugin[method]) {
plugin[method].apply(plugin, [].concat(_toConsumableArray(args), [context]));
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
function Program(path, _ref2) {
var opts = _ref2.opts;
// Init plugin instances once.
if (!plugins) {
if (Array.isArray(opts)) {
plugins = opts.map(function (_ref3) {
var libraryName = _ref3.libraryName,
libraryDirectory = _ref3.libraryDirectory,
style = _ref3.style,
camel2DashComponentName = _ref3.camel2DashComponentName,
camel2UnderlineComponentName = _ref3.camel2UnderlineComponentName;
(0, _assert2.default)(libraryName, 'libraryName should be provided');
return new _Plugin2.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName
, types);
});
} else {
opts = opts || {};
(0, _assert2.default)(opts.libraryName, 'libraryName should be provided');
plugins = [new _Plugin2.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.camel2DashComponentName, opts.
camel2UnderlineComponentName, types)];
}
}
applyInstance('Program', arguments, this);
}
var methods = ['ImportDeclaration', 'CallExpression', 'MemberExpression', 'Property', 'VariableDeclarator', 'LogicalExpression
', 'ConditionalExpression', 'IfStatement', 'ExpressionStatement', 'ExportDefaultDeclaration'];
var ret = {
visitor: { Program: Program }
};
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
var _loop = function _loop() {
var method = _step2.value;
ret.visitor[method] = function () {
applyInstance(method, arguments, ret.visitor);
};
};
for (var _iterator2 = methods[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done);
_iteratorNormalCompletion2 = true) {
_loop();
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return ret;
}