Saving all progress

This commit is contained in:
Luke Hagar
2025-03-19 22:47:50 -05:00
parent 5c6e8a1e4f
commit 00593b402b
14988 changed files with 2598505 additions and 1 deletions

21
node_modules/@vue/compiler-core/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018-present, Yuxi (Evan) You
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.

1
node_modules/@vue/compiler-core/README.md generated vendored Normal file
View File

@@ -0,0 +1 @@
# @vue/compiler-core

6813
node_modules/@vue/compiler-core/dist/compiler-core.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1091
node_modules/@vue/compiler-core/dist/compiler-core.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

7
node_modules/@vue/compiler-core/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/compiler-core.cjs.prod.js')
} else {
module.exports = require('./dist/compiler-core.cjs.js')
}

View File

@@ -0,0 +1,92 @@
# 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))
## 2.0.0
* Add an `asyncWalk` export ([#20](https://github.com/Rich-Harris/estree-walker/pull/20))
* Internal rewrite
## 1.0.1
* Relax node type to `BaseNode` ([#17](https://github.com/Rich-Harris/estree-walker/pull/17))
## 1.0.0
* Don't cache child keys
## 0.9.0
* Add `this.remove()` method
## 0.8.1
* Fix pkg.files
## 0.8.0
* Adopt `estree` types
## 0.7.0
* Add a `this.replace(node)` method
## 0.6.1
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9))
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8))
## 0.6.0
* Fix walker context type
* Update deps, remove unncessary Bublé transformation
## 0.5.2
* Add types to package
## 0.5.1
* Prevent context corruption when `walk()` is called during a walk
## 0.5.0
* Export `childKeys`, for manually fixing in case of malformed ASTs
## 0.4.0
* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
## 0.3.1
* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2))
## 0.3.0
* More predictable ordering
## 0.2.1
* Keep `context` shape
## 0.2.0
* Add ES6 build
## 0.1.3
* npm snafu
## 0.1.2
* Pass current prop and index to `enter`/`leave` callbacks
## 0.1.1
* First release

View File

@@ -0,0 +1,7 @@
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/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.

View File

@@ -0,0 +1,48 @@
# estree-walker
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
## Installation
```bash
npm i estree-walker
```
## Usage
```js
var walk = require( 'estree-walker' ).walk;
var acorn = require( 'acorn' );
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
walk( ast, {
enter: function ( node, parent, prop, index ) {
// some code happens
},
leave: function ( node, parent, prop, index ) {
// some code happens
}
});
```
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
Call `this.remove()` in either `enter` or `leave` to remove the current node.
## Why not use estraverse?
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
## License
MIT

View File

@@ -0,0 +1,333 @@
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => void} SyncHandler */
class SyncWalker extends WalkerBase {
/**
*
* @param {SyncHandler} enter
* @param {SyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => Promise<void>} AsyncHandler */
class AsyncWalker extends WalkerBase {
/**
*
* @param {AsyncHandler} enter
* @param {AsyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}
// @ts-check
/** @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}
*/
function walk(ast, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}
export { asyncWalk, walk };

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,344 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.estreeWalker = {}));
}(this, (function (exports) { 'use strict';
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => void} SyncHandler */
class SyncWalker extends WalkerBase {
/**
*
* @param {SyncHandler} enter
* @param {SyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => Promise<void>} AsyncHandler */
class AsyncWalker extends WalkerBase {
/**
*
* @param {AsyncHandler} enter
* @param {AsyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}
// @ts-check
/** @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}
*/
function walk(ast, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}
exports.asyncWalk = asyncWalk;
exports.walk = walk;
Object.defineProperty(exports, '__esModule', { value: true });
})));

View File

@@ -0,0 +1,37 @@
{
"name": "estree-walker",
"description": "Traverse an ESTree-compliant AST",
"version": "2.0.2",
"private": false,
"author": "Rich Harris",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Rich-Harris/estree-walker"
},
"type": "commonjs",
"main": "./dist/umd/estree-walker.js",
"module": "./dist/esm/estree-walker.js",
"exports": {
"require": "./dist/umd/estree-walker.js",
"import": "./dist/esm/estree-walker.js"
},
"types": "types/index.d.ts",
"scripts": {
"prepublishOnly": "npm run build && npm test",
"build": "tsc && rollup -c",
"test": "uvu test"
},
"devDependencies": {
"@types/estree": "0.0.42",
"rollup": "^2.10.9",
"typescript": "^3.7.5",
"uvu": "^0.5.1"
},
"files": [
"src",
"dist",
"types",
"README.md"
]
}

View File

