Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.

This commit is contained in:
becarta
2025-05-23 12:43:00 +02:00
parent f40db0f5c9
commit a544759a3b
11127 changed files with 1647032 additions and 0 deletions

21
node_modules/magicast/LICENSE generated vendored Normal file
View 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.

209
node_modules/magicast/README.md generated vendored Normal file
View File

@@ -0,0 +1,209 @@
# 🧀 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
# using yarn
yarn add --dev magicast
# using npm
npm install -D magicast
# using pnpm
pnpm add -D magicast
```
Import utilities:
```js
// ESM / Bundler
import { parseModule, generateCode, builders, createNode } from "magicast";
// CommonJS
const { parseModule, generateCode, builders, createNode } = require("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

146
node_modules/magicast/dist/helpers.cjs generated vendored Normal file
View File

@@ -0,0 +1,146 @@
'use strict';
const index = require('./index.cjs');
require('node:fs');
require('fs');
require('source-map-js');
require('@babel/parser');
function deepMergeObject(magicast, object) {
if (typeof object === "object") {
for (const key in object) {
if (typeof magicast[key] === "object" && typeof object[key] === "object") {
deepMergeObject(magicast[key], object[key]);
} else {
magicast[key] = object[key];
}
}
}
}
function getDefaultExportOptions(magicast) {
return configFromNode(magicast.exports.default);
}
function getConfigFromVariableDeclaration(magicast) {
if (magicast.exports.default.$type !== "identifier") {
throw new index.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 init = declaration.init.type === "TSSatisfiesExpression" ? declaration.init.expression : declaration.init;
const code = index.generateCode(init).code;
const configExpression = index.parseExpression(code);
return {
declaration,
config: configFromNode(configExpression)
};
}
}
}
}
throw new index.MagicastError("Couldn't find config declaration");
}
function configFromNode(node) {
if (node.$type === "function-call") {
return node.$args[0];
}
return node;
}
function addNuxtModule(magicast, name, optionsKey, options) {
const config = getDefaultExportOptions(magicast);
config.modules || (config.modules = []);
if (!config.modules.includes(name)) {
config.modules.push(name);
}
if (optionsKey) {
config[optionsKey] || (config[optionsKey] = {});
deepMergeObject(config[optionsKey], options);
}
}
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;
}
function insertPluginIntoVariableDeclarationConfig(magicast, plugin) {
const { config: configObject, declaration } = getConfigFromVariableDeclaration(magicast);
insertPluginIntoConfig(plugin, configObject);
if (declaration.init) {
if (declaration.init.type === "ObjectExpression") {
declaration.init = index.generateCode(configObject).code;
} else if (declaration.init.type === "CallExpression" && declaration.init.callee.type === "Identifier") {
declaration.init = index.generateCode(
index.builders.functionCall(declaration.init.callee.name, configObject)
).code;
} else if (declaration.init.type === "TSSatisfiesExpression") {
if (declaration.init.expression.type === "ObjectExpression") {
declaration.init.expression = index.generateCode(configObject).code;
}
if (declaration.init.expression.type === "CallExpression" && declaration.init.expression.callee.type === "Identifier") {
declaration.init.expression = index.generateCode(
index.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 = []);
config.plugins.splice(
insertionIndex,
0,
plugin.options ? index.builders.functionCall(plugin.constructor, plugin.options) : index.builders.functionCall(plugin.constructor)
);
}
exports.addNuxtModule = addNuxtModule;
exports.addVitePlugin = addVitePlugin;
exports.deepMergeObject = deepMergeObject;
exports.findVitePluginCall = findVitePluginCall;
exports.getConfigFromVariableDeclaration = getConfigFromVariableDeclaration;
exports.getDefaultExportOptions = getDefaultExportOptions;
exports.updateVitePluginConfig = updateVitePluginConfig;

70
node_modules/magicast/dist/helpers.d.cts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import { a as Proxified, P as ProxifiedModule, e as ProxifiedFunctionCall, h as ProxifiedObject } from './shared/magicast.54e2233d.cjs';
import { VariableDeclarator } from '@babel/types';
declare function deepMergeObject(magicast: Proxified<any>, object: any): void;
declare function addNuxtModule(magicast: ProxifiedModule<any>, name: string, optionsKey?: string, options?: any): void;
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;
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;
};
export { type AddVitePluginOptions, type UpdateVitePluginConfigOptions, addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };

70
node_modules/magicast/dist/helpers.d.mts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import { a as Proxified, P as ProxifiedModule, e as ProxifiedFunctionCall, h as ProxifiedObject } from './shared/magicast.54e2233d.mjs';
import { VariableDeclarator } from '@babel/types';
declare function deepMergeObject(magicast: Proxified<any>, object: any): void;
declare function addNuxtModule(magicast: ProxifiedModule<any>, name: string, optionsKey?: string, options?: any): void;
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;
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;
};
export { type AddVitePluginOptions, type UpdateVitePluginConfigOptions, addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };

70
node_modules/magicast/dist/helpers.d.ts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
import { a as Proxified, P as ProxifiedModule, e as ProxifiedFunctionCall, h as ProxifiedObject } from './shared/magicast.54e2233d.js';
import { VariableDeclarator } from '@babel/types';
declare function deepMergeObject(magicast: Proxified<any>, object: any): void;
declare function addNuxtModule(magicast: ProxifiedModule<any>, name: string, optionsKey?: string, options?: any): void;
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;
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;
};
export { type AddVitePluginOptions, type UpdateVitePluginConfigOptions, addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };

