This commit is contained in:
xiaoxiaojx 2025-10-03 20:45:30 +08:00
parent 4c30c3ee83
commit e62546989c
1 changed files with 365 additions and 9 deletions

374
types.d.ts vendored
View File

@ -24,7 +24,7 @@ import {
ClassBody,
ClassDeclaration,
ClassExpression,
Comment,
Comment as CommentImport,
ConditionalExpression,
ContinueStatement,
DebuggerStatement,
@ -99,9 +99,11 @@ import {
} from "inspector";
import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
import { ListenOptions } from "net";
import { validate as validateFunction } from "schema-utils";
import {
ValidationErrorConfiguration,
validate as validateFunction
} from "schema-utils";
import { default as ValidationError } from "schema-utils/declarations/ValidationError";
import { ValidationErrorConfiguration } from "schema-utils/declarations/validate";
import {
AsArray,
AsyncParallelHook,
@ -114,7 +116,8 @@ import {
SyncBailHook,
SyncHook,
SyncWaterfallHook,
TapOptions
TapOptions,
TypedHookMap
} from "tapable";
import { SecureContextOptions, TlsOptions } from "tls";
import { URL } from "url";
@ -297,6 +300,14 @@ declare interface Asset {
*/
info: AssetInfo;
}
declare abstract class AssetBytesGenerator extends Generator {
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
}
declare abstract class AssetBytesParser extends ParserClass {}
declare interface AssetDependencyMeta {
sourceType: "css-url";
}
@ -311,6 +322,25 @@ type AssetFilterItemTypes =
| string
| RegExp
| ((name: string, asset: StatsAsset) => boolean);
declare abstract class AssetGenerator extends Generator {
dataUrlOptions?:
| AssetGeneratorDataUrlOptions
| ((
source: string | Buffer,
context: { filename: string; module: Module }
) => string);
filename?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
publicPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
outputPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
emit?: boolean;
getMimeType(module: NormalModule): string;
generateDataUri(module: NormalModule): string;
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
}
/**
* Options object for data url generation.
@ -349,6 +379,15 @@ declare interface AssetInlineGeneratorOptions {
context: { filename: string; module: Module }
) => string);
}
declare abstract class AssetParser extends ParserClass {
dataUrlCondition?:
| boolean
| AssetParserDataUrlOptions
| ((
source: string | Buffer,
context: { filename: string; module: Module }
) => boolean);
}
/**
* Options object for DataUrl condition.
@ -404,6 +443,14 @@ declare interface AssetResourceGeneratorOptions {
*/
publicPath?: string | ((pathData: PathData, assetInfo?: AssetInfo) => string);
}
declare abstract class AssetSourceGenerator extends Generator {
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
}
declare abstract class AssetSourceParser extends ParserClass {}
declare class AsyncDependenciesBlock extends DependenciesBlock {
constructor(
groupOptions:
@ -473,6 +520,7 @@ declare interface AsyncWebAssemblyModulesPluginOptions {
*/
mangleImports?: boolean;
}
declare abstract class AsyncWebAssemblyParser extends ParserClass {}
declare class AutomaticPrefetchPlugin {
constructor();
@ -2044,6 +2092,11 @@ declare interface ColorsOptions {
*/
useColor?: boolean;
}
declare interface CommentCssParser {
value: string;
range: [number, number];
loc: { start: Position; end: Position };
}
declare interface CommonJsImportSettings {
name?: string;
context: string;
@ -3574,6 +3627,23 @@ declare interface CssData {
*/
exports: Map<string, string>;
}
declare abstract class CssGenerator extends Generator {
convention?:
| "as-is"
| "camel-case"
| "camel-case-only"
| "dashes"
| "dashes-only"
| ((name: string) => string);
localIdentName?: string;
exportsOnly?: boolean;
esModule?: boolean;
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
}
/**
* Generator options for css modules.
@ -3769,6 +3839,19 @@ declare class CssModulesPlugin {
): TemplatePath;
static chunkHasCss(chunk: Chunk, chunkGraph: ChunkGraph): boolean;
}
declare abstract class CssParser extends ParserClass {
defaultMode: "global" | "auto" | "pure" | "local";
import: boolean;
url: boolean;
namedExports: boolean;
comments?: CommentCssParser[];
magicCommentContext: Context;
getComments(range: [number, number]): CommentCssParser[];
parseCommentOptions(range: [number, number]): {
options: null | Record<string, any>;
errors: null | (Error & { comment: CommentCssParser })[];
};
}
/**
* Parser options for css modules.
@ -6659,6 +6742,33 @@ declare interface IteratorObject<T, TReturn = unknown, TNext = unknown>
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
[Symbol.dispose](): void;
}
declare abstract class JavascriptGenerator extends Generator {
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
sourceModule(
module: Module,
initFragments: InitFragment<GenerateContext>[],
source: ReplaceSource,
generateContext: GenerateContext
): void;
sourceBlock(
module: Module,
block: DependenciesBlock,
initFragments: InitFragment<GenerateContext>[],
source: ReplaceSource,
generateContext: GenerateContext
): void;
sourceDependency(
module: Module,
dependency: Dependency,
initFragments: InitFragment<GenerateContext>[],
source: ReplaceSource,
generateContext: GenerateContext
): void;
}
declare class JavascriptModulesPlugin {
constructor(options?: object);
options: object;
@ -7143,15 +7253,15 @@ declare class JavascriptParser extends ParserClass {
[LogicalExpression],
boolean | void
>;
program: SyncBailHook<[Program, Comment[]], boolean | void>;
program: SyncBailHook<[Program, CommentImport[]], boolean | void>;
terminate: SyncBailHook<[ReturnStatement | ThrowStatement], boolean | void>;
finish: SyncBailHook<[Program, Comment[]], boolean | void>;
finish: SyncBailHook<[Program, CommentImport[]], boolean | void>;
unusedStatement: SyncBailHook<[Statement], boolean | void>;
}>;
sourceType: "module" | "auto" | "script";
scope: ScopeInfo;
state: ParserState;
comments?: Comment[];
comments?: CommentImport[];
semicolons?: Set<number>;
statementPath?: StatementPathItem[];
prevStatement?:
@ -7975,7 +8085,7 @@ declare class JavascriptParser extends ParserClass {
| MaybeNamedClassDeclaration,
commentsStartPos: number
): boolean;
getComments(range: [number, number]): Comment[];
getComments(range: [number, number]): CommentImport[];
isAsiPosition(pos: number): boolean;
setAsiPosition(pos: number): void;
unsetAsiPosition(pos: number): void;
@ -8011,7 +8121,7 @@ declare class JavascriptParser extends ParserClass {
evaluatedVariable(tagInfo: TagInfo): VariableInfo;
parseCommentOptions(range: [number, number]): {
options: null | Record<string, any>;
errors: null | (Error & { comment: Comment })[];
errors: null | (Error & { comment: CommentImport })[];
};
extractMemberExpressionChain(
expression:
@ -8363,6 +8473,14 @@ declare abstract class JsonData {
| JsonValueFs[];
updateHash(hash: Hash): void;
}
declare abstract class JsonGenerator extends Generator {
options: JsonGeneratorOptions;
generateError(
error: Error,
module: NormalModule,
generateContext: GenerateContext
): null | Source;
}
/**
* Generator options for json modules.
@ -8373,6 +8491,17 @@ declare interface JsonGeneratorOptions {
*/
JSONParse?: boolean;
}
declare interface JsonModulesPluginParserOptions {
/**
* The depth of json dependency flagged as `exportInfo`.
*/
exportsDepth?: number;
/**
* Function that executes for a module source string and should return json-compatible data.
*/
parse?: (input: string) => any;
}
declare interface JsonObjectFs {
[index: string]:
| undefined
@ -8393,6 +8522,9 @@ declare interface JsonObjectTypes {
| JsonObjectTypes
| JsonValueTypes[];
}
declare abstract class JsonParser extends ParserClass {
options: JsonModulesPluginParserOptions;
}
/**
* Parser options for JSON modules.
@ -11324,6 +11456,225 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
],
Module
>;
createParser: TypedHookMap<
Record<
"javascript/auto",
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
> &
Record<
"javascript/dynamic",
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
> &
Record<
"javascript/esm",
SyncBailHook<[JavascriptParserOptions], JavascriptParser>
> &
Record<"json", SyncBailHook<[JsonParserOptions], JsonParser>> &
Record<"asset", SyncBailHook<[AssetParserOptions], AssetParser>> &
Record<
"asset/inline",
SyncBailHook<[EmptyParserOptions], AssetParser>
> &
Record<
"asset/resource",
SyncBailHook<[EmptyParserOptions], AssetParser>
> &
Record<
"asset/source",
SyncBailHook<[EmptyParserOptions], AssetSourceParser>
> &
Record<
"asset/bytes",
SyncBailHook<[EmptyParserOptions], AssetBytesParser>
> &
Record<
"webassembly/async",
SyncBailHook<[EmptyParserOptions], AsyncWebAssemblyParser>
> &
Record<
"webassembly/sync",
SyncBailHook<[EmptyParserOptions], WebAssemblyParser>
> &
Record<"css", SyncBailHook<[CssParserOptions], CssParser>> &
Record<"css/auto", SyncBailHook<[CssAutoParserOptions], CssParser>> &
Record<
"css/module",
SyncBailHook<[CssModuleParserOptions], CssParser>
> &
Record<
"css/global",
SyncBailHook<[CssGlobalParserOptions], CssParser>
> &
Record<string, SyncBailHook<[ParserOptions], ParserClass>>
>;
parser: TypedHookMap<
Record<
"javascript/auto",
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
> &
Record<
"javascript/dynamic",
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
> &
Record<
"javascript/esm",
SyncBailHook<[JavascriptParser, JavascriptParserOptions], void>
> &
Record<"json", SyncBailHook<[JsonParser, JsonParserOptions], void>> &
Record<"asset", SyncBailHook<[AssetParser, AssetParserOptions], void>> &
Record<
"asset/inline",
SyncBailHook<[AssetParser, EmptyParserOptions], void>
> &
Record<
"asset/resource",
SyncBailHook<[AssetParser, EmptyParserOptions], void>
> &
Record<
"asset/source",
SyncBailHook<[AssetSourceParser, EmptyParserOptions], void>
> &
Record<
"asset/bytes",
SyncBailHook<[AssetBytesParser, EmptyParserOptions], void>
> &
Record<
"webassembly/async",
SyncBailHook<[AsyncWebAssemblyParser, EmptyParserOptions], void>
> &
Record<
"webassembly/sync",
SyncBailHook<[WebAssemblyParser, EmptyParserOptions], void>
> &
Record<"css", SyncBailHook<[CssParser, CssParserOptions], void>> &
Record<
"css/auto",
SyncBailHook<[CssParser, CssAutoParserOptions], void>
> &
Record<
"css/module",
SyncBailHook<[CssParser, CssModuleParserOptions], void>
> &
Record<
"css/global",
SyncBailHook<[CssParser, CssGlobalParserOptions], void>
> &
Record<string, SyncBailHook<[ParserClass, ParserOptions], void>>
>;
createGenerator: TypedHookMap<
Record<
"javascript/auto",
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
> &
Record<
"javascript/dynamic",
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
> &
Record<
"javascript/esm",
SyncBailHook<[EmptyGeneratorOptions], JavascriptGenerator>
> &
Record<"json", SyncBailHook<[JsonGeneratorOptions], JsonGenerator>> &
Record<"asset", SyncBailHook<[AssetGeneratorOptions], AssetGenerator>> &
Record<
"asset/inline",
SyncBailHook<[AssetGeneratorOptions], AssetGenerator>
> &
Record<
"asset/resource",
SyncBailHook<[AssetGeneratorOptions], AssetGenerator>
> &
Record<
"asset/source",
SyncBailHook<[EmptyGeneratorOptions], AssetSourceGenerator>
> &
Record<
"asset/bytes",
SyncBailHook<[EmptyGeneratorOptions], AssetBytesGenerator>
> &
Record<
"webassembly/async",
SyncBailHook<[EmptyParserOptions], Generator>
> &
Record<
"webassembly/sync",
SyncBailHook<[EmptyParserOptions], Generator>
> &
Record<"css", SyncBailHook<[CssGeneratorOptions], CssGenerator>> &
Record<
"css/auto",
SyncBailHook<[CssAutoGeneratorOptions], CssGenerator>
> &
Record<
"css/module",
SyncBailHook<[CssModuleGeneratorOptions], CssGenerator>
> &
Record<
"css/global",
SyncBailHook<[CssGlobalGeneratorOptions], CssGenerator>
> &
Record<string, SyncBailHook<[GeneratorOptions], Generator>>
>;
generator: TypedHookMap<
Record<
"javascript/auto",
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
> &
Record<
"javascript/dynamic",
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
> &
Record<
"javascript/esm",
SyncBailHook<[JavascriptGenerator, EmptyGeneratorOptions], void>
> &
Record<
"json",
SyncBailHook<[JsonGenerator, JsonGeneratorOptions], void>
> &
Record<
"asset",
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
> &
Record<
"asset/inline",
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
> &
Record<
"asset/resource",
SyncBailHook<[AssetGenerator, AssetGeneratorOptions], void>
> &
Record<
"asset/source",
SyncBailHook<[AssetSourceGenerator, EmptyGeneratorOptions], void>
> &
Record<
"asset/bytes",
SyncBailHook<[AssetBytesGenerator, EmptyGeneratorOptions], void>
> &
Record<
"webassembly/async",
SyncBailHook<[Generator, EmptyParserOptions], void>
> &
Record<
"webassembly/sync",
SyncBailHook<[Generator, EmptyParserOptions], void>
> &
Record<"css", SyncBailHook<[CssGenerator, CssGeneratorOptions], void>> &
Record<
"css/auto",
SyncBailHook<[CssGenerator, CssAutoGeneratorOptions], void>
> &
Record<
"css/module",
SyncBailHook<[CssGenerator, CssModuleGeneratorOptions], void>
> &
Record<
"css/global",
SyncBailHook<[CssGenerator, CssGlobalGeneratorOptions], void>
> &
Record<string, SyncBailHook<[Generator, GeneratorOptions], void>>
>;
createModuleClass: HookMap<
SyncBailHook<
[
@ -13196,6 +13547,10 @@ declare interface PnpApi {
options: { considerBuiltins: boolean }
) => null | string;
}
declare interface Position {
line: number;
column: number;
}
declare class PrefetchPlugin {
constructor(context: string, request?: string);
context: null | string;
@ -17845,6 +18200,7 @@ declare abstract class WeakTupleMap<K extends any[], V> {
delete(...args: K): void;
clear(): void;
}
declare abstract class WebAssemblyParser extends ParserClass {}
declare interface WebAssemblyRenderContext {
/**
* the chunk