@@ -0,0 +1,118 @@
// @ts-check
import { WalkerBase } from './walker.js';
/** @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, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}

View File

@@ -0,0 +1,35 @@
// @ts-check
import { SyncWalker } from './sync.js';
import { AsyncWalker } from './async.js';
/** @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, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
export async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}

View File

@@ -0,0 +1 @@
{"type": "module"}

View File

@@ -0,0 +1,118 @@
// @ts-check
import { WalkerBase } from './walker.js';
/** @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, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}

View File

@@ -0,0 +1,61 @@
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
export class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}

View File

@@ -0,0 +1,53 @@
/** @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";

View File

@@ -0,0 +1,56 @@
/** @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>;

View File

@@ -0,0 +1,53 @@
/** @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";

View File

@@ -0,0 +1,345 @@
{
"program": {
"fileInfos": {
"../node_modules/typescript/lib/lib.es5.d.ts": {
"version": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea",
"signature": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea"
},
"../node_modules/typescript/lib/lib.es2015.d.ts": {
"version": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96",
"signature": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96"
},
"../node_modules/typescript/lib/lib.es2016.d.ts": {
"version": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1",
"signature": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1"
},
"../node_modules/typescript/lib/lib.es2017.d.ts": {
"version": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743",
"signature": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743"
},
"../node_modules/typescript/lib/lib.dom.d.ts": {
"version": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de",
"signature": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de"
},
"../node_modules/typescript/lib/lib.dom.iterable.d.ts": {
"version": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf",
"signature": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf"
},
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts": {
"version": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b",
"signature": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b"
},
"../node_modules/typescript/lib/lib.scripthost.d.ts": {
"version": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9",
"signature": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9"
},
"../node_modules/typescript/lib/lib.es2015.core.d.ts": {
"version": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6",
"signature": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6"
},
"../node_modules/typescript/lib/lib.es2015.collection.d.ts": {
"version": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8",
"signature": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8"
},
"../node_modules/typescript/lib/lib.es2015.generator.d.ts": {
"version": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122",
"signature": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122"
},
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
"version": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210",
"signature": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210"
},
"../node_modules/typescript/lib/lib.es2015.promise.d.ts": {
"version": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca",
"signature": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca"
},
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
"version": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe",
"signature": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe"
},
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
"version": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976",
"signature": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976"
},
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
"version": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230",
"signature": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230"
},
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
"version": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303",
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
},
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
"version": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0",
"signature": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0"
},
"../node_modules/typescript/lib/lib.es2017.object.d.ts": {
"version": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408",
"signature": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408"
},
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
"version": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f",
"signature": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f"
},
"../node_modules/typescript/lib/lib.es2017.string.d.ts": {
"version": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c",
"signature": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c"
},
"../node_modules/typescript/lib/lib.es2017.intl.d.ts": {
"version": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6",
"signature": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6"
},
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
"version": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46",
"signature": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46"
},
"../node_modules/typescript/lib/lib.es2017.full.d.ts": {
"version": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594",
"signature": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594"
},
"../node_modules/@types/estree/index.d.ts": {
"version": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644",
"signature": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644"
},
"../src/walker.js": {
"version": "4cc9d0e334d83a4cebeeac502de37a1aeeb953f6d4145a886d9eecea1f2142a7",
"signature": "075872468ccc19c83b03fd717fc9305b5f8ec09592210cf60279cb13eca2bd70"
},
"../src/async.js": {
"version": "904efd145090ac40c3c98f29cc928332898a62ab642dd5921db2ae249bfe014a",
"signature": "da428f781d6dc6dfd4f4afd0dd5f25a780897dc8b57e5b30462491b7d08f32c0"
},
"../src/sync.js": {
"version": "85bb22b85042f0a3717d8fac2fc8f62af16894652be34d1e08eb3e63785535f5",
"signature": "5b131a727db18c956611a5e33d08217df96d0f2e0f26d98b804d1ec2407e59ae"
},
"../src/index.js": {
"version": "99128f4c6cb79cb1e3abf3f2ba96faedd2b820aab4fd7f743aab0b8d710a73af",
"signature": "c52be5c79280bfcfcf359c084c6f2f70f405b0ad14dde96b6703dbc5ef2261f5"
}
},
"options": {
"allowJs": true,
"target": 4,
"module": 99,
"types": [
"estree"
],
"declaration": true,
"declarationDir": "./",
"emitDeclarationOnly": true,
"outDir": "./",
"newLine": 1,
"noImplicitAny": true,
"noImplicitThis": true,
"incremental": true,
"configFilePath": "../tsconfig.json"
},
"referencedMap": {
"../src/walker.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/async.js": [
"../src/walker.js",
"../node_modules/@types/estree/index.d.ts"
],
"../src/sync.js": [
"../src/walker.js",
"../node_modules/@types/estree/index.d.ts"
],
"../src/index.js": [
"../src/sync.js",
"../src/async.js",
"../node_modules/@types/estree/index.d.ts"
]
},
"exportedModulesMap": {
"../src/walker.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/async.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/sync.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/index.js": [
"../node_modules/@types/estree/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../node_modules/typescript/lib/lib.es5.d.ts",
"../node_modules/typescript/lib/lib.es2015.d.ts",
"../node_modules/typescript/lib/lib.es2016.d.ts",
"../node_modules/typescript/lib/lib.es2017.d.ts",
"../node_modules/typescript/lib/lib.dom.d.ts",
"../node_modules/typescript/lib/lib.dom.iterable.d.ts",
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts",
"../node_modules/typescript/lib/lib.scripthost.d.ts",
"../node_modules/typescript/lib/lib.es2015.core.d.ts",
"../node_modules/typescript/lib/lib.es2015.collection.d.ts",
"../node_modules/typescript/lib/lib.es2015.generator.d.ts",
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts",
"../node_modules/typescript/lib/lib.es2015.promise.d.ts",
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts",
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts",
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts",
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts",
"../node_modules/typescript/lib/lib.es2017.object.d.ts",
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
"../node_modules/typescript/lib/lib.es2017.string.d.ts",
"../node_modules/typescript/lib/lib.es2017.intl.d.ts",
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
"../node_modules/typescript/lib/lib.es2017.full.d.ts",
"../node_modules/@types/estree/index.d.ts",
"../src/walker.js",
[
"../src/async.js",
[
{
"file": "../src/async.js",
"start": 864,
"length": 12,
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 907,
"length": 14,
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 954,
"length": 12,
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 991,
"length": 24,
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1021,
"length": 26,
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1053,
"length": 23,
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1643,
"length": 9,
"code": 7053,
"category": 1,
"messageText": {
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
"category": 1,
"code": 7053,
"next": [
{
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
"category": 1,
"code": 7054
}
]
}
}
]
],
[
"../src/sync.js",
[
{
"file": "../src/sync.js",
"start": 837,
"length": 12,
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 880,
"length": 14,
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 927,
"length": 12,
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 964,
"length": 24,
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 994,
"length": 26,
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 1026,
"length": 23,
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 1610,
"length": 9,
"code": 7053,
"category": 1,
"messageText": {
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
"category": 1,
"code": 7053,
"next": [
{
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
"category": 1,
"code": 7054
}
]
}
}
]
],
"../src/index.js"
]
},
"version": "3.7.5"
}

View File

@@ -0,0 +1,37 @@
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
export class WalkerBase {
/** @type {boolean} */
should_skip: boolean;
/** @type {boolean} */
should_remove: boolean;
/** @type {BaseNode | null} */
replacement: BaseNode | null;
/** @type {WalkerContext} */
context: WalkerContext;
/**
*
* @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;
};

58
node_modules/@vue/compiler-core/package.json generated vendored Normal file
View File

@@ -0,0 +1,58 @@
{
"name": "@vue/compiler-core",
"version": "3.5.13",
"description": "@vue/compiler-core",
"main": "index.js",
"module": "dist/compiler-core.esm-bundler.js",
"types": "dist/compiler-core.d.ts",
"files": [
"index.js",
"dist"
],
"exports": {
".": {
"types": "./dist/compiler-core.d.ts",
"node": {
"production": "./dist/compiler-core.cjs.prod.js",
"development": "./dist/compiler-core.cjs.js",
"default": "./index.js"
},
"module": "./dist/compiler-core.esm-bundler.js",
"import": "./dist/compiler-core.esm-bundler.js",
"require": "./index.js"
},
"./*": "./*"
},
"buildOptions": {
"name": "VueCompilerCore",
"compat": true,
"formats": [
"esm-bundler",
"cjs"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/core.git",
"directory": "packages/compiler-core"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/core/issues"
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
"dependencies": {
"@babel/parser": "^7.25.3",
"entities": "^4.5.0",
"estree-walker": "^2.0.2",
"source-map-js": "^1.2.0",
"@vue/shared": "3.5.13"
},
"devDependencies": {
"@babel/types": "^7.25.2"
}
}

21
node_modules/@vue/compiler-dom/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018-present, Yuxi (Evan) You
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.

1
node_modules/@vue/compiler-dom/README.md generated vendored Normal file
View File

@@ -0,0 +1 @@
# @vue/compiler-dom

928
node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js generated vendored Normal file
View File

@@ -0,0 +1,928 @@
/**
* @vue/compiler-dom v3.5.13
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var compilerCore = require('@vue/compiler-core');
var shared = require('@vue/shared');
const V_MODEL_RADIO = Symbol(`vModelRadio` );
const V_MODEL_CHECKBOX = Symbol(
`vModelCheckbox`
);
const V_MODEL_TEXT = Symbol(`vModelText` );
const V_MODEL_SELECT = Symbol(
`vModelSelect`
);
const V_MODEL_DYNAMIC = Symbol(
`vModelDynamic`
);
const V_ON_WITH_MODIFIERS = Symbol(
`vOnModifiersGuard`
);
const V_ON_WITH_KEYS = Symbol(
`vOnKeysGuard`
);
const V_SHOW = Symbol(`vShow` );
const TRANSITION = Symbol(`Transition` );
const TRANSITION_GROUP = Symbol(
`TransitionGroup`
);
compilerCore.registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
[V_MODEL_TEXT]: `vModelText`,
[V_MODEL_SELECT]: `vModelSelect`,
[V_MODEL_DYNAMIC]: `vModelDynamic`,
[V_ON_WITH_MODIFIERS]: `withModifiers`,
[V_ON_WITH_KEYS]: `withKeys`,
[V_SHOW]: `vShow`,
[TRANSITION]: `Transition`,
[TRANSITION_GROUP]: `TransitionGroup`
});
const parserOptions = {
parseMode: "html",
isVoidTag: shared.isVoidTag,
isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
isPreTag: (tag) => tag === "pre",
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
decodeEntities: void 0,
isBuiltInComponent: (tag) => {
if (tag === "Transition" || tag === "transition") {
return TRANSITION;
} else if (tag === "TransitionGroup" || tag === "transition-group") {
return TRANSITION_GROUP;
}
},
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
getNamespace(tag, parent, rootNamespace) {
let ns = parent ? parent.ns : rootNamespace;
if (parent && ns === 2) {
if (parent.tag === "annotation-xml") {
if (tag === "svg") {
return 1;
}
if (parent.props.some(
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
)) {
ns = 0;
}
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
ns = 0;
}
} else if (parent && ns === 1) {
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
ns = 0;
}
}
if (ns === 0) {
if (tag === "svg") {
return 1;
}
if (tag === "math") {
return 2;
}
}
return ns;
}
};
const transformStyle = (node) => {
if (node.type === 1) {
node.props.forEach((p, i) => {
if (p.type === 6 && p.name === "style" && p.value) {
node.props[i] = {
type: 7,
name: `bind`,
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
exp: parseInlineCSS(p.value.content, p.loc),
modifiers: [],
loc: p.loc
};
}
});
}
};
const parseInlineCSS = (cssText, loc) => {
const normalized = shared.parseStringStyle(cssText);
return compilerCore.createSimpleExpression(
JSON.stringify(normalized),
false,
loc,
3
);
};
function createDOMCompilerError(code, loc) {
return compilerCore.createCompilerError(
code,
loc,
DOMErrorMessages
);
}
const DOMErrorCodes = {
"X_V_HTML_NO_EXPRESSION": 53,
"53": "X_V_HTML_NO_EXPRESSION",
"X_V_HTML_WITH_CHILDREN": 54,
"54": "X_V_HTML_WITH_CHILDREN",
"X_V_TEXT_NO_EXPRESSION": 55,
"55": "X_V_TEXT_NO_EXPRESSION",
"X_V_TEXT_WITH_CHILDREN": 56,
"56": "X_V_TEXT_WITH_CHILDREN",
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
"X_V_MODEL_ARG_ON_ELEMENT": 58,
"58": "X_V_MODEL_ARG_ON_ELEMENT",
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
"X_V_MODEL_UNNECESSARY_VALUE": 60,
"60": "X_V_MODEL_UNNECESSARY_VALUE",
"X_V_SHOW_NO_EXPRESSION": 61,
"61": "X_V_SHOW_NO_EXPRESSION",
"X_TRANSITION_INVALID_CHILDREN": 62,
"62": "X_TRANSITION_INVALID_CHILDREN",
"X_IGNORED_SIDE_EFFECT_TAG": 63,
"63": "X_IGNORED_SIDE_EFFECT_TAG",
"__EXTEND_POINT__": 64,
"64": "__EXTEND_POINT__"
};
const DOMErrorMessages = {
[53]: `v-html is missing expression.`,
[54]: `v-html will override element children.`,
[55]: `v-text is missing expression.`,
[56]: `v-text will override element children.`,
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
[58]: `v-model argument is not supported on plain elements.`,
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
[61]: `v-show is missing expression.`,
[62]: `<Transition> expects exactly one child element or component.`,
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
};
const transformVHtml = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(53, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(54, loc)
);
node.children.length = 0;
}
return {
props: [
compilerCore.createObjectProperty(
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
exp || compilerCore.createSimpleExpression("", true)
)
]
};
};
const transformVText = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(55, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(56, loc)
);
node.children.length = 0;
}
return {
props: [
compilerCore.createObjectProperty(
compilerCore.createSimpleExpression(`textContent`, true),
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
context.helperString(compilerCore.TO_DISPLAY_STRING),
[exp],
loc
) : compilerCore.createSimpleExpression("", true)
)
]
};
};
const transformModel = (dir, node, context) => {
const baseResult = compilerCore.transformModel(dir, node, context);
if (!baseResult.props.length || node.tagType === 1) {
return baseResult;
}
if (dir.arg) {
context.onError(
createDOMCompilerError(
58,
dir.arg.loc
)
);
}
function checkDuplicatedValue() {
const value = compilerCore.findDir(node, "bind");
if (value && compilerCore.isStaticArgOf(value.arg, "value")) {
context.onError(
createDOMCompilerError(
60,
value.loc
)
);
}
}
const { tag } = node;
const isCustomElement = context.isCustomElement(tag);
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
let directiveToUse = V_MODEL_TEXT;
let isInvalidType = false;
if (tag === "input" || isCustomElement) {
const type = compilerCore.findProp(node, `type`);
if (type) {
if (type.type === 7) {
directiveToUse = V_MODEL_DYNAMIC;
} else if (type.value) {
switch (type.value.content) {
case "radio":
directiveToUse = V_MODEL_RADIO;
break;
case "checkbox":
directiveToUse = V_MODEL_CHECKBOX;
break;
case "file":
isInvalidType = true;
context.onError(
createDOMCompilerError(
59,
dir.loc
)
);
break;
default:
checkDuplicatedValue();
break;
}
}
} else if (compilerCore.hasDynamicKeyVBind(node)) {
directiveToUse = V_MODEL_DYNAMIC;
} else {
checkDuplicatedValue();
}
} else if (tag === "select") {
directiveToUse = V_MODEL_SELECT;
} else {
checkDuplicatedValue();
}
if (!isInvalidType) {
baseResult.needRuntime = context.helper(directiveToUse);
}
} else {
context.onError(
createDOMCompilerError(
57,
dir.loc
)
);
}
baseResult.props = baseResult.props.filter(
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
);
return baseResult;
};
const isEventOptionModifier = /* @__PURE__ */ shared.makeMap(`passive,once,capture`);
const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
// event propagation management
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
);
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
const resolveModifiers = (key, modifiers, context, loc) => {
const keyModifiers = [];
const nonKeyModifiers = [];
const eventOptionModifiers = [];
for (let i = 0; i < modifiers.length; i++) {
const modifier = modifiers[i].content;
if (modifier === "native" && compilerCore.checkCompatEnabled(
"COMPILER_V_ON_NATIVE",
context,
loc
)) {
eventOptionModifiers.push(modifier);
} else if (isEventOptionModifier(modifier)) {
eventOptionModifiers.push(modifier);
} else {
if (maybeKeyModifier(modifier)) {
if (compilerCore.isStaticExp(key)) {
if (isKeyboardEvent(key.content.toLowerCase())) {
keyModifiers.push(modifier);
} else {
nonKeyModifiers.push(modifier);
}
} else {
keyModifiers.push(modifier);
nonKeyModifiers.push(modifier);
}
} else {
if (isNonKeyModifier(modifier)) {
nonKeyModifiers.push(modifier);
} else {
keyModifiers.push(modifier);
}
}
}
}
return {
keyModifiers,
nonKeyModifiers,
eventOptionModifiers
};
};
const transformClick = (key, event) => {
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === "onclick";
return isStaticClick ? compilerCore.createSimpleExpression(event, true) : key.type !== 4 ? compilerCore.createCompoundExpression([
`(`,
key,
`) === "onClick" ? "${event}" : (`,
key,
`)`
]) : key;
};
const transformOn = (dir, node, context) => {
return compilerCore.transformOn(dir, node, context, (baseResult) => {
const { modifiers } = dir;
if (!modifiers.length) return baseResult;
let { key, value: handlerExp } = baseResult.props[0];
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
if (nonKeyModifiers.includes("right")) {
key = transformClick(key, `onContextmenu`);
}
if (nonKeyModifiers.includes("middle")) {
key = transformClick(key, `onMouseup`);
}
if (nonKeyModifiers.length) {
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
handlerExp,
JSON.stringify(nonKeyModifiers)
]);
}
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
(!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
handlerExp,
JSON.stringify(keyModifiers)
]);
}
if (eventOptionModifiers.length) {
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
}
return {
props: [compilerCore.createObjectProperty(key, handlerExp)]
};
});
};
const transformShow = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(61, loc)
);
}
return {
props: [],
needRuntime: context.helper(V_SHOW)
};
};
const transformTransition = (node, context) => {
if (node.type === 1 && node.tagType === 1) {
const component = context.isBuiltInComponent(node.tag);
if (component === TRANSITION) {
return () => {
if (!node.children.length) {
return;
}
if (hasMultipleChildren(node)) {
context.onError(
createDOMCompilerError(
62,
{
start: node.children[0].loc.start,
end: node.children[node.children.length - 1].loc.end,
source: ""
}
)
);
}
const child = node.children[0];
if (child.type === 1) {
for (const p of child.props) {
if (p.type === 7 && p.name === "show") {
node.props.push({
type: 6,
name: "persisted",
nameLoc: node.loc,
value: void 0,
loc: node.loc
});
}
}
}
};
}
}
};
function hasMultipleChildren(node) {
const children = node.children = node.children.filter(
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
);
const child = children[0];
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
}
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
const stringifyStatic = (children, context, parent) => {
if (context.scopes.vSlot > 0) {
return;
}
const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !shared.isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
let nc = 0;
let ec = 0;
const currentChunk = [];
const stringifyCurrentChunk = (currentIndex) => {
if (nc >= 20 || ec >= 5) {
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
JSON.stringify(
currentChunk.map((node) => stringifyNode(node, context)).join("")
).replace(expReplaceRE, `" + $1 + "`),
// the 2nd argument indicates the number of DOM nodes this static vnode
// will insert / hydrate
String(currentChunk.length)
]);
const deleteCount = currentChunk.length - 1;
if (isParentCached) {
children.splice(
currentIndex - currentChunk.length,
currentChunk.length,
// @ts-expect-error
staticCall
);
} else {
currentChunk[0].codegenNode.value = staticCall;
if (currentChunk.length > 1) {
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
const cacheIndex = context.cached.indexOf(
currentChunk[currentChunk.length - 1].codegenNode
);
if (cacheIndex > -1) {
for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
const c = context.cached[i2];
if (c) c.index -= deleteCount;
}
context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
}
}
}
return deleteCount;
}
return 0;
};
let i = 0;
for (; i < children.length; i++) {
const child = children[i];
const isCached = isParentCached || getCachedNode(child);
if (isCached) {
const result = analyzeNode(child);
if (result) {
nc += result[0];
ec += result[1];
currentChunk.push(child);
continue;
}
}
i -= stringifyCurrentChunk(i);
nc = 0;
ec = 0;
currentChunk.length = 0;
}
stringifyCurrentChunk(i);
};
const getCachedNode = (node) => {
if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
return node.codegenNode;
}
};
const dataAriaRE = /^(data|aria)-/;
const isStringifiableAttr = (name, ns) => {
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
};
const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
);
function analyzeNode(node) {
if (node.type === 1 && isNonStringifiable(node.tag)) {
return false;
}
if (node.type === 12) {
return [1, 0];
}
let nc = 1;
let ec = node.props.length > 0 ? 1 : 0;
let bailed = false;
const bail = () => {
bailed = true;
return false;
};
function walk(node2) {
const isOptionTag = node2.tag === "option" && node2.ns === 0;
for (let i = 0; i < node2.props.length; i++) {
const p = node2.props[i];
if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
return bail();
}
if (p.type === 7 && p.name === "bind") {
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
return bail();
}
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
return bail();
}
if (isOptionTag && compilerCore.isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
return bail();
}
}
}
for (let i = 0; i < node2.children.length; i++) {
nc++;
const child = node2.children[i];
if (child.type === 1) {
if (child.props.length > 0) {
ec++;
}
walk(child);
if (bailed) {
return false;
}
}
}
return true;
}
return walk(node) ? [nc, ec] : false;
}
function stringifyNode(node, context) {
if (shared.isString(node)) {
return node;
}
if (shared.isSymbol(node)) {
return ``;
}
switch (node.type) {
case 1:
return stringifyElement(node, context);
case 2:
return shared.escapeHtml(node.content);
case 3:
return `<!--${shared.escapeHtml(node.content)}-->`;
case 5:
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
case 8:
return shared.escapeHtml(evaluateConstant(node));
case 12:
return stringifyNode(node.content, context);
default:
return "";
}
}
function stringifyElement(node, context) {
let res = `<${node.tag}`;
let innerHTML = "";
for (let i = 0; i < node.props.length; i++) {
const p = node.props[i];
if (p.type === 6) {
res += ` ${p.name}`;
if (p.value) {
res += `="${shared.escapeHtml(p.value.content)}"`;
}
} else if (p.type === 7) {
if (p.name === "bind") {
const exp = p.exp;
if (exp.content[0] === "_") {
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
continue;
}
if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
continue;
}
let evaluated = evaluateConstant(exp);
if (evaluated != null) {
const arg = p.arg && p.arg.content;
if (arg === "class") {
evaluated = shared.normalizeClass(evaluated);
} else if (arg === "style") {
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
}
res += ` ${p.arg.content}="${shared.escapeHtml(
evaluated
)}"`;
}
} else if (p.name === "html") {
innerHTML = evaluateConstant(p.exp);
} else if (p.name === "text") {
innerHTML = shared.escapeHtml(
shared.toDisplayString(evaluateConstant(p.exp))
);
}
}
}
if (context.scopeId) {
res += ` ${context.scopeId}`;
}
res += `>`;
if (innerHTML) {
res += innerHTML;
} else {
for (let i = 0; i < node.children.length; i++) {
res += stringifyNode(node.children[i], context);
}
}
if (!shared.isVoidTag(node.tag)) {
res += `</${node.tag}>`;
}
return res;
}
function evaluateConstant(exp) {
if (exp.type === 4) {
return new Function(`return (${exp.content})`)();
} else {
let res = ``;
exp.children.forEach((c) => {
if (shared.isString(c) || shared.isSymbol(c)) {
return;
}
if (c.type === 2) {
res += c.content;
} else if (c.type === 5) {
res += shared.toDisplayString(evaluateConstant(c.content));
} else {
res += evaluateConstant(c);
}
});
return res;
}
}
const ignoreSideEffectTags = (node, context) => {
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
context.onError(
createDOMCompilerError(
63,
node.loc
)
);
context.removeNode();
}
};
function isValidHTMLNesting(parent, child) {
if (parent in onlyValidChildren) {
return onlyValidChildren[parent].has(child);
}
if (child in onlyValidParents) {
return onlyValidParents[child].has(parent);
}
if (parent in knownInvalidChildren) {
if (knownInvalidChildren[parent].has(child)) return false;
}
if (child in knownInvalidParents) {
if (knownInvalidParents[child].has(parent)) return false;
}
return true;
}
const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
const emptySet = /* @__PURE__ */ new Set([]);
const onlyValidChildren = {
head: /* @__PURE__ */ new Set([
"base",
"basefront",
"bgsound",
"link",
"meta",
"title",
"noscript",
"noframes",
"style",
"script",
"template"
]),
optgroup: /* @__PURE__ */ new Set(["option"]),
select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
// table
table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
tr: /* @__PURE__ */ new Set(["td", "th"]),
colgroup: /* @__PURE__ */ new Set(["col"]),
tbody: /* @__PURE__ */ new Set(["tr"]),
thead: /* @__PURE__ */ new Set(["tr"]),
tfoot: /* @__PURE__ */ new Set(["tr"]),
// these elements can not have any children elements
script: emptySet,
iframe: emptySet,
option: emptySet,
textarea: emptySet,
style: emptySet,
title: emptySet
};
const onlyValidParents = {
// sections
html: emptySet,
body: /* @__PURE__ */ new Set(["html"]),
head: /* @__PURE__ */ new Set(["html"]),
// table
td: /* @__PURE__ */ new Set(["tr"]),
colgroup: /* @__PURE__ */ new Set(["table"]),
caption: /* @__PURE__ */ new Set(["table"]),
tbody: /* @__PURE__ */ new Set(["table"]),
tfoot: /* @__PURE__ */ new Set(["table"]),
col: /* @__PURE__ */ new Set(["colgroup"]),
th: /* @__PURE__ */ new Set(["tr"]),
thead: /* @__PURE__ */ new Set(["table"]),
tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
// data list
dd: /* @__PURE__ */ new Set(["dl", "div"]),
dt: /* @__PURE__ */ new Set(["dl", "div"]),
// other
figcaption: /* @__PURE__ */ new Set(["figure"]),
// li: new Set(["ul", "ol"]),
summary: /* @__PURE__ */ new Set(["details"]),
area: /* @__PURE__ */ new Set(["map"])
};
const knownInvalidChildren = {
p: /* @__PURE__ */ new Set([
"address",
"article",
"aside",
"blockquote",
"center",
"details",
"dialog",
"dir",
"div",
"dl",
"fieldset",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hgroup",
"hr",
"li",
"main",
"nav",
"menu",
"ol",
"p",
"pre",
"section",
"table",
"ul"
]),
svg: /* @__PURE__ */ new Set([
"b",
"blockquote",
"br",
"code",
"dd",
"div",
"dl",
"dt",
"em",
"embed",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"hr",
"i",
"img",
"li",
"menu",
"meta",
"ol",
"p",
"pre",
"ruby",
"s",
"small",
"span",
"strong",
"sub",
"sup",
"table",
"u",
"ul",
"var"
])
};
const knownInvalidParents = {
a: /* @__PURE__ */ new Set(["a"]),
button: /* @__PURE__ */ new Set(["button"]),
dd: /* @__PURE__ */ new Set(["dd", "dt"]),
dt: /* @__PURE__ */ new Set(["dd", "dt"]),
form: /* @__PURE__ */ new Set(["form"]),
li: /* @__PURE__ */ new Set(["li"]),
h1: headings,
h2: headings,
h3: headings,
h4: headings,
h5: headings,
h6: headings
};
const validateHtmlNesting = (node, context) => {
if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
const error = new SyntaxError(
`<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
);
error.loc = node.loc;
context.onWarn(error);
}
};
const DOMNodeTransforms = [
transformStyle,
...[transformTransition, validateHtmlNesting]
];
const DOMDirectiveTransforms = {
cloak: compilerCore.noopDirectiveTransform,
html: transformVHtml,
text: transformVText,
model: transformModel,
// override compiler-core
on: transformOn,
// override compiler-core
show: transformShow
};
function compile(src, options = {}) {
return compilerCore.baseCompile(
src,
shared.extend({}, parserOptions, options, {
nodeTransforms: [
// ignore <script> and <tag>
// this is not put inside DOMNodeTransforms because that list is used
// by compiler-ssr to generate vnode fallback branches
ignoreSideEffectTags,
...DOMNodeTransforms,
...options.nodeTransforms || []
],
directiveTransforms: shared.extend(
{},
DOMDirectiveTransforms,
options.directiveTransforms || {}
),
transformHoist: stringifyStatic
})
);
}
function parse(template, options = {}) {
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
}
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
exports.DOMErrorCodes = DOMErrorCodes;
exports.DOMErrorMessages = DOMErrorMessages;
exports.DOMNodeTransforms = DOMNodeTransforms;
exports.TRANSITION = TRANSITION;
exports.TRANSITION_GROUP = TRANSITION_GROUP;
exports.V_MODEL_CHECKBOX = V_MODEL_CHECKBOX;
exports.V_MODEL_DYNAMIC = V_MODEL_DYNAMIC;
exports.V_MODEL_RADIO = V_MODEL_RADIO;
exports.V_MODEL_SELECT = V_MODEL_SELECT;
exports.V_MODEL_TEXT = V_MODEL_TEXT;
exports.V_ON_WITH_KEYS = V_ON_WITH_KEYS;
exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
exports.V_SHOW = V_SHOW;
exports.compile = compile;
exports.createDOMCompilerError = createDOMCompilerError;
exports.parse = parse;
exports.parserOptions = parserOptions;
exports.transformStyle = transformStyle;
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
});

View File

@@ -0,0 +1,686 @@
/**
* @vue/compiler-dom v3.5.13
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var compilerCore = require('@vue/compiler-core');
var shared = require('@vue/shared');
const V_MODEL_RADIO = Symbol(``);
const V_MODEL_CHECKBOX = Symbol(
``
);
const V_MODEL_TEXT = Symbol(``);
const V_MODEL_SELECT = Symbol(
``
);
const V_MODEL_DYNAMIC = Symbol(
``
);
const V_ON_WITH_MODIFIERS = Symbol(
``
);
const V_ON_WITH_KEYS = Symbol(
``
);
const V_SHOW = Symbol(``);
const TRANSITION = Symbol(``);
const TRANSITION_GROUP = Symbol(
``
);
compilerCore.registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
[V_MODEL_TEXT]: `vModelText`,
[V_MODEL_SELECT]: `vModelSelect`,
[V_MODEL_DYNAMIC]: `vModelDynamic`,
[V_ON_WITH_MODIFIERS]: `withModifiers`,
[V_ON_WITH_KEYS]: `withKeys`,
[V_SHOW]: `vShow`,
[TRANSITION]: `Transition`,
[TRANSITION_GROUP]: `TransitionGroup`
});
const parserOptions = {
parseMode: "html",
isVoidTag: shared.isVoidTag,
isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
isPreTag: (tag) => tag === "pre",
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
decodeEntities: void 0,
isBuiltInComponent: (tag) => {
if (tag === "Transition" || tag === "transition") {
return TRANSITION;
} else if (tag === "TransitionGroup" || tag === "transition-group") {
return TRANSITION_GROUP;
}
},
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
getNamespace(tag, parent, rootNamespace) {
let ns = parent ? parent.ns : rootNamespace;
if (parent && ns === 2) {
if (parent.tag === "annotation-xml") {
if (tag === "svg") {
return 1;
}
if (parent.props.some(
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
)) {
ns = 0;
}
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
ns = 0;
}
} else if (parent && ns === 1) {
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
ns = 0;
}
}
if (ns === 0) {
if (tag === "svg") {
return 1;
}
if (tag === "math") {
return 2;
}
}
return ns;
}
};
const transformStyle = (node) => {
if (node.type === 1) {
node.props.forEach((p, i) => {
if (p.type === 6 && p.name === "style" && p.value) {
node.props[i] = {
type: 7,
name: `bind`,
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
exp: parseInlineCSS(p.value.content, p.loc),
modifiers: [],
loc: p.loc
};
}
});
}
};
const parseInlineCSS = (cssText, loc) => {
const normalized = shared.parseStringStyle(cssText);
return compilerCore.createSimpleExpression(
JSON.stringify(normalized),
false,
loc,
3
);
};
function createDOMCompilerError(code, loc) {
return compilerCore.createCompilerError(
code,
loc,
DOMErrorMessages
);
}
const DOMErrorCodes = {
"X_V_HTML_NO_EXPRESSION": 53,
"53": "X_V_HTML_NO_EXPRESSION",
"X_V_HTML_WITH_CHILDREN": 54,
"54": "X_V_HTML_WITH_CHILDREN",
"X_V_TEXT_NO_EXPRESSION": 55,
"55": "X_V_TEXT_NO_EXPRESSION",
"X_V_TEXT_WITH_CHILDREN": 56,
"56": "X_V_TEXT_WITH_CHILDREN",
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
"X_V_MODEL_ARG_ON_ELEMENT": 58,
"58": "X_V_MODEL_ARG_ON_ELEMENT",
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
"X_V_MODEL_UNNECESSARY_VALUE": 60,
"60": "X_V_MODEL_UNNECESSARY_VALUE",
"X_V_SHOW_NO_EXPRESSION": 61,
"61": "X_V_SHOW_NO_EXPRESSION",
"X_TRANSITION_INVALID_CHILDREN": 62,
"62": "X_TRANSITION_INVALID_CHILDREN",
"X_IGNORED_SIDE_EFFECT_TAG": 63,
"63": "X_IGNORED_SIDE_EFFECT_TAG",
"__EXTEND_POINT__": 64,
"64": "__EXTEND_POINT__"
};
const DOMErrorMessages = {
[53]: `v-html is missing expression.`,
[54]: `v-html will override element children.`,
[55]: `v-text is missing expression.`,
[56]: `v-text will override element children.`,
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
[58]: `v-model argument is not supported on plain elements.`,
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
[61]: `v-show is missing expression.`,
[62]: `<Transition> expects exactly one child element or component.`,
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
};
const transformVHtml = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(53, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(54, loc)
);
node.children.length = 0;
}
return {
props: [
compilerCore.createObjectProperty(
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
exp || compilerCore.createSimpleExpression("", true)
)
]
};
};
const transformVText = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(55, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(56, loc)
);
node.children.length = 0;
}
return {
props: [
compilerCore.createObjectProperty(
compilerCore.createSimpleExpression(`textContent`, true),
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
context.helperString(compilerCore.TO_DISPLAY_STRING),
[exp],
loc
) : compilerCore.createSimpleExpression("", true)
)
]
};
};
const transformModel = (dir, node, context) => {
const baseResult = compilerCore.transformModel(dir, node, context);
if (!baseResult.props.length || node.tagType === 1) {
return baseResult;
}
if (dir.arg) {
context.onError(
createDOMCompilerError(
58,
dir.arg.loc
)
);
}
const { tag } = node;
const isCustomElement = context.isCustomElement(tag);
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
let directiveToUse = V_MODEL_TEXT;
let isInvalidType = false;
if (tag === "input" || isCustomElement) {
const type = compilerCore.findProp(node, `type`);
if (type) {
if (type.type === 7) {
directiveToUse = V_MODEL_DYNAMIC;
} else if (type.value) {
switch (type.value.content) {
case "radio":
directiveToUse = V_MODEL_RADIO;
break;
case "checkbox":
directiveToUse = V_MODEL_CHECKBOX;
break;
case "file":
isInvalidType = true;
context.onError(
createDOMCompilerError(
59,
dir.loc
)
);
break;
}
}
} else if (compilerCore.hasDynamicKeyVBind(node)) {
directiveToUse = V_MODEL_DYNAMIC;
} else ;
} else if (tag === "select") {
directiveToUse = V_MODEL_SELECT;
} else ;
if (!isInvalidType) {
baseResult.needRuntime = context.helper(directiveToUse);
}
} else {
context.onError(
createDOMCompilerError(
57,
dir.loc
)
);
}
baseResult.props = baseResult.props.filter(
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
);
return baseResult;
};
const isEventOptionModifier = /* @__PURE__ */ shared.makeMap(`passive,once,capture`);
const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
// event propagation management
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
);
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
const resolveModifiers = (key, modifiers, context, loc) => {
const keyModifiers = [];
const nonKeyModifiers = [];
const eventOptionModifiers = [];
for (let i = 0; i < modifiers.length; i++) {
const modifier = modifiers[i].content;
if (modifier === "native" && compilerCore.checkCompatEnabled(
"COMPILER_V_ON_NATIVE",
context,
loc
)) {
eventOptionModifiers.push(modifier);
} else if (isEventOptionModifier(modifier)) {
eventOptionModifiers.push(modifier);
} else {
if (maybeKeyModifier(modifier)) {
if (compilerCore.isStaticExp(key)) {
if (isKeyboardEvent(key.content.toLowerCase())) {
keyModifiers.push(modifier);
} else {
nonKeyModifiers.push(modifier);
}
} else {
keyModifiers.push(modifier);
nonKeyModifiers.push(modifier);
}
} else {
if (isNonKeyModifier(modifier)) {
nonKeyModifiers.push(modifier);
} else {
keyModifiers.push(modifier);
}
}
}
}
return {
keyModifiers,
nonKeyModifiers,
eventOptionModifiers
};
};
const transformClick = (key, event) => {
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === "onclick";
return isStaticClick ? compilerCore.createSimpleExpression(event, true) : key.type !== 4 ? compilerCore.createCompoundExpression([
`(`,
key,
`) === "onClick" ? "${event}" : (`,
key,
`)`
]) : key;
};
const transformOn = (dir, node, context) => {
return compilerCore.transformOn(dir, node, context, (baseResult) => {
const { modifiers } = dir;
if (!modifiers.length) return baseResult;
let { key, value: handlerExp } = baseResult.props[0];
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
if (nonKeyModifiers.includes("right")) {
key = transformClick(key, `onContextmenu`);
}
if (nonKeyModifiers.includes("middle")) {
key = transformClick(key, `onMouseup`);
}
if (nonKeyModifiers.length) {
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
handlerExp,
JSON.stringify(nonKeyModifiers)
]);
}
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
(!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
handlerExp,
JSON.stringify(keyModifiers)
]);
}
if (eventOptionModifiers.length) {
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
}
return {
props: [compilerCore.createObjectProperty(key, handlerExp)]
};
});
};
const transformShow = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(61, loc)
);
}
return {
props: [],
needRuntime: context.helper(V_SHOW)
};
};
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
const stringifyStatic = (children, context, parent) => {
if (context.scopes.vSlot > 0) {
return;
}
const isParentCached = parent.type === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !shared.isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 20;
let nc = 0;
let ec = 0;
const currentChunk = [];
const stringifyCurrentChunk = (currentIndex) => {
if (nc >= 20 || ec >= 5) {
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
JSON.stringify(
currentChunk.map((node) => stringifyNode(node, context)).join("")
).replace(expReplaceRE, `" + $1 + "`),
// the 2nd argument indicates the number of DOM nodes this static vnode
// will insert / hydrate
String(currentChunk.length)
]);
const deleteCount = currentChunk.length - 1;
if (isParentCached) {
children.splice(
currentIndex - currentChunk.length,
currentChunk.length,
// @ts-expect-error
staticCall
);
} else {
currentChunk[0].codegenNode.value = staticCall;
if (currentChunk.length > 1) {
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
const cacheIndex = context.cached.indexOf(
currentChunk[currentChunk.length - 1].codegenNode
);
if (cacheIndex > -1) {
for (let i2 = cacheIndex; i2 < context.cached.length; i2++) {
const c = context.cached[i2];
if (c) c.index -= deleteCount;
}
context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
}
}
}
return deleteCount;
}
return 0;
};
let i = 0;
for (; i < children.length; i++) {
const child = children[i];
const isCached = isParentCached || getCachedNode(child);
if (isCached) {
const result = analyzeNode(child);
if (result) {
nc += result[0];
ec += result[1];
currentChunk.push(child);
continue;
}
}
i -= stringifyCurrentChunk(i);
nc = 0;
ec = 0;
currentChunk.length = 0;
}
stringifyCurrentChunk(i);
};
const getCachedNode = (node) => {
if ((node.type === 1 && node.tagType === 0 || node.type === 12) && node.codegenNode && node.codegenNode.type === 20) {
return node.codegenNode;
}
};
const dataAriaRE = /^(data|aria)-/;
const isStringifiableAttr = (name, ns) => {
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
};
const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
);
function analyzeNode(node) {
if (node.type === 1 && isNonStringifiable(node.tag)) {
return false;
}
if (node.type === 12) {
return [1, 0];
}
let nc = 1;
let ec = node.props.length > 0 ? 1 : 0;
let bailed = false;
const bail = () => {
bailed = true;
return false;
};
function walk(node2) {
const isOptionTag = node2.tag === "option" && node2.ns === 0;
for (let i = 0; i < node2.props.length; i++) {
const p = node2.props[i];
if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
return bail();
}
if (p.type === 7 && p.name === "bind") {
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
return bail();
}
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
return bail();
}
if (isOptionTag && compilerCore.isStaticArgOf(p.arg, "value") && p.exp && !p.exp.isStatic) {
return bail();
}
}
}
for (let i = 0; i < node2.children.length; i++) {
nc++;
const child = node2.children[i];
if (child.type === 1) {
if (child.props.length > 0) {
ec++;
}
walk(child);
if (bailed) {
return false;
}
}
}
return true;
}
return walk(node) ? [nc, ec] : false;
}
function stringifyNode(node, context) {
if (shared.isString(node)) {
return node;
}
if (shared.isSymbol(node)) {
return ``;
}
switch (node.type) {
case 1:
return stringifyElement(node, context);
case 2:
return shared.escapeHtml(node.content);
case 3:
return `<!--${shared.escapeHtml(node.content)}-->`;
case 5:
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
case 8:
return shared.escapeHtml(evaluateConstant(node));
case 12:
return stringifyNode(node.content, context);
default:
return "";
}
}
function stringifyElement(node, context) {
let res = `<${node.tag}`;
let innerHTML = "";
for (let i = 0; i < node.props.length; i++) {
const p = node.props[i];
if (p.type === 6) {
res += ` ${p.name}`;
if (p.value) {
res += `="${shared.escapeHtml(p.value.content)}"`;
}
} else if (p.type === 7) {
if (p.name === "bind") {
const exp = p.exp;
if (exp.content[0] === "_") {
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
continue;
}
if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
continue;
}
let evaluated = evaluateConstant(exp);
if (evaluated != null) {
const arg = p.arg && p.arg.content;
if (arg === "class") {
evaluated = shared.normalizeClass(evaluated);
} else if (arg === "style") {
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
}
res += ` ${p.arg.content}="${shared.escapeHtml(
evaluated
)}"`;
}
} else if (p.name === "html") {
innerHTML = evaluateConstant(p.exp);
} else if (p.name === "text") {
innerHTML = shared.escapeHtml(
shared.toDisplayString(evaluateConstant(p.exp))
);
}
}
}
if (context.scopeId) {
res += ` ${context.scopeId}`;
}
res += `>`;
if (innerHTML) {
res += innerHTML;
} else {
for (let i = 0; i < node.children.length; i++) {
res += stringifyNode(node.children[i], context);
}
}
if (!shared.isVoidTag(node.tag)) {
res += `</${node.tag}>`;
}
return res;
}
function evaluateConstant(exp) {
if (exp.type === 4) {
return new Function(`return (${exp.content})`)();
} else {
let res = ``;
exp.children.forEach((c) => {
if (shared.isString(c) || shared.isSymbol(c)) {
return;
}
if (c.type === 2) {
res += c.content;
} else if (c.type === 5) {
res += shared.toDisplayString(evaluateConstant(c.content));
} else {
res += evaluateConstant(c);
}
});
return res;
}
}
const ignoreSideEffectTags = (node, context) => {
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
context.removeNode();
}
};
const DOMNodeTransforms = [
transformStyle,
...[]
];
const DOMDirectiveTransforms = {
cloak: compilerCore.noopDirectiveTransform,
html: transformVHtml,
text: transformVText,
model: transformModel,
// override compiler-core
on: transformOn,
// override compiler-core
show: transformShow
};
function compile(src, options = {}) {
return compilerCore.baseCompile(
src,
shared.extend({}, parserOptions, options, {
nodeTransforms: [
// ignore <script> and <tag>
// this is not put inside DOMNodeTransforms because that list is used
// by compiler-ssr to generate vnode fallback branches
ignoreSideEffectTags,
...DOMNodeTransforms,
...options.nodeTransforms || []
],
directiveTransforms: shared.extend(
{},
DOMDirectiveTransforms,
options.directiveTransforms || {}
),
transformHoist: stringifyStatic
})
);
}
function parse(template, options = {}) {
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
}
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
exports.DOMErrorCodes = DOMErrorCodes;
exports.DOMErrorMessages = DOMErrorMessages;
exports.DOMNodeTransforms = DOMNodeTransforms;
exports.TRANSITION = TRANSITION;
exports.TRANSITION_GROUP = TRANSITION_GROUP;
exports.V_MODEL_CHECKBOX = V_MODEL_CHECKBOX;
exports.V_MODEL_DYNAMIC = V_MODEL_DYNAMIC;
exports.V_MODEL_RADIO = V_MODEL_RADIO;
exports.V_MODEL_SELECT = V_MODEL_SELECT;
exports.V_MODEL_TEXT = V_MODEL_TEXT;
exports.V_ON_WITH_KEYS = V_ON_WITH_KEYS;
exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
exports.V_SHOW = V_SHOW;
exports.compile = compile;
exports.createDOMCompilerError = createDOMCompilerError;
exports.parse = parse;
exports.parserOptions = parserOptions;
exports.transformStyle = transformStyle;
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
});