138
node_modules/magicast/dist/helpers.mjs generated vendored Normal file
View File

@@ -0,0 +1,138 @@
import { MagicastError, generateCode, parseExpression, builders } from './index.mjs';
import 'node:fs';
import 'fs';
import 'source-map-js';
import '@babel/parser';
function deepMergeObject(magicast, object) {
if (typeof object === "object") {
for (const key in object) {
if (typeof magicast[key] === "object" && typeof object[key] === "object") {
deepMergeObject(magicast[key], object[key]);
} else {
magicast[key] = object[key];
}
}
}
}
function getDefaultExportOptions(magicast) {
return configFromNode(magicast.exports.default);
}
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 init = declaration.init.type === "TSSatisfiesExpression" ? declaration.init.expression : declaration.init;
const code = generateCode(init).code;
const configExpression = parseExpression(code);
return {
declaration,
config: configFromNode(configExpression)
};
}
}
}
}
throw new MagicastError("Couldn't find config declaration");
}
function configFromNode(node) {
if (node.$type === "function-call") {
return node.$args[0];
}
return node;
}
function addNuxtModule(magicast, name, optionsKey, options) {
const config = getDefaultExportOptions(magicast);
config.modules || (config.modules = []);
if (!config.modules.includes(name)) {
config.modules.push(name);
}
if (optionsKey) {
config[optionsKey] || (config[optionsKey] = {});
deepMergeObject(config[optionsKey], options);
}
}
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;
}
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 = []);
config.plugins.splice(
insertionIndex,
0,
plugin.options ? builders.functionCall(plugin.constructor, plugin.options) : builders.functionCall(plugin.constructor)
);
}
export { addNuxtModule, addVitePlugin, deepMergeObject, findVitePluginCall, getConfigFromVariableDeclaration, getDefaultExportOptions, updateVitePluginConfig };

8933
node_modules/magicast/dist/index.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

53
node_modules/magicast/dist/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import { O as Options, P as ProxifiedModule, a as Proxified, G as GenerateOptions } from './shared/magicast.54e2233d.cjs';
export { C as CodeFormatOptions, I as ImportItemInput, L as Loc, b as ParsedFileNode, d as ProxifiedArray, g as ProxifiedArrowFunctionExpression, e as ProxifiedFunctionCall, i as ProxifiedIdentifier, m as ProxifiedImportItem, l as ProxifiedImportsMap, j as ProxifiedLogicalExpression, k as ProxifiedMemberExpression, f as ProxifiedNewExpression, h as ProxifiedObject, n as ProxifiedValue, c as ProxyBase, o as ProxyType, T as Token, p as detectCodeFormat } from './shared/magicast.54e2233d.cjs';
import { Node } from '@babel/types';
export { Node as ASTNode } from '@babel/types';
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: Node;
} | Node | 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: Node;
} | Node, filename: string, options?: Options): Promise<void>;
interface MagicastErrorOptions {
ast?: Node;
code?: string;
}
declare class MagicastError extends Error {
rawMessage: string;
options?: MagicastErrorOptions;
constructor(message: string, options?: MagicastErrorOptions);
}
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 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;
};
export { GenerateOptions, MagicastError, type MagicastErrorOptions, Proxified, ProxifiedModule, builders, generateCode, loadFile, parseExpression, parseModule, writeFile };

