Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/magicast/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/magicast/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io> and Anthony Fu <https://github.com/antfu>
|
||||
|
||||
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.
|
||||
202
Frontend-Learner/node_modules/magicast/README.md
generated
vendored
Normal file
202
Frontend-Learner/node_modules/magicast/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
# 🧀 Magicast
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![bundle][bundle-src]][bundle-href]
|
||||
[![Codecov][codecov-src]][codecov-href]
|
||||
[![License][license-src]][license-href]
|
||||
[![JSDocs][jsdocs-src]][jsdocs-href]
|
||||
|
||||
Programmatically modify JavaScript and TypeScript source codes with a simplified, elegant and familiar syntax. Built on top of the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) parsed by [recast](https://github.com/benjamn/recast) and [babel](https://babeljs.io/).
|
||||
|
||||
❯ 🧙🏼 **Magical** modify a JS/TS file and write back magically just like JSON!<br>
|
||||
❯ 🔀 **Exports/Import** manipulate module's imports and exports at ease<br>
|
||||
❯ 💼 **Function Arguments** easily manipulate arguments passed to a function call, like `defineConfig()`<br>
|
||||
❯ 🎨 **Smart Formatting** preseves the formatting style (quotes, tabs, etc.) from the original code<br>
|
||||
❯ 🧑💻 **Readable** get rid of the complexity of AST manipulation and make your code super readable<br>
|
||||
|
||||
## Install
|
||||
|
||||
Install npm package:
|
||||
|
||||
```sh
|
||||
yarn add --dev magicast
|
||||
|
||||
npm install -D magicast
|
||||
|
||||
pnpm add -D magicast
|
||||
```
|
||||
|
||||
Import utilities:
|
||||
|
||||
```js
|
||||
import { parseModule, generateCode, builders, createNode } from "magicast";
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
**Example:** Modify a file:
|
||||
|
||||
`config.js`:
|
||||
|
||||
```js
|
||||
export default {
|
||||
foo: ["a"],
|
||||
};
|
||||
```
|
||||
|
||||
Code to modify and append `b` to `foo` prop of defaultExport:
|
||||
|
||||
```js
|
||||
import { loadFile, writeFile } from "magicast";
|
||||
|
||||
const mod = await loadFile("config.js");
|
||||
|
||||
mod.exports.default.foo.push("b");
|
||||
|
||||
await writeFile(mod, "config.js");
|
||||
```
|
||||
|
||||
Updated `config.js`:
|
||||
|
||||
```js
|
||||
export default {
|
||||
foo: ["a", "b"],
|
||||
};
|
||||
```
|
||||
|
||||
**Example:** Directly use AST utils:
|
||||
|
||||
```js
|
||||
import { parseModule, generateCode } from "magicast";
|
||||
|
||||
// Parse to AST
|
||||
const mod = parseModule(`export default { }`);
|
||||
|
||||
// Ensure foo is an array
|
||||
mod.exports.default.foo ||= [];
|
||||
// Add a new array member
|
||||
mod.exports.default.foo.push("b");
|
||||
mod.exports.default.foo.unshift("a");
|
||||
|
||||
// Generate code
|
||||
const { code, map } = generateCode(mod);
|
||||
```
|
||||
|
||||
Generated code:
|
||||
|
||||
```js
|
||||
export default {
|
||||
foo: ["a", "b"],
|
||||
};
|
||||
```
|
||||
|
||||
**Example:** Get the AST directly:
|
||||
|
||||
```js
|
||||
import { parseModule, generateCode } from "magicast";
|
||||
|
||||
const mod = parseModule(`export default { }`);
|
||||
|
||||
const ast = mod.exports.default.$ast;
|
||||
// do something with ast
|
||||
```
|
||||
|
||||
**Example:** Function arguments:
|
||||
|
||||
```js
|
||||
import { parseModule, generateCode } from "magicast";
|
||||
|
||||
const mod = parseModule(`export default defineConfig({ foo: 'bar' })`);
|
||||
|
||||
// Support for both bare object export and `defineConfig` wrapper
|
||||
const options =
|
||||
mod.exports.default.$type === "function-call"
|
||||
? mod.exports.default.$args[0]
|
||||
: mod.exports.default;
|
||||
|
||||
console.log(options.foo); // bar
|
||||
```
|
||||
|
||||
**Example:** Create a function call:
|
||||
|
||||
```js
|
||||
import { parseModule, generateCode, builders } from "magicast";
|
||||
|
||||
const mod = parseModule(`export default {}`);
|
||||
|
||||
const options = (mod.exports.default.list = builders.functionCall(
|
||||
"create",
|
||||
[1, 2, 3],
|
||||
));
|
||||
|
||||
console.log(mod.generateCode()); // export default { list: create([1, 2, 3]) }
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
As JavaScript is a very dynamic language, you should be aware that Magicast's convention **CAN NOT cover all possible cases**. Magicast serves as a simple and maintainable interface to update static-ish JavaScript code. When interacting with Magicast node, be aware that every option might have chance to throw an error depending on the input code. We recommend to always wrap the code in a `try/catch` block (even better to do some defensive coding), for example:
|
||||
|
||||
```ts
|
||||
import { loadFile, writeFile } from "magicast";
|
||||
|
||||
function updateConfig() {
|
||||
try {
|
||||
const mod = await loadFile("config.js");
|
||||
|
||||
mod.exports.default.foo.push("b");
|
||||
|
||||
await writeFile(mod);
|
||||
} catch {
|
||||
console.error("Unable to update config.js");
|
||||
console.error(
|
||||
"Please update it manually with the following instructions: ...",
|
||||
);
|
||||
// handle error
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## High Level Helpers
|
||||
|
||||
We also experiment to provide a few high level helpers to make common tasks easier. You could import them from `magicast/helpers`. They might be moved to a separate package in the future.
|
||||
|
||||
```js
|
||||
import {
|
||||
deepMergeObject,
|
||||
addNuxtModule,
|
||||
addVitePlugin,
|
||||
// ...
|
||||
} from "magicast/helpers";
|
||||
```
|
||||
|
||||
We recommend to check out the [source code](./src/helpers) and [test cases](./test/helpers) for more details.
|
||||
|
||||
## Development
|
||||
|
||||
- Clone this repository
|
||||
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
|
||||
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
|
||||
- Install dependencies using `pnpm install`
|
||||
- Run interactive tests using `pnpm dev`
|
||||
|
||||
## License
|
||||
|
||||
Made with 💛
|
||||
|
||||
Published under [MIT License](./LICENSE).
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/magicast?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-version-href]: https://npmjs.com/package/magicast
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/magicast?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-downloads-href]: https://npmjs.com/package/magicast
|
||||
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/magicast/main?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[codecov-href]: https://codecov.io/gh/unjs/magicast
|
||||
[bundle-src]: https://img.shields.io/bundlephobia/minzip/magicast?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[bundle-href]: https://bundlephobia.com/result?p=magicast
|
||||
[license-src]: https://img.shields.io/github/license/unjs/magicast.svg?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[license-href]: https://github.com/unjs/magicast/blob/main/LICENSE
|
||||
[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[jsdocs-href]: https://www.jsdocs.io/package/magicast
|
||||
8580
Frontend-Learner/node_modules/magicast/dist/builders-hKD4IrLX.js
generated
vendored
Normal file
8580
Frontend-Learner/node_modules/magicast/dist/builders-hKD4IrLX.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
74
Frontend-Learner/node_modules/magicast/dist/helpers/index.d.ts
generated
vendored
Normal file
74
Frontend-Learner/node_modules/magicast/dist/helpers/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { S as ProxifiedObject, b as ProxifiedModule, c as Proxified, p as ProxifiedFunctionCall } from "../types-CQa2aD_O.js";
|
||||
import { VariableDeclarator } from "@babel/types";
|
||||
|
||||
//#region src/helpers/deep-merge.d.ts
|
||||
declare function deepMergeObject(magicast: Proxified<any>, object: any): void;
|
||||
//#endregion
|
||||
//#region src/helpers/nuxt.d.ts
|
||||
declare function addNuxtModule(magicast: ProxifiedModule<any>, name: string, optionsKey?: string, options?: any): void;
|
||||
//#endregion
|
||||
//#region src/helpers/vite.d.ts
|
||||
interface AddVitePluginOptions {
|
||||
/**
|
||||
* The import path of the plugin
|
||||
*/
|
||||
from: string;
|
||||
/**
|
||||
* The import name of the plugin
|
||||
* @default "default"
|
||||
*/
|
||||
imported?: string;
|
||||
/**
|
||||
* The name of local variable
|
||||
*/
|
||||
constructor: string;
|
||||
/**
|
||||
* The options of the plugin
|
||||
*/
|
||||
options?: Record<string, any>;
|
||||
/**
|
||||
* The index in the plugins array where the plugin should be inserted at.
|
||||
* By default, the plugin is appended to the array.
|
||||
*/
|
||||
index?: number;
|
||||
}
|
||||
interface UpdateVitePluginConfigOptions {
|
||||
/**
|
||||
* The import path of the plugin
|
||||
*/
|
||||
from: string;
|
||||
/**
|
||||
* The import name of the plugin
|
||||
* @default "default"
|
||||
*/
|
||||
imported?: string;
|
||||
}
|
||||
declare function addVitePlugin(magicast: ProxifiedModule<any>, plugin: AddVitePluginOptions): boolean;
|
||||
declare function findVitePluginCall(magicast: ProxifiedModule<any>, plugin: UpdateVitePluginConfigOptions | string): ProxifiedFunctionCall | undefined;
|
||||
declare function updateVitePluginConfig(magicast: ProxifiedModule<any>, plugin: UpdateVitePluginConfigOptions | string, handler: Record<string, any> | ((args: any[]) => any[])): boolean;
|
||||
//#endregion
|
||||
//#region src/helpers/config.d.ts
|
||||
declare function getDefaultExportOptions(magicast: ProxifiedModule<any>): ProxifiedObject<any>;
|
||||
/**
|
||||
* Returns the vite config object from a variable declaration thats
|
||||
* exported as the default export.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const config = {};
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* @param magicast the module
|
||||
*
|
||||
* @returns an object containing the proxified config object and the
|
||||
* declaration "parent" to attach the modified config to later.
|
||||
* If no config declaration is found, undefined is returned.
|
||||
*/
|
||||
declare function getConfigFromVariableDeclaration(magicast: ProxifiedModule<any>): {
|
||||
declaration: VariableDeclarator;
|
||||
config: ProxifiedObject<any> | undefined;
|
||||
};
|
||||
//#endregion
|
||||
export { AddVitePluginOptions, UpdateVitePluginConfigOptions, addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };
|
||||
120
Frontend-Learner/node_modules/magicast/dist/helpers/index.js
generated
vendored
Normal file
120
Frontend-Learner/node_modules/magicast/dist/helpers/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import { c as MagicastError, i as parseExpression, n as generateCode, t as builders } from "../builders-hKD4IrLX.js";
|
||||
|
||||
//#region src/helpers/deep-merge.ts
|
||||
function deepMergeObject(magicast, object) {
|
||||
if (typeof object === "object" && object !== null) for (const key in object) {
|
||||
const magicastValue = magicast[key];
|
||||
const objectValue = object[key];
|
||||
if (magicastValue === objectValue) continue;
|
||||
if (typeof magicastValue === "object" && magicastValue !== null && typeof objectValue === "object" && objectValue !== null) deepMergeObject(magicastValue, objectValue);
|
||||
else magicast[key] = objectValue;
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/helpers/config.ts
|
||||
function getDefaultExportOptions(magicast) {
|
||||
return configFromNode(magicast.exports.default);
|
||||
}
|
||||
/**
|
||||
* Returns the vite config object from a variable declaration thats
|
||||
* exported as the default export.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const config = {};
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* @param magicast the module
|
||||
*
|
||||
* @returns an object containing the proxified config object and the
|
||||
* declaration "parent" to attach the modified config to later.
|
||||
* If no config declaration is found, undefined is returned.
|
||||
*/
|
||||
function getConfigFromVariableDeclaration(magicast) {
|
||||
if (magicast.exports.default.$type !== "identifier") throw new MagicastError(`Not supported: Cannot modify this kind of default export (${magicast.exports.default.$type})`);
|
||||
const configDecalarationId = magicast.exports.default.$name;
|
||||
for (const node of magicast.$ast.body) if (node.type === "VariableDeclaration") {
|
||||
for (const declaration of node.declarations) if (declaration.id.type === "Identifier" && declaration.id.name === configDecalarationId && declaration.init) {
|
||||
const code = generateCode(declaration.init.type === "TSSatisfiesExpression" ? declaration.init.expression : declaration.init).code;
|
||||
return {
|
||||
declaration,
|
||||
config: configFromNode(parseExpression(code))
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new MagicastError("Couldn't find config declaration");
|
||||
}
|
||||
function configFromNode(node) {
|
||||
if (node.$type === "function-call") return node.$args[0];
|
||||
return node;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/helpers/nuxt.ts
|
||||
function addNuxtModule(magicast, name, optionsKey, options) {
|
||||
const config = getDefaultExportOptions(magicast);
|
||||
config.modules ||= [];
|
||||
if (!config.modules.includes(name)) config.modules.push(name);
|
||||
if (optionsKey) {
|
||||
config[optionsKey] ||= {};
|
||||
deepMergeObject(config[optionsKey], options);
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/helpers/vite.ts
|
||||
function addVitePlugin(magicast, plugin) {
|
||||
const config = getDefaultExportOptions(magicast);
|
||||
if (config.$type === "identifier") insertPluginIntoVariableDeclarationConfig(magicast, plugin);
|
||||
else insertPluginIntoConfig(plugin, config);
|
||||
magicast.imports.$prepend({
|
||||
from: plugin.from,
|
||||
local: plugin.constructor,
|
||||
imported: plugin.imported || "default"
|
||||
});
|
||||
return true;
|
||||
}
|
||||
function findVitePluginCall(magicast, plugin) {
|
||||
const _plugin = typeof plugin === "string" ? {
|
||||
from: plugin,
|
||||
imported: "default"
|
||||
} : plugin;
|
||||
const config = getDefaultExportOptions(magicast);
|
||||
const constructor = magicast.imports.$items.find((i) => i.from === _plugin.from && i.imported === (_plugin.imported || "default"))?.local;
|
||||
return config.plugins?.find((p) => p && p.$type === "function-call" && p.$callee === constructor);
|
||||
}
|
||||
function updateVitePluginConfig(magicast, plugin, handler) {
|
||||
const item = findVitePluginCall(magicast, plugin);
|
||||
if (!item) return false;
|
||||
if (typeof handler === "function") item.$args = handler(item.$args);
|
||||
else if (item.$args[0]) deepMergeObject(item.$args[0], handler);
|
||||
else item.$args[0] = handler;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Insert @param plugin into a config object that's declared as a variable in
|
||||
* the module (@param magicast).
|
||||
*/
|
||||
function insertPluginIntoVariableDeclarationConfig(magicast, plugin) {
|
||||
const { config: configObject, declaration } = getConfigFromVariableDeclaration(magicast);
|
||||
insertPluginIntoConfig(plugin, configObject);
|
||||
if (declaration.init) {
|
||||
if (declaration.init.type === "ObjectExpression") declaration.init = generateCode(configObject).code;
|
||||
else if (declaration.init.type === "CallExpression" && declaration.init.callee.type === "Identifier") declaration.init = generateCode(builders.functionCall(declaration.init.callee.name, configObject)).code;
|
||||
else if (declaration.init.type === "TSSatisfiesExpression") {
|
||||
if (declaration.init.expression.type === "ObjectExpression") declaration.init.expression = generateCode(configObject).code;
|
||||
if (declaration.init.expression.type === "CallExpression" && declaration.init.expression.callee.type === "Identifier") declaration.init.expression = generateCode(builders.functionCall(declaration.init.expression.callee.name, configObject)).code;
|
||||
}
|
||||
}
|
||||
}
|
||||
function insertPluginIntoConfig(plugin, config) {
|
||||
const insertionIndex = plugin.index ?? config.plugins?.length ?? 0;
|
||||
config.plugins ||= [];
|
||||
config.plugins.splice(insertionIndex, 0, plugin.options ? builders.functionCall(plugin.constructor, plugin.options) : builders.functionCall(plugin.constructor));
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };
|
||||
57
Frontend-Learner/node_modules/magicast/dist/index.d.ts
generated
vendored
Normal file
57
Frontend-Learner/node_modules/magicast/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { C as ProxifiedValue, D as detectCodeFormat, E as CodeFormatOptions, O as Options, S as ProxifiedObject, T as ProxyType, _ as ProxifiedImportsMap, a as Token, b as ProxifiedModule, c as Proxified, d as ProxifiedBinaryExpression, f as ProxifiedBlockStatement, g as ProxifiedImportItem, h as ProxifiedIdentifier, i as ParsedFileNode, l as ProxifiedArray, m as ProxifiedFunctionExpression, n as GenerateOptions, o as BinaryOperator, p as ProxifiedFunctionCall, r as Loc, s as ImportItemInput, t as ASTNode, u as ProxifiedArrowFunctionExpression, v as ProxifiedLogicalExpression, w as ProxyBase, x as ProxifiedNewExpression, y as ProxifiedMemberExpression } from "./types-CQa2aD_O.js";
|
||||
|
||||
//#region src/code.d.ts
|
||||
declare function parseModule<Exports extends object = any>(code: string, options?: Options): ProxifiedModule<Exports>;
|
||||
declare function parseExpression<T>(code: string, options?: Options): Proxified<T>;
|
||||
declare function generateCode(node: {
|
||||
$ast: ASTNode;
|
||||
} | ASTNode | ProxifiedModule<any>, options?: GenerateOptions): {
|
||||
code: string;
|
||||
map?: any;
|
||||
};
|
||||
declare function loadFile<Exports extends object = any>(filename: string, options?: Options): Promise<ProxifiedModule<Exports>>;
|
||||
declare function writeFile(node: {
|
||||
$ast: ASTNode;
|
||||
} | ASTNode, filename: string, options?: Options): Promise<void>;
|
||||
//#endregion
|
||||
//#region src/error.d.ts
|
||||
interface MagicastErrorOptions {
|
||||
ast?: ASTNode;
|
||||
code?: string;
|
||||
}
|
||||
declare class MagicastError extends Error {
|
||||
rawMessage: string;
|
||||
options?: MagicastErrorOptions;
|
||||
constructor(message: string, options?: MagicastErrorOptions);
|
||||
}
|
||||
//#endregion
|
||||
//#region src/builders.d.ts
|
||||
declare const builders: {
|
||||
/**
|
||||
* Create a function call node.
|
||||
*/
|
||||
functionCall(callee: string, ...args: any[]): Proxified;
|
||||
/**
|
||||
* Create a new expression node.
|
||||
*/
|
||||
newExpression(callee: string, ...args: any[]): Proxified;
|
||||
/**
|
||||
* Create a binary expression node.
|
||||
*/
|
||||
binaryExpression(left: any, operator: "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "&" | "|" | "^" | "in" | "instanceof" | "**", right: any): Proxified;
|
||||
/**
|
||||
* Create a proxified version of a literal value.
|
||||
*/
|
||||
literal(value: any): Proxified;
|
||||
/**
|
||||
* Parse a raw expression and return a proxified version of it.
|
||||
*
|
||||
* ```ts
|
||||
* const obj = builders.raw("{ foo: 1 }");
|
||||
* console.log(obj.foo); // 1
|
||||
* ```
|
||||
*/
|
||||
raw(code: string): Proxified;
|
||||
};
|
||||
//#endregion
|
||||
export { ASTNode, BinaryOperator, CodeFormatOptions, GenerateOptions, ImportItemInput, Loc, MagicastError, MagicastErrorOptions, ParsedFileNode, Proxified, ProxifiedArray, ProxifiedArrowFunctionExpression, ProxifiedBinaryExpression, ProxifiedBlockStatement, ProxifiedFunctionCall, ProxifiedFunctionExpression, ProxifiedIdentifier, ProxifiedImportItem, ProxifiedImportsMap, ProxifiedLogicalExpression, ProxifiedMemberExpression, ProxifiedModule, ProxifiedNewExpression, ProxifiedObject, ProxifiedValue, ProxyBase, ProxyType, Token, builders, detectCodeFormat, generateCode, loadFile, parseExpression, parseModule, writeFile };
|
||||
3
Frontend-Learner/node_modules/magicast/dist/index.js
generated
vendored
Normal file
3
Frontend-Learner/node_modules/magicast/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { a as parseModule, c as MagicastError, i as parseExpression, n as generateCode, o as writeFile, r as loadFile, s as detectCodeFormat, t as builders } from "./builders-hKD4IrLX.js";
|
||||
|
||||
export { MagicastError, builders, detectCodeFormat, generateCode, loadFile, parseExpression, parseModule, writeFile };
|
||||
283
Frontend-Learner/node_modules/magicast/dist/types-CQa2aD_O.d.ts
generated
vendored
Normal file
283
Frontend-Learner/node_modules/magicast/dist/types-CQa2aD_O.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
import { ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, Node as ASTNode, Program } from "@babel/types";
|
||||
|
||||
//#region vendor/recast/lib/options.d.ts
|
||||
|
||||
/**
|
||||
* All Recast API functions take second parameter with configuration options,
|
||||
* documented in options.js
|
||||
*/
|
||||
interface Options extends DeprecatedOptions {
|
||||
/**
|
||||
* If you want to use a different branch of esprima, or any other module
|
||||
* that supports a .parse function, pass that module object to
|
||||
* recast.parse as options.parser (legacy synonym: options.esprima).
|
||||
* @default require("recast/parsers/esprima")
|
||||
*/
|
||||
parser?: any;
|
||||
/**
|
||||
* Number of spaces the pretty-printer should use per tab for
|
||||
* indentation. If you do not pass this option explicitly, it will be
|
||||
* (quite reliably!) inferred from the original code.
|
||||
* @default 4
|
||||
*/
|
||||
tabWidth?: number;
|
||||
/**
|
||||
* If you really want the pretty-printer to use tabs instead of spaces,
|
||||
* make this option true.
|
||||
* @default false
|
||||
*/
|
||||
useTabs?: boolean;
|
||||
/**
|
||||
* The reprinting code leaves leading whitespace untouched unless it has
|
||||
* to reindent a line, or you pass false for this option.
|
||||
* @default true
|
||||
*/
|
||||
reuseWhitespace?: boolean;
|
||||
/**
|
||||
* Override this option to use a different line terminator, e.g. \r\n.
|
||||
* @default require("os").EOL || "\n"
|
||||
*/
|
||||
lineTerminator?: string;
|
||||
/**
|
||||
* Some of the pretty-printer code (such as that for printing function
|
||||
* parameter lists) makes a valiant attempt to prevent really long
|
||||
* lines. You can adjust the limit by changing this option; however,
|
||||
* there is no guarantee that line length will fit inside this limit.
|
||||
* @default 74
|
||||
*/
|
||||
wrapColumn?: number;
|
||||
/**
|
||||
* Pass a string as options.sourceFileName to recast.parse to tell the
|
||||
* reprinter to keep track of reused code so that it can construct a
|
||||
* source map automatically.
|
||||
* @default null
|
||||
*/
|
||||
sourceFileName?: string | null;
|
||||
/**
|
||||
* Pass a string as options.sourceMapName to recast.print, and (provided
|
||||
* you passed options.sourceFileName earlier) the PrintResult of
|
||||
* recast.print will have a .map property for the generated source map.
|
||||
* @default null
|
||||
*/
|
||||
sourceMapName?: string | null;
|
||||
/**
|
||||
* If provided, this option will be passed along to the source map
|
||||
* generator as a root directory for relative source file paths.
|
||||
* @default null
|
||||
*/
|
||||
sourceRoot?: string | null;
|
||||
/**
|
||||
* If you provide a source map that was generated from a previous call
|
||||
* to recast.print as options.inputSourceMap, the old source map will be
|
||||
* composed with the new source map.
|
||||
* @default null
|
||||
*/
|
||||
inputSourceMap?: string | null;
|
||||
/**
|
||||
* If you want esprima to generate .range information (recast only uses
|
||||
* .loc internally), pass true for this option.
|
||||
* @default false
|
||||
*/
|
||||
range?: boolean;
|
||||
/**
|
||||
* If you want esprima not to throw exceptions when it encounters
|
||||
* non-fatal errors, keep this option true.
|
||||
* @default true
|
||||
*/
|
||||
tolerant?: boolean;
|
||||
/**
|
||||
* If you want to override the quotes used in string literals, specify
|
||||
* either "single", "double", or "auto" here ("auto" will select the one
|
||||
* which results in the shorter literal) Otherwise, use double quotes.
|
||||
* @default null
|
||||
*/
|
||||
quote?: "single" | "double" | "auto" | null;
|
||||
/**
|
||||
* Controls the printing of trailing commas in object literals, array
|
||||
* expressions and function parameters.
|
||||
*
|
||||
* This option could either be:
|
||||
* * Boolean - enable/disable in all contexts (objects, arrays and function params).
|
||||
* * Object - enable/disable per context.
|
||||
*
|
||||
* Example:
|
||||
* trailingComma: {
|
||||
* objects: true,
|
||||
* arrays: true,
|
||||
* parameters: false,
|
||||
* }
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
trailingComma?: boolean;
|
||||
/**
|
||||
* Controls the printing of spaces inside array brackets.
|
||||
* See: http://eslint.org/docs/rules/array-bracket-spacing
|
||||
* @default false
|
||||
*/
|
||||
arrayBracketSpacing?: boolean;
|
||||
/**
|
||||
* Controls the printing of spaces inside object literals,
|
||||
* destructuring assignments, and import/export specifiers.
|
||||
* See: http://eslint.org/docs/rules/object-curly-spacing
|
||||
* @default true
|
||||
*/
|
||||
objectCurlySpacing?: boolean;
|
||||
/**
|
||||
* If you want parenthesis to wrap single-argument arrow function
|
||||
* parameter lists, pass true for this option.
|
||||
* @default false
|
||||
*/
|
||||
arrowParensAlways?: boolean;
|
||||
/**
|
||||
* There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
|
||||
* The use of commas is in line with the more popular style and matches
|
||||
* how objects are defined in JS, making it a bit more natural to write.
|
||||
* @default true
|
||||
*/
|
||||
flowObjectCommas?: boolean;
|
||||
/**
|
||||
* Whether to return an array of .tokens on the root AST node.
|
||||
* @default true
|
||||
*/
|
||||
tokens?: boolean;
|
||||
}
|
||||
interface DeprecatedOptions {
|
||||
/** @deprecated */
|
||||
esprima?: any;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/format.d.ts
|
||||
interface CodeFormatOptions {
|
||||
tabWidth?: number;
|
||||
useTabs?: boolean;
|
||||
wrapColumn?: number;
|
||||
quote?: "single" | "double";
|
||||
trailingComma?: boolean;
|
||||
arrayBracketSpacing?: boolean;
|
||||
objectCurlySpacing?: boolean;
|
||||
arrowParensAlways?: boolean;
|
||||
useSemi?: boolean;
|
||||
}
|
||||
declare function detectCodeFormat(code: string, userStyles?: CodeFormatOptions): CodeFormatOptions;
|
||||
//#endregion
|
||||
//#region src/proxy/types.d.ts
|
||||
interface ProxyBase {
|
||||
$ast: ASTNode;
|
||||
}
|
||||
type ProxifiedArray<T extends any[] = unknown[]> = { [K in keyof T]: Proxified<T[K]> } & ProxyBase & {
|
||||
$type: "array";
|
||||
};
|
||||
type ProxifiedFunctionCall<Args extends any[] = unknown[]> = ProxyBase & {
|
||||
$type: "function-call";
|
||||
$args: ProxifiedArray<Args>;
|
||||
$callee: string;
|
||||
};
|
||||
type ProxifiedNewExpression<Args extends any[] = unknown[]> = ProxyBase & {
|
||||
$type: "new-expression";
|
||||
$args: ProxifiedArray<Args>;
|
||||
$callee: string;
|
||||
};
|
||||
type ProxifiedArrowFunctionExpression<Params extends any[] = unknown[]> = ProxyBase & {
|
||||
$type: "arrow-function-expression";
|
||||
$params: ProxifiedArray<Params>;
|
||||
$body: ProxifiedValue;
|
||||
};
|
||||
type ProxifiedFunctionExpression<Params extends any[] = unknown[]> = ProxyBase & {
|
||||
$type: "function-expression";
|
||||
$params: ProxifiedArray<Params>;
|
||||
$body: ProxifiedBlockStatement;
|
||||
};
|
||||
type ProxifiedObject<T extends object = object> = { [K in keyof T]: Proxified<T[K]> } & ProxyBase & {
|
||||
$type: "object";
|
||||
};
|
||||
type ProxifiedIdentifier = ProxyBase & {
|
||||
$type: "identifier";
|
||||
$name: string;
|
||||
};
|
||||
type ProxifiedLogicalExpression = ProxyBase & {
|
||||
$type: "logicalExpression";
|
||||
};
|
||||
type ProxifiedMemberExpression = ProxyBase & {
|
||||
$type: "memberExpression";
|
||||
};
|
||||
type BinaryOperator = "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>";
|
||||
type ProxifiedBinaryExpression = ProxyBase & {
|
||||
$type: "binaryExpression";
|
||||
$left: Proxified;
|
||||
$right: Proxified;
|
||||
$operator: BinaryOperator;
|
||||
};
|
||||
type ProxifiedBlockStatement = ProxyBase & {
|
||||
$type: "blockStatement";
|
||||
$body: ProxifiedArray;
|
||||
};
|
||||
type Proxified<T = any> = T extends number | string | null | undefined | boolean | bigint | symbol ? T : T extends any[] ? { [K in keyof T]: Proxified<T[K]> } & ProxyBase & {
|
||||
$type: "array";
|
||||
} : T extends object ? ProxyBase & { [K in keyof T]: Proxified<T[K]> } & {
|
||||
$type: "object";
|
||||
} : T;
|
||||
type ProxifiedModule<T extends object = Record<string, any>> = ProxyBase & {
|
||||
$type: "module";
|
||||
$code: string;
|
||||
exports: ProxifiedObject<T>;
|
||||
imports: ProxifiedImportsMap;
|
||||
generate: (options?: GenerateOptions) => {
|
||||
code: string;
|
||||
map?: any;
|
||||
};
|
||||
};
|
||||
type ProxifiedImportsMap = Record<string, ProxifiedImportItem> & ProxyBase & {
|
||||
$type: "imports";
|
||||
/** @deprecated Use `$prepend` instead */
|
||||
$add: (item: ImportItemInput) => void;
|
||||
$prepend: (item: ImportItemInput) => void;
|
||||
$append: (item: ImportItemInput) => void;
|
||||
$items: ProxifiedImportItem[];
|
||||
};
|
||||
interface ProxifiedImportItem extends ProxyBase {
|
||||
$type: "import";
|
||||
$ast: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
|
||||
$declaration: ImportDeclaration;
|
||||
imported: string;
|
||||
local: string;
|
||||
from: string;
|
||||
}
|
||||
interface ImportItemInput {
|
||||
local?: string;
|
||||
imported: string;
|
||||
from: string;
|
||||
}
|
||||
type ProxifiedValue = ProxifiedArray | ProxifiedFunctionCall | ProxifiedNewExpression | ProxifiedIdentifier | ProxifiedLogicalExpression | ProxifiedMemberExpression | ProxifiedObject | ProxifiedModule | ProxifiedImportsMap | ProxifiedImportItem | ProxifiedArrowFunctionExpression | ProxifiedFunctionExpression | ProxifiedBinaryExpression | ProxifiedBlockStatement;
|
||||
type ProxyType = ProxifiedValue["$type"];
|
||||
//#endregion
|
||||
//#region src/types.d.ts
|
||||
interface Loc {
|
||||
start?: {
|
||||
line?: number;
|
||||
column?: number;
|
||||
token?: number;
|
||||
};
|
||||
end?: {
|
||||
line?: number;
|
||||
column?: number;
|
||||
token?: number;
|
||||
};
|
||||
lines?: any;
|
||||
}
|
||||
interface Token {
|
||||
type: string;
|
||||
value: string;
|
||||
loc?: Loc;
|
||||
}
|
||||
interface ParsedFileNode {
|
||||
type: "file";
|
||||
program: Program;
|
||||
loc: Loc;
|
||||
comments: null | any;
|
||||
}
|
||||
type GenerateOptions = Options & {
|
||||
format?: false | CodeFormatOptions;
|
||||
};
|
||||
//#endregion
|
||||
export { ProxifiedValue as C, detectCodeFormat as D, CodeFormatOptions as E, Options as O, ProxifiedObject as S, ProxyType as T, ProxifiedImportsMap as _, Token as a, ProxifiedModule as b, Proxified as c, ProxifiedBinaryExpression as d, ProxifiedBlockStatement as f, ProxifiedImportItem as g, ProxifiedIdentifier as h, ParsedFileNode as i, ProxifiedArray as l, ProxifiedFunctionExpression as m, GenerateOptions as n, BinaryOperator as o, ProxifiedFunctionCall as p, Loc as r, ImportItemInput as s, ASTNode as t, ProxifiedArrowFunctionExpression as u, ProxifiedLogicalExpression as v, ProxyBase as w, ProxifiedNewExpression as x, ProxifiedMemberExpression as y };
|
||||
71
Frontend-Learner/node_modules/magicast/package.json
generated
vendored
Normal file
71
Frontend-Learner/node_modules/magicast/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"name": "magicast",
|
||||
"version": "0.5.1",
|
||||
"description": "Modify a JS/TS file and write back magically just like JSON!",
|
||||
"repository": "unjs/magicast",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./helpers": "./dist/helpers/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.28.5",
|
||||
"@babel/types": "^7.28.5",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.9.1",
|
||||
"@vitest/coverage-v8": "^4.0.4",
|
||||
"@vitest/ui": "^4.0.4",
|
||||
"ast-types": "^0.16.1",
|
||||
"bumpp": "^10.3.1",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-config-unjs": "^0.5.0",
|
||||
"giget": "^2.0.0",
|
||||
"jiti": "^2.6.1",
|
||||
"lint-staged": "^16.2.6",
|
||||
"prettier": "^3.6.2",
|
||||
"recast": "^0.23.11",
|
||||
"simple-git-hooks": "^2.13.1",
|
||||
"source-map": "npm:source-map-js@latest",
|
||||
"taze": "^19.8.1",
|
||||
"tsdown": "^0.15.11",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.0.4",
|
||||
"magicast": "0.5.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"source-map": "npm:source-map-js@latest"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "pnpm lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,js,mjs,cjs}": [
|
||||
"eslint --fix",
|
||||
"prettier -w"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"dev": "vitest dev",
|
||||
"dev:ui": "vitest dev --ui",
|
||||
"lint": "eslint --cache . && prettier -c .",
|
||||
"lint:fix": "eslint --cache . --fix && prettier -c . -w",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"release": "pnpm run test run && bumpp",
|
||||
"test": "vitest",
|
||||
"test:build": "TEST_BUILD=true vitest",
|
||||
"test:full": "pnpm run test --run && pnpm run build && pnpm run test:build --run"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue