$
This commit is contained in:
22
node_modules/@babel/traverse/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/traverse/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
node_modules/@babel/traverse/README.md
generated
vendored
Normal file
19
node_modules/@babel/traverse/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/traverse
|
||||
|
||||
> The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
|
||||
|
||||
See our website [@babel/traverse](https://babeljs.io/docs/en/babel-traverse) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/traverse
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/traverse --dev
|
||||
```
|
26
node_modules/@babel/traverse/lib/cache.js
generated
vendored
Normal file
26
node_modules/@babel/traverse/lib/cache.js
generated
vendored
Normal file
@@ -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();
|
||||
}
|
139
node_modules/@babel/traverse/lib/context.js
generated
vendored
Normal file
139
node_modules/@babel/traverse/lib/context.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _path = require("./path");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
|
||||
class TraversalContext {
|
||||
constructor(scope, opts, state, parentPath) {
|
||||
this.queue = null;
|
||||
this.priorityQueue = 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 = VISITOR_KEYS[node.type];
|
||||
if (!(keys != null && keys.length)) return false;
|
||||
|
||||
for (const key of keys) {
|
||||
if (node[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
create(node, container, key, listKey) {
|
||||
return _path.default.get({
|
||||
parentPath: this.parentPath,
|
||||
parent: node,
|
||||
container,
|
||||
key: key,
|
||||
listKey
|
||||
});
|
||||
}
|
||||
|
||||
maybeQueue(path, notPriority) {
|
||||
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 = new WeakSet();
|
||||
let stop = false;
|
||||
|
||||
for (const path of queue) {
|
||||
path.resync();
|
||||
|
||||
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
||||
path.pushContext(this);
|
||||
}
|
||||
|
||||
if (path.key === null) continue;
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
if (visited.has(node)) continue;
|
||||
if (node) visited.add(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 (const path of queue) {
|
||||
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;
|
23
node_modules/@babel/traverse/lib/hub.js
generated
vendored
Normal file
23
node_modules/@babel/traverse/lib/hub.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class Hub {
|
||||
getCode() {}
|
||||
|
||||
getScope() {}
|
||||
|
||||
addHelper() {
|
||||
throw new Error("Helpers are not supported by the default hub.");
|
||||
}
|
||||
|
||||
buildError(node, msg, Error = TypeError) {
|
||||
return new Error(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Hub;
|
111
node_modules/@babel/traverse/lib/index.js
generated
vendored
Normal file
111
node_modules/@babel/traverse/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "Hub", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _hub.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "NodePath", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _path.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "Scope", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _scope.default;
|
||||
}
|
||||
});
|
||||
exports.visitors = exports.default = void 0;
|
||||
|
||||
var visitors = require("./visitors");
|
||||
|
||||
exports.visitors = visitors;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var cache = require("./cache");
|
||||
|
||||
var _traverseNode = require("./traverse-node");
|
||||
|
||||
var _path = require("./path");
|
||||
|
||||
var _scope = require("./scope");
|
||||
|
||||
var _hub = require("./hub");
|
||||
|
||||
const {
|
||||
VISITOR_KEYS,
|
||||
removeProperties,
|
||||
traverseFast
|
||||
} = _t;
|
||||
|
||||
function traverse(parent, opts = {}, scope, state, parentPath) {
|
||||
if (!parent) return;
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!VISITOR_KEYS[parent.type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
visitors.explode(opts);
|
||||
(0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath);
|
||||
}
|
||||
|
||||
var _default = traverse;
|
||||
exports.default = _default;
|
||||
traverse.visitors = visitors;
|
||||
traverse.verify = visitors.verify;
|
||||
traverse.explode = visitors.explode;
|
||||
|
||||
traverse.cheap = function (node, enter) {
|
||||
return traverseFast(node, enter);
|
||||
};
|
||||
|
||||
traverse.node = function (node, opts, scope, state, path, skipKeys) {
|
||||
(0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys);
|
||||
};
|
||||
|
||||
traverse.clearNode = function (node, opts) {
|
||||
removeProperties(node, opts);
|
||||
cache.path.delete(node);
|
||||
};
|
||||
|
||||
traverse.removeProperties = function (tree, opts) {
|
||||
traverseFast(tree, traverse.clearNode, opts);
|
||||
return tree;
|
||||
};
|
||||
|
||||
function hasDenylistedType(path, state) {
|
||||
if (path.node.type === state.type) {
|
||||
state.has = true;
|
||||
path.stop();
|
||||
}
|
||||
}
|
||||
|
||||
traverse.hasType = function (tree, type, denylistTypes) {
|
||||
if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
|
||||
if (tree.type === type) return true;
|
||||
const state = {
|
||||
has: false,
|
||||
type: type
|
||||
};
|
||||
traverse(tree, {
|
||||
noScope: true,
|
||||
denylist: denylistTypes,
|
||||
enter: hasDenylistedType
|
||||
}, null, state);
|
||||
return state.has;
|
||||
};
|
||||
|
||||
traverse.cache = cache;
|
180
node_modules/@babel/traverse/lib/path/ancestry.js
generated
vendored
Normal file
180
node_modules/@babel/traverse/lib/path/ancestry.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.find = find;
|
||||
exports.findParent = findParent;
|
||||
exports.getAncestry = getAncestry;
|
||||
exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
|
||||
exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
|
||||
exports.getFunctionParent = getFunctionParent;
|
||||
exports.getStatementParent = getStatementParent;
|
||||
exports.inType = inType;
|
||||
exports.isAncestor = isAncestor;
|
||||
exports.isDescendant = isDescendant;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _index = require("./index");
|
||||
|
||||
const {
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
|
||||
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 = VISITOR_KEYS[deepest.type];
|
||||
|
||||
for (const ancestry of ancestries) {
|
||||
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];
|
||||
|
||||
for (const ancestry of ancestries) {
|
||||
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(...candidateTypes) {
|
||||
let path = this;
|
||||
|
||||
while (path) {
|
||||
for (const type of candidateTypes) {
|
||||
if (path.node.type === type) return true;
|
||||
}
|
||||
|
||||
path = path.parentPath;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
42
node_modules/@babel/traverse/lib/path/comments.js
generated
vendored
Normal file
42
node_modules/@babel/traverse/lib/path/comments.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.addComment = addComment;
|
||||
exports.addComments = addComments;
|
||||
exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
addComment: _addComment,
|
||||
addComments: _addComments
|
||||
} = _t;
|
||||
|
||||
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) {
|
||||
prev.addComments("trailing", trailing);
|
||||
} else if (hasNext && !hasPrev) {
|
||||
next.addComments("leading", leading);
|
||||
}
|
||||
}
|
||||
|
||||
function addComment(type, content, line) {
|
||||
_addComment(this.node, type, content, line);
|
||||
}
|
||||
|
||||
function addComments(type, comments) {
|
||||
_addComments(this.node, type, comments);
|
||||
}
|
270
node_modules/@babel/traverse/lib/path/context.js
generated
vendored
Normal file
270
node_modules/@babel/traverse/lib/path/context.js
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._call = _call;
|
||||
exports._getQueueContexts = _getQueueContexts;
|
||||
exports._resyncKey = _resyncKey;
|
||||
exports._resyncList = _resyncList;
|
||||
exports._resyncParent = _resyncParent;
|
||||
exports._resyncRemoved = _resyncRemoved;
|
||||
exports.call = call;
|
||||
exports.isBlacklisted = exports.isDenylisted = isDenylisted;
|
||||
exports.popContext = popContext;
|
||||
exports.pushContext = pushContext;
|
||||
exports.requeue = requeue;
|
||||
exports.resync = resync;
|
||||
exports.setContext = setContext;
|
||||
exports.setKey = setKey;
|
||||
exports.setScope = setScope;
|
||||
exports.setup = setup;
|
||||
exports.skip = skip;
|
||||
exports.skipKey = skipKey;
|
||||
exports.stop = stop;
|
||||
exports.visit = visit;
|
||||
|
||||
var _traverseNode = require("../traverse-node");
|
||||
|
||||
var _index = require("./index");
|
||||
|
||||
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 (const fn of fns) {
|
||||
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._traverseFlags > 0) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isDenylisted() {
|
||||
var _this$opts$denylist;
|
||||
|
||||
const denylist = (_this$opts$denylist = this.opts.denylist) != null ? _this$opts$denylist : this.opts.blacklist;
|
||||
return denylist && denylist.indexOf(this.node.type) > -1;
|
||||
}
|
||||
|
||||
function restoreContext(path, context) {
|
||||
if (path.context !== context) {
|
||||
path.context = context;
|
||||
path.state = context.state;
|
||||
path.opts = context.opts;
|
||||
}
|
||||
}
|
||||
|
||||
function visit() {
|
||||
if (!this.node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isDenylisted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.opts.shouldSkip && this.opts.shouldSkip(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentContext = this.context;
|
||||
|
||||
if (this.shouldSkip || this.call("enter")) {
|
||||
this.debug("Skip...");
|
||||
return this.shouldStop;
|
||||
}
|
||||
|
||||
restoreContext(this, currentContext);
|
||||
this.debug("Recursing into...");
|
||||
this.shouldStop = (0, _traverseNode.traverseNode)(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
|
||||
restoreContext(this, currentContext);
|
||||
this.call("exit");
|
||||
return this.shouldStop;
|
||||
}
|
||||
|
||||
function skip() {
|
||||
this.shouldSkip = true;
|
||||
}
|
||||
|
||||
function skipKey(key) {
|
||||
if (this.skipKeys == null) {
|
||||
this.skipKeys = {};
|
||||
}
|
||||
|
||||
this.skipKeys[key] = true;
|
||||
}
|
||||
|
||||
function stop() {
|
||||
this._traverseFlags |= _index.SHOULD_SKIP | _index.SHOULD_STOP;
|
||||
}
|
||||
|
||||
function setScope() {
|
||||
if (this.opts && this.opts.noScope) return;
|
||||
let path = this.parentPath;
|
||||
|
||||
if ((this.key === "key" || this.listKey === "decorators") && path.isMethod()) {
|
||||
path = path.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) {
|
||||
if (this.skipKeys != null) {
|
||||
this.skipKeys = {};
|
||||
}
|
||||
|
||||
this._traverseFlags = 0;
|
||||
|
||||
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 of Object.keys(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.listKey = listKey;
|
||||
this.container = container;
|
||||
this.parentPath = parentPath || this.parentPath;
|
||||
this.setKey(key);
|
||||
}
|
||||
|
||||
function setKey(key) {
|
||||
var _this$node;
|
||||
|
||||
this.key = key;
|
||||
this.node = this.container[this.key];
|
||||
this.type = (_this$node = this.node) == null ? void 0 : _this$node.type;
|
||||
}
|
||||
|
||||
function requeue(pathToQueue = this) {
|
||||
if (pathToQueue.removed) return;
|
||||
;
|
||||
const contexts = this.contexts;
|
||||
|
||||
for (const context of contexts) {
|
||||
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;
|
||||
}
|
539
node_modules/@babel/traverse/lib/path/conversion.js
generated
vendored
Normal file
539
node_modules/@babel/traverse/lib/path/conversion.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
409
node_modules/@babel/traverse/lib/path/evaluation.js
generated
vendored
Normal file
409
node_modules/@babel/traverse/lib/path/evaluation.js
generated
vendored
Normal file
@@ -0,0 +1,409 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.evaluate = evaluate;
|
||||
exports.evaluateTruthy = evaluateTruthy;
|
||||
const VALID_CALLEES = ["String", "Number", "Math"];
|
||||
const INVALID_METHODS = ["random"];
|
||||
|
||||
function isValidCallee(val) {
|
||||
return VALID_CALLEES.includes(val);
|
||||
}
|
||||
|
||||
function isInvalidMethod(val) {
|
||||
return INVALID_METHODS.includes(val);
|
||||
}
|
||||
|
||||
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;
|
||||
const {
|
||||
seen
|
||||
} = state;
|
||||
|
||||
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;
|
||||
|
||||
if (path.isSequenceExpression()) {
|
||||
const exprs = path.get("expressions");
|
||||
return evaluateCached(exprs[exprs.length - 1], state);
|
||||
}
|
||||
|
||||
if (path.isStringLiteral() || path.isNumericLiteral() || path.isBooleanLiteral()) {
|
||||
return path.node.value;
|
||||
}
|
||||
|
||||
if (path.isNullLiteral()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (path.isTemplateLiteral()) {
|
||||
return evaluateQuasis(path, path.node.quasis, state);
|
||||
}
|
||||
|
||||
if (path.isTaggedTemplateExpression() && path.get("tag").isMemberExpression()) {
|
||||
const object = path.get("tag.object");
|
||||
const {
|
||||
node: {
|
||||
name
|
||||
}
|
||||
} = object;
|
||||
const property = path.get("tag.property");
|
||||
|
||||
if (object.isIdentifier() && name === "String" && !path.scope.getBinding(name) && property.isIdentifier() && property.node.name === "raw") {
|
||||
return evaluateQuasis(path, 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: path.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(path.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 != null && binding.hasValue) {
|
||||
return binding.value;
|
||||
} else {
|
||||
if (path.node.name === "undefined") {
|
||||
return binding ? deopt(binding.path, state) : undefined;
|
||||
} else if (path.node.name === "Infinity") {
|
||||
return binding ? deopt(binding.path, state) : Infinity;
|
||||
} else if (path.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 (path.node.operator === "void") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const argument = path.get("argument");
|
||||
|
||||
if (path.node.operator === "typeof" && (argument.isFunction() || argument.isClass())) {
|
||||
return "function";
|
||||
}
|
||||
|
||||
const arg = evaluateCached(argument, state);
|
||||
if (!state.confident) return;
|
||||
|
||||
switch (path.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 (const elem of elems) {
|
||||
const elemValue = elem.evaluate();
|
||||
|
||||
if (elemValue.confident) {
|
||||
arr.push(elemValue.value);
|
||||
} else {
|
||||
return deopt(elemValue.deopt, state);
|
||||
}
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (path.isObjectExpression()) {
|
||||
const obj = {};
|
||||
const props = path.get("properties");
|
||||
|
||||
for (const prop of props) {
|
||||
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(key.deopt, 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(value.deopt, 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;
|
||||
|
||||
switch (path.node.operator) {
|
||||
case "||":
|
||||
state.confident = leftConfident && (!!left || rightConfident);
|
||||
if (!state.confident) return;
|
||||
return left || right;
|
||||
|
||||
case "&&":
|
||||
state.confident = leftConfident && (!left || rightConfident);
|
||||
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 (path.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) && isValidCallee(callee.node.name)) {
|
||||
func = global[callee.node.name];
|
||||
}
|
||||
|
||||
if (callee.isMemberExpression()) {
|
||||
const object = callee.get("object");
|
||||
const property = callee.get("property");
|
||||
|
||||
if (object.isIdentifier() && property.isIdentifier() && isValidCallee(object.node.name) && !isInvalidMethod(property.node.name)) {
|
||||
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 (const elem of quasis) {
|
||||
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
|
||||
};
|
||||
}
|
407
node_modules/@babel/traverse/lib/path/family.js
generated
vendored
Normal file
407
node_modules/@babel/traverse/lib/path/family.js
generated
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._getKey = _getKey;
|
||||
exports._getPattern = _getPattern;
|
||||
exports.get = get;
|
||||
exports.getAllNextSiblings = getAllNextSiblings;
|
||||
exports.getAllPrevSiblings = getAllPrevSiblings;
|
||||
exports.getBindingIdentifierPaths = getBindingIdentifierPaths;
|
||||
exports.getBindingIdentifiers = getBindingIdentifiers;
|
||||
exports.getCompletionRecords = getCompletionRecords;
|
||||
exports.getNextSibling = getNextSibling;
|
||||
exports.getOpposite = getOpposite;
|
||||
exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
|
||||
exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
|
||||
exports.getPrevSibling = getPrevSibling;
|
||||
exports.getSibling = getSibling;
|
||||
|
||||
var _index = require("./index");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
getBindingIdentifiers: _getBindingIdentifiers,
|
||||
getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
|
||||
isDeclaration,
|
||||
numericLiteral,
|
||||
unaryExpression
|
||||
} = _t;
|
||||
const NORMAL_COMPLETION = 0;
|
||||
const BREAK_COMPLETION = 1;
|
||||
|
||||
function NormalCompletion(path) {
|
||||
return {
|
||||
type: NORMAL_COMPLETION,
|
||||
path
|
||||
};
|
||||
}
|
||||
|
||||
function BreakCompletion(path) {
|
||||
return {
|
||||
type: BREAK_COMPLETION,
|
||||
path
|
||||
};
|
||||
}
|
||||
|
||||
function getOpposite() {
|
||||
if (this.key === "left") {
|
||||
return this.getSibling("right");
|
||||
} else if (this.key === "right") {
|
||||
return this.getSibling("left");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function addCompletionRecords(path, records, context) {
|
||||
if (path) {
|
||||
records.push(..._getCompletionRecords(path, context));
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
function completionRecordForSwitch(cases, records, context) {
|
||||
let lastNormalCompletions = [];
|
||||
|
||||
for (let i = 0; i < cases.length; i++) {
|
||||
const casePath = cases[i];
|
||||
|
||||
const caseCompletions = _getCompletionRecords(casePath, context);
|
||||
|
||||
const normalCompletions = [];
|
||||
const breakCompletions = [];
|
||||
|
||||
for (const c of caseCompletions) {
|
||||
if (c.type === NORMAL_COMPLETION) {
|
||||
normalCompletions.push(c);
|
||||
}
|
||||
|
||||
if (c.type === BREAK_COMPLETION) {
|
||||
breakCompletions.push(c);
|
||||
}
|
||||
}
|
||||
|
||||
if (normalCompletions.length) {
|
||||
lastNormalCompletions = normalCompletions;
|
||||
}
|
||||
|
||||
records.push(...breakCompletions);
|
||||
}
|
||||
|
||||
records.push(...lastNormalCompletions);
|
||||
return records;
|
||||
}
|
||||
|
||||
function normalCompletionToBreak(completions) {
|
||||
completions.forEach(c => {
|
||||
c.type = BREAK_COMPLETION;
|
||||
});
|
||||
}
|
||||
|
||||
function replaceBreakStatementInBreakCompletion(completions, reachable) {
|
||||
completions.forEach(c => {
|
||||
if (c.path.isBreakStatement({
|
||||
label: null
|
||||
})) {
|
||||
if (reachable) {
|
||||
c.path.replaceWith(unaryExpression("void", numericLiteral(0)));
|
||||
} else {
|
||||
c.path.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getStatementListCompletion(paths, context) {
|
||||
const completions = [];
|
||||
|
||||
if (context.canHaveBreak) {
|
||||
let lastNormalCompletions = [];
|
||||
|
||||
for (let i = 0; i < paths.length; i++) {
|
||||
const path = paths[i];
|
||||
const newContext = Object.assign({}, context, {
|
||||
inCaseClause: false
|
||||
});
|
||||
|
||||
if (path.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) {
|
||||
newContext.shouldPopulateBreak = true;
|
||||
} else {
|
||||
newContext.shouldPopulateBreak = false;
|
||||
}
|
||||
|
||||
const statementCompletions = _getCompletionRecords(path, newContext);
|
||||
|
||||
if (statementCompletions.length > 0 && statementCompletions.every(c => c.type === BREAK_COMPLETION)) {
|
||||
if (lastNormalCompletions.length > 0 && statementCompletions.every(c => c.path.isBreakStatement({
|
||||
label: null
|
||||
}))) {
|
||||
normalCompletionToBreak(lastNormalCompletions);
|
||||
completions.push(...lastNormalCompletions);
|
||||
|
||||
if (lastNormalCompletions.some(c => c.path.isDeclaration())) {
|
||||
completions.push(...statementCompletions);
|
||||
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
||||
}
|
||||
|
||||
replaceBreakStatementInBreakCompletion(statementCompletions, false);
|
||||
} else {
|
||||
completions.push(...statementCompletions);
|
||||
|
||||
if (!context.shouldPopulateBreak) {
|
||||
replaceBreakStatementInBreakCompletion(statementCompletions, true);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (i === paths.length - 1) {
|
||||
completions.push(...statementCompletions);
|
||||
} else {
|
||||
lastNormalCompletions = [];
|
||||
|
||||
for (let i = 0; i < statementCompletions.length; i++) {
|
||||
const c = statementCompletions[i];
|
||||
|
||||
if (c.type === BREAK_COMPLETION) {
|
||||
completions.push(c);
|
||||
}
|
||||
|
||||
if (c.type === NORMAL_COMPLETION) {
|
||||
lastNormalCompletions.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (paths.length) {
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const pathCompletions = _getCompletionRecords(paths[i], context);
|
||||
|
||||
if (pathCompletions.length > 1 || pathCompletions.length === 1 && !pathCompletions[0].path.isVariableDeclaration()) {
|
||||
completions.push(...pathCompletions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return completions;
|
||||
}
|
||||
|
||||
function _getCompletionRecords(path, context) {
|
||||
let records = [];
|
||||
|
||||
if (path.isIfStatement()) {
|
||||
records = addCompletionRecords(path.get("consequent"), records, context);
|
||||
records = addCompletionRecords(path.get("alternate"), records, context);
|
||||
} else if (path.isDoExpression() || path.isFor() || path.isWhile() || path.isLabeledStatement()) {
|
||||
return addCompletionRecords(path.get("body"), records, context);
|
||||
} else if (path.isProgram() || path.isBlockStatement()) {
|
||||
return getStatementListCompletion(path.get("body"), context);
|
||||
} else if (path.isFunction()) {
|
||||
return _getCompletionRecords(path.get("body"), context);
|
||||
} else if (path.isTryStatement()) {
|
||||
records = addCompletionRecords(path.get("block"), records, context);
|
||||
records = addCompletionRecords(path.get("handler"), records, context);
|
||||
} else if (path.isCatchClause()) {
|
||||
return addCompletionRecords(path.get("body"), records, context);
|
||||
} else if (path.isSwitchStatement()) {
|
||||
return completionRecordForSwitch(path.get("cases"), records, context);
|
||||
} else if (path.isSwitchCase()) {
|
||||
return getStatementListCompletion(path.get("consequent"), {
|
||||
canHaveBreak: true,
|
||||
shouldPopulateBreak: false,
|
||||
inCaseClause: true
|
||||
});
|
||||
} else if (path.isBreakStatement()) {
|
||||
records.push(BreakCompletion(path));
|
||||
} else {
|
||||
records.push(NormalCompletion(path));
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
function getCompletionRecords() {
|
||||
const records = _getCompletionRecords(this, {
|
||||
canHaveBreak: false,
|
||||
shouldPopulateBreak: false,
|
||||
inCaseClause: false
|
||||
});
|
||||
|
||||
return records.map(r => r.path);
|
||||
}
|
||||
|
||||
function getSibling(key) {
|
||||
return _index.default.get({
|
||||
parentPath: this.parentPath,
|
||||
parent: this.parent,
|
||||
container: this.container,
|
||||
listKey: this.listKey,
|
||||
key: key
|
||||
}).setContext(this.context);
|
||||
}
|
||||
|
||||
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 = true) {
|
||||
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;
|
||||
|
||||
for (const part of parts) {
|
||||
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 _getBindingIdentifiers(this.node, duplicates);
|
||||
}
|
||||
|
||||
function getOuterBindingIdentifiers(duplicates) {
|
||||
return _getOuterBindingIdentifiers(this.node, duplicates);
|
||||
}
|
||||
|
||||
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
|
||||
const path = this;
|
||||
const search = [path];
|
||||
const ids = Object.create(null);
|
||||
|
||||
while (search.length) {
|
||||
const id = search.shift();
|
||||
if (!id) continue;
|
||||
if (!id.node) continue;
|
||||
const keys = _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 (isDeclaration(declaration)) {
|
||||
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)) {
|
||||
search.push(...child);
|
||||
} else if (child.node) {
|
||||
search.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
function getOuterBindingIdentifierPaths(duplicates = false) {
|
||||
return this.getBindingIdentifierPaths(duplicates, true);
|
||||
}
|
5
node_modules/@babel/traverse/lib/path/generated/asserts.js
generated
vendored
Normal file
5
node_modules/@babel/traverse/lib/path/generated/asserts.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var t = require("@babel/types");
|
||||
|
||||
var _index = require("../index");
|
0
node_modules/@babel/traverse/lib/path/generated/validators.js
generated
vendored
Normal file
0
node_modules/@babel/traverse/lib/path/generated/validators.js
generated
vendored
Normal file
259
node_modules/@babel/traverse/lib/path/index.js
generated
vendored
Normal file
259
node_modules/@babel/traverse/lib/path/index.js
generated
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.SHOULD_STOP = exports.SHOULD_SKIP = exports.REMOVED = void 0;
|
||||
|
||||
var virtualTypes = require("./lib/virtual-types");
|
||||
|
||||
var _debug = require("debug");
|
||||
|
||||
var _index = require("../index");
|
||||
|
||||
var _scope = require("../scope");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var t = _t;
|
||||
|
||||
var _cache = require("../cache");
|
||||
|
||||
var _generator = require("@babel/generator");
|
||||
|
||||
var NodePath_ancestry = require("./ancestry");
|
||||
|
||||
var NodePath_inference = require("./inference");
|
||||
|
||||
var NodePath_replacement = require("./replacement");
|
||||
|
||||
var NodePath_evaluation = require("./evaluation");
|
||||
|
||||
var NodePath_conversion = require("./conversion");
|
||||
|
||||
var NodePath_introspection = require("./introspection");
|
||||
|
||||
var NodePath_context = require("./context");
|
||||
|
||||
var NodePath_removal = require("./removal");
|
||||
|
||||
var NodePath_modification = require("./modification");
|
||||
|
||||
var NodePath_family = require("./family");
|
||||
|
||||
var NodePath_comments = require("./comments");
|
||||
|
||||
var NodePath_virtual_types_validator = require("./lib/virtual-types-validator");
|
||||
|
||||
const {
|
||||
validate
|
||||
} = _t;
|
||||
|
||||
const debug = _debug("babel");
|
||||
|
||||
const REMOVED = 1 << 0;
|
||||
exports.REMOVED = REMOVED;
|
||||
const SHOULD_STOP = 1 << 1;
|
||||
exports.SHOULD_STOP = SHOULD_STOP;
|
||||
const SHOULD_SKIP = 1 << 2;
|
||||
exports.SHOULD_SKIP = SHOULD_SKIP;
|
||||
|
||||
class NodePath {
|
||||
constructor(hub, parent) {
|
||||
this.contexts = [];
|
||||
this.state = null;
|
||||
this.opts = null;
|
||||
this._traverseFlags = 0;
|
||||
this.skipKeys = null;
|
||||
this.parentPath = null;
|
||||
this.container = null;
|
||||
this.listKey = null;
|
||||
this.key = null;
|
||||
this.node = null;
|
||||
this.type = null;
|
||||
this.parent = parent;
|
||||
this.hub = hub;
|
||||
this.data = null;
|
||||
this.context = null;
|
||||
this.scope = null;
|
||||
}
|
||||
|
||||
static get({
|
||||
hub,
|
||||
parentPath,
|
||||
parent,
|
||||
container,
|
||||
listKey,
|
||||
key
|
||||
}) {
|
||||
if (!hub && parentPath) {
|
||||
hub = parentPath.hub;
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
throw new Error("To get a node path the parent needs to exist");
|
||||
}
|
||||
|
||||
const targetNode = container[key];
|
||||
|
||||
let paths = _cache.path.get(parent);
|
||||
|
||||
if (!paths) {
|
||||
paths = new Map();
|
||||
|
||||
_cache.path.set(parent, paths);
|
||||
}
|
||||
|
||||
let path = paths.get(targetNode);
|
||||
|
||||
if (!path) {
|
||||
path = new NodePath(hub, parent);
|
||||
if (targetNode) paths.set(targetNode, path);
|
||||
}
|
||||
|
||||
path.setup(parentPath, container, listKey, key);
|
||||
return path;
|
||||
}
|
||||
|
||||
getScope(scope) {
|
||||
return this.isScope() ? new _scope.default(this) : scope;
|
||||
}
|
||||
|
||||
setData(key, val) {
|
||||
if (this.data == null) {
|
||||
this.data = Object.create(null);
|
||||
}
|
||||
|
||||
return this.data[key] = val;
|
||||
}
|
||||
|
||||
getData(key, def) {
|
||||
if (this.data == null) {
|
||||
this.data = Object.create(null);
|
||||
}
|
||||
|
||||
let val = this.data[key];
|
||||
if (val === undefined && def !== undefined) val = this.data[key] = def;
|
||||
return val;
|
||||
}
|
||||
|
||||
hasNode() {
|
||||
return this.node != null;
|
||||
}
|
||||
|
||||
buildCodeFrameError(msg, Error = SyntaxError) {
|
||||
return this.hub.buildError(this.node, msg, Error);
|
||||
}
|
||||
|
||||
traverse(visitor, state) {
|
||||
(0, _index.default)(this.node, visitor, this.scope, state, this);
|
||||
}
|
||||
|
||||
set(key, node) {
|
||||
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;
|
||||
}
|
||||
|
||||
get inList() {
|
||||
return !!this.listKey;
|
||||
}
|
||||
|
||||
set inList(inList) {
|
||||
if (!inList) {
|
||||
this.listKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
get parentKey() {
|
||||
return this.listKey || this.key;
|
||||
}
|
||||
|
||||
get shouldSkip() {
|
||||
return !!(this._traverseFlags & SHOULD_SKIP);
|
||||
}
|
||||
|
||||
set shouldSkip(v) {
|
||||
if (v) {
|
||||
this._traverseFlags |= SHOULD_SKIP;
|
||||
} else {
|
||||
this._traverseFlags &= ~SHOULD_SKIP;
|
||||
}
|
||||
}
|
||||
|
||||
get shouldStop() {
|
||||
return !!(this._traverseFlags & SHOULD_STOP);
|
||||
}
|
||||
|
||||
set shouldStop(v) {
|
||||
if (v) {
|
||||
this._traverseFlags |= SHOULD_STOP;
|
||||
} else {
|
||||
this._traverseFlags &= ~SHOULD_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
get removed() {
|
||||
return !!(this._traverseFlags & REMOVED);
|
||||
}
|
||||
|
||||
set removed(v) {
|
||||
if (v) {
|
||||
this._traverseFlags |= REMOVED;
|
||||
} else {
|
||||
this._traverseFlags &= ~REMOVED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
{
|
||||
NodePath.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo;
|
||||
}
|
||||
|
||||
for (const type of t.TYPES) {
|
||||
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}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Object.assign(NodePath.prototype, NodePath_virtual_types_validator);
|
||||
|
||||
for (const type of Object.keys(virtualTypes)) {
|
||||
if (type[0] === "_") continue;
|
||||
if (!t.TYPES.includes(type)) t.TYPES.push(type);
|
||||
}
|
||||
|
||||
var _default = NodePath;
|
||||
exports.default = _default;
|
180
node_modules/@babel/traverse/lib/path/inference/index.js
generated
vendored
Normal file
180
node_modules/@babel/traverse/lib/path/inference/index.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._getTypeAnnotation = _getTypeAnnotation;
|
||||
exports.baseTypeStrictlyMatches = baseTypeStrictlyMatches;
|
||||
exports.couldBeBaseType = couldBeBaseType;
|
||||
exports.getTypeAnnotation = getTypeAnnotation;
|
||||
exports.isBaseType = isBaseType;
|
||||
exports.isGenericType = isGenericType;
|
||||
|
||||
var inferers = require("./inferers");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
anyTypeAnnotation,
|
||||
isAnyTypeAnnotation,
|
||||
isArrayTypeAnnotation,
|
||||
isBooleanTypeAnnotation,
|
||||
isEmptyTypeAnnotation,
|
||||
isFlowBaseAnnotation,
|
||||
isGenericTypeAnnotation,
|
||||
isIdentifier,
|
||||
isMixedTypeAnnotation,
|
||||
isNumberTypeAnnotation,
|
||||
isStringTypeAnnotation,
|
||||
isTSArrayType,
|
||||
isTSTypeAnnotation,
|
||||
isTSTypeReference,
|
||||
isTupleTypeAnnotation,
|
||||
isTypeAnnotation,
|
||||
isUnionTypeAnnotation,
|
||||
isVoidTypeAnnotation,
|
||||
stringTypeAnnotation,
|
||||
voidTypeAnnotation
|
||||
} = _t;
|
||||
|
||||
function getTypeAnnotation() {
|
||||
let type = this.getData("typeAnnotation");
|
||||
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
|
||||
type = this._getTypeAnnotation() || anyTypeAnnotation();
|
||||
|
||||
if (isTypeAnnotation(type) || isTSTypeAnnotation(type)) {
|
||||
type = type.typeAnnotation;
|
||||
}
|
||||
|
||||
this.setData("typeAnnotation", type);
|
||||
return type;
|
||||
}
|
||||
|
||||
const typeAnnotationInferringNodes = new WeakSet();
|
||||
|
||||
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 stringTypeAnnotation();
|
||||
}
|
||||
|
||||
if (declar.key === "left" && declarParent.isForOfStatement()) {
|
||||
return anyTypeAnnotation();
|
||||
}
|
||||
|
||||
return voidTypeAnnotation();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.typeAnnotation) {
|
||||
return node.typeAnnotation;
|
||||
}
|
||||
|
||||
if (typeAnnotationInferringNodes.has(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
typeAnnotationInferringNodes.add(node);
|
||||
|
||||
try {
|
||||
var _inferer;
|
||||
|
||||
let inferer = inferers[node.type];
|
||||
|
||||
if (inferer) {
|
||||
return inferer.call(this, node);
|
||||
}
|
||||
|
||||
inferer = inferers[this.parentPath.type];
|
||||
|
||||
if ((_inferer = inferer) != null && _inferer.validParent) {
|
||||
return this.parentPath.getTypeAnnotation();
|
||||
}
|
||||
} finally {
|
||||
typeAnnotationInferringNodes.delete(node);
|
||||
}
|
||||
}
|
||||
|
||||
function isBaseType(baseName, soft) {
|
||||
return _isBaseType(baseName, this.getTypeAnnotation(), soft);
|
||||
}
|
||||
|
||||
function _isBaseType(baseName, type, soft) {
|
||||
if (baseName === "string") {
|
||||
return isStringTypeAnnotation(type);
|
||||
} else if (baseName === "number") {
|
||||
return isNumberTypeAnnotation(type);
|
||||
} else if (baseName === "boolean") {
|
||||
return isBooleanTypeAnnotation(type);
|
||||
} else if (baseName === "any") {
|
||||
return isAnyTypeAnnotation(type);
|
||||
} else if (baseName === "mixed") {
|
||||
return isMixedTypeAnnotation(type);
|
||||
} else if (baseName === "empty") {
|
||||
return isEmptyTypeAnnotation(type);
|
||||
} else if (baseName === "void") {
|
||||
return isVoidTypeAnnotation(type);
|
||||
} else {
|
||||
if (soft) {
|
||||
return false;
|
||||
} else {
|
||||
throw new Error(`Unknown base type ${baseName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function couldBeBaseType(name) {
|
||||
const type = this.getTypeAnnotation();
|
||||
if (isAnyTypeAnnotation(type)) return true;
|
||||
|
||||
if (isUnionTypeAnnotation(type)) {
|
||||
for (const type2 of type.types) {
|
||||
if (isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return _isBaseType(name, type, true);
|
||||
}
|
||||
}
|
||||
|
||||
function baseTypeStrictlyMatches(rightArg) {
|
||||
const left = this.getTypeAnnotation();
|
||||
const right = rightArg.getTypeAnnotation();
|
||||
|
||||
if (!isAnyTypeAnnotation(left) && isFlowBaseAnnotation(left)) {
|
||||
return right.type === left.type;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isGenericType(genericName) {
|
||||
const type = this.getTypeAnnotation();
|
||||
|
||||
if (genericName === "Array") {
|
||||
if (isTSArrayType(type) || isArrayTypeAnnotation(type) || isTupleTypeAnnotation(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return isGenericTypeAnnotation(type) && isIdentifier(type.id, {
|
||||
name: genericName
|
||||
}) || isTSTypeReference(type) && isIdentifier(type.typeName, {
|
||||
name: genericName
|
||||
});
|
||||
}
|
182
node_modules/@babel/traverse/lib/path/inference/inferer-reference.js
generated
vendored
Normal file
182
node_modules/@babel/traverse/lib/path/inference/inferer-reference.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
const {
|
||||
BOOLEAN_NUMBER_BINARY_OPERATORS,
|
||||
createTypeAnnotationBasedOnTypeof,
|
||||
numberTypeAnnotation,
|
||||
voidTypeAnnotation
|
||||
} = _t;
|
||||
|
||||
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 voidTypeAnnotation();
|
||||
} else if (node.name === "NaN" || node.name === "Infinity") {
|
||||
return 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.push(...functionConstantViolations);
|
||||
|
||||
for (const violation of constantViolations) {
|
||||
types.push(violation.getTypeAnnotation());
|
||||
}
|
||||
}
|
||||
|
||||
if (!types.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (0, _util.createUnionType)(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 === "unknown") 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 (BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return 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 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: (0, _util.createUnionType)(types),
|
||||
ifStatement
|
||||
};
|
||||
}
|
||||
|
||||
return getConditionalAnnotation(binding, ifStatement, name);
|
||||
}
|
248
node_modules/@babel/traverse/lib/path/inference/inferers.js
generated
vendored
Normal file
248
node_modules/@babel/traverse/lib/path/inference/inferers.js
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArrayExpression = ArrayExpression;
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.BooleanLiteral = BooleanLiteral;
|
||||
exports.CallExpression = CallExpression;
|
||||
exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.ClassDeclaration = exports.ClassExpression = exports.FunctionDeclaration = exports.ArrowFunctionExpression = exports.FunctionExpression = Func;
|
||||
Object.defineProperty(exports, "Identifier", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _infererReference.default;
|
||||
}
|
||||
});
|
||||
exports.LogicalExpression = LogicalExpression;
|
||||
exports.NewExpression = NewExpression;
|
||||
exports.NullLiteral = NullLiteral;
|
||||
exports.NumericLiteral = NumericLiteral;
|
||||
exports.ObjectExpression = ObjectExpression;
|
||||
exports.ParenthesizedExpression = ParenthesizedExpression;
|
||||
exports.RegExpLiteral = RegExpLiteral;
|
||||
exports.RestElement = RestElement;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSNonNullExpression = TSNonNullExpression;
|
||||
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
exports.TypeCastExpression = TypeCastExpression;
|
||||
exports.UnaryExpression = UnaryExpression;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _infererReference = require("./inferer-reference");
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
const {
|
||||
BOOLEAN_BINARY_OPERATORS,
|
||||
BOOLEAN_UNARY_OPERATORS,
|
||||
NUMBER_BINARY_OPERATORS,
|
||||
NUMBER_UNARY_OPERATORS,
|
||||
STRING_UNARY_OPERATORS,
|
||||
anyTypeAnnotation,
|
||||
arrayTypeAnnotation,
|
||||
booleanTypeAnnotation,
|
||||
buildMatchMemberExpression,
|
||||
genericTypeAnnotation,
|
||||
identifier,
|
||||
nullLiteralTypeAnnotation,
|
||||
numberTypeAnnotation,
|
||||
stringTypeAnnotation,
|
||||
tupleTypeAnnotation,
|
||||
unionTypeAnnotation,
|
||||
voidTypeAnnotation,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
|
||||
function VariableDeclarator() {
|
||||
if (!this.get("id").isIdentifier()) return;
|
||||
return this.get("init").getTypeAnnotation();
|
||||
}
|
||||
|
||||
function TypeCastExpression(node) {
|
||||
return node.typeAnnotation;
|
||||
}
|
||||
|
||||
TypeCastExpression.validParent = true;
|
||||
|
||||
function TSAsExpression(node) {
|
||||
return node.typeAnnotation;
|
||||
}
|
||||
|
||||
TSAsExpression.validParent = true;
|
||||
|
||||
function TSNonNullExpression() {
|
||||
return this.get("expression").getTypeAnnotation();
|
||||
}
|
||||
|
||||
function NewExpression(node) {
|
||||
if (node.callee.type === "Identifier") {
|
||||
return genericTypeAnnotation(node.callee);
|
||||
}
|
||||
}
|
||||
|
||||
function TemplateLiteral() {
|
||||
return stringTypeAnnotation();
|
||||
}
|
||||
|
||||
function UnaryExpression(node) {
|
||||
const operator = node.operator;
|
||||
|
||||
if (operator === "void") {
|
||||
return voidTypeAnnotation();
|
||||
} else if (NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return numberTypeAnnotation();
|
||||
} else if (STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return stringTypeAnnotation();
|
||||
} else if (BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return booleanTypeAnnotation();
|
||||
}
|
||||
}
|
||||
|
||||
function BinaryExpression(node) {
|
||||
const operator = node.operator;
|
||||
|
||||
if (NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return numberTypeAnnotation();
|
||||
} else if (BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
|
||||
return booleanTypeAnnotation();
|
||||
} else if (operator === "+") {
|
||||
const right = this.get("right");
|
||||
const left = this.get("left");
|
||||
|
||||
if (left.isBaseType("number") && right.isBaseType("number")) {
|
||||
return numberTypeAnnotation();
|
||||
} else if (left.isBaseType("string") || right.isBaseType("string")) {
|
||||
return stringTypeAnnotation();
|
||||
}
|
||||
|
||||
return unionTypeAnnotation([stringTypeAnnotation(), numberTypeAnnotation()]);
|
||||
}
|
||||
}
|
||||
|
||||
function LogicalExpression() {
|
||||
const argumentTypes = [this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()];
|
||||
return (0, _util.createUnionType)(argumentTypes);
|
||||
}
|
||||
|
||||
function ConditionalExpression() {
|
||||
const argumentTypes = [this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()];
|
||||
return (0, _util.createUnionType)(argumentTypes);
|
||||
}
|
||||
|
||||
function SequenceExpression() {
|
||||
return this.get("expressions").pop().getTypeAnnotation();
|
||||
}
|
||||
|
||||
function ParenthesizedExpression() {
|
||||
return this.get("expression").getTypeAnnotation();
|
||||
}
|
||||
|
||||
function AssignmentExpression() {
|
||||
return this.get("right").getTypeAnnotation();
|
||||
}
|
||||
|
||||
function UpdateExpression(node) {
|
||||
const operator = node.operator;
|
||||
|
||||
if (operator === "++" || operator === "--") {
|
||||
return numberTypeAnnotation();
|
||||
}
|
||||
}
|
||||
|
||||
function StringLiteral() {
|
||||
return stringTypeAnnotation();
|
||||
}
|
||||
|
||||
function NumericLiteral() {
|
||||
return numberTypeAnnotation();
|
||||
}
|
||||
|
||||
function BooleanLiteral() {
|
||||
return booleanTypeAnnotation();
|
||||
}
|
||||
|
||||
function NullLiteral() {
|
||||
return nullLiteralTypeAnnotation();
|
||||
}
|
||||
|
||||
function RegExpLiteral() {
|
||||
return genericTypeAnnotation(identifier("RegExp"));
|
||||
}
|
||||
|
||||
function ObjectExpression() {
|
||||
return genericTypeAnnotation(identifier("Object"));
|
||||
}
|
||||
|
||||
function ArrayExpression() {
|
||||
return genericTypeAnnotation(identifier("Array"));
|
||||
}
|
||||
|
||||
function RestElement() {
|
||||
return ArrayExpression();
|
||||
}
|
||||
|
||||
RestElement.validParent = true;
|
||||
|
||||
function Func() {
|
||||
return genericTypeAnnotation(identifier("Function"));
|
||||
}
|
||||
|
||||
const isArrayFrom = buildMatchMemberExpression("Array.from");
|
||||
const isObjectKeys = buildMatchMemberExpression("Object.keys");
|
||||
const isObjectValues = buildMatchMemberExpression("Object.values");
|
||||
const isObjectEntries = buildMatchMemberExpression("Object.entries");
|
||||
|
||||
function CallExpression() {
|
||||
const {
|
||||
callee
|
||||
} = this.node;
|
||||
|
||||
if (isObjectKeys(callee)) {
|
||||
return arrayTypeAnnotation(stringTypeAnnotation());
|
||||
} else if (isArrayFrom(callee) || isObjectValues(callee) || isIdentifier(callee, {
|
||||
name: "Array"
|
||||
})) {
|
||||
return arrayTypeAnnotation(anyTypeAnnotation());
|
||||
} else if (isObjectEntries(callee)) {
|
||||
return arrayTypeAnnotation(tupleTypeAnnotation([stringTypeAnnotation(), anyTypeAnnotation()]));
|
||||
}
|
||||
|
||||
return resolveCall(this.get("callee"));
|
||||
}
|
||||
|
||||
function TaggedTemplateExpression() {
|
||||
return resolveCall(this.get("tag"));
|
||||
}
|
||||
|
||||
function resolveCall(callee) {
|
||||
callee = callee.resolve();
|
||||
|
||||
if (callee.isFunction()) {
|
||||
const {
|
||||
node
|
||||
} = callee;
|
||||
|
||||
if (node.async) {
|
||||
if (node.generator) {
|
||||
return genericTypeAnnotation(identifier("AsyncIterator"));
|
||||
} else {
|
||||
return genericTypeAnnotation(identifier("Promise"));
|
||||
}
|
||||
} else {
|
||||
if (node.generator) {
|
||||
return genericTypeAnnotation(identifier("Iterator"));
|
||||
} else if (callee.node.returnType) {
|
||||
return callee.node.returnType;
|
||||
} else {}
|
||||
}
|
||||
}
|
||||
}
|
32
node_modules/@babel/traverse/lib/path/inference/util.js
generated
vendored
Normal file
32
node_modules/@babel/traverse/lib/path/inference/util.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createUnionType = createUnionType;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
createFlowUnionType,
|
||||
createTSUnionType,
|
||||
createUnionTypeAnnotation,
|
||||
isFlowType,
|
||||
isTSType
|
||||
} = _t;
|
||||
|
||||
function createUnionType(types) {
|
||||
{
|
||||
if (isFlowType(types[0])) {
|
||||
if (createFlowUnionType) {
|
||||
return createFlowUnionType(types);
|
||||
}
|
||||
|
||||
return createUnionTypeAnnotation(types);
|
||||
} else {
|
||||
if (createTSUnionType) {
|
||||
return createTSUnionType(types);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
466
node_modules/@babel/traverse/lib/path/introspection.js
generated
vendored
Normal file
466
node_modules/@babel/traverse/lib/path/introspection.js
generated
vendored
Normal file
@@ -0,0 +1,466 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._guessExecutionStatusRelativeTo = _guessExecutionStatusRelativeTo;
|
||||
exports._resolve = _resolve;
|
||||
exports.canHaveVariableDeclarationOrExpression = canHaveVariableDeclarationOrExpression;
|
||||
exports.canSwapBetweenExpressionAndStatement = canSwapBetweenExpressionAndStatement;
|
||||
exports.equals = equals;
|
||||
exports.getSource = getSource;
|
||||
exports.has = has;
|
||||
exports.is = void 0;
|
||||
exports.isCompletionRecord = isCompletionRecord;
|
||||
exports.isConstantExpression = isConstantExpression;
|
||||
exports.isInStrictMode = isInStrictMode;
|
||||
exports.isNodeType = isNodeType;
|
||||
exports.isStatementOrBlock = isStatementOrBlock;
|
||||
exports.isStatic = isStatic;
|
||||
exports.isnt = isnt;
|
||||
exports.matchesPattern = matchesPattern;
|
||||
exports.referencesImport = referencesImport;
|
||||
exports.resolve = resolve;
|
||||
exports.willIMaybeExecuteBefore = willIMaybeExecuteBefore;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
STATEMENT_OR_BLOCK_KEYS,
|
||||
VISITOR_KEYS,
|
||||
isBlockStatement,
|
||||
isExpression,
|
||||
isIdentifier,
|
||||
isLiteral,
|
||||
isStringLiteral,
|
||||
isType,
|
||||
matchesPattern: _matchesPattern
|
||||
} = _t;
|
||||
|
||||
function matchesPattern(pattern, allowPartial) {
|
||||
return _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 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 isBlockStatement(replacement);
|
||||
} else if (this.isBlockStatement()) {
|
||||
return isExpression(replacement);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isCompletionRecord(allowInsideFunction) {
|
||||
let path = this;
|
||||
let first = true;
|
||||
|
||||
do {
|
||||
const {
|
||||
type,
|
||||
container
|
||||
} = path;
|
||||
|
||||
if (!first && (path.isFunction() || type === "StaticBlock")) {
|
||||
return !!allowInsideFunction;
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
if (Array.isArray(container) && path.key !== container.length - 1) {
|
||||
return false;
|
||||
}
|
||||
} while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isStatementOrBlock() {
|
||||
if (this.parentPath.isLabeledStatement() || isBlockStatement(this.container)) {
|
||||
return false;
|
||||
} else {
|
||||
return STATEMENT_OR_BLOCK_KEYS.includes(this.key);
|
||||
}
|
||||
}
|
||||
|
||||
function referencesImport(moduleSource, importName) {
|
||||
if (!this.isReferencedIdentifier()) {
|
||||
if (this.isJSXMemberExpression() && this.node.property.name === importName || (this.isMemberExpression() || this.isOptionalMemberExpression()) && (this.node.computed ? isStringLiteral(this.node.property, {
|
||||
value: importName
|
||||
}) : this.node.property.name === importName)) {
|
||||
const object = this.get("object");
|
||||
return object.isReferencedIdentifier() && object.referencesImport(moduleSource, "*");
|
||||
}
|
||||
|
||||
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() && isIdentifier(path.node.imported, {
|
||||
name: importName
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSource() {
|
||||
const node = this.node;
|
||||
|
||||
if (node.end) {
|
||||
const code = this.hub.getCode();
|
||||
if (code) return code.slice(node.start, node.end);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function willIMaybeExecuteBefore(target) {
|
||||
return this._guessExecutionStatusRelativeTo(target) !== "after";
|
||||
}
|
||||
|
||||
function getOuterFunction(path) {
|
||||
return (path.scope.getFunctionParent() || path.scope.getProgramParent()).path;
|
||||
}
|
||||
|
||||
function isExecutionUncertain(type, key) {
|
||||
switch (type) {
|
||||
case "LogicalExpression":
|
||||
return key === "right";
|
||||
|
||||
case "ConditionalExpression":
|
||||
case "IfStatement":
|
||||
return key === "consequent" || key === "alternate";
|
||||
|
||||
case "WhileStatement":
|
||||
case "DoWhileStatement":
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
return key === "body";
|
||||
|
||||
case "ForStatement":
|
||||
return key === "body" || key === "update";
|
||||
|
||||
case "SwitchStatement":
|
||||
return key === "cases";
|
||||
|
||||
case "TryStatement":
|
||||
return key === "handler";
|
||||
|
||||
case "AssignmentPattern":
|
||||
return key === "right";
|
||||
|
||||
case "OptionalMemberExpression":
|
||||
return key === "property";
|
||||
|
||||
case "OptionalCallExpression":
|
||||
return key === "arguments";
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isExecutionUncertainInList(paths, maxIndex) {
|
||||
for (let i = 0; i < maxIndex; i++) {
|
||||
const path = paths[i];
|
||||
|
||||
if (isExecutionUncertain(path.parent.type, path.parentKey)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _guessExecutionStatusRelativeTo(target) {
|
||||
return _guessExecutionStatusRelativeToCached(this, target, new Map());
|
||||
}
|
||||
|
||||
function _guessExecutionStatusRelativeToCached(base, target, cache) {
|
||||
const funcParent = {
|
||||
this: getOuterFunction(base),
|
||||
target: getOuterFunction(target)
|
||||
};
|
||||
|
||||
if (funcParent.target.node !== funcParent.this.node) {
|
||||
return _guessExecutionStatusRelativeToDifferentFunctionsCached(base, funcParent.target, cache);
|
||||
}
|
||||
|
||||
const paths = {
|
||||
target: target.getAncestry(),
|
||||
this: base.getAncestry()
|
||||
};
|
||||
if (paths.target.indexOf(base) >= 0) return "after";
|
||||
if (paths.this.indexOf(target) >= 0) return "before";
|
||||
let commonPath;
|
||||
const commonIndex = {
|
||||
target: 0,
|
||||
this: 0
|
||||
};
|
||||
|
||||
while (!commonPath && commonIndex.this < paths.this.length) {
|
||||
const path = paths.this[commonIndex.this];
|
||||
commonIndex.target = paths.target.indexOf(path);
|
||||
|
||||
if (commonIndex.target >= 0) {
|
||||
commonPath = path;
|
||||
} else {
|
||||
commonIndex.this++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!commonPath) {
|
||||
throw new Error("Internal Babel error - The two compared nodes" + " don't appear to belong to the same program.");
|
||||
}
|
||||
|
||||
if (isExecutionUncertainInList(paths.this, commonIndex.this - 1) || isExecutionUncertainInList(paths.target, commonIndex.target - 1)) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const divergence = {
|
||||
this: paths.this[commonIndex.this - 1],
|
||||
target: paths.target[commonIndex.target - 1]
|
||||
};
|
||||
|
||||
if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) {
|
||||
return divergence.target.key > divergence.this.key ? "before" : "after";
|
||||
}
|
||||
|
||||
const keys = VISITOR_KEYS[commonPath.type];
|
||||
const keyPosition = {
|
||||
this: keys.indexOf(divergence.this.parentKey),
|
||||
target: keys.indexOf(divergence.target.parentKey)
|
||||
};
|
||||
return keyPosition.target > keyPosition.this ? "before" : "after";
|
||||
}
|
||||
|
||||
const executionOrderCheckedNodes = new Set();
|
||||
|
||||
function _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache) {
|
||||
if (!target.isFunctionDeclaration() || target.parentPath.isExportDeclaration()) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const binding = target.scope.getBinding(target.node.id.name);
|
||||
if (!binding.references) return "before";
|
||||
const referencePaths = binding.referencePaths;
|
||||
let allStatus;
|
||||
|
||||
for (const path of referencePaths) {
|
||||
const childOfFunction = !!path.find(path => path.node === target.node);
|
||||
if (childOfFunction) continue;
|
||||
|
||||
if (path.key !== "callee" || !path.parentPath.isCallExpression()) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
if (executionOrderCheckedNodes.has(path.node)) continue;
|
||||
executionOrderCheckedNodes.add(path.node);
|
||||
|
||||
try {
|
||||
const status = _guessExecutionStatusRelativeToCached(base, path, cache);
|
||||
|
||||
if (allStatus && allStatus !== status) {
|
||||
return "unknown";
|
||||
} else {
|
||||
allStatus = status;
|
||||
}
|
||||
} finally {
|
||||
executionOrderCheckedNodes.delete(path.node);
|
||||
}
|
||||
}
|
||||
|
||||
return allStatus;
|
||||
}
|
||||
|
||||
function _guessExecutionStatusRelativeToDifferentFunctionsCached(base, target, cache) {
|
||||
let nodeMap = cache.get(base.node);
|
||||
|
||||
if (!nodeMap) {
|
||||
cache.set(base.node, nodeMap = new Map());
|
||||
} else if (nodeMap.has(target.node)) {
|
||||
return nodeMap.get(target.node);
|
||||
}
|
||||
|
||||
const result = _guessExecutionStatusRelativeToDifferentFunctionsInternal(base, target, cache);
|
||||
|
||||
nodeMap.set(target.node, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
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 (!isLiteral(targetKey)) return;
|
||||
const targetName = targetKey.value;
|
||||
const target = this.get("object").resolve(dangerous, resolved);
|
||||
|
||||
if (target.isObjectExpression()) {
|
||||
const props = target.get("properties");
|
||||
|
||||
for (const prop of props) {
|
||||
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;
|
||||
}
|
||||
|
||||
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.node.operator !== "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.isArrowFunctionExpression() && !path.get("body").isBlockStatement()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let body;
|
||||
|
||||
if (path.isFunction()) {
|
||||
body = path.node.body;
|
||||
} else if (path.isProgram()) {
|
||||
body = path.node;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const directive of body.directives) {
|
||||
if (directive.value.value === "use strict") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return !!strictParent;
|
||||
}
|
206
node_modules/@babel/traverse/lib/path/lib/hoister.js
generated
vendored
Normal file
206
node_modules/@babel/traverse/lib/path/lib/hoister.js
generated
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _t2 = _t;
|
||||
const {
|
||||
react
|
||||
} = _t;
|
||||
const {
|
||||
cloneNode,
|
||||
jsxExpressionContainer,
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t2;
|
||||
const referenceVisitor = {
|
||||
ReferencedIdentifier(path, state) {
|
||||
if (path.isJSXIdentifier() && 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;
|
||||
|
||||
for (const violation of binding.constantViolations) {
|
||||
if (violation.scope !== binding.path.scope) {
|
||||
state.mutableBinding = true;
|
||||
path.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (binding !== state.scope.getBinding(path.node.name)) return;
|
||||
state.bindings[path.node.name] = binding;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class PathHoister {
|
||||
constructor(path, scope) {
|
||||
this.breakOnScopePaths = void 0;
|
||||
this.bindings = void 0;
|
||||
this.mutableBinding = void 0;
|
||||
this.scopes = void 0;
|
||||
this.scope = void 0;
|
||||
this.path = void 0;
|
||||
this.attachAfter = void 0;
|
||||
this.breakOnScopePaths = [];
|
||||
this.bindings = {};
|
||||
this.mutableBinding = false;
|
||||
this.scopes = [];
|
||||
this.scope = scope;
|
||||
this.path = path;
|
||||
this.attachAfter = false;
|
||||
}
|
||||
|
||||
isCompatibleScope(scope) {
|
||||
for (const key of Object.keys(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 of Object.keys(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;
|
||||
|
||||
for (const violationPath of binding.constantViolations) {
|
||||
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 of Object.keys(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);
|
||||
if (this.mutableBinding) return;
|
||||
this.getCompatibleScopes();
|
||||
const attachTo = this.getAttachmentPath();
|
||||
if (!attachTo) return;
|
||||
if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
|
||||
let uid = attachTo.scope.generateUidIdentifier("ref");
|
||||
const declarator = variableDeclarator(uid, this.path.node);
|
||||
const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
|
||||
const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : variableDeclaration("var", [declarator])]);
|
||||
const parent = this.path.parentPath;
|
||||
|
||||
if (parent.isJSXElement() && this.path.container === parent.node.children) {
|
||||
uid = jsxExpressionContainer(uid);
|
||||
}
|
||||
|
||||
this.path.replaceWith(cloneNode(uid));
|
||||
return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = PathHoister;
|
41
node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
generated
vendored
Normal file
41
node_modules/@babel/traverse/lib/path/lib/removal-hooks.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hooks = void 0;
|
||||
|
||||
var _ = require("..");
|
||||
|
||||
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;
|
183
node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js
generated
vendored
Normal file
183
node_modules/@babel/traverse/lib/path/lib/virtual-types-validator.js
generated
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isBindingIdentifier = isBindingIdentifier;
|
||||
exports.isBlockScoped = isBlockScoped;
|
||||
exports.isExistentialTypeParam = isExistentialTypeParam;
|
||||
exports.isExpression = isExpression;
|
||||
exports.isFlow = isFlow;
|
||||
exports.isForAwaitStatement = isForAwaitStatement;
|
||||
exports.isGenerated = isGenerated;
|
||||
exports.isNumericLiteralTypeAnnotation = isNumericLiteralTypeAnnotation;
|
||||
exports.isPure = isPure;
|
||||
exports.isReferenced = isReferenced;
|
||||
exports.isReferencedIdentifier = isReferencedIdentifier;
|
||||
exports.isReferencedMemberExpression = isReferencedMemberExpression;
|
||||
exports.isRestProperty = isRestProperty;
|
||||
exports.isScope = isScope;
|
||||
exports.isSpreadProperty = isSpreadProperty;
|
||||
exports.isStatement = isStatement;
|
||||
exports.isUser = isUser;
|
||||
exports.isVar = isVar;
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
isBinding,
|
||||
isBlockScoped: nodeIsBlockScoped,
|
||||
isExportDeclaration,
|
||||
isExpression: nodeIsExpression,
|
||||
isFlow: nodeIsFlow,
|
||||
isForStatement,
|
||||
isForXStatement,
|
||||
isIdentifier,
|
||||
isImportDeclaration,
|
||||
isImportSpecifier,
|
||||
isJSXIdentifier,
|
||||
isJSXMemberExpression,
|
||||
isMemberExpression,
|
||||
isRestElement: nodeIsRestElement,
|
||||
isReferenced: nodeIsReferenced,
|
||||
isScope: nodeIsScope,
|
||||
isStatement: nodeIsStatement,
|
||||
isVar: nodeIsVar,
|
||||
isVariableDeclaration,
|
||||
react
|
||||
} = _t;
|
||||
const {
|
||||
isCompatTag
|
||||
} = react;
|
||||
|
||||
function isReferencedIdentifier(opts) {
|
||||
const {
|
||||
node,
|
||||
parent
|
||||
} = this;
|
||||
|
||||
if (!isIdentifier(node, opts) && !isJSXMemberExpression(parent, opts)) {
|
||||
if (isJSXIdentifier(node, opts)) {
|
||||
if (isCompatTag(node.name)) return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return nodeIsReferenced(node, parent, this.parentPath.parent);
|
||||
}
|
||||
|
||||
function isReferencedMemberExpression() {
|
||||
const {
|
||||
node,
|
||||
parent
|
||||
} = this;
|
||||
return isMemberExpression(node) && nodeIsReferenced(node, parent);
|
||||
}
|
||||
|
||||
function isBindingIdentifier() {
|
||||
const {
|
||||
node,
|
||||
parent
|
||||
} = this;
|
||||
const grandparent = this.parentPath.parent;
|
||||
return isIdentifier(node) && isBinding(node, parent, grandparent);
|
||||
}
|
||||
|
||||
function isStatement() {
|
||||
const {
|
||||
node,
|
||||
parent
|
||||
} = this;
|
||||
|
||||
if (nodeIsStatement(node)) {
|
||||
if (isVariableDeclaration(node)) {
|
||||
if (isForXStatement(parent, {
|
||||
left: node
|
||||
})) return false;
|
||||
if (isForStatement(parent, {
|
||||
init: node
|
||||
})) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isExpression() {
|
||||
if (this.isIdentifier()) {
|
||||
return this.isReferencedIdentifier();
|
||||
} else {
|
||||
return nodeIsExpression(this.node);
|
||||
}
|
||||
}
|
||||
|
||||
function isScope() {
|
||||
return nodeIsScope(this.node, this.parent);
|
||||
}
|
||||
|
||||
function isReferenced() {
|
||||
return nodeIsReferenced(this.node, this.parent);
|
||||
}
|
||||
|
||||
function isBlockScoped() {
|
||||
return nodeIsBlockScoped(this.node);
|
||||
}
|
||||
|
||||
function isVar() {
|
||||
return nodeIsVar(this.node);
|
||||
}
|
||||
|
||||
function isUser() {
|
||||
return this.node && !!this.node.loc;
|
||||
}
|
||||
|
||||
function isGenerated() {
|
||||
return !this.isUser();
|
||||
}
|
||||
|
||||
function isPure(constantsOnly) {
|
||||
return this.scope.isPure(this.node, constantsOnly);
|
||||
}
|
||||
|
||||
function isFlow() {
|
||||
const {
|
||||
node
|
||||
} = this;
|
||||
|
||||
if (nodeIsFlow(node)) {
|
||||
return true;
|
||||
} else if (isImportDeclaration(node)) {
|
||||
return node.importKind === "type" || node.importKind === "typeof";
|
||||
} else if (isExportDeclaration(node)) {
|
||||
return node.exportKind === "type";
|
||||
} else if (isImportSpecifier(node)) {
|
||||
return node.importKind === "type" || node.importKind === "typeof";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isRestProperty() {
|
||||
return nodeIsRestElement(this.node) && this.parentPath && this.parentPath.isObjectPattern();
|
||||
}
|
||||
|
||||
function isSpreadProperty() {
|
||||
return nodeIsRestElement(this.node) && this.parentPath && this.parentPath.isObjectExpression();
|
||||
}
|
||||
|
||||
function isForAwaitStatement() {
|
||||
return isForStatement(this.node, {
|
||||
await: true
|
||||
});
|
||||
}
|
||||
|
||||
function isExistentialTypeParam() {
|
||||
throw new Error("`path.isExistentialTypeParam` has been renamed to `path.isExistsTypeAnnotation()` in Babel 7.");
|
||||
}
|
||||
|
||||
function isNumericLiteralTypeAnnotation() {
|
||||
throw new Error("`path.isNumericLiteralTypeAnnotation()` has been renamed to `path.isNumberLiteralTypeAnnotation()` in Babel 7.");
|
||||
}
|
42
node_modules/@babel/traverse/lib/path/lib/virtual-types.js
generated
vendored
Normal file
42
node_modules/@babel/traverse/lib/path/lib/virtual-types.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.Var = exports.User = exports.Statement = exports.SpreadProperty = exports.Scope = exports.RestProperty = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = exports.Referenced = exports.Pure = exports.NumericLiteralTypeAnnotation = exports.Generated = exports.ForAwaitStatement = exports.Flow = exports.Expression = exports.ExistentialTypeParam = exports.BlockScoped = exports.BindingIdentifier = void 0;
|
||||
const ReferencedIdentifier = ["Identifier", "JSXIdentifier"];
|
||||
exports.ReferencedIdentifier = ReferencedIdentifier;
|
||||
const ReferencedMemberExpression = ["MemberExpression"];
|
||||
exports.ReferencedMemberExpression = ReferencedMemberExpression;
|
||||
const BindingIdentifier = ["Identifier"];
|
||||
exports.BindingIdentifier = BindingIdentifier;
|
||||
const Statement = ["Statement"];
|
||||
exports.Statement = Statement;
|
||||
const Expression = ["Expression"];
|
||||
exports.Expression = Expression;
|
||||
const Scope = ["Scopable", "Pattern"];
|
||||
exports.Scope = Scope;
|
||||
const Referenced = null;
|
||||
exports.Referenced = Referenced;
|
||||
const BlockScoped = null;
|
||||
exports.BlockScoped = BlockScoped;
|
||||
const Var = ["VariableDeclaration"];
|
||||
exports.Var = Var;
|
||||
const User = null;
|
||||
exports.User = User;
|
||||
const Generated = null;
|
||||
exports.Generated = Generated;
|
||||
const Pure = null;
|
||||
exports.Pure = Pure;
|
||||
const Flow = ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"];
|
||||
exports.Flow = Flow;
|
||||
const RestProperty = ["RestElement"];
|
||||
exports.RestProperty = RestProperty;
|
||||
const SpreadProperty = ["RestElement"];
|
||||
exports.SpreadProperty = SpreadProperty;
|
||||
const ExistentialTypeParam = ["ExistsTypeAnnotation"];
|
||||
exports.ExistentialTypeParam = ExistentialTypeParam;
|
||||
const NumericLiteralTypeAnnotation = ["NumberLiteralTypeAnnotation"];
|
||||
exports.NumericLiteralTypeAnnotation = NumericLiteralTypeAnnotation;
|
||||
const ForAwaitStatement = ["ForOfStatement"];
|
||||
exports.ForAwaitStatement = ForAwaitStatement;
|
269
node_modules/@babel/traverse/lib/path/modification.js
generated
vendored
Normal file
269
node_modules/@babel/traverse/lib/path/modification.js
generated
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._containerInsert = _containerInsert;
|
||||
exports._containerInsertAfter = _containerInsertAfter;
|
||||
exports._containerInsertBefore = _containerInsertBefore;
|
||||
exports._verifyNodeList = _verifyNodeList;
|
||||
exports.hoist = hoist;
|
||||
exports.insertAfter = insertAfter;
|
||||
exports.insertBefore = insertBefore;
|
||||
exports.pushContainer = pushContainer;
|
||||
exports.unshiftContainer = unshiftContainer;
|
||||
exports.updateSiblingKeys = updateSiblingKeys;
|
||||
|
||||
var _cache = require("../cache");
|
||||
|
||||
var _hoister = require("./lib/hoister");
|
||||
|
||||
var _index = require("./index");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
arrowFunctionExpression,
|
||||
assertExpression,
|
||||
assignmentExpression,
|
||||
blockStatement,
|
||||
callExpression,
|
||||
cloneNode,
|
||||
expressionStatement,
|
||||
isAssignmentExpression,
|
||||
isCallExpression,
|
||||
isExpression,
|
||||
isIdentifier,
|
||||
isSequenceExpression,
|
||||
isSuper,
|
||||
thisExpression
|
||||
} = _t;
|
||||
|
||||
function insertBefore(nodes_) {
|
||||
this._assertUnremoved();
|
||||
|
||||
const nodes = this._verifyNodeList(nodes_);
|
||||
|
||||
const {
|
||||
parentPath
|
||||
} = this;
|
||||
|
||||
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
|
||||
return parentPath.insertBefore(nodes);
|
||||
} else if (this.isNodeType("Expression") && !this.isJSXElement() || 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 node = this.node;
|
||||
const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null);
|
||||
this.replaceWith(blockStatement(shouldInsertCurrentNode ? [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 (const path of paths) {
|
||||
path.setScope();
|
||||
path.debug("Inserted.");
|
||||
|
||||
for (const context of contexts) {
|
||||
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);
|
||||
}
|
||||
|
||||
const last = arr => arr[arr.length - 1];
|
||||
|
||||
function isHiddenInSequenceExpression(path) {
|
||||
return isSequenceExpression(path.parent) && (last(path.parent.expressions) !== path.node || isHiddenInSequenceExpression(path.parentPath));
|
||||
}
|
||||
|
||||
function isAlmostConstantAssignment(node, scope) {
|
||||
if (!isAssignmentExpression(node) || !isIdentifier(node.left)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const blockScope = scope.getBlockParent();
|
||||
return blockScope.hasOwnBinding(node.left.name) && blockScope.getOwnBinding(node.left.name).constantViolations.length <= 1;
|
||||
}
|
||||
|
||||
function insertAfter(nodes_) {
|
||||
this._assertUnremoved();
|
||||
|
||||
if (this.isSequenceExpression()) {
|
||||
return last(this.get("expressions")).insertAfter(nodes_);
|
||||
}
|
||||
|
||||
const nodes = this._verifyNodeList(nodes_);
|
||||
|
||||
const {
|
||||
parentPath
|
||||
} = this;
|
||||
|
||||
if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) {
|
||||
return parentPath.insertAfter(nodes.map(node => {
|
||||
return isExpression(node) ? expressionStatement(node) : node;
|
||||
}));
|
||||
} else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") {
|
||||
if (this.node) {
|
||||
const node = this.node;
|
||||
let {
|
||||
scope
|
||||
} = this;
|
||||
|
||||
if (scope.path.isPattern()) {
|
||||
assertExpression(node);
|
||||
this.replaceWith(callExpression(arrowFunctionExpression([], node), []));
|
||||
this.get("callee.body").insertAfter(nodes);
|
||||
return [this];
|
||||
}
|
||||
|
||||
if (isHiddenInSequenceExpression(this)) {
|
||||
nodes.unshift(node);
|
||||
} else if (isCallExpression(node) && isSuper(node.callee)) {
|
||||
nodes.unshift(node);
|
||||
nodes.push(thisExpression());
|
||||
} else if (isAlmostConstantAssignment(node, scope)) {
|
||||
nodes.unshift(node);
|
||||
nodes.push(cloneNode(node.left));
|
||||
} else if (scope.isPure(node, true)) {
|
||||
nodes.push(node);
|
||||
} else {
|
||||
if (parentPath.isMethod({
|
||||
computed: true,
|
||||
key: node
|
||||
})) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
|
||||
const temp = scope.generateDeclaredUidIdentifier();
|
||||
nodes.unshift(expressionStatement(assignmentExpression("=", cloneNode(temp), node)));
|
||||
nodes.push(expressionStatement(cloneNode(temp)));
|
||||
}
|
||||
}
|
||||
|
||||
return this.replaceExpressionWithStatements(nodes);
|
||||
} else if (Array.isArray(this.container)) {
|
||||
return this._containerInsertAfter(nodes);
|
||||
} else if (this.isStatementOrBlock()) {
|
||||
const node = this.node;
|
||||
const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null);
|
||||
this.replaceWith(blockStatement(shouldInsertCurrentNode ? [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 (const [, path] of paths) {
|
||||
if (path.key >= fromIndex) {
|
||||
path.key += incrementBy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _verifyNodeList(nodes) {
|
||||
if (!nodes) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!Array.isArray(nodes)) {
|
||||
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
|
||||
}).setContext(this.context);
|
||||
|
||||
return path._containerInsertBefore(nodes);
|
||||
}
|
||||
|
||||
function pushContainer(listKey, nodes) {
|
||||
this._assertUnremoved();
|
||||
|
||||
const verifiedNodes = this._verifyNodeList(nodes);
|
||||
|
||||
const container = this.node[listKey];
|
||||
|
||||
const path = _index.default.get({
|
||||
parentPath: this,
|
||||
parent: this.node,
|
||||
container: container,
|
||||
listKey,
|
||||
key: container.length
|
||||
}).setContext(this.context);
|
||||
|
||||
return path.replaceWithMultiple(verifiedNodes);
|
||||
}
|
||||
|
||||
function hoist(scope = this.scope) {
|
||||
const hoister = new _hoister.default(this, scope);
|
||||
return hoister.run();
|
||||
}
|
73
node_modules/@babel/traverse/lib/path/removal.js
generated
vendored
Normal file
73
node_modules/@babel/traverse/lib/path/removal.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._assertUnremoved = _assertUnremoved;
|
||||
exports._callRemovalHooks = _callRemovalHooks;
|
||||
exports._markRemoved = _markRemoved;
|
||||
exports._remove = _remove;
|
||||
exports._removeFromScope = _removeFromScope;
|
||||
exports.remove = remove;
|
||||
|
||||
var _removalHooks = require("./lib/removal-hooks");
|
||||
|
||||
var _cache = require("../cache");
|
||||
|
||||
var _index = require("./index");
|
||||
|
||||
function remove() {
|
||||
var _this$opts;
|
||||
|
||||
this._assertUnremoved();
|
||||
|
||||
this.resync();
|
||||
|
||||
if (!((_this$opts = this.opts) != null && _this$opts.noScope)) {
|
||||
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() {
|
||||
for (const fn of _removalHooks.hooks) {
|
||||
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._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED;
|
||||
if (this.parent) _cache.path.get(this.parent).delete(this.node);
|
||||
this.node = null;
|
||||
}
|
||||
|
||||
function _assertUnremoved() {
|
||||
if (this.removed) {
|
||||
throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
|
||||
}
|
||||
}
|
259
node_modules/@babel/traverse/lib/path/replacement.js
generated
vendored
Normal file
259
node_modules/@babel/traverse/lib/path/replacement.js
generated
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._replaceWith = _replaceWith;
|
||||
exports.replaceExpressionWithStatements = replaceExpressionWithStatements;
|
||||
exports.replaceInline = replaceInline;
|
||||
exports.replaceWith = replaceWith;
|
||||
exports.replaceWithMultiple = replaceWithMultiple;
|
||||
exports.replaceWithSourceString = replaceWithSourceString;
|
||||
|
||||
var _codeFrame = require("@babel/code-frame");
|
||||
|
||||
var _index = require("../index");
|
||||
|
||||
var _index2 = require("./index");
|
||||
|
||||
var _cache = require("../cache");
|
||||
|
||||
var _parser = require("@babel/parser");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _helperHoistVariables = require("@babel/helper-hoist-variables");
|
||||
|
||||
const {
|
||||
FUNCTION_TYPES,
|
||||
arrowFunctionExpression,
|
||||
assignmentExpression,
|
||||
awaitExpression,
|
||||
blockStatement,
|
||||
callExpression,
|
||||
cloneNode,
|
||||
expressionStatement,
|
||||
identifier,
|
||||
inheritLeadingComments,
|
||||
inheritTrailingComments,
|
||||
inheritsComments,
|
||||
isExpression,
|
||||
isProgram,
|
||||
isStatement,
|
||||
removeComments,
|
||||
returnStatement,
|
||||
toSequenceExpression,
|
||||
validate,
|
||||
yieldExpression
|
||||
} = _t;
|
||||
|
||||
function replaceWithMultiple(nodes) {
|
||||
var _pathCache$get;
|
||||
|
||||
this.resync();
|
||||
nodes = this._verifyNodeList(nodes);
|
||||
inheritLeadingComments(nodes[0], this.node);
|
||||
inheritTrailingComments(nodes[nodes.length - 1], this.node);
|
||||
(_pathCache$get = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get.delete(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();
|
||||
let ast;
|
||||
|
||||
try {
|
||||
replacement = `(${replacement})`;
|
||||
ast = (0, _parser.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;
|
||||
}
|
||||
|
||||
const expressionAST = ast.program.body[0].expression;
|
||||
|
||||
_index.default.removeProperties(expressionAST);
|
||||
|
||||
return this.replaceWith(expressionAST);
|
||||
}
|
||||
|
||||
function replaceWith(replacementPath) {
|
||||
this.resync();
|
||||
|
||||
if (this.removed) {
|
||||
throw new Error("You can't replace this node, we've already removed it");
|
||||
}
|
||||
|
||||
let replacement = replacementPath instanceof _index2.default ? replacementPath.node : replacementPath;
|
||||
|
||||
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() && !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") && isExpression(replacement)) {
|
||||
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) {
|
||||
replacement = expressionStatement(replacement);
|
||||
nodePath = "expression";
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isNodeType("Expression") && isStatement(replacement)) {
|
||||
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
|
||||
return this.replaceExpressionWithStatements([replacement]);
|
||||
}
|
||||
}
|
||||
|
||||
const oldNode = this.node;
|
||||
|
||||
if (oldNode) {
|
||||
inheritsComments(replacement, oldNode);
|
||||
removeComments(oldNode);
|
||||
}
|
||||
|
||||
this._replaceWith(replacement);
|
||||
|
||||
this.type = replacement.type;
|
||||
this.setScope();
|
||||
this.requeue();
|
||||
return [nodePath ? this.get(nodePath) : this];
|
||||
}
|
||||
|
||||
function _replaceWith(node) {
|
||||
var _pathCache$get2;
|
||||
|
||||
if (!this.container) {
|
||||
throw new ReferenceError("Container is falsy");
|
||||
}
|
||||
|
||||
if (this.inList) {
|
||||
validate(this.parent, this.key, [node]);
|
||||
} else {
|
||||
validate(this.parent, this.key, node);
|
||||
}
|
||||
|
||||
this.debug(`Replace with ${node == null ? void 0 : node.type}`);
|
||||
(_pathCache$get2 = _cache.path.get(this.parent)) == null ? void 0 : _pathCache$get2.set(node, this).delete(this.node);
|
||||
this.node = this.container[this.key] = node;
|
||||
}
|
||||
|
||||
function replaceExpressionWithStatements(nodes) {
|
||||
this.resync();
|
||||
const nodesAsSequenceExpression = toSequenceExpression(nodes, this.scope);
|
||||
|
||||
if (nodesAsSequenceExpression) {
|
||||
return this.replaceWith(nodesAsSequenceExpression)[0].get("expressions");
|
||||
}
|
||||
|
||||
const functionParent = this.getFunctionParent();
|
||||
const isParentAsync = functionParent == null ? void 0 : functionParent.is("async");
|
||||
const isParentGenerator = functionParent == null ? void 0 : functionParent.is("generator");
|
||||
const container = arrowFunctionExpression([], blockStatement(nodes));
|
||||
this.replaceWith(callExpression(container, []));
|
||||
const callee = this.get("callee");
|
||||
(0, _helperHoistVariables.default)(callee.get("body"), id => {
|
||||
this.scope.push({
|
||||
id
|
||||
});
|
||||
}, "var");
|
||||
const completionRecords = this.get("callee").getCompletionRecords();
|
||||
|
||||
for (const path of completionRecords) {
|
||||
if (!path.isExpressionStatement()) continue;
|
||||
const loop = path.findParent(path => path.isLoop());
|
||||
|
||||
if (loop) {
|
||||
let uid = loop.getData("expressionReplacementReturnUid");
|
||||
|
||||
if (!uid) {
|
||||
uid = callee.scope.generateDeclaredUidIdentifier("ret");
|
||||
callee.get("body").pushContainer("body", returnStatement(cloneNode(uid)));
|
||||
loop.setData("expressionReplacementReturnUid", uid);
|
||||
} else {
|
||||
uid = identifier(uid.name);
|
||||
}
|
||||
|
||||
path.get("expression").replaceWith(assignmentExpression("=", cloneNode(uid), path.node.expression));
|
||||
} else {
|
||||
path.replaceWith(returnStatement(path.node.expression));
|
||||
}
|
||||
}
|
||||
|
||||
callee.arrowFunctionToExpression();
|
||||
const newCallee = callee;
|
||||
|
||||
const needToAwaitFunction = isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", FUNCTION_TYPES);
|
||||
|
||||
const needToYieldFunction = isParentGenerator && _index.default.hasType(this.get("callee.body").node, "YieldExpression", FUNCTION_TYPES);
|
||||
|
||||
if (needToAwaitFunction) {
|
||||
newCallee.set("async", true);
|
||||
|
||||
if (!needToYieldFunction) {
|
||||
this.replaceWith(awaitExpression(this.node));
|
||||
}
|
||||
}
|
||||
|
||||
if (needToYieldFunction) {
|
||||
newCallee.set("generator", true);
|
||||
this.replaceWith(yieldExpression(this.node, true));
|
||||
}
|
||||
|
||||
return newCallee.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);
|
||||
}
|
||||
}
|
75
node_modules/@babel/traverse/lib/scope/binding.js
generated
vendored
Normal file
75
node_modules/@babel/traverse/lib/scope/binding.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
class Binding {
|
||||
constructor({
|
||||
identifier,
|
||||
scope,
|
||||
path,
|
||||
kind
|
||||
}) {
|
||||
this.identifier = void 0;
|
||||
this.scope = void 0;
|
||||
this.path = void 0;
|
||||
this.kind = void 0;
|
||||
this.constantViolations = [];
|
||||
this.constant = true;
|
||||
this.referencePaths = [];
|
||||
this.referenced = false;
|
||||
this.references = 0;
|
||||
this.identifier = identifier;
|
||||
this.scope = scope;
|
||||
this.path = path;
|
||||
this.kind = kind;
|
||||
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;
|
1067
node_modules/@babel/traverse/lib/scope/index.js
generated
vendored
Normal file
1067
node_modules/@babel/traverse/lib/scope/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
129
node_modules/@babel/traverse/lib/scope/lib/renamer.js
generated
vendored
Normal file
129
node_modules/@babel/traverse/lib/scope/lib/renamer.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _binding = require("../binding");
|
||||
|
||||
var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration");
|
||||
|
||||
var t = require("@babel/types");
|
||||
|
||||
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
|
||||
|
||||
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();
|
||||
|
||||
if (path.isMethod()) {
|
||||
(0, _helperEnvironmentVisitor.requeueComputedKeyAndDecorators)(path);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
|
||||
if (path.isVariableDeclaration()) return;
|
||||
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()) {
|
||||
const {
|
||||
declaration
|
||||
} = maybeExportDeclar.node;
|
||||
|
||||
if (t.isDeclaration(declaration) && !declaration.id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (maybeExportDeclar.isExportAllDeclaration()) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _helperSplitExportDeclaration.default)(maybeExportDeclar);
|
||||
}
|
||||
|
||||
maybeConvertFromClassFunctionDeclaration(path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
maybeConvertFromClassFunctionExpression(path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
rename(block) {
|
||||
const {
|
||||
binding,
|
||||
oldName,
|
||||
newName
|
||||
} = this;
|
||||
const {
|
||||
scope,
|
||||
path
|
||||
} = binding;
|
||||
const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression());
|
||||
|
||||
if (parentDeclar) {
|
||||
const bindingIds = parentDeclar.getOuterBindingIdentifiers();
|
||||
|
||||
if (bindingIds[oldName] === binding.identifier) {
|
||||
this.maybeConvertFromExportDeclaration(parentDeclar);
|
||||
}
|
||||
}
|
||||
|
||||
const blockToTraverse = block || scope.block;
|
||||
|
||||
if ((blockToTraverse == null ? void 0 : blockToTraverse.type) === "SwitchStatement") {
|
||||
blockToTraverse.cases.forEach(c => {
|
||||
scope.traverse(c, renameVisitor, this);
|
||||
});
|
||||
} else {
|
||||
scope.traverse(blockToTraverse, renameVisitor, this);
|
||||
}
|
||||
|
||||
if (!block) {
|
||||
scope.removeOwnBinding(oldName);
|
||||
scope.bindings[newName] = binding;
|
||||
this.binding.identifier.name = newName;
|
||||
}
|
||||
|
||||
if (parentDeclar) {
|
||||
this.maybeConvertFromClassFunctionDeclaration(path);
|
||||
this.maybeConvertFromClassFunctionExpression(path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Renamer;
|
30
node_modules/@babel/traverse/lib/traverse-node.js
generated
vendored
Normal file
30
node_modules/@babel/traverse/lib/traverse-node.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.traverseNode = traverseNode;
|
||||
|
||||
var _context = require("./context");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
|
||||
function traverseNode(node, opts, scope, state, path, skipKeys) {
|
||||
const keys = VISITOR_KEYS[node.type];
|
||||
if (!keys) return false;
|
||||
const context = new _context.default(scope, opts, state, path);
|
||||
|
||||
for (const key of keys) {
|
||||
if (skipKeys && skipKeys[key]) continue;
|
||||
|
||||
if (context.visit(node, key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
3
node_modules/@babel/traverse/lib/types.js
generated
vendored
Normal file
3
node_modules/@babel/traverse/lib/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
var _index = require("./index");
|
246
node_modules/@babel/traverse/lib/visitors.js
generated
vendored
Normal file
246
node_modules/@babel/traverse/lib/visitors.js
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.explode = explode;
|
||||
exports.merge = merge;
|
||||
exports.verify = verify;
|
||||
|
||||
var virtualTypes = require("./path/lib/virtual-types");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
|
||||
const {
|
||||
DEPRECATED_KEYS,
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
TYPES
|
||||
} = _t;
|
||||
|
||||
function isVirtualType(type) {
|
||||
return type in virtualTypes;
|
||||
}
|
||||
|
||||
function explode(visitor) {
|
||||
if (visitor._exploded) return visitor;
|
||||
visitor._exploded = true;
|
||||
|
||||
for (const nodeType of Object.keys(visitor)) {
|
||||
if (shouldIgnoreKey(nodeType)) continue;
|
||||
const parts = nodeType.split("|");
|
||||
if (parts.length === 1) continue;
|
||||
const fns = visitor[nodeType];
|
||||
delete visitor[nodeType];
|
||||
|
||||
for (const part of parts) {
|
||||
visitor[part] = fns;
|
||||
}
|
||||
}
|
||||
|
||||
verify(visitor);
|
||||
delete visitor.__esModule;
|
||||
ensureEntranceObjects(visitor);
|
||||
ensureCallbackArrays(visitor);
|
||||
|
||||
for (const nodeType of Object.keys(visitor)) {
|
||||
if (shouldIgnoreKey(nodeType)) continue;
|
||||
if (!isVirtualType(nodeType)) continue;
|
||||
const fns = visitor[nodeType];
|
||||
|
||||
for (const type of Object.keys(fns)) {
|
||||
fns[type] = wrapCheck(nodeType, fns[type]);
|
||||
}
|
||||
|
||||
delete visitor[nodeType];
|
||||
const types = virtualTypes[nodeType];
|
||||
|
||||
if (types !== null) {
|
||||
for (const type of types) {
|
||||
if (visitor[type]) {
|
||||
mergePair(visitor[type], fns);
|
||||
} else {
|
||||
visitor[type] = fns;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mergePair(visitor, fns);
|
||||
}
|
||||
}
|
||||
|
||||
for (const nodeType of Object.keys(visitor)) {
|
||||
if (shouldIgnoreKey(nodeType)) continue;
|
||||
const fns = visitor[nodeType];
|
||||
let aliases = FLIPPED_ALIAS_KEYS[nodeType];
|
||||
const deprecatedKey = DEPRECATED_KEYS[nodeType];
|
||||
|
||||
if (deprecatedKey) {
|
||||
console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecatedKey}`);
|
||||
aliases = [deprecatedKey];
|
||||
}
|
||||
|
||||
if (!aliases) continue;
|
||||
delete visitor[nodeType];
|
||||
|
||||
for (const alias of aliases) {
|
||||
const existing = visitor[alias];
|
||||
|
||||
if (existing) {
|
||||
mergePair(existing, fns);
|
||||
} else {
|
||||
visitor[alias] = Object.assign({}, fns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const nodeType of Object.keys(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 of Object.keys(visitor)) {
|
||||
if (nodeType === "enter" || nodeType === "exit") {
|
||||
validateVisitorMethods(nodeType, visitor[nodeType]);
|
||||
}
|
||||
|
||||
if (shouldIgnoreKey(nodeType)) continue;
|
||||
|
||||
if (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 of Object.keys(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 (const fn of fns) {
|
||||
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 of Object.keys(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 of Object.keys(oldVisitor)) {
|
||||
let fns = oldVisitor[key];
|
||||
if (!Array.isArray(fns)) continue;
|
||||
fns = fns.map(function (fn) {
|
||||
let newFn = fn;
|
||||
|
||||
if (state) {
|
||||
newFn = function (path) {
|
||||
return fn.call(state, path, state);
|
||||
};
|
||||
}
|
||||
|
||||
if (wrapper) {
|
||||
newFn = wrapper(state.key, key, newFn);
|
||||
}
|
||||
|
||||
if (newFn !== fn) {
|
||||
newFn.toString = () => fn.toString();
|
||||
}
|
||||
|
||||
return newFn;
|
||||
});
|
||||
newVisitor[key] = fns;
|
||||
}
|
||||
|
||||
return newVisitor;
|
||||
}
|
||||
|
||||
function ensureEntranceObjects(obj) {
|
||||
for (const key of Object.keys(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(nodeType, fn) {
|
||||
const newFn = function (path) {
|
||||
if (path[`is${nodeType}`]()) {
|
||||
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 === "denylist" || key === "noScope" || key === "skipKeys" || key === "blacklist") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function mergePair(dest, src) {
|
||||
for (const key of Object.keys(src)) {
|
||||
dest[key] = [].concat(dest[key] || [], src[key]);
|
||||
}
|
||||
}
|
20
node_modules/@babel/traverse/node_modules/debug/LICENSE
generated
vendored
Normal file
20
node_modules/@babel/traverse/node_modules/debug/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2018-2021 Josh Junon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the 'Software'), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
481
node_modules/@babel/traverse/node_modules/debug/README.md
generated
vendored
Normal file
481
node_modules/@babel/traverse/node_modules/debug/README.md
generated
vendored
Normal file
@@ -0,0 +1,481 @@
|
||||
# debug
|
||||
[](https://travis-ci.org/debug-js/debug) [](https://coveralls.io/github/debug-js/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
A tiny JavaScript debugging utility modelled after Node.js core's debugging
|
||||
technique. Works in Node.js and web browsers.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
|
||||
|
||||
Example [_app.js_](./examples/node/app.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %o', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example [_worker.js_](./examples/node/worker.js):
|
||||
|
||||
```js
|
||||
var a = require('debug')('worker:a')
|
||||
, b = require('debug')('worker:b');
|
||||
|
||||
function work() {
|
||||
a('doing lots of uninteresting work');
|
||||
setTimeout(work, Math.random() * 1000);
|
||||
}
|
||||
|
||||
work();
|
||||
|
||||
function workb() {
|
||||
b('doing some work');
|
||||
setTimeout(workb, Math.random() * 2000);
|
||||
}
|
||||
|
||||
workb();
|
||||
```
|
||||
|
||||
The `DEBUG` environment variable is then used to enable these based on space or
|
||||
comma-delimited names.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
||||
|
||||
#### Windows command prompt notes
|
||||
|
||||
##### CMD
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
set DEBUG=* & node app.js
|
||||
```
|
||||
|
||||
##### PowerShell (VS Code default)
|
||||
|
||||
PowerShell uses different syntax to set environment variables.
|
||||
|
||||
```cmd
|
||||
$env:DEBUG = "*,-not_this"
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```cmd
|
||||
$env:DEBUG='app';node app.js
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as usual.
|
||||
|
||||
npm script example:
|
||||
```js
|
||||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js",
|
||||
```
|
||||
|
||||
## Namespace Colors
|
||||
|
||||
Every debug instance has a color generated for it based on its namespace name.
|
||||
This helps when visually parsing the debug output to identify which debug instance
|
||||
a debug line belongs to.
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
|
||||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
|
||||
otherwise debug will only use a small handful of basic colors.
|
||||
|
||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
||||
|
||||
#### Web Browser
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
||||
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
||||
|
||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
||||
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has
|
||||
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
|
||||
instead of listing all three with
|
||||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
|
||||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character.
|
||||
For example, `DEBUG=*,-connect:*` would include all debuggers except those
|
||||
starting with "connect:".
|
||||
|
||||
## Environment Variables
|
||||
|
||||
When running through Node.js, you can set a few environment variables that will
|
||||
change the behavior of the debug logging:
|
||||
|
||||
| Name | Purpose |
|
||||
|-----------|-------------------------------------------------|
|
||||
| `DEBUG` | Enables/disables specific debugging namespaces. |
|
||||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
|
||||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
|
||||
| `DEBUG_DEPTH` | Object inspection depth. |
|
||||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
|
||||
|
||||
|
||||
__Note:__ The environment variables beginning with `DEBUG_` end up being
|
||||
converted into an Options object that gets used with `%o`/`%O` formatters.
|
||||
See the Node.js documentation for
|
||||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
|
||||
for the complete list.
|
||||
|
||||
## Formatters
|
||||
|
||||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
|
||||
Below are the officially supported formatters:
|
||||
|
||||
| Formatter | Representation |
|
||||
|-----------|----------------|
|
||||
| `%O` | Pretty-print an Object on multiple lines. |
|
||||
| `%o` | Pretty-print an Object all on a single line. |
|
||||
| `%s` | String. |
|
||||
| `%d` | Number (both integer and float). |
|
||||
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
|
||||
| `%%` | Single percent sign ('%'). This does not consume an argument. |
|
||||
|
||||
|
||||
### Custom formatters
|
||||
|
||||
You can add custom formatters by extending the `debug.formatters` object.
|
||||
For example, if you wanted to add support for rendering a Buffer as hex with
|
||||
`%h`, you could do something like:
|
||||
|
||||
```js
|
||||
const createDebug = require('debug')
|
||||
createDebug.formatters.h = (v) => {
|
||||
return v.toString('hex')
|
||||
}
|
||||
|
||||
// …elsewhere
|
||||
const debug = createDebug('foo')
|
||||
debug('this is hex: %h', new Buffer('hello world'))
|
||||
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
|
||||
```
|
||||
|
||||
|
||||
## Browser Support
|
||||
|
||||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
|
||||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
|
||||
if you don't want to build it yourself.
|
||||
|
||||
Debug's enable state is currently persisted by `localStorage`.
|
||||
Consider the situation shown below where you have `worker:a` and `worker:b`,
|
||||
and wish to debug both. You can enable this using `localStorage.debug`:
|
||||
|
||||
```js
|
||||
localStorage.debug = 'worker:*'
|
||||
```
|
||||
|
||||
And then refresh the page.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_.
|
||||
|
||||
<img width="647" src="https://user-images.githubusercontent.com/7143133/152083257-29034707-c42c-4959-8add-3cee850e6fcf.png">
|
||||
|
||||
## Output streams
|
||||
|
||||
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
|
||||
|
||||
Example [_stdout.js_](./examples/node/stdout.js):
|
||||
|
||||
```js
|
||||
var debug = require('debug');
|
||||
var error = debug('app:error');
|
||||
|
||||
// by default stderr is used
|
||||
error('goes to stderr!');
|
||||
|
||||
var log = debug('app:log');
|
||||
// set this namespace to log via console.log
|
||||
log.log = console.log.bind(console); // don't forget to bind to console!
|
||||
log('goes to stdout');
|
||||
error('still goes to stderr!');
|
||||
|
||||
// set all output to go via console.info
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.info.bind(console);
|
||||
error('now goes to stdout via console.info');
|
||||
log('still goes to stdout, but via console.info now');
|
||||
```
|
||||
|
||||
## Extend
|
||||
You can simply extend debugger
|
||||
```js
|
||||
const log = require('debug')('auth');
|
||||
|
||||
//creates new debug instance with extended namespace
|
||||
const logSign = log.extend('sign');
|
||||
const logLogin = log.extend('login');
|
||||
|
||||
log('hello'); // auth hello
|
||||
logSign('hello'); //auth:sign hello
|
||||
logLogin('hello'); //auth:login hello
|
||||
```
|
||||
|
||||
## Set dynamically
|
||||
|
||||
You can also enable debug dynamically by calling the `enable()` method :
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
|
||||
console.log(1, debug.enabled('test'));
|
||||
|
||||
debug.enable('test');
|
||||
console.log(2, debug.enabled('test'));
|
||||
|
||||
debug.disable();
|
||||
console.log(3, debug.enabled('test'));
|
||||
|
||||
```
|
||||
|
||||
print :
|
||||
```
|
||||
1 false
|
||||
2 true
|
||||
3 false
|
||||
```
|
||||
|
||||
Usage :
|
||||
`enable(namespaces)`
|
||||
`namespaces` can include modes separated by a colon and wildcards.
|
||||
|
||||
Note that calling `enable()` completely overrides previously set DEBUG variable :
|
||||
|
||||
```
|
||||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
|
||||
=> false
|
||||
```
|
||||
|
||||
`disable()`
|
||||
|
||||
Will disable all namespaces. The functions returns the namespaces currently
|
||||
enabled (and skipped). This can be useful if you want to disable debugging
|
||||
temporarily without knowing what was enabled to begin with.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
let debug = require('debug');
|
||||
debug.enable('foo:*,-foo:bar');
|
||||
let namespaces = debug.disable();
|
||||
debug.enable(namespaces);
|
||||
```
|
||||
|
||||
Note: There is no guarantee that the string will be identical to the initial
|
||||
enable string, but semantically they will be identical.
|
||||
|
||||
## Checking whether a debug target is enabled
|
||||
|
||||
After you've created a debug instance, you can determine whether or not it is
|
||||
enabled by checking the `enabled` property:
|
||||
|
||||
```javascript
|
||||
const debug = require('debug')('http');
|
||||
|
||||
if (debug.enabled) {
|
||||
// do stuff...
|
||||
}
|
||||
```
|
||||
|
||||
You can also manually toggle this property to force the debug instance to be
|
||||
enabled or disabled.
|
||||
|
||||
## Usage in child processes
|
||||
|
||||
Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process.
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
worker = fork(WORKER_WRAP_PATH, [workerPath], {
|
||||
stdio: [
|
||||
/* stdin: */ 0,
|
||||
/* stdout: */ 'pipe',
|
||||
/* stderr: */ 'pipe',
|
||||
'ipc',
|
||||
],
|
||||
env: Object.assign({}, process.env, {
|
||||
DEBUG_COLORS: 1 // without this settings, colors won't be shown
|
||||
}),
|
||||
});
|
||||
|
||||
worker.stderr.pipe(process.stderr, { end: false });
|
||||
```
|
||||
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
- Andrew Rhyne
|
||||
- Josh Junon
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
|
||||
|
||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2018-2021 Josh Junon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
59
node_modules/@babel/traverse/node_modules/debug/package.json
generated
vendored
Normal file
59
node_modules/@babel/traverse/node_modules/debug/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "debug",
|
||||
"version": "4.3.4",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/debug-js/debug.git"
|
||||
},
|
||||
"description": "Lightweight debugging utility for Node.js and the browser",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"author": "Josh Junon <josh.junon@protonmail.com>",
|
||||
"contributors": [
|
||||
"TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
||||
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "xo",
|
||||
"test": "npm run test:node && npm run test:browser && npm run lint",
|
||||
"test:node": "istanbul cover _mocha -- test.js",
|
||||
"test:browser": "karma start --single-run",
|
||||
"test:coverage": "cat ./coverage/lcov.info | coveralls"
|
||||
},
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"brfs": "^2.0.1",
|
||||
"browserify": "^16.2.3",
|
||||
"coveralls": "^3.0.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^3.1.4",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-lcov-reporter": "^1.2.0",
|
||||
"xo": "^0.23.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"main": "./src/index.js",
|
||||
"browser": "./src/browser.js",
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
}
|
||||
}
|
269
node_modules/@babel/traverse/node_modules/debug/src/browser.js
generated
vendored
Normal file
269
node_modules/@babel/traverse/node_modules/debug/src/browser.js
generated
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.storage = localstorage();
|
||||
exports.destroy = (() => {
|
||||
let warned = false;
|
||||
|
||||
return () => {
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'#0000CC',
|
||||
'#0000FF',
|
||||
'#0033CC',
|
||||
'#0033FF',
|
||||
'#0066CC',
|
||||
'#0066FF',
|
||||
'#0099CC',
|
||||
'#0099FF',
|
||||
'#00CC00',
|
||||
'#00CC33',
|
||||
'#00CC66',
|
||||
'#00CC99',
|
||||
'#00CCCC',
|
||||
'#00CCFF',
|
||||
'#3300CC',
|
||||
'#3300FF',
|
||||
'#3333CC',
|
||||
'#3333FF',
|
||||
'#3366CC',
|
||||
'#3366FF',
|
||||
'#3399CC',
|
||||
'#3399FF',
|
||||
'#33CC00',
|
||||
'#33CC33',
|
||||
'#33CC66',
|
||||
'#33CC99',
|
||||
'#33CCCC',
|
||||
'#33CCFF',
|
||||
'#6600CC',
|
||||
'#6600FF',
|
||||
'#6633CC',
|
||||
'#6633FF',
|
||||
'#66CC00',
|
||||
'#66CC33',
|
||||
'#9900CC',
|
||||
'#9900FF',
|
||||
'#9933CC',
|
||||
'#9933FF',
|
||||
'#99CC00',
|
||||
'#99CC33',
|
||||
'#CC0000',
|
||||
'#CC0033',
|
||||
'#CC0066',
|
||||
'#CC0099',
|
||||
'#CC00CC',
|
||||
'#CC00FF',
|
||||
'#CC3300',
|
||||
'#CC3333',
|
||||
'#CC3366',
|
||||
'#CC3399',
|
||||
'#CC33CC',
|
||||
'#CC33FF',
|
||||
'#CC6600',
|
||||
'#CC6633',
|
||||
'#CC9900',
|
||||
'#CC9933',
|
||||
'#CCCC00',
|
||||
'#CCCC33',
|
||||
'#FF0000',
|
||||
'#FF0033',
|
||||
'#FF0066',
|
||||
'#FF0099',
|
||||
'#FF00CC',
|
||||
'#FF00FF',
|
||||
'#FF3300',
|
||||
'#FF3333',
|
||||
'#FF3366',
|
||||
'#FF3399',
|
||||
'#FF33CC',
|
||||
'#FF33FF',
|
||||
'#FF6600',
|
||||
'#FF6633',
|
||||
'#FF9900',
|
||||
'#FF9933',
|
||||
'#FFCC00',
|
||||
'#FFCC33'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
function useColors() {
|
||||
// NB: In an Electron preload script, document will be defined but not fully
|
||||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||||
// explicitly
|
||||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Internet Explorer and Edge do not support colors.
|
||||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
// Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||
// Double check webkit in userAgent just in case we are in a worker
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
args[0] = (this.useColors ? '%c' : '') +
|
||||
this.namespace +
|
||||
(this.useColors ? ' %c' : ' ') +
|
||||
args[0] +
|
||||
(this.useColors ? '%c ' : ' ') +
|
||||
'+' + module.exports.humanize(this.diff);
|
||||
|
||||
if (!this.useColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
const c = 'color: ' + this.color;
|
||||
args.splice(1, 0, c, 'color: inherit');
|
||||
|
||||
// The final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
let index = 0;
|
||||
let lastC = 0;
|
||||
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||||
if (match === '%%') {
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
if (match === '%c') {
|
||||
// We only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.debug()` when available.
|
||||
* No-op when `console.debug` is not a "function".
|
||||
* If `console.debug` is not available, falls back
|
||||
* to `console.log`.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
exports.log = console.debug || console.log || (() => {});
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (namespaces) {
|
||||
exports.storage.setItem('debug', namespaces);
|
||||
} else {
|
||||
exports.storage.removeItem('debug');
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
|
||||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||||
r = process.env.DEBUG;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localstorage attempts to return the localstorage.
|
||||
*
|
||||
* This is necessary because safari throws
|
||||
* when a user disables cookies/localstorage
|
||||
* and you attempt to access it.
|
||||
*
|
||||
* @return {LocalStorage}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function localstorage() {
|
||||
try {
|
||||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||||
// The Browser also has localStorage in the global context.
|
||||
return localStorage;
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
formatters.j = function (v) {
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
} catch (error) {
|
||||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||||
}
|
||||
};
|
274
node_modules/@babel/traverse/node_modules/debug/src/common.js
generated
vendored
Normal file
274
node_modules/@babel/traverse/node_modules/debug/src/common.js
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*/
|
||||
|
||||
function setup(env) {
|
||||
createDebug.debug = createDebug;
|
||||
createDebug.default = createDebug;
|
||||
createDebug.coerce = coerce;
|
||||
createDebug.disable = disable;
|
||||
createDebug.enable = enable;
|
||||
createDebug.enabled = enabled;
|
||||
createDebug.humanize = require('ms');
|
||||
createDebug.destroy = destroy;
|
||||
|
||||
Object.keys(env).forEach(key => {
|
||||
createDebug[key] = env[key];
|
||||
});
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||||
*/
|
||||
createDebug.formatters = {};
|
||||
|
||||
/**
|
||||
* Selects a color for a debug namespace
|
||||
* @param {String} namespace The namespace string for the debug instance to be colored
|
||||
* @return {Number|String} An ANSI color code for the given namespace
|
||||
* @api private
|
||||
*/
|
||||
function selectColor(namespace) {
|
||||
let hash = 0;
|
||||
|
||||
for (let i = 0; i < namespace.length; i++) {
|
||||
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||||
}
|
||||
createDebug.selectColor = selectColor;
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
function createDebug(namespace) {
|
||||
let prevTime;
|
||||
let enableOverride = null;
|
||||
let namespacesCache;
|
||||
let enabledCache;
|
||||
|
||||
function debug(...args) {
|
||||
// Disabled?
|
||||
if (!debug.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const self = debug;
|
||||
|
||||
// Set `diff` timestamp
|
||||
const curr = Number(new Date());
|
||||
const ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
args[0] = createDebug.coerce(args[0]);
|
||||
|
||||
if (typeof args[0] !== 'string') {
|
||||
// Anything else let's inspect with %O
|
||||
args.unshift('%O');
|
||||
}
|
||||
|
||||
// Apply any `formatters` transformations
|
||||
let index = 0;
|
||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||||
// If we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') {
|
||||
return '%';
|
||||
}
|
||||
index++;
|
||||
const formatter = createDebug.formatters[format];
|
||||
if (typeof formatter === 'function') {
|
||||
const val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// Now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// Apply env-specific formatting (colors, etc.)
|
||||
createDebug.formatArgs.call(self, args);
|
||||
|
||||
const logFn = self.log || createDebug.log;
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
|
||||
debug.namespace = namespace;
|
||||
debug.useColors = createDebug.useColors();
|
||||
debug.color = createDebug.selectColor(namespace);
|
||||
debug.extend = extend;
|
||||
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||||
|
||||
Object.defineProperty(debug, 'enabled', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: () => {
|
||||
if (enableOverride !== null) {
|
||||
return enableOverride;
|
||||
}
|
||||
if (namespacesCache !== createDebug.namespaces) {
|
||||
namespacesCache = createDebug.namespaces;
|
||||
enabledCache = createDebug.enabled(namespace);
|
||||
}
|
||||
|
||||
return enabledCache;
|
||||
},
|
||||
set: v => {
|
||||
enableOverride = v;
|
||||
}
|
||||
});
|
||||
|
||||
// Env-specific initialization logic for debug instances
|
||||
if (typeof createDebug.init === 'function') {
|
||||
createDebug.init(debug);
|
||||
}
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
function extend(namespace, delimiter) {
|
||||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||||
newDebug.log = this.log;
|
||||
return newDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function enable(namespaces) {
|
||||
createDebug.save(namespaces);
|
||||
createDebug.namespaces = namespaces;
|
||||
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @return {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) {
|
||||
return val.stack || val.message;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX DO NOT USE. This is a temporary stub function.
|
||||
* XXX It WILL be removed in the next major release.
|
||||
*/
|
||||
function destroy() {
|
||||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||||
}
|
||||
|
||||
createDebug.enable(createDebug.load());
|
||||
|
||||
return createDebug;
|
||||
}
|
||||
|
||||
module.exports = setup;
|
10
node_modules/@babel/traverse/node_modules/debug/src/index.js
generated
vendored
Normal file
10
node_modules/@babel/traverse/node_modules/debug/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||||
* treat as a browser.
|
||||
*/
|
||||
|
||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||
module.exports = require('./browser.js');
|
||||
} else {
|
||||
module.exports = require('./node.js');
|
||||
}
|
263
node_modules/@babel/traverse/node_modules/debug/src/node.js
generated
vendored
Normal file
263
node_modules/@babel/traverse/node_modules/debug/src/node.js
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const tty = require('tty');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*/
|
||||
|
||||
exports.init = init;
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
exports.destroy = util.deprecate(
|
||||
() => {},
|
||||
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
||||
);
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
try {
|
||||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const supportsColor = require('supports-color');
|
||||
|
||||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||||
exports.colors = [
|
||||
20,
|
||||
21,
|
||||
26,
|
||||
27,
|
||||
32,
|
||||
33,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
56,
|
||||
57,
|
||||
62,
|
||||
63,
|
||||
68,
|
||||
69,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
80,
|
||||
81,
|
||||
92,
|
||||
93,
|
||||
98,
|
||||
99,
|
||||
112,
|
||||
113,
|
||||
128,
|
||||
129,
|
||||
134,
|
||||
135,
|
||||
148,
|
||||
149,
|
||||
160,
|
||||
161,
|
||||
162,
|
||||
163,
|
||||
164,
|
||||
165,
|
||||
166,
|
||||
167,
|
||||
168,
|
||||
169,
|
||||
170,
|
||||
171,
|
||||
172,
|
||||
173,
|
||||
178,
|
||||
179,
|
||||
184,
|
||||
185,
|
||||
196,
|
||||
197,
|
||||
198,
|
||||
199,
|
||||
200,
|
||||
201,
|
||||
202,
|
||||
203,
|
||||
204,
|
||||
205,
|
||||
206,
|
||||
207,
|
||||
208,
|
||||
209,
|
||||
214,
|
||||
215,
|
||||
220,
|
||||
221
|
||||
];
|
||||
}
|
||||
} catch (error) {
|
||||
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the default `inspectOpts` object from the environment variables.
|
||||
*
|
||||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||||
*/
|
||||
|
||||
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||||
return /^debug_/i.test(key);
|
||||
}).reduce((obj, key) => {
|
||||
// Camel-case
|
||||
const prop = key
|
||||
.substring(6)
|
||||
.toLowerCase()
|
||||
.replace(/_([a-z])/g, (_, k) => {
|
||||
return k.toUpperCase();
|
||||
});
|
||||
|
||||
// Coerce string value into JS value
|
||||
let val = process.env[key];
|
||||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||||
val = true;
|
||||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||||
val = false;
|
||||
} else if (val === 'null') {
|
||||
val = null;
|
||||
} else {
|
||||
val = Number(val);
|
||||
}
|
||||
|
||||
obj[prop] = val;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
return 'colors' in exports.inspectOpts ?
|
||||
Boolean(exports.inspectOpts.colors) :
|
||||
tty.isatty(process.stderr.fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs(args) {
|
||||
const {namespace: name, useColors} = this;
|
||||
|
||||
if (useColors) {
|
||||
const c = this.color;
|
||||
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||||
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||||
|
||||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||||
} else {
|
||||
args[0] = getDate() + name + ' ' + args[0];
|
||||
}
|
||||
}
|
||||
|
||||
function getDate() {
|
||||
if (exports.inspectOpts.hideDate) {
|
||||
return '';
|
||||
}
|
||||
return new Date().toISOString() + ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
function log(...args) {
|
||||
return process.stderr.write(util.format(...args) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
function save(namespaces) {
|
||||
if (namespaces) {
|
||||
process.env.DEBUG = namespaces;
|
||||
} else {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init logic for `debug` instances.
|
||||
*
|
||||
* Create a new `inspectOpts` object in case `useColors` is set
|
||||
* differently for a particular `debug` instance.
|
||||
*/
|
||||
|
||||
function init(debug) {
|
||||
debug.inspectOpts = {};
|
||||
|
||||
const keys = Object.keys(exports.inspectOpts);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = require('./common')(exports);
|
||||
|
||||
const {formatters} = module.exports;
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, all on a single line.
|
||||
*/
|
||||
|
||||
formatters.o = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts)
|
||||
.split('\n')
|
||||
.map(str => str.trim())
|
||||
.join(' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||||
*/
|
||||
|
||||
formatters.O = function (v) {
|
||||
this.inspectOpts.colors = this.useColors;
|
||||
return util.inspect(v, this.inspectOpts);
|
||||
};
|
1563
node_modules/@babel/traverse/node_modules/globals/globals.json
generated
vendored
Normal file
1563
node_modules/@babel/traverse/node_modules/globals/globals.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/@babel/traverse/node_modules/globals/index.js
generated
vendored
Normal file
2
node_modules/@babel/traverse/node_modules/globals/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = require('./globals.json');
|
9
node_modules/@babel/traverse/node_modules/globals/license
generated
vendored
Normal file
9
node_modules/@babel/traverse/node_modules/globals/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
41
node_modules/@babel/traverse/node_modules/globals/package.json
generated
vendored
Normal file
41
node_modules/@babel/traverse/node_modules/globals/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "globals",
|
||||
"version": "11.12.0",
|
||||
"description": "Global identifiers from different JavaScript environments",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/globals",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"globals.json"
|
||||
],
|
||||
"keywords": [
|
||||
"globals",
|
||||
"global",
|
||||
"identifiers",
|
||||
"variables",
|
||||
"vars",
|
||||
"jshint",
|
||||
"eslint",
|
||||
"environments"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "0.21.0",
|
||||
"xo": "0.18.0"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"get-browser-globals.js"
|
||||
]
|
||||
}
|
||||
}
|
41
node_modules/@babel/traverse/node_modules/globals/readme.md
generated
vendored
Normal file
41
node_modules/@babel/traverse/node_modules/globals/readme.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# globals [](https://travis-ci.org/sindresorhus/globals)
|
||||
|
||||
> Global identifiers from different JavaScript environments
|
||||
|
||||
Extracted from [JSHint](https://github.com/jshint/jshint/blob/3a8efa979dbb157bfb5c10b5826603a55a33b9ad/src/vars.js) and [ESLint](https://github.com/eslint/eslint/blob/b648406218f8a2d7302b98f5565e23199f44eb31/conf/environments.json) and merged.
|
||||
|
||||
It's just a [JSON file](globals.json), so use it in whatever environment you like.
|
||||
|
||||
**This module [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).**
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install globals
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const globals = require('globals');
|
||||
|
||||
console.log(globals.browser);
|
||||
/*
|
||||
{
|
||||
addEventListener: false,
|
||||
applicationCache: false,
|
||||
ArrayBuffer: false,
|
||||
atob: false,
|
||||
...
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
162
node_modules/@babel/traverse/node_modules/ms/index.js
generated
vendored
Normal file
162
node_modules/@babel/traverse/node_modules/ms/index.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var w = d * 7;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isFinite(val)) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'weeks':
|
||||
case 'week':
|
||||
case 'w':
|
||||
return n * w;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
var msAbs = Math.abs(ms);
|
||||
if (msAbs >= d) {
|
||||
return plural(ms, msAbs, d, 'day');
|
||||
}
|
||||
if (msAbs >= h) {
|
||||
return plural(ms, msAbs, h, 'hour');
|
||||
}
|
||||
if (msAbs >= m) {
|
||||
return plural(ms, msAbs, m, 'minute');
|
||||
}
|
||||
if (msAbs >= s) {
|
||||
return plural(ms, msAbs, s, 'second');
|
||||
}
|
||||
return ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, msAbs, n, name) {
|
||||
var isPlural = msAbs >= n * 1.5;
|
||||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||||
}
|
21
node_modules/@babel/traverse/node_modules/ms/license.md
generated
vendored
Normal file
21
node_modules/@babel/traverse/node_modules/ms/license.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
37
node_modules/@babel/traverse/node_modules/ms/package.json
generated
vendored
Normal file
37
node_modules/@babel/traverse/node_modules/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "ms",
|
||||
"version": "2.1.2",
|
||||
"description": "Tiny millisecond conversion utility",
|
||||
"repository": "zeit/ms",
|
||||
"main": "./index",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "4.12.1",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.14.3",
|
||||
"lint-staged": "5.0.0",
|
||||
"mocha": "4.0.1"
|
||||
}
|
||||
}
|
60
node_modules/@babel/traverse/node_modules/ms/readme.md
generated
vendored
Normal file
60
node_modules/@babel/traverse/node_modules/ms/readme.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://spectrum.chat/zeit)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
ms('-3 days') // -259200000
|
||||
ms('-1h') // -3600000
|
||||
ms('-200') // -200
|
||||
```
|
||||
|
||||
### Convert from Milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(-3 * 60000) // "-3m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time Format Written-Out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(-3 * 60000, { long: true }) // "-3 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [Node.js](https://nodejs.org) and in the browser
|
||||
- If a number is supplied to `ms`, a string with a unit is returned
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`)
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned
|
||||
|
||||
## Related Packages
|
||||
|
||||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time.
|
||||
|
||||
## Caught a Bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
37
node_modules/@babel/traverse/package.json
generated
vendored
Normal file
37
node_modules/@babel/traverse/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@babel/traverse",
|
||||
"version": "7.18.11",
|
||||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-traverse",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-traverse"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.18.6",
|
||||
"@babel/generator": "^7.18.10",
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-function-name": "^7.18.9",
|
||||
"@babel/helper-hoist-variables": "^7.18.6",
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"@babel/parser": "^7.18.11",
|
||||
"@babel/types": "^7.18.10",
|
||||
"debug": "^4.1.0",
|
||||
"globals": "^11.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user