53
node_modules/magicast/dist/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import { O as Options, P as ProxifiedModule, a as Proxified, G as GenerateOptions } from './shared/magicast.54e2233d.mjs';
export { C as CodeFormatOptions, I as ImportItemInput, L as Loc, b as ParsedFileNode, d as ProxifiedArray, g as ProxifiedArrowFunctionExpression, e as ProxifiedFunctionCall, i as ProxifiedIdentifier, m as ProxifiedImportItem, l as ProxifiedImportsMap, j as ProxifiedLogicalExpression, k as ProxifiedMemberExpression, f as ProxifiedNewExpression, h as ProxifiedObject, n as ProxifiedValue, c as ProxyBase, o as ProxyType, T as Token, p as detectCodeFormat } from './shared/magicast.54e2233d.mjs';
import { Node } from '@babel/types';
export { Node as ASTNode } from '@babel/types';
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: Node;
} | Node | 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: Node;
} | Node, filename: string, options?: Options): Promise<void>;
interface MagicastErrorOptions {
ast?: Node;
code?: string;
}
declare class MagicastError extends Error {
rawMessage: string;
options?: MagicastErrorOptions;
constructor(message: string, options?: MagicastErrorOptions);
}
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 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;
};
export { GenerateOptions, MagicastError, type MagicastErrorOptions, Proxified, ProxifiedModule, builders, generateCode, loadFile, parseExpression, parseModule, writeFile };

53
node_modules/magicast/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import { O as Options, P as ProxifiedModule, a as Proxified, G as GenerateOptions } from './shared/magicast.54e2233d.js';
export { C as CodeFormatOptions, I as ImportItemInput, L as Loc, b as ParsedFileNode, d as ProxifiedArray, g as ProxifiedArrowFunctionExpression, e as ProxifiedFunctionCall, i as ProxifiedIdentifier, m as ProxifiedImportItem, l as ProxifiedImportsMap, j as ProxifiedLogicalExpression, k as ProxifiedMemberExpression, f as ProxifiedNewExpression, h as ProxifiedObject, n as ProxifiedValue, c as ProxyBase, o as ProxyType, T as Token, p as detectCodeFormat } from './shared/magicast.54e2233d.js';
import { Node } from '@babel/types';
export { Node as ASTNode } from '@babel/types';
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: Node;
} | Node | 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: Node;
} | Node, filename: string, options?: Options): Promise<void>;
interface MagicastErrorOptions {
ast?: Node;
code?: string;
}
declare class MagicastError extends Error {
rawMessage: string;
options?: MagicastErrorOptions;
constructor(message: string, options?: MagicastErrorOptions);
}
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 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;
};
export { GenerateOptions, MagicastError, type MagicastErrorOptions, Proxified, ProxifiedModule, builders, generateCode, loadFile, parseExpression, parseModule, writeFile };

