feat: refactoring project
This commit is contained in:
19
node_modules/@babel/traverse/lib/path/context.js
generated
vendored
19
node_modules/@babel/traverse/lib/path/context.js
generated
vendored
@@ -10,7 +10,7 @@ exports._resyncList = _resyncList;
|
||||
exports._resyncParent = _resyncParent;
|
||||
exports._resyncRemoved = _resyncRemoved;
|
||||
exports.call = call;
|
||||
exports.isBlacklisted = exports.isDenylisted = isDenylisted;
|
||||
exports.isDenylisted = isDenylisted;
|
||||
exports.popContext = popContext;
|
||||
exports.pushContext = pushContext;
|
||||
exports.requeue = requeue;
|
||||
@@ -61,7 +61,10 @@ function _call(fns) {
|
||||
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;
|
||||
return denylist == null ? void 0 : denylist.includes(this.node.type);
|
||||
}
|
||||
{
|
||||
exports.isBlacklisted = isDenylisted;
|
||||
}
|
||||
function restoreContext(path, context) {
|
||||
if (path.context !== context) {
|
||||
@@ -82,7 +85,7 @@ function visit() {
|
||||
return false;
|
||||
}
|
||||
const currentContext = this.context;
|
||||
if (this.shouldSkip || this.call("enter")) {
|
||||
if (this.shouldSkip || call.call(this, "enter")) {
|
||||
this.debug("Skip...");
|
||||
return this.shouldStop;
|
||||
}
|
||||
@@ -90,7 +93,7 @@ function visit() {
|
||||
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");
|
||||
call.call(this, "exit");
|
||||
return this.shouldStop;
|
||||
}
|
||||
function skip() {
|
||||
@@ -132,7 +135,7 @@ function setContext(context) {
|
||||
this.state = context.state;
|
||||
this.opts = context.opts;
|
||||
}
|
||||
this.setScope();
|
||||
setScope.call(this);
|
||||
return this;
|
||||
}
|
||||
function resync() {
|
||||
@@ -154,14 +157,14 @@ function _resyncKey() {
|
||||
if (Array.isArray(this.container)) {
|
||||
for (let i = 0; i < this.container.length; i++) {
|
||||
if (this.container[i] === this.node) {
|
||||
this.setKey(i);
|
||||
setKey.call(this, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const key of Object.keys(this.container)) {
|
||||
if (this.container[key] === this.node) {
|
||||
this.setKey(key);
|
||||
setKey.call(this, key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +198,7 @@ function setup(parentPath, container, listKey, key) {
|
||||
this.listKey = listKey;
|
||||
this.container = container;
|
||||
this.parentPath = parentPath || this.parentPath;
|
||||
this.setKey(key);
|
||||
setKey.call(this, key);
|
||||
}
|
||||
function setKey(key) {
|
||||
var _this$node;
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/context.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/context.js.map
generated
vendored
File diff suppressed because one or more lines are too long
3
node_modules/@babel/traverse/lib/path/conversion.js
generated
vendored
3
node_modules/@babel/traverse/lib/path/conversion.js
generated
vendored
@@ -12,6 +12,7 @@ exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
|
||||
var _t = require("@babel/types");
|
||||
var _template = require("@babel/template");
|
||||
var _visitors = require("../visitors.js");
|
||||
var _context = require("./context.js");
|
||||
const {
|
||||
arrowFunctionExpression,
|
||||
assignmentExpression,
|
||||
@@ -96,7 +97,7 @@ function ensureBlock() {
|
||||
}
|
||||
this.node.body = blockStatement(statements);
|
||||
const parentPath = this.get(stringPath);
|
||||
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
|
||||
_context.setup.call(body, parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
|
||||
return this.node;
|
||||
}
|
||||
{
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/conversion.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/conversion.js.map
generated
vendored
File diff suppressed because one or more lines are too long
37
node_modules/@babel/traverse/lib/path/index.js
generated
vendored
37
node_modules/@babel/traverse/lib/path/index.js
generated
vendored
@@ -18,7 +18,8 @@ var NodePath_replacement = require("./replacement.js");
|
||||
var NodePath_evaluation = require("./evaluation.js");
|
||||
var NodePath_conversion = require("./conversion.js");
|
||||
var NodePath_introspection = require("./introspection.js");
|
||||
var NodePath_context = require("./context.js");
|
||||
var _context = require("./context.js");
|
||||
var NodePath_context = _context;
|
||||
var NodePath_removal = require("./removal.js");
|
||||
var NodePath_modification = require("./modification.js");
|
||||
var NodePath_family = require("./family.js");
|
||||
@@ -89,7 +90,7 @@ const NodePath_Final = exports.default = class NodePath {
|
||||
path = new NodePath(hub, parent);
|
||||
if (targetNode) paths.set(targetNode, path);
|
||||
}
|
||||
path.setup(parentPath, container, listKey, key);
|
||||
_context.setup.call(path, parentPath, container, listKey, key);
|
||||
return path;
|
||||
}
|
||||
getScope(scope) {
|
||||
@@ -181,11 +182,7 @@ const methods = {
|
||||
splitExportDeclaration: NodePath_conversion.splitExportDeclaration,
|
||||
ensureFunctionName: NodePath_conversion.ensureFunctionName,
|
||||
matchesPattern: NodePath_introspection.matchesPattern,
|
||||
has: NodePath_introspection.has,
|
||||
isStatic: NodePath_introspection.isStatic,
|
||||
is: NodePath_introspection.is,
|
||||
isnt: NodePath_introspection.isnt,
|
||||
equals: NodePath_introspection.equals,
|
||||
isNodeType: NodePath_introspection.isNodeType,
|
||||
canHaveVariableDeclarationOrExpression: NodePath_introspection.canHaveVariableDeclarationOrExpression,
|
||||
canSwapBetweenExpressionAndStatement: NodePath_introspection.canSwapBetweenExpressionAndStatement,
|
||||
@@ -198,29 +195,19 @@ const methods = {
|
||||
resolve: NodePath_introspection.resolve,
|
||||
isConstantExpression: NodePath_introspection.isConstantExpression,
|
||||
isInStrictMode: NodePath_introspection.isInStrictMode,
|
||||
call: NodePath_context.call,
|
||||
isDenylisted: NodePath_context.isDenylisted,
|
||||
isBlacklisted: NodePath_context.isBlacklisted,
|
||||
visit: NodePath_context.visit,
|
||||
skip: NodePath_context.skip,
|
||||
skipKey: NodePath_context.skipKey,
|
||||
stop: NodePath_context.stop,
|
||||
setScope: NodePath_context.setScope,
|
||||
setContext: NodePath_context.setContext,
|
||||
resync: NodePath_context.resync,
|
||||
popContext: NodePath_context.popContext,
|
||||
pushContext: NodePath_context.pushContext,
|
||||
setup: NodePath_context.setup,
|
||||
setKey: NodePath_context.setKey,
|
||||
requeue: NodePath_context.requeue,
|
||||
requeueComputedKeyAndDecorators: NodePath_context.requeueComputedKeyAndDecorators,
|
||||
remove: NodePath_removal.remove,
|
||||
insertBefore: NodePath_modification.insertBefore,
|
||||
insertAfter: NodePath_modification.insertAfter,
|
||||
updateSiblingKeys: NodePath_modification.updateSiblingKeys,
|
||||
unshiftContainer: NodePath_modification.unshiftContainer,
|
||||
pushContainer: NodePath_modification.pushContainer,
|
||||
hoist: NodePath_modification.hoist,
|
||||
getOpposite: NodePath_family.getOpposite,
|
||||
getCompletionRecords: NodePath_family.getCompletionRecords,
|
||||
getSibling: NodePath_family.getSibling,
|
||||
@@ -241,11 +228,25 @@ const methods = {
|
||||
Object.assign(NodePath_Final.prototype, methods);
|
||||
{
|
||||
NodePath_Final.prototype.arrowFunctionToShadowed = NodePath_conversion[String("arrowFunctionToShadowed")];
|
||||
Object.assign(NodePath_Final.prototype, {
|
||||
has: NodePath_introspection[String("has")],
|
||||
is: NodePath_introspection[String("is")],
|
||||
isnt: NodePath_introspection[String("isnt")],
|
||||
equals: NodePath_introspection[String("equals")],
|
||||
hoist: NodePath_modification[String("hoist")],
|
||||
updateSiblingKeys: NodePath_modification.updateSiblingKeys,
|
||||
call: NodePath_context.call,
|
||||
isBlacklisted: NodePath_context[String("isBlacklisted")],
|
||||
setScope: NodePath_context.setScope,
|
||||
resync: NodePath_context.resync,
|
||||
popContext: NodePath_context.popContext,
|
||||
pushContext: NodePath_context.pushContext,
|
||||
setup: NodePath_context.setup,
|
||||
setKey: NodePath_context.setKey
|
||||
});
|
||||
}
|
||||
{
|
||||
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo;
|
||||
}
|
||||
{
|
||||
NodePath_Final.prototype._guessExecutionStatusRelativeToDifferentFunctions = NodePath_introspection._guessExecutionStatusRelativeTo;
|
||||
Object.assign(NodePath_Final.prototype, {
|
||||
_getTypeAnnotation: NodePath_inference._getTypeAnnotation,
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/index.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
36
node_modules/@babel/traverse/lib/path/introspection.js
generated
vendored
36
node_modules/@babel/traverse/lib/path/introspection.js
generated
vendored
@@ -7,17 +7,13 @@ 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;
|
||||
@@ -37,24 +33,28 @@ const {
|
||||
function matchesPattern(pattern, allowPartial) {
|
||||
return _matchesPattern(this.node, pattern, allowPartial);
|
||||
}
|
||||
function has(key) {
|
||||
var _this$node;
|
||||
const val = (_this$node = this.node) == null ? void 0 : _this$node[key];
|
||||
if (val && Array.isArray(val)) {
|
||||
return !!val.length;
|
||||
} else {
|
||||
return !!val;
|
||||
}
|
||||
{
|
||||
exports.has = function has(key) {
|
||||
var _this$node;
|
||||
const val = (_this$node = this.node) == null ? void 0 : _this$node[key];
|
||||
if (val && Array.isArray(val)) {
|
||||
return !!val.length;
|
||||
} else {
|
||||
return !!val;
|
||||
}
|
||||
};
|
||||
}
|
||||
function isStatic() {
|
||||
return this.scope.isStatic(this.node);
|
||||
}
|
||||
const is = exports.is = has;
|
||||
function isnt(key) {
|
||||
return !this.has(key);
|
||||
}
|
||||
function equals(key, value) {
|
||||
return this.node[key] === value;
|
||||
{
|
||||
exports.is = exports.has;
|
||||
exports.isnt = function isnt(key) {
|
||||
return !this.has(key);
|
||||
};
|
||||
exports.equals = function equals(key, value) {
|
||||
return this.node[key] === value;
|
||||
};
|
||||
}
|
||||
function isNodeType(type) {
|
||||
return isType(this.type, type);
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/introspection.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/introspection.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/@babel/traverse/lib/path/lib/hoister.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/lib/hoister.js.map
generated
vendored
File diff suppressed because one or more lines are too long
17
node_modules/@babel/traverse/lib/path/modification.js
generated
vendored
17
node_modules/@babel/traverse/lib/path/modification.js
generated
vendored
@@ -7,7 +7,6 @@ exports._containerInsert = _containerInsert;
|
||||
exports._containerInsertAfter = _containerInsertAfter;
|
||||
exports._containerInsertBefore = _containerInsertBefore;
|
||||
exports._verifyNodeList = _verifyNodeList;
|
||||
exports.hoist = hoist;
|
||||
exports.insertAfter = insertAfter;
|
||||
exports.insertBefore = insertBefore;
|
||||
exports.pushContainer = pushContainer;
|
||||
@@ -60,7 +59,7 @@ function insertBefore(nodes_) {
|
||||
}
|
||||
}
|
||||
function _containerInsert(from, nodes) {
|
||||
this.updateSiblingKeys(from, nodes.length);
|
||||
updateSiblingKeys.call(this, from, nodes.length);
|
||||
const paths = [];
|
||||
this.container.splice(from, 0, ...nodes);
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
@@ -69,12 +68,12 @@ function _containerInsert(from, nodes) {
|
||||
const path = this.getSibling(to);
|
||||
paths.push(path);
|
||||
if ((_this$context = this.context) != null && _this$context.queue) {
|
||||
path.pushContext(this.context);
|
||||
_context.pushContext.call(path, this.context);
|
||||
}
|
||||
}
|
||||
const contexts = _context._getQueueContexts.call(this);
|
||||
for (const path of paths) {
|
||||
path.setScope();
|
||||
_context.setScope.call(path);
|
||||
path.debug("Inserted.");
|
||||
for (const context of contexts) {
|
||||
context.maybeQueue(path, true);
|
||||
@@ -164,7 +163,7 @@ function updateSiblingKeys(fromIndex, incrementBy) {
|
||||
if (!this.parent) return;
|
||||
const paths = (0, _cache.getCachedPaths)(this.hub, this.parent) || [];
|
||||
for (const [, path] of paths) {
|
||||
if (typeof path.key === "number" && path.key >= fromIndex) {
|
||||
if (typeof path.key === "number" && path.container === this.container && path.key >= fromIndex) {
|
||||
path.key += incrementBy;
|
||||
}
|
||||
}
|
||||
@@ -220,9 +219,11 @@ function pushContainer(listKey, nodes) {
|
||||
}).setContext(this.context);
|
||||
return path.replaceWithMultiple(verifiedNodes);
|
||||
}
|
||||
function hoist(scope = this.scope) {
|
||||
const hoister = new _hoister.default(this, scope);
|
||||
return hoister.run();
|
||||
{
|
||||
exports.hoist = function hoist(scope = this.scope) {
|
||||
const hoister = new _hoister.default(this, scope);
|
||||
return hoister.run();
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=modification.js.map
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/modification.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/modification.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
node_modules/@babel/traverse/lib/path/removal.js
generated
vendored
6
node_modules/@babel/traverse/lib/path/removal.js
generated
vendored
@@ -14,13 +14,15 @@ var _cache = require("../cache.js");
|
||||
var _replacement = require("./replacement.js");
|
||||
var _index = require("./index.js");
|
||||
var _t = require("@babel/types");
|
||||
var _modification = require("./modification.js");
|
||||
var _context = require("./context.js");
|
||||
const {
|
||||
getBindingIdentifiers
|
||||
} = _t;
|
||||
function remove() {
|
||||
var _this$opts;
|
||||
_assertUnremoved.call(this);
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
if (_callRemovalHooks.call(this)) {
|
||||
_markRemoved.call(this);
|
||||
return;
|
||||
@@ -46,7 +48,7 @@ function _callRemovalHooks() {
|
||||
function _remove() {
|
||||
if (Array.isArray(this.container)) {
|
||||
this.container.splice(this.key, 1);
|
||||
this.updateSiblingKeys(this.key, -1);
|
||||
_modification.updateSiblingKeys.call(this, this.key, -1);
|
||||
} else {
|
||||
_replacement._replaceWith.call(this, null);
|
||||
}
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/removal.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/removal.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"names":["_removalHooks","require","_cache","_replacement","_index","_t","getBindingIdentifiers","remove","_this$opts","_assertUnremoved","call","resync","_callRemovalHooks","_markRemoved","opts","noScope","_removeFromScope","shareCommentsWithSiblings","_remove","bindings","node","Object","keys","forEach","name","scope","removeBinding","parentPath","fn","hooks","Array","isArray","container","splice","key","updateSiblingKeys","_replaceWith","_traverseFlags","SHOULD_SKIP","REMOVED","parent","getCachedPaths","hub","delete","removed","buildCodeFrameError"],"sources":["../../src/path/removal.ts"],"sourcesContent":["// This file contains methods responsible for removing a node.\n\nimport { hooks } from \"./lib/removal-hooks.ts\";\nimport { getCachedPaths } from \"../cache.ts\";\nimport { _replaceWith } from \"./replacement.ts\";\nimport type NodePath from \"./index.ts\";\nimport { REMOVED, SHOULD_SKIP } from \"./index.ts\";\nimport { getBindingIdentifiers } from \"@babel/types\";\n\nexport function remove(this: NodePath) {\n _assertUnremoved.call(this);\n\n this.resync();\n\n if (_callRemovalHooks.call(this)) {\n _markRemoved.call(this);\n return;\n }\n\n if (!this.opts?.noScope) {\n _removeFromScope.call(this);\n }\n\n this.shareCommentsWithSiblings();\n _remove.call(this);\n _markRemoved.call(this);\n}\n\nexport function _removeFromScope(this: NodePath) {\n const bindings = getBindingIdentifiers(this.node, false, false, true);\n Object.keys(bindings).forEach(name => this.scope.removeBinding(name));\n}\n\nexport function _callRemovalHooks(this: NodePath) {\n if (this.parentPath) {\n for (const fn of hooks) {\n if (fn(this, this.parentPath)) return true;\n }\n }\n}\n\nexport function _remove(this: NodePath) {\n if (Array.isArray(this.container)) {\n this.container.splice(this.key as number, 1);\n this.updateSiblingKeys(this.key as number, -1);\n } else {\n _replaceWith.call(this, null);\n }\n}\n\nexport function _markRemoved(this: NodePath) {\n // this.shouldSkip = true; this.removed = true;\n this._traverseFlags |= SHOULD_SKIP | REMOVED;\n if (this.parent) {\n getCachedPaths(this.hub, this.parent).delete(this.node);\n }\n this.node = null;\n}\n\nexport function _assertUnremoved(this: NodePath) {\n if (this.removed) {\n throw this.buildCodeFrameError(\n \"NodePath has been removed so is read-only.\",\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,EAAA,GAAAJ,OAAA;AAAqD;EAA5CK;AAAqB,IAAAD,EAAA;AAEvB,SAASE,MAAMA,CAAA,EAAiB;EAAA,IAAAC,UAAA;EACrCC,gBAAgB,CAACC,IAAI,CAAC,IAAI,CAAC;EAE3B,IAAI,CAACC,MAAM,CAAC,CAAC;EAEb,IAAIC,iBAAiB,CAACF,IAAI,CAAC,IAAI,CAAC,EAAE;IAChCG,YAAY,CAACH,IAAI,CAAC,IAAI,CAAC;IACvB;EACF;EAEA,IAAI,GAAAF,UAAA,GAAC,IAAI,CAACM,IAAI,aAATN,UAAA,CAAWO,OAAO,GAAE;IACvBC,gBAAgB,CAACN,IAAI,CAAC,IAAI,CAAC;EAC7B;EAEA,IAAI,CAACO,yBAAyB,CAAC,CAAC;EAChCC,OAAO,CAACR,IAAI,CAAC,IAAI,CAAC;EAClBG,YAAY,CAACH,IAAI,CAAC,IAAI,CAAC;AACzB;AAEO,SAASM,gBAAgBA,CAAA,EAAiB;EAC/C,MAAMG,QAAQ,GAAGb,qBAAqB,CAAC,IAAI,CAACc,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;EACrEC,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,OAAO,CAACC,IAAI,IAAI,IAAI,CAACC,KAAK,CAACC,aAAa,CAACF,IAAI,CAAC,CAAC;AACvE;AAEO,SAASZ,iBAAiBA,CAAA,EAAiB;EAChD,IAAI,IAAI,CAACe,UAAU,EAAE;IACnB,KAAK,MAAMC,EAAE,IAAIC,mBAAK,EAAE;MACtB,IAAID,EAAE,CAAC,IAAI,EAAE,IAAI,CAACD,UAAU,CAAC,EAAE,OAAO,IAAI;IAC5C;EACF;AACF;AAEO,SAAST,OAAOA,CAAA,EAAiB;EACtC,IAAIY,KAAK,CAACC,OAAO,CAAC,IAAI,CAACC,SAAS,CAAC,EAAE;IACjC,IAAI,CAACA,SAAS,CAACC,MAAM,CAAC,IAAI,CAACC,GAAG,EAAY,CAAC,CAAC;IAC5C,IAAI,CAACC,iBAAiB,CAAC,IAAI,CAACD,GAAG,EAAY,CAAC,CAAC,CAAC;EAChD,CAAC,MAAM;IACLE,yBAAY,CAAC1B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;EAC/B;AACF;AAEO,SAASG,YAAYA,CAAA,EAAiB;EAE3C,IAAI,CAACwB,cAAc,IAAIC,kBAAW,GAAGC,cAAO;EAC5C,IAAI,IAAI,CAACC,MAAM,EAAE;IACf,IAAAC,qBAAc,EAAC,IAAI,CAACC,GAAG,EAAE,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,IAAI,CAACvB,IAAI,CAAC;EACzD;EACA,IAAI,CAACA,IAAI,GAAG,IAAI;AAClB;AAEO,SAASX,gBAAgBA,CAAA,EAAiB;EAC/C,IAAI,IAAI,CAACmC,OAAO,EAAE;IAChB,MAAM,IAAI,CAACC,mBAAmB,CAC5B,4CACF,CAAC;EACH;AACF","ignoreList":[]}
|
||||
{"version":3,"names":["_removalHooks","require","_cache","_replacement","_index","_t","_modification","_context","getBindingIdentifiers","remove","_this$opts","_assertUnremoved","call","resync","_callRemovalHooks","_markRemoved","opts","noScope","_removeFromScope","shareCommentsWithSiblings","_remove","bindings","node","Object","keys","forEach","name","scope","removeBinding","parentPath","fn","hooks","Array","isArray","container","splice","key","updateSiblingKeys","_replaceWith","_traverseFlags","SHOULD_SKIP","REMOVED","parent","getCachedPaths","hub","delete","removed","buildCodeFrameError"],"sources":["../../src/path/removal.ts"],"sourcesContent":["// This file contains methods responsible for removing a node.\n\nimport { hooks } from \"./lib/removal-hooks.ts\";\nimport { getCachedPaths } from \"../cache.ts\";\nimport { _replaceWith } from \"./replacement.ts\";\nimport type NodePath from \"./index.ts\";\nimport { REMOVED, SHOULD_SKIP } from \"./index.ts\";\nimport { getBindingIdentifiers } from \"@babel/types\";\nimport { updateSiblingKeys } from \"./modification.ts\";\nimport { resync } from \"./context.ts\";\n\nexport function remove(this: NodePath) {\n _assertUnremoved.call(this);\n\n resync.call(this);\n\n if (_callRemovalHooks.call(this)) {\n _markRemoved.call(this);\n return;\n }\n\n if (!this.opts?.noScope) {\n _removeFromScope.call(this);\n }\n\n this.shareCommentsWithSiblings();\n _remove.call(this);\n _markRemoved.call(this);\n}\n\nexport function _removeFromScope(this: NodePath) {\n const bindings = getBindingIdentifiers(this.node, false, false, true);\n Object.keys(bindings).forEach(name => this.scope.removeBinding(name));\n}\n\nexport function _callRemovalHooks(this: NodePath) {\n if (this.parentPath) {\n for (const fn of hooks) {\n if (fn(this, this.parentPath)) return true;\n }\n }\n}\n\nexport function _remove(this: NodePath) {\n if (Array.isArray(this.container)) {\n this.container.splice(this.key as number, 1);\n updateSiblingKeys.call(this, this.key as number, -1);\n } else {\n _replaceWith.call(this, null);\n }\n}\n\nexport function _markRemoved(this: NodePath) {\n // this.shouldSkip = true; this.removed = true;\n this._traverseFlags |= SHOULD_SKIP | REMOVED;\n if (this.parent) {\n getCachedPaths(this.hub, this.parent).delete(this.node);\n }\n this.node = null;\n}\n\nexport function _assertUnremoved(this: NodePath) {\n if (this.removed) {\n throw this.buildCodeFrameError(\n \"NodePath has been removed so is read-only.\",\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,EAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAAsC;EAF7BO;AAAqB,IAAAH,EAAA;AAIvB,SAASI,MAAMA,CAAA,EAAiB;EAAA,IAAAC,UAAA;EACrCC,gBAAgB,CAACC,IAAI,CAAC,IAAI,CAAC;EAE3BC,eAAM,CAACD,IAAI,CAAC,IAAI,CAAC;EAEjB,IAAIE,iBAAiB,CAACF,IAAI,CAAC,IAAI,CAAC,EAAE;IAChCG,YAAY,CAACH,IAAI,CAAC,IAAI,CAAC;IACvB;EACF;EAEA,IAAI,GAAAF,UAAA,GAAC,IAAI,CAACM,IAAI,aAATN,UAAA,CAAWO,OAAO,GAAE;IACvBC,gBAAgB,CAACN,IAAI,CAAC,IAAI,CAAC;EAC7B;EAEA,IAAI,CAACO,yBAAyB,CAAC,CAAC;EAChCC,OAAO,CAACR,IAAI,CAAC,IAAI,CAAC;EAClBG,YAAY,CAACH,IAAI,CAAC,IAAI,CAAC;AACzB;AAEO,SAASM,gBAAgBA,CAAA,EAAiB;EAC/C,MAAMG,QAAQ,GAAGb,qBAAqB,CAAC,IAAI,CAACc,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;EACrEC,MAAM,CAACC,IAAI,CAACH,QAAQ,CAAC,CAACI,OAAO,CAACC,IAAI,IAAI,IAAI,CAACC,KAAK,CAACC,aAAa,CAACF,IAAI,CAAC,CAAC;AACvE;AAEO,SAASZ,iBAAiBA,CAAA,EAAiB;EAChD,IAAI,IAAI,CAACe,UAAU,EAAE;IACnB,KAAK,MAAMC,EAAE,IAAIC,mBAAK,EAAE;MACtB,IAAID,EAAE,CAAC,IAAI,EAAE,IAAI,CAACD,UAAU,CAAC,EAAE,OAAO,IAAI;IAC5C;EACF;AACF;AAEO,SAAST,OAAOA,CAAA,EAAiB;EACtC,IAAIY,KAAK,CAACC,OAAO,CAAC,IAAI,CAACC,SAAS,CAAC,EAAE;IACjC,IAAI,CAACA,SAAS,CAACC,MAAM,CAAC,IAAI,CAACC,GAAG,EAAY,CAAC,CAAC;IAC5CC,+BAAiB,CAACzB,IAAI,CAAC,IAAI,EAAE,IAAI,CAACwB,GAAG,EAAY,CAAC,CAAC,CAAC;EACtD,CAAC,MAAM;IACLE,yBAAY,CAAC1B,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;EAC/B;AACF;AAEO,SAASG,YAAYA,CAAA,EAAiB;EAE3C,IAAI,CAACwB,cAAc,IAAIC,kBAAW,GAAGC,cAAO;EAC5C,IAAI,IAAI,CAACC,MAAM,EAAE;IACf,IAAAC,qBAAc,EAAC,IAAI,CAACC,GAAG,EAAE,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,CAAC,IAAI,CAACvB,IAAI,CAAC;EACzD;EACA,IAAI,CAACA,IAAI,GAAG,IAAI;AAClB;AAEO,SAASX,gBAAgBA,CAAA,EAAiB;EAC/C,IAAI,IAAI,CAACmC,OAAO,EAAE;IAChB,MAAM,IAAI,CAACC,mBAAmB,CAC5B,4CACF,CAAC;EACH;AACF","ignoreList":[]}
|
||||
17
node_modules/@babel/traverse/lib/path/replacement.js
generated
vendored
17
node_modules/@babel/traverse/lib/path/replacement.js
generated
vendored
@@ -16,6 +16,7 @@ var _cache = require("../cache.js");
|
||||
var _modification = require("./modification.js");
|
||||
var _parser = require("@babel/parser");
|
||||
var _t = require("@babel/types");
|
||||
var _context = require("./context.js");
|
||||
const {
|
||||
FUNCTION_TYPES,
|
||||
arrowFunctionExpression,
|
||||
@@ -48,7 +49,7 @@ const {
|
||||
} = _t;
|
||||
function replaceWithMultiple(nodes) {
|
||||
var _getCachedPaths;
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
nodes = _modification._verifyNodeList.call(this, nodes);
|
||||
inheritLeadingComments(nodes[0], this.node);
|
||||
inheritTrailingComments(nodes[nodes.length - 1], this.node);
|
||||
@@ -63,7 +64,7 @@ function replaceWithMultiple(nodes) {
|
||||
return paths;
|
||||
}
|
||||
function replaceWithSourceString(replacement) {
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
let ast;
|
||||
try {
|
||||
replacement = `(${replacement})`;
|
||||
@@ -86,7 +87,7 @@ function replaceWithSourceString(replacement) {
|
||||
return this.replaceWith(expressionAST);
|
||||
}
|
||||
function replaceWith(replacementPath) {
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
if (this.removed) {
|
||||
throw new Error("You can't replace this node, we've already removed it");
|
||||
}
|
||||
@@ -125,7 +126,7 @@ function replaceWith(replacementPath) {
|
||||
}
|
||||
_replaceWith.call(this, replacement);
|
||||
this.type = replacement.type;
|
||||
this.setScope();
|
||||
_context.setScope.call(this);
|
||||
this.requeue();
|
||||
return [nodePath ? this.get(nodePath) : this];
|
||||
}
|
||||
@@ -144,7 +145,7 @@ function _replaceWith(node) {
|
||||
this.node = this.container[this.key] = node;
|
||||
}
|
||||
function replaceExpressionWithStatements(nodes) {
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
const declars = [];
|
||||
const nodesAsSingleExpression = gatherSequenceExpressions(nodes, declars);
|
||||
if (nodesAsSingleExpression) {
|
||||
@@ -154,8 +155,8 @@ function replaceExpressionWithStatements(nodes) {
|
||||
return this.replaceWith(nodesAsSingleExpression)[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 isParentAsync = functionParent == null ? void 0 : functionParent.node.async;
|
||||
const isParentGenerator = functionParent == null ? void 0 : functionParent.node.generator;
|
||||
const container = arrowFunctionExpression([], blockStatement(nodes));
|
||||
this.replaceWith(callExpression(container, []));
|
||||
const callee = this.get("callee");
|
||||
@@ -244,7 +245,7 @@ function gatherSequenceExpressions(nodes, declars) {
|
||||
}
|
||||
}
|
||||
function replaceInline(nodes) {
|
||||
this.resync();
|
||||
_context.resync.call(this);
|
||||
if (Array.isArray(nodes)) {
|
||||
if (Array.isArray(this.container)) {
|
||||
nodes = _modification._verifyNodeList.call(this, nodes);
|
||||
|
||||
2
node_modules/@babel/traverse/lib/path/replacement.js.map
generated
vendored
2
node_modules/@babel/traverse/lib/path/replacement.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user