aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/traverse/lib
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/@babel/traverse/lib
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/@babel/traverse/lib')
-rw-r--r--node_modules/@babel/traverse/lib/cache.js26
-rw-r--r--node_modules/@babel/traverse/lib/context.js188
-rw-r--r--node_modules/@babel/traverse/lib/hub.js15
-rw-r--r--node_modules/@babel/traverse/lib/index.js142
-rw-r--r--node_modules/@babel/traverse/lib/path/ancestry.js196
-rw-r--r--node_modules/@babel/traverse/lib/path/comments.js47
-rw-r--r--node_modules/@babel/traverse/lib/path/context.js269
-rw-r--r--node_modules/@babel/traverse/lib/path/conversion.js465
-rw-r--r--node_modules/@babel/traverse/lib/path/evaluation.js439
-rw-r--r--node_modules/@babel/traverse/lib/path/family.js244
-rw-r--r--node_modules/@babel/traverse/lib/path/index.js228
-rw-r--r--node_modules/@babel/traverse/lib/path/inference/index.js136
-rw-r--r--node_modules/@babel/traverse/lib/path/inference/inferer-reference.js183
-rw-r--r--node_modules/@babel/traverse/lib/path/inference/inferers.js220
-rw-r--r--node_modules/@babel/traverse/lib/path/introspection.js412
-rw-r--r--node_modules/@babel/traverse/lib/path/lib/hoister.js194
-rw-r--r--node_modules/@babel/traverse/lib/path/lib/removal-hooks.js38
-rw-r--r--node_modules/@babel/traverse/lib/path/lib/virtual-types.js212
-rw-r--r--node_modules/@babel/traverse/lib/path/modification.js227
-rw-r--r--node_modules/@babel/traverse/lib/path/removal.js68
-rw-r--r--node_modules/@babel/traverse/lib/path/replacement.js273
-rw-r--r--node_modules/@babel/traverse/lib/scope/binding.js71
-rw-r--r--node_modules/@babel/traverse/lib/scope/index.js1006
-rw-r--r--node_modules/@babel/traverse/lib/scope/lib/renamer.js130
-rw-r--r--node_modules/@babel/traverse/lib/visitors.js298
25 files changed, 5727 insertions, 0 deletions
diff --git a/node_modules/@babel/traverse/lib/cache.js b/node_modules/@babel/traverse/lib/cache.js
new file mode 100644
index 00000000..89f20077
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/cache.js
@@ -0,0 +1,26 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.clear = clear;
+exports.clearPath = clearPath;
+exports.clearScope = clearScope;
+exports.scope = exports.path = void 0;
+let path = new WeakMap();
+exports.path = path;
+let scope = new WeakMap();
+exports.scope = scope;
+
+function clear() {
+ clearPath();
+ clearScope();
+}
+
+function clearPath() {
+ exports.path = path = new WeakMap();
+}
+
+function clearScope() {
+ exports.scope = scope = new WeakMap();
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/context.js b/node_modules/@babel/traverse/lib/context.js
new file mode 100644
index 00000000..1ba35ddc
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/context.js
@@ -0,0 +1,188 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+var _path = _interopRequireDefault(require("./path"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const testing = process.env.NODE_ENV === "test";
+
+class TraversalContext {
+ constructor(scope, opts, state, parentPath) {
+ this.queue = null;
+ this.parentPath = parentPath;
+ this.scope = scope;
+ this.state = state;
+ this.opts = opts;
+ }
+
+ shouldVisit(node) {
+ const opts = this.opts;
+ if (opts.enter || opts.exit) return true;
+ if (opts[node.type]) return true;
+ const keys = t().VISITOR_KEYS[node.type];
+ if (!keys || !keys.length) return false;
+
+ for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const key = _ref;
+ if (node[key]) return true;
+ }
+
+ return false;
+ }
+
+ create(node, obj, key, listKey) {
+ return _path.default.get({
+ parentPath: this.parentPath,
+ parent: node,
+ container: obj,
+ key: key,
+ listKey
+ });
+ }
+
+ maybeQueue(path, notPriority) {
+ if (this.trap) {
+ throw new Error("Infinite cycle detected");
+ }
+
+ if (this.queue) {
+ if (notPriority) {
+ this.queue.push(path);
+ } else {
+ this.priorityQueue.push(path);
+ }
+ }
+ }
+
+ visitMultiple(container, parent, listKey) {
+ if (container.length === 0) return false;
+ const queue = [];
+
+ for (let key = 0; key < container.length; key++) {
+ const node = container[key];
+
+ if (node && this.shouldVisit(node)) {
+ queue.push(this.create(parent, container, key, listKey));
+ }
+ }
+
+ return this.visitQueue(queue);
+ }
+
+ visitSingle(node, key) {
+ if (this.shouldVisit(node[key])) {
+ return this.visitQueue([this.create(node, node, key)]);
+ } else {
+ return false;
+ }
+ }
+
+ visitQueue(queue) {
+ this.queue = queue;
+ this.priorityQueue = [];
+ const visited = [];
+ let stop = false;
+
+ for (var _iterator2 = queue, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+
+ const path = _ref2;
+ path.resync();
+
+ if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
+ path.pushContext(this);
+ }
+
+ if (path.key === null) continue;
+
+ if (testing && queue.length >= 10000) {
+ this.trap = true;
+ }
+
+ if (visited.indexOf(path.node) >= 0) continue;
+ visited.push(path.node);
+
+ if (path.visit()) {
+ stop = true;
+ break;
+ }
+
+ if (this.priorityQueue.length) {
+ stop = this.visitQueue(this.priorityQueue);
+ this.priorityQueue = [];
+ this.queue = queue;
+ if (stop) break;
+ }
+ }
+
+ for (var _iterator3 = queue, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
+ var _ref3;
+
+ if (_isArray3) {
+ if (_i3 >= _iterator3.length) break;
+ _ref3 = _iterator3[_i3++];
+ } else {
+ _i3 = _iterator3.next();
+ if (_i3.done) break;
+ _ref3 = _i3.value;
+ }
+
+ const path = _ref3;
+ path.popContext();
+ }
+
+ this.queue = null;
+ return stop;
+ }
+
+ visit(node, key) {
+ const nodes = node[key];
+ if (!nodes) return false;
+
+ if (Array.isArray(nodes)) {
+ return this.visitMultiple(nodes, node, key);
+ } else {
+ return this.visitSingle(node, key);
+ }
+ }
+
+}
+
+exports.default = TraversalContext; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/hub.js b/node_modules/@babel/traverse/lib/hub.js
new file mode 100644
index 00000000..9f97f79c
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/hub.js
@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+class Hub {
+ constructor(file) {
+ this.file = file;
+ }
+
+}
+
+exports.default = Hub; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/index.js b/node_modules/@babel/traverse/lib/index.js
new file mode 100644
index 00000000..d140f19f
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/index.js
@@ -0,0 +1,142 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = traverse;
+Object.defineProperty(exports, "NodePath", {
+ enumerable: true,
+ get: function get() {
+ return _path.default;
+ }
+});
+Object.defineProperty(exports, "Scope", {
+ enumerable: true,
+ get: function get() {
+ return _scope.default;
+ }
+});
+Object.defineProperty(exports, "Hub", {
+ enumerable: true,
+ get: function get() {
+ return _hub.default;
+ }
+});
+exports.visitors = void 0;
+
+var _context = _interopRequireDefault(require("./context"));
+
+var visitors = _interopRequireWildcard(require("./visitors"));
+
+exports.visitors = visitors;
+
+function _includes() {
+ const data = _interopRequireDefault(require("lodash/includes"));
+
+ _includes = function _includes() {
+ return data;
+ };
+
+ return data;
+}
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+var cache = _interopRequireWildcard(require("./cache"));
+
+var _path = _interopRequireDefault(require("./path"));
+
+var _scope = _interopRequireDefault(require("./scope"));
+
+var _hub = _interopRequireDefault(require("./hub"));
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function traverse(parent, opts, scope, state, parentPath) {
+ if (!parent) return;
+ if (!opts) opts = {};
+
+ if (!opts.noScope && !scope) {
+ if (parent.type !== "Program" && parent.type !== "File") {
+ 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.");
+ }
+ }
+
+ visitors.explode(opts);
+ traverse.node(parent, opts, scope, state, parentPath);
+}
+
+traverse.visitors = visitors;
+traverse.verify = visitors.verify;
+traverse.explode = visitors.explode;
+
+traverse.cheap = function (node, enter) {
+ return t().traverseFast(node, enter);
+};
+
+traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
+ const keys = t().VISITOR_KEYS[node.type];
+ if (!keys) return;
+ const context = new _context.default(scope, opts, state, parentPath);
+
+ for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const key = _ref;
+ if (skipKeys && skipKeys[key]) continue;
+ if (context.visit(node, key)) return;
+ }
+};
+
+traverse.clearNode = function (node, opts) {
+ t().removeProperties(node, opts);
+ cache.path.delete(node);
+};
+
+traverse.removeProperties = function (tree, opts) {
+ t().traverseFast(tree, traverse.clearNode, opts);
+ return tree;
+};
+
+function hasBlacklistedType(path, state) {
+ if (path.node.type === state.type) {
+ state.has = true;
+ path.stop();
+ }
+}
+
+traverse.hasType = function (tree, type, blacklistTypes) {
+ if ((0, _includes().default)(blacklistTypes, tree.type)) return false;
+ if (tree.type === type) return true;
+ const state = {
+ has: false,
+ type: type
+ };
+ traverse(tree, {
+ noScope: true,
+ blacklist: blacklistTypes,
+ enter: hasBlacklistedType
+ }, null, state);
+ return state.has;
+};
+
+traverse.cache = cache; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/ancestry.js b/node_modules/@babel/traverse/lib/path/ancestry.js
new file mode 100644
index 00000000..f60b08e8
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/ancestry.js
@@ -0,0 +1,196 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.findParent = findParent;
+exports.find = find;
+exports.getFunctionParent = getFunctionParent;
+exports.getStatementParent = getStatementParent;
+exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
+exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
+exports.getAncestry = getAncestry;
+exports.isAncestor = isAncestor;
+exports.isDescendant = isDescendant;
+exports.inType = inType;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+var _index = _interopRequireDefault(require("./index"));
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function findParent(callback) {
+ let path = this;
+
+ while (path = path.parentPath) {
+ if (callback(path)) return path;
+ }
+
+ return null;
+}
+
+function find(callback) {
+ let path = this;
+
+ do {
+ if (callback(path)) return path;
+ } while (path = path.parentPath);
+
+ return null;
+}
+
+function getFunctionParent() {
+ return this.findParent(p => p.isFunction());
+}
+
+function getStatementParent() {
+ let path = this;
+
+ do {
+ if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
+ break;
+ } else {
+ path = path.parentPath;
+ }
+ } while (path);
+
+ if (path && (path.isProgram() || path.isFile())) {
+ throw new Error("File/Program node, we can't possibly find a statement parent to this");
+ }
+
+ return path;
+}
+
+function getEarliestCommonAncestorFrom(paths) {
+ return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
+ let earliest;
+ const keys = t().VISITOR_KEYS[deepest.type];
+ var _arr = ancestries;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const ancestry = _arr[_i];
+ const path = ancestry[i + 1];
+
+ if (!earliest) {
+ earliest = path;
+ continue;
+ }
+
+ if (path.listKey && earliest.listKey === path.listKey) {
+ if (path.key < earliest.key) {
+ earliest = path;
+ continue;
+ }
+ }
+
+ const earliestKeyIndex = keys.indexOf(earliest.parentKey);
+ const currentKeyIndex = keys.indexOf(path.parentKey);
+
+ if (earliestKeyIndex > currentKeyIndex) {
+ earliest = path;
+ }
+ }
+
+ return earliest;
+ });
+}
+
+function getDeepestCommonAncestorFrom(paths, filter) {
+ if (!paths.length) {
+ return this;
+ }
+
+ if (paths.length === 1) {
+ return paths[0];
+ }
+
+ let minDepth = Infinity;
+ let lastCommonIndex, lastCommon;
+ const ancestries = paths.map(path => {
+ const ancestry = [];
+
+ do {
+ ancestry.unshift(path);
+ } while ((path = path.parentPath) && path !== this);
+
+ if (ancestry.length < minDepth) {
+ minDepth = ancestry.length;
+ }
+
+ return ancestry;
+ });
+ const first = ancestries[0];
+
+ depthLoop: for (let i = 0; i < minDepth; i++) {
+ const shouldMatch = first[i];
+ var _arr2 = ancestries;
+
+ for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
+ const ancestry = _arr2[_i2];
+
+ if (ancestry[i] !== shouldMatch) {
+ break depthLoop;
+ }
+ }
+
+ lastCommonIndex = i;
+ lastCommon = shouldMatch;
+ }
+
+ if (lastCommon) {
+ if (filter) {
+ return filter(lastCommon, lastCommonIndex, ancestries);
+ } else {
+ return lastCommon;
+ }
+ } else {
+ throw new Error("Couldn't find intersection");
+ }
+}
+
+function getAncestry() {
+ let path = this;
+ const paths = [];
+
+ do {
+ paths.push(path);
+ } while (path = path.parentPath);
+
+ return paths;
+}
+
+function isAncestor(maybeDescendant) {
+ return maybeDescendant.isDescendant(this);
+}
+
+function isDescendant(maybeAncestor) {
+ return !!this.findParent(parent => parent === maybeAncestor);
+}
+
+function inType() {
+ let path = this;
+
+ while (path) {
+ var _arr3 = arguments;
+
+ for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
+ const type = _arr3[_i3];
+ if (path.node.type === type) return true;
+ }
+
+ path = path.parentPath;
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/comments.js b/node_modules/@babel/traverse/lib/path/comments.js
new file mode 100644
index 00000000..da5f0356
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/comments.js
@@ -0,0 +1,47 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
+exports.addComment = addComment;
+exports.addComments = addComments;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function shareCommentsWithSiblings() {
+ if (typeof this.key === "string") return;
+ const node = this.node;
+ if (!node) return;
+ const trailing = node.trailingComments;
+ const leading = node.leadingComments;
+ if (!trailing && !leading) return;
+ const prev = this.getSibling(this.key - 1);
+ const next = this.getSibling(this.key + 1);
+ const hasPrev = Boolean(prev.node);
+ const hasNext = Boolean(next.node);
+
+ if (hasPrev && hasNext) {} else if (hasPrev) {
+ prev.addComments("trailing", trailing);
+ } else if (hasNext) {
+ next.addComments("leading", leading);
+ }
+}
+
+function addComment(type, content, line) {
+ t().addComment(this.node, type, content, line);
+}
+
+function addComments(type, comments) {
+ t().addComments(this.node, type, comments);
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/context.js b/node_modules/@babel/traverse/lib/path/context.js
new file mode 100644
index 00000000..72bfac1e
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/context.js
@@ -0,0 +1,269 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.call = call;
+exports._call = _call;
+exports.isBlacklisted = isBlacklisted;
+exports.visit = visit;
+exports.skip = skip;
+exports.skipKey = skipKey;
+exports.stop = stop;
+exports.setScope = setScope;
+exports.setContext = setContext;
+exports.resync = resync;
+exports._resyncParent = _resyncParent;
+exports._resyncKey = _resyncKey;
+exports._resyncList = _resyncList;
+exports._resyncRemoved = _resyncRemoved;
+exports.popContext = popContext;
+exports.pushContext = pushContext;
+exports.setup = setup;
+exports.setKey = setKey;
+exports.requeue = requeue;
+exports._getQueueContexts = _getQueueContexts;
+
+var _index = _interopRequireDefault(require("../index"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function call(key) {
+ const opts = this.opts;
+ this.debug(key);
+
+ if (this.node) {
+ if (this._call(opts[key])) return true;
+ }
+
+ if (this.node) {
+ return this._call(opts[this.node.type] && opts[this.node.type][key]);
+ }
+
+ return false;
+}
+
+function _call(fns) {
+ if (!fns) return false;
+
+ for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const fn = _ref;
+ if (!fn) continue;
+ const node = this.node;
+ if (!node) return true;
+ const ret = fn.call(this.state, this, this.state);
+
+ if (ret && typeof ret === "object" && typeof ret.then === "function") {
+ throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
+ }
+
+ if (ret) {
+ throw new Error(`Unexpected return value from visitor method ${fn}`);
+ }
+
+ if (this.node !== node) return true;
+ if (this.shouldStop || this.shouldSkip || this.removed) return true;
+ }
+
+ return false;
+}
+
+function isBlacklisted() {
+ const blacklist = this.opts.blacklist;
+ return blacklist && blacklist.indexOf(this.node.type) > -1;
+}
+
+function visit() {
+ if (!this.node) {
+ return false;
+ }
+
+ if (this.isBlacklisted()) {
+ return false;
+ }
+
+ if (this.opts.shouldSkip && this.opts.shouldSkip(this)) {
+ return false;
+ }
+
+ if (this.call("enter") || this.shouldSkip) {
+ this.debug("Skip...");
+ return this.shouldStop;
+ }
+
+ this.debug("Recursing into...");
+
+ _index.default.node(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
+
+ this.call("exit");
+ return this.shouldStop;
+}
+
+function skip() {
+ this.shouldSkip = true;
+}
+
+function skipKey(key) {
+ this.skipKeys[key] = true;
+}
+
+function stop() {
+ this.shouldStop = true;
+ this.shouldSkip = true;
+}
+
+function setScope() {
+ if (this.opts && this.opts.noScope) return;
+ let path = this.parentPath;
+ let target;
+
+ while (path && !target) {
+ if (path.opts && path.opts.noScope) return;
+ target = path.scope;
+ path = path.parentPath;
+ }
+
+ this.scope = this.getScope(target);
+ if (this.scope) this.scope.init();
+}
+
+function setContext(context) {
+ this.shouldSkip = false;
+ this.shouldStop = false;
+ this.removed = false;
+ this.skipKeys = {};
+
+ if (context) {
+ this.context = context;
+ this.state = context.state;
+ this.opts = context.opts;
+ }
+
+ this.setScope();
+ return this;
+}
+
+function resync() {
+ if (this.removed) return;
+
+ this._resyncParent();
+
+ this._resyncList();
+
+ this._resyncKey();
+}
+
+function _resyncParent() {
+ if (this.parentPath) {
+ this.parent = this.parentPath.node;
+ }
+}
+
+function _resyncKey() {
+ if (!this.container) return;
+ if (this.node === this.container[this.key]) return;
+
+ if (Array.isArray(this.container)) {
+ for (let i = 0; i < this.container.length; i++) {
+ if (this.container[i] === this.node) {
+ return this.setKey(i);
+ }
+ }
+ } else {
+ for (const key in this.container) {
+ if (this.container[key] === this.node) {
+ return this.setKey(key);
+ }
+ }
+ }
+
+ this.key = null;
+}
+
+function _resyncList() {
+ if (!this.parent || !this.inList) return;
+ const newContainer = this.parent[this.listKey];
+ if (this.container === newContainer) return;
+ this.container = newContainer || null;
+}
+
+function _resyncRemoved() {
+ if (this.key == null || !this.container || this.container[this.key] !== this.node) {
+ this._markRemoved();
+ }
+}
+
+function popContext() {
+ this.contexts.pop();
+
+ if (this.contexts.length > 0) {
+ this.setContext(this.contexts[this.contexts.length - 1]);
+ } else {
+ this.setContext(undefined);
+ }
+}
+
+function pushContext(context) {
+ this.contexts.push(context);
+ this.setContext(context);
+}
+
+function setup(parentPath, container, listKey, key) {
+ this.inList = !!listKey;
+ this.listKey = listKey;
+ this.parentKey = listKey || key;
+ this.container = container;
+ this.parentPath = parentPath || this.parentPath;
+ this.setKey(key);
+}
+
+function setKey(key) {
+ this.key = key;
+ this.node = this.container[this.key];
+ this.type = this.node && this.node.type;
+}
+
+function requeue(pathToQueue = this) {
+ if (pathToQueue.removed) return;
+ const contexts = this.contexts;
+
+ for (var _iterator2 = contexts, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+
+ const context = _ref2;
+ context.maybeQueue(pathToQueue);
+ }
+}
+
+function _getQueueContexts() {
+ let path = this;
+ let contexts = this.contexts;
+
+ while (!contexts.length) {
+ path = path.parentPath;
+ if (!path) break;
+ contexts = path.contexts;
+ }
+
+ return contexts;
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/conversion.js b/node_modules/@babel/traverse/lib/path/conversion.js
new file mode 100644
index 00000000..a449ce3f
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/conversion.js
@@ -0,0 +1,465 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.toComputedKey = toComputedKey;
+exports.ensureBlock = ensureBlock;
+exports.arrowFunctionToShadowed = arrowFunctionToShadowed;
+exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
+exports.arrowFunctionToExpression = arrowFunctionToExpression;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+function _helperFunctionName() {
+ const data = _interopRequireDefault(require("@babel/helper-function-name"));
+
+ _helperFunctionName = function _helperFunctionName() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function toComputedKey() {
+ const node = this.node;
+ let key;
+
+ if (this.isMemberExpression()) {
+ key = node.property;
+ } else if (this.isProperty() || this.isMethod()) {
+ key = node.key;
+ } else {
+ throw new ReferenceError("todo");
+ }
+
+ if (!node.computed) {
+ if (t().isIdentifier(key)) key = t().stringLiteral(key.name);
+ }
+
+ return key;
+}
+
+function ensureBlock() {
+ const body = this.get("body");
+ const 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;
+ }
+
+ const statements = [];
+ let stringPath = "body";
+ let key;
+ let 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);
+ const parentPath = this.get(stringPath);
+ body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
+ return this.node;
+}
+
+function arrowFunctionToShadowed() {
+ if (!this.isArrowFunctionExpression()) return;
+ this.arrowFunctionToExpression();
+}
+
+function unwrapFunctionEnvironment() {
+ if (!this.isArrowFunctionExpression() && !this.isFunctionExpression() && !this.isFunctionDeclaration()) {
+ throw this.buildCodeFrameError("Can only unwrap the environment of a function.");
+ }
+
+ hoistFunctionEnvironment(this);
+}
+
+function arrowFunctionToExpression({
+ allowInsertArrow = true,
+ specCompliant = false
+} = {}) {
+ if (!this.isArrowFunctionExpression()) {
+ throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
+ }
+
+ const thisBinding = hoistFunctionEnvironment(this, specCompliant, allowInsertArrow);
+ this.ensureBlock();
+ this.node.type = "FunctionExpression";
+
+ if (specCompliant) {
+ const checkBinding = thisBinding ? null : this.parentPath.scope.generateUidIdentifier("arrowCheckId");
+
+ if (checkBinding) {
+ this.parentPath.scope.push({
+ id: checkBinding,
+ init: t().objectExpression([])
+ });
+ }
+
+ 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, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()]));
+ }
+}
+
+function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArrow = true) {
+ const thisEnvFn = fnPath.findParent(p => {
+ return p.isFunction() && !p.isArrowFunctionExpression() || p.isProgram() || p.isClassProperty({
+ static: false
+ });
+ });
+ const inConstructor = thisEnvFn && thisEnvFn.node.kind === "constructor";
+
+ if (thisEnvFn.isClassProperty()) {
+ throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
+ }
+
+ const _getScopeInformation = getScopeInformation(fnPath),
+ thisPaths = _getScopeInformation.thisPaths,
+ argumentsPaths = _getScopeInformation.argumentsPaths,
+ newTargetPaths = _getScopeInformation.newTargetPaths,
+ superProps = _getScopeInformation.superProps,
+ superCalls = _getScopeInformation.superCalls;
+
+ if (inConstructor && superCalls.length > 0) {
+ if (!allowInsertArrow) {
+ throw superCalls[0].buildCodeFrameError("Unable to handle nested super() usage in arrow");
+ }
+
+ const allSuperCalls = [];
+ thisEnvFn.traverse({
+ Function(child) {
+ if (child.isArrowFunctionExpression()) return;
+ child.skip();
+ },
+
+ ClassProperty(child) {
+ if (child.node.static) return;
+ child.skip();
+ },
+
+ CallExpression(child) {
+ if (!child.get("callee").isSuper()) return;
+ allSuperCalls.push(child);
+ }
+
+ });
+ const superBinding = getSuperBinding(thisEnvFn);
+ allSuperCalls.forEach(superCall => {
+ const callee = t().identifier(superBinding);
+ callee.loc = superCall.node.callee.loc;
+ superCall.get("callee").replaceWith(callee);
+ });
+ }
+
+ let thisBinding;
+
+ if (thisPaths.length > 0 || specCompliant) {
+ thisBinding = getThisBinding(thisEnvFn, inConstructor);
+
+ if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
+ thisPaths.forEach(thisChild => {
+ const thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding);
+ thisRef.loc = thisChild.node.loc;
+ thisChild.replaceWith(thisRef);
+ });
+ if (specCompliant) thisBinding = null;
+ }
+ }
+
+ if (argumentsPaths.length > 0) {
+ const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t().identifier("arguments"));
+ argumentsPaths.forEach(argumentsChild => {
+ const argsRef = t().identifier(argumentsBinding);
+ argsRef.loc = argumentsChild.node.loc;
+ argumentsChild.replaceWith(argsRef);
+ });
+ }
+
+ if (newTargetPaths.length > 0) {
+ const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t().metaProperty(t().identifier("new"), t().identifier("target")));
+ newTargetPaths.forEach(targetChild => {
+ const targetRef = t().identifier(newTargetBinding);
+ targetRef.loc = targetChild.node.loc;
+ targetChild.replaceWith(targetRef);
+ });
+ }
+
+ if (superProps.length > 0) {
+ if (!allowInsertArrow) {
+ throw superProps[0].buildCodeFrameError("Unable to handle nested super.prop usage");
+ }
+
+ const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
+ flatSuperProps.forEach(superProp => {
+ const key = superProp.node.computed ? "" : superProp.get("property").node.name;
+
+ if (superProp.parentPath.isCallExpression({
+ callee: superProp.node
+ })) {
+ const superBinding = getSuperPropCallBinding(thisEnvFn, key);
+
+ if (superProp.node.computed) {
+ const prop = superProp.get("property").node;
+ superProp.replaceWith(t().identifier(superBinding));
+ superProp.parentPath.node.arguments.unshift(prop);
+ } else {
+ superProp.replaceWith(t().identifier(superBinding));
+ }
+ } else {
+ const isAssignment = superProp.parentPath.isAssignmentExpression({
+ left: superProp.node
+ });
+ const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
+ const args = [];
+
+ if (superProp.node.computed) {
+ args.push(superProp.get("property").node);
+ }
+
+ if (isAssignment) {
+ const value = superProp.parentPath.node.right;
+ args.push(value);
+ superProp.parentPath.replaceWith(t().callExpression(t().identifier(superBinding), args));
+ } else {
+ superProp.replaceWith(t().callExpression(t().identifier(superBinding), args));
+ }
+ }
+ });
+ }
+
+ return thisBinding;
+}
+
+function standardizeSuperProperty(superProp) {
+ if (superProp.parentPath.isAssignmentExpression() && superProp.parentPath.node.operator !== "=") {
+ const assignmentPath = superProp.parentPath;
+ const op = assignmentPath.node.operator.slice(0, -1);
+ const value = assignmentPath.node.right;
+ assignmentPath.node.operator = "=";
+
+ if (superProp.node.computed) {
+ const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
+ assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true));
+ assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value));
+ } else {
+ assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, superProp.node.property));
+ assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(superProp.node.property.name)), value));
+ }
+
+ return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
+ } else if (superProp.parentPath.isUpdateExpression()) {
+ const updateExpr = superProp.parentPath;
+ const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
+ const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
+ const parts = [t().assignmentExpression("=", tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(tmp.name), t().numericLiteral(1)))];
+
+ if (!superProp.parentPath.node.prefix) {
+ parts.push(t().identifier(tmp.name));
+ }
+
+ updateExpr.replaceWith(t().sequenceExpression(parts));
+ const left = updateExpr.get("expressions.0.right");
+ const right = updateExpr.get("expressions.1.left");
+ return [left, right];
+ }
+
+ return [superProp];
+}
+
+function hasSuperClass(thisEnvFn) {
+ return thisEnvFn.isClassMethod() && !!thisEnvFn.parentPath.parentPath.node.superClass;
+}
+
+function getThisBinding(thisEnvFn, inConstructor) {
+ return getBinding(thisEnvFn, "this", thisBinding => {
+ if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression();
+ const supers = new WeakSet();
+ thisEnvFn.traverse({
+ Function(child) {
+ if (child.isArrowFunctionExpression()) return;
+ child.skip();
+ },
+
+ ClassProperty(child) {
+ if (child.node.static) return;
+ child.skip();
+ },
+
+ CallExpression(child) {
+ if (!child.get("callee").isSuper()) return;
+ if (supers.has(child.node)) return;
+ supers.add(child.node);
+ child.replaceWith(t().assignmentExpression("=", t().identifier(thisBinding), child.node));
+ }
+
+ });
+ });
+}
+
+function getSuperBinding(thisEnvFn) {
+ return getBinding(thisEnvFn, "supercall", () => {
+ const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
+ return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))]));
+ });
+}
+
+function getSuperPropCallBinding(thisEnvFn, propName) {
+ return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => {
+ const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
+ const argsList = [t().restElement(argsBinding)];
+ let fnBody;
+
+ if (propName) {
+ fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]);
+ } else {
+ const method = thisEnvFn.scope.generateUidIdentifier("prop");
+ argsList.unshift(method);
+ fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]);
+ }
+
+ return t().arrowFunctionExpression(argsList, fnBody);
+ });
+}
+
+function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
+ const op = isAssignment ? "set" : "get";
+ return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => {
+ const argsList = [];
+ let fnBody;
+
+ if (propName) {
+ fnBody = t().memberExpression(t().super(), t().identifier(propName));
+ } else {
+ const method = thisEnvFn.scope.generateUidIdentifier("prop");
+ argsList.unshift(method);
+ fnBody = t().memberExpression(t().super(), t().identifier(method.name), true);
+ }
+
+ if (isAssignment) {
+ const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
+ argsList.push(valueIdent);
+ fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name));
+ }
+
+ return t().arrowFunctionExpression(argsList, fnBody);
+ });
+}
+
+function getBinding(thisEnvFn, key, init) {
+ const cacheKey = "binding:" + key;
+ let data = thisEnvFn.getData(cacheKey);
+
+ if (!data) {
+ const id = thisEnvFn.scope.generateUidIdentifier(key);
+ data = id.name;
+ thisEnvFn.setData(cacheKey, data);
+ thisEnvFn.scope.push({
+ id: id,
+ init: init(data)
+ });
+ }
+
+ return data;
+}
+
+function getScopeInformation(fnPath) {
+ const thisPaths = [];
+ const argumentsPaths = [];
+ const newTargetPaths = [];
+ const superProps = [];
+ const superCalls = [];
+ fnPath.traverse({
+ ClassProperty(child) {
+ if (child.node.static) return;
+ child.skip();
+ },
+
+ Function(child) {
+ if (child.isArrowFunctionExpression()) return;
+ child.skip();
+ },
+
+ ThisExpression(child) {
+ thisPaths.push(child);
+ },
+
+ JSXIdentifier(child) {
+ if (child.node.name !== "this") return;
+
+ if (!child.parentPath.isJSXMemberExpression({
+ object: child.node
+ }) && !child.parentPath.isJSXOpeningElement({
+ name: child.node
+ })) {
+ return;
+ }
+
+ thisPaths.push(child);
+ },
+
+ CallExpression(child) {
+ if (child.get("callee").isSuper()) superCalls.push(child);
+ },
+
+ MemberExpression(child) {
+ if (child.get("object").isSuper()) superProps.push(child);
+ },
+
+ ReferencedIdentifier(child) {
+ if (child.node.name !== "arguments") return;
+ argumentsPaths.push(child);
+ },
+
+ MetaProperty(child) {
+ if (!child.get("meta").isIdentifier({
+ name: "new"
+ })) return;
+ if (!child.get("property").isIdentifier({
+ name: "target"
+ })) return;
+ newTargetPaths.push(child);
+ }
+
+ });
+ return {
+ thisPaths,
+ argumentsPaths,
+ newTargetPaths,
+ superProps,
+ superCalls
+ };
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/evaluation.js b/node_modules/@babel/traverse/lib/path/evaluation.js
new file mode 100644
index 00000000..0f2d04c9
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/evaluation.js
@@ -0,0 +1,439 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.evaluateTruthy = evaluateTruthy;
+exports.evaluate = evaluate;
+const VALID_CALLEES = ["String", "Number", "Math"];
+const INVALID_METHODS = ["random"];
+
+function evaluateTruthy() {
+ const res = this.evaluate();
+ if (res.confident) return !!res.value;
+}
+
+function deopt(path, state) {
+ if (!state.confident) return;
+ state.deoptPath = path;
+ state.confident = false;
+}
+
+function evaluateCached(path, state) {
+ const node = path.node;
+ const seen = state.seen;
+
+ if (seen.has(node)) {
+ const existing = seen.get(node);
+
+ if (existing.resolved) {
+ return existing.value;
+ } else {
+ deopt(path, state);
+ return;
+ }
+ } else {
+ const item = {
+ resolved: false
+ };
+ seen.set(node, item);
+
+ const val = _evaluate(path, state);
+
+ if (state.confident) {
+ item.resolved = true;
+ item.value = val;
+ }
+
+ return val;
+ }
+}
+
+function _evaluate(path, state) {
+ if (!state.confident) return;
+ const node = path.node;
+
+ if (path.isSequenceExpression()) {
+ const exprs = path.get("expressions");
+ return evaluateCached(exprs[exprs.length - 1], state);
+ }
+
+ if (path.isStringLiteral() || path.isNumericLiteral() || path.isBooleanLiteral()) {
+ return node.value;
+ }
+
+ if (path.isNullLiteral()) {
+ return null;
+ }
+
+ if (path.isTemplateLiteral()) {
+ return evaluateQuasis(path, node.quasis, state);
+ }
+
+ if (path.isTaggedTemplateExpression() && path.get("tag").isMemberExpression()) {
+ const object = path.get("tag.object");
+ const name = object.node.name;
+ const property = path.get("tag.property");
+
+ if (object.isIdentifier() && name === "String" && !path.scope.getBinding(name, true) && property.isIdentifier && property.node.name === "raw") {
+ return evaluateQuasis(path, node.quasi.quasis, state, true);
+ }
+ }
+
+ if (path.isConditionalExpression()) {
+ const testResult = evaluateCached(path.get("test"), state);
+ if (!state.confident) return;
+
+ if (testResult) {
+ return evaluateCached(path.get("consequent"), state);
+ } else {
+ return evaluateCached(path.get("alternate"), state);
+ }
+ }
+
+ if (path.isExpressionWrapper()) {
+ return evaluateCached(path.get("expression"), state);
+ }
+
+ if (path.isMemberExpression() && !path.parentPath.isCallExpression({
+ callee: node
+ })) {
+ const property = path.get("property");
+ const object = path.get("object");
+
+ if (object.isLiteral() && property.isIdentifier()) {
+ const value = object.node.value;
+ const type = typeof value;
+
+ if (type === "number" || type === "string") {
+ return value[property.node.name];
+ }
+ }
+ }
+
+ if (path.isReferencedIdentifier()) {
+ const binding = path.scope.getBinding(node.name);
+
+ if (binding && binding.constantViolations.length > 0) {
+ return deopt(binding.path, state);
+ }
+
+ if (binding && path.node.start < binding.path.node.end) {
+ return deopt(binding.path, state);
+ }
+
+ if (binding && binding.hasValue) {
+ return binding.value;
+ } else {
+ if (node.name === "undefined") {
+ return binding ? deopt(binding.path, state) : undefined;
+ } else if (node.name === "Infinity") {
+ return binding ? deopt(binding.path, state) : Infinity;
+ } else if (node.name === "NaN") {
+ return binding ? deopt(binding.path, state) : NaN;
+ }
+
+ const resolved = path.resolve();
+
+ if (resolved === path) {
+ return deopt(path, state);
+ } else {
+ return evaluateCached(resolved, state);
+ }
+ }
+ }
+
+ if (path.isUnaryExpression({
+ prefix: true
+ })) {
+ if (node.operator === "void") {
+ return undefined;
+ }
+
+ const argument = path.get("argument");
+
+ if (node.operator === "typeof" && (argument.isFunction() || argument.isClass())) {
+ return "function";
+ }
+
+ const arg = evaluateCached(argument, state);
+ if (!state.confident) return;
+
+ switch (node.operator) {
+ case "!":
+ return !arg;
+
+ case "+":
+ return +arg;
+
+ case "-":
+ return -arg;
+
+ case "~":
+ return ~arg;
+
+ case "typeof":
+ return typeof arg;
+ }
+ }
+
+ if (path.isArrayExpression()) {
+ const arr = [];
+ const elems = path.get("elements");
+
+ for (var _iterator = elems, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const elem = _ref;
+ const elemValue = elem.evaluate();
+
+ if (elemValue.confident) {
+ arr.push(elemValue.value);
+ } else {
+ return deopt(elem, state);
+ }
+ }
+
+ return arr;
+ }
+
+ if (path.isObjectExpression()) {
+ const obj = {};
+ const props = path.get("properties");
+
+ for (var _iterator2 = props, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+
+ const prop = _ref2;
+
+ if (prop.isObjectMethod() || prop.isSpreadElement()) {
+ return deopt(prop, state);
+ }
+
+ const keyPath = prop.get("key");
+ let key = keyPath;
+
+ if (prop.node.computed) {
+ key = key.evaluate();
+
+ if (!key.confident) {
+ return deopt(keyPath, state);
+ }
+
+ key = key.value;
+ } else if (key.isIdentifier()) {
+ key = key.node.name;
+ } else {
+ key = key.node.value;
+ }
+
+ const valuePath = prop.get("value");
+ let value = valuePath.evaluate();
+
+ if (!value.confident) {
+ return deopt(valuePath, state);
+ }
+
+ value = value.value;
+ obj[key] = value;
+ }
+
+ return obj;
+ }
+
+ if (path.isLogicalExpression()) {
+ const wasConfident = state.confident;
+ const left = evaluateCached(path.get("left"), state);
+ const leftConfident = state.confident;
+ state.confident = wasConfident;
+ const right = evaluateCached(path.get("right"), state);
+ const rightConfident = state.confident;
+ state.confident = leftConfident && rightConfident;
+
+ switch (node.operator) {
+ case "||":
+ if (left && leftConfident) {
+ state.confident = true;
+ return left;
+ }
+
+ if (!state.confident) return;
+ return left || right;
+
+ case "&&":
+ if (!left && leftConfident || !right && rightConfident) {
+ state.confident = true;
+ }
+
+ if (!state.confident) return;
+ return left && right;
+ }
+ }
+
+ if (path.isBinaryExpression()) {
+ const left = evaluateCached(path.get("left"), state);
+ if (!state.confident) return;
+ const right = evaluateCached(path.get("right"), state);
+ if (!state.confident) return;
+
+ switch (node.operator) {
+ case "-":
+ return left - right;
+
+ case "+":
+ return left + right;
+
+ case "/":
+ return left / right;
+
+ case "*":
+ return left * right;
+
+ case "%":
+ return left % right;
+
+ case "**":
+ return Math.pow(left, right);
+
+ case "<":
+ return left < right;
+
+ case ">":
+ return left > right;
+
+ case "<=":
+ return left <= right;
+
+ case ">=":
+ return left >= right;
+
+ case "==":
+ return left == right;
+
+ case "!=":
+ return left != right;
+
+ case "===":
+ return left === right;
+
+ case "!==":
+ return left !== right;
+
+ case "|":
+ return left | right;
+
+ case "&":
+ return left & right;
+
+ case "^":
+ return left ^ right;
+
+ case "<<":
+ return left << right;
+
+ case ">>":
+ return left >> right;
+
+ case ">>>":
+ return left >>> right;
+ }
+ }
+
+ if (path.isCallExpression()) {
+ const callee = path.get("callee");
+ let context;
+ let func;
+
+ if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name, true) && VALID_CALLEES.indexOf(callee.node.name) >= 0) {
+ func = global[node.callee.name];
+ }
+
+ if (callee.isMemberExpression()) {
+ const object = callee.get("object");
+ const property = callee.get("property");
+
+ if (object.isIdentifier() && property.isIdentifier() && VALID_CALLEES.indexOf(object.node.name) >= 0 && INVALID_METHODS.indexOf(property.node.name) < 0) {
+ context = global[object.node.name];
+ func = context[property.node.name];
+ }
+
+ if (object.isLiteral() && property.isIdentifier()) {
+ const type = typeof object.node.value;
+
+ if (type === "string" || type === "number") {
+ context = object.node.value;
+ func = context[property.node.name];
+ }
+ }
+ }
+
+ if (func) {
+ const args = path.get("arguments").map(arg => evaluateCached(arg, state));
+ if (!state.confident) return;
+ return func.apply(context, args);
+ }
+ }
+
+ deopt(path, state);
+}
+
+function evaluateQuasis(path, quasis, state, raw = false) {
+ let str = "";
+ let i = 0;
+ const exprs = path.get("expressions");
+
+ for (var _iterator3 = quasis, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
+ var _ref3;
+
+ if (_isArray3) {
+ if (_i3 >= _iterator3.length) break;
+ _ref3 = _iterator3[_i3++];
+ } else {
+ _i3 = _iterator3.next();
+ if (_i3.done) break;
+ _ref3 = _i3.value;
+ }
+
+ const elem = _ref3;
+ if (!state.confident) break;
+ str += raw ? elem.value.raw : elem.value.cooked;
+ const expr = exprs[i++];
+ if (expr) str += String(evaluateCached(expr, state));
+ }
+
+ if (!state.confident) return;
+ return str;
+}
+
+function evaluate() {
+ const state = {
+ confident: true,
+ deoptPath: null,
+ seen: new Map()
+ };
+ let value = evaluateCached(this, state);
+ if (!state.confident) value = undefined;
+ return {
+ confident: state.confident,
+ deopt: state.deoptPath,
+ value: value
+ };
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/family.js b/node_modules/@babel/traverse/lib/path/family.js
new file mode 100644
index 00000000..2a193940
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/family.js
@@ -0,0 +1,244 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.getOpposite = getOpposite;
+exports.getCompletionRecords = getCompletionRecords;
+exports.getSibling = getSibling;
+exports.getPrevSibling = getPrevSibling;
+exports.getNextSibling = getNextSibling;
+exports.getAllNextSiblings = getAllNextSiblings;
+exports.getAllPrevSiblings = getAllPrevSiblings;
+exports.get = get;
+exports._getKey = _getKey;
+exports._getPattern = _getPattern;
+exports.getBindingIdentifiers = getBindingIdentifiers;
+exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
+exports.getBindingIdentifierPaths = getBindingIdentifierPaths;
+exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
+
+var _index = _interopRequireDefault(require("./index"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function getOpposite() {
+ if (this.key === "left") {
+ return this.getSibling("right");
+ } else if (this.key === "right") {
+ return this.getSibling("left");
+ }
+}
+
+function addCompletionRecords(path, paths) {
+ if (path) return paths.concat(path.getCompletionRecords());
+ return paths;
+}
+
+function getCompletionRecords() {
+ let paths = [];
+
+ if (this.isIfStatement()) {
+ paths = addCompletionRecords(this.get("consequent"), paths);
+ paths = addCompletionRecords(this.get("alternate"), paths);
+ } else if (this.isDoExpression() || this.isFor() || this.isWhile()) {
+ paths = addCompletionRecords(this.get("body"), paths);
+ } else if (this.isProgram() || this.isBlockStatement()) {
+ paths = addCompletionRecords(this.get("body").pop(), paths);
+ } else if (this.isFunction()) {
+ return this.get("body").getCompletionRecords();
+ } else if (this.isTryStatement()) {
+ paths = addCompletionRecords(this.get("block"), paths);
+ paths = addCompletionRecords(this.get("handler"), paths);
+ paths = addCompletionRecords(this.get("finalizer"), paths);
+ } else if (this.isCatchClause()) {
+ paths = addCompletionRecords(this.get("body"), paths);
+ } else {
+ paths.push(this);
+ }
+
+ return paths;
+}
+
+function getSibling(key) {
+ return _index.default.get({
+ parentPath: this.parentPath,
+ parent: this.parent,
+ container: this.container,
+ listKey: this.listKey,
+ key: key
+ });
+}
+
+function getPrevSibling() {
+ return this.getSibling(this.key - 1);
+}
+
+function getNextSibling() {
+ return this.getSibling(this.key + 1);
+}
+
+function getAllNextSiblings() {
+ let _key = this.key;
+ let sibling = this.getSibling(++_key);
+ const siblings = [];
+
+ while (sibling.node) {
+ siblings.push(sibling);
+ sibling = this.getSibling(++_key);
+ }
+
+ return siblings;
+}
+
+function getAllPrevSiblings() {
+ let _key = this.key;
+ let sibling = this.getSibling(--_key);
+ const siblings = [];
+
+ while (sibling.node) {
+ siblings.push(sibling);
+ sibling = this.getSibling(--_key);
+ }
+
+ return siblings;
+}
+
+function get(key, context) {
+ if (context === true) context = this.context;
+ const parts = key.split(".");
+
+ if (parts.length === 1) {
+ return this._getKey(key, context);
+ } else {
+ return this._getPattern(parts, context);
+ }
+}
+
+function _getKey(key, context) {
+ const node = this.node;
+ const container = node[key];
+
+ if (Array.isArray(container)) {
+ return container.map((_, i) => {
+ return _index.default.get({
+ listKey: key,
+ parentPath: this,
+ parent: node,
+ container: container,
+ key: i
+ }).setContext(context);
+ });
+ } else {
+ return _index.default.get({
+ parentPath: this,
+ parent: node,
+ container: node,
+ key: key
+ }).setContext(context);
+ }
+}
+
+function _getPattern(parts, context) {
+ let path = this;
+ var _arr = parts;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const part = _arr[_i];
+
+ if (part === ".") {
+ path = path.parentPath;
+ } else {
+ if (Array.isArray(path)) {
+ path = path[part];
+ } else {
+ path = path.get(part, context);
+ }
+ }
+ }
+
+ return path;
+}
+
+function getBindingIdentifiers(duplicates) {
+ return t().getBindingIdentifiers(this.node, duplicates);
+}
+
+function getOuterBindingIdentifiers(duplicates) {
+ return t().getOuterBindingIdentifiers(this.node, duplicates);
+}
+
+function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
+ const path = this;
+ let search = [].concat(path);
+ const ids = Object.create(null);
+
+ while (search.length) {
+ const id = search.shift();
+ if (!id) continue;
+ if (!id.node) continue;
+ const keys = t().getBindingIdentifiers.keys[id.node.type];
+
+ if (id.isIdentifier()) {
+ if (duplicates) {
+ const _ids = ids[id.node.name] = ids[id.node.name] || [];
+
+ _ids.push(id);
+ } else {
+ ids[id.node.name] = id;
+ }
+
+ continue;
+ }
+
+ if (id.isExportDeclaration()) {
+ const declaration = id.get("declaration");
+
+ if (declaration.isDeclaration()) {
+ search.push(declaration);
+ }
+
+ continue;
+ }
+
+ if (outerOnly) {
+ if (id.isFunctionDeclaration()) {
+ search.push(id.get("id"));
+ continue;
+ }
+
+ if (id.isFunctionExpression()) {
+ continue;
+ }
+ }
+
+ if (keys) {
+ for (let i = 0; i < keys.length; i++) {
+ const key = keys[i];
+ const child = id.get(key);
+
+ if (Array.isArray(child) || child.node) {
+ search = search.concat(child);
+ }
+ }
+ }
+ }
+
+ return ids;
+}
+
+function getOuterBindingIdentifierPaths(duplicates) {
+ return this.getBindingIdentifierPaths(duplicates, true);
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/index.js b/node_modules/@babel/traverse/lib/path/index.js
new file mode 100644
index 00000000..2f0927eb
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/index.js
@@ -0,0 +1,228 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types"));
+
+function _debug() {
+ const data = _interopRequireDefault(require("debug"));
+
+ _debug = function _debug() {
+ return data;
+ };
+
+ return data;
+}
+
+function _invariant() {
+ const data = _interopRequireDefault(require("invariant"));
+
+ _invariant = function _invariant() {
+ return data;
+ };
+
+ return data;
+}
+
+var _index = _interopRequireDefault(require("../index"));
+
+var _scope = _interopRequireDefault(require("../scope"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+var _cache = require("../cache");
+
+function _generator() {
+ const data = _interopRequireDefault(require("@babel/generator"));
+
+ _generator = function _generator() {
+ return data;
+ };
+
+ return data;
+}
+
+var NodePath_ancestry = _interopRequireWildcard(require("./ancestry"));
+
+var NodePath_inference = _interopRequireWildcard(require("./inference"));
+
+var NodePath_replacement = _interopRequireWildcard(require("./replacement"));
+
+var NodePath_evaluation = _interopRequireWildcard(require("./evaluation"));
+
+var NodePath_conversion = _interopRequireWildcard(require("./conversion"));
+
+var NodePath_introspection = _interopRequireWildcard(require("./introspection"));
+
+var NodePath_context = _interopRequireWildcard(require("./context"));
+
+var NodePath_removal = _interopRequireWildcard(require("./removal"));
+
+var NodePath_modification = _interopRequireWildcard(require("./modification"));
+
+var NodePath_family = _interopRequireWildcard(require("./family"));
+
+var NodePath_comments = _interopRequireWildcard(require("./comments"));
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+const debug = (0, _debug().default)("babel");
+
+class NodePath {
+ constructor(hub, parent) {
+ this.parent = parent;
+ this.hub = hub;
+ this.contexts = [];
+ this.data = {};
+ this.shouldSkip = false;
+ this.shouldStop = false;
+ this.removed = false;
+ this.state = null;
+ this.opts = null;
+ this.skipKeys = null;
+ this.parentPath = null;
+ this.context = null;
+ this.container = null;
+ this.listKey = null;
+ this.inList = false;
+ this.parentKey = null;
+ this.key = null;
+ this.node = null;
+ this.scope = null;
+ this.type = null;
+ this.typeAnnotation = null;
+ }
+
+ static get({
+ hub,
+ parentPath,
+ parent,
+ container,
+ listKey,
+ key
+ }) {
+ if (!hub && parentPath) {
+ hub = parentPath.hub;
+ }
+
+ (0, _invariant().default)(parent, "To get a node path the parent needs to exist");
+ const targetNode = container[key];
+ const paths = _cache.path.get(parent) || [];
+
+ if (!_cache.path.has(parent)) {
+ _cache.path.set(parent, paths);
+ }
+
+ let path;
+
+ for (let i = 0; i < paths.length; i++) {
+ const pathCheck = paths[i];
+
+ if (pathCheck.node === targetNode) {
+ path = pathCheck;
+ break;
+ }
+ }
+
+ if (!path) {
+ path = new NodePath(hub, parent);
+ paths.push(path);
+ }
+
+ path.setup(parentPath, container, listKey, key);
+ return path;
+ }
+
+ getScope(scope) {
+ return this.isScope() ? new _scope.default(this) : scope;
+ }
+
+ setData(key, val) {
+ return this.data[key] = val;
+ }
+
+ getData(key, def) {
+ let val = this.data[key];
+ if (!val && def) val = this.data[key] = def;
+ return val;
+ }
+
+ buildCodeFrameError(msg, Error = SyntaxError) {
+ return this.hub.file.buildCodeFrameError(this.node, msg, Error);
+ }
+
+ traverse(visitor, state) {
+ (0, _index.default)(this.node, visitor, this.scope, state, this);
+ }
+
+ set(key, node) {
+ t().validate(this.node, key, node);
+ this.node[key] = node;
+ }
+
+ getPathLocation() {
+ const parts = [];
+ let path = this;
+
+ do {
+ let key = path.key;
+ if (path.inList) key = `${path.listKey}[${key}]`;
+ parts.unshift(key);
+ } while (path = path.parentPath);
+
+ return parts.join(".");
+ }
+
+ debug(message) {
+ if (!debug.enabled) return;
+ debug(`${this.getPathLocation()} ${this.type}: ${message}`);
+ }
+
+ toString() {
+ return (0, _generator().default)(this.node).code;
+ }
+
+}
+
+exports.default = NodePath;
+Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments);
+var _arr = t().TYPES;
+
+for (var _i = 0; _i < _arr.length; _i++) {
+ const type = _arr[_i];
+ const typeKey = `is${type}`;
+ const fn = t()[typeKey];
+
+ NodePath.prototype[typeKey] = function (opts) {
+ return fn(this.node, opts);
+ };
+
+ NodePath.prototype[`assert${type}`] = function (opts) {
+ if (!fn(this.node, opts)) {
+ throw new TypeError(`Expected node path of type ${type}`);
+ }
+ };
+}
+
+for (const type in virtualTypes) {
+ if (type[0] === "_") continue;
+ if (t().TYPES.indexOf(type) < 0) t().TYPES.push(type);
+ const virtualType = virtualTypes[type];
+
+ NodePath.prototype[`is${type}`] = function (opts) {
+ return virtualType.checkPath(this, opts);
+ };
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/inference/index.js b/node_modules/@babel/traverse/lib/path/inference/index.js
new file mode 100644
index 00000000..d6e565c7
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/inference/index.js
@@ -0,0 +1,136 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.getTypeAnnotation = getTypeAnnotation;
+exports._getTypeAnnotation = _getTypeAnnotation;
+exports.isBaseType = isBaseType;
+exports.couldBeBaseType = couldBeBaseType;
+exports.baseTypeStrictlyMatches = baseTypeStrictlyMatches;
+exports.isGenericType = isGenericType;
+
+var inferers = _interopRequireWildcard(require("./inferers"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function getTypeAnnotation() {
+ if (this.typeAnnotation) return this.typeAnnotation;
+ let type = this._getTypeAnnotation() || t().anyTypeAnnotation();
+ if (t().isTypeAnnotation(type)) type = type.typeAnnotation;
+ return this.typeAnnotation = type;
+}
+
+function _getTypeAnnotation() {
+ const node = this.node;
+
+ if (!node) {
+ if (this.key === "init" && this.parentPath.isVariableDeclarator()) {
+ const declar = this.parentPath.parentPath;
+ const declarParent = declar.parentPath;
+
+ if (declar.key === "left" && declarParent.isForInStatement()) {
+ return t().stringTypeAnnotation();
+ }
+
+ if (declar.key === "left" && declarParent.isForOfStatement()) {
+ return t().anyTypeAnnotation();
+ }
+
+ return t().voidTypeAnnotation();
+ } else {
+ return;
+ }
+ }
+
+ if (node.typeAnnotation) {
+ return node.typeAnnotation;
+ }
+
+ let inferer = inferers[node.type];
+
+ if (inferer) {
+ return inferer.call(this, node);
+ }
+
+ inferer = inferers[this.parentPath.type];
+
+ if (inferer && inferer.validParent) {
+ return this.parentPath.getTypeAnnotation();
+ }
+}
+
+function isBaseType(baseName, soft) {
+ return _isBaseType(baseName, this.getTypeAnnotation(), soft);
+}
+
+function _isBaseType(baseName, type, soft) {
+ if (baseName === "string") {
+ return t().isStringTypeAnnotation(type);
+ } else if (baseName === "number") {
+ return t().isNumberTypeAnnotation(type);
+ } else if (baseName === "boolean") {
+ return t().isBooleanTypeAnnotation(type);
+ } else if (baseName === "any") {
+ return t().isAnyTypeAnnotation(type);
+ } else if (baseName === "mixed") {
+ return t().isMixedTypeAnnotation(type);
+ } else if (baseName === "empty") {
+ return t().isEmptyTypeAnnotation(type);
+ } else if (baseName === "void") {
+ return t().isVoidTypeAnnotation(type);
+ } else {
+ if (soft) {
+ return false;
+ } else {
+ throw new Error(`Unknown base type ${baseName}`);
+ }
+ }
+}
+
+function couldBeBaseType(name) {
+ const type = this.getTypeAnnotation();
+ if (t().isAnyTypeAnnotation(type)) return true;
+
+ if (t().isUnionTypeAnnotation(type)) {
+ var _arr = type.types;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const type2 = _arr[_i];
+
+ if (t().isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
+ return true;
+ }
+ }
+
+ return false;
+ } else {
+ return _isBaseType(name, type, true);
+ }
+}
+
+function baseTypeStrictlyMatches(right) {
+ const left = this.getTypeAnnotation();
+ right = right.getTypeAnnotation();
+
+ if (!t().isAnyTypeAnnotation(left) && t().isFlowBaseAnnotation(left)) {
+ return right.type === left.type;
+ }
+}
+
+function isGenericType(genericName) {
+ const type = this.getTypeAnnotation();
+ return t().isGenericTypeAnnotation(type) && t().isIdentifier(type.id, {
+ name: genericName
+ });
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js b/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js
new file mode 100644
index 00000000..32f6bce5
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js
@@ -0,0 +1,183 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _default;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _default(node) {
+ if (!this.isReferenced()) return;
+ const binding = this.scope.getBinding(node.name);
+
+ if (binding) {
+ if (binding.identifier.typeAnnotation) {
+ return binding.identifier.typeAnnotation;
+ } else {
+ return getTypeAnnotationBindingConstantViolations(binding, this, node.name);
+ }
+ }
+
+ if (node.name === "undefined") {
+ return t().voidTypeAnnotation();
+ } else if (node.name === "NaN" || node.name === "Infinity") {
+ return t().numberTypeAnnotation();
+ } else if (node.name === "arguments") {}
+}
+
+function getTypeAnnotationBindingConstantViolations(binding, path, name) {
+ const types = [];
+ const functionConstantViolations = [];
+ let constantViolations = getConstantViolationsBefore(binding, path, functionConstantViolations);
+ const testType = getConditionalAnnotation(binding, path, name);
+
+ if (testType) {
+ const testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
+ constantViolations = constantViolations.filter(path => testConstantViolations.indexOf(path) < 0);
+ types.push(testType.typeAnnotation);
+ }
+
+ if (constantViolations.length) {
+ constantViolations = constantViolations.concat(functionConstantViolations);
+ var _arr = constantViolations;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const violation = _arr[_i];
+ types.push(violation.getTypeAnnotation());
+ }
+ }
+
+ if (types.length) {
+ return t().createUnionTypeAnnotation(types);
+ }
+}
+
+function getConstantViolationsBefore(binding, path, functions) {
+ const violations = binding.constantViolations.slice();
+ violations.unshift(binding.path);
+ return violations.filter(violation => {
+ violation = violation.resolve();
+
+ const status = violation._guessExecutionStatusRelativeTo(path);
+
+ if (functions && status === "function") functions.push(violation);
+ return status === "before";
+ });
+}
+
+function inferAnnotationFromBinaryExpression(name, path) {
+ const operator = path.node.operator;
+ const right = path.get("right").resolve();
+ const left = path.get("left").resolve();
+ let target;
+
+ if (left.isIdentifier({
+ name
+ })) {
+ target = right;
+ } else if (right.isIdentifier({
+ name
+ })) {
+ target = left;
+ }
+
+ if (target) {
+ if (operator === "===") {
+ return target.getTypeAnnotation();
+ }
+
+ if (t().BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().numberTypeAnnotation();
+ }
+
+ return;
+ }
+
+ if (operator !== "===" && operator !== "==") return;
+ let typeofPath;
+ let typePath;
+
+ if (left.isUnaryExpression({
+ operator: "typeof"
+ })) {
+ typeofPath = left;
+ typePath = right;
+ } else if (right.isUnaryExpression({
+ operator: "typeof"
+ })) {
+ typeofPath = right;
+ typePath = left;
+ }
+
+ if (!typeofPath) return;
+ if (!typeofPath.get("argument").isIdentifier({
+ name
+ })) return;
+ typePath = typePath.resolve();
+ if (!typePath.isLiteral()) return;
+ const typeValue = typePath.node.value;
+ if (typeof typeValue !== "string") return;
+ return t().createTypeAnnotationBasedOnTypeof(typeValue);
+}
+
+function getParentConditionalPath(binding, path, name) {
+ let parentPath;
+
+ while (parentPath = path.parentPath) {
+ if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {
+ if (path.key === "test") {
+ return;
+ }
+
+ return parentPath;
+ }
+
+ if (parentPath.isFunction()) {
+ if (parentPath.parentPath.scope.getBinding(name) !== binding) return;
+ }
+
+ path = parentPath;
+ }
+}
+
+function getConditionalAnnotation(binding, path, name) {
+ const ifStatement = getParentConditionalPath(binding, path, name);
+ if (!ifStatement) return;
+ const test = ifStatement.get("test");
+ const paths = [test];
+ const types = [];
+
+ for (let i = 0; i < paths.length; i++) {
+ const path = paths[i];
+
+ if (path.isLogicalExpression()) {
+ if (path.node.operator === "&&") {
+ paths.push(path.get("left"));
+ paths.push(path.get("right"));
+ }
+ } else if (path.isBinaryExpression()) {
+ const type = inferAnnotationFromBinaryExpression(name, path);
+ if (type) types.push(type);
+ }
+ }
+
+ if (types.length) {
+ return {
+ typeAnnotation: t().createUnionTypeAnnotation(types),
+ ifStatement
+ };
+ }
+
+ return getConditionalAnnotation(ifStatement, name);
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/inference/inferers.js b/node_modules/@babel/traverse/lib/path/inference/inferers.js
new file mode 100644
index 00000000..fe224058
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/inference/inferers.js
@@ -0,0 +1,220 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.VariableDeclarator = VariableDeclarator;
+exports.TypeCastExpression = TypeCastExpression;
+exports.NewExpression = NewExpression;
+exports.TemplateLiteral = TemplateLiteral;
+exports.UnaryExpression = UnaryExpression;
+exports.BinaryExpression = BinaryExpression;
+exports.LogicalExpression = LogicalExpression;
+exports.ConditionalExpression = ConditionalExpression;
+exports.SequenceExpression = SequenceExpression;
+exports.AssignmentExpression = AssignmentExpression;
+exports.UpdateExpression = UpdateExpression;
+exports.StringLiteral = StringLiteral;
+exports.NumericLiteral = NumericLiteral;
+exports.BooleanLiteral = BooleanLiteral;
+exports.NullLiteral = NullLiteral;
+exports.RegExpLiteral = RegExpLiteral;
+exports.ObjectExpression = ObjectExpression;
+exports.ArrayExpression = ArrayExpression;
+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;
+ }
+});
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function VariableDeclarator() {
+ const id = this.get("id");
+ if (!id.isIdentifier()) return;
+ const init = this.get("init");
+ let type = init.getTypeAnnotation();
+
+ if (type && type.type === "AnyTypeAnnotation") {
+ if (init.isCallExpression() && init.get("callee").isIdentifier({
+ name: "Array"
+ }) && !init.scope.hasBinding("Array", true)) {
+ type = ArrayExpression();
+ }
+ }
+
+ return type;
+}
+
+function TypeCastExpression(node) {
+ return node.typeAnnotation;
+}
+
+TypeCastExpression.validParent = true;
+
+function NewExpression(node) {
+ if (this.get("callee").isIdentifier()) {
+ return t().genericTypeAnnotation(node.callee);
+ }
+}
+
+function TemplateLiteral() {
+ return t().stringTypeAnnotation();
+}
+
+function UnaryExpression(node) {
+ const operator = node.operator;
+
+ if (operator === "void") {
+ return t().voidTypeAnnotation();
+ } else if (t().NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().numberTypeAnnotation();
+ } else if (t().STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().stringTypeAnnotation();
+ } else if (t().BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().booleanTypeAnnotation();
+ }
+}
+
+function BinaryExpression(node) {
+ const operator = node.operator;
+
+ if (t().NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().numberTypeAnnotation();
+ } else if (t().BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
+ return t().booleanTypeAnnotation();
+ } else if (operator === "+") {
+ const right = this.get("right");
+ const left = this.get("left");
+
+ if (left.isBaseType("number") && right.isBaseType("number")) {
+ return t().numberTypeAnnotation();
+ } else if (left.isBaseType("string") || right.isBaseType("string")) {
+ return t().stringTypeAnnotation();
+ }
+
+ return t().unionTypeAnnotation([t().stringTypeAnnotation(), t().numberTypeAnnotation()]);
+ }
+}
+
+function LogicalExpression() {
+ return t().createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
+}
+
+function ConditionalExpression() {
+ return t().createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
+}
+
+function SequenceExpression() {
+ return this.get("expressions").pop().getTypeAnnotation();
+}
+
+function AssignmentExpression() {
+ return this.get("right").getTypeAnnotation();
+}
+
+function UpdateExpression(node) {
+ const operator = node.operator;
+
+ if (operator === "++" || operator === "--") {
+ return t().numberTypeAnnotation();
+ }
+}
+
+function StringLiteral() {
+ return t().stringTypeAnnotation();
+}
+
+function NumericLiteral() {
+ return t().numberTypeAnnotation();
+}
+
+function BooleanLiteral() {
+ return t().booleanTypeAnnotation();
+}
+
+function NullLiteral() {
+ return t().nullLiteralTypeAnnotation();
+}
+
+function RegExpLiteral() {
+ return t().genericTypeAnnotation(t().identifier("RegExp"));
+}
+
+function ObjectExpression() {
+ return t().genericTypeAnnotation(t().identifier("Object"));
+}
+
+function ArrayExpression() {
+ return t().genericTypeAnnotation(t().identifier("Array"));
+}
+
+function RestElement() {
+ return ArrayExpression();
+}
+
+RestElement.validParent = true;
+
+function Func() {
+ return t().genericTypeAnnotation(t().identifier("Function"));
+}
+
+const isArrayFrom = t().buildMatchMemberExpression("Array.from");
+const isObjectKeys = t().buildMatchMemberExpression("Object.keys");
+const isObjectValues = t().buildMatchMemberExpression("Object.values");
+const isObjectEntries = t().buildMatchMemberExpression("Object.entries");
+
+function CallExpression() {
+ const callee = this.node.callee;
+
+ if (isObjectKeys(callee)) {
+ return t().arrayTypeAnnotation(t().stringTypeAnnotation());
+ } else if (isArrayFrom(callee) || isObjectValues(callee)) {
+ return t().arrayTypeAnnotation(t().anyTypeAnnotation());
+ } else if (isObjectEntries(callee)) {
+ return t().arrayTypeAnnotation(t().tupleTypeAnnotation([t().stringTypeAnnotation(), t().anyTypeAnnotation()]));
+ }
+
+ return resolveCall(this.get("callee"));
+}
+
+function TaggedTemplateExpression() {
+ return resolveCall(this.get("tag"));
+}
+
+function resolveCall(callee) {
+ callee = callee.resolve();
+
+ if (callee.isFunction()) {
+ if (callee.is("async")) {
+ if (callee.is("generator")) {
+ return t().genericTypeAnnotation(t().identifier("AsyncIterator"));
+ } else {
+ return t().genericTypeAnnotation(t().identifier("Promise"));
+ }
+ } else {
+ if (callee.node.returnType) {
+ return callee.node.returnType;
+ } else {}
+ }
+ }
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/introspection.js b/node_modules/@babel/traverse/lib/path/introspection.js
new file mode 100644
index 00000000..6177b65c
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/introspection.js
@@ -0,0 +1,412 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.matchesPattern = matchesPattern;
+exports.has = has;
+exports.isStatic = isStatic;
+exports.isnt = isnt;
+exports.equals = equals;
+exports.isNodeType = isNodeType;
+exports.canHaveVariableDeclarationOrExpression = canHaveVariableDeclarationOrExpression;
+exports.canSwapBetweenExpressionAndStatement = canSwapBetweenExpressionAndStatement;
+exports.isCompletionRecord = isCompletionRecord;
+exports.isStatementOrBlock = isStatementOrBlock;
+exports.referencesImport = referencesImport;
+exports.getSource = getSource;
+exports.willIMaybeExecuteBefore = willIMaybeExecuteBefore;
+exports._guessExecutionStatusRelativeTo = _guessExecutionStatusRelativeTo;
+exports._guessExecutionStatusRelativeToDifferentFunctions = _guessExecutionStatusRelativeToDifferentFunctions;
+exports.resolve = resolve;
+exports._resolve = _resolve;
+exports.isConstantExpression = isConstantExpression;
+exports.isInStrictMode = isInStrictMode;
+exports.is = void 0;
+
+function _includes() {
+ const data = _interopRequireDefault(require("lodash/includes"));
+
+ _includes = function _includes() {
+ return data;
+ };
+
+ return data;
+}
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function matchesPattern(pattern, allowPartial) {
+ return t().matchesPattern(this.node, pattern, allowPartial);
+}
+
+function has(key) {
+ const val = this.node && this.node[key];
+
+ if (val && Array.isArray(val)) {
+ return !!val.length;
+ } else {
+ return !!val;
+ }
+}
+
+function isStatic() {
+ return this.scope.isStatic(this.node);
+}
+
+const is = has;
+exports.is = is;
+
+function isnt(key) {
+ return !this.has(key);
+}
+
+function equals(key, value) {
+ return this.node[key] === value;
+}
+
+function isNodeType(type) {
+ return t().isType(this.type, type);
+}
+
+function canHaveVariableDeclarationOrExpression() {
+ return (this.key === "init" || this.key === "left") && this.parentPath.isFor();
+}
+
+function canSwapBetweenExpressionAndStatement(replacement) {
+ if (this.key !== "body" || !this.parentPath.isArrowFunctionExpression()) {
+ return false;
+ }
+
+ if (this.isExpression()) {
+ return t().isBlockStatement(replacement);
+ } else if (this.isBlockStatement()) {
+ return t().isExpression(replacement);
+ }
+
+ return false;
+}
+
+function isCompletionRecord(allowInsideFunction) {
+ let path = this;
+ let first = true;
+
+ do {
+ const container = path.container;
+
+ if (path.isFunction() && !first) {
+ return !!allowInsideFunction;
+ }
+
+ first = false;
+
+ if (Array.isArray(container) && path.key !== container.length - 1) {
+ return false;
+ }
+ } while ((path = path.parentPath) && !path.isProgram());
+
+ return true;
+}
+
+function isStatementOrBlock() {
+ if (this.parentPath.isLabeledStatement() || t().isBlockStatement(this.container)) {
+ return false;
+ } else {
+ return (0, _includes().default)(t().STATEMENT_OR_BLOCK_KEYS, this.key);
+ }
+}
+
+function referencesImport(moduleSource, importName) {
+ if (!this.isReferencedIdentifier()) return false;
+ const binding = this.scope.getBinding(this.node.name);
+ if (!binding || binding.kind !== "module") return false;
+ const path = binding.path;
+ const parent = path.parentPath;
+ if (!parent.isImportDeclaration()) return false;
+
+ if (parent.node.source.value === moduleSource) {
+ if (!importName) return true;
+ } else {
+ return false;
+ }
+
+ if (path.isImportDefaultSpecifier() && importName === "default") {
+ return true;
+ }
+
+ if (path.isImportNamespaceSpecifier() && importName === "*") {
+ return true;
+ }
+
+ if (path.isImportSpecifier() && path.node.imported.name === importName) {
+ return true;
+ }
+
+ return false;
+}
+
+function getSource() {
+ const node = this.node;
+
+ if (node.end) {
+ return this.hub.file.code.slice(node.start, node.end);
+ } else {
+ return "";
+ }
+}
+
+function willIMaybeExecuteBefore(target) {
+ return this._guessExecutionStatusRelativeTo(target) !== "after";
+}
+
+function _guessExecutionStatusRelativeTo(target) {
+ const targetFuncParent = target.scope.getFunctionParent() || target.scope.getProgramParent();
+ const selfFuncParent = this.scope.getFunctionParent() || target.scope.getProgramParent();
+
+ if (targetFuncParent.node !== selfFuncParent.node) {
+ const status = this._guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent);
+
+ if (status) {
+ return status;
+ } else {
+ target = targetFuncParent.path;
+ }
+ }
+
+ const targetPaths = target.getAncestry();
+ if (targetPaths.indexOf(this) >= 0) return "after";
+ const selfPaths = this.getAncestry();
+ let commonPath;
+ let targetIndex;
+ let selfIndex;
+
+ for (selfIndex = 0; selfIndex < selfPaths.length; selfIndex++) {
+ const selfPath = selfPaths[selfIndex];
+ targetIndex = targetPaths.indexOf(selfPath);
+
+ if (targetIndex >= 0) {
+ commonPath = selfPath;
+ break;
+ }
+ }
+
+ if (!commonPath) {
+ return "before";
+ }
+
+ const targetRelationship = targetPaths[targetIndex - 1];
+ const selfRelationship = selfPaths[selfIndex - 1];
+
+ if (!targetRelationship || !selfRelationship) {
+ return "before";
+ }
+
+ if (targetRelationship.listKey && targetRelationship.container === selfRelationship.container) {
+ return targetRelationship.key > selfRelationship.key ? "before" : "after";
+ }
+
+ const keys = t().VISITOR_KEYS[commonPath.type];
+ const targetKeyPosition = keys.indexOf(targetRelationship.key);
+ const selfKeyPosition = keys.indexOf(selfRelationship.key);
+ return targetKeyPosition > selfKeyPosition ? "before" : "after";
+}
+
+function _guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent) {
+ const targetFuncPath = targetFuncParent.path;
+ if (!targetFuncPath.isFunctionDeclaration()) return;
+ const binding = targetFuncPath.scope.getBinding(targetFuncPath.node.id.name);
+ if (!binding.references) return "before";
+ const referencePaths = binding.referencePaths;
+
+ for (var _iterator = referencePaths, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const path = _ref;
+
+ if (path.key !== "callee" || !path.parentPath.isCallExpression()) {
+ return;
+ }
+ }
+
+ let allStatus;
+
+ for (var _iterator2 = referencePaths, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+
+ const path = _ref2;
+ const childOfFunction = !!path.find(path => path.node === targetFuncPath.node);
+ if (childOfFunction) continue;
+
+ const status = this._guessExecutionStatusRelativeTo(path);
+
+ if (allStatus) {
+ if (allStatus !== status) return;
+ } else {
+ allStatus = status;
+ }
+ }
+
+ return allStatus;
+}
+
+function resolve(dangerous, resolved) {
+ return this._resolve(dangerous, resolved) || this;
+}
+
+function _resolve(dangerous, resolved) {
+ if (resolved && resolved.indexOf(this) >= 0) return;
+ resolved = resolved || [];
+ resolved.push(this);
+
+ if (this.isVariableDeclarator()) {
+ if (this.get("id").isIdentifier()) {
+ return this.get("init").resolve(dangerous, resolved);
+ } else {}
+ } else if (this.isReferencedIdentifier()) {
+ const binding = this.scope.getBinding(this.node.name);
+ if (!binding) return;
+ if (!binding.constant) return;
+ if (binding.kind === "module") return;
+
+ if (binding.path !== this) {
+ const ret = binding.path.resolve(dangerous, resolved);
+ if (this.find(parent => parent.node === ret.node)) return;
+ return ret;
+ }
+ } else if (this.isTypeCastExpression()) {
+ return this.get("expression").resolve(dangerous, resolved);
+ } else if (dangerous && this.isMemberExpression()) {
+ const targetKey = this.toComputedKey();
+ if (!t().isLiteral(targetKey)) return;
+ const targetName = targetKey.value;
+ const target = this.get("object").resolve(dangerous, resolved);
+
+ if (target.isObjectExpression()) {
+ const props = target.get("properties");
+ var _arr = props;
+
+ for (var _i3 = 0; _i3 < _arr.length; _i3++) {
+ const prop = _arr[_i3];
+ if (!prop.isProperty()) continue;
+ const key = prop.get("key");
+ let match = prop.isnt("computed") && key.isIdentifier({
+ name: targetName
+ });
+ match = match || key.isLiteral({
+ value: targetName
+ });
+ if (match) return prop.get("value").resolve(dangerous, resolved);
+ }
+ } else if (target.isArrayExpression() && !isNaN(+targetName)) {
+ const elems = target.get("elements");
+ const elem = elems[targetName];
+ if (elem) return elem.resolve(dangerous, resolved);
+ }
+ }
+}
+
+function isConstantExpression() {
+ if (this.isIdentifier()) {
+ const binding = this.scope.getBinding(this.node.name);
+
+ if (!binding) {
+ return false;
+ }
+
+ return binding.constant && binding.path.get("init").isConstantExpression();
+ }
+
+ if (this.isLiteral()) {
+ if (this.isRegExpLiteral()) {
+ return false;
+ }
+
+ if (this.isTemplateLiteral()) {
+ return this.get("expressions").every(expression => expression.isConstantExpression());
+ }
+
+ return true;
+ }
+
+ if (this.isUnaryExpression()) {
+ if (this.get("operator").node !== "void") {
+ return false;
+ }
+
+ return this.get("argument").isConstantExpression();
+ }
+
+ if (this.isBinaryExpression()) {
+ return this.get("left").isConstantExpression() && this.get("right").isConstantExpression();
+ }
+
+ return false;
+}
+
+function isInStrictMode() {
+ const start = this.isProgram() ? this : this.parentPath;
+ const strictParent = start.find(path => {
+ if (path.isProgram({
+ sourceType: "module"
+ })) return true;
+ if (path.isClass()) return true;
+ if (!path.isProgram() && !path.isFunction()) return false;
+
+ if (path.isArrowFunctionExpression() && !path.get("body").isBlockStatement()) {
+ return false;
+ }
+
+ let node = path.node;
+ if (path.isFunction()) node = node.body;
+
+ for (var _iterator3 = node.directives, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
+ var _ref3;
+
+ if (_isArray3) {
+ if (_i4 >= _iterator3.length) break;
+ _ref3 = _iterator3[_i4++];
+ } else {
+ _i4 = _iterator3.next();
+ if (_i4.done) break;
+ _ref3 = _i4.value;
+ }
+
+ const directive = _ref3;
+
+ if (directive.value.value === "use strict") {
+ return true;
+ }
+ }
+ });
+ return !!strictParent;
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/lib/hoister.js b/node_modules/@babel/traverse/lib/path/lib/hoister.js
new file mode 100644
index 00000000..94809727
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/lib/hoister.js
@@ -0,0 +1,194 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+const referenceVisitor = {
+ ReferencedIdentifier(path, state) {
+ if (path.isJSXIdentifier() && t().react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
+ return;
+ }
+
+ if (path.node.name === "this") {
+ let scope = path.scope;
+
+ do {
+ if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
+ break;
+ }
+ } while (scope = scope.parent);
+
+ if (scope) state.breakOnScopePaths.push(scope.path);
+ }
+
+ const binding = path.scope.getBinding(path.node.name);
+ if (!binding) return;
+ if (binding !== state.scope.getBinding(path.node.name)) return;
+ state.bindings[path.node.name] = binding;
+ }
+
+};
+
+class PathHoister {
+ constructor(path, scope) {
+ this.breakOnScopePaths = [];
+ this.bindings = {};
+ this.scopes = [];
+ this.scope = scope;
+ this.path = path;
+ this.attachAfter = false;
+ }
+
+ isCompatibleScope(scope) {
+ for (const key in this.bindings) {
+ const binding = this.bindings[key];
+
+ if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ getCompatibleScopes() {
+ let scope = this.path.scope;
+
+ do {
+ if (this.isCompatibleScope(scope)) {
+ this.scopes.push(scope);
+ } else {
+ break;
+ }
+
+ if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
+ break;
+ }
+ } while (scope = scope.parent);
+ }
+
+ getAttachmentPath() {
+ let path = this._getAttachmentPath();
+
+ if (!path) return;
+ let targetScope = path.scope;
+
+ if (targetScope.path === path) {
+ targetScope = path.scope.parent;
+ }
+
+ if (targetScope.path.isProgram() || targetScope.path.isFunction()) {
+ for (const name in this.bindings) {
+ if (!targetScope.hasOwnBinding(name)) continue;
+ const binding = this.bindings[name];
+
+ if (binding.kind === "param" || binding.path.parentKey === "params") {
+ continue;
+ }
+
+ const bindingParentPath = this.getAttachmentParentForPath(binding.path);
+
+ if (bindingParentPath.key >= path.key) {
+ this.attachAfter = true;
+ path = binding.path;
+ var _arr = binding.constantViolations;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const violationPath = _arr[_i];
+
+ if (this.getAttachmentParentForPath(violationPath).key > path.key) {
+ path = violationPath;
+ }
+ }
+ }
+ }
+ }
+
+ return path;
+ }
+
+ _getAttachmentPath() {
+ const scopes = this.scopes;
+ const scope = scopes.pop();
+ if (!scope) return;
+
+ if (scope.path.isFunction()) {
+ if (this.hasOwnParamBindings(scope)) {
+ if (this.scope === scope) return;
+ const bodies = scope.path.get("body").get("body");
+
+ for (let i = 0; i < bodies.length; i++) {
+ if (bodies[i].node._blockHoist) continue;
+ return bodies[i];
+ }
+ } else {
+ return this.getNextScopeAttachmentParent();
+ }
+ } else if (scope.path.isProgram()) {
+ return this.getNextScopeAttachmentParent();
+ }
+ }
+
+ getNextScopeAttachmentParent() {
+ const scope = this.scopes.pop();
+ if (scope) return this.getAttachmentParentForPath(scope.path);
+ }
+
+ getAttachmentParentForPath(path) {
+ do {
+ if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
+ return path;
+ }
+ } while (path = path.parentPath);
+ }
+
+ hasOwnParamBindings(scope) {
+ for (const name in this.bindings) {
+ if (!scope.hasOwnBinding(name)) continue;
+ const binding = this.bindings[name];
+ if (binding.kind === "param" && binding.constant) return true;
+ }
+
+ return false;
+ }
+
+ run() {
+ this.path.traverse(referenceVisitor, this);
+ this.getCompatibleScopes();
+ const attachTo = this.getAttachmentPath();
+ if (!attachTo) return;
+ if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
+ let uid = attachTo.scope.generateUidIdentifier("ref");
+ const declarator = t().variableDeclarator(uid, this.path.node);
+ const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
+
+ const _attachTo$insertFn = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t().variableDeclaration("var", [declarator])]),
+ attached = _attachTo$insertFn[0];
+
+ const parent = this.path.parentPath;
+
+ if (parent.isJSXElement() && this.path.container === parent.node.children) {
+ uid = t().JSXExpressionContainer(uid);
+ }
+
+ this.path.replaceWith(t().cloneNode(uid));
+ return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
+ }
+
+}
+
+exports.default = PathHoister; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js b/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
new file mode 100644
index 00000000..23ec8fe6
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
@@ -0,0 +1,38 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.hooks = void 0;
+const hooks = [function (self, parent) {
+ const 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();
+
+ if (removeParent) {
+ parent.remove();
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
+ parent.replaceWith(parent.node.expressions[0]);
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isBinary()) {
+ if (self.key === "left") {
+ parent.replaceWith(parent.node.right);
+ } else {
+ parent.replaceWith(parent.node.left);
+ }
+
+ return true;
+ }
+}, function (self, parent) {
+ if (parent.isIfStatement() && (self.key === "consequent" || self.key === "alternate") || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
+ self.replaceWith({
+ type: "BlockStatement",
+ body: []
+ });
+ return true;
+ }
+}];
+exports.hooks = hooks; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/lib/virtual-types.js b/node_modules/@babel/traverse/lib/path/lib/virtual-types.js
new file mode 100644
index 00000000..904b0d0d
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/lib/virtual-types.js
@@ -0,0 +1,212 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: 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 = void 0;
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+const ReferencedIdentifier = {
+ types: ["Identifier", "JSXIdentifier"],
+
+ checkPath({
+ node,
+ parent
+ }, opts) {
+ if (!t().isIdentifier(node, opts) && !t().isJSXMemberExpression(parent, opts)) {
+ if (t().isJSXIdentifier(node, opts)) {
+ if (t().react.isCompatTag(node.name)) return false;
+ } else {
+ return false;
+ }
+ }
+
+ return t().isReferenced(node, parent);
+ }
+
+};
+exports.ReferencedIdentifier = ReferencedIdentifier;
+const ReferencedMemberExpression = {
+ types: ["MemberExpression"],
+
+ checkPath({
+ node,
+ parent
+ }) {
+ return t().isMemberExpression(node) && t().isReferenced(node, parent);
+ }
+
+};
+exports.ReferencedMemberExpression = ReferencedMemberExpression;
+const BindingIdentifier = {
+ types: ["Identifier"],
+
+ checkPath({
+ node,
+ parent
+ }) {
+ return t().isIdentifier(node) && t().isBinding(node, parent);
+ }
+
+};
+exports.BindingIdentifier = BindingIdentifier;
+const Statement = {
+ types: ["Statement"],
+
+ checkPath({
+ node,
+ parent
+ }) {
+ if (t().isStatement(node)) {
+ if (t().isVariableDeclaration(node)) {
+ if (t().isForXStatement(parent, {
+ left: node
+ })) return false;
+ if (t().isForStatement(parent, {
+ init: node
+ })) return false;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+};
+exports.Statement = Statement;
+const Expression = {
+ types: ["Expression"],
+
+ checkPath(path) {
+ if (path.isIdentifier()) {
+ return path.isReferencedIdentifier();
+ } else {
+ return t().isExpression(path.node);
+ }
+ }
+
+};
+exports.Expression = Expression;
+const Scope = {
+ types: ["Scopable"],
+
+ checkPath(path) {
+ return t().isScope(path.node, path.parent);
+ }
+
+};
+exports.Scope = Scope;
+const Referenced = {
+ checkPath(path) {
+ return t().isReferenced(path.node, path.parent);
+ }
+
+};
+exports.Referenced = Referenced;
+const BlockScoped = {
+ checkPath(path) {
+ return t().isBlockScoped(path.node);
+ }
+
+};
+exports.BlockScoped = BlockScoped;
+const Var = {
+ types: ["VariableDeclaration"],
+
+ checkPath(path) {
+ return t().isVar(path.node);
+ }
+
+};
+exports.Var = Var;
+const User = {
+ checkPath(path) {
+ return path.node && !!path.node.loc;
+ }
+
+};
+exports.User = User;
+const Generated = {
+ checkPath(path) {
+ return !path.isUser();
+ }
+
+};
+exports.Generated = Generated;
+const Pure = {
+ checkPath(path, opts) {
+ return path.scope.isPure(path.node, opts);
+ }
+
+};
+exports.Pure = Pure;
+const Flow = {
+ types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],
+
+ checkPath({
+ node
+ }) {
+ if (t().isFlow(node)) {
+ return true;
+ } else if (t().isImportDeclaration(node)) {
+ return node.importKind === "type" || node.importKind === "typeof";
+ } else if (t().isExportDeclaration(node)) {
+ return node.exportKind === "type";
+ } else if (t().isImportSpecifier(node)) {
+ return node.importKind === "type" || node.importKind === "typeof";
+ } else {
+ return false;
+ }
+ }
+
+};
+exports.Flow = Flow;
+const RestProperty = {
+ types: ["RestElement"],
+
+ checkPath(path) {
+ return path.parentPath && path.parentPath.isObjectPattern();
+ }
+
+};
+exports.RestProperty = RestProperty;
+const SpreadProperty = {
+ types: ["RestElement"],
+
+ checkPath(path) {
+ return path.parentPath && path.parentPath.isObjectExpression();
+ }
+
+};
+exports.SpreadProperty = SpreadProperty;
+const ExistentialTypeParam = {
+ types: ["ExistsTypeAnnotation"]
+};
+exports.ExistentialTypeParam = ExistentialTypeParam;
+const NumericLiteralTypeAnnotation = {
+ types: ["NumberLiteralTypeAnnotation"]
+};
+exports.NumericLiteralTypeAnnotation = NumericLiteralTypeAnnotation;
+const ForAwaitStatement = {
+ types: ["ForOfStatement"],
+
+ checkPath({
+ node
+ }) {
+ return node.await === true;
+ }
+
+};
+exports.ForAwaitStatement = ForAwaitStatement; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/modification.js b/node_modules/@babel/traverse/lib/path/modification.js
new file mode 100644
index 00000000..946dceb2
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/modification.js
@@ -0,0 +1,227 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.insertBefore = insertBefore;
+exports._containerInsert = _containerInsert;
+exports._containerInsertBefore = _containerInsertBefore;
+exports._containerInsertAfter = _containerInsertAfter;
+exports.insertAfter = insertAfter;
+exports.updateSiblingKeys = updateSiblingKeys;
+exports._verifyNodeList = _verifyNodeList;
+exports.unshiftContainer = unshiftContainer;
+exports.pushContainer = pushContainer;
+exports.hoist = hoist;
+
+var _cache = require("../cache");
+
+var _hoister = _interopRequireDefault(require("./lib/hoister"));
+
+var _index = _interopRequireDefault(require("./index"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function insertBefore(nodes) {
+ this._assertUnremoved();
+
+ nodes = this._verifyNodeList(nodes);
+ const parentPath = this.parentPath;
+
+ if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
+ return parentPath.insertBefore(nodes);
+ } else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || parentPath.isForStatement() && this.key === "init") {
+ if (this.node) nodes.push(this.node);
+ return this.replaceExpressionWithStatements(nodes);
+ } else if (Array.isArray(this.container)) {
+ return this._containerInsertBefore(nodes);
+ } else if (this.isStatementOrBlock()) {
+ const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
+ this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : []));
+ return this.unshiftContainer("body", nodes);
+ } else {
+ throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
+ }
+}
+
+function _containerInsert(from, nodes) {
+ this.updateSiblingKeys(from, nodes.length);
+ const paths = [];
+ this.container.splice(from, 0, ...nodes);
+
+ for (let i = 0; i < nodes.length; i++) {
+ const to = from + i;
+ const path = this.getSibling(to);
+ paths.push(path);
+
+ if (this.context && this.context.queue) {
+ path.pushContext(this.context);
+ }
+ }
+
+ const contexts = this._getQueueContexts();
+
+ for (var _i = 0; _i < paths.length; _i++) {
+ const path = paths[_i];
+ path.setScope();
+ path.debug("Inserted.");
+
+ for (var _iterator = contexts, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i2 >= _iterator.length) break;
+ _ref = _iterator[_i2++];
+ } else {
+ _i2 = _iterator.next();
+ if (_i2.done) break;
+ _ref = _i2.value;
+ }
+
+ const context = _ref;
+ context.maybeQueue(path, true);
+ }
+ }
+
+ return paths;
+}
+
+function _containerInsertBefore(nodes) {
+ return this._containerInsert(this.key, nodes);
+}
+
+function _containerInsertAfter(nodes) {
+ return this._containerInsert(this.key + 1, nodes);
+}
+
+function insertAfter(nodes) {
+ this._assertUnremoved();
+
+ nodes = this._verifyNodeList(nodes);
+ const parentPath = this.parentPath;
+
+ if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
+ return parentPath.insertAfter(nodes);
+ } else if (this.isNodeType("Expression") || parentPath.isForStatement() && this.key === "init") {
+ if (this.node) {
+ let scope = this.scope;
+
+ if (parentPath.isMethod({
+ computed: true,
+ key: this.node
+ })) {
+ scope = scope.parent;
+ }
+
+ const temp = scope.generateDeclaredUidIdentifier();
+ nodes.unshift(t().expressionStatement(t().assignmentExpression("=", t().cloneNode(temp), this.node)));
+ nodes.push(t().expressionStatement(t().cloneNode(temp)));
+ }
+
+ return this.replaceExpressionWithStatements(nodes);
+ } else if (Array.isArray(this.container)) {
+ return this._containerInsertAfter(nodes);
+ } else if (this.isStatementOrBlock()) {
+ const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null);
+ this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : []));
+ return this.pushContainer("body", nodes);
+ } else {
+ throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?");
+ }
+}
+
+function updateSiblingKeys(fromIndex, incrementBy) {
+ if (!this.parent) return;
+
+ const paths = _cache.path.get(this.parent);
+
+ for (let i = 0; i < paths.length; i++) {
+ const path = paths[i];
+
+ if (path.key >= fromIndex) {
+ path.key += incrementBy;
+ }
+ }
+}
+
+function _verifyNodeList(nodes) {
+ if (!nodes) {
+ return [];
+ }
+
+ if (nodes.constructor !== Array) {
+ nodes = [nodes];
+ }
+
+ for (let i = 0; i < nodes.length; i++) {
+ const node = nodes[i];
+ let msg;
+
+ if (!node) {
+ msg = "has falsy node";
+ } else if (typeof node !== "object") {
+ msg = "contains a non-object node";
+ } else if (!node.type) {
+ msg = "without a type";
+ } else if (node instanceof _index.default) {
+ msg = "has a NodePath when it expected a raw object";
+ }
+
+ if (msg) {
+ const type = Array.isArray(node) ? "array" : typeof node;
+ throw new Error(`Node list ${msg} with the index of ${i} and type of ${type}`);
+ }
+ }
+
+ return nodes;
+}
+
+function unshiftContainer(listKey, nodes) {
+ this._assertUnremoved();
+
+ nodes = this._verifyNodeList(nodes);
+
+ const path = _index.default.get({
+ parentPath: this,
+ parent: this.node,
+ container: this.node[listKey],
+ listKey,
+ key: 0
+ });
+
+ return path.insertBefore(nodes);
+}
+
+function pushContainer(listKey, nodes) {
+ this._assertUnremoved();
+
+ nodes = this._verifyNodeList(nodes);
+ const container = this.node[listKey];
+
+ const path = _index.default.get({
+ parentPath: this,
+ parent: this.node,
+ container: container,
+ listKey,
+ key: container.length
+ });
+
+ return path.replaceWithMultiple(nodes);
+}
+
+function hoist(scope = this.scope) {
+ const hoister = new _hoister.default(this, scope);
+ return hoister.run();
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/removal.js b/node_modules/@babel/traverse/lib/path/removal.js
new file mode 100644
index 00000000..9f4ba97b
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/removal.js
@@ -0,0 +1,68 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.remove = remove;
+exports._removeFromScope = _removeFromScope;
+exports._callRemovalHooks = _callRemovalHooks;
+exports._remove = _remove;
+exports._markRemoved = _markRemoved;
+exports._assertUnremoved = _assertUnremoved;
+
+var _removalHooks = require("./lib/removal-hooks");
+
+function remove() {
+ this._assertUnremoved();
+
+ this.resync();
+
+ this._removeFromScope();
+
+ if (this._callRemovalHooks()) {
+ this._markRemoved();
+
+ return;
+ }
+
+ this.shareCommentsWithSiblings();
+
+ this._remove();
+
+ this._markRemoved();
+}
+
+function _removeFromScope() {
+ const bindings = this.getBindingIdentifiers();
+ Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
+}
+
+function _callRemovalHooks() {
+ var _arr = _removalHooks.hooks;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const fn = _arr[_i];
+ if (fn(this, this.parentPath)) return true;
+ }
+}
+
+function _remove() {
+ if (Array.isArray(this.container)) {
+ this.container.splice(this.key, 1);
+ this.updateSiblingKeys(this.key, -1);
+ } else {
+ this._replaceWith(null);
+ }
+}
+
+function _markRemoved() {
+ this.shouldSkip = true;
+ this.removed = true;
+ this.node = null;
+}
+
+function _assertUnremoved() {
+ if (this.removed) {
+ throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
+ }
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/path/replacement.js b/node_modules/@babel/traverse/lib/path/replacement.js
new file mode 100644
index 00000000..011eb312
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/path/replacement.js
@@ -0,0 +1,273 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.replaceWithMultiple = replaceWithMultiple;
+exports.replaceWithSourceString = replaceWithSourceString;
+exports.replaceWith = replaceWith;
+exports._replaceWith = _replaceWith;
+exports.replaceExpressionWithStatements = replaceExpressionWithStatements;
+exports.replaceInline = replaceInline;
+
+function _codeFrame() {
+ const data = require("@babel/code-frame");
+
+ _codeFrame = function _codeFrame() {
+ return data;
+ };
+
+ return data;
+}
+
+var _index = _interopRequireDefault(require("../index"));
+
+var _index2 = _interopRequireDefault(require("./index"));
+
+function _babylon() {
+ const data = require("babylon");
+
+ _babylon = function _babylon() {
+ return data;
+ };
+
+ return data;
+}
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const hoistVariablesVisitor = {
+ Function(path) {
+ path.skip();
+ },
+
+ VariableDeclaration(path) {
+ if (path.node.kind !== "var") return;
+ const bindings = path.getBindingIdentifiers();
+
+ for (const key in bindings) {
+ path.scope.push({
+ id: bindings[key]
+ });
+ }
+
+ const exprs = [];
+ var _arr = path.node.declarations;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const declar = _arr[_i];
+
+ if (declar.init) {
+ exprs.push(t().expressionStatement(t().assignmentExpression("=", declar.id, declar.init)));
+ }
+ }
+
+ path.replaceWithMultiple(exprs);
+ }
+
+};
+
+function replaceWithMultiple(nodes) {
+ this.resync();
+ nodes = this._verifyNodeList(nodes);
+ t().inheritLeadingComments(nodes[0], this.node);
+ t().inheritTrailingComments(nodes[nodes.length - 1], this.node);
+ this.node = this.container[this.key] = null;
+ const paths = this.insertAfter(nodes);
+
+ if (this.node) {
+ this.requeue();
+ } else {
+ this.remove();
+ }
+
+ return paths;
+}
+
+function replaceWithSourceString(replacement) {
+ this.resync();
+
+ try {
+ replacement = `(${replacement})`;
+ replacement = (0, _babylon().parse)(replacement);
+ } catch (err) {
+ const loc = err.loc;
+
+ if (loc) {
+ err.message += " - make sure this is an expression.\n" + (0, _codeFrame().codeFrameColumns)(replacement, {
+ start: {
+ line: loc.line,
+ column: loc.column + 1
+ }
+ });
+ err.code = "BABEL_REPLACE_SOURCE_ERROR";
+ }
+
+ throw err;
+ }
+
+ replacement = replacement.program.body[0].expression;
+
+ _index.default.removeProperties(replacement);
+
+ return this.replaceWith(replacement);
+}
+
+function replaceWith(replacement) {
+ this.resync();
+
+ if (this.removed) {
+ throw new Error("You can't replace this node, we've already removed it");
+ }
+
+ if (replacement instanceof _index2.default) {
+ replacement = replacement.node;
+ }
+
+ if (!replacement) {
+ throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");
+ }
+
+ if (this.node === replacement) {
+ return [this];
+ }
+
+ if (this.isProgram() && !t().isProgram(replacement)) {
+ throw new Error("You can only replace a Program root node with another Program node");
+ }
+
+ if (Array.isArray(replacement)) {
+ throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
+ }
+
+ if (typeof replacement === "string") {
+ throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`");
+ }
+
+ let nodePath = "";
+
+ if (this.isNodeType("Statement") && t().isExpression(replacement)) {
+ if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) {
+ replacement = t().expressionStatement(replacement);
+ nodePath = "expression";
+ }
+ }
+
+ if (this.isNodeType("Expression") && t().isStatement(replacement)) {
+ if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
+ return this.replaceExpressionWithStatements([replacement]);
+ }
+ }
+
+ const oldNode = this.node;
+
+ if (oldNode) {
+ t().inheritsComments(replacement, oldNode);
+ t().removeComments(oldNode);
+ }
+
+ this._replaceWith(replacement);
+
+ this.type = replacement.type;
+ this.setScope();
+ this.requeue();
+ return [nodePath ? this.get(nodePath) : this];
+}
+
+function _replaceWith(node) {
+ if (!this.container) {
+ throw new ReferenceError("Container is falsy");
+ }
+
+ if (this.inList) {
+ t().validate(this.parent, this.key, [node]);
+ } else {
+ t().validate(this.parent, this.key, node);
+ }
+
+ this.debug(`Replace with ${node && node.type}`);
+ this.node = this.container[this.key] = node;
+}
+
+function replaceExpressionWithStatements(nodes) {
+ this.resync();
+ const toSequenceExpression = t().toSequenceExpression(nodes, this.scope);
+
+ if (toSequenceExpression) {
+ return this.replaceWith(toSequenceExpression)[0].get("expressions");
+ }
+
+ const container = t().arrowFunctionExpression([], t().blockStatement(nodes));
+ this.replaceWith(t().callExpression(container, []));
+ this.traverse(hoistVariablesVisitor);
+ const completionRecords = this.get("callee").getCompletionRecords();
+
+ for (var _iterator = completionRecords, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i2 >= _iterator.length) break;
+ _ref = _iterator[_i2++];
+ } else {
+ _i2 = _iterator.next();
+ if (_i2.done) break;
+ _ref = _i2.value;
+ }
+
+ const path = _ref;
+ if (!path.isExpressionStatement()) continue;
+ const loop = path.findParent(path => path.isLoop());
+
+ if (loop) {
+ let uid = loop.getData("expressionReplacementReturnUid");
+
+ if (!uid) {
+ const callee = this.get("callee");
+ uid = callee.scope.generateDeclaredUidIdentifier("ret");
+ callee.get("body").pushContainer("body", t().returnStatement(t().cloneNode(uid)));
+ loop.setData("expressionReplacementReturnUid", uid);
+ } else {
+ uid = t().identifier(uid.name);
+ }
+
+ path.get("expression").replaceWith(t().assignmentExpression("=", t().cloneNode(uid), path.node.expression));
+ } else {
+ path.replaceWith(t().returnStatement(path.node.expression));
+ }
+ }
+
+ const callee = this.get("callee");
+ callee.arrowFunctionToExpression();
+ return callee.get("body.body");
+}
+
+function replaceInline(nodes) {
+ this.resync();
+
+ if (Array.isArray(nodes)) {
+ if (Array.isArray(this.container)) {
+ nodes = this._verifyNodeList(nodes);
+
+ const paths = this._containerInsertAfter(nodes);
+
+ this.remove();
+ return paths;
+ } else {
+ return this.replaceWithMultiple(nodes);
+ }
+ } else {
+ return this.replaceWith(nodes);
+ }
+} \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/scope/binding.js b/node_modules/@babel/traverse/lib/scope/binding.js
new file mode 100644
index 00000000..d19f1168
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/scope/binding.js
@@ -0,0 +1,71 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+class Binding {
+ constructor({
+ identifier,
+ scope,
+ path,
+ kind
+ }) {
+ this.identifier = identifier;
+ this.scope = scope;
+ this.path = path;
+ this.kind = kind;
+ this.constantViolations = [];
+ this.constant = true;
+ this.referencePaths = [];
+ this.referenced = false;
+ this.references = 0;
+ this.clearValue();
+ }
+
+ deoptValue() {
+ this.clearValue();
+ this.hasDeoptedValue = true;
+ }
+
+ setValue(value) {
+ if (this.hasDeoptedValue) return;
+ this.hasValue = true;
+ this.value = value;
+ }
+
+ clearValue() {
+ this.hasDeoptedValue = false;
+ this.hasValue = false;
+ this.value = null;
+ }
+
+ reassign(path) {
+ this.constant = false;
+
+ if (this.constantViolations.indexOf(path) !== -1) {
+ return;
+ }
+
+ this.constantViolations.push(path);
+ }
+
+ reference(path) {
+ if (this.referencePaths.indexOf(path) !== -1) {
+ return;
+ }
+
+ this.referenced = true;
+ this.references++;
+ this.referencePaths.push(path);
+ }
+
+ dereference() {
+ this.references--;
+ this.referenced = !!this.references;
+ }
+
+}
+
+exports.default = Binding; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/scope/index.js b/node_modules/@babel/traverse/lib/scope/index.js
new file mode 100644
index 00000000..4c200ba6
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/scope/index.js
@@ -0,0 +1,1006 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+function _includes() {
+ const data = _interopRequireDefault(require("lodash/includes"));
+
+ _includes = function _includes() {
+ return data;
+ };
+
+ return data;
+}
+
+function _repeat() {
+ const data = _interopRequireDefault(require("lodash/repeat"));
+
+ _repeat = function _repeat() {
+ return data;
+ };
+
+ return data;
+}
+
+var _renamer = _interopRequireDefault(require("./lib/renamer"));
+
+var _index = _interopRequireDefault(require("../index"));
+
+function _defaults() {
+ const data = _interopRequireDefault(require("lodash/defaults"));
+
+ _defaults = function _defaults() {
+ return data;
+ };
+
+ return data;
+}
+
+var _binding = _interopRequireDefault(require("./binding"));
+
+function _globals() {
+ const data = _interopRequireDefault(require("globals"));
+
+ _globals = function _globals() {
+ return data;
+ };
+
+ return data;
+}
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function gatherNodeParts(node, parts) {
+ if (t().isModuleDeclaration(node)) {
+ if (node.source) {
+ gatherNodeParts(node.source, parts);
+ } else if (node.specifiers && node.specifiers.length) {
+ var _arr = node.specifiers;
+
+ for (var _i = 0; _i < _arr.length; _i++) {
+ const specifier = _arr[_i];
+ gatherNodeParts(specifier, parts);
+ }
+ } else if (node.declaration) {
+ gatherNodeParts(node.declaration, parts);
+ }
+ } else if (t().isModuleSpecifier(node)) {
+ gatherNodeParts(node.local, parts);
+ } else if (t().isMemberExpression(node)) {
+ gatherNodeParts(node.object, parts);
+ gatherNodeParts(node.property, parts);
+ } else if (t().isIdentifier(node)) {
+ parts.push(node.name);
+ } else if (t().isLiteral(node)) {
+ parts.push(node.value);
+ } else if (t().isCallExpression(node)) {
+ gatherNodeParts(node.callee, parts);
+ } else if (t().isObjectExpression(node) || t().isObjectPattern(node)) {
+ var _arr2 = node.properties;
+
+ for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
+ const prop = _arr2[_i2];
+ gatherNodeParts(prop.key || prop.argument, parts);
+ }
+ } else if (t().isPrivateName(node)) {
+ gatherNodeParts(node.id, parts);
+ } else if (t().isThisExpression(node)) {
+ parts.push("this");
+ } else if (t().isSuper(node)) {
+ parts.push("super");
+ }
+}
+
+const collectorVisitor = {
+ For(path) {
+ var _arr3 = t().FOR_INIT_KEYS;
+
+ for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
+ const key = _arr3[_i3];
+ const declar = path.get(key);
+
+ if (declar.isVar()) {
+ const parentScope = path.scope.getFunctionParent() || path.scope.getProgramParent();
+ parentScope.registerBinding("var", declar);
+ }
+ }
+ },
+
+ Declaration(path) {
+ if (path.isBlockScoped()) return;
+
+ if (path.isExportDeclaration() && path.get("declaration").isDeclaration()) {
+ return;
+ }
+
+ const parent = path.scope.getFunctionParent() || path.scope.getProgramParent();
+ parent.registerDeclaration(path);
+ },
+
+ ReferencedIdentifier(path, state) {
+ state.references.push(path);
+ },
+
+ ForXStatement(path, state) {
+ const left = path.get("left");
+
+ if (left.isPattern() || left.isIdentifier()) {
+ state.constantViolations.push(path);
+ }
+ },
+
+ ExportDeclaration: {
+ exit(path) {
+ const node = path.node,
+ scope = path.scope;
+ const declar = node.declaration;
+
+ if (t().isClassDeclaration(declar) || t().isFunctionDeclaration(declar)) {
+ const id = declar.id;
+ if (!id) return;
+ const binding = scope.getBinding(id.name);
+ if (binding) binding.reference(path);
+ } else if (t().isVariableDeclaration(declar)) {
+ var _arr4 = declar.declarations;
+
+ for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
+ const decl = _arr4[_i4];
+ const ids = t().getBindingIdentifiers(decl);
+
+ for (const name in ids) {
+ const binding = scope.getBinding(name);
+ if (binding) binding.reference(path);
+ }
+ }
+ }
+ }
+
+ },
+
+ LabeledStatement(path) {
+ path.scope.getProgramParent().addGlobal(path.node);
+ path.scope.getBlockParent().registerDeclaration(path);
+ },
+
+ AssignmentExpression(path, state) {
+ state.assignments.push(path);
+ },
+
+ UpdateExpression(path, state) {
+ state.constantViolations.push(path);
+ },
+
+ UnaryExpression(path, state) {
+ if (path.node.operator === "delete") {
+ state.constantViolations.push(path);
+ }
+ },
+
+ BlockScoped(path) {
+ let scope = path.scope;
+ if (scope.path === path) scope = scope.parent;
+ scope.getBlockParent().registerDeclaration(path);
+ },
+
+ ClassDeclaration(path) {
+ const id = path.node.id;
+ if (!id) return;
+ const name = id.name;
+ path.scope.bindings[name] = path.scope.getBinding(name);
+ },
+
+ Block(path) {
+ const paths = path.get("body");
+ var _arr5 = paths;
+
+ for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
+ const bodyPath = _arr5[_i5];
+
+ if (bodyPath.isFunctionDeclaration()) {
+ path.scope.getBlockParent().registerDeclaration(bodyPath);
+ }
+ }
+ }
+
+};
+let uid = 0;
+
+class Scope {
+ constructor(path) {
+ const node = path.node;
+
+ const cached = _cache.scope.get(node);
+
+ if (cached && cached.path === path) {
+ return cached;
+ }
+
+ _cache.scope.set(node, this);
+
+ this.uid = uid++;
+ this.block = node;
+ this.path = path;
+ this.labels = new Map();
+ }
+
+ get parent() {
+ const parent = this.path.findParent(p => p.isScope());
+ return parent && parent.scope;
+ }
+
+ get parentBlock() {
+ return this.path.parent;
+ }
+
+ get hub() {
+ return this.path.hub;
+ }
+
+ traverse(node, opts, state) {
+ (0, _index.default)(node, opts, this, state, this.path);
+ }
+
+ generateDeclaredUidIdentifier(name) {
+ const id = this.generateUidIdentifier(name);
+ this.push({
+ id
+ });
+ return t().cloneNode(id);
+ }
+
+ generateUidIdentifier(name) {
+ return t().identifier(this.generateUid(name));
+ }
+
+ generateUid(name = "temp") {
+ name = t().toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
+ let uid;
+ let i = 0;
+
+ do {
+ uid = this._generateUid(name, i);
+ i++;
+ } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
+
+ const program = this.getProgramParent();
+ program.references[uid] = true;
+ program.uids[uid] = true;
+ return uid;
+ }
+
+ _generateUid(name, i) {
+ let id = name;
+ if (i > 1) id += i;
+ return `_${id}`;
+ }
+
+ generateUidBasedOnNode(parent, defaultName) {
+ let node = parent;
+
+ if (t().isAssignmentExpression(parent)) {
+ node = parent.left;
+ } else if (t().isVariableDeclarator(parent)) {
+ node = parent.id;
+ } else if (t().isObjectProperty(node) || t().isObjectMethod(node)) {
+ node = node.key;
+ }
+
+ const parts = [];
+ gatherNodeParts(node, parts);
+ let id = parts.join("$");
+ id = id.replace(/^_/, "") || defaultName || "ref";
+ return this.generateUid(id.slice(0, 20));
+ }
+
+ generateUidIdentifierBasedOnNode(parent, defaultName) {
+ return t().identifier(this.generateUidBasedOnNode(parent, defaultName));
+ }
+
+ isStatic(node) {
+ if (t().isThisExpression(node) || t().isSuper(node)) {
+ return true;
+ }
+
+ if (t().isIdentifier(node)) {
+ const binding = this.getBinding(node.name);
+
+ if (binding) {
+ return binding.constant;
+ } else {
+ return this.hasBinding(node.name);
+ }
+ }
+
+ return false;
+ }
+
+ maybeGenerateMemoised(node, dontPush) {
+ if (this.isStatic(node)) {
+ return null;
+ } else {
+ const id = this.generateUidIdentifierBasedOnNode(node);
+
+ if (!dontPush) {
+ this.push({
+ id
+ });
+ return t().cloneNode(id);
+ }
+
+ return id;
+ }
+ }
+
+ checkBlockScopedCollisions(local, kind, name, id) {
+ if (kind === "param") return;
+ if (local.kind === "local") return;
+ if (kind === "hoisted" && local.kind === "let") return;
+ const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
+
+ if (duplicate) {
+ throw this.hub.file.buildCodeFrameError(id, `Duplicate declaration "${name}"`, TypeError);
+ }
+ }
+
+ rename(oldName, newName, block) {
+ const binding = this.getBinding(oldName);
+
+ if (binding) {
+ newName = newName || this.generateUidIdentifier(oldName).name;
+ return new _renamer.default(binding, oldName, newName).rename(block);
+ }
+ }
+
+ _renameFromMap(map, oldName, newName, value) {
+ if (map[oldName]) {
+ map[newName] = value;
+ map[oldName] = null;
+ }
+ }
+
+ dump() {
+ const sep = (0, _repeat().default)("-", 60);
+ console.log(sep);
+ let scope = this;
+
+ do {
+ console.log("#", scope.block.type);
+
+ for (const name in scope.bindings) {
+ const binding = scope.bindings[name];
+ console.log(" -", name, {
+ constant: binding.constant,
+ references: binding.references,
+ violations: binding.constantViolations.length,
+ kind: binding.kind
+ });
+ }
+ } while (scope = scope.parent);
+
+ console.log(sep);
+ }
+
+ toArray(node, i) {
+ const file = this.hub.file;
+
+ if (t().isIdentifier(node)) {
+ const binding = this.getBinding(node.name);
+
+ if (binding && binding.constant && binding.path.isGenericType("Array")) {
+ return node;
+ }
+ }
+
+ if (t().isArrayExpression(node)) {
+ return node;
+ }
+
+ if (t().isIdentifier(node, {
+ name: "arguments"
+ })) {
+ return t().callExpression(t().memberExpression(t().memberExpression(t().memberExpression(t().identifier("Array"), t().identifier("prototype")), t().identifier("slice")), t().identifier("call")), [node]);
+ }
+
+ let helperName;
+ const args = [node];
+
+ if (i === true) {
+ helperName = "toConsumableArray";
+ } else if (i) {
+ args.push(t().numericLiteral(i));
+ helperName = "slicedToArray";
+ } else {
+ helperName = "toArray";
+ }
+
+ return t().callExpression(file.addHelper(helperName), args);
+ }
+
+ hasLabel(name) {
+ return !!this.getLabel(name);
+ }
+
+ getLabel(name) {
+ return this.labels.get(name);
+ }
+
+ registerLabel(path) {
+ this.labels.set(path.node.label.name, path);
+ }
+
+ registerDeclaration(path) {
+ if (path.isFlow()) return;
+
+ if (path.isLabeledStatement()) {
+ this.registerLabel(path);
+ } else if (path.isFunctionDeclaration()) {
+ this.registerBinding("hoisted", path.get("id"), path);
+ } else if (path.isVariableDeclaration()) {
+ const declarations = path.get("declarations");
+ var _arr6 = declarations;
+
+ for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
+ const declar = _arr6[_i6];
+ this.registerBinding(path.node.kind, declar);
+ }
+ } else if (path.isClassDeclaration()) {
+ this.registerBinding("let", path);
+ } else if (path.isImportDeclaration()) {
+ const specifiers = path.get("specifiers");
+ var _arr7 = specifiers;
+
+ for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
+ const specifier = _arr7[_i7];
+ this.registerBinding("module", specifier);
+ }
+ } else if (path.isExportDeclaration()) {
+ const declar = path.get("declaration");
+
+ if (declar.isClassDeclaration() || declar.isFunctionDeclaration() || declar.isVariableDeclaration()) {
+ this.registerDeclaration(declar);
+ }
+ } else {
+ this.registerBinding("unknown", path);
+ }
+ }
+
+ buildUndefinedNode() {
+ if (this.hasBinding("undefined")) {
+ return t().unaryExpression("void", t().numericLiteral(0), true);
+ } else {
+ return t().identifier("undefined");
+ }
+ }
+
+ registerConstantViolation(path) {
+ const ids = path.getBindingIdentifiers();
+
+ for (const name in ids) {
+ const binding = this.getBinding(name);
+ if (binding) binding.reassign(path);
+ }
+ }
+
+ registerBinding(kind, path, bindingPath = path) {
+ if (!kind) throw new ReferenceError("no `kind`");
+
+ if (path.isVariableDeclaration()) {
+ const declarators = path.get("declarations");
+
+ for (var _iterator = declarators, _isArray = Array.isArray(_iterator), _i8 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i8 >= _iterator.length) break;
+ _ref = _iterator[_i8++];
+ } else {
+ _i8 = _iterator.next();
+ if (_i8.done) break;
+ _ref = _i8.value;
+ }
+
+ const declar = _ref;
+ this.registerBinding(kind, declar);
+ }
+
+ return;
+ }
+
+ const parent = this.getProgramParent();
+ const ids = path.getBindingIdentifiers(true);
+
+ for (const name in ids) {
+ var _arr8 = ids[name];
+
+ for (var _i9 = 0; _i9 < _arr8.length; _i9++) {
+ const id = _arr8[_i9];
+ const local = this.getOwnBinding(name);
+
+ if (local) {
+ if (local.identifier === id) continue;
+ this.checkBlockScopedCollisions(local, kind, name, id);
+ }
+
+ parent.references[name] = true;
+
+ if (local) {
+ this.registerConstantViolation(bindingPath);
+ } else {
+ this.bindings[name] = new _binding.default({
+ identifier: id,
+ scope: this,
+ path: bindingPath,
+ kind: kind
+ });
+ }
+ }
+ }
+ }
+
+ addGlobal(node) {
+ this.globals[node.name] = node;
+ }
+
+ hasUid(name) {
+ let scope = this;
+
+ do {
+ if (scope.uids[name]) return true;
+ } while (scope = scope.parent);
+
+ return false;
+ }
+
+ hasGlobal(name) {
+ let scope = this;
+
+ do {
+ if (scope.globals[name]) return true;
+ } while (scope = scope.parent);
+
+ return false;
+ }
+
+ hasReference(name) {
+ let scope = this;
+
+ do {
+ if (scope.references[name]) return true;
+ } while (scope = scope.parent);
+
+ return false;
+ }
+
+ isPure(node, constantsOnly) {
+ if (t().isIdentifier(node)) {
+ const binding = this.getBinding(node.name);
+ if (!binding) return false;
+ if (constantsOnly) return binding.constant;
+ return true;
+ } else if (t().isClass(node)) {
+ if (node.superClass && !this.isPure(node.superClass, constantsOnly)) {
+ return false;
+ }
+
+ return this.isPure(node.body, constantsOnly);
+ } else if (t().isClassBody(node)) {
+ for (var _iterator2 = node.body, _isArray2 = Array.isArray(_iterator2), _i10 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i10 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i10++];
+ } else {
+ _i10 = _iterator2.next();
+ if (_i10.done) break;
+ _ref2 = _i10.value;
+ }
+
+ const method = _ref2;
+ if (!this.isPure(method, constantsOnly)) return false;
+ }
+
+ return true;
+ } else if (t().isBinary(node)) {
+ return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
+ } else if (t().isArrayExpression(node)) {
+ var _arr9 = node.elements;
+
+ for (var _i11 = 0; _i11 < _arr9.length; _i11++) {
+ const elem = _arr9[_i11];
+ if (!this.isPure(elem, constantsOnly)) return false;
+ }
+
+ return true;
+ } else if (t().isObjectExpression(node)) {
+ var _arr10 = node.properties;
+
+ for (var _i12 = 0; _i12 < _arr10.length; _i12++) {
+ const prop = _arr10[_i12];
+ if (!this.isPure(prop, constantsOnly)) return false;
+ }
+
+ return true;
+ } else if (t().isClassMethod(node)) {
+ if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
+ if (node.kind === "get" || node.kind === "set") return false;
+ return true;
+ } else if (t().isProperty(node)) {
+ if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
+ return this.isPure(node.value, constantsOnly);
+ } else if (t().isUnaryExpression(node)) {
+ return this.isPure(node.argument, constantsOnly);
+ } else if (t().isTaggedTemplateExpression(node)) {
+ return t().matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly);
+ } else if (t().isTemplateLiteral(node)) {
+ var _arr11 = node.expressions;
+
+ for (var _i13 = 0; _i13 < _arr11.length; _i13++) {
+ const expression = _arr11[_i13];
+ if (!this.isPure(expression, constantsOnly)) return false;
+ }
+
+ return true;
+ } else {
+ return t().isPureish(node);
+ }
+ }
+
+ setData(key, val) {
+ return this.data[key] = val;
+ }
+
+ getData(key) {
+ let scope = this;
+
+ do {
+ const data = scope.data[key];
+ if (data != null) return data;
+ } while (scope = scope.parent);
+ }
+
+ removeData(key) {
+ let scope = this;
+
+ do {
+ const data = scope.data[key];
+ if (data != null) scope.data[key] = null;
+ } while (scope = scope.parent);
+ }
+
+ init() {
+ if (!this.references) this.crawl();
+ }
+
+ crawl() {
+ const path = this.path;
+ this.references = Object.create(null);
+ this.bindings = Object.create(null);
+ this.globals = Object.create(null);
+ this.uids = Object.create(null);
+ this.data = Object.create(null);
+
+ if (path.isLoop()) {
+ var _arr12 = t().FOR_INIT_KEYS;
+
+ for (var _i14 = 0; _i14 < _arr12.length; _i14++) {
+ const key = _arr12[_i14];
+ const node = path.get(key);
+ if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
+ }
+ }
+
+ if (path.isFunctionExpression() && path.has("id")) {
+ if (!path.get("id").node[t().NOT_LOCAL_BINDING]) {
+ this.registerBinding("local", path.get("id"), path);
+ }
+ }
+
+ if (path.isClassExpression() && path.has("id")) {
+ if (!path.get("id").node[t().NOT_LOCAL_BINDING]) {
+ this.registerBinding("local", path);
+ }
+ }
+
+ if (path.isFunction()) {
+ const params = path.get("params");
+
+ for (var _iterator3 = params, _isArray3 = Array.isArray(_iterator3), _i15 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
+ var _ref3;
+
+ if (_isArray3) {
+ if (_i15 >= _iterator3.length) break;
+ _ref3 = _iterator3[_i15++];
+ } else {
+ _i15 = _iterator3.next();
+ if (_i15.done) break;
+ _ref3 = _i15.value;
+ }
+
+ const param = _ref3;
+ this.registerBinding("param", param);
+ }
+ }
+
+ if (path.isCatchClause()) {
+ this.registerBinding("let", path);
+ }
+
+ const parent = this.getProgramParent();
+ if (parent.crawling) return;
+ const state = {
+ references: [],
+ constantViolations: [],
+ assignments: []
+ };
+ this.crawling = true;
+ path.traverse(collectorVisitor, state);
+ this.crawling = false;
+
+ for (var _iterator4 = state.assignments, _isArray4 = Array.isArray(_iterator4), _i16 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
+ var _ref4;
+
+ if (_isArray4) {
+ if (_i16 >= _iterator4.length) break;
+ _ref4 = _iterator4[_i16++];
+ } else {
+ _i16 = _iterator4.next();
+ if (_i16.done) break;
+ _ref4 = _i16.value;
+ }
+
+ const path = _ref4;
+ const ids = path.getBindingIdentifiers();
+ let programParent;
+
+ for (const name in ids) {
+ if (path.scope.getBinding(name)) continue;
+ programParent = programParent || path.scope.getProgramParent();
+ programParent.addGlobal(ids[name]);
+ }
+
+ path.scope.registerConstantViolation(path);
+ }
+
+ for (var _iterator5 = state.references, _isArray5 = Array.isArray(_iterator5), _i17 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
+ var _ref5;
+
+ if (_isArray5) {
+ if (_i17 >= _iterator5.length) break;
+ _ref5 = _iterator5[_i17++];
+ } else {
+ _i17 = _iterator5.next();
+ if (_i17.done) break;
+ _ref5 = _i17.value;
+ }
+
+ const ref = _ref5;
+ const binding = ref.scope.getBinding(ref.node.name);
+
+ if (binding) {
+ binding.reference(ref);
+ } else {
+ ref.scope.getProgramParent().addGlobal(ref.node);
+ }
+ }
+
+ for (var _iterator6 = state.constantViolations, _isArray6 = Array.isArray(_iterator6), _i18 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
+ var _ref6;
+
+ if (_isArray6) {
+ if (_i18 >= _iterator6.length) break;
+ _ref6 = _iterator6[_i18++];
+ } else {
+ _i18 = _iterator6.next();
+ if (_i18.done) break;
+ _ref6 = _i18.value;
+ }
+
+ const path = _ref6;
+ path.scope.registerConstantViolation(path);
+ }
+ }
+
+ push(opts) {
+ let path = this.path;
+
+ if (!path.isBlockStatement() && !path.isProgram()) {
+ path = this.getBlockParent().path;
+ }
+
+ if (path.isSwitchStatement()) {
+ path = (this.getFunctionParent() || this.getProgramParent()).path;
+ }
+
+ if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
+ path.ensureBlock();
+ path = path.get("body");
+ }
+
+ const unique = opts.unique;
+ const kind = opts.kind || "var";
+ const blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;
+ const dataKey = `declaration:${kind}:${blockHoist}`;
+ let declarPath = !unique && path.getData(dataKey);
+
+ if (!declarPath) {
+ const declar = t().variableDeclaration(kind, []);
+ declar._blockHoist = blockHoist;
+
+ var _path$unshiftContaine = path.unshiftContainer("body", [declar]);
+
+ declarPath = _path$unshiftContaine[0];
+ if (!unique) path.setData(dataKey, declarPath);
+ }
+
+ const declarator = t().variableDeclarator(opts.id, opts.init);
+ declarPath.node.declarations.push(declarator);
+ this.registerBinding(kind, declarPath.get("declarations").pop());
+ }
+
+ getProgramParent() {
+ let scope = this;
+
+ do {
+ if (scope.path.isProgram()) {
+ return scope;
+ }
+ } while (scope = scope.parent);
+
+ throw new Error("Couldn't find a Program");
+ }
+
+ getFunctionParent() {
+ let scope = this;
+
+ do {
+ if (scope.path.isFunctionParent()) {
+ return scope;
+ }
+ } while (scope = scope.parent);
+
+ return null;
+ }
+
+ getBlockParent() {
+ let scope = this;
+
+ do {
+ if (scope.path.isBlockParent()) {
+ return scope;
+ }
+ } while (scope = scope.parent);
+
+ throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...");
+ }
+
+ getAllBindings() {
+ const ids = Object.create(null);
+ let scope = this;
+
+ do {
+ (0, _defaults().default)(ids, scope.bindings);
+ scope = scope.parent;
+ } while (scope);
+
+ return ids;
+ }
+
+ getAllBindingsOfKind() {
+ const ids = Object.create(null);
+ var _arr13 = arguments;
+
+ for (var _i19 = 0; _i19 < _arr13.length; _i19++) {
+ const kind = _arr13[_i19];
+ let scope = this;
+
+ do {
+ for (const name in scope.bindings) {
+ const binding = scope.bindings[name];
+ if (binding.kind === kind) ids[name] = binding;
+ }
+
+ scope = scope.parent;
+ } while (scope);
+ }
+
+ return ids;
+ }
+
+ bindingIdentifierEquals(name, node) {
+ return this.getBindingIdentifier(name) === node;
+ }
+
+ getBinding(name) {
+ let scope = this;
+
+ do {
+ const binding = scope.getOwnBinding(name);
+ if (binding) return binding;
+ } while (scope = scope.parent);
+ }
+
+ getOwnBinding(name) {
+ return this.bindings[name];
+ }
+
+ getBindingIdentifier(name) {
+ const info = this.getBinding(name);
+ return info && info.identifier;
+ }
+
+ getOwnBindingIdentifier(name) {
+ const binding = this.bindings[name];
+ return binding && binding.identifier;
+ }
+
+ hasOwnBinding(name) {
+ return !!this.getOwnBinding(name);
+ }
+
+ hasBinding(name, noGlobals) {
+ if (!name) return false;
+ if (this.hasOwnBinding(name)) return true;
+ if (this.parentHasBinding(name, noGlobals)) return true;
+ if (this.hasUid(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;
+ }
+
+ parentHasBinding(name, noGlobals) {
+ return this.parent && this.parent.hasBinding(name, noGlobals);
+ }
+
+ moveBindingTo(name, scope) {
+ const info = this.getBinding(name);
+
+ if (info) {
+ info.scope.removeOwnBinding(name);
+ info.scope = scope;
+ scope.bindings[name] = info;
+ }
+ }
+
+ removeOwnBinding(name) {
+ delete this.bindings[name];
+ }
+
+ removeBinding(name) {
+ const info = this.getBinding(name);
+
+ if (info) {
+ info.scope.removeOwnBinding(name);
+ }
+
+ let scope = this;
+
+ do {
+ if (scope.uids[name]) {
+ scope.uids[name] = false;
+ }
+ } while (scope = scope.parent);
+ }
+
+}
+
+exports.default = Scope;
+Scope.globals = Object.keys(_globals().default.builtin);
+Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"]; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/scope/lib/renamer.js b/node_modules/@babel/traverse/lib/scope/lib/renamer.js
new file mode 100644
index 00000000..47016e47
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/scope/lib/renamer.js
@@ -0,0 +1,130 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+var _binding = _interopRequireDefault(require("../binding"));
+
+function _helperSplitExportDeclaration() {
+ const data = _interopRequireDefault(require("@babel/helper-split-export-declaration"));
+
+ _helperSplitExportDeclaration = function _helperSplitExportDeclaration() {
+ return data;
+ };
+
+ return data;
+}
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+const renameVisitor = {
+ ReferencedIdentifier({
+ node
+ }, state) {
+ if (node.name === state.oldName) {
+ node.name = state.newName;
+ }
+ },
+
+ Scope(path, state) {
+ if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
+ path.skip();
+ }
+ },
+
+ "AssignmentExpression|Declaration"(path, state) {
+ const ids = path.getOuterBindingIdentifiers();
+
+ for (const name in ids) {
+ if (name === state.oldName) ids[name].name = state.newName;
+ }
+ }
+
+};
+
+class Renamer {
+ constructor(binding, oldName, newName) {
+ this.newName = newName;
+ this.oldName = oldName;
+ this.binding = binding;
+ }
+
+ maybeConvertFromExportDeclaration(parentDeclar) {
+ const maybeExportDeclar = parentDeclar.parentPath;
+
+ if (!maybeExportDeclar.isExportDeclaration()) {
+ return;
+ }
+
+ if (maybeExportDeclar.isExportDefaultDeclaration() && !maybeExportDeclar.get("declaration").node.id) {
+ return;
+ }
+
+ (0, _helperSplitExportDeclaration().default)(maybeExportDeclar);
+ }
+
+ maybeConvertFromClassFunctionDeclaration(path) {
+ return;
+ if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
+ if (this.binding.kind !== "hoisted") return;
+ path.node.id = t().identifier(this.oldName);
+ path.node._blockHoist = 3;
+ path.replaceWith(t().variableDeclaration("let", [t().variableDeclarator(t().identifier(this.newName), t().toExpression(path.node))]));
+ }
+
+ maybeConvertFromClassFunctionExpression(path) {
+ return;
+ if (!path.isFunctionExpression() && !path.isClassExpression()) return;
+ if (this.binding.kind !== "local") return;
+ path.node.id = t().identifier(this.oldName);
+ this.binding.scope.parent.push({
+ id: t().identifier(this.newName)
+ });
+ path.replaceWith(t().assignmentExpression("=", t().identifier(this.newName), path.node));
+ }
+
+ rename(block) {
+ const binding = this.binding,
+ oldName = this.oldName,
+ newName = this.newName;
+ const scope = binding.scope,
+ path = binding.path;
+ const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression());
+
+ if (parentDeclar) {
+ this.maybeConvertFromExportDeclaration(parentDeclar);
+ }
+
+ scope.traverse(block || scope.block, renameVisitor, this);
+
+ if (!block) {
+ scope.removeOwnBinding(oldName);
+ scope.bindings[newName] = binding;
+ this.binding.identifier.name = newName;
+ }
+
+ if (binding.type === "hoisted") {}
+
+ if (parentDeclar) {
+ this.maybeConvertFromClassFunctionDeclaration(parentDeclar);
+ this.maybeConvertFromClassFunctionExpression(parentDeclar);
+ }
+ }
+
+}
+
+exports.default = Renamer; \ No newline at end of file
diff --git a/node_modules/@babel/traverse/lib/visitors.js b/node_modules/@babel/traverse/lib/visitors.js
new file mode 100644
index 00000000..bff50dfc
--- /dev/null
+++ b/node_modules/@babel/traverse/lib/visitors.js
@@ -0,0 +1,298 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.explode = explode;
+exports.verify = verify;
+exports.merge = merge;
+
+var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types"));
+
+function t() {
+ const data = _interopRequireWildcard(require("@babel/types"));
+
+ t = function t() {
+ return data;
+ };
+
+ return data;
+}
+
+function _clone() {
+ const data = _interopRequireDefault(require("lodash/clone"));
+
+ _clone = function _clone() {
+ return data;
+ };
+
+ return data;
+}
+
+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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
+
+function explode(visitor) {
+ if (visitor._exploded) return visitor;
+ visitor._exploded = true;
+
+ for (const nodeType in visitor) {
+ if (shouldIgnoreKey(nodeType)) continue;
+ const parts = nodeType.split("|");
+ if (parts.length === 1) continue;
+ const fns = visitor[nodeType];
+ delete visitor[nodeType];
+
+ for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const part = _ref;
+ visitor[part] = fns;
+ }
+ }
+
+ verify(visitor);
+ delete visitor.__esModule;
+ ensureEntranceObjects(visitor);
+ ensureCallbackArrays(visitor);
+
+ var _arr = Object.keys(visitor);
+
+ for (var _i2 = 0; _i2 < _arr.length; _i2++) {
+ const nodeType = _arr[_i2];
+ if (shouldIgnoreKey(nodeType)) continue;
+ const wrapper = virtualTypes[nodeType];
+ if (!wrapper) continue;
+ const fns = visitor[nodeType];
+
+ for (const type in fns) {
+ fns[type] = wrapCheck(wrapper, fns[type]);
+ }
+
+ delete visitor[nodeType];
+
+ if (wrapper.types) {
+ var _arr2 = wrapper.types;
+
+ for (var _i4 = 0; _i4 < _arr2.length; _i4++) {
+ const type = _arr2[_i4];
+
+ if (visitor[type]) {
+ mergePair(visitor[type], fns);
+ } else {
+ visitor[type] = fns;
+ }
+ }
+ } else {
+ mergePair(visitor, fns);
+ }
+ }
+
+ for (const nodeType in visitor) {
+ if (shouldIgnoreKey(nodeType)) continue;
+ const fns = visitor[nodeType];
+ let aliases = t().FLIPPED_ALIAS_KEYS[nodeType];
+ const deprecratedKey = t().DEPRECATED_KEYS[nodeType];
+
+ if (deprecratedKey) {
+ console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`);
+ aliases = [deprecratedKey];
+ }
+
+ if (!aliases) continue;
+ delete visitor[nodeType];
+
+ for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i3 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+
+ if (_isArray2) {
+ if (_i3 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i3++];
+ } else {
+ _i3 = _iterator2.next();
+ if (_i3.done) break;
+ _ref2 = _i3.value;
+ }
+
+ const alias = _ref2;
+ const existing = visitor[alias];
+
+ if (existing) {
+ mergePair(existing, fns);
+ } else {
+ visitor[alias] = (0, _clone().default)(fns);
+ }
+ }
+ }
+
+ for (const nodeType in visitor) {
+ if (shouldIgnoreKey(nodeType)) continue;
+ ensureCallbackArrays(visitor[nodeType]);
+ }
+
+ return visitor;
+}
+
+function verify(visitor) {
+ if (visitor._verified) return;
+
+ if (typeof visitor === "function") {
+ throw new Error("You passed `traverse()` a function when it expected a visitor object, " + "are you sure you didn't mean `{ enter: Function }`?");
+ }
+
+ for (const nodeType in visitor) {
+ if (nodeType === "enter" || nodeType === "exit") {
+ validateVisitorMethods(nodeType, visitor[nodeType]);
+ }
+
+ if (shouldIgnoreKey(nodeType)) continue;
+
+ if (t().TYPES.indexOf(nodeType) < 0) {
+ throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
+ }
+
+ const visitors = visitor[nodeType];
+
+ if (typeof visitors === "object") {
+ for (const visitorKey in visitors) {
+ if (visitorKey === "enter" || visitorKey === "exit") {
+ validateVisitorMethods(`${nodeType}.${visitorKey}`, visitors[visitorKey]);
+ } else {
+ throw new Error("You passed `traverse()` a visitor object with the property " + `${nodeType} that has the invalid property ${visitorKey}`);
+ }
+ }
+ }
+ }
+
+ visitor._verified = true;
+}
+
+function validateVisitorMethods(path, val) {
+ const fns = [].concat(val);
+
+ for (var _iterator3 = fns, _isArray3 = Array.isArray(_iterator3), _i5 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
+ var _ref3;
+
+ if (_isArray3) {
+ if (_i5 >= _iterator3.length) break;
+ _ref3 = _iterator3[_i5++];
+ } else {
+ _i5 = _iterator3.next();
+ if (_i5.done) break;
+ _ref3 = _i5.value;
+ }
+
+ const fn = _ref3;
+
+ if (typeof fn !== "function") {
+ throw new TypeError(`Non-function found defined in ${path} with type ${typeof fn}`);
+ }
+ }
+}
+
+function merge(visitors, states = [], wrapper) {
+ const rootVisitor = {};
+
+ for (let i = 0; i < visitors.length; i++) {
+ const visitor = visitors[i];
+ const state = states[i];
+ explode(visitor);
+
+ for (const type in visitor) {
+ let visitorType = visitor[type];
+
+ if (state || wrapper) {
+ visitorType = wrapWithStateOrWrapper(visitorType, state, wrapper);
+ }
+
+ const nodeVisitor = rootVisitor[type] = rootVisitor[type] || {};
+ mergePair(nodeVisitor, visitorType);
+ }
+ }
+
+ return rootVisitor;
+}
+
+function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
+ const newVisitor = {};
+
+ for (const key in oldVisitor) {
+ let fns = oldVisitor[key];
+ if (!Array.isArray(fns)) continue;
+ fns = fns.map(function (fn) {
+ let newFn = fn;
+
+ if (state) {
+ newFn = function newFn(path) {
+ return fn.call(state, path, state);
+ };
+ }
+
+ if (wrapper) {
+ newFn = wrapper(state.key, key, newFn);
+ }
+
+ return newFn;
+ });
+ newVisitor[key] = fns;
+ }
+
+ return newVisitor;
+}
+
+function ensureEntranceObjects(obj) {
+ for (const key in obj) {
+ if (shouldIgnoreKey(key)) continue;
+ const fns = obj[key];
+
+ if (typeof fns === "function") {
+ obj[key] = {
+ enter: fns
+ };
+ }
+ }
+}
+
+function ensureCallbackArrays(obj) {
+ if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
+ if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
+}
+
+function wrapCheck(wrapper, fn) {
+ const newFn = function newFn(path) {
+ if (wrapper.checkPath(path)) {
+ return fn.apply(this, arguments);
+ }
+ };
+
+ newFn.toString = () => fn.toString();
+
+ return newFn;
+}
+
+function shouldIgnoreKey(key) {
+ if (key[0] === "_") return true;
+ if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
+
+ if (key === "blacklist" || key === "noScope" || key === "skipKeys") {
+ return true;
+ }
+
+ return false;
+}
+
+function mergePair(dest, src) {
+ for (const key in src) {
+ dest[key] = [].concat(dest[key] || [], src[key]);
+ }
+} \ No newline at end of file