Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-traverse

Package Overview
Dependencies
Maintainers
6
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-traverse - npm Package Compare versions

Comparing version 7.0.0-beta.2 to 7.0.0-beta.3

7

lib/cache.js

@@ -7,4 +7,7 @@ "use strict";

exports.clearScope = clearScope;
var path = exports.path = new WeakMap();
var scope = exports.scope = new WeakMap();
exports.scope = exports.path = void 0;
var path = new WeakMap();
exports.path = path;
var scope = new WeakMap();
exports.scope = scope;

@@ -11,0 +14,0 @@ function clear() {

"use strict";
exports.__esModule = true;
exports.default = undefined;
exports.default = void 0;
var _path4 = require("./path");
var _path4 = _interopRequireDefault(require("./path"));
var _path5 = _interopRequireDefault(_path4);
var t = _interopRequireWildcard(require("babel-types"));
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -22,3 +18,8 @@

function TraversalContext(scope, opts, state, parentPath) {
this.queue = null;
Object.defineProperty(this, "queue", {
configurable: true,
enumerable: true,
writable: true,
value: null
});
this.parentPath = parentPath;

@@ -30,3 +31,5 @@ this.scope = scope;

TraversalContext.prototype.shouldVisit = function shouldVisit(node) {
var _proto = TraversalContext.prototype;
_proto.shouldVisit = function shouldVisit(node) {
var opts = this.opts;

@@ -57,4 +60,4 @@ if (opts.enter || opts.exit) return true;

TraversalContext.prototype.create = function create(node, obj, key, listKey) {
return _path5.default.get({
_proto.create = function create(node, obj, key, listKey) {
return _path4.default.get({
parentPath: this.parentPath,

@@ -68,3 +71,3 @@ parent: node,

TraversalContext.prototype.maybeQueue = function maybeQueue(path, notPriority) {
_proto.maybeQueue = function maybeQueue(path, notPriority) {
if (this.trap) {

@@ -83,3 +86,3 @@ throw new Error("Infinite cycle detected");

TraversalContext.prototype.visitMultiple = function visitMultiple(container, parent, listKey) {
_proto.visitMultiple = function visitMultiple(container, parent, listKey) {
if (container.length === 0) return false;

@@ -99,3 +102,3 @@ var queue = [];

TraversalContext.prototype.visitSingle = function visitSingle(node, key) {
_proto.visitSingle = function visitSingle(node, key) {
if (this.shouldVisit(node[key])) {

@@ -108,3 +111,3 @@ return this.visitQueue([this.create(node, node, key)]);

TraversalContext.prototype.visitQueue = function visitQueue(queue) {
_proto.visitQueue = function visitQueue(queue) {
this.queue = queue;

@@ -178,3 +181,3 @@ this.priorityQueue = [];

TraversalContext.prototype.visit = function visit(node, key) {
_proto.visit = function visit(node, key) {
var nodes = node[key];

@@ -181,0 +184,0 @@ if (!nodes) return false;

"use strict";
exports.__esModule = true;
exports.default = void 0;
var Hub = function Hub(file, options) {
var Hub = function Hub(file) {
this.file = file;
this.options = options;
};
exports.default = Hub;
"use strict";
exports.__esModule = true;
exports.visitors = exports.Hub = exports.Scope = exports.NodePath = undefined;
var _path = require("./path");
exports.default = traverse;
Object.defineProperty(exports, "NodePath", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_path).default;
return _path.default;
}
});
var _scope = require("./scope");
Object.defineProperty(exports, "Scope", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_scope).default;
return _scope.default;
}
});
var _hub = require("./hub");
Object.defineProperty(exports, "Hub", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_hub).default;
return _hub.default;
}
});
exports.default = traverse;
exports.visitors = void 0;
var _context = require("./context");
var _context = _interopRequireDefault(require("./context"));
var _context2 = _interopRequireDefault(_context);
var visitors = _interopRequireWildcard(require("./visitors"));
var _visitors = require("./visitors");
exports.visitors = visitors;
var visitors = _interopRequireWildcard(_visitors);
var _includes = _interopRequireDefault(require("lodash/includes"));
var _babelMessages = require("babel-messages");
var t = _interopRequireWildcard(require("babel-types"));
var messages = _interopRequireWildcard(_babelMessages);
var cache = _interopRequireWildcard(require("./cache"));
var _includes = require("lodash/includes");
var _path = _interopRequireDefault(require("./path"));
var _includes2 = _interopRequireDefault(_includes);
var _scope = _interopRequireDefault(require("./scope"));
var _babelTypes = require("babel-types");
var _hub = _interopRequireDefault(require("./hub"));
var t = _interopRequireWildcard(_babelTypes);
var _cache = require("./cache");
var cache = _interopRequireWildcard(_cache);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -62,4 +47,2 @@

exports.visitors = visitors;
function traverse(parent, opts, scope, state, parentPath) {

@@ -71,3 +54,3 @@ if (!parent) return;

if (parent.type !== "Program" && parent.type !== "File") {
throw new Error(messages.get("traverseNeedsParent", parent.type));
throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + ("Instead of that you tried to traverse a " + parent.type + " node without ") + "passing scope and parentPath.");
}

@@ -94,3 +77,3 @@ }

if (!keys) return;
var context = new _context2.default(scope, opts, state, parentPath);
var context = new _context.default(scope, opts, state, parentPath);

@@ -133,3 +116,3 @@ for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

traverse.hasType = function (tree, type, blacklistTypes) {
if ((0, _includes2.default)(blacklistTypes, tree.type)) return false;
if ((0, _includes.default)(blacklistTypes, tree.type)) return false;
if (tree.type === type) return true;

@@ -136,0 +119,0 @@ var state = {

@@ -15,10 +15,6 @@ "use strict";

var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
var _index = _interopRequireDefault(require("./index"));
var _index = require("./index");
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -74,3 +70,3 @@

return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
var earliest = void 0;
var earliest;
var keys = t.VISITOR_KEYS[deepest.type];

@@ -119,4 +115,3 @@ var _arr = ancestries;

var minDepth = Infinity;
var lastCommonIndex = void 0,
lastCommon = void 0;
var lastCommonIndex, lastCommon;
var ancestries = paths.map(function (path) {

@@ -123,0 +118,0 @@ var ancestry = [];

@@ -8,6 +8,4 @@ "use strict";

var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -14,0 +12,0 @@

@@ -25,6 +25,4 @@ "use strict";

var _index = require("../index");
var _index = _interopRequireDefault(require("../index"));
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -34,5 +32,3 @@

var opts = this.opts;
this.debug(function () {
return key;
});
this.debug(key);

@@ -102,13 +98,9 @@ if (this.node) {

if (this.call("enter") || this.shouldSkip) {
this.debug(function () {
return "Skip...";
});
this.debug("Skip...");
return this.shouldStop;
}
this.debug(function () {
return "Recursing into...";
});
this.debug("Recursing into...");
_index2.default.node(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
_index.default.node(this.node, this.opts, this.scope, this.state, this, this.skipKeys);

@@ -134,12 +126,9 @@ this.call("exit");

if (this.opts && this.opts.noScope) return;
var target = this.context && this.context.scope;
var path = this.parentPath;
var target;
if (!target) {
var path = this.parentPath;
while (path && !target) {
if (path.opts && path.opts.noScope) return;
target = path.scope;
path = path.parentPath;
}
while (path && !target) {
if (path.opts && path.opts.noScope) return;
target = path.scope;
path = path.parentPath;
}

@@ -146,0 +135,0 @@

@@ -10,10 +10,6 @@ "use strict";

var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
var _babelHelperFunctionName = _interopRequireDefault(require("babel-helper-function-name"));
var _babelHelperFunctionName = require("babel-helper-function-name");
var _babelHelperFunctionName2 = _interopRequireDefault(_babelHelperFunctionName);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -25,3 +21,3 @@

var node = this.node;
var key = void 0;
var key;

@@ -44,3 +40,42 @@ if (this.isMemberExpression()) {

function ensureBlock() {
return t.ensureBlock(this.node);
var body = this.get("body");
var bodyNode = body.node;
if (Array.isArray(body)) {
throw new Error("Can't convert array path to a block statement");
}
if (!bodyNode) {
throw new Error("Can't convert node without a body");
}
if (body.isBlockStatement()) {
return bodyNode;
}
var statements = [];
var stringPath = "body";
var key;
var listKey;
if (body.isStatement()) {
listKey = "body";
key = 0;
statements.push(body.node);
} else {
stringPath += ".body.0";
if (this.isFunction()) {
key = "argument";
statements.push(t.returnStatement(body.node));
} else {
key = "expression";
statements.push(t.expressionStatement(body.node));
}
}
this.node.body = t.blockStatement(statements);
var parentPath = this.get(stringPath);
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
return this.node;
}

@@ -64,5 +99,5 @@

_ref$allowInsertArrow = _ref.allowInsertArrow,
allowInsertArrow = _ref$allowInsertArrow === undefined ? true : _ref$allowInsertArrow,
allowInsertArrow = _ref$allowInsertArrow === void 0 ? true : _ref$allowInsertArrow,
_ref$specCompliant = _ref.specCompliant,
specCompliant = _ref$specCompliant === undefined ? false : _ref$specCompliant;
specCompliant = _ref$specCompliant === void 0 ? false : _ref$specCompliant;

@@ -88,3 +123,3 @@ if (!this.isArrowFunctionExpression()) {

this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.file.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)])));
this.replaceWith(t.callExpression(t.memberExpression((0, _babelHelperFunctionName2.default)(this) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
this.replaceWith(t.callExpression(t.memberExpression((0, _babelHelperFunctionName.default)(this) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
}

@@ -146,3 +181,3 @@ }

var thisBinding = void 0;
var thisBinding;

@@ -304,3 +339,3 @@ if (thisPaths.length > 0 || specCompliant) {

var argsList = [t.restElement(argsBinding)];
var fnBody = void 0;
var fnBody;

@@ -323,3 +358,3 @@ if (propName) {

var argsList = [];
var fnBody = void 0;
var fnBody;

@@ -326,0 +361,0 @@ if (propName) {

"use strict";
exports.__esModule = true;
exports.evaluateTruthy = evaluateTruthy;
exports.evaluate = evaluate;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
exports.evaluateTruthy = evaluateTruthy;
exports.evaluate = evaluate;
var VALID_CALLEES = ["String", "Number", "Math"];

@@ -370,4 +370,4 @@ var INVALID_METHODS = ["random"];

var callee = path.get("callee");
var context = void 0;
var func = void 0;
var context;
var func;

@@ -374,0 +374,0 @@ if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name, true) && VALID_CALLEES.indexOf(callee.node.name) >= 0) {

@@ -19,10 +19,6 @@ "use strict";

var _index = require("./index");
var _index = _interopRequireDefault(require("./index"));
var _index2 = _interopRequireDefault(_index);
var t = _interopRequireWildcard(require("babel-types"));
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -61,2 +57,4 @@

paths = addCompletionRecords(this.get("finalizer"), paths);
} else if (this.isCatchClause()) {
paths = addCompletionRecords(this.get("body"), paths);
} else {

@@ -70,3 +68,3 @@ paths.push(this);

function getSibling(key) {
return _index2.default.get({
return _index.default.get({
parentPath: this.parentPath,

@@ -133,3 +131,3 @@ parent: this.parent,

return container.map(function (_, i) {
return _index2.default.get({
return _index.default.get({
listKey: key,

@@ -143,3 +141,3 @@ parentPath: _this,

} else {
return _index2.default.get({
return _index.default.get({
parentPath: this,

@@ -146,0 +144,0 @@ parent: node,

"use strict";
exports.__esModule = true;
exports.default = undefined;
exports.default = void 0;
var _virtualTypes = require("./lib/virtual-types");
var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types"));
var virtualTypes = _interopRequireWildcard(_virtualTypes);
var _debug2 = _interopRequireDefault(require("debug"));
var _debug2 = require("debug");
var _invariant = _interopRequireDefault(require("invariant"));
var _debug3 = _interopRequireDefault(_debug2);
var _index = _interopRequireDefault(require("../index"));
var _invariant = require("invariant");
var _scope = _interopRequireDefault(require("../scope"));
var _invariant2 = _interopRequireDefault(_invariant);
var t = _interopRequireWildcard(require("babel-types"));
var _index = require("../index");
var _index2 = _interopRequireDefault(_index);
var _scope = require("../scope");
var _scope2 = _interopRequireDefault(_scope);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _cache = require("../cache");
var _ancestry = require("./ancestry");
var NodePath_ancestry = _interopRequireWildcard(require("./ancestry"));
var NodePath_ancestry = _interopRequireWildcard(_ancestry);
var NodePath_inference = _interopRequireWildcard(require("./inference"));
var _inference = require("./inference");
var NodePath_replacement = _interopRequireWildcard(require("./replacement"));
var NodePath_inference = _interopRequireWildcard(_inference);
var NodePath_evaluation = _interopRequireWildcard(require("./evaluation"));
var _replacement = require("./replacement");
var NodePath_conversion = _interopRequireWildcard(require("./conversion"));
var NodePath_replacement = _interopRequireWildcard(_replacement);
var NodePath_introspection = _interopRequireWildcard(require("./introspection"));
var _evaluation = require("./evaluation");
var NodePath_context = _interopRequireWildcard(require("./context"));
var NodePath_evaluation = _interopRequireWildcard(_evaluation);
var NodePath_removal = _interopRequireWildcard(require("./removal"));
var _conversion = require("./conversion");
var NodePath_modification = _interopRequireWildcard(require("./modification"));
var NodePath_conversion = _interopRequireWildcard(_conversion);
var NodePath_family = _interopRequireWildcard(require("./family"));
var _introspection = require("./introspection");
var NodePath_comments = _interopRequireWildcard(require("./comments"));
var NodePath_introspection = _interopRequireWildcard(_introspection);
var _context = require("./context");
var NodePath_context = _interopRequireWildcard(_context);
var _removal = require("./removal");
var NodePath_removal = _interopRequireWildcard(_removal);
var _modification = require("./modification");
var NodePath_modification = _interopRequireWildcard(_modification);
var _family = require("./family");
var NodePath_family = _interopRequireWildcard(_family);
var _comments = require("./comments");
var NodePath_comments = _interopRequireWildcard(_comments);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -80,3 +46,3 @@

var _debug = (0, _debug3.default)("babel");
var _debug = (0, _debug2.default)("babel");

@@ -120,3 +86,3 @@ var NodePath = function () {

(0, _invariant2.default)(parent, "To get a node path the parent needs to exist");
(0, _invariant.default)(parent, "To get a node path the parent needs to exist");
var targetNode = container[key];

@@ -129,3 +95,3 @@ var paths = _cache.path.get(parent) || [];

var path = void 0;
var path;

@@ -150,11 +116,13 @@ for (var i = 0; i < paths.length; i++) {

NodePath.prototype.getScope = function getScope(scope) {
return this.isScope() ? new _scope2.default(this) : scope;
var _proto = NodePath.prototype;
_proto.getScope = function getScope(scope) {
return this.isScope() ? new _scope.default(this) : scope;
};
NodePath.prototype.setData = function setData(key, val) {
_proto.setData = function setData(key, val) {
return this.data[key] = val;
};
NodePath.prototype.getData = function getData(key, def) {
_proto.getData = function getData(key, def) {
var val = this.data[key];

@@ -165,3 +133,3 @@ if (!val && def) val = this.data[key] = def;

NodePath.prototype.buildCodeFrameError = function buildCodeFrameError(msg, Error) {
_proto.buildCodeFrameError = function buildCodeFrameError(msg, Error) {
if (Error === void 0) {

@@ -174,15 +142,7 @@ Error = SyntaxError;

NodePath.prototype.traverse = function traverse(visitor, state) {
(0, _index2.default)(this.node, visitor, this.scope, state, this);
_proto.traverse = function traverse(visitor, state) {
(0, _index.default)(this.node, visitor, this.scope, state, this);
};
NodePath.prototype.mark = function mark(type, message) {
this.hub.file.metadata.marked.push({
type: type,
message: message,
loc: this.node.loc
});
};
NodePath.prototype.set = function set(key, node) {
_proto.set = function set(key, node) {
t.validate(this.node, key, node);

@@ -192,3 +152,3 @@ this.node[key] = node;

NodePath.prototype.getPathLocation = function getPathLocation() {
_proto.getPathLocation = function getPathLocation() {
var parts = [];

@@ -206,6 +166,6 @@ var path = this;

NodePath.prototype.debug = function debug(buildMessage) {
_proto.debug = function debug(message) {
if (!_debug.enabled) return;
_debug(this.getPathLocation() + " " + this.type + ": " + buildMessage());
_debug(this.getPathLocation() + " " + this.type + ": " + message);
};

@@ -212,0 +172,0 @@

@@ -11,10 +11,6 @@ "use strict";

var _inferers = require("./inferers");
var inferers = _interopRequireWildcard(require("./inferers"));
var inferers = _interopRequireWildcard(_inferers);
var t = _interopRequireWildcard(require("babel-types"));
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -21,0 +17,0 @@

"use strict";
exports.__esModule = true;
exports.default = _default;
exports.default = function (node) {
var t = _interopRequireWildcard(require("babel-types"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _default(node) {
if (!this.isReferenced()) return;

@@ -22,10 +27,4 @@ var binding = this.scope.getBinding(node.name);

} else if (node.name === "arguments") {}
};
}
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function getTypeAnnotationBindingConstantViolations(binding, path, name) {

@@ -77,3 +76,3 @@ var types = [];

var left = path.get("left").resolve();
var target = void 0;
var target;

@@ -103,4 +102,4 @@ if (left.isIdentifier({

if (operator !== "===" && operator !== "==") return;
var typeofPath = void 0;
var typePath = void 0;
var typeofPath;
var typePath;

@@ -131,3 +130,3 @@ if (left.isUnaryExpression({

function getParentConditionalPath(binding, path, name) {
var parentPath = void 0;
var parentPath;

@@ -134,0 +133,0 @@ while (parentPath = path.parentPath) {

"use strict";
exports.__esModule = true;
exports.ClassDeclaration = exports.ClassExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = exports.FunctionExpression = exports.Identifier = undefined;
var _infererReference = require("./inferer-reference");
Object.defineProperty(exports, "Identifier", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_infererReference).default;
}
});
exports.VariableDeclarator = VariableDeclarator;

@@ -33,13 +23,20 @@ exports.TypeCastExpression = TypeCastExpression;

exports.RestElement = RestElement;
exports.ClassDeclaration = exports.ClassExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = exports.FunctionExpression = Func;
exports.CallExpression = CallExpression;
exports.TaggedTemplateExpression = TaggedTemplateExpression;
Object.defineProperty(exports, "Identifier", {
enumerable: true,
get: function get() {
return _infererReference.default;
}
});
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
var _infererReference = _interopRequireDefault(require("./inferer-reference"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function VariableDeclarator() {

@@ -175,7 +172,2 @@ var id = this.get("id");

exports.FunctionExpression = Func;
exports.ArrowFunctionExpression = Func;
exports.FunctionDeclaration = Func;
exports.ClassExpression = Func;
exports.ClassDeclaration = Func;
var isArrayFrom = t.buildMatchMemberExpression("Array.from");

@@ -182,0 +174,0 @@ var isObjectKeys = t.buildMatchMemberExpression("Object.keys");

"use strict";
exports.__esModule = true;
exports.is = undefined;
exports.matchesPattern = matchesPattern;

@@ -22,11 +21,8 @@ exports.has = has;

exports._resolve = _resolve;
exports.is = void 0;
var _includes = require("lodash/includes");
var _includes = _interopRequireDefault(require("lodash/includes"));
var _includes2 = _interopRequireDefault(_includes);
var t = _interopRequireWildcard(require("babel-types"));
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -54,3 +50,4 @@

var is = exports.is = has;
var is = has;
exports.is = is;

@@ -112,3 +109,3 @@ function isnt(key) {

} else {
return (0, _includes2.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key);
return (0, _includes.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key);
}

@@ -177,5 +174,5 @@ }

var selfPaths = this.getAncestry();
var commonPath = void 0;
var targetIndex = void 0;
var selfIndex = void 0;
var commonPath;
var targetIndex;
var selfIndex;

@@ -239,3 +236,3 @@ for (selfIndex = 0; selfIndex < selfPaths.length; selfIndex++) {

var allStatus = void 0;
var allStatus;

@@ -242,0 +239,0 @@ for (var _iterator2 = referencePaths, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {

"use strict";
exports.__esModule = true;
exports.default = undefined;
exports.default = void 0;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -14,3 +12,3 @@

ReferencedIdentifier: function ReferencedIdentifier(path, state) {
if (path.isJSXIdentifier() && _babelTypes.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
return;

@@ -48,3 +46,5 @@ }

PathHoister.prototype.isCompatibleScope = function isCompatibleScope(scope) {
var _proto = PathHoister.prototype;
_proto.isCompatibleScope = function isCompatibleScope(scope) {
for (var key in this.bindings) {

@@ -61,3 +61,3 @@ var binding = this.bindings[key];

PathHoister.prototype.getCompatibleScopes = function getCompatibleScopes() {
_proto.getCompatibleScopes = function getCompatibleScopes() {
var scope = this.path.scope;

@@ -78,3 +78,3 @@

PathHoister.prototype.getAttachmentPath = function getAttachmentPath() {
_proto.getAttachmentPath = function getAttachmentPath() {
var path = this._getAttachmentPath();

@@ -123,3 +123,3 @@

PathHoister.prototype._getAttachmentPath = function _getAttachmentPath() {
_proto._getAttachmentPath = function _getAttachmentPath() {
var scopes = this.scopes;

@@ -146,3 +146,3 @@ var scope = scopes.pop();

PathHoister.prototype.getNextScopeAttachmentParent = function getNextScopeAttachmentParent() {
_proto.getNextScopeAttachmentParent = function getNextScopeAttachmentParent() {
var scope = this.scopes.pop();

@@ -152,3 +152,3 @@ if (scope) return this.getAttachmentParentForPath(scope.path);

PathHoister.prototype.getAttachmentParentForPath = function getAttachmentParentForPath(path) {
_proto.getAttachmentParentForPath = function getAttachmentParentForPath(path) {
do {

@@ -161,3 +161,3 @@ if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {

PathHoister.prototype.hasOwnParamBindings = function hasOwnParamBindings(scope) {
_proto.hasOwnParamBindings = function hasOwnParamBindings(scope) {
for (var name in this.bindings) {

@@ -172,3 +172,3 @@ if (!scope.hasOwnBinding(name)) continue;

PathHoister.prototype.run = function run() {
_proto.run = function run() {
this.path.traverse(referenceVisitor, this);

@@ -175,0 +175,0 @@ this.getCompatibleScopes();

"use strict";
exports.__esModule = true;
var hooks = exports.hooks = [function (self, parent) {
exports.hooks = void 0;
var hooks = [function (self, parent) {
var removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();

@@ -34,2 +35,3 @@

}
}];
}];
exports.hooks = hooks;
"use strict";
exports.__esModule = true;
exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = undefined;
exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var ReferencedIdentifier = exports.ReferencedIdentifier = {
var ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"],

@@ -20,3 +18,3 @@ checkPath: function checkPath(_ref, opts) {

if (t.isJSXIdentifier(node, opts)) {
if (_babelTypes.react.isCompatTag(node.name)) return false;
if (t.react.isCompatTag(node.name)) return false;
} else {

@@ -30,3 +28,4 @@ return false;

};
var ReferencedMemberExpression = exports.ReferencedMemberExpression = {
exports.ReferencedIdentifier = ReferencedIdentifier;
var ReferencedMemberExpression = {
types: ["MemberExpression"],

@@ -39,3 +38,4 @@ checkPath: function checkPath(_ref2) {

};
var BindingIdentifier = exports.BindingIdentifier = {
exports.ReferencedMemberExpression = ReferencedMemberExpression;
var BindingIdentifier = {
types: ["Identifier"],

@@ -48,3 +48,4 @@ checkPath: function checkPath(_ref3) {

};
var Statement = exports.Statement = {
exports.BindingIdentifier = BindingIdentifier;
var Statement = {
types: ["Statement"],

@@ -71,3 +72,4 @@ checkPath: function checkPath(_ref4) {

};
var Expression = exports.Expression = {
exports.Statement = Statement;
var Expression = {
types: ["Expression"],

@@ -82,3 +84,4 @@ checkPath: function checkPath(path) {

};
var Scope = exports.Scope = {
exports.Expression = Expression;
var Scope = {
types: ["Scopable"],

@@ -89,3 +92,4 @@ checkPath: function checkPath(path) {

};
var Referenced = exports.Referenced = {
exports.Scope = Scope;
var Referenced = {
checkPath: function checkPath(path) {

@@ -95,3 +99,4 @@ return t.isReferenced(path.node, path.parent);

};
var BlockScoped = exports.BlockScoped = {
exports.Referenced = Referenced;
var BlockScoped = {
checkPath: function checkPath(path) {

@@ -101,3 +106,4 @@ return t.isBlockScoped(path.node);

};
var Var = exports.Var = {
exports.BlockScoped = BlockScoped;
var Var = {
types: ["VariableDeclaration"],

@@ -108,3 +114,4 @@ checkPath: function checkPath(path) {

};
var User = exports.User = {
exports.Var = Var;
var User = {
checkPath: function checkPath(path) {

@@ -114,3 +121,4 @@ return path.node && !!path.node.loc;

};
var Generated = exports.Generated = {
exports.User = User;
var Generated = {
checkPath: function checkPath(path) {

@@ -120,3 +128,4 @@ return !path.isUser();

};
var Pure = exports.Pure = {
exports.Generated = Generated;
var Pure = {
checkPath: function checkPath(path, opts) {

@@ -126,3 +135,4 @@ return path.scope.isPure(path.node, opts);

};
var Flow = exports.Flow = {
exports.Pure = Pure;
var Flow = {
types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],

@@ -145,3 +155,4 @@ checkPath: function checkPath(_ref5) {

};
var RestProperty = exports.RestProperty = {
exports.Flow = Flow;
var RestProperty = {
types: ["RestElement"],

@@ -152,3 +163,4 @@ checkPath: function checkPath(path) {

};
var SpreadProperty = exports.SpreadProperty = {
exports.RestProperty = RestProperty;
var SpreadProperty = {
types: ["RestElement"],

@@ -159,9 +171,12 @@ checkPath: function checkPath(path) {

};
var ExistentialTypeParam = exports.ExistentialTypeParam = {
exports.SpreadProperty = SpreadProperty;
var ExistentialTypeParam = {
types: ["ExistsTypeAnnotation"]
};
var NumericLiteralTypeAnnotation = exports.NumericLiteralTypeAnnotation = {
exports.ExistentialTypeParam = ExistentialTypeParam;
var NumericLiteralTypeAnnotation = {
types: ["NumberLiteralTypeAnnotation"]
};
var ForAwaitStatement = exports.ForAwaitStatement = {
exports.NumericLiteralTypeAnnotation = NumericLiteralTypeAnnotation;
var ForAwaitStatement = {
types: ["ForOfStatement"],

@@ -172,2 +187,3 @@ checkPath: function checkPath(_ref6) {

}
};
};
exports.ForAwaitStatement = ForAwaitStatement;
"use strict";
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.insertBefore = insertBefore;

@@ -20,14 +17,8 @@ exports._containerInsert = _containerInsert;

var _hoister = require("./lib/hoister");
var _hoister = _interopRequireDefault(require("./lib/hoister"));
var _hoister2 = _interopRequireDefault(_hoister);
var _index = _interopRequireDefault(require("./index"));
var _index = require("./index");
var t = _interopRequireWildcard(require("babel-types"));
var _index2 = _interopRequireDefault(_index);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -37,2 +28,4 @@

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function insertBefore(nodes) {

@@ -45,3 +38,3 @@ this._assertUnremoved();

return this.parentPath.insertBefore(nodes);
} else if (this.isNodeType("Expression") && this.listKey !== "params" || this.parentPath.isForStatement() && this.key === "init") {
} else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || this.parentPath.isForStatement() && this.key === "init") {
if (this.node) nodes.push(this.node);

@@ -85,5 +78,3 @@ return this.replaceExpressionWithStatements(nodes);

_path.debug(function () {
return "Inserted.";
});
_path.debug("Inserted.");

@@ -178,3 +169,3 @@ for (var _iterator = contexts, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

msg = "without a type";
} else if (node instanceof _index2.default) {
} else if (node instanceof _index.default) {
msg = "has a NodePath when it expected a raw object";

@@ -197,3 +188,3 @@ }

var path = _index2.default.get({
var path = _index.default.get({
parentPath: this,

@@ -215,3 +206,3 @@ parent: this.node,

var path = _index2.default.get({
var path = _index.default.get({
parentPath: this,

@@ -232,4 +223,4 @@ parent: this.node,

var hoister = new _hoister2.default(this, scope);
var hoister = new _hoister.default(this, scope);
return hoister.run();
}

@@ -13,16 +13,10 @@ "use strict";

var _index = require("../index");
var _index = _interopRequireDefault(require("../index"));
var _index2 = _interopRequireDefault(_index);
var _index2 = _interopRequireDefault(require("./index"));
var _index3 = require("./index");
var _index4 = _interopRequireDefault(_index3);
var _babylon = require("babylon");
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(require("babel-types"));
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -88,3 +82,4 @@

if (loc) {
var location = {
err.loc = null;
err.message += " - make sure this is an expression.\n" + (0, _babelCodeFrame.codeFrameColumns)(replacement, {
start: {

@@ -94,5 +89,3 @@ line: loc.line,

}
};
err.message += " - make sure this is an expression.";
err.message += "\n" + (0, _babelCodeFrame.codeFrameColumns)(replacement, location);
});
}

@@ -105,3 +98,3 @@

_index2.default.removeProperties(replacement);
_index.default.removeProperties(replacement);

@@ -118,3 +111,3 @@ return this.replaceWith(replacement);

if (replacement instanceof _index4.default) {
if (replacement instanceof _index2.default) {
replacement = replacement.node;

@@ -184,5 +177,3 @@ }

this.debug(function () {
return "Replace with " + (node && node.type);
});
this.debug("Replace with " + (node && node.type));
this.node = this.container[this.key] = node;

@@ -189,0 +180,0 @@ }

"use strict";
exports.__esModule = true;
exports.default = void 0;

@@ -23,3 +24,5 @@ var Binding = function () {

Binding.prototype.deoptValue = function deoptValue() {
var _proto = Binding.prototype;
_proto.deoptValue = function deoptValue() {
this.clearValue();

@@ -29,3 +32,3 @@ this.hasDeoptedValue = true;

Binding.prototype.setValue = function setValue(value) {
_proto.setValue = function setValue(value) {
if (this.hasDeoptedValue) return;

@@ -36,3 +39,3 @@ this.hasValue = true;

Binding.prototype.clearValue = function clearValue() {
_proto.clearValue = function clearValue() {
this.hasDeoptedValue = false;

@@ -43,3 +46,3 @@ this.hasValue = false;

Binding.prototype.reassign = function reassign(path) {
_proto.reassign = function reassign(path) {
this.constant = false;

@@ -54,3 +57,3 @@

Binding.prototype.reference = function reference(path) {
_proto.reference = function reference(path) {
if (this.referencePaths.indexOf(path) !== -1) {

@@ -65,3 +68,3 @@ return;

Binding.prototype.dereference = function dereference() {
_proto.dereference = function dereference() {
this.references--;

@@ -68,0 +71,0 @@ this.referenced = !!this.references;

"use strict";
exports.__esModule = true;
exports.default = undefined;
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _includes = _interopRequireDefault(require("lodash/includes"));
var _class, _temp;
var _repeat = _interopRequireDefault(require("lodash/repeat"));
var _includes = require("lodash/includes");
var _renamer = _interopRequireDefault(require("./lib/renamer"));
var _includes2 = _interopRequireDefault(_includes);
var _index = _interopRequireDefault(require("../index"));
var _repeat = require("lodash/repeat");
var _defaults = _interopRequireDefault(require("lodash/defaults"));
var _repeat2 = _interopRequireDefault(_repeat);
var _binding2 = _interopRequireDefault(require("./binding"));
var _renamer = require("./lib/renamer");
var _globals = _interopRequireDefault(require("globals"));
var _renamer2 = _interopRequireDefault(_renamer);
var t = _interopRequireWildcard(require("babel-types"));
var _index = require("../index");
var _cache = require("../cache");
var _index2 = _interopRequireDefault(_index);
var _class, _temp;
var _defaults = require("lodash/defaults");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var _defaults2 = _interopRequireDefault(_defaults);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _babelMessages = require("babel-messages");
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
var messages = _interopRequireWildcard(_babelMessages);
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _binding2 = require("./binding");
var _binding3 = _interopRequireDefault(_binding2);
var _globals = require("globals");
var _globals2 = _interopRequireDefault(_globals);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _cache = require("../cache");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _crawlCallsCount = 0;

@@ -208,7 +190,9 @@

Scope.prototype.traverse = function traverse(node, opts, state) {
(0, _index2.default)(node, opts, this, state, this.path);
var _proto = Scope.prototype;
_proto.traverse = function traverse(node, opts, state) {
(0, _index.default)(node, opts, this, state, this.path);
};
Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier(name) {
_proto.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier(name) {
if (name === void 0) {

@@ -225,3 +209,3 @@ name = "temp";

Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
_proto.generateUidIdentifier = function generateUidIdentifier(name) {
if (name === void 0) {

@@ -234,3 +218,3 @@ name = "temp";

Scope.prototype.generateUid = function generateUid(name) {
_proto.generateUid = function generateUid(name) {
if (name === void 0) {

@@ -241,3 +225,3 @@ name = "temp";

name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
var uid = void 0;
var uid;
var i = 0;

@@ -256,3 +240,3 @@

Scope.prototype._generateUid = function _generateUid(name, i) {
_proto._generateUid = function _generateUid(name, i) {
var id = name;

@@ -263,3 +247,3 @@ if (i > 1) id += i;

Scope.prototype.generateUidIdentifierBasedOnNode = function generateUidIdentifierBasedOnNode(parent, defaultName) {
_proto.generateUidIdentifierBasedOnNode = function generateUidIdentifierBasedOnNode(parent, defaultName) {
var node = parent;

@@ -282,3 +266,3 @@

Scope.prototype.isStatic = function isStatic(node) {
_proto.isStatic = function isStatic(node) {
if (t.isThisExpression(node) || t.isSuper(node)) {

@@ -301,3 +285,3 @@ return true;

Scope.prototype.maybeGenerateMemoised = function maybeGenerateMemoised(node, dontPush) {
_proto.maybeGenerateMemoised = function maybeGenerateMemoised(node, dontPush) {
if (this.isStatic(node)) {

@@ -315,3 +299,3 @@ return null;

Scope.prototype.checkBlockScopedCollisions = function checkBlockScopedCollisions(local, kind, name, id) {
_proto.checkBlockScopedCollisions = function checkBlockScopedCollisions(local, kind, name, id) {
if (kind === "param") return;

@@ -323,7 +307,7 @@ if (local.kind === "local") return;

if (duplicate) {
throw this.hub.file.buildCodeFrameError(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
throw this.hub.file.buildCodeFrameError(id, "Duplicate declaration \"" + name + "\"", TypeError);
}
};
Scope.prototype.rename = function rename(oldName, newName, block) {
_proto.rename = function rename(oldName, newName, block) {
var binding = this.getBinding(oldName);

@@ -333,7 +317,7 @@

newName = newName || this.generateUidIdentifier(oldName).name;
return new _renamer2.default(binding, oldName, newName).rename(block);
return new _renamer.default(binding, oldName, newName).rename(block);
}
};
Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
_proto._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
if (map[oldName]) {

@@ -345,4 +329,4 @@ map[newName] = value;

Scope.prototype.dump = function dump() {
var sep = (0, _repeat2.default)("-", 60);
_proto.dump = function dump() {
var sep = (0, _repeat.default)("-", 60);
console.log(sep);

@@ -354,5 +338,5 @@ var scope = this;

for (var _name in scope.bindings) {
var binding = scope.bindings[_name];
console.log(" -", _name, {
for (var name in scope.bindings) {
var binding = scope.bindings[name];
console.log(" -", name, {
constant: binding.constant,

@@ -369,3 +353,3 @@ references: binding.references,

Scope.prototype.toArray = function toArray(node, i) {
_proto.toArray = function toArray(node, i) {
var file = this.hub.file;

@@ -404,15 +388,15 @@

Scope.prototype.hasLabel = function hasLabel(name) {
_proto.hasLabel = function hasLabel(name) {
return !!this.getLabel(name);
};
Scope.prototype.getLabel = function getLabel(name) {
_proto.getLabel = function getLabel(name) {
return this.labels.get(name);
};
Scope.prototype.registerLabel = function registerLabel(path) {
_proto.registerLabel = function registerLabel(path) {
this.labels.set(path.node.label.name, path);
};
Scope.prototype.registerDeclaration = function registerDeclaration(path) {
_proto.registerDeclaration = function registerDeclaration(path) {
if (path.isLabeledStatement()) {

@@ -451,3 +435,3 @@ this.registerLabel(path);

Scope.prototype.buildUndefinedNode = function buildUndefinedNode() {
_proto.buildUndefinedNode = function buildUndefinedNode() {
if (this.hasBinding("undefined")) {

@@ -460,7 +444,7 @@ return t.unaryExpression("void", t.numericLiteral(0), true);

Scope.prototype.registerConstantViolation = function registerConstantViolation(path) {
_proto.registerConstantViolation = function registerConstantViolation(path) {
var ids = path.getBindingIdentifiers();
for (var _name2 in ids) {
var binding = this.getBinding(_name2);
for (var name in ids) {
var binding = this.getBinding(name);
if (binding) binding.reassign(path);

@@ -470,3 +454,3 @@ }

Scope.prototype.registerBinding = function registerBinding(kind, path, bindingPath) {
_proto.registerBinding = function registerBinding(kind, path, bindingPath) {
if (bindingPath === void 0) {

@@ -503,16 +487,16 @@ bindingPath = path;

for (var _name3 in ids) {
var _arr8 = ids[_name3];
for (var name in ids) {
var _arr8 = ids[name];
for (var _i9 = 0; _i9 < _arr8.length; _i9++) {
var _id3 = _arr8[_i9];
var local = this.getOwnBinding(_name3);
var local = this.getOwnBinding(name);
if (local) {
if (local.identifier === _id3) continue;
this.checkBlockScopedCollisions(local, kind, _name3, _id3);
this.checkBlockScopedCollisions(local, kind, name, _id3);
}
if (local && local.path.isFlow()) local = null;
parent.references[_name3] = true;
parent.references[name] = true;

@@ -522,3 +506,3 @@ if (local) {

} else {
this.bindings[_name3] = new _binding3.default({
this.bindings[name] = new _binding2.default({
identifier: _id3,

@@ -534,7 +518,7 @@ scope: this,

Scope.prototype.addGlobal = function addGlobal(node) {
_proto.addGlobal = function addGlobal(node) {
this.globals[node.name] = node;
};
Scope.prototype.hasUid = function hasUid(name) {
_proto.hasUid = function hasUid(name) {
var scope = this;

@@ -549,3 +533,3 @@

Scope.prototype.hasGlobal = function hasGlobal(name) {
_proto.hasGlobal = function hasGlobal(name) {
var scope = this;

@@ -560,3 +544,3 @@

Scope.prototype.hasReference = function hasReference(name) {
_proto.hasReference = function hasReference(name) {
var scope = this;

@@ -571,3 +555,3 @@

Scope.prototype.isPure = function isPure(node, constantsOnly) {
_proto.isPure = function isPure(node, constantsOnly) {
if (t.isIdentifier(node)) {

@@ -647,7 +631,7 @@ var binding = this.getBinding(node.name);

Scope.prototype.setData = function setData(key, val) {
_proto.setData = function setData(key, val) {
return this.data[key] = val;
};
Scope.prototype.getData = function getData(key) {
_proto.getData = function getData(key) {
var scope = this;

@@ -661,3 +645,3 @@

Scope.prototype.removeData = function removeData(key) {
_proto.removeData = function removeData(key) {
var scope = this;

@@ -671,7 +655,7 @@

Scope.prototype.init = function init() {
_proto.init = function init() {
if (!this.references) this.crawl();
};
Scope.prototype.crawl = function crawl() {
_proto.crawl = function crawl() {
_crawlCallsCount++;

@@ -684,3 +668,3 @@

Scope.prototype._crawl = function _crawl() {
_proto._crawl = function _crawl() {
var path = this.path;

@@ -768,6 +752,6 @@ this.references = Object.create(null);

for (var _name4 in ids) {
if (_path3.scope.getBinding(_name4)) continue;
for (var name in ids) {
if (_path3.scope.getBinding(name)) continue;
programParent = programParent || _path3.scope.getProgramParent();
programParent.addGlobal(ids[_name4]);
programParent.addGlobal(ids[name]);
}

@@ -819,3 +803,3 @@

Scope.prototype.push = function push(opts) {
_proto.push = function push(opts) {
var path = this.path;

@@ -832,3 +816,3 @@

if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
t.ensureBlock(path.node);
path.ensureBlock();
path = path.get("body");

@@ -858,3 +842,3 @@ }

Scope.prototype.getProgramParent = function getProgramParent() {
_proto.getProgramParent = function getProgramParent() {
var scope = this;

@@ -871,3 +855,3 @@

Scope.prototype.getFunctionParent = function getFunctionParent() {
_proto.getFunctionParent = function getFunctionParent() {
var scope = this;

@@ -884,3 +868,3 @@

Scope.prototype.getBlockParent = function getBlockParent() {
_proto.getBlockParent = function getBlockParent() {
var scope = this;

@@ -897,3 +881,3 @@

Scope.prototype.getAllBindings = function getAllBindings() {
_proto.getAllBindings = function getAllBindings() {
var ids = Object.create(null);

@@ -903,3 +887,3 @@ var scope = this;

do {
(0, _defaults2.default)(ids, scope.bindings);
(0, _defaults.default)(ids, scope.bindings);
scope = scope.parent;

@@ -911,3 +895,3 @@ } while (scope);

Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind() {
_proto.getAllBindingsOfKind = function getAllBindingsOfKind() {
var ids = Object.create(null);

@@ -921,5 +905,5 @@ var _arr13 = arguments;

do {
for (var _name5 in scope.bindings) {
var binding = scope.bindings[_name5];
if (binding.kind === kind) ids[_name5] = binding;
for (var name in scope.bindings) {
var binding = scope.bindings[name];
if (binding.kind === kind) ids[name] = binding;
}

@@ -934,7 +918,7 @@

Scope.prototype.bindingIdentifierEquals = function bindingIdentifierEquals(name, node) {
_proto.bindingIdentifierEquals = function bindingIdentifierEquals(name, node) {
return this.getBindingIdentifier(name) === node;
};
Scope.prototype.warnOnFlowBinding = function warnOnFlowBinding(binding) {
_proto.warnOnFlowBinding = function warnOnFlowBinding(binding) {
if (_crawlCallsCount === 0 && binding && binding.path.isFlow()) {

@@ -947,3 +931,3 @@ console.warn("\n You or one of the Babel plugins you are using are using Flow declarations as bindings.\n Support for this will be removed in version 7. To find out the caller, grep for this\n message and change it to a `console.trace()`.\n ");

Scope.prototype.getBinding = function getBinding(name) {
_proto.getBinding = function getBinding(name) {
var scope = this;

@@ -957,7 +941,7 @@

Scope.prototype.getOwnBinding = function getOwnBinding(name) {
_proto.getOwnBinding = function getOwnBinding(name) {
return this.warnOnFlowBinding(this.bindings[name]);
};
Scope.prototype.getBindingIdentifier = function getBindingIdentifier(name) {
_proto.getBindingIdentifier = function getBindingIdentifier(name) {
var info = this.getBinding(name);

@@ -967,3 +951,3 @@ return info && info.identifier;

Scope.prototype.getOwnBindingIdentifier = function getOwnBindingIdentifier(name) {
_proto.getOwnBindingIdentifier = function getOwnBindingIdentifier(name) {
var binding = this.bindings[name];

@@ -973,7 +957,7 @@ return binding && binding.identifier;

Scope.prototype.hasOwnBinding = function hasOwnBinding(name) {
_proto.hasOwnBinding = function hasOwnBinding(name) {
return !!this.getOwnBinding(name);
};
Scope.prototype.hasBinding = function hasBinding(name, noGlobals) {
_proto.hasBinding = function hasBinding(name, noGlobals) {
if (!name) return false;

@@ -983,12 +967,12 @@ if (this.hasOwnBinding(name)) return true;

if (this.hasUid(name)) return true;
if (!noGlobals && (0, _includes2.default)(Scope.globals, name)) return true;
if (!noGlobals && (0, _includes2.default)(Scope.contextVariables, name)) return true;
if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true;
if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true;
return false;
};
Scope.prototype.parentHasBinding = function parentHasBinding(name, noGlobals) {
_proto.parentHasBinding = function parentHasBinding(name, noGlobals) {
return this.parent && this.parent.hasBinding(name, noGlobals);
};
Scope.prototype.moveBindingTo = function moveBindingTo(name, scope) {
_proto.moveBindingTo = function moveBindingTo(name, scope) {
var info = this.getBinding(name);

@@ -1003,7 +987,7 @@

Scope.prototype.removeOwnBinding = function removeOwnBinding(name) {
_proto.removeOwnBinding = function removeOwnBinding(name) {
delete this.bindings[name];
};
Scope.prototype.removeBinding = function removeBinding(name) {
_proto.removeBinding = function removeBinding(name) {
var info = this.getBinding(name);

@@ -1045,3 +1029,13 @@

return Scope;
}(), _class.globals = Object.keys(_globals2.default.builtin), _class.contextVariables = ["arguments", "undefined", "Infinity", "NaN"], _temp);
}(), Object.defineProperty(_class, "globals", {
configurable: true,
enumerable: true,
writable: true,
value: Object.keys(_globals.default.builtin)
}), Object.defineProperty(_class, "contextVariables", {
configurable: true,
enumerable: true,
writable: true,
value: ["arguments", "undefined", "Infinity", "NaN"]
}), _temp);
exports.default = Scope;
"use strict";
exports.__esModule = true;
exports.default = undefined;
exports.default = void 0;
var _binding = require("../binding");
var _binding = _interopRequireDefault(require("../binding"));
var _binding2 = _interopRequireDefault(_binding);
var t = _interopRequireWildcard(require("babel-types"));
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -47,3 +43,5 @@

Renamer.prototype.maybeConvertFromExportDeclaration = function maybeConvertFromExportDeclaration(parentDeclar) {
var _proto = Renamer.prototype;
_proto.maybeConvertFromExportDeclaration = function maybeConvertFromExportDeclaration(parentDeclar) {
var exportDeclar = parentDeclar.parentPath.isExportDeclaration() && parentDeclar.parentPath;

@@ -78,3 +76,3 @@ if (!exportDeclar) return;

Renamer.prototype.maybeConvertFromClassFunctionDeclaration = function maybeConvertFromClassFunctionDeclaration(path) {
_proto.maybeConvertFromClassFunctionDeclaration = function maybeConvertFromClassFunctionDeclaration(path) {
return;

@@ -88,3 +86,3 @@ if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;

Renamer.prototype.maybeConvertFromClassFunctionExpression = function maybeConvertFromClassFunctionExpression(path) {
_proto.maybeConvertFromClassFunctionExpression = function maybeConvertFromClassFunctionExpression(path) {
return;

@@ -100,3 +98,3 @@ if (!path.isFunctionExpression() && !path.isClassExpression()) return;

Renamer.prototype.rename = function rename(block) {
_proto.rename = function rename(block) {
var binding = this.binding,

@@ -103,0 +101,0 @@ oldName = this.oldName,

"use strict";
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.explode = explode;

@@ -11,18 +8,8 @@ exports.verify = verify;

var _virtualTypes = require("./path/lib/virtual-types");
var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
var virtualTypes = _interopRequireWildcard(_virtualTypes);
var t = _interopRequireWildcard(require("babel-types"));
var _babelMessages = require("babel-messages");
var _clone = _interopRequireDefault(require("lodash/clone"));
var messages = _interopRequireWildcard(_babelMessages);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _clone = require("lodash/clone");
var _clone2 = _interopRequireDefault(_clone);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -32,2 +19,4 @@

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function explode(visitor) {

@@ -130,3 +119,3 @@ if (visitor._exploded) return visitor;

} else {
visitor[_alias] = (0, _clone2.default)(_fns2);
visitor[_alias] = (0, _clone.default)(_fns2);
}

@@ -148,3 +137,3 @@ }

if (typeof visitor === "function") {
throw new Error(messages.get("traverseVerifyRootFunction"));
throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?");
}

@@ -160,3 +149,3 @@

if (t.TYPES.indexOf(nodeType) < 0) {
throw new Error(messages.get("traverseVerifyNodeType", nodeType));
throw new Error("You gave us a visitor for the node type " + nodeType + " but it's not a valid type");
}

@@ -171,3 +160,3 @@

} else {
throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
throw new Error("You passed `traverse()` a visitor object with the property " + (nodeType + " that has the invalid property " + visitorKey));
}

@@ -174,0 +163,0 @@ }

{
"name": "babel-traverse",
"version": "7.0.0-beta.2",
"version": "7.0.0-beta.3",
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",

@@ -11,7 +11,6 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"dependencies": {
"babel-code-frame": "7.0.0-beta.2",
"babel-helper-function-name": "7.0.0-beta.2",
"babel-messages": "7.0.0-beta.2",
"babel-types": "7.0.0-beta.2",
"babylon": "7.0.0-beta.25",
"babel-code-frame": "7.0.0-beta.3",
"babel-helper-function-name": "7.0.0-beta.3",
"babel-types": "7.0.0-beta.3",
"babylon": "7.0.0-beta.27",
"debug": "^3.0.1",

@@ -23,5 +22,5 @@ "globals": "^10.0.0",

"devDependencies": {
"babel-generator": "7.0.0-beta.2",
"babel-helper-plugin-test-runner": "7.0.0-beta.2"
"babel-generator": "7.0.0-beta.3",
"babel-helper-plugin-test-runner": "7.0.0-beta.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc