mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
chore:更换到主分支
This commit is contained in:
4
node_modules/estree-walker/CHANGELOG.md
generated
vendored
4
node_modules/estree-walker/CHANGELOG.md
generated
vendored
@@ -1,5 +1,9 @@
|
||||
# changelog
|
||||
|
||||
## 2.0.2
|
||||
|
||||
* Internal tidying up (change test runner, convert to JS)
|
||||
|
||||
## 2.0.1
|
||||
|
||||
* Robustify `this.remove()`, pass current index to walker functions ([#18](https://github.com/Rich-Harris/estree-walker/pull/18))
|
||||
|
||||
253
node_modules/estree-walker/dist/estree-walker.umd.js
generated
vendored
253
node_modules/estree-walker/dist/estree-walker.umd.js
generated
vendored
@@ -1,253 +0,0 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.estreeWalker = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); }
|
||||
__init() {this.should_skip = false;}
|
||||
__init2() {this.should_remove = false;}
|
||||
__init3() {this.replacement = null;}
|
||||
|
||||
__init4() {this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};}
|
||||
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, enter, leave, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
async visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, enter, leave, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
function walk(ast, walker) {
|
||||
const instance = new SyncWalkerClass(walker);
|
||||
return instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
async function asyncWalk(
|
||||
ast,
|
||||
walker
|
||||
) {
|
||||
const instance = new AsyncWalkerClass(walker);
|
||||
return await instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
exports.walk = walk;
|
||||
exports.asyncWalk = asyncWalk;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
44
node_modules/estree-walker/package.json
generated
vendored
44
node_modules/estree-walker/package.json
generated
vendored
@@ -1,36 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"estree-walker@2.0.1",
|
||||
"estree-walker@2.0.2",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "estree-walker@2.0.1",
|
||||
"_id": "estree-walker@2.0.1",
|
||||
"_from": "estree-walker@2.0.2",
|
||||
"_id": "estree-walker@2.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-+OAw+yHO+hg7RLetUWt0dDTno+A=",
|
||||
"_integrity": "sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw=",
|
||||
"_location": "/estree-walker",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "estree-walker@2.0.1",
|
||||
"raw": "estree-walker@2.0.2",
|
||||
"name": "estree-walker",
|
||||
"escapedName": "estree-walker",
|
||||
"rawSpec": "2.0.1",
|
||||
"rawSpec": "2.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.1"
|
||||
"fetchSpec": "2.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@rollup/plugin-commonjs",
|
||||
"/@rollup/pluginutils",
|
||||
"/@vue/compiler-core",
|
||||
"/@vue/compiler-sfc",
|
||||
"/rollup-plugin-dynamic-import-variables"
|
||||
"/@vue/compiler-sfc"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/estree-walker/-/estree-walker-2.0.1.tgz",
|
||||
"_spec": "2.0.1",
|
||||
"_resolved": "http://192.168.250.101:4873/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
"_spec": "2.0.2",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Rich Harris"
|
||||
@@ -41,10 +37,13 @@
|
||||
"description": "Traverse an ESTree-compliant AST",
|
||||
"devDependencies": {
|
||||
"@types/estree": "0.0.42",
|
||||
"mocha": "^5.2.0",
|
||||
"rollup": "^0.67.3",
|
||||
"rollup-plugin-sucrase": "^2.1.0",
|
||||
"typescript": "^3.7.5"
|
||||
"rollup": "^2.10.9",
|
||||
"typescript": "^3.7.5",
|
||||
"uvu": "^0.5.1"
|
||||
},
|
||||
"exports": {
|
||||
"require": "./dist/umd/estree-walker.js",
|
||||
"import": "./dist/esm/estree-walker.js"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
@@ -54,8 +53,8 @@
|
||||
],
|
||||
"homepage": "https://github.com/Rich-Harris/estree-walker#readme",
|
||||
"license": "MIT",
|
||||
"main": "dist/estree-walker.umd.js",
|
||||
"module": "src/estree-walker.js",
|
||||
"main": "./dist/umd/estree-walker.js",
|
||||
"module": "./dist/esm/estree-walker.js",
|
||||
"name": "estree-walker",
|
||||
"private": false,
|
||||
"repository": {
|
||||
@@ -65,8 +64,9 @@
|
||||
"scripts": {
|
||||
"build": "tsc && rollup -c",
|
||||
"prepublishOnly": "npm run build && npm test",
|
||||
"test": "mocha --opts mocha.opts"
|
||||
"test": "uvu test"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"types": "types/index.d.ts",
|
||||
"version": "2.0.1"
|
||||
"version": "2.0.2"
|
||||
}
|
||||
|
||||
113
node_modules/estree-walker/src/async.ts
generated
vendored
113
node_modules/estree-walker/src/async.ts
generated
vendored
@@ -1,113 +0,0 @@
|
||||
import { WalkerBase, WalkerContext } from "./walker";
|
||||
import { BaseNode } from "estree";
|
||||
|
||||
export type AsyncWalker = {
|
||||
enter?: AsyncWalkerHandler;
|
||||
leave?: AsyncWalkerHandler;
|
||||
};
|
||||
|
||||
export type AsyncWalkerHandler = (
|
||||
this: WalkerContext,
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
key: string,
|
||||
index: number
|
||||
) => Promise<void>;
|
||||
|
||||
export class AsyncWalkerClass extends WalkerBase {
|
||||
protected enter: AsyncWalker["enter"];
|
||||
protected leave: AsyncWalker["leave"];
|
||||
|
||||
constructor(walker: AsyncWalker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
public async visit(
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
enter: AsyncWalkerHandler,
|
||||
leave: AsyncWalkerHandler,
|
||||
prop?: string,
|
||||
index?: number
|
||||
): Promise<BaseNode> {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node as any)[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, enter, leave, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
242
node_modules/estree-walker/src/estree-walker.js
generated
vendored
242
node_modules/estree-walker/src/estree-walker.js
generated
vendored
@@ -1,242 +0,0 @@
|
||||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); }
|
||||
__init() {this.should_skip = false;}
|
||||
__init2() {this.should_remove = false;}
|
||||
__init3() {this.replacement = null;}
|
||||
|
||||
__init4() {this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};}
|
||||
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, enter, leave, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
async visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node )[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, enter, leave, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
function walk(ast, walker) {
|
||||
const instance = new SyncWalkerClass(walker);
|
||||
return instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
async function asyncWalk(
|
||||
ast,
|
||||
walker
|
||||
) {
|
||||
const instance = new AsyncWalkerClass(walker);
|
||||
return await instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
export { walk, asyncWalk };
|
||||
16
node_modules/estree-walker/src/index.ts
generated
vendored
16
node_modules/estree-walker/src/index.ts
generated
vendored
@@ -1,16 +0,0 @@
|
||||
import { BaseNode } from "estree";
|
||||
import { SyncWalkerClass, SyncWalker } from "./sync";
|
||||
import { AsyncWalkerClass, AsyncWalker } from "./async";
|
||||
|
||||
export function walk(ast: BaseNode, walker: SyncWalker): BaseNode {
|
||||
const instance = new SyncWalkerClass(walker);
|
||||
return instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
export async function asyncWalk(
|
||||
ast: BaseNode,
|
||||
walker: AsyncWalker
|
||||
): Promise<BaseNode> {
|
||||
const instance = new AsyncWalkerClass(walker);
|
||||
return await instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
113
node_modules/estree-walker/src/sync.ts
generated
vendored
113
node_modules/estree-walker/src/sync.ts
generated
vendored
@@ -1,113 +0,0 @@
|
||||
import { WalkerBase, WalkerContext } from "./walker";
|
||||
import { BaseNode } from "estree";
|
||||
|
||||
export type SyncWalker = {
|
||||
enter?: WalkerHandler;
|
||||
leave?: WalkerHandler;
|
||||
};
|
||||
|
||||
export type WalkerHandler = (
|
||||
this: WalkerContext,
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
key: string,
|
||||
index: number
|
||||
) => void;
|
||||
|
||||
export class SyncWalkerClass extends WalkerBase {
|
||||
protected enter: SyncWalker["enter"];
|
||||
protected leave: SyncWalker["leave"];
|
||||
|
||||
constructor(walker: SyncWalker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
public visit(
|
||||
node: BaseNode,
|
||||
parent: BaseNode,
|
||||
enter: WalkerHandler,
|
||||
leave: WalkerHandler,
|
||||
prop?: string,
|
||||
index?: number
|
||||
): BaseNode {
|
||||
if (node) {
|
||||
if (enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = (node as any)[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, enter, leave, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
39
node_modules/estree-walker/src/walker.ts
generated
vendored
39
node_modules/estree-walker/src/walker.ts
generated
vendored
@@ -1,39 +0,0 @@
|
||||
import { BaseNode } from "estree";
|
||||
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
};
|
||||
|
||||
export class WalkerBase {
|
||||
protected should_skip: boolean = false;
|
||||
protected should_remove: boolean = false;
|
||||
protected replacement: BaseNode = null;
|
||||
|
||||
public context: WalkerContext = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node: BaseNode) => (this.replacement = node)
|
||||
};
|
||||
|
||||
public replace(parent: any, prop: string, index: number, node: BaseNode) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public remove(parent: any, prop: string, index: number) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
node_modules/estree-walker/types/async.d.ts
generated
vendored
64
node_modules/estree-walker/types/async.d.ts
generated
vendored
@@ -1,13 +1,53 @@
|
||||
import { WalkerBase, WalkerContext } from "./walker";
|
||||
import { BaseNode } from "estree";
|
||||
export declare type AsyncWalker = {
|
||||
enter?: AsyncWalkerHandler;
|
||||
leave?: AsyncWalkerHandler;
|
||||
};
|
||||
export declare type AsyncWalkerHandler = (this: WalkerContext, node: BaseNode, parent: BaseNode, key: string, index: number) => Promise<void>;
|
||||
export declare class AsyncWalkerClass extends WalkerBase {
|
||||
protected enter: AsyncWalker["enter"];
|
||||
protected leave: AsyncWalker["leave"];
|
||||
constructor(walker: AsyncWalker);
|
||||
visit(node: BaseNode, parent: BaseNode, enter: AsyncWalkerHandler, leave: AsyncWalkerHandler, prop?: string, index?: number): Promise<BaseNode>;
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker').WalkerContext} WalkerContext */
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => Promise<void>} AsyncHandler */
|
||||
export class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} enter
|
||||
* @param {AsyncHandler} leave
|
||||
*/
|
||||
constructor(enter: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>, leave: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>);
|
||||
/** @type {AsyncHandler} */
|
||||
enter: AsyncHandler;
|
||||
/** @type {AsyncHandler} */
|
||||
leave: AsyncHandler;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
visit(node: import("estree").BaseNode, parent: import("estree").BaseNode, prop?: string, index?: number): Promise<import("estree").BaseNode>;
|
||||
should_skip: any;
|
||||
should_remove: any;
|
||||
replacement: any;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
export type AsyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
|
||||
61
node_modules/estree-walker/types/index.d.ts
generated
vendored
61
node_modules/estree-walker/types/index.d.ts
generated
vendored
@@ -1,5 +1,56 @@
|
||||
import { BaseNode } from "estree";
|
||||
import { SyncWalker } from "./sync";
|
||||
import { AsyncWalker } from "./async";
|
||||
export declare function walk(ast: BaseNode, walker: SyncWalker): BaseNode;
|
||||
export declare function asyncWalk(ast: BaseNode, walker: AsyncWalker): Promise<BaseNode>;
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
||||
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
export function walk(ast: import("estree").BaseNode, { enter, leave }: {
|
||||
enter?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
leave?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
}): import("estree").BaseNode;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
export function asyncWalk(ast: import("estree").BaseNode, { enter, leave }: {
|
||||
enter?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
leave?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
}): Promise<import("estree").BaseNode>;
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type SyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
export type AsyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
|
||||
64
node_modules/estree-walker/types/sync.d.ts
generated
vendored
64
node_modules/estree-walker/types/sync.d.ts
generated
vendored
@@ -1,13 +1,53 @@
|
||||
import { WalkerBase, WalkerContext } from "./walker";
|
||||
import { BaseNode } from "estree";
|
||||
export declare type SyncWalker = {
|
||||
enter?: WalkerHandler;
|
||||
leave?: WalkerHandler;
|
||||
};
|
||||
export declare type WalkerHandler = (this: WalkerContext, node: BaseNode, parent: BaseNode, key: string, index: number) => void;
|
||||
export declare class SyncWalkerClass extends WalkerBase {
|
||||
protected enter: SyncWalker["enter"];
|
||||
protected leave: SyncWalker["leave"];
|
||||
constructor(walker: SyncWalker);
|
||||
visit(node: BaseNode, parent: BaseNode, enter: WalkerHandler, leave: WalkerHandler, prop?: string, index?: number): BaseNode;
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => void} SyncHandler */
|
||||
export class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} enter
|
||||
* @param {SyncHandler} leave
|
||||
*/
|
||||
constructor(enter: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void, leave: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void);
|
||||
/** @type {SyncHandler} */
|
||||
enter: SyncHandler;
|
||||
/** @type {SyncHandler} */
|
||||
leave: SyncHandler;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
visit(node: import("estree").BaseNode, parent: import("estree").BaseNode, prop?: string, index?: number): import("estree").BaseNode;
|
||||
should_skip: any;
|
||||
should_remove: any;
|
||||
replacement: any;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
export type SyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
|
||||
39
node_modules/estree-walker/types/walker.d.ts
generated
vendored
39
node_modules/estree-walker/types/walker.d.ts
generated
vendored
@@ -1,14 +1,37 @@
|
||||
import { BaseNode } from "estree";
|
||||
export declare type WalkerContext = {
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
};
|
||||
export declare class WalkerBase {
|
||||
protected should_skip: boolean;
|
||||
protected should_remove: boolean;
|
||||
protected replacement: BaseNode;
|
||||
}} WalkerContext */
|
||||
export class WalkerBase {
|
||||
/** @type {boolean} */
|
||||
should_skip: boolean;
|
||||
/** @type {boolean} */
|
||||
should_remove: boolean;
|
||||
/** @type {BaseNode | null} */
|
||||
replacement: BaseNode | null;
|
||||
/** @type {WalkerContext} */
|
||||
context: WalkerContext;
|
||||
replace(parent: any, prop: string, index: number, node: BaseNode): void;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent: any, prop: string, index: number, node: import("estree").BaseNode): void;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent: any, prop: string, index: number): void;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user