8907
node_modules/magicast/dist/index.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,270 @@
import { Node, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportDeclaration, Program } from '@babel/types';
/**
* 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;
}
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;
interface ProxyBase {
$ast: Node;
}
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 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 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;
type ProxyType = ProxifiedValue["$type"];
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;
};
export { type CodeFormatOptions as C, type GenerateOptions as G, type ImportItemInput as I, type Loc as L, type Options as O, type ProxifiedModule as P, type Token as T, type Proxified as a, type ParsedFileNode as b, type ProxyBase as c, type ProxifiedArray as d, type ProxifiedFunctionCall as e, type ProxifiedNewExpression as f, type ProxifiedArrowFunctionExpression as g, type ProxifiedObject as h, type ProxifiedIdentifier as i, type ProxifiedLogicalExpression as j, type ProxifiedMemberExpression as k, type ProxifiedImportsMap as l, type ProxifiedImportItem as m, type ProxifiedValue as n, type ProxyType as o, detectCodeFormat as p };

View File

@@ -0,0 +1,270 @@
import { Node, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportDeclaration, Program } from '@babel/types';
/**
* 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;
}
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;
interface ProxyBase {
$ast: Node;
}
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 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 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;
type ProxyType = ProxifiedValue["$type"];
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;
};
export { type CodeFormatOptions as C, type GenerateOptions as G, type ImportItemInput as I, type Loc as L, type Options as O, type ProxifiedModule as P, type Token as T, type Proxified as a, type ParsedFileNode as b, type ProxyBase as c, type ProxifiedArray as d, type ProxifiedFunctionCall as e, type ProxifiedNewExpression as f, type ProxifiedArrowFunctionExpression as g, type ProxifiedObject as h, type ProxifiedIdentifier as i, type ProxifiedLogicalExpression as j, type ProxifiedMemberExpression as k, type ProxifiedImportsMap as l, type ProxifiedImportItem as m, type ProxifiedValue as n, type ProxyType as o, detectCodeFormat as p };

View File

@@ -0,0 +1,270 @@
import { Node, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportDeclaration, Program } from '@babel/types';
/**
* 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;
}
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;
interface ProxyBase {
$ast: Node;
}
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 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 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;
type ProxyType = ProxifiedValue["$type"];
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;
};
export { type CodeFormatOptions as C, type GenerateOptions as G, type ImportItemInput as I, type Loc as L, type Options as O, type ProxifiedModule as P, type Token as T, type Proxified as a, type ParsedFileNode as b, type ProxyBase as c, type ProxifiedArray as d, type ProxifiedFunctionCall as e, type ProxifiedNewExpression as f, type ProxifiedArrowFunctionExpression as g, type ProxifiedObject as h, type ProxifiedIdentifier as i, type ProxifiedLogicalExpression as j, type ProxifiedMemberExpression as k, type ProxifiedImportsMap as l, type ProxifiedImportItem as m, type ProxifiedValue as n, type ProxyType as o, detectCodeFormat as p };

1
node_modules/magicast/helpers.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from "./dist/helpers.js";

90
node_modules/magicast/package.json generated vendored Normal file
View File

@@ -0,0 +1,90 @@
{
"name": "magicast",
"version": "0.3.5",
"description": "Modify a JS/TS file and write back magically just like JSON!",
"repository": "unjs/magicast",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./helpers": {
"import": "./dist/helpers.mjs",
"require": "./dist/helpers.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist",
"*.d.ts"
],
"scripts": {
"build": "unbuild",
"prepare": "esno ./scripts/vendor.ts",
"dev": "vitest dev",
"dev:ui": "vitest dev --ui",
"lint": "eslint --cache . && prettier -c .",
"lint:fix": "eslint --cache . --fix && prettier -c . -w",
"prepack": "pnpm run build",
"typecheck": "tsc --noEmit",
"release": "pnpm run test run && changelogen --release && npm publish && git push --follow-tags",
"test": "vitest",
"test:build": "TEST_BUILD=true vitest",
"test:full": "pnpm run test --run && pnpm run build && pnpm run test:build --run"
},
"dependencies": {
"@babel/parser": "^7.25.4",
"@babel/types": "^7.25.4",
"source-map-js": "^1.2.0"
},
"devDependencies": {
"@types/node": "^20.16.1",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"ast-types": "^0.16.1",
"changelogen": "^0.5.5",
"eslint": "^9.9.1",
"eslint-config-unjs": "^0.3.2",
"esno": "^4.7.0",
"giget": "^1.2.3",
"lint-staged": "^15.2.9",
"magicast": "workspace:*",
"prettier": "^3.3.3",
"recast": "^0.23.9",
"simple-git-hooks": "^2.11.1",
"source-map": "npm:source-map-js@latest",
"typescript": "^5.5.4",
"unbuild": "^2.0.0",
"vitest": "^1.6.0"
},
"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"
]
},
"packageManager": "pnpm@8.15.9",
"pnpm": {
"overrides": {
"array-includes": "npm:@nolyfill/array-includes@latest",
"array.prototype.findlastindex": "npm:@nolyfill/array.prototype.findlastindex@latest",
"array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
"array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
"hasown": "npm:@nolyfill/hasown@latest",
"object.fromentries": "npm:@nolyfill/object.fromentries@latest",
"object.groupby": "npm:@nolyfill/object.groupby@latest",
"object.values": "npm:@nolyfill/object.values@latest"
}
}
}