feat: init
This commit is contained in:
21
node_modules/ast-kit/LICENSE
generated
vendored
Normal file
21
node_modules/ast-kit/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2023-PRESENT Kevin Deng (https://github.com/sxzz)
|
||||
|
||||
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.
|
||||
55
node_modules/ast-kit/README.md
generated
vendored
Normal file
55
node_modules/ast-kit/README.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# ast-kit
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![JSR][jsr-src]][jsr-href]
|
||||
[![Unit Test][unit-test-src]][unit-test-href]
|
||||
[![codecov][codecov-src]][codecov-href]
|
||||
|
||||
A toolkit for easy Babel AST generation and manipulation.
|
||||
|
||||
[📖 API Reference](https://jsr.io/@sxzz/ast-kit/doc)
|
||||
|
||||
## Features
|
||||
|
||||
- **😇 Easy to Use**: Parse and resolve Babel AST with a straightforward API.
|
||||
- **🦾 Type-Friendly**: Built in TypeScript with complete type definitions.
|
||||
- **💯 Coverage**: 100% test coverage.
|
||||
- **🪶 Lightweight**: Tree-shakable with only two dependencies.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i ast-kit
|
||||
```
|
||||
|
||||
Requires Node.js 20.19.0 or higher.
|
||||
|
||||
## AST Explorer
|
||||
|
||||
You can explore your code's AST using the [AST Explorer](https://ast-explorer.dev/).
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2023-PRESENT [Kevin Deng](https://github.com/sxzz)
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/ast-kit.svg
|
||||
[npm-version-href]: https://npmjs.com/package/ast-kit
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/ast-kit
|
||||
[npm-downloads-href]: https://www.npmcharts.com/compare/ast-kit?interval=30
|
||||
[jsr-src]: https://jsr.io/badges/@sxzz/ast-kit
|
||||
[jsr-href]: https://jsr.io/@sxzz/ast-kit
|
||||
[unit-test-src]: https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml/badge.svg
|
||||
[unit-test-href]: https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml
|
||||
[codecov-src]: https://codecov.io/gh/sxzz/ast-kit/graph/badge.svg?token=MHTCPNMZAK
|
||||
[codecov-href]: https://codecov.io/gh/sxzz/ast-kit
|
||||
380
node_modules/ast-kit/dist/index.d.ts
generated
vendored
Normal file
380
node_modules/ast-kit/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
import { ParseError, ParseResult, ParserOptions, parse } from "@babel/parser";
|
||||
import * as t from "@babel/types";
|
||||
import { Node } from "@babel/types";
|
||||
|
||||
//#region src/check.d.ts
|
||||
/**
|
||||
* All possible node types.
|
||||
*/
|
||||
type NodeType = t.Node["type"] | "Function" | "Literal" | "Expression";
|
||||
/**
|
||||
* Represents the corresponding node based on the given node type.
|
||||
*/
|
||||
type GetNode<K extends NodeType> = K extends "Function" ? t.Function : K extends "Literal" ? t.Literal : Extract<t.Node, {
|
||||
type: K;
|
||||
}>;
|
||||
/**
|
||||
* Checks if the given node matches the specified type(s).
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @param types - The type(s) to match against. It can be a single type or an array of types.
|
||||
* @returns True if the node matches the specified type(s), false otherwise.
|
||||
*/
|
||||
declare function isTypeOf<K extends NodeType>(node: t.Node | undefined | null, types: K | Readonly<K[]>): node is GetNode<K>;
|
||||
/**
|
||||
* Checks if the given node is a CallExpression with the specified callee.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @param test - The callee to compare against. It can be a string, an array of strings, or a function that takes a string and returns a boolean.
|
||||
* @returns True if the node is a CallExpression with the specified callee, false otherwise.
|
||||
*/
|
||||
declare function isCallOf(node: t.Node | null | undefined, test: string | string[] | ((id: string) => boolean)): node is t.CallExpression;
|
||||
/**
|
||||
* Checks if the given node is a TaggedTemplateExpression with the specified callee.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @param test - The callee to compare against. It can be a string, an array of strings, or a function that takes a string and returns a boolean.
|
||||
* @returns True if the node is a TaggedTemplateExpression with the specified callee, false otherwise.
|
||||
*/
|
||||
declare function isTaggedFunctionCallOf(node: t.Node | null | undefined, test: string | string[] | ((id: string) => boolean)): node is t.TaggedTemplateExpression;
|
||||
/**
|
||||
* Checks if the given node is an Identifier with the specified name.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @param test - The name to compare against. It can be a string or an array of strings.
|
||||
* @returns True if the node is an Identifier with the specified name, false otherwise.
|
||||
*/
|
||||
declare function isIdentifierOf(node: t.Node | undefined | null, test: string | string[] | ((id: string) => boolean)): node is t.Identifier;
|
||||
/**
|
||||
* Checks if the given node is a literal type.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @returns True if the node is a literal type, false otherwise.
|
||||
*/
|
||||
declare function isLiteralType(node: t.Node | undefined | null): node is t.Literal;
|
||||
/**
|
||||
* Checks if the given node is a function type.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @returns True if the node is a function type, false otherwise.
|
||||
*/
|
||||
declare function isFunctionType(node: t.Node | undefined | null): node is t.Function;
|
||||
/**
|
||||
* Checks if the given node is a declaration type.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @returns True if the node is a declaration type, false otherwise.
|
||||
*/
|
||||
declare function isDeclarationType(node: t.Node | undefined | null): node is t.Declaration;
|
||||
/**
|
||||
* Checks if the given node is an expression type.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @returns True if the node is an expression type, false otherwise.
|
||||
*/
|
||||
declare function isExpressionType(node: t.Node | null | undefined): node is t.Expression;
|
||||
/**
|
||||
* Checks if the input `node` is a reference to a bound variable.
|
||||
*
|
||||
* Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
|
||||
*
|
||||
* To avoid runtime dependency on `@babel/types` (which includes process references)
|
||||
* This file should not change very often in babel but we may need to keep it
|
||||
* up-to-date from time to time.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @param parent - The parent node of the input `node`.
|
||||
* @param grandparent - The grandparent node of the input `node`.
|
||||
* @returns True if the input `node` is a reference to a bound variable, false otherwise.
|
||||
*/
|
||||
declare function isReferenced(node: t.Node, parent: t.Node, grandparent?: t.Node): boolean;
|
||||
declare function isIdentifier(node?: t.Node | undefined | null): node is t.Identifier;
|
||||
declare function isStaticProperty(node?: t.Node | undefined | null): node is t.ObjectProperty;
|
||||
declare function isStaticPropertyKey(node: t.Node, parent: t.Node): boolean;
|
||||
declare function isForStatement(stmt: t.Node): stmt is t.ForStatement | t.ForOfStatement | t.ForInStatement;
|
||||
declare function isReferencedIdentifier(id: t.Identifier, parent: t.Node | null | undefined, parentStack: t.Node[]): boolean;
|
||||
declare function isInDestructureAssignment(parent: t.Node, parentStack: t.Node[]): boolean;
|
||||
declare function isInNewExpression(parentStack: t.Node[]): boolean;
|
||||
//#endregion
|
||||
//#region src/create.d.ts
|
||||
/**
|
||||
* Creates a string literal AST node.
|
||||
*
|
||||
* @param value - The value of the string literal.
|
||||
* @returns The string literal AST node.
|
||||
*/
|
||||
declare function createStringLiteral(value: string): t.StringLiteral;
|
||||
/**
|
||||
* Creates a TypeScript union type AST node.
|
||||
*
|
||||
* @param types - An array of TypeScript types.
|
||||
* @returns The TypeScript union type AST node.
|
||||
*/
|
||||
declare function createTSUnionType(types: t.TSType[]): t.TSUnionType;
|
||||
/**
|
||||
* Creates a TypeScript literal type AST node.
|
||||
*
|
||||
* @param literal - The literal value.
|
||||
* @returns The TypeScript literal type AST node.
|
||||
*/
|
||||
declare function createTSLiteralType(literal: t.TSLiteralType["literal"]): t.TSLiteralType;
|
||||
//#endregion
|
||||
//#region src/extract.d.ts
|
||||
/**
|
||||
* Extract identifiers of the given node.
|
||||
* @param node The node to extract.
|
||||
* @param identifiers The array to store the extracted identifiers.
|
||||
* @see https://github.com/vuejs/core/blob/1f6a1102aa09960f76a9af2872ef01e7da8538e3/packages/compiler-core/src/babelUtils.ts#L208
|
||||
*/
|
||||
declare function extractIdentifiers(node: t.Node, identifiers?: t.Identifier[]): t.Identifier[];
|
||||
//#endregion
|
||||
//#region src/lang.d.ts
|
||||
declare const REGEX_DTS: RegExp;
|
||||
declare const REGEX_LANG_TS: RegExp;
|
||||
declare const REGEX_LANG_JSX: RegExp;
|
||||
/**
|
||||
* Returns the language (extension name) of a given filename.
|
||||
* @param filename - The name of the file.
|
||||
* @returns The language of the file.
|
||||
*/
|
||||
declare function getLang(filename: string): string;
|
||||
/**
|
||||
* Checks if a filename represents a TypeScript declaration file (.d.ts).
|
||||
* @param filename - The name of the file to check.
|
||||
* @returns A boolean value indicating whether the filename is a TypeScript declaration file.
|
||||
*/
|
||||
declare function isDts(filename: string): boolean;
|
||||
/**
|
||||
* Checks if the given language (ts, mts, cjs, dts, tsx...) is TypeScript.
|
||||
* @param lang - The language to check.
|
||||
* @returns A boolean indicating whether the language is TypeScript.
|
||||
*/
|
||||
declare function isTs(lang?: string): boolean;
|
||||
//#endregion
|
||||
//#region src/loc.d.ts
|
||||
/**
|
||||
* Locates the trailing comma in the given code within the specified range.
|
||||
*
|
||||
* @param code - The code to search for the trailing comma.
|
||||
* @param start - The start index of the range to search within.
|
||||
* @param end - The end index of the range to search within.
|
||||
* @param comments - Optional array of comments to exclude from the search range.
|
||||
* @returns The index of the trailing comma, or -1 if not found.
|
||||
*/
|
||||
declare function locateTrailingComma(code: string, start: number, end: number, comments?: t.Comment[]): number;
|
||||
//#endregion
|
||||
//#region src/parse.d.ts
|
||||
/**
|
||||
* Gets the Babel parser options for the given language.
|
||||
* @param lang - The language of the code (optional).
|
||||
* @param options - The parser options (optional).
|
||||
* @returns The Babel parser options for the given language.
|
||||
*/
|
||||
declare function getBabelParserOptions(lang?: string, options?: ParserOptions): ParserOptions;
|
||||
/**
|
||||
* Parses the given code using Babel parser.
|
||||
*
|
||||
* @param code - The code to parse.
|
||||
* @param lang - The language of the code (optional).
|
||||
* @param options - The parser options (optional).
|
||||
* @param options.cache - Whether to cache the result (optional).
|
||||
* @returns The parse result, including the program, errors, and comments.
|
||||
*/
|
||||
declare function babelParse(code: string, lang?: string, {
|
||||
cache,
|
||||
...options
|
||||
}?: ParserOptions & {
|
||||
cache?: boolean;
|
||||
}): t.Program & Omit<ParseResult<t.File>, "type" | "program">;
|
||||
declare const parseCache: Map<string, ParseResult<t.File>>;
|
||||
/**
|
||||
* Parses the given code using the Babel parser as an expression.
|
||||
*
|
||||
* @template T - The type of the parsed AST node.
|
||||
* @param {string} code - The code to parse.
|
||||
* @param {string} [lang] - The language to parse. Defaults to undefined.
|
||||
* @param {ParserOptions} [options] - The options to configure the parser. Defaults to an empty object.
|
||||
* @returns {ParseResult<T>} - The result of the parsing operation.
|
||||
*/
|
||||
declare function babelParseExpression<T extends t.Node = t.Expression>(code: string, lang?: string, options?: ParserOptions): T & {
|
||||
errors: null | ParseError[];
|
||||
};
|
||||
//#endregion
|
||||
//#region src/resolve.d.ts
|
||||
/**
|
||||
* Resolves a string representation of the given node.
|
||||
* @param node The node to resolve.
|
||||
* @param computed Whether the node is computed or not.
|
||||
* @returns The resolved string representation of the node.
|
||||
*/
|
||||
declare function resolveString(node: string | t.Identifier | t.Literal | t.PrivateName | t.ThisExpression | t.Super, computed?: boolean): string;
|
||||
/**
|
||||
* Resolves the value of a literal node.
|
||||
* @param node The literal node to resolve.
|
||||
* @returns The resolved value of the literal node.
|
||||
*/
|
||||
declare function resolveLiteral(node: t.Literal): string | number | boolean | null | RegExp | bigint;
|
||||
/**
|
||||
* Resolves a template literal node into a string.
|
||||
* @param node The template literal node to resolve.
|
||||
* @returns The resolved string representation of the template literal.
|
||||
*/
|
||||
declare function resolveTemplateLiteral(node: t.TemplateLiteral): string;
|
||||
/**
|
||||
* Resolves the identifier node into an array of strings.
|
||||
* @param node The identifier node to resolve.
|
||||
* @returns An array of resolved strings representing the identifier.
|
||||
* @throws TypeError If the identifier is invalid.
|
||||
*/
|
||||
declare function resolveIdentifier(node: t.Identifier | t.PrivateName | t.MemberExpression | t.ThisExpression | t.Super | t.TSEntityName): string[];
|
||||
declare function tryResolveIdentifier(...args: Parameters<typeof resolveIdentifier>): string[] | undefined;
|
||||
type ObjectPropertyLike = t.ObjectMethod | t.ObjectProperty | t.TSMethodSignature | t.TSPropertySignature | t.ImportAttribute;
|
||||
/**
|
||||
* Resolves the key of an object property-like node.
|
||||
* @param node The object property-like node to resolve.
|
||||
* @param raw Whether to return the raw value of the key or not.
|
||||
* @returns The resolved key of the object property-like node.
|
||||
*/
|
||||
declare function resolveObjectKey(node: ObjectPropertyLike, raw?: false): string | number;
|
||||
declare function resolveObjectKey(node: ObjectPropertyLike, raw: true): string;
|
||||
//#endregion
|
||||
//#region src/scope.d.ts
|
||||
interface AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: {
|
||||
[key: string]: boolean;
|
||||
};
|
||||
addDeclaration: (node: Node, isBlockDeclaration: boolean, isVar: boolean) => void;
|
||||
contains: (name: string) => boolean;
|
||||
}
|
||||
type WithScope<T> = T & {
|
||||
scope?: AttachedScope;
|
||||
};
|
||||
/**
|
||||
* Options for creating a new scope.
|
||||
*/
|
||||
interface ScopeOptions {
|
||||
parent?: AttachedScope;
|
||||
block?: boolean;
|
||||
params?: Node[];
|
||||
}
|
||||
/**
|
||||
* Represents a scope.
|
||||
*/
|
||||
declare class Scope implements AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: {
|
||||
[key: string]: boolean;
|
||||
};
|
||||
constructor(options?: ScopeOptions);
|
||||
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void;
|
||||
contains(name: string): boolean;
|
||||
}
|
||||
/**
|
||||
* Attaches scopes to the given AST
|
||||
*
|
||||
* @param ast - The AST to attach scopes to.
|
||||
* @param propertyName - The name of the property to attach the scopes to. Default is 'scope'.
|
||||
* @returns The root scope of the AST.
|
||||
*/
|
||||
declare function attachScopes(ast: Node, propertyName?: string): Scope;
|
||||
//#endregion
|
||||
//#region src/types.d.ts
|
||||
/**
|
||||
* A type that represents a literal union.
|
||||
*/
|
||||
type LiteralUnion<LiteralType, BaseType extends null | undefined | string | number | boolean | symbol | bigint = string> = LiteralType | (BaseType & Record<never, never>);
|
||||
//#endregion
|
||||
//#region src/utils.d.ts
|
||||
declare const TS_NODE_TYPES: readonly ["TSAsExpression", "TSTypeAssertion", "TSNonNullExpression", "TSInstantiationExpression", "TSSatisfiesExpression"];
|
||||
/**
|
||||
* Unwraps a TypeScript node by recursively traversing the AST until a non-TypeScript node is found.
|
||||
* @param node - The TypeScript node to unwrap.
|
||||
* @returns The unwrapped node.
|
||||
*/
|
||||
declare function unwrapTSNode(node: t.Node): t.Node;
|
||||
/**
|
||||
* Escapes a raw key by checking if it needs to be wrapped with quotes or not.
|
||||
*
|
||||
* @param rawKey - The raw key to escape.
|
||||
* @returns The escaped key.
|
||||
*/
|
||||
declare function escapeKey(rawKey: string): string;
|
||||
//#endregion
|
||||
//#region src/walk.d.ts
|
||||
interface WalkThis<T> {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: T) => void;
|
||||
}
|
||||
type WalkCallback<T, R> = (this: WalkThis<T>, node: T, parent: T | null | undefined, key: string | null | undefined, index: number | null | undefined) => R;
|
||||
interface WalkHandlers<T, R> {
|
||||
enter?: WalkCallback<T, R>;
|
||||
leave?: WalkCallback<T, R>;
|
||||
}
|
||||
/**
|
||||
* Walks the AST and applies the provided handlers.
|
||||
*
|
||||
* @template T - The type of the AST node.
|
||||
* @param {T} node - The root node of the AST.
|
||||
* @param {WalkHandlers<T, void>} hooks - The handlers to be applied during the walk.
|
||||
* @returns {T | null} - The modified AST node or null if the node is removed.
|
||||
*/
|
||||
declare const walkAST: <T = t.Node>(node: NoInfer<T>, hooks: WalkHandlers<T, void>) => T | null;
|
||||
/**
|
||||
* Asynchronously walks the AST starting from the given node,
|
||||
* applying the provided handlers to each node encountered.
|
||||
*
|
||||
* @template T - The type of the AST node.
|
||||
* @param {T} node - The root node of the AST.
|
||||
* @param {WalkHandlers<T, Promise<void>>} handlers - The handlers to be applied to each node.
|
||||
* @returns {Promise<T | null>} - A promise that resolves to the modified AST or null if the AST is empty.
|
||||
*/
|
||||
declare const walkASTAsync: <T = t.Node>(node: NoInfer<T>, handlers: WalkHandlers<T, Promise<void>>) => Promise<T | null>;
|
||||
interface ImportBinding {
|
||||
local: string;
|
||||
imported: LiteralUnion<"*" | "default">;
|
||||
source: string;
|
||||
specifier: t.ImportSpecifier | t.ImportDefaultSpecifier | t.ImportNamespaceSpecifier;
|
||||
isType: boolean;
|
||||
}
|
||||
/**
|
||||
* Walks through an ImportDeclaration node and populates the provided imports object.
|
||||
*
|
||||
* @param imports - The object to store the import bindings.
|
||||
* @param node - The ImportDeclaration node to walk through.
|
||||
*/
|
||||
declare function walkImportDeclaration(imports: Record<string, ImportBinding>, node: t.ImportDeclaration): void;
|
||||
/**
|
||||
* Represents an export binding.
|
||||
*/
|
||||
interface ExportBinding {
|
||||
local: string;
|
||||
exported: LiteralUnion<"*" | "default">;
|
||||
isType: boolean;
|
||||
source: string | null;
|
||||
specifier: t.ExportSpecifier | t.ExportDefaultSpecifier | t.ExportNamespaceSpecifier | null;
|
||||
declaration: t.Declaration | t.ExportDefaultDeclaration["declaration"] | null;
|
||||
}
|
||||
/**
|
||||
* Walks through an ExportDeclaration node and populates the exports object with the relevant information.
|
||||
* @param exports - The object to store the export information.
|
||||
* @param node - The ExportDeclaration node to process.
|
||||
*/
|
||||
declare function walkExportDeclaration(exports: Record<string, ExportBinding>, node: t.ExportDeclaration): void;
|
||||
/**
|
||||
* Modified from https://github.com/vuejs/core/blob/main/packages/compiler-core/src/babelUtils.ts
|
||||
* To support browser environments and JSX.
|
||||
*
|
||||
* https://github.com/vuejs/core/blob/main/LICENSE
|
||||
*/
|
||||
/**
|
||||
* Return value indicates whether the AST walked can be a constant
|
||||
*/
|
||||
declare function walkIdentifiers(root: t.Node, onIdentifier: (node: t.Identifier, parent: t.Node | null | undefined, parentStack: t.Node[], isReference: boolean, isLocal: boolean) => void, includeAll?: boolean, parentStack?: t.Node[], knownIds?: Record<string, number>): void;
|
||||
declare function walkFunctionParams(node: t.Function, onIdent: (id: t.Identifier) => void): void;
|
||||
declare function walkBlockDeclarations(block: t.BlockStatement | t.Program, onIdent: (node: t.Identifier) => void): void;
|
||||
//#endregion
|
||||
export { AttachedScope, ExportBinding, GetNode, ImportBinding, LiteralUnion, NodeType, ObjectPropertyLike, REGEX_DTS, REGEX_LANG_JSX, REGEX_LANG_TS, Scope, ScopeOptions, TS_NODE_TYPES, WithScope, attachScopes, babelParse, babelParseExpression, parse as babelParseFile, createStringLiteral, createTSLiteralType, createTSUnionType, escapeKey, extractIdentifiers, getBabelParserOptions, getLang, isCallOf, isDeclarationType, isDts, isExpressionType, isForStatement, isFunctionType, isIdentifier, isIdentifierOf, isInDestructureAssignment, isInNewExpression, isLiteralType, isReferenced, isReferencedIdentifier, isStaticProperty, isStaticPropertyKey, isTaggedFunctionCallOf, isTs, isTypeOf, locateTrailingComma, parseCache, resolveIdentifier, resolveLiteral, resolveObjectKey, resolveString, resolveTemplateLiteral, tryResolveIdentifier, unwrapTSNode, walkAST, walkASTAsync, walkBlockDeclarations, walkExportDeclaration, walkFunctionParams, walkIdentifiers, walkImportDeclaration };
|
||||
1205
node_modules/ast-kit/dist/index.js
generated
vendored
Normal file
1205
node_modules/ast-kit/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
node_modules/ast-kit/node_modules/pathe/LICENSE
generated
vendored
Normal file
70
node_modules/ast-kit/node_modules/pathe/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Copyright Joyent, Inc. and other Node 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.
|
||||
|
||||
---
|
||||
|
||||
Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2023-present Fabio Spampinato
|
||||
|
||||
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.
|
||||
73
node_modules/ast-kit/node_modules/pathe/README.md
generated
vendored
Normal file
73
node_modules/ast-kit/node_modules/pathe/README.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# 🛣️ pathe
|
||||
|
||||
> Universal filesystem path utils
|
||||
|
||||
[![version][npm-v-src]][npm-v-href]
|
||||
[![downloads][npm-d-src]][npm-d-href]
|
||||
[![size][size-src]][size-href]
|
||||
|
||||
## ❓ Why
|
||||
|
||||
For [historical reasons](https://docs.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character), windows followed MS-DOS and used backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, [Windows](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN) supports both Slash and Backslash for paths. [Node.js's built-in `path` module](https://nodejs.org/api/path.html) in the default operation of the path module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the path module will assume that Windows-style paths are being used. **This makes inconsistent code behavior between Windows and POSIX.**
|
||||
|
||||
Compared to popular [upath](https://github.com/anodynos/upath), pathe provides **identical exports** of Node.js with normalization on **all operations** and is written in modern **ESM/TypeScript** and has **no dependency on Node.js**!
|
||||
|
||||
This package is a drop-in replacement of the Node.js's [path module](https://nodejs.org/api/path.html) module and ensures paths are normalized with slash `/` and work in environments including Node.js.
|
||||
|
||||
## 💿 Usage
|
||||
|
||||
Install using npm or yarn:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm i pathe
|
||||
|
||||
# yarn
|
||||
yarn add pathe
|
||||
|
||||
# pnpm
|
||||
pnpm i pathe
|
||||
```
|
||||
|
||||
Import:
|
||||
|
||||
```js
|
||||
// ESM / Typescript
|
||||
import { resolve, matchesGlob } from "pathe";
|
||||
|
||||
// CommonJS
|
||||
const { resolve, matchesGlob } = require("pathe");
|
||||
```
|
||||
|
||||
Read more about path utils from [Node.js documentation](https://nodejs.org/api/path.html) and rest assured behavior is consistently like POSIX regardless of your input paths format and running platform (the only exception is `delimiter` constant export, it will be set to `;` on windows platform).
|
||||
|
||||
### Extra utilities
|
||||
|
||||
Pathe exports some extra utilities that do not exist in standard Node.js [path module](https://nodejs.org/api/path.html).
|
||||
In order to use them, you can import from `pathe/utils` subpath:
|
||||
|
||||
```js
|
||||
import {
|
||||
filename,
|
||||
normalizeAliases,
|
||||
resolveAlias,
|
||||
reverseResolveAlias,
|
||||
} from "pathe/utils";
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Made with 💛 Published under the [MIT](./LICENSE) license.
|
||||
|
||||
Some code was used from the Node.js project. Glob supported is powered by [zeptomatch](https://github.com/fabiospampinato/zeptomatch).
|
||||
|
||||
<!-- Refs -->
|
||||
|
||||
[npm-v-src]: https://img.shields.io/npm/v/pathe?style=flat-square
|
||||
[npm-v-href]: https://npmjs.com/package/pathe
|
||||
[npm-d-src]: https://img.shields.io/npm/dm/pathe?style=flat-square
|
||||
[npm-d-href]: https://npmjs.com/package/pathe
|
||||
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/pathe/ci/main?style=flat-square
|
||||
[github-actions-href]: https://github.com/unjs/pathe/actions?query=workflow%3Aci
|
||||
[size-src]: https://packagephobia.now.sh/badge?p=pathe
|
||||
[size-href]: https://packagephobia.now.sh/result?p=pathe
|
||||
39
node_modules/ast-kit/node_modules/pathe/dist/index.cjs
generated
vendored
Normal file
39
node_modules/ast-kit/node_modules/pathe/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const _path = require('./shared/pathe.BSlhyZSM.cjs');
|
||||
|
||||
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
||||
const _platforms = { posix: void 0, win32: void 0 };
|
||||
const mix = (del = delimiter) => {
|
||||
return new Proxy(_path._path, {
|
||||
get(_, prop) {
|
||||
if (prop === "delimiter") return del;
|
||||
if (prop === "posix") return posix;
|
||||
if (prop === "win32") return win32;
|
||||
return _platforms[prop] || _path._path[prop];
|
||||
}
|
||||
});
|
||||
};
|
||||
const posix = /* @__PURE__ */ mix(":");
|
||||
const win32 = /* @__PURE__ */ mix(";");
|
||||
|
||||
exports.basename = _path.basename;
|
||||
exports.dirname = _path.dirname;
|
||||
exports.extname = _path.extname;
|
||||
exports.format = _path.format;
|
||||
exports.isAbsolute = _path.isAbsolute;
|
||||
exports.join = _path.join;
|
||||
exports.matchesGlob = _path.matchesGlob;
|
||||
exports.normalize = _path.normalize;
|
||||
exports.normalizeString = _path.normalizeString;
|
||||
exports.parse = _path.parse;
|
||||
exports.relative = _path.relative;
|
||||
exports.resolve = _path.resolve;
|
||||
exports.sep = _path.sep;
|
||||
exports.toNamespacedPath = _path.toNamespacedPath;
|
||||
exports.default = posix;
|
||||
exports.delimiter = delimiter;
|
||||
exports.posix = posix;
|
||||
exports.win32 = win32;
|
||||
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.cts
generated
vendored
Normal file
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.mts
generated
vendored
Normal file
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.ts
generated
vendored
Normal file
47
node_modules/ast-kit/node_modules/pathe/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
19
node_modules/ast-kit/node_modules/pathe/dist/index.mjs
generated
vendored
Normal file
19
node_modules/ast-kit/node_modules/pathe/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { _ as _path } from './shared/pathe.M-eThtNZ.mjs';
|
||||
export { c as basename, d as dirname, e as extname, f as format, i as isAbsolute, j as join, m as matchesGlob, n as normalize, a as normalizeString, p as parse, b as relative, r as resolve, s as sep, t as toNamespacedPath } from './shared/pathe.M-eThtNZ.mjs';
|
||||
|
||||
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
||||
const _platforms = { posix: void 0, win32: void 0 };
|
||||
const mix = (del = delimiter) => {
|
||||
return new Proxy(_path, {
|
||||
get(_, prop) {
|
||||
if (prop === "delimiter") return del;
|
||||
if (prop === "posix") return posix;
|
||||
if (prop === "win32") return win32;
|
||||
return _platforms[prop] || _path[prop];
|
||||
}
|
||||
});
|
||||
};
|
||||
const posix = /* @__PURE__ */ mix(":");
|
||||
const win32 = /* @__PURE__ */ mix(";");
|
||||
|
||||
export { posix as default, delimiter, posix, win32 };
|
||||
266
node_modules/ast-kit/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs
generated
vendored
Normal file
266
node_modules/ast-kit/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
249
node_modules/ast-kit/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
generated
vendored
Normal file
249
node_modules/ast-kit/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
82
node_modules/ast-kit/node_modules/pathe/dist/utils.cjs
generated
vendored
Normal file
82
node_modules/ast-kit/node_modules/pathe/dist/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const _path = require('./shared/pathe.BSlhyZSM.cjs');
|
||||
|
||||
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
|
||||
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
||||
const SLASH_RE = /[/\\]/;
|
||||
function normalizeAliases(_aliases) {
|
||||
if (_aliases[normalizedAliasSymbol]) {
|
||||
return _aliases;
|
||||
}
|
||||
const aliases = Object.fromEntries(
|
||||
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
|
||||
);
|
||||
for (const key in aliases) {
|
||||
for (const alias in aliases) {
|
||||
if (alias === key || key.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
|
||||
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
||||
value: true,
|
||||
enumerable: false
|
||||
});
|
||||
return aliases;
|
||||
}
|
||||
function resolveAlias(path, aliases) {
|
||||
const _path$1 = _path.normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
for (const [alias, to] of Object.entries(aliases)) {
|
||||
if (!_path$1.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path$1[_alias.length])) {
|
||||
return _path.join(to, _path$1.slice(alias.length));
|
||||
}
|
||||
}
|
||||
return _path$1;
|
||||
}
|
||||
function reverseResolveAlias(path, aliases) {
|
||||
const _path$1 = _path.normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
const matches = [];
|
||||
for (const [to, alias] of Object.entries(aliases)) {
|
||||
if (!_path$1.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path$1[_alias.length])) {
|
||||
matches.push(_path.join(to, _path$1.slice(alias.length)));
|
||||
}
|
||||
}
|
||||
return matches.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
function filename(path) {
|
||||
const base = path.split(SLASH_RE).pop();
|
||||
if (!base) {
|
||||
return void 0;
|
||||
}
|
||||
const separatorIndex = base.lastIndexOf(".");
|
||||
if (separatorIndex <= 0) {
|
||||
return base;
|
||||
}
|
||||
return base.slice(0, separatorIndex);
|
||||
}
|
||||
function _compareAliases(a, b) {
|
||||
return b.split("/").length - a.split("/").length;
|
||||
}
|
||||
function hasTrailingSlash(path = "/") {
|
||||
const lastChar = path[path.length - 1];
|
||||
return lastChar === "/" || lastChar === "\\";
|
||||
}
|
||||
|
||||
exports.filename = filename;
|
||||
exports.normalizeAliases = normalizeAliases;
|
||||
exports.resolveAlias = resolveAlias;
|
||||
exports.reverseResolveAlias = reverseResolveAlias;
|
||||
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.cts
generated
vendored
Normal file
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.cts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.mts
generated
vendored
Normal file
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.mts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.ts
generated
vendored
Normal file
32
node_modules/ast-kit/node_modules/pathe/dist/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
77
node_modules/ast-kit/node_modules/pathe/dist/utils.mjs
generated
vendored
Normal file
77
node_modules/ast-kit/node_modules/pathe/dist/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import { g as normalizeWindowsPath, j as join } from './shared/pathe.M-eThtNZ.mjs';
|
||||
|
||||
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
|
||||
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
||||
const SLASH_RE = /[/\\]/;
|
||||
function normalizeAliases(_aliases) {
|
||||
if (_aliases[normalizedAliasSymbol]) {
|
||||
return _aliases;
|
||||
}
|
||||
const aliases = Object.fromEntries(
|
||||
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
|
||||
);
|
||||
for (const key in aliases) {
|
||||
for (const alias in aliases) {
|
||||
if (alias === key || key.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
|
||||
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
||||
value: true,
|
||||
enumerable: false
|
||||
});
|
||||
return aliases;
|
||||
}
|
||||
function resolveAlias(path, aliases) {
|
||||
const _path = normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
for (const [alias, to] of Object.entries(aliases)) {
|
||||
if (!_path.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path[_alias.length])) {
|
||||
return join(to, _path.slice(alias.length));
|
||||
}
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
function reverseResolveAlias(path, aliases) {
|
||||
const _path = normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
const matches = [];
|
||||
for (const [to, alias] of Object.entries(aliases)) {
|
||||
if (!_path.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path[_alias.length])) {
|
||||
matches.push(join(to, _path.slice(alias.length)));
|
||||
}
|
||||
}
|
||||
return matches.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
function filename(path) {
|
||||
const base = path.split(SLASH_RE).pop();
|
||||
if (!base) {
|
||||
return void 0;
|
||||
}
|
||||
const separatorIndex = base.lastIndexOf(".");
|
||||
if (separatorIndex <= 0) {
|
||||
return base;
|
||||
}
|
||||
return base.slice(0, separatorIndex);
|
||||
}
|
||||
function _compareAliases(a, b) {
|
||||
return b.split("/").length - a.split("/").length;
|
||||
}
|
||||
function hasTrailingSlash(path = "/") {
|
||||
const lastChar = path[path.length - 1];
|
||||
return lastChar === "/" || lastChar === "\\";
|
||||
}
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
61
node_modules/ast-kit/node_modules/pathe/package.json
generated
vendored
Normal file
61
node_modules/ast-kit/node_modules/pathe/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "pathe",
|
||||
"version": "2.0.3",
|
||||
"description": "Universal filesystem path utils",
|
||||
"repository": "unjs/pathe",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"./utils": {
|
||||
"import": {
|
||||
"types": "./dist/utils.d.mts",
|
||||
"default": "./dist/utils.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/utils.d.cts",
|
||||
"default": "./dist/utils.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"utils.d.ts"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.13.1",
|
||||
"@vitest/coverage-v8": "^3.0.5",
|
||||
"changelogen": "^0.5.7",
|
||||
"esbuild": "^0.25.0",
|
||||
"eslint": "^9.20.1",
|
||||
"eslint-config-unjs": "^0.4.2",
|
||||
"jiti": "^2.4.2",
|
||||
"prettier": "^3.5.0",
|
||||
"typescript": "^5.7.3",
|
||||
"unbuild": "^3.3.1",
|
||||
"vitest": "^3.0.5",
|
||||
"zeptomatch": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "vitest",
|
||||
"lint": "eslint . && prettier -c src test",
|
||||
"lint:fix": "eslint . --fix && prettier -w src test",
|
||||
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
||||
"test": "pnpm lint && vitest run --coverage",
|
||||
"test:types": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
1
node_modules/ast-kit/node_modules/pathe/utils.d.ts
generated
vendored
Normal file
1
node_modules/ast-kit/node_modules/pathe/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/utils";
|
||||
63
node_modules/ast-kit/package.json
generated
vendored
Normal file
63
node_modules/ast-kit/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "ast-kit",
|
||||
"version": "2.2.0",
|
||||
"description": "A toolkit for easy Babel AST generation and manipulation.",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/sxzz/ast-kit#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sxzz/ast-kit/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sxzz/ast-kit.git"
|
||||
},
|
||||
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
||||
"funding": "https://github.com/sponsors/sxzz",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.28.5",
|
||||
"pathe": "^2.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/types": "^7.28.5",
|
||||
"@sxzz/eslint-config": "^7.2.8",
|
||||
"@sxzz/prettier-config": "^2.2.4",
|
||||
"@types/node": "^24.10.0",
|
||||
"@vitest/coverage-v8": "^4.0.8",
|
||||
"@vitest/ui": "^4.0.8",
|
||||
"bumpp": "^10.3.1",
|
||||
"eslint": "^9.39.1",
|
||||
"estree-walker": "^3.0.3",
|
||||
"fast-glob": "^3.3.3",
|
||||
"prettier": "^3.6.2",
|
||||
"tsdown": "^0.16.1",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "5.9.3",
|
||||
"vitest": "^4.0.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"prettier": "@sxzz/prettier-config",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "pnpm run lint --fix",
|
||||
"build": "tsdown",
|
||||
"test": "vitest",
|
||||
"release": "bumpp",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user