45
node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts generated vendored Normal file
View File

@@ -0,0 +1,45 @@
import { ParserOptions, NodeTransform, SourceLocation, CompilerError, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
export * from '@vue/compiler-core';
export declare const parserOptions: ParserOptions;
export declare const V_MODEL_RADIO: unique symbol;
export declare const V_MODEL_CHECKBOX: unique symbol;
export declare const V_MODEL_TEXT: unique symbol;
export declare const V_MODEL_SELECT: unique symbol;
export declare const V_MODEL_DYNAMIC: unique symbol;
export declare const V_ON_WITH_MODIFIERS: unique symbol;
export declare const V_ON_WITH_KEYS: unique symbol;
export declare const V_SHOW: unique symbol;
export declare const TRANSITION: unique symbol;
export declare const TRANSITION_GROUP: unique symbol;
export declare const transformStyle: NodeTransform;
interface DOMCompilerError extends CompilerError {
code: DOMErrorCodes;
}
export declare function createDOMCompilerError(code: DOMErrorCodes, loc?: SourceLocation): DOMCompilerError;
export declare enum DOMErrorCodes {
X_V_HTML_NO_EXPRESSION = 53,
X_V_HTML_WITH_CHILDREN = 54,
X_V_TEXT_NO_EXPRESSION = 55,
X_V_TEXT_WITH_CHILDREN = 56,
X_V_MODEL_ON_INVALID_ELEMENT = 57,
X_V_MODEL_ARG_ON_ELEMENT = 58,
X_V_MODEL_ON_FILE_INPUT_ELEMENT = 59,
X_V_MODEL_UNNECESSARY_VALUE = 60,
X_V_SHOW_NO_EXPRESSION = 61,
X_TRANSITION_INVALID_CHILDREN = 62,
X_IGNORED_SIDE_EFFECT_TAG = 63,
__EXTEND_POINT__ = 64
}
export declare const DOMErrorMessages: {
[code: number]: string;
};
export declare const DOMNodeTransforms: NodeTransform[];
export declare const DOMDirectiveTransforms: Record<string, DirectiveTransform>;
export declare function compile(src: string | RootNode, options?: CompilerOptions): CodegenResult;
export declare function parse(template: string, options?: ParserOptions): RootNode;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,687 @@
/**
* @vue/compiler-dom v3.5.13
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
import { registerRuntimeHelpers, createSimpleExpression, createCompilerError, createObjectProperty, getConstantType, createCallExpression, TO_DISPLAY_STRING, transformModel as transformModel$1, findProp, hasDynamicKeyVBind, findDir, isStaticArgOf, transformOn as transformOn$1, isStaticExp, createCompoundExpression, checkCompatEnabled, noopDirectiveTransform, baseCompile, baseParse } from '@vue/compiler-core';
export * from '@vue/compiler-core';
import { isVoidTag, isHTMLTag, isSVGTag, isMathMLTag, parseStringStyle, capitalize, makeMap, extend } from '@vue/shared';
const V_MODEL_RADIO = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelRadio` : ``);
const V_MODEL_CHECKBOX = Symbol(
!!(process.env.NODE_ENV !== "production") ? `vModelCheckbox` : ``
);
const V_MODEL_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelText` : ``);
const V_MODEL_SELECT = Symbol(
!!(process.env.NODE_ENV !== "production") ? `vModelSelect` : ``
);
const V_MODEL_DYNAMIC = Symbol(
!!(process.env.NODE_ENV !== "production") ? `vModelDynamic` : ``
);
const V_ON_WITH_MODIFIERS = Symbol(
!!(process.env.NODE_ENV !== "production") ? `vOnModifiersGuard` : ``
);
const V_ON_WITH_KEYS = Symbol(
!!(process.env.NODE_ENV !== "production") ? `vOnKeysGuard` : ``
);
const V_SHOW = Symbol(!!(process.env.NODE_ENV !== "production") ? `vShow` : ``);
const TRANSITION = Symbol(!!(process.env.NODE_ENV !== "production") ? `Transition` : ``);
const TRANSITION_GROUP = Symbol(
!!(process.env.NODE_ENV !== "production") ? `TransitionGroup` : ``
);
registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
[V_MODEL_TEXT]: `vModelText`,
[V_MODEL_SELECT]: `vModelSelect`,
[V_MODEL_DYNAMIC]: `vModelDynamic`,
[V_ON_WITH_MODIFIERS]: `withModifiers`,
[V_ON_WITH_KEYS]: `withKeys`,
[V_SHOW]: `vShow`,
[TRANSITION]: `Transition`,
[TRANSITION_GROUP]: `TransitionGroup`
});
let decoder;
function decodeHtmlBrowser(raw, asAttr = false) {
if (!decoder) {
decoder = document.createElement("div");
}
if (asAttr) {
decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
return decoder.children[0].getAttribute("foo");
} else {
decoder.innerHTML = raw;
return decoder.textContent;
}
}
const parserOptions = {
parseMode: "html",
isVoidTag,
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
isPreTag: (tag) => tag === "pre",
isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
decodeEntities: decodeHtmlBrowser ,
isBuiltInComponent: (tag) => {
if (tag === "Transition" || tag === "transition") {
return TRANSITION;
} else if (tag === "TransitionGroup" || tag === "transition-group") {
return TRANSITION_GROUP;
}
},
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
getNamespace(tag, parent, rootNamespace) {
let ns = parent ? parent.ns : rootNamespace;
if (parent && ns === 2) {
if (parent.tag === "annotation-xml") {
if (tag === "svg") {
return 1;
}
if (parent.props.some(
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
)) {
ns = 0;
}
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
ns = 0;
}
} else if (parent && ns === 1) {
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
ns = 0;
}
}
if (ns === 0) {
if (tag === "svg") {
return 1;
}
if (tag === "math") {
return 2;
}
}
return ns;
}
};
const transformStyle = (node) => {
if (node.type === 1) {
node.props.forEach((p, i) => {
if (p.type === 6 && p.name === "style" && p.value) {
node.props[i] = {
type: 7,
name: `bind`,
arg: createSimpleExpression(`style`, true, p.loc),
exp: parseInlineCSS(p.value.content, p.loc),
modifiers: [],
loc: p.loc
};
}
});
}
};
const parseInlineCSS = (cssText, loc) => {
const normalized = parseStringStyle(cssText);
return createSimpleExpression(
JSON.stringify(normalized),
false,
loc,
3
);
};
function createDOMCompilerError(code, loc) {
return createCompilerError(
code,
loc,
!!(process.env.NODE_ENV !== "production") || false ? DOMErrorMessages : void 0
);
}
const DOMErrorCodes = {
"X_V_HTML_NO_EXPRESSION": 53,
"53": "X_V_HTML_NO_EXPRESSION",
"X_V_HTML_WITH_CHILDREN": 54,
"54": "X_V_HTML_WITH_CHILDREN",
"X_V_TEXT_NO_EXPRESSION": 55,
"55": "X_V_TEXT_NO_EXPRESSION",
"X_V_TEXT_WITH_CHILDREN": 56,
"56": "X_V_TEXT_WITH_CHILDREN",
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
"X_V_MODEL_ARG_ON_ELEMENT": 58,
"58": "X_V_MODEL_ARG_ON_ELEMENT",
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
"X_V_MODEL_UNNECESSARY_VALUE": 60,
"60": "X_V_MODEL_UNNECESSARY_VALUE",
"X_V_SHOW_NO_EXPRESSION": 61,
"61": "X_V_SHOW_NO_EXPRESSION",
"X_TRANSITION_INVALID_CHILDREN": 62,
"62": "X_TRANSITION_INVALID_CHILDREN",
"X_IGNORED_SIDE_EFFECT_TAG": 63,
"63": "X_IGNORED_SIDE_EFFECT_TAG",
"__EXTEND_POINT__": 64,
"64": "__EXTEND_POINT__"
};
const DOMErrorMessages = {
[53]: `v-html is missing expression.`,
[54]: `v-html will override element children.`,
[55]: `v-text is missing expression.`,
[56]: `v-text will override element children.`,
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
[58]: `v-model argument is not supported on plain elements.`,
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
[61]: `v-show is missing expression.`,
[62]: `<Transition> expects exactly one child element or component.`,
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
};
const transformVHtml = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(53, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(54, loc)
);
node.children.length = 0;
}
return {
props: [
createObjectProperty(
createSimpleExpression(`innerHTML`, true, loc),
exp || createSimpleExpression("", true)
)
]
};
};
const transformVText = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(55, loc)
);
}
if (node.children.length) {
context.onError(
createDOMCompilerError(56, loc)
);
node.children.length = 0;
}
return {
props: [
createObjectProperty(
createSimpleExpression(`textContent`, true),
exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
context.helperString(TO_DISPLAY_STRING),
[exp],
loc
) : createSimpleExpression("", true)
)
]
};
};
const transformModel = (dir, node, context) => {
const baseResult = transformModel$1(dir, node, context);
if (!baseResult.props.length || node.tagType === 1) {
return baseResult;
}
if (dir.arg) {
context.onError(
createDOMCompilerError(
58,
dir.arg.loc
)
);
}
function checkDuplicatedValue() {
const value = findDir(node, "bind");
if (value && isStaticArgOf(value.arg, "value")) {
context.onError(
createDOMCompilerError(
60,
value.loc
)
);
}
}
const { tag } = node;
const isCustomElement = context.isCustomElement(tag);
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
let directiveToUse = V_MODEL_TEXT;
let isInvalidType = false;
if (tag === "input" || isCustomElement) {
const type = findProp(node, `type`);
if (type) {
if (type.type === 7) {
directiveToUse = V_MODEL_DYNAMIC;
} else if (type.value) {
switch (type.value.content) {
case "radio":
directiveToUse = V_MODEL_RADIO;
break;
case "checkbox":
directiveToUse = V_MODEL_CHECKBOX;
break;
case "file":
isInvalidType = true;
context.onError(
createDOMCompilerError(
59,
dir.loc
)
);
break;
default:
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
break;
}
}
} else if (hasDynamicKeyVBind(node)) {
directiveToUse = V_MODEL_DYNAMIC;
} else {
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
}
} else if (tag === "select") {
directiveToUse = V_MODEL_SELECT;
} else {
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
}
if (!isInvalidType) {
baseResult.needRuntime = context.helper(directiveToUse);
}
} else {
context.onError(
createDOMCompilerError(
57,
dir.loc
)
);
}
baseResult.props = baseResult.props.filter(
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
);
return baseResult;
};
const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
const isNonKeyModifier = /* @__PURE__ */ makeMap(
// event propagation management
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
);
const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
const resolveModifiers = (key, modifiers, context, loc) => {
const keyModifiers = [];
const nonKeyModifiers = [];
const eventOptionModifiers = [];
for (let i = 0; i < modifiers.length; i++) {
const modifier = modifiers[i].content;
if (modifier === "native" && checkCompatEnabled(
"COMPILER_V_ON_NATIVE",
context,
loc
)) {
eventOptionModifiers.push(modifier);
} else if (isEventOptionModifier(modifier)) {
eventOptionModifiers.push(modifier);
} else {
if (maybeKeyModifier(modifier)) {
if (isStaticExp(key)) {
if (isKeyboardEvent(key.content.toLowerCase())) {
keyModifiers.push(modifier);
} else {
nonKeyModifiers.push(modifier);
}
} else {
keyModifiers.push(modifier);
nonKeyModifiers.push(modifier);
}
} else {
if (isNonKeyModifier(modifier)) {
nonKeyModifiers.push(modifier);
} else {
keyModifiers.push(modifier);
}
}
}
}
return {
keyModifiers,
nonKeyModifiers,
eventOptionModifiers
};
};
const transformClick = (key, event) => {
const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
`(`,
key,
`) === "onClick" ? "${event}" : (`,
key,
`)`
]) : key;
};
const transformOn = (dir, node, context) => {
return transformOn$1(dir, node, context, (baseResult) => {
const { modifiers } = dir;
if (!modifiers.length) return baseResult;
let { key, value: handlerExp } = baseResult.props[0];
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
if (nonKeyModifiers.includes("right")) {
key = transformClick(key, `onContextmenu`);
}
if (nonKeyModifiers.includes("middle")) {
key = transformClick(key, `onMouseup`);
}
if (nonKeyModifiers.length) {
handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
handlerExp,
JSON.stringify(nonKeyModifiers)
]);
}
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
(!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
handlerExp,
JSON.stringify(keyModifiers)
]);
}
if (eventOptionModifiers.length) {
const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
}
return {
props: [createObjectProperty(key, handlerExp)]
};
});
};
const transformShow = (dir, node, context) => {
const { exp, loc } = dir;
if (!exp) {
context.onError(
createDOMCompilerError(61, loc)
);
}
return {
props: [],
needRuntime: context.helper(V_SHOW)
};
};
const transformTransition = (node, context) => {
if (node.type === 1 && node.tagType === 1) {
const component = context.isBuiltInComponent(node.tag);
if (component === TRANSITION) {
return () => {
if (!node.children.length) {
return;
}
if (hasMultipleChildren(node)) {
context.onError(
createDOMCompilerError(
62,
{
start: node.children[0].loc.start,
end: node.children[node.children.length - 1].loc.end,
source: ""
}
)
);
}
const child = node.children[0];
if (child.type === 1) {
for (const p of child.props) {
if (p.type === 7 && p.name === "show") {
node.props.push({
type: 6,
name: "persisted",
nameLoc: node.loc,
value: void 0,
loc: node.loc
});
}
}
}
};
}
}
};
function hasMultipleChildren(node) {
const children = node.children = node.children.filter(
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
);
const child = children[0];
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
}
const ignoreSideEffectTags = (node, context) => {
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
!!(process.env.NODE_ENV !== "production") && context.onError(
createDOMCompilerError(
63,
node.loc
)
);
context.removeNode();
}
};
function isValidHTMLNesting(parent, child) {
if (parent in onlyValidChildren) {
return onlyValidChildren[parent].has(child);
}
if (child in onlyValidParents) {
return onlyValidParents[child].has(parent);
}
if (parent in knownInvalidChildren) {
if (knownInvalidChildren[parent].has(child)) return false;
}
if (child in knownInvalidParents) {
if (knownInvalidParents[child].has(parent)) return false;
}
return true;
}
const headings = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
const emptySet = /* @__PURE__ */ new Set([]);
const onlyValidChildren = {
head: /* @__PURE__ */ new Set([
"base",
"basefront",
"bgsound",
"link",
"meta",
"title",
"noscript",
"noframes",
"style",
"script",
"template"
]),
optgroup: /* @__PURE__ */ new Set(["option"]),
select: /* @__PURE__ */ new Set(["optgroup", "option", "hr"]),
// table
table: /* @__PURE__ */ new Set(["caption", "colgroup", "tbody", "tfoot", "thead"]),
tr: /* @__PURE__ */ new Set(["td", "th"]),
colgroup: /* @__PURE__ */ new Set(["col"]),
tbody: /* @__PURE__ */ new Set(["tr"]),
thead: /* @__PURE__ */ new Set(["tr"]),
tfoot: /* @__PURE__ */ new Set(["tr"]),
// these elements can not have any children elements
script: emptySet,
iframe: emptySet,
option: emptySet,
textarea: emptySet,
style: emptySet,
title: emptySet
};
const onlyValidParents = {
// sections
html: emptySet,
body: /* @__PURE__ */ new Set(["html"]),
head: /* @__PURE__ */ new Set(["html"]),
// table
td: /* @__PURE__ */ new Set(["tr"]),
colgroup: /* @__PURE__ */ new Set(["table"]),
caption: /* @__PURE__ */ new Set(["table"]),
tbody: /* @__PURE__ */ new Set(["table"]),
tfoot: /* @__PURE__ */ new Set(["table"]),
col: /* @__PURE__ */ new Set(["colgroup"]),
th: /* @__PURE__ */ new Set(["tr"]),
thead: /* @__PURE__ */ new Set(["table"]),
tr: /* @__PURE__ */ new Set(["tbody", "thead", "tfoot"]),
// data list
dd: /* @__PURE__ */ new Set(["dl", "div"]),
dt: /* @__PURE__ */ new Set(["dl", "div"]),
// other
figcaption: /* @__PURE__ */ new Set(["figure"]),
// li: new Set(["ul", "ol"]),
summary: /* @__PURE__ */ new Set(["details"]),
area: /* @__PURE__ */ new Set(["map"])
};
const knownInvalidChildren = {
p: /* @__PURE__ */ new Set([
"address",
"article",
"aside",
"blockquote",
"center",
"details",
"dialog",
"dir",
"div",
"dl",
"fieldset",
"figure",
"footer",
"form",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"header",
"hgroup",
"hr",
"li",
"main",
"nav",
"menu",
"ol",
"p",
"pre",
"section",
"table",
"ul"
]),
svg: /* @__PURE__ */ new Set([
"b",
"blockquote",
"br",
"code",
"dd",
"div",
"dl",
"dt",
"em",
"embed",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"hr",
"i",
"img",
"li",
"menu",
"meta",
"ol",
"p",
"pre",
"ruby",
"s",
"small",
"span",
"strong",
"sub",
"sup",
"table",
"u",
"ul",
"var"
])
};
const knownInvalidParents = {
a: /* @__PURE__ */ new Set(["a"]),
button: /* @__PURE__ */ new Set(["button"]),
dd: /* @__PURE__ */ new Set(["dd", "dt"]),
dt: /* @__PURE__ */ new Set(["dd", "dt"]),
form: /* @__PURE__ */ new Set(["form"]),
li: /* @__PURE__ */ new Set(["li"]),
h1: headings,
h2: headings,
h3: headings,
h4: headings,
h5: headings,
h6: headings
};
const validateHtmlNesting = (node, context) => {
if (node.type === 1 && node.tagType === 0 && context.parent && context.parent.type === 1 && context.parent.tagType === 0 && !isValidHTMLNesting(context.parent.tag, node.tag)) {
const error = new SyntaxError(
`<${node.tag}> cannot be child of <${context.parent.tag}>, according to HTML specifications. This can cause hydration errors or potentially disrupt future functionality.`
);
error.loc = node.loc;
context.onWarn(error);
}
};
const DOMNodeTransforms = [
transformStyle,
...!!(process.env.NODE_ENV !== "production") ? [transformTransition, validateHtmlNesting] : []
];
const DOMDirectiveTransforms = {
cloak: noopDirectiveTransform,
html: transformVHtml,
text: transformVText,
model: transformModel,
// override compiler-core
on: transformOn,
// override compiler-core
show: transformShow
};
function compile(src, options = {}) {
return baseCompile(
src,
extend({}, parserOptions, options, {
nodeTransforms: [
// ignore <script> and <tag>
// this is not put inside DOMNodeTransforms because that list is used
// by compiler-ssr to generate vnode fallback branches
ignoreSideEffectTags,
...DOMNodeTransforms,
...options.nodeTransforms || []
],
directiveTransforms: extend(
{},
DOMDirectiveTransforms,
options.directiveTransforms || {}
),
transformHoist: null
})
);
}
function parse(template, options = {}) {
return baseParse(template, extend({}, parserOptions, options));
}
export { DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, TRANSITION, TRANSITION_GROUP, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, compile, createDOMCompilerError, parse, parserOptions, transformStyle };

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

7
node_modules/@vue/compiler-dom/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/compiler-dom.cjs.prod.js')
} else {
module.exports = require('./dist/compiler-dom.cjs.js')
}

57
node_modules/@vue/compiler-dom/package.json generated vendored Normal file
View File

@@ -0,0 +1,57 @@
{
"name": "@vue/compiler-dom",
"version": "3.5.13",
"description": "@vue/compiler-dom",
"main": "index.js",
"module": "dist/compiler-dom.esm-bundler.js",
"types": "dist/compiler-dom.d.ts",
"unpkg": "dist/compiler-dom.global.js",
"jsdelivr": "dist/compiler-dom.global.js",
"files": [
"index.js",
"dist"
],
"exports": {
".": {
"types": "./dist/compiler-dom.d.ts",
"node": {
"production": "./dist/compiler-dom.cjs.prod.js",
"development": "./dist/compiler-dom.cjs.js",
"default": "./index.js"
},
"module": "./dist/compiler-dom.esm-bundler.js",
"import": "./dist/compiler-dom.esm-bundler.js",
"require": "./index.js"
},
"./*": "./*"
},
"sideEffects": false,
"buildOptions": {
"name": "VueCompilerDOM",
"compat": true,
"formats": [
"esm-bundler",
"esm-browser",
"cjs",
"global"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/core.git",
"directory": "packages/compiler-dom"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/core/issues"
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
"dependencies": {
"@vue/shared": "3.5.13",
"@vue/compiler-core": "3.5.13"
}
}

21
node_modules/@vue/compiler-sfc/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018-present, Yuxi (Evan) You
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.

80
node_modules/@vue/compiler-sfc/README.md generated vendored Normal file
View File

@@ -0,0 +1,80 @@
# @vue/compiler-sfc
> Lower level utilities for compiling Vue Single File Components
**Note: as of 3.2.13+, this package is included as a dependency of the main `vue` package and can be accessed as `vue/compiler-sfc`. This means you no longer need to explicitly install this package and ensure its version match that of `vue`'s. Just use the main `vue/compiler-sfc` deep import instead.**
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader) and [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
## API
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
- Separate hot-module replacement (HMR) for script, template and styles
- template updates should not reset component state
- style updates should be performed without component re-render
- Leveraging the tool's plugin system for pre-processor handling. e.g. `<style lang="scss">` should be processed by the corresponding webpack loader.
- In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with `thread-loader` or other parallelized configurations, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor.
The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
```
+--------------------+
| |
| script transform |
+----->+ |
| +--------------------+
|
+--------------------+ | +--------------------+
| | | | |
| facade transform +----------->+ template transform |
| | | | |
+--------------------+ | +--------------------+
|
| +--------------------+
+----->+ |
| style transform |
| |
+--------------------+
```
Where the facade module looks like this:
```js
// main script
import script from '/project/foo.vue?vue&type=script'
// template compiled to render function
import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx'
// css
import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx'
// attach render function to script
script.render = render
// attach additional metadata
// some of these should be dev only
script.__file = 'example.vue'
script.__scopeId = 'xxxxxx'
// additional tooling-specific HMR handling code
// using __VUE_HMR_API__ global
export default script
```
### High Level Workflow
1. In facade transform, parse the source into descriptor with the `parse` API and generate the above facade module code based on the descriptor;
2. In script transform, use `compileScript` to process the script. This handles features like `<script setup>` and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting `export default` to a temp variable (a `rewriteDefault` convenience API is provided for this purpose) so additional options can be attached to the exported object.
3. In template transform, use `compileTemplate` to compile the raw template into render function code.
4. In style transform, use `compileStyle` to compile raw CSS to handle `<style scoped>`, `<style module>` and CSS variable injection.
Options needed for these APIs can be passed via the query string.
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).

24970
node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

484
node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts generated vendored Normal file
View File

@@ -0,0 +1,484 @@
import * as _babel_types from '@babel/types';
import { Statement, Expression, TSType, Node, Program, CallExpression, ObjectPattern, TSModuleDeclaration, TSPropertySignature, TSMethodSignature, TSCallSignatureDeclaration, TSFunctionType } from '@babel/types';
import { RootNode, CompilerOptions, CodegenResult, ParserOptions, CompilerError, RawSourceMap, SourceLocation, BindingMetadata as BindingMetadata$1 } from '@vue/compiler-core';
export { BindingMetadata, CompilerError, CompilerOptions, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, walkIdentifiers } from '@vue/compiler-core';
import { ParserPlugin } from '@babel/parser';
export { parse as babelParse } from '@babel/parser';
import { Result, LazyResult } from 'postcss';
import MagicString from 'magic-string';
export { default as MagicString } from 'magic-string';
import TS from 'typescript';
export interface AssetURLTagConfig {
[name: string]: string[];
}
export interface AssetURLOptions {
/**
* If base is provided, instead of transforming relative asset urls into
* imports, they will be directly rewritten to absolute urls.
*/
base?: string | null;
/**
* If true, also processes absolute urls.
*/
includeAbsolute?: boolean;
tags?: AssetURLTagConfig;
}
export interface TemplateCompiler {
compile(source: string | RootNode, options: CompilerOptions): CodegenResult;
parse(template: string, options: ParserOptions): RootNode;
}
export interface SFCTemplateCompileResults {
code: string;
ast?: RootNode;
preamble?: string;
source: string;
tips: string[];
errors: (string | CompilerError)[];
map?: RawSourceMap;
}
export interface SFCTemplateCompileOptions {
source: string;
ast?: RootNode;
filename: string;
id: string;
scoped?: boolean;
slotted?: boolean;
isProd?: boolean;
ssr?: boolean;
ssrCssVars?: string[];
inMap?: RawSourceMap;
compiler?: TemplateCompiler;
compilerOptions?: CompilerOptions;
preprocessLang?: string;
preprocessOptions?: any;
/**
* In some cases, compiler-sfc may not be inside the project root (e.g. when
* linked or globally installed). In such cases a custom `require` can be
* passed to correctly resolve the preprocessors.
*/
preprocessCustomRequire?: (id: string) => any;
/**
* Configure what tags/attributes to transform into asset url imports,
* or disable the transform altogether with `false`.
*/
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean;
}
export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
export interface SFCScriptCompileOptions {
/**
* Scope ID for prefixing injected CSS variables.
* This must be consistent with the `id` passed to `compileStyle`.
*/
id: string;
/**
* Production mode. Used to determine whether to generate hashed CSS variables
*/
isProd?: boolean;
/**
* Enable/disable source map. Defaults to true.
*/
sourceMap?: boolean;
/**
* https://babeljs.io/docs/en/babel-parser#plugins
*/
babelParserPlugins?: ParserPlugin[];
/**
* A list of files to parse for global types to be made available for type
* resolving in SFC macros. The list must be fully resolved file system paths.
*/
globalTypeFiles?: string[];
/**
* Compile the template and inline the resulting render function
* directly inside setup().
* - Only affects `<script setup>`
* - This should only be used in production because it prevents the template
* from being hot-reloaded separately from component state.
*/
inlineTemplate?: boolean;
/**
* Generate the final component as a variable instead of default export.
* This is useful in e.g. @vitejs/plugin-vue where the script needs to be
* placed inside the main module.
*/
genDefaultAs?: string;
/**
* Options for template compilation when inlining. Note these are options that
* would normally be passed to `compiler-sfc`'s own `compileTemplate()`, not
* options passed to `compiler-dom`.
*/
templateOptions?: Partial<SFCTemplateCompileOptions>;
/**
* Hoist <script setup> static constants.
* - Only enables when one `<script setup>` exists.
* @default true
*/
hoistStatic?: boolean;
/**
* Set to `false` to disable reactive destructure for `defineProps` (pre-3.5
* behavior), or set to `'error'` to throw hard error on props destructures.
* @default true
*/
propsDestructure?: boolean | 'error';
/**
* File system access methods to be used when resolving types
* imported in SFC macros. Defaults to ts.sys in Node.js, can be overwritten
* to use a virtual file system for use in browsers (e.g. in REPLs)
*/
fs?: {
fileExists(file: string): boolean;
readFile(file: string): string | undefined;
realpath?(file: string): string;
};
/**
* Transform Vue SFCs into custom elements.
*/
customElement?: boolean | ((filename: string) => boolean);
}
interface ImportBinding {
isType: boolean;
imported: string;
local: string;
source: string;
isFromSetup: boolean;
isUsedInTemplate: boolean;
}
/**
* Compile `<script setup>`
* It requires the whole SFC descriptor because we need to handle and merge
* normal `<script>` + `<script setup>` if both are present.
*/
export declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
export interface SFCParseOptions {
filename?: string;
sourceMap?: boolean;
sourceRoot?: string;
pad?: boolean | 'line' | 'space';
ignoreEmpty?: boolean;
compiler?: TemplateCompiler;
templateParseOptions?: ParserOptions;
}
export interface SFCBlock {
type: string;
content: string;
attrs: Record<string, string | true>;
loc: SourceLocation;
map?: RawSourceMap;
lang?: string;
src?: string;
}
export interface SFCTemplateBlock extends SFCBlock {
type: 'template';
ast?: RootNode;
}
export interface SFCScriptBlock extends SFCBlock {
type: 'script';
setup?: string | boolean;
bindings?: BindingMetadata$1;
imports?: Record<string, ImportBinding>;
scriptAst?: _babel_types.Statement[];
scriptSetupAst?: _babel_types.Statement[];
warnings?: string[];
/**
* Fully resolved dependency file paths (unix slashes) with imported types
* used in macros, used for HMR cache busting in @vitejs/plugin-vue and
* vue-loader.
*/
deps?: string[];
}
export interface SFCStyleBlock extends SFCBlock {
type: 'style';
scoped?: boolean;
module?: string | boolean;
}
export interface SFCDescriptor {
filename: string;
source: string;
template: SFCTemplateBlock | null;
script: SFCScriptBlock | null;
scriptSetup: SFCScriptBlock | null;
styles: SFCStyleBlock[];
customBlocks: SFCBlock[];
cssVars: string[];
/**
* whether the SFC uses :slotted() modifier.
* this is used as a compiler optimization hint.
*/
slotted: boolean;
/**
* compare with an existing descriptor to determine whether HMR should perform
* a reload vs. re-render.
*
* Note: this comparison assumes the prev/next script are already identical,
* and only checks the special case where <script setup lang="ts"> unused import
* pruning result changes due to template changes.
*/
shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
}
export interface SFCParseResult {
descriptor: SFCDescriptor;
errors: (CompilerError | SyntaxError)[];
}
export declare function parse(source: string, options?: SFCParseOptions): SFCParseResult;
type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus';
export interface SFCStyleCompileOptions {
source: string;
filename: string;
id: string;
scoped?: boolean;
trim?: boolean;
isProd?: boolean;
inMap?: RawSourceMap;
preprocessLang?: PreprocessLang;
preprocessOptions?: any;
preprocessCustomRequire?: (id: string) => any;
postcssOptions?: any;
postcssPlugins?: any[];
/**
* @deprecated use `inMap` instead.
*/
map?: RawSourceMap;
}
/**
* Aligns with postcss-modules
* https://github.com/css-modules/postcss-modules
*/
interface CSSModulesOptions {
scopeBehaviour?: 'global' | 'local';
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
hashPrefix?: string;
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
exportGlobals?: boolean;
globalModulePaths?: RegExp[];
}
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
isAsync?: boolean;
modules?: boolean;
modulesOptions?: CSSModulesOptions;
}
export interface SFCStyleCompileResults {
code: string;
map: RawSourceMap | undefined;
rawResult: Result | LazyResult | undefined;
errors: Error[];
modules?: Record<string, string>;
dependencies: Set<string>;
}
export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
export declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
export declare function rewriteDefault(input: string, as: string, parserPlugins?: ParserPlugin[]): string;
/**
* Utility for rewriting `export default` in a script block into a variable
* declaration so that we can inject things into it
*/
export declare function rewriteDefaultAST(ast: Statement[], s: MagicString, as: string): void;
type PropsDestructureBindings = Record<string, // public prop key
{
local: string;
default?: Expression;
}>;
export declare function extractRuntimeProps(ctx: TypeResolveContext): string | undefined;
interface ModelDecl {
type: TSType | undefined;
options: string | undefined;
identifier: string | undefined;
runtimeOptionNodes: Node[];
}
declare enum BindingTypes {
/**
* returned from data()
*/
DATA = "data",
/**
* declared as a prop
*/
PROPS = "props",
/**
* a local alias of a `<script setup>` destructured prop.
* the original is stored in __propsAliases of the bindingMetadata object.
*/
PROPS_ALIASED = "props-aliased",
/**
* a let binding (may or may not be a ref)
*/
SETUP_LET = "setup-let",
/**
* a const binding that can never be a ref.
* these bindings don't need `unref()` calls when processed in inlined
* template expressions.
*/
SETUP_CONST = "setup-const",
/**
* a const binding that does not need `unref()`, but may be mutated.
*/
SETUP_REACTIVE_CONST = "setup-reactive-const",
/**
* a const binding that may be a ref.
*/
SETUP_MAYBE_REF = "setup-maybe-ref",
/**
* bindings that are guaranteed to be refs
*/
SETUP_REF = "setup-ref",
/**
* declared by other options, e.g. computed, inject
*/
OPTIONS = "options",
/**
* a literal constant, e.g. 'foo', 1, true
*/
LITERAL_CONST = "literal-const"
}
type BindingMetadata = {
[key: string]: BindingTypes | undefined;
} & {
__isScriptSetup?: boolean;
__propsAliases?: Record<string, string>;
};
export declare class ScriptCompileContext {
descriptor: SFCDescriptor;
options: Partial<SFCScriptCompileOptions>;
isJS: boolean;
isTS: boolean;
isCE: boolean;
scriptAst: Program | null;
scriptSetupAst: Program | null;
source: string;
filename: string;
s: MagicString;
startOffset: number | undefined;
endOffset: number | undefined;
scope?: TypeScope;
globalScopes?: TypeScope[];
userImports: Record<string, ImportBinding>;
hasDefinePropsCall: boolean;
hasDefineEmitCall: boolean;
hasDefineExposeCall: boolean;
hasDefaultExportName: boolean;
hasDefaultExportRender: boolean;
hasDefineOptionsCall: boolean;
hasDefineSlotsCall: boolean;
hasDefineModelCall: boolean;
propsCall: CallExpression | undefined;
propsDecl: Node | undefined;
propsRuntimeDecl: Node | undefined;
propsTypeDecl: Node | undefined;
propsDestructureDecl: ObjectPattern | undefined;
propsDestructuredBindings: PropsDestructureBindings;
propsDestructureRestId: string | undefined;
propsRuntimeDefaults: Node | undefined;
emitsRuntimeDecl: Node | undefined;
emitsTypeDecl: Node | undefined;
emitDecl: Node | undefined;
modelDecls: Record<string, ModelDecl>;
optionsRuntimeDecl: Node | undefined;
bindingMetadata: BindingMetadata;
helperImports: Set<string>;
helper(key: string): string;
/**
* to be exposed on compiled script block for HMR cache busting
*/
deps?: Set<string>;
/**
* cache for resolved fs
*/
fs?: NonNullable<SFCScriptCompileOptions['fs']>;
constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
getString(node: Node, scriptSetup?: boolean): string;
warn(msg: string, node: Node, scope?: TypeScope): void;
error(msg: string, node: Node, scope?: TypeScope): never;
}
export type SimpleTypeResolveOptions = Partial<Pick<SFCScriptCompileOptions, 'globalTypeFiles' | 'fs' | 'babelParserPlugins' | 'isProd'>>;
/**
* TypeResolveContext is compatible with ScriptCompileContext
* but also allows a simpler version of it with minimal required properties
* when resolveType needs to be used in a non-SFC context, e.g. in a babel
* plugin. The simplest context can be just:
* ```ts
* const ctx: SimpleTypeResolveContext = {
* filename: '...',
* source: '...',
* options: {},
* error() {},
* ast: []
* }
* ```
*/
export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'helper' | 'getString' | 'propsTypeDecl' | 'propsRuntimeDefaults' | 'propsDestructuredBindings' | 'emitsTypeDecl' | 'isCE'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
ast: Statement[];
options: SimpleTypeResolveOptions;
};
export type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext;
type Import = Pick<ImportBinding, 'source' | 'imported'>;
interface WithScope {
_ownerScope: TypeScope;
}
type ScopeTypeNode = Node & WithScope & {
_ns?: TSModuleDeclaration & WithScope;
};
declare class TypeScope {
filename: string;
source: string;
offset: number;
imports: Record<string, Import>;
types: Record<string, ScopeTypeNode>;
declares: Record<string, ScopeTypeNode>;
constructor(filename: string, source: string, offset?: number, imports?: Record<string, Import>, types?: Record<string, ScopeTypeNode>, declares?: Record<string, ScopeTypeNode>);
isGenericScope: boolean;
resolvedImportSources: Record<string, string>;
exportedTypes: Record<string, ScopeTypeNode>;
exportedDeclares: Record<string, ScopeTypeNode>;
}
interface MaybeWithScope {
_ownerScope?: TypeScope;
}
interface ResolvedElements {
props: Record<string, (TSPropertySignature | TSMethodSignature) & {
_ownerScope: TypeScope;
}>;
calls?: (TSCallSignatureDeclaration | TSFunctionType)[];
}
/**
* Resolve arbitrary type node to a list of type elements that can be then
* mapped to runtime props or emits.
*/
export declare function resolveTypeElements(ctx: TypeResolveContext, node: Node & MaybeWithScope & {
_resolvedElements?: ResolvedElements;
}, scope?: TypeScope, typeParameters?: Record<string, Node>): ResolvedElements;
/**
* @private
*/
export declare function registerTS(_loadTS: () => typeof TS): void;
/**
* @private
*/
export declare function invalidateTypeCache(filename: string): void;
export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean): string[];
export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
export declare const version: string;
export declare const parseCache: Map<string, SFCParseResult>;
export declare const errorMessages: Record<number, string>;
export declare const walk: any;
/**
* @deprecated this is preserved to avoid breaking vite-plugin-vue < 5.0
* with reactivityTransform: true. The desired behavior should be silently
* ignoring the option instead of breaking.
*/
export declare const shouldTransformRef: () => boolean;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,92 @@
# 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))
## 2.0.0
* Add an `asyncWalk` export ([#20](https://github.com/Rich-Harris/estree-walker/pull/20))
* Internal rewrite
## 1.0.1
* Relax node type to `BaseNode` ([#17](https://github.com/Rich-Harris/estree-walker/pull/17))
## 1.0.0
* Don't cache child keys
## 0.9.0
* Add `this.remove()` method
## 0.8.1
* Fix pkg.files
## 0.8.0
* Adopt `estree` types
## 0.7.0
* Add a `this.replace(node)` method
## 0.6.1
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9))
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8))
## 0.6.0
* Fix walker context type
* Update deps, remove unncessary Bublé transformation
## 0.5.2
* Add types to package
## 0.5.1
* Prevent context corruption when `walk()` is called during a walk
## 0.5.0
* Export `childKeys`, for manually fixing in case of malformed ASTs
## 0.4.0
* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
## 0.3.1
* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2))
## 0.3.0
* More predictable ordering
## 0.2.1
* Keep `context` shape
## 0.2.0
* Add ES6 build
## 0.1.3
* npm snafu
## 0.1.2
* Pass current prop and index to `enter`/`leave` callbacks
## 0.1.1
* First release

View File

@@ -0,0 +1,7 @@
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/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.

View File

@@ -0,0 +1,48 @@
# estree-walker
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
## Installation
```bash
npm i estree-walker
```
## Usage
```js
var walk = require( 'estree-walker' ).walk;
var acorn = require( 'acorn' );
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
walk( ast, {
enter: function ( node, parent, prop, index ) {
// some code happens
},
leave: function ( node, parent, prop, index ) {
// some code happens
}
});
```
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
Call `this.remove()` in either `enter` or `leave` to remove the current node.
## Why not use estraverse?
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
## License
MIT

View File

@@ -0,0 +1,333 @@
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => void} SyncHandler */
class SyncWalker extends WalkerBase {
/**
*
* @param {SyncHandler} enter
* @param {SyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => Promise<void>} AsyncHandler */
class AsyncWalker extends WalkerBase {
/**
*
* @param {AsyncHandler} enter
* @param {AsyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}
// @ts-check
/** @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}
*/
function walk(ast, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}
export { asyncWalk, walk };

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,344 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.estreeWalker = {}));
}(this, (function (exports) { 'use strict';
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => void} SyncHandler */
class SyncWalker extends WalkerBase {
/**
*
* @param {SyncHandler} enter
* @param {SyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef { import('./walker').WalkerContext} WalkerContext */
/** @typedef {(
* this: WalkerContext,
* node: BaseNode,
* parent: BaseNode,
* key: string,
* index: number
* ) => Promise<void>} AsyncHandler */
class AsyncWalker extends WalkerBase {
/**
*
* @param {AsyncHandler} enter
* @param {AsyncHandler} leave
*/
constructor(enter, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}
// @ts-check
/** @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}
*/
function walk(ast, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}
exports.asyncWalk = asyncWalk;
exports.walk = walk;
Object.defineProperty(exports, '__esModule', { value: true });
})));

View File

@@ -0,0 +1,37 @@
{
"name": "estree-walker",
"description": "Traverse an ESTree-compliant AST",
"version": "2.0.2",
"private": false,
"author": "Rich Harris",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Rich-Harris/estree-walker"
},
"type": "commonjs",
"main": "./dist/umd/estree-walker.js",
"module": "./dist/esm/estree-walker.js",
"exports": {
"require": "./dist/umd/estree-walker.js",
"import": "./dist/esm/estree-walker.js"
},
"types": "types/index.d.ts",
"scripts": {
"prepublishOnly": "npm run build && npm test",
"build": "tsc && rollup -c",
"test": "uvu test"
},
"devDependencies": {
"@types/estree": "0.0.42",
"rollup": "^2.10.9",
"typescript": "^3.7.5",
"uvu": "^0.5.1"
},
"files": [
"src",
"dist",
"types",
"README.md"
]
}

View File

@@ -0,0 +1,118 @@
// @ts-check
import { WalkerBase } from './walker.js';
/** @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, leave) {
super();
/** @type {AsyncHandler} */
this.enter = enter;
/** @type {AsyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {Promise<BaseNode>}
*/
async visit(node, parent, prop, index) {
if (node) {
if (this.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 this.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, key, i))) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
await this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
await this.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;
}
}

View File

@@ -0,0 +1,35 @@
// @ts-check
import { SyncWalker } from './sync.js';
import { AsyncWalker } from './async.js';
/** @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, { enter, leave }) {
const instance = new SyncWalker(enter, leave);
return instance.visit(ast, null);
}
/**
*
* @param {BaseNode} ast
* @param {{
* enter?: AsyncHandler
* leave?: AsyncHandler
* }} walker
* @returns {Promise<BaseNode>}
*/
export async function asyncWalk(ast, { enter, leave }) {
const instance = new AsyncWalker(enter, leave);
return await instance.visit(ast, null);
}

View File

@@ -0,0 +1 @@
{"type": "module"}

View File

@@ -0,0 +1,118 @@
// @ts-check
import { WalkerBase } from './walker.js';
/** @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, leave) {
super();
/** @type {SyncHandler} */
this.enter = enter;
/** @type {SyncHandler} */
this.leave = leave;
}
/**
*
* @param {BaseNode} node
* @param {BaseNode} parent
* @param {string} [prop]
* @param {number} [index]
* @returns {BaseNode}
*/
visit(node, parent, prop, index) {
if (node) {
if (this.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;
this.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, key, i)) {
// removed
i--;
}
}
}
} else if (value !== null && typeof value.type === "string") {
this.visit(value, node, key, null);
}
}
if (this.leave) {
const _replacement = this.replacement;
const _should_remove = this.should_remove;
this.replacement = null;
this.should_remove = false;
this.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;
}
}

View File

@@ -0,0 +1,61 @@
// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
export class WalkerBase {
constructor() {
/** @type {boolean} */
this.should_skip = false;
/** @type {boolean} */
this.should_remove = false;
/** @type {BaseNode | null} */
this.replacement = null;
/** @type {WalkerContext} */
this.context = {
skip: () => (this.should_skip = true),
remove: () => (this.should_remove = true),
replace: (node) => (this.replacement = node)
};
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
* @param {BaseNode} node
*/
replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
/**
*
* @param {any} parent
* @param {string} prop
* @param {number} index
*/
remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
}

View File

@@ -0,0 +1,53 @@
/** @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";

View File

@@ -0,0 +1,56 @@
/** @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>;

View File

@@ -0,0 +1,53 @@
/** @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";

View File

@@ -0,0 +1,345 @@
{
"program": {
"fileInfos": {
"../node_modules/typescript/lib/lib.es5.d.ts": {
"version": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea",
"signature": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea"
},
"../node_modules/typescript/lib/lib.es2015.d.ts": {
"version": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96",
"signature": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96"
},
"../node_modules/typescript/lib/lib.es2016.d.ts": {
"version": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1",
"signature": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1"
},
"../node_modules/typescript/lib/lib.es2017.d.ts": {
"version": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743",
"signature": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743"
},
"../node_modules/typescript/lib/lib.dom.d.ts": {
"version": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de",
"signature": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de"
},
"../node_modules/typescript/lib/lib.dom.iterable.d.ts": {
"version": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf",
"signature": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf"
},
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts": {
"version": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b",
"signature": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b"
},
"../node_modules/typescript/lib/lib.scripthost.d.ts": {
"version": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9",
"signature": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9"
},
"../node_modules/typescript/lib/lib.es2015.core.d.ts": {
"version": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6",
"signature": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6"
},
"../node_modules/typescript/lib/lib.es2015.collection.d.ts": {
"version": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8",
"signature": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8"
},
"../node_modules/typescript/lib/lib.es2015.generator.d.ts": {
"version": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122",
"signature": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122"
},
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
"version": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210",
"signature": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210"
},
"../node_modules/typescript/lib/lib.es2015.promise.d.ts": {
"version": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca",
"signature": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca"
},
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
"version": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe",
"signature": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe"
},
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
"version": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976",
"signature": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976"
},
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
"version": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230",
"signature": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230"
},
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
"version": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303",
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
},
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
"version": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0",
"signature": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0"
},
"../node_modules/typescript/lib/lib.es2017.object.d.ts": {
"version": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408",
"signature": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408"
},
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
"version": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f",
"signature": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f"
},
"../node_modules/typescript/lib/lib.es2017.string.d.ts": {
"version": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c",
"signature": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c"
},
"../node_modules/typescript/lib/lib.es2017.intl.d.ts": {
"version": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6",
"signature": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6"
},
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
"version": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46",
"signature": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46"
},
"../node_modules/typescript/lib/lib.es2017.full.d.ts": {
"version": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594",
"signature": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594"
},
"../node_modules/@types/estree/index.d.ts": {
"version": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644",
"signature": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644"
},
"../src/walker.js": {
"version": "4cc9d0e334d83a4cebeeac502de37a1aeeb953f6d4145a886d9eecea1f2142a7",
"signature": "075872468ccc19c83b03fd717fc9305b5f8ec09592210cf60279cb13eca2bd70"
},
"../src/async.js": {
"version": "904efd145090ac40c3c98f29cc928332898a62ab642dd5921db2ae249bfe014a",
"signature": "da428f781d6dc6dfd4f4afd0dd5f25a780897dc8b57e5b30462491b7d08f32c0"
},
"../src/sync.js": {
"version": "85bb22b85042f0a3717d8fac2fc8f62af16894652be34d1e08eb3e63785535f5",
"signature": "5b131a727db18c956611a5e33d08217df96d0f2e0f26d98b804d1ec2407e59ae"
},
"../src/index.js": {
"version": "99128f4c6cb79cb1e3abf3f2ba96faedd2b820aab4fd7f743aab0b8d710a73af",
"signature": "c52be5c79280bfcfcf359c084c6f2f70f405b0ad14dde96b6703dbc5ef2261f5"
}
},
"options": {
"allowJs": true,
"target": 4,
"module": 99,
"types": [
"estree"
],
"declaration": true,
"declarationDir": "./",
"emitDeclarationOnly": true,
"outDir": "./",
"newLine": 1,
"noImplicitAny": true,
"noImplicitThis": true,
"incremental": true,
"configFilePath": "../tsconfig.json"
},
"referencedMap": {
"../src/walker.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/async.js": [
"../src/walker.js",
"../node_modules/@types/estree/index.d.ts"
],
"../src/sync.js": [
"../src/walker.js",
"../node_modules/@types/estree/index.d.ts"
],
"../src/index.js": [
"../src/sync.js",
"../src/async.js",
"../node_modules/@types/estree/index.d.ts"
]
},
"exportedModulesMap": {
"../src/walker.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/async.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/sync.js": [
"../node_modules/@types/estree/index.d.ts"
],
"../src/index.js": [
"../node_modules/@types/estree/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../node_modules/typescript/lib/lib.es5.d.ts",
"../node_modules/typescript/lib/lib.es2015.d.ts",
"../node_modules/typescript/lib/lib.es2016.d.ts",
"../node_modules/typescript/lib/lib.es2017.d.ts",
"../node_modules/typescript/lib/lib.dom.d.ts",
"../node_modules/typescript/lib/lib.dom.iterable.d.ts",
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts",
"../node_modules/typescript/lib/lib.scripthost.d.ts",
"../node_modules/typescript/lib/lib.es2015.core.d.ts",
"../node_modules/typescript/lib/lib.es2015.collection.d.ts",
"../node_modules/typescript/lib/lib.es2015.generator.d.ts",
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts",
"../node_modules/typescript/lib/lib.es2015.promise.d.ts",
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts",
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts",
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts",
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts",
"../node_modules/typescript/lib/lib.es2017.object.d.ts",
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
"../node_modules/typescript/lib/lib.es2017.string.d.ts",
"../node_modules/typescript/lib/lib.es2017.intl.d.ts",
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
"../node_modules/typescript/lib/lib.es2017.full.d.ts",
"../node_modules/@types/estree/index.d.ts",
"../src/walker.js",
[
"../src/async.js",
[
{
"file": "../src/async.js",
"start": 864,
"length": 12,
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 907,
"length": 14,
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 954,
"length": 12,
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 991,
"length": 24,
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1021,
"length": 26,
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1053,
"length": 23,
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/async.js",
"start": 1643,
"length": 9,
"code": 7053,
"category": 1,
"messageText": {
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
"category": 1,
"code": 7053,
"next": [
{
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
"category": 1,
"code": 7054
}
]
}
}
]
],
[
"../src/sync.js",
[
{
"file": "../src/sync.js",
"start": 837,
"length": 12,
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 880,
"length": 14,
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 927,
"length": 12,
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 964,
"length": 24,
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 994,
"length": 26,
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 1026,
"length": 23,
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
"category": 1,
"code": 7022
},
{
"file": "../src/sync.js",
"start": 1610,
"length": 9,
"code": 7053,
"category": 1,
"messageText": {
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
"category": 1,
"code": 7053,
"next": [
{
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
"category": 1,
"code": 7054
}
]
}
}
]
],
"../src/index.js"
]
},
"version": "3.7.5"
}

View File

@@ -0,0 +1,37 @@
/** @typedef { import('estree').BaseNode} BaseNode */
/** @typedef {{
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
}} WalkerContext */
export class WalkerBase {
/** @type {boolean} */
should_skip: boolean;
/** @type {boolean} */
should_remove: boolean;
/** @type {BaseNode | null} */
replacement: BaseNode | null;
/** @type {WalkerContext} */
context: WalkerContext;
/**
*
* @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;
};

67
node_modules/@vue/compiler-sfc/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"name": "@vue/compiler-sfc",
"version": "3.5.13",
"description": "@vue/compiler-sfc",
"main": "dist/compiler-sfc.cjs.js",
"module": "dist/compiler-sfc.esm-browser.js",
"types": "dist/compiler-sfc.d.ts",
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/compiler-sfc.d.ts",
"node": "./dist/compiler-sfc.cjs.js",
"module": "./dist/compiler-sfc.esm-browser.js",
"import": "./dist/compiler-sfc.esm-browser.js",
"require": "./dist/compiler-sfc.cjs.js"
},
"./*": "./*"
},
"buildOptions": {
"name": "VueCompilerSFC",
"formats": [
"cjs",
"esm-browser"
],
"prod": false,
"enableNonBrowserBranches": true
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/core.git",
"directory": "packages/compiler-sfc"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/core/issues"
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
"dependencies": {
"@babel/parser": "^7.25.3",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.11",
"postcss": "^8.4.48",
"source-map-js": "^1.2.0",
"@vue/compiler-core": "3.5.13",
"@vue/shared": "3.5.13",
"@vue/compiler-dom": "3.5.13",
"@vue/compiler-ssr": "3.5.13"
},
"devDependencies": {
"@babel/types": "^7.25.2",
"@vue/consolidate": "^1.0.0",
"hash-sum": "^2.0.0",
"lru-cache": "10.1.0",
"merge-source-map": "^1.1.0",
"minimatch": "~9.0.5",
"postcss-modules": "^6.0.0",
"postcss-selector-parser": "^7.0.0",
"pug": "^3.0.3",
"sass": "^1.80.6"
}
}

21
node_modules/@vue/compiler-ssr/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018-present, Yuxi (Evan) You
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.

1
node_modules/@vue/compiler-ssr/README.md generated vendored Normal file
View File

@@ -0,0 +1 @@
# @vue/compiler-ssr

1404
node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
import { RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-dom';
export declare function compile(source: string | RootNode, options?: CompilerOptions): CodegenResult;

34
node_modules/@vue/compiler-ssr/package.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "@vue/compiler-ssr",
"version": "3.5.13",
"description": "@vue/compiler-ssr",
"main": "dist/compiler-ssr.cjs.js",
"types": "dist/compiler-ssr.d.ts",
"files": [
"dist"
],
"buildOptions": {
"prod": false,
"formats": [
"cjs"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/core.git",
"directory": "packages/compiler-ssr"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/core/issues"
},
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-ssr#readme",
"dependencies": {
"@vue/shared": "3.5.13",
"@vue/compiler-dom": "3.5.13"
}
}

2
node_modules/@vue/devtools-api/lib/cjs/api/api.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

2
node_modules/@vue/devtools-api/lib/cjs/api/app.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

2
node_modules/@vue/devtools-api/lib/cjs/api/hooks.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

22
node_modules/@vue/devtools-api/lib/cjs/api/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./api.js"), exports);
__exportStar(require("./app.js"), exports);
__exportStar(require("./component.js"), exports);
__exportStar(require("./context.js"), exports);
__exportStar(require("./hooks.js"), exports);
__exportStar(require("./util.js"), exports);

2
node_modules/@vue/devtools-api/lib/cjs/api/util.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

5
node_modules/@vue/devtools-api/lib/cjs/const.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HOOK_PLUGIN_SETTINGS_SET = exports.HOOK_SETUP = void 0;
exports.HOOK_SETUP = 'devtools-plugin:setup';
exports.HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';

17
node_modules/@vue/devtools-api/lib/cjs/env.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isProxyAvailable = exports.getTarget = exports.getDevtoolsGlobalHook = void 0;
function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
exports.getDevtoolsGlobalHook = getDevtoolsGlobalHook;
function getTarget() {
// @ts-expect-error navigator and windows are not available in all environments
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
? window
: typeof globalThis !== 'undefined'
? globalThis
: {};
}
exports.getTarget = getTarget;
exports.isProxyAvailable = typeof Proxy === 'function';

45
node_modules/@vue/devtools-api/lib/cjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupDevtoolsPlugin = void 0;
const env_js_1 = require("./env.js");
const const_js_1 = require("./const.js");
const proxy_js_1 = require("./proxy.js");
__exportStar(require("./api/index.js"), exports);
__exportStar(require("./plugin.js"), exports);
__exportStar(require("./time.js"), exports);
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = (0, env_js_1.getTarget)();
const hook = (0, env_js_1.getDevtoolsGlobalHook)();
const enableProxy = env_js_1.isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(const_js_1.HOOK_SETUP, pluginDescriptor, setupFn);
}
else {
const proxy = enableProxy ? new proxy_js_1.ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy,
});
if (proxy) {
setupFn(proxy.proxiedTarget);
}
}
}
exports.setupDevtoolsPlugin = setupDevtoolsPlugin;

2
node_modules/@vue/devtools-api/lib/cjs/plugin.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

111
node_modules/@vue/devtools-api/lib/cjs/proxy.js generated vendored Normal file
View File

@@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiProxy = void 0;
const const_js_1 = require("./const.js");
const time_js_1 = require("./time.js");
class ApiProxy {
constructor(plugin, hook) {
this.target = null;
this.targetQueue = [];
this.onQueue = [];
this.plugin = plugin;
this.hook = hook;
const defaultSettings = {};
if (plugin.settings) {
for (const id in plugin.settings) {
const item = plugin.settings[id];
defaultSettings[id] = item.defaultValue;
}
}
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
let currentSettings = Object.assign({}, defaultSettings);
try {
const raw = localStorage.getItem(localSettingsSaveId);
const data = JSON.parse(raw);
Object.assign(currentSettings, data);
}
catch (e) {
// noop
}
this.fallbacks = {
getSettings() {
return currentSettings;
},
setSettings(value) {
try {
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
}
catch (e) {
// noop
}
currentSettings = value;
},
now() {
return (0, time_js_1.now)();
},
};
if (hook) {
hook.on(const_js_1.HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
if (pluginId === this.plugin.id) {
this.fallbacks.setSettings(value);
}
});
}
this.proxiedOn = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target.on[prop];
}
else {
return (...args) => {
this.onQueue.push({
method: prop,
args,
});
};
}
},
});
this.proxiedTarget = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target[prop];
}
else if (prop === 'on') {
return this.proxiedOn;
}
else if (Object.keys(this.fallbacks).includes(prop)) {
return (...args) => {
this.targetQueue.push({
method: prop,
args,
resolve: () => { },
});
return this.fallbacks[prop](...args);
};
}
else {
return (...args) => {
return new Promise((resolve) => {
this.targetQueue.push({
method: prop,
args,
resolve,
});
});
};
}
},
});
}
async setRealTarget(target) {
this.target = target;
for (const item of this.onQueue) {
this.target.on[item.method](...item.args);
}
for (const item of this.targetQueue) {
item.resolve(await this.target[item.method](...item.args));
}
}
}
exports.ApiProxy = ApiProxy;

28
node_modules/@vue/devtools-api/lib/cjs/time.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.now = exports.isPerformanceSupported = void 0;
let supported;
let perf;
function isPerformanceSupported() {
var _a;
if (supported !== undefined) {
return supported;
}
if (typeof window !== 'undefined' && window.performance) {
supported = true;
perf = window.performance;
}
else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
supported = true;
perf = globalThis.perf_hooks.performance;
}
else {
supported = false;
}
return supported;
}
exports.isPerformanceSupported = isPerformanceSupported;
function now() {
return isPerformanceSupported() ? perf.now() : Date.now();
}
exports.now = now;

108
node_modules/@vue/devtools-api/lib/esm/api/api.d.ts generated vendored Normal file
View File

@@ -0,0 +1,108 @@
import type { ComponentBounds, Hookable } from './hooks.js';
import type { Context } from './context.js';
import type { ComponentInstance, ComponentState, StateBase } from './component.js';
import type { App } from './app.js';
import type { ID } from './util.js';
export interface DevtoolsPluginApi<TSettings> {
on: Hookable<Context>;
notifyComponentUpdate: (instance?: ComponentInstance) => void;
addTimelineLayer: (options: TimelineLayerOptions) => void;
addTimelineEvent: (options: TimelineEventOptions) => void;
addInspector: (options: CustomInspectorOptions) => void;
sendInspectorTree: (inspectorId: string) => void;
sendInspectorState: (inspectorId: string) => void;
selectInspectorNode: (inspectorId: string, nodeId: string) => void;
getComponentBounds: (instance: ComponentInstance) => Promise<ComponentBounds>;
getComponentName: (instance: ComponentInstance) => Promise<string>;
getComponentInstances: (app: App) => Promise<ComponentInstance[]>;
highlightElement: (instance: ComponentInstance) => void;
unhighlightElement: () => void;
getSettings: (pluginId?: string) => TSettings;
now: () => number;
/**
* @private
*/
setSettings: (values: TSettings) => void;
}
export interface AppRecord {
id: string;
name: string;
instanceMap: Map<string, ComponentInstance>;
rootInstance: ComponentInstance;
}
export interface TimelineLayerOptions<TData = any, TMeta = any> {
id: string;
label: string;
color: number;
skipScreenshots?: boolean;
groupsOnly?: boolean;
ignoreNoDurationGroups?: boolean;
screenshotOverlayRender?: (event: TimelineEvent<TData, TMeta> & ScreenshotOverlayEvent, ctx: ScreenshotOverlayRenderContext) => ScreenshotOverlayRenderResult | Promise<ScreenshotOverlayRenderResult>;
}
export interface ScreenshotOverlayEvent {
layerId: string;
renderMeta: any;
}
export interface ScreenshotOverlayRenderContext<TData = any, TMeta = any> {
screenshot: ScreenshotData;
events: (TimelineEvent<TData, TMeta> & ScreenshotOverlayEvent)[];
index: number;
}
export type ScreenshotOverlayRenderResult = HTMLElement | string | false;
export interface ScreenshotData {
time: number;
}
export interface TimelineEventOptions {
layerId: string;
event: TimelineEvent;
all?: boolean;
}
export interface TimelineEvent<TData = any, TMeta = any> {
time: number;
data: TData;
logType?: 'default' | 'warning' | 'error';
meta?: TMeta;
groupId?: ID;
title?: string;
subtitle?: string;
}
export interface TimelineMarkerOptions {
id: string;
time: number;
color: number;
label: string;
all?: boolean;
}
export interface CustomInspectorOptions {
id: string;
label: string;
icon?: string;
treeFilterPlaceholder?: string;
stateFilterPlaceholder?: string;
noSelectionText?: string;
actions?: {
icon: string;
tooltip?: string;
action: () => void | Promise<void>;
}[];
nodeActions?: {
icon: string;
tooltip?: string;
action: (nodeId: string) => void | Promise<void>;
}[];
}
export interface CustomInspectorNode {
id: string;
label: string;
children?: CustomInspectorNode[];
tags?: InspectorNodeTag[];
}
export interface InspectorNodeTag {
label: string;
textColor: number;
backgroundColor: number;
tooltip?: string;
}
export interface CustomInspectorState {
[key: string]: (StateBase | Omit<ComponentState, 'type'>)[];
}

1
node_modules/@vue/devtools-api/lib/esm/api/api.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

1
node_modules/@vue/devtools-api/lib/esm/api/app.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export type App = any;

1
node_modules/@vue/devtools-api/lib/esm/api/app.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,78 @@
import type { InspectorNodeTag } from './api.js';
import type { ID } from './util.js';
export type ComponentInstance = any;
export interface ComponentTreeNode {
uid: ID;
id: string;
name: string;
renderKey: string | number;
inactive: boolean;
isFragment: boolean;
hasChildren: boolean;
children: ComponentTreeNode[];
domOrder?: number[];
consoleId?: string;
isRouterView?: boolean;
macthedRouteSegment?: string;
tags: InspectorNodeTag[];
autoOpen: boolean;
meta?: any;
}
export interface InspectedComponentData {
id: string;
name: string;
file: string;
state: ComponentState[];
functional?: boolean;
}
export interface StateBase {
key: string;
value: any;
editable?: boolean;
objectType?: 'ref' | 'reactive' | 'computed' | 'other';
raw?: string;
}
export interface ComponentStateBase extends StateBase {
type: string;
}
export interface ComponentPropState extends ComponentStateBase {
meta?: {
type: string;
required: boolean;
/** Vue 1 only */
mode?: 'default' | 'sync' | 'once';
};
}
export type ComponentBuiltinCustomStateTypes = 'function' | 'map' | 'set' | 'reference' | 'component' | 'component-definition' | 'router' | 'store';
export interface ComponentCustomState extends ComponentStateBase {
value: CustomState;
}
export interface CustomState {
_custom: {
type: ComponentBuiltinCustomStateTypes | string;
objectType?: string;
display?: string;
tooltip?: string;
value?: any;
abstract?: boolean;
file?: string;
uid?: number;
readOnly?: boolean;
/** Configure immediate child fields */
fields?: {
abstract?: boolean;
};
id?: any;
actions?: {
icon: string;
tooltip?: string;
action: () => void | Promise<void>;
}[];
/** internal */
_reviveId?: number;
};
}
export type ComponentState = ComponentStateBase | ComponentPropState | ComponentCustomState;
export interface ComponentDevtoolsOptions {
hide?: boolean;
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,5 @@
import type { AppRecord } from './api.js';
export interface Context {
currentTab: string;
currentAppRecord: AppRecord;
}

View File

@@ -0,0 +1 @@
export {};

180
node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts generated vendored Normal file
View File

@@ -0,0 +1,180 @@
import type { ComponentDevtoolsOptions, ComponentInstance, ComponentTreeNode, InspectedComponentData } from './component.js';
import type { App } from './app.js';
import type { CustomInspectorNode, CustomInspectorState, TimelineEvent } from './api.js';
export declare const enum Hooks {
TRANSFORM_CALL = "transformCall",
GET_APP_RECORD_NAME = "getAppRecordName",
GET_APP_ROOT_INSTANCE = "getAppRootInstance",
REGISTER_APPLICATION = "registerApplication",
WALK_COMPONENT_TREE = "walkComponentTree",
VISIT_COMPONENT_TREE = "visitComponentTree",
WALK_COMPONENT_PARENTS = "walkComponentParents",
INSPECT_COMPONENT = "inspectComponent",
GET_COMPONENT_BOUNDS = "getComponentBounds",
GET_COMPONENT_NAME = "getComponentName",
GET_COMPONENT_INSTANCES = "getComponentInstances",
GET_ELEMENT_COMPONENT = "getElementComponent",
GET_COMPONENT_ROOT_ELEMENTS = "getComponentRootElements",
EDIT_COMPONENT_STATE = "editComponentState",
GET_COMPONENT_DEVTOOLS_OPTIONS = "getAppDevtoolsOptions",
GET_COMPONENT_RENDER_CODE = "getComponentRenderCode",
INSPECT_TIMELINE_EVENT = "inspectTimelineEvent",
TIMELINE_CLEARED = "timelineCleared",
GET_INSPECTOR_TREE = "getInspectorTree",
GET_INSPECTOR_STATE = "getInspectorState",
EDIT_INSPECTOR_STATE = "editInspectorState",
SET_PLUGIN_SETTINGS = "setPluginSettings"
}
export interface ComponentBounds {
left: number;
top: number;
width: number;
height: number;
}
export interface HookPayloads {
[Hooks.TRANSFORM_CALL]: {
callName: string;
inArgs: any[];
outArgs: any[];
};
[Hooks.GET_APP_RECORD_NAME]: {
app: App;
name: string;
};
[Hooks.GET_APP_ROOT_INSTANCE]: {
app: App;
root: ComponentInstance;
};
[Hooks.REGISTER_APPLICATION]: {
app: App;
};
[Hooks.WALK_COMPONENT_TREE]: {
componentInstance: ComponentInstance;
componentTreeData: ComponentTreeNode[];
maxDepth: number;
filter: string;
recursively: boolean;
};
[Hooks.VISIT_COMPONENT_TREE]: {
app: App;
componentInstance: ComponentInstance;
treeNode: ComponentTreeNode;
filter: string;
};
[Hooks.WALK_COMPONENT_PARENTS]: {
componentInstance: ComponentInstance;
parentInstances: ComponentInstance[];
};
[Hooks.INSPECT_COMPONENT]: {
app: App;
componentInstance: ComponentInstance;
instanceData: InspectedComponentData;
};
[Hooks.GET_COMPONENT_BOUNDS]: {
componentInstance: ComponentInstance;
bounds: ComponentBounds;
};
[Hooks.GET_COMPONENT_NAME]: {
componentInstance: ComponentInstance;
name: string;
};
[Hooks.GET_COMPONENT_INSTANCES]: {
app: App;
componentInstances: ComponentInstance[];
};
[Hooks.GET_ELEMENT_COMPONENT]: {
element: HTMLElement | any;
componentInstance: ComponentInstance;
};
[Hooks.GET_COMPONENT_ROOT_ELEMENTS]: {
componentInstance: ComponentInstance;
rootElements: (HTMLElement | any)[];
};
[Hooks.EDIT_COMPONENT_STATE]: {
app: App;
componentInstance: ComponentInstance;
path: string[];
type: string;
state: EditStatePayload;
set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void;
};
[Hooks.GET_COMPONENT_DEVTOOLS_OPTIONS]: {
componentInstance: ComponentInstance;
options: ComponentDevtoolsOptions;
};
[Hooks.GET_COMPONENT_RENDER_CODE]: {
componentInstance: ComponentInstance;
code: string;
};
[Hooks.INSPECT_TIMELINE_EVENT]: {
app: App;
layerId: string;
event: TimelineEvent;
all?: boolean;
data: any;
};
[Hooks.TIMELINE_CLEARED]: Record<string, never>;
[Hooks.GET_INSPECTOR_TREE]: {
app: App;
inspectorId: string;
filter: string;
rootNodes: CustomInspectorNode[];
};
[Hooks.GET_INSPECTOR_STATE]: {
app: App;
inspectorId: string;
nodeId: string;
state: CustomInspectorState;
};
[Hooks.EDIT_INSPECTOR_STATE]: {
app: App;
inspectorId: string;
nodeId: string;
path: string[];
type: string;
state: EditStatePayload;
set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void;
};
[Hooks.SET_PLUGIN_SETTINGS]: {
app: App;
pluginId: string;
key: string;
newValue: any;
oldValue: any;
settings: any;
};
}
export type EditStatePayload = {
value: any;
newKey?: string | null;
remove?: undefined | false;
} | {
value?: undefined;
newKey?: undefined;
remove: true;
};
export type HookHandler<TPayload, TContext> = (payload: TPayload, ctx: TContext) => void | Promise<void>;
export interface Hookable<TContext> {
transformCall: (handler: HookHandler<HookPayloads[Hooks.TRANSFORM_CALL], TContext>) => any;
getAppRecordName: (handler: HookHandler<HookPayloads[Hooks.GET_APP_RECORD_NAME], TContext>) => any;
getAppRootInstance: (handler: HookHandler<HookPayloads[Hooks.GET_APP_ROOT_INSTANCE], TContext>) => any;
registerApplication: (handler: HookHandler<HookPayloads[Hooks.REGISTER_APPLICATION], TContext>) => any;
walkComponentTree: (handler: HookHandler<HookPayloads[Hooks.WALK_COMPONENT_TREE], TContext>) => any;
visitComponentTree: (handler: HookHandler<HookPayloads[Hooks.VISIT_COMPONENT_TREE], TContext>) => any;
walkComponentParents: (handler: HookHandler<HookPayloads[Hooks.WALK_COMPONENT_PARENTS], TContext>) => any;
inspectComponent: (handler: HookHandler<HookPayloads[Hooks.INSPECT_COMPONENT], TContext>) => any;
getComponentBounds: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_BOUNDS], TContext>) => any;
getComponentName: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_NAME], TContext>) => any;
getComponentInstances: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_INSTANCES], TContext>) => any;
getElementComponent: (handler: HookHandler<HookPayloads[Hooks.GET_ELEMENT_COMPONENT], TContext>) => any;
getComponentRootElements: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_ROOT_ELEMENTS], TContext>) => any;
editComponentState: (handler: HookHandler<HookPayloads[Hooks.EDIT_COMPONENT_STATE], TContext>) => any;
getComponentDevtoolsOptions: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_DEVTOOLS_OPTIONS], TContext>) => any;
getComponentRenderCode: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_RENDER_CODE], TContext>) => any;
inspectTimelineEvent: (handler: HookHandler<HookPayloads[Hooks.INSPECT_TIMELINE_EVENT], TContext>) => any;
timelineCleared: (handler: HookHandler<HookPayloads[Hooks.TIMELINE_CLEARED], TContext>) => any;
getInspectorTree: (handler: HookHandler<HookPayloads[Hooks.GET_INSPECTOR_TREE], TContext>) => any;
getInspectorState: (handler: HookHandler<HookPayloads[Hooks.GET_INSPECTOR_STATE], TContext>) => any;
editInspectorState: (handler: HookHandler<HookPayloads[Hooks.EDIT_INSPECTOR_STATE], TContext>) => any;
setPluginSettings: (handler: HookHandler<HookPayloads[Hooks.SET_PLUGIN_SETTINGS], TContext>) => any;
}

1
node_modules/@vue/devtools-api/lib/esm/api/hooks.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,6 @@
export * from './api.js';
export * from './app.js';
export * from './component.js';
export * from './context.js';
export * from './hooks.js';
export * from './util.js';

6
node_modules/@vue/devtools-api/lib/esm/api/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export * from './api.js';
export * from './app.js';
export * from './component.js';
export * from './context.js';
export * from './hooks.js';
export * from './util.js';

4
node_modules/@vue/devtools-api/lib/esm/api/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export type ID = number | string;
export interface WithId {
id: ID;
}

1
node_modules/@vue/devtools-api/lib/esm/api/util.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

2
node_modules/@vue/devtools-api/lib/esm/const.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare const HOOK_SETUP = "devtools-plugin:setup";
export declare const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";

2
node_modules/@vue/devtools-api/lib/esm/const.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export const HOOK_SETUP = 'devtools-plugin:setup';
export const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';

15
node_modules/@vue/devtools-api/lib/esm/env.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import type { ApiProxy } from './proxy.js';
import type { PluginDescriptor, SetupFunction } from './index.js';
export interface PluginQueueItem {
pluginDescriptor: PluginDescriptor;
setupFn: SetupFunction;
proxy?: ApiProxy;
}
interface GlobalTarget {
__VUE_DEVTOOLS_PLUGINS__?: PluginQueueItem[];
__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__?: boolean;
}
export declare function getDevtoolsGlobalHook(): any;
export declare function getTarget(): GlobalTarget;
export declare const isProxyAvailable: boolean;
export {};

12
node_modules/@vue/devtools-api/lib/esm/env.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
export function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
export function getTarget() {
// @ts-expect-error navigator and windows are not available in all environments
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
? window
: typeof globalThis !== 'undefined'
? globalThis
: {};
}
export const isProxyAvailable = typeof Proxy === 'function';

18
node_modules/@vue/devtools-api/lib/esm/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import type { DevtoolsPluginApi } from './api/index.js';
import type { ExtractSettingsTypes, PluginDescriptor, PluginSettingsItem } from './plugin.js';
export * from './api/index.js';
export * from './plugin.js';
export * from './time.js';
export { PluginQueueItem } from './env.js';
type Cast<A, B> = A extends B ? A : B;
type Narrowable = string | number | bigint | boolean;
type Narrow<A> = Cast<A, [] | (A extends Narrowable ? A : never) | ({
[K in keyof A]: Narrow<A[K]>;
})>;
type Exact<C, T> = {
[K in keyof C]: K extends keyof T ? T[K] : never;
};
export type SetupFunction<TSettings = any> = (api: DevtoolsPluginApi<TSettings>) => void;
export declare function setupDevtoolsPlugin<TDescriptor extends Exact<TDescriptor, PluginDescriptor>, TSettings = ExtractSettingsTypes<TDescriptor extends {
settings: infer S;
} ? S extends Record<string, PluginSettingsItem> ? S : Record<string, PluginSettingsItem> : Record<string, PluginSettingsItem>>>(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>): void;

27
node_modules/@vue/devtools-api/lib/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { getDevtoolsGlobalHook, getTarget, isProxyAvailable } from './env.js';
import { HOOK_SETUP } from './const.js';
import { ApiProxy } from './proxy.js';
export * from './api/index.js';
export * from './plugin.js';
export * from './time.js';
export function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = getTarget();
const hook = getDevtoolsGlobalHook();
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
}
else {
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy,
});
if (proxy) {
setupFn(proxy.proxiedTarget);
}
}
}

47
node_modules/@vue/devtools-api/lib/esm/plugin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,47 @@
import type { App } from './api/index.js';
export interface PluginDescriptor {
id: string;
label: string;
app: App;
packageName?: string;
homepage?: string;
componentStateTypes?: string[];
logo?: string;
disableAppScope?: boolean;
disablePluginScope?: boolean;
/**
* Run the plugin setup and expose the api even if the devtools is not opened yet.
* Useful to record timeline events early.
*/
enableEarlyProxy?: boolean;
settings?: Record<string, PluginSettingsItem>;
}
export type PluginSettingsItem = {
label: string;
description?: string;
} & ({
type: 'boolean';
defaultValue: boolean;
} | {
type: 'choice';
defaultValue: string | number;
options: {
value: string | number;
label: string;
}[];
component?: 'select' | 'button-group';
} | {
type: 'text';
defaultValue: string;
});
type InferSettingsType<T extends PluginSettingsItem> = [T] extends [{
type: 'boolean';
}] ? boolean : [T] extends [{
type: 'choice';
}] ? T['options'][number]['value'] : [T] extends [{
type: 'text';
}] ? string : unknown;
export type ExtractSettingsTypes<O extends Record<string, PluginSettingsItem>> = {
[K in keyof O]: InferSettingsType<O[K]>;
};
export {};

1
node_modules/@vue/devtools-api/lib/esm/plugin.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

Some files were not shown because too many files have changed in this diff Show More