5532 lines
182 KiB
TypeScript
5532 lines
182 KiB
TypeScript
/// <reference types="node" />
|
||
import * as vite from 'vite';
|
||
import { BuildOptions, Logger, UserConfig as UserConfig$1, ConfigEnv, ServerOptions } from 'vite';
|
||
export { Plugin, loadEnv } from 'vite';
|
||
import { Awaitable, SiteData, PageData, HeadConfig, LocaleSpecificConfig, LocaleConfig, SSGContext, DefaultTheme } from '../../types/shared.js';
|
||
export { DefaultTheme, HeadConfig, Header, SiteData } from '../../types/shared.js';
|
||
import { RawSourceMap } from 'source-map-js';
|
||
import { Result, LazyResult, Root } from 'postcss';
|
||
import { UseDarkOptions } from '@vueuse/core';
|
||
import { TransformOptions as TransformOptions$1 } from 'stream';
|
||
import { IThemeRegistration, ILanguageRegistration } from 'shiki';
|
||
import glob from 'fast-glob';
|
||
import { IncomingMessage, ServerResponse } from 'http';
|
||
import { Server, ListenOptions } from 'net';
|
||
|
||
declare function build(root?: string, buildOptions?: BuildOptions & {
|
||
base?: string;
|
||
mpa?: string;
|
||
}): Promise<void>;
|
||
|
||
interface BaseComment {
|
||
value: string;
|
||
start?: number;
|
||
end?: number;
|
||
loc?: SourceLocation$1;
|
||
ignore?: boolean;
|
||
type: "CommentBlock" | "CommentLine";
|
||
}
|
||
interface Position$1 {
|
||
line: number;
|
||
column: number;
|
||
index: number;
|
||
}
|
||
interface CommentBlock extends BaseComment {
|
||
type: "CommentBlock";
|
||
}
|
||
interface CommentLine extends BaseComment {
|
||
type: "CommentLine";
|
||
}
|
||
type Comment = CommentBlock | CommentLine;
|
||
interface SourceLocation$1 {
|
||
start: Position$1;
|
||
end: Position$1;
|
||
filename: string;
|
||
identifierName: string | undefined | null;
|
||
}
|
||
interface BaseNode {
|
||
type: Node$1["type"];
|
||
leadingComments?: Comment[] | null;
|
||
innerComments?: Comment[] | null;
|
||
trailingComments?: Comment[] | null;
|
||
start?: number | null;
|
||
end?: number | null;
|
||
loc?: SourceLocation$1 | null;
|
||
range?: [number, number];
|
||
extra?: Record<string, unknown>;
|
||
}
|
||
type Node$1 = AnyTypeAnnotation | ArgumentPlaceholder | ArrayExpression$1 | ArrayPattern | ArrayTypeAnnotation | ArrowFunctionExpression | AssignmentExpression$1 | AssignmentPattern | AwaitExpression | BigIntLiteral | BinaryExpression | BindExpression | BlockStatement$1 | BooleanLiteral | BooleanLiteralTypeAnnotation | BooleanTypeAnnotation | BreakStatement | CallExpression$1 | CatchClause | ClassAccessorProperty | ClassBody | ClassDeclaration | ClassExpression | ClassImplements | ClassMethod | ClassPrivateMethod | ClassPrivateProperty | ClassProperty | ConditionalExpression$1 | ContinueStatement | DebuggerStatement | DecimalLiteral | DeclareClass | DeclareExportAllDeclaration | DeclareExportDeclaration | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareOpaqueType | DeclareTypeAlias | DeclareVariable | DeclaredPredicate | Decorator | Directive | DirectiveLiteral | DoExpression | DoWhileStatement | EmptyStatement | EmptyTypeAnnotation | EnumBooleanBody | EnumBooleanMember | EnumDeclaration | EnumDefaultedMember | EnumNumberBody | EnumNumberMember | EnumStringBody | EnumStringMember | EnumSymbolBody | ExistsTypeAnnotation | ExportAllDeclaration | ExportDefaultDeclaration | ExportDefaultSpecifier | ExportNamedDeclaration | ExportNamespaceSpecifier | ExportSpecifier | ExpressionStatement | File | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression$1 | FunctionTypeAnnotation | FunctionTypeParam | GenericTypeAnnotation | Identifier | IfStatement$1 | Import$1 | ImportAttribute | ImportDeclaration | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier | IndexedAccessType | InferredPredicate | InterfaceDeclaration | InterfaceExtends | InterfaceTypeAnnotation | InterpreterDirective | IntersectionTypeAnnotation | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXText | LabeledStatement | LogicalExpression | MemberExpression | MetaProperty | MixedTypeAnnotation | ModuleExpression | NewExpression | Noop | NullLiteral | NullLiteralTypeAnnotation | NullableTypeAnnotation | NumberLiteral$1 | NumberLiteralTypeAnnotation | NumberTypeAnnotation | NumericLiteral | ObjectExpression$1 | ObjectMethod | ObjectPattern | ObjectProperty | ObjectTypeAnnotation | ObjectTypeCallProperty | ObjectTypeIndexer | ObjectTypeInternalSlot | ObjectTypeProperty | ObjectTypeSpreadProperty | OpaqueType | OptionalCallExpression | OptionalIndexedAccessType | OptionalMemberExpression | ParenthesizedExpression | PipelineBareFunction | PipelinePrimaryTopicReference | PipelineTopicExpression | Placeholder | PrivateName | Program | QualifiedTypeIdentifier | RecordExpression | RegExpLiteral | RegexLiteral$1 | RestElement | RestProperty$1 | ReturnStatement$1 | SequenceExpression$1 | SpreadElement | SpreadProperty$1 | StaticBlock | StringLiteral | StringLiteralTypeAnnotation | StringTypeAnnotation | Super | SwitchCase | SwitchStatement | SymbolTypeAnnotation | TSAnyKeyword | TSArrayType | TSAsExpression | TSBigIntKeyword | TSBooleanKeyword | TSCallSignatureDeclaration | TSConditionalType | TSConstructSignatureDeclaration | TSConstructorType | TSDeclareFunction | TSDeclareMethod | TSEnumDeclaration | TSEnumMember | TSExportAssignment | TSExpressionWithTypeArguments | TSExternalModuleReference | TSFunctionType | TSImportEqualsDeclaration | TSImportType | TSIndexSignature | TSIndexedAccessType | TSInferType | TSInstantiationExpression | TSInterfaceBody | TSInterfaceDeclaration | TSIntersectionType | TSIntrinsicKeyword | TSLiteralType | TSMappedType | TSMethodSignature | TSModuleBlock | TSModuleDeclaration | TSNamedTupleMember | TSNamespaceExportDeclaration | TSNeverKeyword | TSNonNullExpression | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSOptionalType | TSParameterProperty | TSParenthesizedType | TSPropertySignature | TSQualifiedName | TSRestType | TSSatisfiesExpression | TSStringKeyword | TSSymbolKeyword | TSThisType | TSTupleType | TSTypeAliasDeclaration | TSTypeAnnotation | TSTypeAssertion | TSTypeLiteral | TSTypeOperator | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUndefinedKeyword | TSUnionType | TSUnknownKeyword | TSVoidKeyword | TaggedTemplateExpression | TemplateElement | TemplateLiteral$1 | ThisExpression | ThisTypeAnnotation | ThrowStatement | TopicReference | TryStatement | TupleExpression | TupleTypeAnnotation | TypeAlias | TypeAnnotation | TypeCastExpression | TypeParameter | TypeParameterDeclaration | TypeParameterInstantiation | TypeofTypeAnnotation | UnaryExpression | UnionTypeAnnotation | UpdateExpression | V8IntrinsicIdentifier | VariableDeclaration | VariableDeclarator | Variance | VoidTypeAnnotation | WhileStatement | WithStatement | YieldExpression;
|
||
interface ArrayExpression$1 extends BaseNode {
|
||
type: "ArrayExpression";
|
||
elements: Array<null | Expression | SpreadElement>;
|
||
}
|
||
interface AssignmentExpression$1 extends BaseNode {
|
||
type: "AssignmentExpression";
|
||
operator: string;
|
||
left: LVal;
|
||
right: Expression;
|
||
}
|
||
interface BinaryExpression extends BaseNode {
|
||
type: "BinaryExpression";
|
||
operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>";
|
||
left: Expression | PrivateName;
|
||
right: Expression;
|
||
}
|
||
interface InterpreterDirective extends BaseNode {
|
||
type: "InterpreterDirective";
|
||
value: string;
|
||
}
|
||
interface Directive extends BaseNode {
|
||
type: "Directive";
|
||
value: DirectiveLiteral;
|
||
}
|
||
interface DirectiveLiteral extends BaseNode {
|
||
type: "DirectiveLiteral";
|
||
value: string;
|
||
}
|
||
interface BlockStatement$1 extends BaseNode {
|
||
type: "BlockStatement";
|
||
body: Array<Statement>;
|
||
directives: Array<Directive>;
|
||
}
|
||
interface BreakStatement extends BaseNode {
|
||
type: "BreakStatement";
|
||
label?: Identifier | null;
|
||
}
|
||
interface CallExpression$1 extends BaseNode {
|
||
type: "CallExpression";
|
||
callee: Expression | Super | V8IntrinsicIdentifier;
|
||
arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>;
|
||
optional?: true | false | null;
|
||
typeArguments?: TypeParameterInstantiation | null;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface CatchClause extends BaseNode {
|
||
type: "CatchClause";
|
||
param?: Identifier | ArrayPattern | ObjectPattern | null;
|
||
body: BlockStatement$1;
|
||
}
|
||
interface ConditionalExpression$1 extends BaseNode {
|
||
type: "ConditionalExpression";
|
||
test: Expression;
|
||
consequent: Expression;
|
||
alternate: Expression;
|
||
}
|
||
interface ContinueStatement extends BaseNode {
|
||
type: "ContinueStatement";
|
||
label?: Identifier | null;
|
||
}
|
||
interface DebuggerStatement extends BaseNode {
|
||
type: "DebuggerStatement";
|
||
}
|
||
interface DoWhileStatement extends BaseNode {
|
||
type: "DoWhileStatement";
|
||
test: Expression;
|
||
body: Statement;
|
||
}
|
||
interface EmptyStatement extends BaseNode {
|
||
type: "EmptyStatement";
|
||
}
|
||
interface ExpressionStatement extends BaseNode {
|
||
type: "ExpressionStatement";
|
||
expression: Expression;
|
||
}
|
||
interface File extends BaseNode {
|
||
type: "File";
|
||
program: Program;
|
||
comments?: Array<CommentBlock | CommentLine> | null;
|
||
tokens?: Array<any> | null;
|
||
}
|
||
interface ForInStatement extends BaseNode {
|
||
type: "ForInStatement";
|
||
left: VariableDeclaration | LVal;
|
||
right: Expression;
|
||
body: Statement;
|
||
}
|
||
interface ForStatement extends BaseNode {
|
||
type: "ForStatement";
|
||
init?: VariableDeclaration | Expression | null;
|
||
test?: Expression | null;
|
||
update?: Expression | null;
|
||
body: Statement;
|
||
}
|
||
interface FunctionDeclaration extends BaseNode {
|
||
type: "FunctionDeclaration";
|
||
id?: Identifier | null;
|
||
params: Array<Identifier | Pattern$1 | RestElement>;
|
||
body: BlockStatement$1;
|
||
generator: boolean;
|
||
async: boolean;
|
||
declare?: boolean | null;
|
||
predicate?: DeclaredPredicate | InferredPredicate | null;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface FunctionExpression$1 extends BaseNode {
|
||
type: "FunctionExpression";
|
||
id?: Identifier | null;
|
||
params: Array<Identifier | Pattern$1 | RestElement>;
|
||
body: BlockStatement$1;
|
||
generator: boolean;
|
||
async: boolean;
|
||
predicate?: DeclaredPredicate | InferredPredicate | null;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface Identifier extends BaseNode {
|
||
type: "Identifier";
|
||
name: string;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
interface IfStatement$1 extends BaseNode {
|
||
type: "IfStatement";
|
||
test: Expression;
|
||
consequent: Statement;
|
||
alternate?: Statement | null;
|
||
}
|
||
interface LabeledStatement extends BaseNode {
|
||
type: "LabeledStatement";
|
||
label: Identifier;
|
||
body: Statement;
|
||
}
|
||
interface StringLiteral extends BaseNode {
|
||
type: "StringLiteral";
|
||
value: string;
|
||
}
|
||
interface NumericLiteral extends BaseNode {
|
||
type: "NumericLiteral";
|
||
value: number;
|
||
}
|
||
/**
|
||
* @deprecated Use `NumericLiteral`
|
||
*/
|
||
interface NumberLiteral$1 extends BaseNode {
|
||
type: "NumberLiteral";
|
||
value: number;
|
||
}
|
||
interface NullLiteral extends BaseNode {
|
||
type: "NullLiteral";
|
||
}
|
||
interface BooleanLiteral extends BaseNode {
|
||
type: "BooleanLiteral";
|
||
value: boolean;
|
||
}
|
||
interface RegExpLiteral extends BaseNode {
|
||
type: "RegExpLiteral";
|
||
pattern: string;
|
||
flags: string;
|
||
}
|
||
/**
|
||
* @deprecated Use `RegExpLiteral`
|
||
*/
|
||
interface RegexLiteral$1 extends BaseNode {
|
||
type: "RegexLiteral";
|
||
pattern: string;
|
||
flags: string;
|
||
}
|
||
interface LogicalExpression extends BaseNode {
|
||
type: "LogicalExpression";
|
||
operator: "||" | "&&" | "??";
|
||
left: Expression;
|
||
right: Expression;
|
||
}
|
||
interface MemberExpression extends BaseNode {
|
||
type: "MemberExpression";
|
||
object: Expression | Super;
|
||
property: Expression | Identifier | PrivateName;
|
||
computed: boolean;
|
||
optional?: true | false | null;
|
||
}
|
||
interface NewExpression extends BaseNode {
|
||
type: "NewExpression";
|
||
callee: Expression | Super | V8IntrinsicIdentifier;
|
||
arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>;
|
||
optional?: true | false | null;
|
||
typeArguments?: TypeParameterInstantiation | null;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface Program extends BaseNode {
|
||
type: "Program";
|
||
body: Array<Statement>;
|
||
directives: Array<Directive>;
|
||
sourceType: "script" | "module";
|
||
interpreter?: InterpreterDirective | null;
|
||
sourceFile: string;
|
||
}
|
||
interface ObjectExpression$1 extends BaseNode {
|
||
type: "ObjectExpression";
|
||
properties: Array<ObjectMethod | ObjectProperty | SpreadElement>;
|
||
}
|
||
interface ObjectMethod extends BaseNode {
|
||
type: "ObjectMethod";
|
||
kind: "method" | "get" | "set";
|
||
key: Expression | Identifier | StringLiteral | NumericLiteral | BigIntLiteral;
|
||
params: Array<Identifier | Pattern$1 | RestElement>;
|
||
body: BlockStatement$1;
|
||
computed: boolean;
|
||
generator: boolean;
|
||
async: boolean;
|
||
decorators?: Array<Decorator> | null;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface ObjectProperty extends BaseNode {
|
||
type: "ObjectProperty";
|
||
key: Expression | Identifier | StringLiteral | NumericLiteral | BigIntLiteral | DecimalLiteral | PrivateName;
|
||
value: Expression | PatternLike;
|
||
computed: boolean;
|
||
shorthand: boolean;
|
||
decorators?: Array<Decorator> | null;
|
||
}
|
||
interface RestElement extends BaseNode {
|
||
type: "RestElement";
|
||
argument: LVal;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
/**
|
||
* @deprecated Use `RestElement`
|
||
*/
|
||
interface RestProperty$1 extends BaseNode {
|
||
type: "RestProperty";
|
||
argument: LVal;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
interface ReturnStatement$1 extends BaseNode {
|
||
type: "ReturnStatement";
|
||
argument?: Expression | null;
|
||
}
|
||
interface SequenceExpression$1 extends BaseNode {
|
||
type: "SequenceExpression";
|
||
expressions: Array<Expression>;
|
||
}
|
||
interface ParenthesizedExpression extends BaseNode {
|
||
type: "ParenthesizedExpression";
|
||
expression: Expression;
|
||
}
|
||
interface SwitchCase extends BaseNode {
|
||
type: "SwitchCase";
|
||
test?: Expression | null;
|
||
consequent: Array<Statement>;
|
||
}
|
||
interface SwitchStatement extends BaseNode {
|
||
type: "SwitchStatement";
|
||
discriminant: Expression;
|
||
cases: Array<SwitchCase>;
|
||
}
|
||
interface ThisExpression extends BaseNode {
|
||
type: "ThisExpression";
|
||
}
|
||
interface ThrowStatement extends BaseNode {
|
||
type: "ThrowStatement";
|
||
argument: Expression;
|
||
}
|
||
interface TryStatement extends BaseNode {
|
||
type: "TryStatement";
|
||
block: BlockStatement$1;
|
||
handler?: CatchClause | null;
|
||
finalizer?: BlockStatement$1 | null;
|
||
}
|
||
interface UnaryExpression extends BaseNode {
|
||
type: "UnaryExpression";
|
||
operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof";
|
||
argument: Expression;
|
||
prefix: boolean;
|
||
}
|
||
interface UpdateExpression extends BaseNode {
|
||
type: "UpdateExpression";
|
||
operator: "++" | "--";
|
||
argument: Expression;
|
||
prefix: boolean;
|
||
}
|
||
interface VariableDeclaration extends BaseNode {
|
||
type: "VariableDeclaration";
|
||
kind: "var" | "let" | "const" | "using" | "await using";
|
||
declarations: Array<VariableDeclarator>;
|
||
declare?: boolean | null;
|
||
}
|
||
interface VariableDeclarator extends BaseNode {
|
||
type: "VariableDeclarator";
|
||
id: LVal;
|
||
init?: Expression | null;
|
||
definite?: boolean | null;
|
||
}
|
||
interface WhileStatement extends BaseNode {
|
||
type: "WhileStatement";
|
||
test: Expression;
|
||
body: Statement;
|
||
}
|
||
interface WithStatement extends BaseNode {
|
||
type: "WithStatement";
|
||
object: Expression;
|
||
body: Statement;
|
||
}
|
||
interface AssignmentPattern extends BaseNode {
|
||
type: "AssignmentPattern";
|
||
left: Identifier | ObjectPattern | ArrayPattern | MemberExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression;
|
||
right: Expression;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
interface ArrayPattern extends BaseNode {
|
||
type: "ArrayPattern";
|
||
elements: Array<null | PatternLike | LVal>;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
interface ArrowFunctionExpression extends BaseNode {
|
||
type: "ArrowFunctionExpression";
|
||
params: Array<Identifier | Pattern$1 | RestElement>;
|
||
body: BlockStatement$1 | Expression;
|
||
async: boolean;
|
||
expression: boolean;
|
||
generator?: boolean;
|
||
predicate?: DeclaredPredicate | InferredPredicate | null;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface ClassBody extends BaseNode {
|
||
type: "ClassBody";
|
||
body: Array<ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock>;
|
||
}
|
||
interface ClassExpression extends BaseNode {
|
||
type: "ClassExpression";
|
||
id?: Identifier | null;
|
||
superClass?: Expression | null;
|
||
body: ClassBody;
|
||
decorators?: Array<Decorator> | null;
|
||
implements?: Array<TSExpressionWithTypeArguments | ClassImplements> | null;
|
||
mixins?: InterfaceExtends | null;
|
||
superTypeParameters?: TypeParameterInstantiation | TSTypeParameterInstantiation | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface ClassDeclaration extends BaseNode {
|
||
type: "ClassDeclaration";
|
||
id?: Identifier | null;
|
||
superClass?: Expression | null;
|
||
body: ClassBody;
|
||
decorators?: Array<Decorator> | null;
|
||
abstract?: boolean | null;
|
||
declare?: boolean | null;
|
||
implements?: Array<TSExpressionWithTypeArguments | ClassImplements> | null;
|
||
mixins?: InterfaceExtends | null;
|
||
superTypeParameters?: TypeParameterInstantiation | TSTypeParameterInstantiation | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface ExportAllDeclaration extends BaseNode {
|
||
type: "ExportAllDeclaration";
|
||
source: StringLiteral;
|
||
assertions?: Array<ImportAttribute> | null;
|
||
attributes?: Array<ImportAttribute> | null;
|
||
exportKind?: "type" | "value" | null;
|
||
}
|
||
interface ExportDefaultDeclaration extends BaseNode {
|
||
type: "ExportDefaultDeclaration";
|
||
declaration: TSDeclareFunction | FunctionDeclaration | ClassDeclaration | Expression;
|
||
exportKind?: "value" | null;
|
||
}
|
||
interface ExportNamedDeclaration extends BaseNode {
|
||
type: "ExportNamedDeclaration";
|
||
declaration?: Declaration | null;
|
||
specifiers: Array<ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier>;
|
||
source?: StringLiteral | null;
|
||
assertions?: Array<ImportAttribute> | null;
|
||
attributes?: Array<ImportAttribute> | null;
|
||
exportKind?: "type" | "value" | null;
|
||
}
|
||
interface ExportSpecifier extends BaseNode {
|
||
type: "ExportSpecifier";
|
||
local: Identifier;
|
||
exported: Identifier | StringLiteral;
|
||
exportKind?: "type" | "value" | null;
|
||
}
|
||
interface ForOfStatement extends BaseNode {
|
||
type: "ForOfStatement";
|
||
left: VariableDeclaration | LVal;
|
||
right: Expression;
|
||
body: Statement;
|
||
await: boolean;
|
||
}
|
||
interface ImportDeclaration extends BaseNode {
|
||
type: "ImportDeclaration";
|
||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
||
source: StringLiteral;
|
||
assertions?: Array<ImportAttribute> | null;
|
||
attributes?: Array<ImportAttribute> | null;
|
||
importKind?: "type" | "typeof" | "value" | null;
|
||
module?: boolean | null;
|
||
}
|
||
interface ImportDefaultSpecifier extends BaseNode {
|
||
type: "ImportDefaultSpecifier";
|
||
local: Identifier;
|
||
}
|
||
interface ImportNamespaceSpecifier extends BaseNode {
|
||
type: "ImportNamespaceSpecifier";
|
||
local: Identifier;
|
||
}
|
||
interface ImportSpecifier extends BaseNode {
|
||
type: "ImportSpecifier";
|
||
local: Identifier;
|
||
imported: Identifier | StringLiteral;
|
||
importKind?: "type" | "typeof" | "value" | null;
|
||
}
|
||
interface MetaProperty extends BaseNode {
|
||
type: "MetaProperty";
|
||
meta: Identifier;
|
||
property: Identifier;
|
||
}
|
||
interface ClassMethod extends BaseNode {
|
||
type: "ClassMethod";
|
||
kind: "get" | "set" | "method" | "constructor";
|
||
key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression;
|
||
params: Array<Identifier | Pattern$1 | RestElement | TSParameterProperty>;
|
||
body: BlockStatement$1;
|
||
computed: boolean;
|
||
static: boolean;
|
||
generator: boolean;
|
||
async: boolean;
|
||
abstract?: boolean | null;
|
||
access?: "public" | "private" | "protected" | null;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
override?: boolean;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface ObjectPattern extends BaseNode {
|
||
type: "ObjectPattern";
|
||
properties: Array<RestElement | ObjectProperty>;
|
||
decorators?: Array<Decorator> | null;
|
||
optional?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
}
|
||
interface SpreadElement extends BaseNode {
|
||
type: "SpreadElement";
|
||
argument: Expression;
|
||
}
|
||
/**
|
||
* @deprecated Use `SpreadElement`
|
||
*/
|
||
interface SpreadProperty$1 extends BaseNode {
|
||
type: "SpreadProperty";
|
||
argument: Expression;
|
||
}
|
||
interface Super extends BaseNode {
|
||
type: "Super";
|
||
}
|
||
interface TaggedTemplateExpression extends BaseNode {
|
||
type: "TaggedTemplateExpression";
|
||
tag: Expression;
|
||
quasi: TemplateLiteral$1;
|
||
typeParameters?: TypeParameterInstantiation | TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TemplateElement extends BaseNode {
|
||
type: "TemplateElement";
|
||
value: {
|
||
raw: string;
|
||
cooked?: string;
|
||
};
|
||
tail: boolean;
|
||
}
|
||
interface TemplateLiteral$1 extends BaseNode {
|
||
type: "TemplateLiteral";
|
||
quasis: Array<TemplateElement>;
|
||
expressions: Array<Expression | TSType>;
|
||
}
|
||
interface YieldExpression extends BaseNode {
|
||
type: "YieldExpression";
|
||
argument?: Expression | null;
|
||
delegate: boolean;
|
||
}
|
||
interface AwaitExpression extends BaseNode {
|
||
type: "AwaitExpression";
|
||
argument: Expression;
|
||
}
|
||
interface Import$1 extends BaseNode {
|
||
type: "Import";
|
||
}
|
||
interface BigIntLiteral extends BaseNode {
|
||
type: "BigIntLiteral";
|
||
value: string;
|
||
}
|
||
interface ExportNamespaceSpecifier extends BaseNode {
|
||
type: "ExportNamespaceSpecifier";
|
||
exported: Identifier;
|
||
}
|
||
interface OptionalMemberExpression extends BaseNode {
|
||
type: "OptionalMemberExpression";
|
||
object: Expression;
|
||
property: Expression | Identifier;
|
||
computed: boolean;
|
||
optional: boolean;
|
||
}
|
||
interface OptionalCallExpression extends BaseNode {
|
||
type: "OptionalCallExpression";
|
||
callee: Expression;
|
||
arguments: Array<Expression | SpreadElement | JSXNamespacedName | ArgumentPlaceholder>;
|
||
optional: boolean;
|
||
typeArguments?: TypeParameterInstantiation | null;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface ClassProperty extends BaseNode {
|
||
type: "ClassProperty";
|
||
key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression;
|
||
value?: Expression | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
decorators?: Array<Decorator> | null;
|
||
computed: boolean;
|
||
static: boolean;
|
||
abstract?: boolean | null;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
declare?: boolean | null;
|
||
definite?: boolean | null;
|
||
optional?: boolean | null;
|
||
override?: boolean;
|
||
readonly?: boolean | null;
|
||
variance?: Variance | null;
|
||
}
|
||
interface ClassAccessorProperty extends BaseNode {
|
||
type: "ClassAccessorProperty";
|
||
key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression | PrivateName;
|
||
value?: Expression | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
decorators?: Array<Decorator> | null;
|
||
computed: boolean;
|
||
static: boolean;
|
||
abstract?: boolean | null;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
declare?: boolean | null;
|
||
definite?: boolean | null;
|
||
optional?: boolean | null;
|
||
override?: boolean;
|
||
readonly?: boolean | null;
|
||
variance?: Variance | null;
|
||
}
|
||
interface ClassPrivateProperty extends BaseNode {
|
||
type: "ClassPrivateProperty";
|
||
key: PrivateName;
|
||
value?: Expression | null;
|
||
decorators?: Array<Decorator> | null;
|
||
static: boolean;
|
||
definite?: boolean | null;
|
||
readonly?: boolean | null;
|
||
typeAnnotation?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
variance?: Variance | null;
|
||
}
|
||
interface ClassPrivateMethod extends BaseNode {
|
||
type: "ClassPrivateMethod";
|
||
kind: "get" | "set" | "method";
|
||
key: PrivateName;
|
||
params: Array<Identifier | Pattern$1 | RestElement | TSParameterProperty>;
|
||
body: BlockStatement$1;
|
||
static: boolean;
|
||
abstract?: boolean | null;
|
||
access?: "public" | "private" | "protected" | null;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
async?: boolean;
|
||
computed?: boolean;
|
||
decorators?: Array<Decorator> | null;
|
||
generator?: boolean;
|
||
optional?: boolean | null;
|
||
override?: boolean;
|
||
returnType?: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
||
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
||
}
|
||
interface PrivateName extends BaseNode {
|
||
type: "PrivateName";
|
||
id: Identifier;
|
||
}
|
||
interface StaticBlock extends BaseNode {
|
||
type: "StaticBlock";
|
||
body: Array<Statement>;
|
||
}
|
||
interface AnyTypeAnnotation extends BaseNode {
|
||
type: "AnyTypeAnnotation";
|
||
}
|
||
interface ArrayTypeAnnotation extends BaseNode {
|
||
type: "ArrayTypeAnnotation";
|
||
elementType: FlowType;
|
||
}
|
||
interface BooleanTypeAnnotation extends BaseNode {
|
||
type: "BooleanTypeAnnotation";
|
||
}
|
||
interface BooleanLiteralTypeAnnotation extends BaseNode {
|
||
type: "BooleanLiteralTypeAnnotation";
|
||
value: boolean;
|
||
}
|
||
interface NullLiteralTypeAnnotation extends BaseNode {
|
||
type: "NullLiteralTypeAnnotation";
|
||
}
|
||
interface ClassImplements extends BaseNode {
|
||
type: "ClassImplements";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterInstantiation | null;
|
||
}
|
||
interface DeclareClass extends BaseNode {
|
||
type: "DeclareClass";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
extends?: Array<InterfaceExtends> | null;
|
||
body: ObjectTypeAnnotation;
|
||
implements?: Array<ClassImplements> | null;
|
||
mixins?: Array<InterfaceExtends> | null;
|
||
}
|
||
interface DeclareFunction extends BaseNode {
|
||
type: "DeclareFunction";
|
||
id: Identifier;
|
||
predicate?: DeclaredPredicate | null;
|
||
}
|
||
interface DeclareInterface extends BaseNode {
|
||
type: "DeclareInterface";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
extends?: Array<InterfaceExtends> | null;
|
||
body: ObjectTypeAnnotation;
|
||
}
|
||
interface DeclareModule extends BaseNode {
|
||
type: "DeclareModule";
|
||
id: Identifier | StringLiteral;
|
||
body: BlockStatement$1;
|
||
kind?: "CommonJS" | "ES" | null;
|
||
}
|
||
interface DeclareModuleExports extends BaseNode {
|
||
type: "DeclareModuleExports";
|
||
typeAnnotation: TypeAnnotation;
|
||
}
|
||
interface DeclareTypeAlias extends BaseNode {
|
||
type: "DeclareTypeAlias";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
right: FlowType;
|
||
}
|
||
interface DeclareOpaqueType extends BaseNode {
|
||
type: "DeclareOpaqueType";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
supertype?: FlowType | null;
|
||
impltype?: FlowType | null;
|
||
}
|
||
interface DeclareVariable extends BaseNode {
|
||
type: "DeclareVariable";
|
||
id: Identifier;
|
||
}
|
||
interface DeclareExportDeclaration extends BaseNode {
|
||
type: "DeclareExportDeclaration";
|
||
declaration?: Flow | null;
|
||
specifiers?: Array<ExportSpecifier | ExportNamespaceSpecifier> | null;
|
||
source?: StringLiteral | null;
|
||
default?: boolean | null;
|
||
}
|
||
interface DeclareExportAllDeclaration extends BaseNode {
|
||
type: "DeclareExportAllDeclaration";
|
||
source: StringLiteral;
|
||
exportKind?: "type" | "value" | null;
|
||
}
|
||
interface DeclaredPredicate extends BaseNode {
|
||
type: "DeclaredPredicate";
|
||
value: Flow;
|
||
}
|
||
interface ExistsTypeAnnotation extends BaseNode {
|
||
type: "ExistsTypeAnnotation";
|
||
}
|
||
interface FunctionTypeAnnotation extends BaseNode {
|
||
type: "FunctionTypeAnnotation";
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
params: Array<FunctionTypeParam>;
|
||
rest?: FunctionTypeParam | null;
|
||
returnType: FlowType;
|
||
this?: FunctionTypeParam | null;
|
||
}
|
||
interface FunctionTypeParam extends BaseNode {
|
||
type: "FunctionTypeParam";
|
||
name?: Identifier | null;
|
||
typeAnnotation: FlowType;
|
||
optional?: boolean | null;
|
||
}
|
||
interface GenericTypeAnnotation extends BaseNode {
|
||
type: "GenericTypeAnnotation";
|
||
id: Identifier | QualifiedTypeIdentifier;
|
||
typeParameters?: TypeParameterInstantiation | null;
|
||
}
|
||
interface InferredPredicate extends BaseNode {
|
||
type: "InferredPredicate";
|
||
}
|
||
interface InterfaceExtends extends BaseNode {
|
||
type: "InterfaceExtends";
|
||
id: Identifier | QualifiedTypeIdentifier;
|
||
typeParameters?: TypeParameterInstantiation | null;
|
||
}
|
||
interface InterfaceDeclaration extends BaseNode {
|
||
type: "InterfaceDeclaration";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
extends?: Array<InterfaceExtends> | null;
|
||
body: ObjectTypeAnnotation;
|
||
}
|
||
interface InterfaceTypeAnnotation extends BaseNode {
|
||
type: "InterfaceTypeAnnotation";
|
||
extends?: Array<InterfaceExtends> | null;
|
||
body: ObjectTypeAnnotation;
|
||
}
|
||
interface IntersectionTypeAnnotation extends BaseNode {
|
||
type: "IntersectionTypeAnnotation";
|
||
types: Array<FlowType>;
|
||
}
|
||
interface MixedTypeAnnotation extends BaseNode {
|
||
type: "MixedTypeAnnotation";
|
||
}
|
||
interface EmptyTypeAnnotation extends BaseNode {
|
||
type: "EmptyTypeAnnotation";
|
||
}
|
||
interface NullableTypeAnnotation extends BaseNode {
|
||
type: "NullableTypeAnnotation";
|
||
typeAnnotation: FlowType;
|
||
}
|
||
interface NumberLiteralTypeAnnotation extends BaseNode {
|
||
type: "NumberLiteralTypeAnnotation";
|
||
value: number;
|
||
}
|
||
interface NumberTypeAnnotation extends BaseNode {
|
||
type: "NumberTypeAnnotation";
|
||
}
|
||
interface ObjectTypeAnnotation extends BaseNode {
|
||
type: "ObjectTypeAnnotation";
|
||
properties: Array<ObjectTypeProperty | ObjectTypeSpreadProperty>;
|
||
indexers?: Array<ObjectTypeIndexer>;
|
||
callProperties?: Array<ObjectTypeCallProperty>;
|
||
internalSlots?: Array<ObjectTypeInternalSlot>;
|
||
exact: boolean;
|
||
inexact?: boolean | null;
|
||
}
|
||
interface ObjectTypeInternalSlot extends BaseNode {
|
||
type: "ObjectTypeInternalSlot";
|
||
id: Identifier;
|
||
value: FlowType;
|
||
optional: boolean;
|
||
static: boolean;
|
||
method: boolean;
|
||
}
|
||
interface ObjectTypeCallProperty extends BaseNode {
|
||
type: "ObjectTypeCallProperty";
|
||
value: FlowType;
|
||
static: boolean;
|
||
}
|
||
interface ObjectTypeIndexer extends BaseNode {
|
||
type: "ObjectTypeIndexer";
|
||
id?: Identifier | null;
|
||
key: FlowType;
|
||
value: FlowType;
|
||
variance?: Variance | null;
|
||
static: boolean;
|
||
}
|
||
interface ObjectTypeProperty extends BaseNode {
|
||
type: "ObjectTypeProperty";
|
||
key: Identifier | StringLiteral;
|
||
value: FlowType;
|
||
variance?: Variance | null;
|
||
kind: "init" | "get" | "set";
|
||
method: boolean;
|
||
optional: boolean;
|
||
proto: boolean;
|
||
static: boolean;
|
||
}
|
||
interface ObjectTypeSpreadProperty extends BaseNode {
|
||
type: "ObjectTypeSpreadProperty";
|
||
argument: FlowType;
|
||
}
|
||
interface OpaqueType extends BaseNode {
|
||
type: "OpaqueType";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
supertype?: FlowType | null;
|
||
impltype: FlowType;
|
||
}
|
||
interface QualifiedTypeIdentifier extends BaseNode {
|
||
type: "QualifiedTypeIdentifier";
|
||
id: Identifier;
|
||
qualification: Identifier | QualifiedTypeIdentifier;
|
||
}
|
||
interface StringLiteralTypeAnnotation extends BaseNode {
|
||
type: "StringLiteralTypeAnnotation";
|
||
value: string;
|
||
}
|
||
interface StringTypeAnnotation extends BaseNode {
|
||
type: "StringTypeAnnotation";
|
||
}
|
||
interface SymbolTypeAnnotation extends BaseNode {
|
||
type: "SymbolTypeAnnotation";
|
||
}
|
||
interface ThisTypeAnnotation extends BaseNode {
|
||
type: "ThisTypeAnnotation";
|
||
}
|
||
interface TupleTypeAnnotation extends BaseNode {
|
||
type: "TupleTypeAnnotation";
|
||
types: Array<FlowType>;
|
||
}
|
||
interface TypeofTypeAnnotation extends BaseNode {
|
||
type: "TypeofTypeAnnotation";
|
||
argument: FlowType;
|
||
}
|
||
interface TypeAlias extends BaseNode {
|
||
type: "TypeAlias";
|
||
id: Identifier;
|
||
typeParameters?: TypeParameterDeclaration | null;
|
||
right: FlowType;
|
||
}
|
||
interface TypeAnnotation extends BaseNode {
|
||
type: "TypeAnnotation";
|
||
typeAnnotation: FlowType;
|
||
}
|
||
interface TypeCastExpression extends BaseNode {
|
||
type: "TypeCastExpression";
|
||
expression: Expression;
|
||
typeAnnotation: TypeAnnotation;
|
||
}
|
||
interface TypeParameter extends BaseNode {
|
||
type: "TypeParameter";
|
||
bound?: TypeAnnotation | null;
|
||
default?: FlowType | null;
|
||
variance?: Variance | null;
|
||
name: string;
|
||
}
|
||
interface TypeParameterDeclaration extends BaseNode {
|
||
type: "TypeParameterDeclaration";
|
||
params: Array<TypeParameter>;
|
||
}
|
||
interface TypeParameterInstantiation extends BaseNode {
|
||
type: "TypeParameterInstantiation";
|
||
params: Array<FlowType>;
|
||
}
|
||
interface UnionTypeAnnotation extends BaseNode {
|
||
type: "UnionTypeAnnotation";
|
||
types: Array<FlowType>;
|
||
}
|
||
interface Variance extends BaseNode {
|
||
type: "Variance";
|
||
kind: "minus" | "plus";
|
||
}
|
||
interface VoidTypeAnnotation extends BaseNode {
|
||
type: "VoidTypeAnnotation";
|
||
}
|
||
interface EnumDeclaration extends BaseNode {
|
||
type: "EnumDeclaration";
|
||
id: Identifier;
|
||
body: EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody;
|
||
}
|
||
interface EnumBooleanBody extends BaseNode {
|
||
type: "EnumBooleanBody";
|
||
members: Array<EnumBooleanMember>;
|
||
explicitType: boolean;
|
||
hasUnknownMembers: boolean;
|
||
}
|
||
interface EnumNumberBody extends BaseNode {
|
||
type: "EnumNumberBody";
|
||
members: Array<EnumNumberMember>;
|
||
explicitType: boolean;
|
||
hasUnknownMembers: boolean;
|
||
}
|
||
interface EnumStringBody extends BaseNode {
|
||
type: "EnumStringBody";
|
||
members: Array<EnumStringMember | EnumDefaultedMember>;
|
||
explicitType: boolean;
|
||
hasUnknownMembers: boolean;
|
||
}
|
||
interface EnumSymbolBody extends BaseNode {
|
||
type: "EnumSymbolBody";
|
||
members: Array<EnumDefaultedMember>;
|
||
hasUnknownMembers: boolean;
|
||
}
|
||
interface EnumBooleanMember extends BaseNode {
|
||
type: "EnumBooleanMember";
|
||
id: Identifier;
|
||
init: BooleanLiteral;
|
||
}
|
||
interface EnumNumberMember extends BaseNode {
|
||
type: "EnumNumberMember";
|
||
id: Identifier;
|
||
init: NumericLiteral;
|
||
}
|
||
interface EnumStringMember extends BaseNode {
|
||
type: "EnumStringMember";
|
||
id: Identifier;
|
||
init: StringLiteral;
|
||
}
|
||
interface EnumDefaultedMember extends BaseNode {
|
||
type: "EnumDefaultedMember";
|
||
id: Identifier;
|
||
}
|
||
interface IndexedAccessType extends BaseNode {
|
||
type: "IndexedAccessType";
|
||
objectType: FlowType;
|
||
indexType: FlowType;
|
||
}
|
||
interface OptionalIndexedAccessType extends BaseNode {
|
||
type: "OptionalIndexedAccessType";
|
||
objectType: FlowType;
|
||
indexType: FlowType;
|
||
optional: boolean;
|
||
}
|
||
interface JSXAttribute extends BaseNode {
|
||
type: "JSXAttribute";
|
||
name: JSXIdentifier | JSXNamespacedName;
|
||
value?: JSXElement | JSXFragment | StringLiteral | JSXExpressionContainer | null;
|
||
}
|
||
interface JSXClosingElement extends BaseNode {
|
||
type: "JSXClosingElement";
|
||
name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName;
|
||
}
|
||
interface JSXElement extends BaseNode {
|
||
type: "JSXElement";
|
||
openingElement: JSXOpeningElement;
|
||
closingElement?: JSXClosingElement | null;
|
||
children: Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>;
|
||
selfClosing?: boolean | null;
|
||
}
|
||
interface JSXEmptyExpression extends BaseNode {
|
||
type: "JSXEmptyExpression";
|
||
}
|
||
interface JSXExpressionContainer extends BaseNode {
|
||
type: "JSXExpressionContainer";
|
||
expression: Expression | JSXEmptyExpression;
|
||
}
|
||
interface JSXSpreadChild extends BaseNode {
|
||
type: "JSXSpreadChild";
|
||
expression: Expression;
|
||
}
|
||
interface JSXIdentifier extends BaseNode {
|
||
type: "JSXIdentifier";
|
||
name: string;
|
||
}
|
||
interface JSXMemberExpression extends BaseNode {
|
||
type: "JSXMemberExpression";
|
||
object: JSXMemberExpression | JSXIdentifier;
|
||
property: JSXIdentifier;
|
||
}
|
||
interface JSXNamespacedName extends BaseNode {
|
||
type: "JSXNamespacedName";
|
||
namespace: JSXIdentifier;
|
||
name: JSXIdentifier;
|
||
}
|
||
interface JSXOpeningElement extends BaseNode {
|
||
type: "JSXOpeningElement";
|
||
name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName;
|
||
attributes: Array<JSXAttribute | JSXSpreadAttribute>;
|
||
selfClosing: boolean;
|
||
typeParameters?: TypeParameterInstantiation | TSTypeParameterInstantiation | null;
|
||
}
|
||
interface JSXSpreadAttribute extends BaseNode {
|
||
type: "JSXSpreadAttribute";
|
||
argument: Expression;
|
||
}
|
||
interface JSXText extends BaseNode {
|
||
type: "JSXText";
|
||
value: string;
|
||
}
|
||
interface JSXFragment extends BaseNode {
|
||
type: "JSXFragment";
|
||
openingFragment: JSXOpeningFragment;
|
||
closingFragment: JSXClosingFragment;
|
||
children: Array<JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment>;
|
||
}
|
||
interface JSXOpeningFragment extends BaseNode {
|
||
type: "JSXOpeningFragment";
|
||
}
|
||
interface JSXClosingFragment extends BaseNode {
|
||
type: "JSXClosingFragment";
|
||
}
|
||
interface Noop extends BaseNode {
|
||
type: "Noop";
|
||
}
|
||
interface Placeholder extends BaseNode {
|
||
type: "Placeholder";
|
||
expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern";
|
||
name: Identifier;
|
||
}
|
||
interface V8IntrinsicIdentifier extends BaseNode {
|
||
type: "V8IntrinsicIdentifier";
|
||
name: string;
|
||
}
|
||
interface ArgumentPlaceholder extends BaseNode {
|
||
type: "ArgumentPlaceholder";
|
||
}
|
||
interface BindExpression extends BaseNode {
|
||
type: "BindExpression";
|
||
object: Expression;
|
||
callee: Expression;
|
||
}
|
||
interface ImportAttribute extends BaseNode {
|
||
type: "ImportAttribute";
|
||
key: Identifier | StringLiteral;
|
||
value: StringLiteral;
|
||
}
|
||
interface Decorator extends BaseNode {
|
||
type: "Decorator";
|
||
expression: Expression;
|
||
}
|
||
interface DoExpression extends BaseNode {
|
||
type: "DoExpression";
|
||
body: BlockStatement$1;
|
||
async: boolean;
|
||
}
|
||
interface ExportDefaultSpecifier extends BaseNode {
|
||
type: "ExportDefaultSpecifier";
|
||
exported: Identifier;
|
||
}
|
||
interface RecordExpression extends BaseNode {
|
||
type: "RecordExpression";
|
||
properties: Array<ObjectProperty | SpreadElement>;
|
||
}
|
||
interface TupleExpression extends BaseNode {
|
||
type: "TupleExpression";
|
||
elements: Array<Expression | SpreadElement>;
|
||
}
|
||
interface DecimalLiteral extends BaseNode {
|
||
type: "DecimalLiteral";
|
||
value: string;
|
||
}
|
||
interface ModuleExpression extends BaseNode {
|
||
type: "ModuleExpression";
|
||
body: Program;
|
||
}
|
||
interface TopicReference extends BaseNode {
|
||
type: "TopicReference";
|
||
}
|
||
interface PipelineTopicExpression extends BaseNode {
|
||
type: "PipelineTopicExpression";
|
||
expression: Expression;
|
||
}
|
||
interface PipelineBareFunction extends BaseNode {
|
||
type: "PipelineBareFunction";
|
||
callee: Expression;
|
||
}
|
||
interface PipelinePrimaryTopicReference extends BaseNode {
|
||
type: "PipelinePrimaryTopicReference";
|
||
}
|
||
interface TSParameterProperty extends BaseNode {
|
||
type: "TSParameterProperty";
|
||
parameter: Identifier | AssignmentPattern;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
decorators?: Array<Decorator> | null;
|
||
override?: boolean | null;
|
||
readonly?: boolean | null;
|
||
}
|
||
interface TSDeclareFunction extends BaseNode {
|
||
type: "TSDeclareFunction";
|
||
id?: Identifier | null;
|
||
typeParameters?: TSTypeParameterDeclaration | Noop | null;
|
||
params: Array<Identifier | Pattern$1 | RestElement>;
|
||
returnType?: TSTypeAnnotation | Noop | null;
|
||
async?: boolean;
|
||
declare?: boolean | null;
|
||
generator?: boolean;
|
||
}
|
||
interface TSDeclareMethod extends BaseNode {
|
||
type: "TSDeclareMethod";
|
||
decorators?: Array<Decorator> | null;
|
||
key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral | Expression;
|
||
typeParameters?: TSTypeParameterDeclaration | Noop | null;
|
||
params: Array<Identifier | Pattern$1 | RestElement | TSParameterProperty>;
|
||
returnType?: TSTypeAnnotation | Noop | null;
|
||
abstract?: boolean | null;
|
||
access?: "public" | "private" | "protected" | null;
|
||
accessibility?: "public" | "private" | "protected" | null;
|
||
async?: boolean;
|
||
computed?: boolean;
|
||
generator?: boolean;
|
||
kind?: "get" | "set" | "method" | "constructor";
|
||
optional?: boolean | null;
|
||
override?: boolean;
|
||
static?: boolean;
|
||
}
|
||
interface TSQualifiedName extends BaseNode {
|
||
type: "TSQualifiedName";
|
||
left: TSEntityName;
|
||
right: Identifier;
|
||
}
|
||
interface TSCallSignatureDeclaration extends BaseNode {
|
||
type: "TSCallSignatureDeclaration";
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
}
|
||
interface TSConstructSignatureDeclaration extends BaseNode {
|
||
type: "TSConstructSignatureDeclaration";
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
}
|
||
interface TSPropertySignature extends BaseNode {
|
||
type: "TSPropertySignature";
|
||
key: Expression;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
initializer?: Expression | null;
|
||
computed?: boolean;
|
||
kind: "get" | "set";
|
||
optional?: boolean | null;
|
||
readonly?: boolean | null;
|
||
}
|
||
interface TSMethodSignature extends BaseNode {
|
||
type: "TSMethodSignature";
|
||
key: Expression;
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
computed?: boolean;
|
||
kind: "method" | "get" | "set";
|
||
optional?: boolean | null;
|
||
}
|
||
interface TSIndexSignature extends BaseNode {
|
||
type: "TSIndexSignature";
|
||
parameters: Array<Identifier>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
readonly?: boolean | null;
|
||
static?: boolean | null;
|
||
}
|
||
interface TSAnyKeyword extends BaseNode {
|
||
type: "TSAnyKeyword";
|
||
}
|
||
interface TSBooleanKeyword extends BaseNode {
|
||
type: "TSBooleanKeyword";
|
||
}
|
||
interface TSBigIntKeyword extends BaseNode {
|
||
type: "TSBigIntKeyword";
|
||
}
|
||
interface TSIntrinsicKeyword extends BaseNode {
|
||
type: "TSIntrinsicKeyword";
|
||
}
|
||
interface TSNeverKeyword extends BaseNode {
|
||
type: "TSNeverKeyword";
|
||
}
|
||
interface TSNullKeyword extends BaseNode {
|
||
type: "TSNullKeyword";
|
||
}
|
||
interface TSNumberKeyword extends BaseNode {
|
||
type: "TSNumberKeyword";
|
||
}
|
||
interface TSObjectKeyword extends BaseNode {
|
||
type: "TSObjectKeyword";
|
||
}
|
||
interface TSStringKeyword extends BaseNode {
|
||
type: "TSStringKeyword";
|
||
}
|
||
interface TSSymbolKeyword extends BaseNode {
|
||
type: "TSSymbolKeyword";
|
||
}
|
||
interface TSUndefinedKeyword extends BaseNode {
|
||
type: "TSUndefinedKeyword";
|
||
}
|
||
interface TSUnknownKeyword extends BaseNode {
|
||
type: "TSUnknownKeyword";
|
||
}
|
||
interface TSVoidKeyword extends BaseNode {
|
||
type: "TSVoidKeyword";
|
||
}
|
||
interface TSThisType extends BaseNode {
|
||
type: "TSThisType";
|
||
}
|
||
interface TSFunctionType extends BaseNode {
|
||
type: "TSFunctionType";
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
}
|
||
interface TSConstructorType extends BaseNode {
|
||
type: "TSConstructorType";
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
abstract?: boolean | null;
|
||
}
|
||
interface TSTypeReference extends BaseNode {
|
||
type: "TSTypeReference";
|
||
typeName: TSEntityName;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TSTypePredicate extends BaseNode {
|
||
type: "TSTypePredicate";
|
||
parameterName: Identifier | TSThisType;
|
||
typeAnnotation?: TSTypeAnnotation | null;
|
||
asserts?: boolean | null;
|
||
}
|
||
interface TSTypeQuery extends BaseNode {
|
||
type: "TSTypeQuery";
|
||
exprName: TSEntityName | TSImportType;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TSTypeLiteral extends BaseNode {
|
||
type: "TSTypeLiteral";
|
||
members: Array<TSTypeElement>;
|
||
}
|
||
interface TSArrayType extends BaseNode {
|
||
type: "TSArrayType";
|
||
elementType: TSType;
|
||
}
|
||
interface TSTupleType extends BaseNode {
|
||
type: "TSTupleType";
|
||
elementTypes: Array<TSType | TSNamedTupleMember>;
|
||
}
|
||
interface TSOptionalType extends BaseNode {
|
||
type: "TSOptionalType";
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSRestType extends BaseNode {
|
||
type: "TSRestType";
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSNamedTupleMember extends BaseNode {
|
||
type: "TSNamedTupleMember";
|
||
label: Identifier;
|
||
elementType: TSType;
|
||
optional: boolean;
|
||
}
|
||
interface TSUnionType extends BaseNode {
|
||
type: "TSUnionType";
|
||
types: Array<TSType>;
|
||
}
|
||
interface TSIntersectionType extends BaseNode {
|
||
type: "TSIntersectionType";
|
||
types: Array<TSType>;
|
||
}
|
||
interface TSConditionalType extends BaseNode {
|
||
type: "TSConditionalType";
|
||
checkType: TSType;
|
||
extendsType: TSType;
|
||
trueType: TSType;
|
||
falseType: TSType;
|
||
}
|
||
interface TSInferType extends BaseNode {
|
||
type: "TSInferType";
|
||
typeParameter: TSTypeParameter;
|
||
}
|
||
interface TSParenthesizedType extends BaseNode {
|
||
type: "TSParenthesizedType";
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSTypeOperator extends BaseNode {
|
||
type: "TSTypeOperator";
|
||
typeAnnotation: TSType;
|
||
operator: string;
|
||
}
|
||
interface TSIndexedAccessType extends BaseNode {
|
||
type: "TSIndexedAccessType";
|
||
objectType: TSType;
|
||
indexType: TSType;
|
||
}
|
||
interface TSMappedType extends BaseNode {
|
||
type: "TSMappedType";
|
||
typeParameter: TSTypeParameter;
|
||
typeAnnotation?: TSType | null;
|
||
nameType?: TSType | null;
|
||
optional?: true | false | "+" | "-" | null;
|
||
readonly?: true | false | "+" | "-" | null;
|
||
}
|
||
interface TSLiteralType extends BaseNode {
|
||
type: "TSLiteralType";
|
||
literal: NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TemplateLiteral$1 | UnaryExpression;
|
||
}
|
||
interface TSExpressionWithTypeArguments extends BaseNode {
|
||
type: "TSExpressionWithTypeArguments";
|
||
expression: TSEntityName;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TSInterfaceDeclaration extends BaseNode {
|
||
type: "TSInterfaceDeclaration";
|
||
id: Identifier;
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
extends?: Array<TSExpressionWithTypeArguments> | null;
|
||
body: TSInterfaceBody;
|
||
declare?: boolean | null;
|
||
}
|
||
interface TSInterfaceBody extends BaseNode {
|
||
type: "TSInterfaceBody";
|
||
body: Array<TSTypeElement>;
|
||
}
|
||
interface TSTypeAliasDeclaration extends BaseNode {
|
||
type: "TSTypeAliasDeclaration";
|
||
id: Identifier;
|
||
typeParameters?: TSTypeParameterDeclaration | null;
|
||
typeAnnotation: TSType;
|
||
declare?: boolean | null;
|
||
}
|
||
interface TSInstantiationExpression extends BaseNode {
|
||
type: "TSInstantiationExpression";
|
||
expression: Expression;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TSAsExpression extends BaseNode {
|
||
type: "TSAsExpression";
|
||
expression: Expression;
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSSatisfiesExpression extends BaseNode {
|
||
type: "TSSatisfiesExpression";
|
||
expression: Expression;
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSTypeAssertion extends BaseNode {
|
||
type: "TSTypeAssertion";
|
||
typeAnnotation: TSType;
|
||
expression: Expression;
|
||
}
|
||
interface TSEnumDeclaration extends BaseNode {
|
||
type: "TSEnumDeclaration";
|
||
id: Identifier;
|
||
members: Array<TSEnumMember>;
|
||
const?: boolean | null;
|
||
declare?: boolean | null;
|
||
initializer?: Expression | null;
|
||
}
|
||
interface TSEnumMember extends BaseNode {
|
||
type: "TSEnumMember";
|
||
id: Identifier | StringLiteral;
|
||
initializer?: Expression | null;
|
||
}
|
||
interface TSModuleDeclaration extends BaseNode {
|
||
type: "TSModuleDeclaration";
|
||
id: Identifier | StringLiteral;
|
||
body: TSModuleBlock | TSModuleDeclaration;
|
||
declare?: boolean | null;
|
||
global?: boolean | null;
|
||
}
|
||
interface TSModuleBlock extends BaseNode {
|
||
type: "TSModuleBlock";
|
||
body: Array<Statement>;
|
||
}
|
||
interface TSImportType extends BaseNode {
|
||
type: "TSImportType";
|
||
argument: StringLiteral;
|
||
qualifier?: TSEntityName | null;
|
||
typeParameters?: TSTypeParameterInstantiation | null;
|
||
}
|
||
interface TSImportEqualsDeclaration extends BaseNode {
|
||
type: "TSImportEqualsDeclaration";
|
||
id: Identifier;
|
||
moduleReference: TSEntityName | TSExternalModuleReference;
|
||
importKind?: "type" | "value" | null;
|
||
isExport: boolean;
|
||
}
|
||
interface TSExternalModuleReference extends BaseNode {
|
||
type: "TSExternalModuleReference";
|
||
expression: StringLiteral;
|
||
}
|
||
interface TSNonNullExpression extends BaseNode {
|
||
type: "TSNonNullExpression";
|
||
expression: Expression;
|
||
}
|
||
interface TSExportAssignment extends BaseNode {
|
||
type: "TSExportAssignment";
|
||
expression: Expression;
|
||
}
|
||
interface TSNamespaceExportDeclaration extends BaseNode {
|
||
type: "TSNamespaceExportDeclaration";
|
||
id: Identifier;
|
||
}
|
||
interface TSTypeAnnotation extends BaseNode {
|
||
type: "TSTypeAnnotation";
|
||
typeAnnotation: TSType;
|
||
}
|
||
interface TSTypeParameterInstantiation extends BaseNode {
|
||
type: "TSTypeParameterInstantiation";
|
||
params: Array<TSType>;
|
||
}
|
||
interface TSTypeParameterDeclaration extends BaseNode {
|
||
type: "TSTypeParameterDeclaration";
|
||
params: Array<TSTypeParameter>;
|
||
}
|
||
interface TSTypeParameter extends BaseNode {
|
||
type: "TSTypeParameter";
|
||
constraint?: TSType | null;
|
||
default?: TSType | null;
|
||
name: string;
|
||
const?: boolean | null;
|
||
in?: boolean | null;
|
||
out?: boolean | null;
|
||
}
|
||
type Expression = ArrayExpression$1 | AssignmentExpression$1 | BinaryExpression | CallExpression$1 | ConditionalExpression$1 | FunctionExpression$1 | Identifier | StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | LogicalExpression | MemberExpression | NewExpression | ObjectExpression$1 | SequenceExpression$1 | ParenthesizedExpression | ThisExpression | UnaryExpression | UpdateExpression | ArrowFunctionExpression | ClassExpression | MetaProperty | Super | TaggedTemplateExpression | TemplateLiteral$1 | YieldExpression | AwaitExpression | Import$1 | BigIntLiteral | OptionalMemberExpression | OptionalCallExpression | TypeCastExpression | JSXElement | JSXFragment | BindExpression | DoExpression | RecordExpression | TupleExpression | DecimalLiteral | ModuleExpression | TopicReference | PipelineTopicExpression | PipelineBareFunction | PipelinePrimaryTopicReference | TSInstantiationExpression | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression;
|
||
type Statement = BlockStatement$1 | BreakStatement | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExpressionStatement | ForInStatement | ForStatement | FunctionDeclaration | IfStatement$1 | LabeledStatement | ReturnStatement$1 | SwitchStatement | ThrowStatement | TryStatement | VariableDeclaration | WhileStatement | WithStatement | ClassDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ForOfStatement | ImportDeclaration | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | InterfaceDeclaration | OpaqueType | TypeAlias | EnumDeclaration | TSDeclareFunction | TSInterfaceDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration | TSModuleDeclaration | TSImportEqualsDeclaration | TSExportAssignment | TSNamespaceExportDeclaration;
|
||
type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | InterfaceDeclaration | OpaqueType | TypeAlias | EnumDeclaration | TSDeclareFunction | TSInterfaceDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration | TSModuleDeclaration;
|
||
type PatternLike = Identifier | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression;
|
||
type LVal = Identifier | MemberExpression | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSParameterProperty | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression;
|
||
type TSEntityName = Identifier | TSQualifiedName;
|
||
type Pattern$1 = AssignmentPattern | ArrayPattern | ObjectPattern;
|
||
type Flow = AnyTypeAnnotation | ArrayTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullLiteralTypeAnnotation | ClassImplements | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | DeclaredPredicate | ExistsTypeAnnotation | FunctionTypeAnnotation | FunctionTypeParam | GenericTypeAnnotation | InferredPredicate | InterfaceExtends | InterfaceDeclaration | InterfaceTypeAnnotation | IntersectionTypeAnnotation | MixedTypeAnnotation | EmptyTypeAnnotation | NullableTypeAnnotation | NumberLiteralTypeAnnotation | NumberTypeAnnotation | ObjectTypeAnnotation | ObjectTypeInternalSlot | ObjectTypeCallProperty | ObjectTypeIndexer | ObjectTypeProperty | ObjectTypeSpreadProperty | OpaqueType | QualifiedTypeIdentifier | StringLiteralTypeAnnotation | StringTypeAnnotation | SymbolTypeAnnotation | ThisTypeAnnotation | TupleTypeAnnotation | TypeofTypeAnnotation | TypeAlias | TypeAnnotation | TypeCastExpression | TypeParameter | TypeParameterDeclaration | TypeParameterInstantiation | UnionTypeAnnotation | Variance | VoidTypeAnnotation | EnumDeclaration | EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody | EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember | IndexedAccessType | OptionalIndexedAccessType;
|
||
type FlowType = AnyTypeAnnotation | ArrayTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullLiteralTypeAnnotation | ExistsTypeAnnotation | FunctionTypeAnnotation | GenericTypeAnnotation | InterfaceTypeAnnotation | IntersectionTypeAnnotation | MixedTypeAnnotation | EmptyTypeAnnotation | NullableTypeAnnotation | NumberLiteralTypeAnnotation | NumberTypeAnnotation | ObjectTypeAnnotation | StringLiteralTypeAnnotation | StringTypeAnnotation | SymbolTypeAnnotation | ThisTypeAnnotation | TupleTypeAnnotation | TypeofTypeAnnotation | UnionTypeAnnotation | VoidTypeAnnotation | IndexedAccessType | OptionalIndexedAccessType;
|
||
type TSTypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSPropertySignature | TSMethodSignature | TSIndexSignature;
|
||
type TSType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSFunctionType | TSConstructorType | TSTypeReference | TSTypePredicate | TSTypeQuery | TSTypeLiteral | TSArrayType | TSTupleType | TSOptionalType | TSRestType | TSUnionType | TSIntersectionType | TSConditionalType | TSInferType | TSParenthesizedType | TSTypeOperator | TSIndexedAccessType | TSMappedType | TSLiteralType | TSExpressionWithTypeArguments | TSImportType;
|
||
|
||
// This file is auto-generated! Do not modify it directly.
|
||
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/consistent-type-imports, prettier/prettier */
|
||
|
||
|
||
type Plugin =
|
||
| "asyncDoExpressions"
|
||
| "asyncGenerators"
|
||
| "bigInt"
|
||
| "classPrivateMethods"
|
||
| "classPrivateProperties"
|
||
| "classProperties"
|
||
| "classStaticBlock" // Enabled by default
|
||
| "decimal"
|
||
| "decorators-legacy"
|
||
| "decoratorAutoAccessors"
|
||
| "destructuringPrivate"
|
||
| "doExpressions"
|
||
| "dynamicImport"
|
||
| "explicitResourceManagement"
|
||
| "exportDefaultFrom"
|
||
| "exportNamespaceFrom" // deprecated
|
||
| "flow"
|
||
| "flowComments"
|
||
| "functionBind"
|
||
| "functionSent"
|
||
| "importMeta"
|
||
| "jsx"
|
||
| "logicalAssignment"
|
||
| "importAssertions" // deprecated
|
||
| "importAttributes"
|
||
| "importReflection"
|
||
| "moduleBlocks"
|
||
| "moduleStringNames"
|
||
| "nullishCoalescingOperator"
|
||
| "numericSeparator"
|
||
| "objectRestSpread"
|
||
| "optionalCatchBinding"
|
||
| "optionalChaining"
|
||
| "partialApplication"
|
||
| "placeholders"
|
||
| "privateIn" // Enabled by default
|
||
| "regexpUnicodeSets" // Enabled by default
|
||
| "throwExpressions"
|
||
| "topLevelAwait"
|
||
| "v8intrinsic"
|
||
| ParserPluginWithOptions[0];
|
||
|
||
type ParserPluginWithOptions =
|
||
| ["decorators", DecoratorsPluginOptions]
|
||
| ["estree", { classFeatures?: boolean }]
|
||
| ["importAttributes", { deprecatedAssertSyntax: boolean }]
|
||
// @deprecated
|
||
| ["moduleAttributes", { version: "may-2020" }]
|
||
| ["pipelineOperator", PipelineOperatorPluginOptions]
|
||
| ["recordAndTuple", RecordAndTuplePluginOptions]
|
||
| ["flow", FlowPluginOptions]
|
||
| ["typescript", TypeScriptPluginOptions];
|
||
|
||
type PluginConfig = Plugin | ParserPluginWithOptions;
|
||
|
||
interface DecoratorsPluginOptions {
|
||
decoratorsBeforeExport?: boolean;
|
||
allowCallParenthesized?: boolean;
|
||
}
|
||
|
||
interface PipelineOperatorPluginOptions {
|
||
proposal: "minimal" | "fsharp" | "hack" | "smart";
|
||
topicToken?: "%" | "#" | "@@" | "^^" | "^";
|
||
}
|
||
|
||
interface RecordAndTuplePluginOptions {
|
||
syntaxType: "bar" | "hash";
|
||
}
|
||
|
||
interface FlowPluginOptions {
|
||
all?: boolean;
|
||
enums?: boolean;
|
||
}
|
||
|
||
interface TypeScriptPluginOptions {
|
||
dts?: boolean;
|
||
disallowAmbiguousJSXLike?: boolean;
|
||
}
|
||
|
||
// Type definitions for @babel/parser
|
||
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||
// Avi Vahl <https://github.com/AviVahl>
|
||
// TypeScript Version: 2.9
|
||
|
||
/**
|
||
* Parse the provided code as an entire ECMAScript program.
|
||
*/
|
||
declare function parse$2(
|
||
input: string,
|
||
options?: ParserOptions$1
|
||
): ParseResult<File>;
|
||
|
||
interface ParserOptions$1 {
|
||
/**
|
||
* By default, import and export declarations can only appear at a program's top level.
|
||
* Setting this option to true allows them anywhere where a statement is allowed.
|
||
*/
|
||
allowImportExportEverywhere?: boolean;
|
||
|
||
/**
|
||
* By default, await use is not allowed outside of an async function.
|
||
* Set this to true to accept such code.
|
||
*/
|
||
allowAwaitOutsideFunction?: boolean;
|
||
|
||
/**
|
||
* By default, a return statement at the top level raises an error.
|
||
* Set this to true to accept such code.
|
||
*/
|
||
allowReturnOutsideFunction?: boolean;
|
||
|
||
/**
|
||
* By default, new.target use is not allowed outside of a function or class.
|
||
* Set this to true to accept such code.
|
||
*/
|
||
allowNewTargetOutsideFunction?: boolean;
|
||
|
||
allowSuperOutsideMethod?: boolean;
|
||
|
||
/**
|
||
* By default, exported identifiers must refer to a declared variable.
|
||
* Set this to true to allow export statements to reference undeclared variables.
|
||
*/
|
||
allowUndeclaredExports?: boolean;
|
||
|
||
/**
|
||
* By default, Babel parser JavaScript code according to Annex B syntax.
|
||
* Set this to `false` to disable such behavior.
|
||
*/
|
||
annexB?: boolean;
|
||
|
||
/**
|
||
* By default, Babel attaches comments to adjacent AST nodes.
|
||
* When this option is set to false, comments are not attached.
|
||
* It can provide up to 30% performance improvement when the input code has many comments.
|
||
* @babel/eslint-parser will set it for you.
|
||
* It is not recommended to use attachComment: false with Babel transform,
|
||
* as doing so removes all the comments in output code, and renders annotations such as
|
||
* /* istanbul ignore next *\/ nonfunctional.
|
||
*/
|
||
attachComment?: boolean;
|
||
|
||
/**
|
||
* By default, Babel always throws an error when it finds some invalid code.
|
||
* When this option is set to true, it will store the parsing error and
|
||
* try to continue parsing the invalid input file.
|
||
*/
|
||
errorRecovery?: boolean;
|
||
|
||
/**
|
||
* Indicate the mode the code should be parsed in.
|
||
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
|
||
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
||
* of ES6 import or export statements.
|
||
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
||
*/
|
||
sourceType?: "script" | "module" | "unambiguous";
|
||
|
||
/**
|
||
* Correlate output AST nodes with their source filename.
|
||
* Useful when generating code and source maps from the ASTs of multiple input files.
|
||
*/
|
||
sourceFilename?: string;
|
||
|
||
/**
|
||
* By default, the first line of code parsed is treated as line 1.
|
||
* You can provide a line number to alternatively start with.
|
||
* Useful for integration with other source tools.
|
||
*/
|
||
startLine?: number;
|
||
|
||
/**
|
||
* By default, the parsed code is treated as if it starts from line 1, column 0.
|
||
* You can provide a column number to alternatively start with.
|
||
* Useful for integration with other source tools.
|
||
*/
|
||
startColumn?: number;
|
||
|
||
/**
|
||
* Array containing the plugins that you want to enable.
|
||
*/
|
||
plugins?: ParserPlugin[];
|
||
|
||
/**
|
||
* Should the parser work in strict mode.
|
||
* Defaults to true if sourceType === 'module'. Otherwise, false.
|
||
*/
|
||
strictMode?: boolean;
|
||
|
||
/**
|
||
* Adds a ranges property to each node: [node.start, node.end]
|
||
*/
|
||
ranges?: boolean;
|
||
|
||
/**
|
||
* Adds all parsed tokens to a tokens property on the File node.
|
||
*/
|
||
tokens?: boolean;
|
||
|
||
/**
|
||
* By default, the parser adds information about parentheses by setting
|
||
* `extra.parenthesized` to `true` as needed.
|
||
* When this option is `true` the parser creates `ParenthesizedExpression`
|
||
* AST nodes instead of using the `extra` property.
|
||
*/
|
||
createParenthesizedExpressions?: boolean;
|
||
}
|
||
|
||
type ParserPlugin = PluginConfig;
|
||
|
||
interface ParseError {
|
||
code: string;
|
||
reasonCode: string;
|
||
}
|
||
|
||
type ParseResult<Result> = Result & {
|
||
errors: ParseError[];
|
||
};
|
||
|
||
declare function generateCodeFrame(source: string, start?: number, end?: number): string;
|
||
|
||
declare const enum TextModes {
|
||
DATA = 0,
|
||
RCDATA = 1,
|
||
RAWTEXT = 2,
|
||
CDATA = 3,
|
||
ATTRIBUTE_VALUE = 4
|
||
}
|
||
|
||
type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>> & {
|
||
MODE?: 2 | 3;
|
||
};
|
||
interface CompilerCompatOptions {
|
||
compatConfig?: CompilerCompatConfig;
|
||
}
|
||
declare const enum CompilerDeprecationTypes {
|
||
COMPILER_IS_ON_ELEMENT = "COMPILER_IS_ON_ELEMENT",
|
||
COMPILER_V_BIND_SYNC = "COMPILER_V_BIND_SYNC",
|
||
COMPILER_V_BIND_PROP = "COMPILER_V_BIND_PROP",
|
||
COMPILER_V_BIND_OBJECT_ORDER = "COMPILER_V_BIND_OBJECT_ORDER",
|
||
COMPILER_V_ON_NATIVE = "COMPILER_V_ON_NATIVE",
|
||
COMPILER_V_IF_V_FOR_PRECEDENCE = "COMPILER_V_IF_V_FOR_PRECEDENCE",
|
||
COMPILER_NATIVE_TEMPLATE = "COMPILER_NATIVE_TEMPLATE",
|
||
COMPILER_INLINE_TEMPLATE = "COMPILER_INLINE_TEMPLATE",
|
||
COMPILER_FILTERS = "COMPILER_FILTER"
|
||
}
|
||
|
||
type NodeTransform = (node: RootNode | TemplateChildNode, context: TransformContext$1) => void | (() => void) | (() => void)[];
|
||
type DirectiveTransform = (dir: DirectiveNode, node: ElementNode, context: TransformContext$1, augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult) => DirectiveTransformResult;
|
||
interface DirectiveTransformResult {
|
||
props: Property[];
|
||
needRuntime?: boolean | symbol;
|
||
ssrTagParts?: TemplateLiteral['elements'];
|
||
}
|
||
interface ImportItem {
|
||
exp: string | ExpressionNode;
|
||
path: string;
|
||
}
|
||
interface TransformContext$1 extends Required<Omit<TransformOptions, 'filename' | keyof CompilerCompatOptions>>, CompilerCompatOptions {
|
||
selfName: string | null;
|
||
root: RootNode;
|
||
helpers: Map<symbol, number>;
|
||
components: Set<string>;
|
||
directives: Set<string>;
|
||
hoists: (JSChildNode | null)[];
|
||
imports: ImportItem[];
|
||
temps: number;
|
||
cached: number;
|
||
identifiers: {
|
||
[name: string]: number | undefined;
|
||
};
|
||
scopes: {
|
||
vFor: number;
|
||
vSlot: number;
|
||
vPre: number;
|
||
vOnce: number;
|
||
};
|
||
parent: ParentNode | null;
|
||
childIndex: number;
|
||
currentNode: RootNode | TemplateChildNode | null;
|
||
inVOnce: boolean;
|
||
helper<T extends symbol>(name: T): T;
|
||
removeHelper<T extends symbol>(name: T): void;
|
||
helperString(name: symbol): string;
|
||
replaceNode(node: TemplateChildNode): void;
|
||
removeNode(node?: TemplateChildNode): void;
|
||
onNodeRemoved(): void;
|
||
addIdentifiers(exp: ExpressionNode | string): void;
|
||
removeIdentifiers(exp: ExpressionNode | string): void;
|
||
hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
|
||
cache<T extends JSChildNode>(exp: T, isVNode?: boolean): CacheExpression | T;
|
||
constantCache: Map<TemplateChildNode, ConstantTypes>;
|
||
filters?: Set<string>;
|
||
}
|
||
interface ForParseResult {
|
||
source: ExpressionNode;
|
||
value: ExpressionNode | undefined;
|
||
key: ExpressionNode | undefined;
|
||
index: ExpressionNode | undefined;
|
||
}
|
||
|
||
declare const FRAGMENT: unique symbol;
|
||
declare const RENDER_LIST: unique symbol;
|
||
declare const RENDER_SLOT: unique symbol;
|
||
declare const CREATE_SLOTS: unique symbol;
|
||
declare const WITH_MEMO: unique symbol;
|
||
type PropsExpression = ObjectExpression | CallExpression | ExpressionNode;
|
||
|
||
type Namespace = number;
|
||
declare const enum NodeTypes {
|
||
ROOT = 0,
|
||
ELEMENT = 1,
|
||
TEXT = 2,
|
||
COMMENT = 3,
|
||
SIMPLE_EXPRESSION = 4,
|
||
INTERPOLATION = 5,
|
||
ATTRIBUTE = 6,
|
||
DIRECTIVE = 7,
|
||
COMPOUND_EXPRESSION = 8,
|
||
IF = 9,
|
||
IF_BRANCH = 10,
|
||
FOR = 11,
|
||
TEXT_CALL = 12,
|
||
VNODE_CALL = 13,
|
||
JS_CALL_EXPRESSION = 14,
|
||
JS_OBJECT_EXPRESSION = 15,
|
||
JS_PROPERTY = 16,
|
||
JS_ARRAY_EXPRESSION = 17,
|
||
JS_FUNCTION_EXPRESSION = 18,
|
||
JS_CONDITIONAL_EXPRESSION = 19,
|
||
JS_CACHE_EXPRESSION = 20,
|
||
JS_BLOCK_STATEMENT = 21,
|
||
JS_TEMPLATE_LITERAL = 22,
|
||
JS_IF_STATEMENT = 23,
|
||
JS_ASSIGNMENT_EXPRESSION = 24,
|
||
JS_SEQUENCE_EXPRESSION = 25,
|
||
JS_RETURN_STATEMENT = 26
|
||
}
|
||
declare const enum ElementTypes {
|
||
ELEMENT = 0,
|
||
COMPONENT = 1,
|
||
SLOT = 2,
|
||
TEMPLATE = 3
|
||
}
|
||
interface Node {
|
||
type: NodeTypes;
|
||
loc: SourceLocation;
|
||
}
|
||
interface SourceLocation {
|
||
start: Position;
|
||
end: Position;
|
||
source: string;
|
||
}
|
||
interface Position {
|
||
offset: number;
|
||
line: number;
|
||
column: number;
|
||
}
|
||
type ParentNode = RootNode | ElementNode | IfBranchNode | ForNode;
|
||
type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode;
|
||
type TemplateChildNode = ElementNode | InterpolationNode | CompoundExpressionNode | TextNode | CommentNode | IfNode | IfBranchNode | ForNode | TextCallNode;
|
||
interface RootNode extends Node {
|
||
type: NodeTypes.ROOT;
|
||
children: TemplateChildNode[];
|
||
helpers: Set<symbol>;
|
||
components: string[];
|
||
directives: string[];
|
||
hoists: (JSChildNode | null)[];
|
||
imports: ImportItem[];
|
||
cached: number;
|
||
temps: number;
|
||
ssrHelpers?: symbol[];
|
||
codegenNode?: TemplateChildNode | JSChildNode | BlockStatement;
|
||
filters?: string[];
|
||
}
|
||
type ElementNode = PlainElementNode | ComponentNode | SlotOutletNode | TemplateNode;
|
||
interface BaseElementNode extends Node {
|
||
type: NodeTypes.ELEMENT;
|
||
ns: Namespace;
|
||
tag: string;
|
||
tagType: ElementTypes;
|
||
isSelfClosing: boolean;
|
||
props: Array<AttributeNode | DirectiveNode>;
|
||
children: TemplateChildNode[];
|
||
}
|
||
interface PlainElementNode extends BaseElementNode {
|
||
tagType: ElementTypes.ELEMENT;
|
||
codegenNode: VNodeCall | SimpleExpressionNode | CacheExpression | MemoExpression | undefined;
|
||
ssrCodegenNode?: TemplateLiteral;
|
||
}
|
||
interface ComponentNode extends BaseElementNode {
|
||
tagType: ElementTypes.COMPONENT;
|
||
codegenNode: VNodeCall | CacheExpression | MemoExpression | undefined;
|
||
ssrCodegenNode?: CallExpression;
|
||
}
|
||
interface SlotOutletNode extends BaseElementNode {
|
||
tagType: ElementTypes.SLOT;
|
||
codegenNode: RenderSlotCall | CacheExpression | undefined;
|
||
ssrCodegenNode?: CallExpression;
|
||
}
|
||
interface TemplateNode extends BaseElementNode {
|
||
tagType: ElementTypes.TEMPLATE;
|
||
codegenNode: undefined;
|
||
}
|
||
interface TextNode extends Node {
|
||
type: NodeTypes.TEXT;
|
||
content: string;
|
||
}
|
||
interface CommentNode extends Node {
|
||
type: NodeTypes.COMMENT;
|
||
content: string;
|
||
}
|
||
interface AttributeNode extends Node {
|
||
type: NodeTypes.ATTRIBUTE;
|
||
name: string;
|
||
value: TextNode | undefined;
|
||
}
|
||
interface DirectiveNode extends Node {
|
||
type: NodeTypes.DIRECTIVE;
|
||
name: string;
|
||
exp: ExpressionNode | undefined;
|
||
arg: ExpressionNode | undefined;
|
||
modifiers: string[];
|
||
/**
|
||
* optional property to cache the expression parse result for v-for
|
||
*/
|
||
parseResult?: ForParseResult;
|
||
}
|
||
/**
|
||
* Static types have several levels.
|
||
* Higher levels implies lower levels. e.g. a node that can be stringified
|
||
* can always be hoisted and skipped for patch.
|
||
*/
|
||
declare const enum ConstantTypes {
|
||
NOT_CONSTANT = 0,
|
||
CAN_SKIP_PATCH = 1,
|
||
CAN_HOIST = 2,
|
||
CAN_STRINGIFY = 3
|
||
}
|
||
interface SimpleExpressionNode extends Node {
|
||
type: NodeTypes.SIMPLE_EXPRESSION;
|
||
content: string;
|
||
isStatic: boolean;
|
||
constType: ConstantTypes;
|
||
/**
|
||
* Indicates this is an identifier for a hoist vnode call and points to the
|
||
* hoisted node.
|
||
*/
|
||
hoisted?: JSChildNode;
|
||
/**
|
||
* an expression parsed as the params of a function will track
|
||
* the identifiers declared inside the function body.
|
||
*/
|
||
identifiers?: string[];
|
||
isHandlerKey?: boolean;
|
||
}
|
||
interface InterpolationNode extends Node {
|
||
type: NodeTypes.INTERPOLATION;
|
||
content: ExpressionNode;
|
||
}
|
||
interface CompoundExpressionNode extends Node {
|
||
type: NodeTypes.COMPOUND_EXPRESSION;
|
||
children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string | symbol)[];
|
||
/**
|
||
* an expression parsed as the params of a function will track
|
||
* the identifiers declared inside the function body.
|
||
*/
|
||
identifiers?: string[];
|
||
isHandlerKey?: boolean;
|
||
}
|
||
interface IfNode extends Node {
|
||
type: NodeTypes.IF;
|
||
branches: IfBranchNode[];
|
||
codegenNode?: IfConditionalExpression | CacheExpression;
|
||
}
|
||
interface IfBranchNode extends Node {
|
||
type: NodeTypes.IF_BRANCH;
|
||
condition: ExpressionNode | undefined;
|
||
children: TemplateChildNode[];
|
||
userKey?: AttributeNode | DirectiveNode;
|
||
isTemplateIf?: boolean;
|
||
}
|
||
interface ForNode extends Node {
|
||
type: NodeTypes.FOR;
|
||
source: ExpressionNode;
|
||
valueAlias: ExpressionNode | undefined;
|
||
keyAlias: ExpressionNode | undefined;
|
||
objectIndexAlias: ExpressionNode | undefined;
|
||
parseResult: ForParseResult;
|
||
children: TemplateChildNode[];
|
||
codegenNode?: ForCodegenNode;
|
||
}
|
||
interface TextCallNode extends Node {
|
||
type: NodeTypes.TEXT_CALL;
|
||
content: TextNode | InterpolationNode | CompoundExpressionNode;
|
||
codegenNode: CallExpression | SimpleExpressionNode;
|
||
}
|
||
type TemplateTextChildNode = TextNode | InterpolationNode | CompoundExpressionNode;
|
||
interface VNodeCall extends Node {
|
||
type: NodeTypes.VNODE_CALL;
|
||
tag: string | symbol | CallExpression;
|
||
props: PropsExpression | undefined;
|
||
children: TemplateChildNode[] | TemplateTextChildNode | SlotsExpression | ForRenderListExpression | SimpleExpressionNode | undefined;
|
||
patchFlag: string | undefined;
|
||
dynamicProps: string | SimpleExpressionNode | undefined;
|
||
directives: DirectiveArguments | undefined;
|
||
isBlock: boolean;
|
||
disableTracking: boolean;
|
||
isComponent: boolean;
|
||
}
|
||
type JSChildNode = VNodeCall | CallExpression | ObjectExpression | ArrayExpression | ExpressionNode | FunctionExpression | ConditionalExpression | CacheExpression | AssignmentExpression | SequenceExpression;
|
||
interface CallExpression extends Node {
|
||
type: NodeTypes.JS_CALL_EXPRESSION;
|
||
callee: string | symbol;
|
||
arguments: (string | symbol | JSChildNode | SSRCodegenNode | TemplateChildNode | TemplateChildNode[])[];
|
||
}
|
||
interface ObjectExpression extends Node {
|
||
type: NodeTypes.JS_OBJECT_EXPRESSION;
|
||
properties: Array<Property>;
|
||
}
|
||
interface Property extends Node {
|
||
type: NodeTypes.JS_PROPERTY;
|
||
key: ExpressionNode;
|
||
value: JSChildNode;
|
||
}
|
||
interface ArrayExpression extends Node {
|
||
type: NodeTypes.JS_ARRAY_EXPRESSION;
|
||
elements: Array<string | Node>;
|
||
}
|
||
interface FunctionExpression extends Node {
|
||
type: NodeTypes.JS_FUNCTION_EXPRESSION;
|
||
params: ExpressionNode | string | (ExpressionNode | string)[] | undefined;
|
||
returns?: TemplateChildNode | TemplateChildNode[] | JSChildNode;
|
||
body?: BlockStatement | IfStatement;
|
||
newline: boolean;
|
||
/**
|
||
* This flag is for codegen to determine whether it needs to generate the
|
||
* withScopeId() wrapper
|
||
*/
|
||
isSlot: boolean;
|
||
/**
|
||
* __COMPAT__ only, indicates a slot function that should be excluded from
|
||
* the legacy $scopedSlots instance property.
|
||
*/
|
||
isNonScopedSlot?: boolean;
|
||
}
|
||
interface ConditionalExpression extends Node {
|
||
type: NodeTypes.JS_CONDITIONAL_EXPRESSION;
|
||
test: JSChildNode;
|
||
consequent: JSChildNode;
|
||
alternate: JSChildNode;
|
||
newline: boolean;
|
||
}
|
||
interface CacheExpression extends Node {
|
||
type: NodeTypes.JS_CACHE_EXPRESSION;
|
||
index: number;
|
||
value: JSChildNode;
|
||
isVNode: boolean;
|
||
}
|
||
interface MemoExpression extends CallExpression {
|
||
callee: typeof WITH_MEMO;
|
||
arguments: [ExpressionNode, MemoFactory, string, string];
|
||
}
|
||
interface MemoFactory extends FunctionExpression {
|
||
returns: BlockCodegenNode;
|
||
}
|
||
type SSRCodegenNode = BlockStatement | TemplateLiteral | IfStatement | AssignmentExpression | ReturnStatement | SequenceExpression;
|
||
interface BlockStatement extends Node {
|
||
type: NodeTypes.JS_BLOCK_STATEMENT;
|
||
body: (JSChildNode | IfStatement)[];
|
||
}
|
||
interface TemplateLiteral extends Node {
|
||
type: NodeTypes.JS_TEMPLATE_LITERAL;
|
||
elements: (string | JSChildNode)[];
|
||
}
|
||
interface IfStatement extends Node {
|
||
type: NodeTypes.JS_IF_STATEMENT;
|
||
test: ExpressionNode;
|
||
consequent: BlockStatement;
|
||
alternate: IfStatement | BlockStatement | ReturnStatement | undefined;
|
||
}
|
||
interface AssignmentExpression extends Node {
|
||
type: NodeTypes.JS_ASSIGNMENT_EXPRESSION;
|
||
left: SimpleExpressionNode;
|
||
right: JSChildNode;
|
||
}
|
||
interface SequenceExpression extends Node {
|
||
type: NodeTypes.JS_SEQUENCE_EXPRESSION;
|
||
expressions: JSChildNode[];
|
||
}
|
||
interface ReturnStatement extends Node {
|
||
type: NodeTypes.JS_RETURN_STATEMENT;
|
||
returns: TemplateChildNode | TemplateChildNode[] | JSChildNode;
|
||
}
|
||
interface DirectiveArguments extends ArrayExpression {
|
||
elements: DirectiveArgumentNode[];
|
||
}
|
||
interface DirectiveArgumentNode extends ArrayExpression {
|
||
elements: [string] | [string, ExpressionNode] | [string, ExpressionNode, ExpressionNode] | [string, ExpressionNode, ExpressionNode, ObjectExpression];
|
||
}
|
||
interface RenderSlotCall extends CallExpression {
|
||
callee: typeof RENDER_SLOT;
|
||
arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [
|
||
string,
|
||
string | ExpressionNode,
|
||
PropsExpression | '{}',
|
||
TemplateChildNode[]
|
||
];
|
||
}
|
||
type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
|
||
interface SlotsObjectExpression extends ObjectExpression {
|
||
properties: SlotsObjectProperty[];
|
||
}
|
||
interface SlotsObjectProperty extends Property {
|
||
value: SlotFunctionExpression;
|
||
}
|
||
interface SlotFunctionExpression extends FunctionExpression {
|
||
returns: TemplateChildNode[];
|
||
}
|
||
interface DynamicSlotsExpression extends CallExpression {
|
||
callee: typeof CREATE_SLOTS;
|
||
arguments: [SlotsObjectExpression, DynamicSlotEntries];
|
||
}
|
||
interface DynamicSlotEntries extends ArrayExpression {
|
||
elements: (ConditionalDynamicSlotNode | ListDynamicSlotNode)[];
|
||
}
|
||
interface ConditionalDynamicSlotNode extends ConditionalExpression {
|
||
consequent: DynamicSlotNode;
|
||
alternate: DynamicSlotNode | SimpleExpressionNode;
|
||
}
|
||
interface ListDynamicSlotNode extends CallExpression {
|
||
callee: typeof RENDER_LIST;
|
||
arguments: [ExpressionNode, ListDynamicSlotIterator];
|
||
}
|
||
interface ListDynamicSlotIterator extends FunctionExpression {
|
||
returns: DynamicSlotNode;
|
||
}
|
||
interface DynamicSlotNode extends ObjectExpression {
|
||
properties: [Property, DynamicSlotFnProperty];
|
||
}
|
||
interface DynamicSlotFnProperty extends Property {
|
||
value: SlotFunctionExpression;
|
||
}
|
||
type BlockCodegenNode = VNodeCall | RenderSlotCall;
|
||
interface IfConditionalExpression extends ConditionalExpression {
|
||
consequent: BlockCodegenNode | MemoExpression;
|
||
alternate: BlockCodegenNode | IfConditionalExpression | MemoExpression;
|
||
}
|
||
interface ForCodegenNode extends VNodeCall {
|
||
isBlock: true;
|
||
tag: typeof FRAGMENT;
|
||
props: undefined;
|
||
children: ForRenderListExpression;
|
||
patchFlag: string;
|
||
disableTracking: boolean;
|
||
}
|
||
interface ForRenderListExpression extends CallExpression {
|
||
callee: typeof RENDER_LIST;
|
||
arguments: [ExpressionNode, ForIteratorExpression];
|
||
}
|
||
interface ForIteratorExpression extends FunctionExpression {
|
||
returns: BlockCodegenNode;
|
||
}
|
||
|
||
interface CompilerError extends SyntaxError {
|
||
code: number | string;
|
||
loc?: SourceLocation;
|
||
}
|
||
|
||
interface ErrorHandlingOptions {
|
||
onWarn?: (warning: CompilerError) => void;
|
||
onError?: (error: CompilerError) => void;
|
||
}
|
||
interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptions {
|
||
/**
|
||
* e.g. platform native elements, e.g. `<div>` for browsers
|
||
*/
|
||
isNativeTag?: (tag: string) => boolean;
|
||
/**
|
||
* e.g. native elements that can self-close, e.g. `<img>`, `<br>`, `<hr>`
|
||
*/
|
||
isVoidTag?: (tag: string) => boolean;
|
||
/**
|
||
* e.g. elements that should preserve whitespace inside, e.g. `<pre>`
|
||
*/
|
||
isPreTag?: (tag: string) => boolean;
|
||
/**
|
||
* Platform-specific built-in components e.g. `<Transition>`
|
||
*/
|
||
isBuiltInComponent?: (tag: string) => symbol | void;
|
||
/**
|
||
* Separate option for end users to extend the native elements list
|
||
*/
|
||
isCustomElement?: (tag: string) => boolean | void;
|
||
/**
|
||
* Get tag namespace
|
||
*/
|
||
getNamespace?: (tag: string, parent: ElementNode | undefined) => Namespace;
|
||
/**
|
||
* Get text parsing mode for this element
|
||
*/
|
||
getTextMode?: (node: ElementNode, parent: ElementNode | undefined) => TextModes;
|
||
/**
|
||
* @default ['{{', '}}']
|
||
*/
|
||
delimiters?: [string, string];
|
||
/**
|
||
* Whitespace handling strategy
|
||
*/
|
||
whitespace?: 'preserve' | 'condense';
|
||
/**
|
||
* Only needed for DOM compilers
|
||
*/
|
||
decodeEntities?: (rawText: string, asAttr: boolean) => string;
|
||
/**
|
||
* Whether to keep comments in the templates AST.
|
||
* This defaults to `true` in development and `false` in production builds.
|
||
*/
|
||
comments?: boolean;
|
||
}
|
||
type HoistTransform = (children: TemplateChildNode[], context: TransformContext$1, parent: ParentNode) => void;
|
||
declare const enum BindingTypes$1 {
|
||
/**
|
||
* returned from data()
|
||
*/
|
||
DATA = "data",
|
||
/**
|
||
* declared as a prop
|
||
*/
|
||
PROPS = "props",
|
||
/**
|
||
* a local alias of a `<script setup>` destructured prop.
|
||
* the original is stored in __propsAliases of the bindingMetadata object.
|
||
*/
|
||
PROPS_ALIASED = "props-aliased",
|
||
/**
|
||
* a let binding (may or may not be a ref)
|
||
*/
|
||
SETUP_LET = "setup-let",
|
||
/**
|
||
* a const binding that can never be a ref.
|
||
* these bindings don't need `unref()` calls when processed in inlined
|
||
* template expressions.
|
||
*/
|
||
SETUP_CONST = "setup-const",
|
||
/**
|
||
* a const binding that does not need `unref()`, but may be mutated.
|
||
*/
|
||
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
||
/**
|
||
* a const binding that may be a ref.
|
||
*/
|
||
SETUP_MAYBE_REF = "setup-maybe-ref",
|
||
/**
|
||
* bindings that are guaranteed to be refs
|
||
*/
|
||
SETUP_REF = "setup-ref",
|
||
/**
|
||
* declared by other options, e.g. computed, inject
|
||
*/
|
||
OPTIONS = "options",
|
||
/**
|
||
* a literal constant, e.g. 'foo', 1, true
|
||
*/
|
||
LITERAL_CONST = "literal-const"
|
||
}
|
||
type BindingMetadata$1 = {
|
||
[key: string]: BindingTypes$1 | undefined;
|
||
} & {
|
||
__isScriptSetup?: boolean;
|
||
__propsAliases?: Record<string, string>;
|
||
};
|
||
interface SharedTransformCodegenOptions {
|
||
/**
|
||
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
||
* If this option is false, the generated code will be wrapped in a
|
||
* `with (this) { ... }` block.
|
||
* - This is force-enabled in module mode, since modules are by default strict
|
||
* and cannot use `with`
|
||
* @default mode === 'module'
|
||
*/
|
||
prefixIdentifiers?: boolean;
|
||
/**
|
||
* Control whether generate SSR-optimized render functions instead.
|
||
* The resulting function must be attached to the component via the
|
||
* `ssrRender` option instead of `render`.
|
||
*
|
||
* When compiler generates code for SSR's fallback branch, we need to set it to false:
|
||
* - context.ssr = false
|
||
*
|
||
* see `subTransform` in `ssrTransformComponent.ts`
|
||
*/
|
||
ssr?: boolean;
|
||
/**
|
||
* Indicates whether the compiler generates code for SSR,
|
||
* it is always true when generating code for SSR,
|
||
* regardless of whether we are generating code for SSR's fallback branch,
|
||
* this means that when the compiler generates code for SSR's fallback branch:
|
||
* - context.ssr = false
|
||
* - context.inSSR = true
|
||
*/
|
||
inSSR?: boolean;
|
||
/**
|
||
* Optional binding metadata analyzed from script - used to optimize
|
||
* binding access when `prefixIdentifiers` is enabled.
|
||
*/
|
||
bindingMetadata?: BindingMetadata$1;
|
||
/**
|
||
* Compile the function for inlining inside setup().
|
||
* This allows the function to directly access setup() local bindings.
|
||
*/
|
||
inline?: boolean;
|
||
/**
|
||
* Indicates that transforms and codegen should try to output valid TS code
|
||
*/
|
||
isTS?: boolean;
|
||
/**
|
||
* Filename for source map generation.
|
||
* Also used for self-recursive reference in templates
|
||
* @default 'template.vue.html'
|
||
*/
|
||
filename?: string;
|
||
}
|
||
interface TransformOptions extends SharedTransformCodegenOptions, ErrorHandlingOptions, CompilerCompatOptions {
|
||
/**
|
||
* An array of node transforms to be applied to every AST node.
|
||
*/
|
||
nodeTransforms?: NodeTransform[];
|
||
/**
|
||
* An object of { name: transform } to be applied to every directive attribute
|
||
* node found on element nodes.
|
||
*/
|
||
directiveTransforms?: Record<string, DirectiveTransform | undefined>;
|
||
/**
|
||
* An optional hook to transform a node being hoisted.
|
||
* used by compiler-dom to turn hoisted nodes into stringified HTML vnodes.
|
||
* @default null
|
||
*/
|
||
transformHoist?: HoistTransform | null;
|
||
/**
|
||
* If the pairing runtime provides additional built-in elements, use this to
|
||
* mark them as built-in so the compiler will generate component vnodes
|
||
* for them.
|
||
*/
|
||
isBuiltInComponent?: (tag: string) => symbol | void;
|
||
/**
|
||
* Used by some transforms that expects only native elements
|
||
*/
|
||
isCustomElement?: (tag: string) => boolean | void;
|
||
/**
|
||
* Transform expressions like {{ foo }} to `_ctx.foo`.
|
||
* If this option is false, the generated code will be wrapped in a
|
||
* `with (this) { ... }` block.
|
||
* - This is force-enabled in module mode, since modules are by default strict
|
||
* and cannot use `with`
|
||
* @default mode === 'module'
|
||
*/
|
||
prefixIdentifiers?: boolean;
|
||
/**
|
||
* Hoist static VNodes and props objects to `_hoisted_x` constants
|
||
* @default false
|
||
*/
|
||
hoistStatic?: boolean;
|
||
/**
|
||
* Cache v-on handlers to avoid creating new inline functions on each render,
|
||
* also avoids the need for dynamically patching the handlers by wrapping it.
|
||
* e.g `@click="foo"` by default is compiled to `{ onClick: foo }`. With this
|
||
* option it's compiled to:
|
||
* ```js
|
||
* { onClick: _cache[0] || (_cache[0] = e => _ctx.foo(e)) }
|
||
* ```
|
||
* - Requires "prefixIdentifiers" to be enabled because it relies on scope
|
||
* analysis to determine if a handler is safe to cache.
|
||
* @default false
|
||
*/
|
||
cacheHandlers?: boolean;
|
||
/**
|
||
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
||
* parse expressions in bindings and interpolations.
|
||
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
||
*/
|
||
expressionPlugins?: ParserPlugin[];
|
||
/**
|
||
* SFC scoped styles ID
|
||
*/
|
||
scopeId?: string | null;
|
||
/**
|
||
* Indicates this SFC template has used :slotted in its styles
|
||
* Defaults to `true` for backwards compatibility - SFC tooling should set it
|
||
* to `false` if no `:slotted` usage is detected in `<style>`
|
||
*/
|
||
slotted?: boolean;
|
||
/**
|
||
* SFC `<style vars>` injection string
|
||
* Should already be an object expression, e.g. `{ 'xxxx-color': color }`
|
||
* needed to render inline CSS variables on component root
|
||
*/
|
||
ssrCssVars?: string;
|
||
}
|
||
interface CodegenOptions extends SharedTransformCodegenOptions {
|
||
/**
|
||
* - `module` mode will generate ES module import statements for helpers
|
||
* and export the render function as the default export.
|
||
* - `function` mode will generate a single `const { helpers... } = Vue`
|
||
* statement and return the render function. It expects `Vue` to be globally
|
||
* available (or passed by wrapping the code with an IIFE). It is meant to be
|
||
* used with `new Function(code)()` to generate a render function at runtime.
|
||
* @default 'function'
|
||
*/
|
||
mode?: 'module' | 'function';
|
||
/**
|
||
* Generate source map?
|
||
* @default false
|
||
*/
|
||
sourceMap?: boolean;
|
||
/**
|
||
* SFC scoped styles ID
|
||
*/
|
||
scopeId?: string | null;
|
||
/**
|
||
* Option to optimize helper import bindings via variable assignment
|
||
* (only used for webpack code-split)
|
||
* @default false
|
||
*/
|
||
optimizeImports?: boolean;
|
||
/**
|
||
* Customize where to import runtime helpers from.
|
||
* @default 'vue'
|
||
*/
|
||
runtimeModuleName?: string;
|
||
/**
|
||
* Customize where to import ssr runtime helpers from/**
|
||
* @default 'vue/server-renderer'
|
||
*/
|
||
ssrRuntimeModuleName?: string;
|
||
/**
|
||
* Customize the global variable name of `Vue` to get helpers from
|
||
* in function mode
|
||
* @default 'Vue'
|
||
*/
|
||
runtimeGlobalName?: string;
|
||
}
|
||
type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
|
||
interface CodegenResult {
|
||
code: string;
|
||
preamble: string;
|
||
ast: RootNode;
|
||
map?: RawSourceMap;
|
||
}
|
||
|
||
declare function walkIdentifiers(root: Node$1, onIdentifier: (node: Identifier, parent: Node$1, parentStack: Node$1[], isReference: boolean, isLocal: boolean) => void, includeAll?: boolean, parentStack?: Node$1[], knownIds?: Record<string, number>): void;
|
||
declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
|
||
declare function extractIdentifiers(param: Node$1, nodes?: Identifier[]): Identifier[];
|
||
declare const isStaticProperty: (node: Node$1) => node is ObjectProperty;
|
||
|
||
interface SourceMapOptions {
|
||
/**
|
||
* Whether the mapping should be high-resolution.
|
||
* Hi-res mappings map every single character, meaning (for example) your devtools will always
|
||
* be able to pinpoint the exact location of function calls and so on.
|
||
* With lo-res mappings, devtools may only be able to identify the correct
|
||
* line - but they're quicker to generate and less bulky.
|
||
* You can also set `"boundary"` to generate a semi-hi-res mappings segmented per word boundary
|
||
* instead of per character, suitable for string semantics that are separated by words.
|
||
* If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
|
||
*/
|
||
hires?: boolean | 'boundary';
|
||
/**
|
||
* The filename where you plan to write the sourcemap.
|
||
*/
|
||
file?: string;
|
||
/**
|
||
* The filename of the file containing the original source.
|
||
*/
|
||
source?: string;
|
||
/**
|
||
* Whether to include the original content in the map's sourcesContent array.
|
||
*/
|
||
includeContent?: boolean;
|
||
}
|
||
|
||
type SourceMapSegment =
|
||
| [number]
|
||
| [number, number, number, number]
|
||
| [number, number, number, number, number];
|
||
|
||
interface DecodedSourceMap {
|
||
file: string;
|
||
sources: string[];
|
||
sourcesContent: (string | null)[];
|
||
names: string[];
|
||
mappings: SourceMapSegment[][];
|
||
x_google_ignoreList?: number[];
|
||
}
|
||
|
||
declare class SourceMap {
|
||
constructor(properties: DecodedSourceMap);
|
||
|
||
version: number;
|
||
file: string;
|
||
sources: string[];
|
||
sourcesContent: (string | null)[];
|
||
names: string[];
|
||
mappings: string;
|
||
x_google_ignoreList?: number[];
|
||
|
||
/**
|
||
* Returns the equivalent of `JSON.stringify(map)`
|
||
*/
|
||
toString(): string;
|
||
/**
|
||
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
||
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
||
*/
|
||
toUrl(): string;
|
||
}
|
||
|
||
type ExclusionRange = [ number, number ];
|
||
|
||
interface MagicStringOptions {
|
||
filename?: string,
|
||
indentExclusionRanges?: ExclusionRange | Array<ExclusionRange>;
|
||
}
|
||
|
||
interface IndentOptions {
|
||
exclude?: ExclusionRange | Array<ExclusionRange>;
|
||
indentStart?: boolean;
|
||
}
|
||
|
||
interface OverwriteOptions {
|
||
storeName?: boolean;
|
||
contentOnly?: boolean;
|
||
}
|
||
|
||
interface UpdateOptions {
|
||
storeName?: boolean;
|
||
overwrite?: boolean;
|
||
}
|
||
|
||
declare class MagicString {
|
||
constructor(str: string, options?: MagicStringOptions);
|
||
/**
|
||
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
||
*/
|
||
addSourcemapLocation(char: number): void;
|
||
/**
|
||
* Appends the specified content to the end of the string.
|
||
*/
|
||
append(content: string): MagicString;
|
||
/**
|
||
* Appends the specified content at the index in the original string.
|
||
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
||
* See also `s.prependLeft(...)`.
|
||
*/
|
||
appendLeft(index: number, content: string): MagicString;
|
||
/**
|
||
* Appends the specified content at the index in the original string.
|
||
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
||
* See also `s.prependRight(...)`.
|
||
*/
|
||
appendRight(index: number, content: string): MagicString;
|
||
/**
|
||
* Does what you'd expect.
|
||
*/
|
||
clone(): MagicString;
|
||
/**
|
||
* Generates a version 3 sourcemap.
|
||
*/
|
||
generateMap(options?: SourceMapOptions): SourceMap;
|
||
/**
|
||
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
||
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
||
*/
|
||
generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
|
||
getIndentString(): string;
|
||
|
||
/**
|
||
* Prefixes each line of the string with prefix.
|
||
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
||
*/
|
||
indent(options?: IndentOptions): MagicString;
|
||
/**
|
||
* Prefixes each line of the string with prefix.
|
||
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
||
*
|
||
* The options argument can have an exclude property, which is an array of [start, end] character ranges.
|
||
* These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
|
||
*/
|
||
indent(indentStr?: string, options?: IndentOptions): MagicString;
|
||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||
|
||
/**
|
||
* Moves the characters from `start and `end` to `index`.
|
||
*/
|
||
move(start: number, end: number, index: number): MagicString;
|
||
/**
|
||
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
||
* that range. The same restrictions as `s.remove()` apply.
|
||
*
|
||
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
||
* for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only
|
||
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
||
*
|
||
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
||
*/
|
||
overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): MagicString;
|
||
/**
|
||
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
||
*
|
||
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
||
* for later inclusion in a sourcemap's names array — and an overwrite property which determines whether only
|
||
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
||
*/
|
||
update(start: number, end: number, content: string, options?: boolean | UpdateOptions): MagicString;
|
||
/**
|
||
* Prepends the string with the specified content.
|
||
*/
|
||
prepend(content: string): MagicString;
|
||
/**
|
||
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
||
*/
|
||
prependLeft(index: number, content: string): MagicString;
|
||
/**
|
||
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||
*/
|
||
prependRight(index: number, content: string): MagicString;
|
||
/**
|
||
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
||
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
||
*/
|
||
remove(start: number, end: number): MagicString;
|
||
/**
|
||
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
||
* Throws error if the indices are for characters that were already removed.
|
||
*/
|
||
slice(start: number, end: number): string;
|
||
/**
|
||
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
||
*/
|
||
snip(start: number, end: number): MagicString;
|
||
/**
|
||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
||
*/
|
||
trim(charType?: string): MagicString;
|
||
/**
|
||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
||
*/
|
||
trimStart(charType?: string): MagicString;
|
||
/**
|
||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
||
*/
|
||
trimEnd(charType?: string): MagicString;
|
||
/**
|
||
* Removes empty lines from the start and end.
|
||
*/
|
||
trimLines(): MagicString;
|
||
/**
|
||
* String replacement with RegExp or string.
|
||
*/
|
||
replace(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): MagicString;
|
||
/**
|
||
* Same as `s.replace`, but replace all matched strings instead of just one.
|
||
*/
|
||
replaceAll(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): MagicString;
|
||
|
||
lastChar(): string;
|
||
lastLine(): string;
|
||
/**
|
||
* Returns true if the resulting source is empty (disregarding white space).
|
||
*/
|
||
isEmpty(): boolean;
|
||
length(): number;
|
||
|
||
/**
|
||
* Indicates if the string has been changed.
|
||
*/
|
||
hasChanged(): boolean;
|
||
|
||
original: string;
|
||
/**
|
||
* Returns the generated string.
|
||
*/
|
||
toString(): string;
|
||
}
|
||
|
||
declare function shouldTransform(src: string): boolean;
|
||
interface RefTransformOptions {
|
||
filename?: string;
|
||
sourceMap?: boolean;
|
||
parserPlugins?: ParserPlugin[];
|
||
importHelpersFrom?: string;
|
||
}
|
||
interface RefTransformResults {
|
||
code: string;
|
||
map: SourceMap | null;
|
||
rootRefs: string[];
|
||
importedHelpers: string[];
|
||
}
|
||
declare function transform(src: string, { filename, sourceMap, parserPlugins, importHelpersFrom }?: RefTransformOptions): RefTransformResults;
|
||
declare function transformAST(ast: Program, s: MagicString, offset?: number, knownRefs?: string[], knownProps?: Record<string, // public prop key
|
||
{
|
||
local: string;
|
||
default?: any;
|
||
isConst?: boolean;
|
||
}>): {
|
||
rootRefs: string[];
|
||
importedHelpers: string[];
|
||
};
|
||
|
||
interface AssetURLTagConfig {
|
||
[name: string]: string[];
|
||
}
|
||
interface AssetURLOptions {
|
||
/**
|
||
* If base is provided, instead of transforming relative asset urls into
|
||
* imports, they will be directly rewritten to absolute urls.
|
||
*/
|
||
base?: string | null;
|
||
/**
|
||
* If true, also processes absolute urls.
|
||
*/
|
||
includeAbsolute?: boolean;
|
||
tags?: AssetURLTagConfig;
|
||
}
|
||
|
||
interface TemplateCompiler {
|
||
compile(template: string, options: CompilerOptions): CodegenResult;
|
||
parse(template: string, options: ParserOptions): RootNode;
|
||
}
|
||
interface SFCTemplateCompileResults {
|
||
code: string;
|
||
ast?: RootNode;
|
||
preamble?: string;
|
||
source: string;
|
||
tips: string[];
|
||
errors: (string | CompilerError)[];
|
||
map?: RawSourceMap;
|
||
}
|
||
interface SFCTemplateCompileOptions {
|
||
source: string;
|
||
filename: string;
|
||
id: string;
|
||
scoped?: boolean;
|
||
slotted?: boolean;
|
||
isProd?: boolean;
|
||
ssr?: boolean;
|
||
ssrCssVars?: string[];
|
||
inMap?: RawSourceMap;
|
||
compiler?: TemplateCompiler;
|
||
compilerOptions?: CompilerOptions;
|
||
preprocessLang?: string;
|
||
preprocessOptions?: any;
|
||
/**
|
||
* In some cases, compiler-sfc may not be inside the project root (e.g. when
|
||
* linked or globally installed). In such cases a custom `require` can be
|
||
* passed to correctly resolve the preprocessors.
|
||
*/
|
||
preprocessCustomRequire?: (id: string) => any;
|
||
/**
|
||
* Configure what tags/attributes to transform into asset url imports,
|
||
* or disable the transform altogether with `false`.
|
||
*/
|
||
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean;
|
||
}
|
||
declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
|
||
|
||
interface SFCScriptCompileOptions {
|
||
/**
|
||
* Scope ID for prefixing injected CSS variables.
|
||
* This must be consistent with the `id` passed to `compileStyle`.
|
||
*/
|
||
id: string;
|
||
/**
|
||
* Production mode. Used to determine whether to generate hashed CSS variables
|
||
*/
|
||
isProd?: boolean;
|
||
/**
|
||
* Enable/disable source map. Defaults to true.
|
||
*/
|
||
sourceMap?: boolean;
|
||
/**
|
||
* https://babeljs.io/docs/en/babel-parser#plugins
|
||
*/
|
||
babelParserPlugins?: ParserPlugin[];
|
||
/**
|
||
* A list of files to parse for global types to be made available for type
|
||
* resolving in SFC macros. The list must be fully resolved file system paths.
|
||
*/
|
||
globalTypeFiles?: string[];
|
||
/**
|
||
* Compile the template and inline the resulting render function
|
||
* directly inside setup().
|
||
* - Only affects `<script setup>`
|
||
* - This should only be used in production because it prevents the template
|
||
* from being hot-reloaded separately from component state.
|
||
*/
|
||
inlineTemplate?: boolean;
|
||
/**
|
||
* Generate the final component as a variable instead of default export.
|
||
* This is useful in e.g. @vitejs/plugin-vue where the script needs to be
|
||
* placed inside the main module.
|
||
*/
|
||
genDefaultAs?: string;
|
||
/**
|
||
* Options for template compilation when inlining. Note these are options that
|
||
* would normally be passed to `compiler-sfc`'s own `compileTemplate()`, not
|
||
* options passed to `compiler-dom`.
|
||
*/
|
||
templateOptions?: Partial<SFCTemplateCompileOptions>;
|
||
/**
|
||
* Hoist <script setup> static constants.
|
||
* - Only enables when one `<script setup>` exists.
|
||
* @default true
|
||
*/
|
||
hoistStatic?: boolean;
|
||
/**
|
||
* (**Experimental**) Enable macro `defineModel`
|
||
* @default false
|
||
*/
|
||
defineModel?: boolean;
|
||
/**
|
||
* (**Experimental**) Enable reactive destructure for `defineProps`
|
||
* @default false
|
||
*/
|
||
propsDestructure?: boolean;
|
||
/**
|
||
* File system access methods to be used when resolving types
|
||
* imported in SFC macros. Defaults to ts.sys in Node.js, can be overwritten
|
||
* to use a virtual file system for use in browsers (e.g. in REPLs)
|
||
*/
|
||
fs?: {
|
||
fileExists(file: string): boolean;
|
||
readFile(file: string): string | undefined;
|
||
};
|
||
/**
|
||
* (Experimental) Enable syntax transform for using refs without `.value` and
|
||
* using destructured props with reactivity
|
||
* @deprecated the Reactivity Transform proposal has been dropped. This
|
||
* feature will be removed from Vue core in 3.4. If you intend to continue
|
||
* using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html).
|
||
*/
|
||
reactivityTransform?: boolean;
|
||
}
|
||
interface ImportBinding {
|
||
isType: boolean;
|
||
imported: string;
|
||
local: string;
|
||
source: string;
|
||
isFromSetup: boolean;
|
||
isUsedInTemplate: boolean;
|
||
}
|
||
/**
|
||
* Compile `<script setup>`
|
||
* It requires the whole SFC descriptor because we need to handle and merge
|
||
* normal `<script>` + `<script setup>` if both are present.
|
||
*/
|
||
declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
|
||
|
||
interface SFCParseOptions {
|
||
filename?: string;
|
||
sourceMap?: boolean;
|
||
sourceRoot?: string;
|
||
pad?: boolean | 'line' | 'space';
|
||
ignoreEmpty?: boolean;
|
||
compiler?: TemplateCompiler;
|
||
}
|
||
interface SFCBlock {
|
||
type: string;
|
||
content: string;
|
||
attrs: Record<string, string | true>;
|
||
loc: SourceLocation;
|
||
map?: RawSourceMap;
|
||
lang?: string;
|
||
src?: string;
|
||
}
|
||
interface SFCTemplateBlock extends SFCBlock {
|
||
type: 'template';
|
||
ast: ElementNode;
|
||
}
|
||
interface SFCScriptBlock extends SFCBlock {
|
||
type: 'script';
|
||
setup?: string | boolean;
|
||
bindings?: BindingMetadata$1;
|
||
imports?: Record<string, ImportBinding>;
|
||
scriptAst?: Statement[];
|
||
scriptSetupAst?: Statement[];
|
||
warnings?: string[];
|
||
/**
|
||
* Fully resolved dependency file paths (unix slashes) with imported types
|
||
* used in macros, used for HMR cache busting in @vitejs/plugin-vue and
|
||
* vue-loader.
|
||
*/
|
||
deps?: string[];
|
||
}
|
||
interface SFCStyleBlock extends SFCBlock {
|
||
type: 'style';
|
||
scoped?: boolean;
|
||
module?: string | boolean;
|
||
}
|
||
interface SFCDescriptor {
|
||
filename: string;
|
||
source: string;
|
||
template: SFCTemplateBlock | null;
|
||
script: SFCScriptBlock | null;
|
||
scriptSetup: SFCScriptBlock | null;
|
||
styles: SFCStyleBlock[];
|
||
customBlocks: SFCBlock[];
|
||
cssVars: string[];
|
||
/**
|
||
* whether the SFC uses :slotted() modifier.
|
||
* this is used as a compiler optimization hint.
|
||
*/
|
||
slotted: boolean;
|
||
/**
|
||
* compare with an existing descriptor to determine whether HMR should perform
|
||
* a reload vs. re-render.
|
||
*
|
||
* Note: this comparison assumes the prev/next script are already identical,
|
||
* and only checks the special case where <script setup lang="ts"> unused import
|
||
* pruning result changes due to template changes.
|
||
*/
|
||
shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
|
||
}
|
||
interface SFCParseResult {
|
||
descriptor: SFCDescriptor;
|
||
errors: (CompilerError | SyntaxError)[];
|
||
}
|
||
declare const parseCache: Map<string, SFCParseResult> & {
|
||
max?: number | undefined;
|
||
};
|
||
declare function parse$1(source: string, { sourceMap, filename, sourceRoot, pad, ignoreEmpty, compiler }?: SFCParseOptions): SFCParseResult;
|
||
|
||
type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus';
|
||
|
||
interface SFCStyleCompileOptions {
|
||
source: string;
|
||
filename: string;
|
||
id: string;
|
||
scoped?: boolean;
|
||
trim?: boolean;
|
||
isProd?: boolean;
|
||
inMap?: RawSourceMap;
|
||
preprocessLang?: PreprocessLang;
|
||
preprocessOptions?: any;
|
||
preprocessCustomRequire?: (id: string) => any;
|
||
postcssOptions?: any;
|
||
postcssPlugins?: any[];
|
||
/**
|
||
* @deprecated use `inMap` instead.
|
||
*/
|
||
map?: RawSourceMap;
|
||
}
|
||
/**
|
||
* Aligns with postcss-modules
|
||
* https://github.com/css-modules/postcss-modules
|
||
*/
|
||
interface CSSModulesOptions {
|
||
scopeBehaviour?: 'global' | 'local';
|
||
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
||
hashPrefix?: string;
|
||
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
||
exportGlobals?: boolean;
|
||
globalModulePaths?: RegExp[];
|
||
}
|
||
interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||
isAsync?: boolean;
|
||
modules?: boolean;
|
||
modulesOptions?: CSSModulesOptions;
|
||
}
|
||
interface SFCStyleCompileResults {
|
||
code: string;
|
||
map: RawSourceMap | undefined;
|
||
rawResult: Result | LazyResult | undefined;
|
||
errors: Error[];
|
||
modules?: Record<string, string>;
|
||
dependencies: Set<string>;
|
||
}
|
||
declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
|
||
declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
|
||
|
||
declare function rewriteDefault(input: string, as: string, parserPlugins?: ParserPlugin[]): string;
|
||
/**
|
||
* Utility for rewriting `export default` in a script block into a variable
|
||
* declaration so that we can inject things into it
|
||
*/
|
||
declare function rewriteDefaultAST(ast: Statement[], s: MagicString, as: string): void;
|
||
|
||
type PropsDestructureBindings = Record<string, // public prop key
|
||
{
|
||
local: string;
|
||
default?: Expression;
|
||
}>;
|
||
|
||
interface ModelDecl {
|
||
type: TSType | undefined;
|
||
options: string | undefined;
|
||
identifier: string | undefined;
|
||
}
|
||
|
||
declare const enum BindingTypes {
|
||
/**
|
||
* returned from data()
|
||
*/
|
||
DATA = "data",
|
||
/**
|
||
* declared as a prop
|
||
*/
|
||
PROPS = "props",
|
||
/**
|
||
* a local alias of a `<script setup>` destructured prop.
|
||
* the original is stored in __propsAliases of the bindingMetadata object.
|
||
*/
|
||
PROPS_ALIASED = "props-aliased",
|
||
/**
|
||
* a let binding (may or may not be a ref)
|
||
*/
|
||
SETUP_LET = "setup-let",
|
||
/**
|
||
* a const binding that can never be a ref.
|
||
* these bindings don't need `unref()` calls when processed in inlined
|
||
* template expressions.
|
||
*/
|
||
SETUP_CONST = "setup-const",
|
||
/**
|
||
* a const binding that does not need `unref()`, but may be mutated.
|
||
*/
|
||
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
||
/**
|
||
* a const binding that may be a ref.
|
||
*/
|
||
SETUP_MAYBE_REF = "setup-maybe-ref",
|
||
/**
|
||
* bindings that are guaranteed to be refs
|
||
*/
|
||
SETUP_REF = "setup-ref",
|
||
/**
|
||
* declared by other options, e.g. computed, inject
|
||
*/
|
||
OPTIONS = "options",
|
||
/**
|
||
* a literal constant, e.g. 'foo', 1, true
|
||
*/
|
||
LITERAL_CONST = "literal-const"
|
||
}
|
||
type BindingMetadata = {
|
||
[key: string]: BindingTypes | undefined;
|
||
} & {
|
||
__isScriptSetup?: boolean;
|
||
__propsAliases?: Record<string, string>;
|
||
};
|
||
|
||
declare class ScriptCompileContext {
|
||
descriptor: SFCDescriptor;
|
||
options: Partial<SFCScriptCompileOptions>;
|
||
isJS: boolean;
|
||
isTS: boolean;
|
||
scriptAst: Program | null;
|
||
scriptSetupAst: Program | null;
|
||
source: string;
|
||
filename: string;
|
||
s: MagicString;
|
||
startOffset: number | undefined;
|
||
endOffset: number | undefined;
|
||
scope?: TypeScope;
|
||
globalScopes?: TypeScope[];
|
||
userImports: Record<string, ImportBinding>;
|
||
hasDefinePropsCall: boolean;
|
||
hasDefineEmitCall: boolean;
|
||
hasDefineExposeCall: boolean;
|
||
hasDefaultExportName: boolean;
|
||
hasDefaultExportRender: boolean;
|
||
hasDefineOptionsCall: boolean;
|
||
hasDefineSlotsCall: boolean;
|
||
hasDefineModelCall: boolean;
|
||
propsIdentifier: string | undefined;
|
||
propsRuntimeDecl: Node$1 | undefined;
|
||
propsTypeDecl: Node$1 | undefined;
|
||
propsDestructureDecl: ObjectPattern | undefined;
|
||
propsDestructuredBindings: PropsDestructureBindings;
|
||
propsDestructureRestId: string | undefined;
|
||
propsRuntimeDefaults: Node$1 | undefined;
|
||
emitsRuntimeDecl: Node$1 | undefined;
|
||
emitsTypeDecl: Node$1 | undefined;
|
||
emitIdentifier: string | undefined;
|
||
modelDecls: Record<string, ModelDecl>;
|
||
optionsRuntimeDecl: Node$1 | undefined;
|
||
bindingMetadata: BindingMetadata;
|
||
helperImports: Set<string>;
|
||
helper(key: string): string;
|
||
/**
|
||
* to be exposed on compiled script block for HMR cache busting
|
||
*/
|
||
deps?: Set<string>;
|
||
/**
|
||
* cache for resolved fs
|
||
*/
|
||
fs?: NonNullable<SFCScriptCompileOptions['fs']>;
|
||
constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
|
||
getString(node: Node$1, scriptSetup?: boolean): string;
|
||
error(msg: string, node: Node$1, scope?: TypeScope): never;
|
||
}
|
||
|
||
/**
|
||
* TypeResolveContext is compatible with ScriptCompileContext
|
||
* but also allows a simpler version of it with minimal required properties
|
||
* when resolveType needs to be used in a non-SFC context, e.g. in a babel
|
||
* plugin. The simplest context can be just:
|
||
* ```ts
|
||
* const ctx: SimpleTypeResolveContext = {
|
||
* filename: '...',
|
||
* source: '...',
|
||
* options: {},
|
||
* error() {},
|
||
* ast: []
|
||
* }
|
||
* ```
|
||
*/
|
||
type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'options'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
|
||
ast: Statement[];
|
||
};
|
||
type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext;
|
||
type Import = Pick<ImportBinding, 'source' | 'imported'>;
|
||
interface WithScope {
|
||
_ownerScope: TypeScope;
|
||
}
|
||
type ScopeTypeNode = Node$1 & WithScope & {
|
||
_ns?: TSModuleDeclaration & WithScope;
|
||
};
|
||
declare class TypeScope {
|
||
filename: string;
|
||
source: string;
|
||
offset: number;
|
||
imports: Record<string, Import>;
|
||
types: Record<string, ScopeTypeNode>;
|
||
declares: Record<string, ScopeTypeNode>;
|
||
constructor(filename: string, source: string, offset?: number, imports?: Record<string, Import>, types?: Record<string, ScopeTypeNode>, declares?: Record<string, ScopeTypeNode>);
|
||
resolvedImportSources: Record<string, string>;
|
||
exportedTypes: Record<string, ScopeTypeNode>;
|
||
exportedDeclares: Record<string, ScopeTypeNode>;
|
||
}
|
||
interface MaybeWithScope {
|
||
_ownerScope?: TypeScope;
|
||
}
|
||
interface ResolvedElements {
|
||
props: Record<string, (TSPropertySignature | TSMethodSignature) & {
|
||
_ownerScope: TypeScope;
|
||
}>;
|
||
calls?: (TSCallSignatureDeclaration | TSFunctionType)[];
|
||
}
|
||
/**
|
||
* Resolve arbitrary type node to a list of type elements that can be then
|
||
* mapped to runtime props or emits.
|
||
*/
|
||
declare function resolveTypeElements(ctx: TypeResolveContext, node: Node$1 & MaybeWithScope & {
|
||
_resolvedElements?: ResolvedElements;
|
||
}, scope?: TypeScope): ResolvedElements;
|
||
/**
|
||
* @private
|
||
*/
|
||
declare function registerTS(_ts: any): void;
|
||
/**
|
||
* @private
|
||
*/
|
||
declare function invalidateTypeCache(filename: string): void;
|
||
declare function inferRuntimeType(ctx: TypeResolveContext, node: Node$1 & MaybeWithScope, scope?: TypeScope): string[];
|
||
|
||
declare const version: string;
|
||
|
||
declare const walk: any;
|
||
|
||
type _compiler_AssetURLOptions = AssetURLOptions;
|
||
type _compiler_AssetURLTagConfig = AssetURLTagConfig;
|
||
type _compiler_CompilerError = CompilerError;
|
||
type _compiler_CompilerOptions = CompilerOptions;
|
||
type _compiler_MagicString = MagicString;
|
||
declare const _compiler_MagicString: typeof MagicString;
|
||
type _compiler_SFCAsyncStyleCompileOptions = SFCAsyncStyleCompileOptions;
|
||
type _compiler_SFCBlock = SFCBlock;
|
||
type _compiler_SFCDescriptor = SFCDescriptor;
|
||
type _compiler_SFCParseOptions = SFCParseOptions;
|
||
type _compiler_SFCParseResult = SFCParseResult;
|
||
type _compiler_SFCScriptBlock = SFCScriptBlock;
|
||
type _compiler_SFCScriptCompileOptions = SFCScriptCompileOptions;
|
||
type _compiler_SFCStyleBlock = SFCStyleBlock;
|
||
type _compiler_SFCStyleCompileOptions = SFCStyleCompileOptions;
|
||
type _compiler_SFCStyleCompileResults = SFCStyleCompileResults;
|
||
type _compiler_SFCTemplateBlock = SFCTemplateBlock;
|
||
type _compiler_SFCTemplateCompileOptions = SFCTemplateCompileOptions;
|
||
type _compiler_SFCTemplateCompileResults = SFCTemplateCompileResults;
|
||
type _compiler_ScriptCompileContext = ScriptCompileContext;
|
||
declare const _compiler_ScriptCompileContext: typeof ScriptCompileContext;
|
||
type _compiler_SimpleTypeResolveContext = SimpleTypeResolveContext;
|
||
type _compiler_TemplateCompiler = TemplateCompiler;
|
||
type _compiler_TypeResolveContext = TypeResolveContext;
|
||
declare const _compiler_compileScript: typeof compileScript;
|
||
declare const _compiler_compileStyle: typeof compileStyle;
|
||
declare const _compiler_compileStyleAsync: typeof compileStyleAsync;
|
||
declare const _compiler_compileTemplate: typeof compileTemplate;
|
||
declare const _compiler_extractIdentifiers: typeof extractIdentifiers;
|
||
declare const _compiler_generateCodeFrame: typeof generateCodeFrame;
|
||
declare const _compiler_inferRuntimeType: typeof inferRuntimeType;
|
||
declare const _compiler_invalidateTypeCache: typeof invalidateTypeCache;
|
||
declare const _compiler_isInDestructureAssignment: typeof isInDestructureAssignment;
|
||
declare const _compiler_isStaticProperty: typeof isStaticProperty;
|
||
declare const _compiler_parseCache: typeof parseCache;
|
||
declare const _compiler_registerTS: typeof registerTS;
|
||
declare const _compiler_resolveTypeElements: typeof resolveTypeElements;
|
||
declare const _compiler_rewriteDefault: typeof rewriteDefault;
|
||
declare const _compiler_rewriteDefaultAST: typeof rewriteDefaultAST;
|
||
declare const _compiler_version: typeof version;
|
||
declare const _compiler_walk: typeof walk;
|
||
declare const _compiler_walkIdentifiers: typeof walkIdentifiers;
|
||
declare namespace _compiler {
|
||
export { type _compiler_AssetURLOptions as AssetURLOptions, type _compiler_AssetURLTagConfig as AssetURLTagConfig, type BindingMetadata$1 as BindingMetadata, type _compiler_CompilerError as CompilerError, type _compiler_CompilerOptions as CompilerOptions, _compiler_MagicString as MagicString, type _compiler_SFCAsyncStyleCompileOptions as SFCAsyncStyleCompileOptions, type _compiler_SFCBlock as SFCBlock, type _compiler_SFCDescriptor as SFCDescriptor, type _compiler_SFCParseOptions as SFCParseOptions, type _compiler_SFCParseResult as SFCParseResult, type _compiler_SFCScriptBlock as SFCScriptBlock, type _compiler_SFCScriptCompileOptions as SFCScriptCompileOptions, type _compiler_SFCStyleBlock as SFCStyleBlock, type _compiler_SFCStyleCompileOptions as SFCStyleCompileOptions, type _compiler_SFCStyleCompileResults as SFCStyleCompileResults, type _compiler_SFCTemplateBlock as SFCTemplateBlock, type _compiler_SFCTemplateCompileOptions as SFCTemplateCompileOptions, type _compiler_SFCTemplateCompileResults as SFCTemplateCompileResults, _compiler_ScriptCompileContext as ScriptCompileContext, type _compiler_SimpleTypeResolveContext as SimpleTypeResolveContext, type _compiler_TemplateCompiler as TemplateCompiler, type _compiler_TypeResolveContext as TypeResolveContext, parse$2 as babelParse, _compiler_compileScript as compileScript, _compiler_compileStyle as compileStyle, _compiler_compileStyleAsync as compileStyleAsync, _compiler_compileTemplate as compileTemplate, _compiler_extractIdentifiers as extractIdentifiers, _compiler_generateCodeFrame as generateCodeFrame, _compiler_inferRuntimeType as inferRuntimeType, _compiler_invalidateTypeCache as invalidateTypeCache, _compiler_isInDestructureAssignment as isInDestructureAssignment, _compiler_isStaticProperty as isStaticProperty, parse$1 as parse, _compiler_parseCache as parseCache, _compiler_registerTS as registerTS, _compiler_resolveTypeElements as resolveTypeElements, _compiler_rewriteDefault as rewriteDefault, _compiler_rewriteDefaultAST as rewriteDefaultAST, shouldTransform as shouldTransformRef, transform as transformRef, transformAST as transformRefAST, _compiler_version as version, _compiler_walk as walk, _compiler_walkIdentifiers as walkIdentifiers };
|
||
}
|
||
|
||
interface Options$1 {
|
||
include?: string | RegExp | (string | RegExp)[];
|
||
exclude?: string | RegExp | (string | RegExp)[];
|
||
isProduction?: boolean;
|
||
script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins' | 'globalTypeFiles' | 'defineModel' | 'propsDestructure' | 'fs' | 'reactivityTransform' | 'hoistStatic'>>;
|
||
template?: Partial<Pick<SFCTemplateCompileOptions, 'compiler' | 'compilerOptions' | 'preprocessOptions' | 'preprocessCustomRequire' | 'transformAssetUrls'>>;
|
||
style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>>;
|
||
/**
|
||
* Transform Vue SFCs into custom elements.
|
||
* - `true`: all `*.vue` imports are converted into custom elements
|
||
* - `string | RegExp`: matched files are converted into custom elements
|
||
*
|
||
* @default /\.ce\.vue$/
|
||
*/
|
||
customElement?: boolean | string | RegExp | (string | RegExp)[];
|
||
/**
|
||
* Enable Vue reactivity transform (experimental).
|
||
* https://vuejs.org/guide/extras/reactivity-transform.html
|
||
* - `true`: transform will be enabled for all vue,js(x),ts(x) files except
|
||
* those inside node_modules
|
||
* - `string | RegExp`: apply to vue + only matched files (will include
|
||
* node_modules, so specify directories if necessary)
|
||
* - `false`: disable in all cases
|
||
*
|
||
* @default false
|
||
*/
|
||
reactivityTransform?: boolean | string | RegExp | (string | RegExp)[];
|
||
/**
|
||
* Use custom compiler-sfc instance. Can be used to force a specific version.
|
||
*/
|
||
compiler?: typeof _compiler;
|
||
}
|
||
|
||
/**
|
||
* How frequently the page is likely to change. This value provides general
|
||
* information to search engines and may not correlate exactly to how often they crawl the page. Please note that the
|
||
* value of this tag is considered a hint and not a command. See
|
||
* <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable
|
||
* values
|
||
*/
|
||
declare enum EnumChangefreq {
|
||
DAILY = "daily",
|
||
MONTHLY = "monthly",
|
||
ALWAYS = "always",
|
||
HOURLY = "hourly",
|
||
WEEKLY = "weekly",
|
||
YEARLY = "yearly",
|
||
NEVER = "never"
|
||
}
|
||
/**
|
||
* https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190
|
||
*/
|
||
interface NewsItem {
|
||
access?: 'Registration' | 'Subscription';
|
||
publication: {
|
||
name: string;
|
||
/**
|
||
* The `<language>` is the language of your publication. Use an ISO 639
|
||
* language code (2 or 3 letters).
|
||
*/
|
||
language: string;
|
||
};
|
||
/**
|
||
* @example 'PressRelease, Blog'
|
||
*/
|
||
genres?: string;
|
||
/**
|
||
* Article publication date in W3C format, using either the "complete date" (YYYY-MM-DD) format or the "complete date
|
||
* plus hours, minutes, and seconds"
|
||
*/
|
||
publication_date: string;
|
||
/**
|
||
* The title of the news article
|
||
* @example 'Companies A, B in Merger Talks'
|
||
*/
|
||
title: string;
|
||
/**
|
||
* @example 'business, merger, acquisition'
|
||
*/
|
||
keywords?: string;
|
||
/**
|
||
* @example 'NASDAQ:A, NASDAQ:B'
|
||
*/
|
||
stock_tickers?: string;
|
||
}
|
||
/**
|
||
* Sitemap Image
|
||
* https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190
|
||
*/
|
||
interface Img {
|
||
/**
|
||
* The URL of the image
|
||
* @example 'https://example.com/image.jpg'
|
||
*/
|
||
url: string;
|
||
/**
|
||
* The caption of the image
|
||
* @example 'Thanksgiving dinner'
|
||
*/
|
||
caption?: string;
|
||
/**
|
||
* The title of the image
|
||
* @example 'Star Wars EP IV'
|
||
*/
|
||
title?: string;
|
||
/**
|
||
* The geographic location of the image.
|
||
* @example 'Limerick, Ireland'
|
||
*/
|
||
geoLocation?: string;
|
||
/**
|
||
* A URL to the license of the image.
|
||
* @example 'https://example.com/license.txt'
|
||
*/
|
||
license?: string;
|
||
}
|
||
/**
|
||
* https://support.google.com/webmasters/answer/189077
|
||
*/
|
||
interface LinkItem {
|
||
/**
|
||
* @example 'en'
|
||
*/
|
||
lang: string;
|
||
/**
|
||
* @example 'en-us'
|
||
*/
|
||
hreflang?: string;
|
||
url: string;
|
||
}
|
||
/**
|
||
* How to handle errors in passed in urls
|
||
*/
|
||
declare enum ErrorLevel {
|
||
/**
|
||
* Validation will be skipped and nothing logged or thrown.
|
||
*/
|
||
SILENT = "silent",
|
||
/**
|
||
* If an invalid value is encountered, a console.warn will be called with details
|
||
*/
|
||
WARN = "warn",
|
||
/**
|
||
* An Error will be thrown on encountering invalid data.
|
||
*/
|
||
THROW = "throw"
|
||
}
|
||
declare type ErrorHandler$1 = (error: Error, level: ErrorLevel) => void;
|
||
|
||
interface NSArgs {
|
||
news: boolean;
|
||
video: boolean;
|
||
xhtml: boolean;
|
||
image: boolean;
|
||
custom?: string[];
|
||
}
|
||
interface SitemapStreamOptions extends TransformOptions$1 {
|
||
hostname?: string;
|
||
level?: ErrorLevel;
|
||
lastmodDateOnly?: boolean;
|
||
xmlns?: NSArgs;
|
||
xslUrl?: string;
|
||
errorHandler?: ErrorHandler$1;
|
||
}
|
||
|
||
interface SitemapItem {
|
||
lastmod?: string | number | Date;
|
||
changefreq?: `${EnumChangefreq}`;
|
||
fullPrecisionPriority?: boolean;
|
||
priority?: number;
|
||
news?: NewsItem;
|
||
expires?: string;
|
||
androidLink?: string;
|
||
ampLink?: string;
|
||
url: string;
|
||
video?: any;
|
||
img?: string | Img | (string | Img)[];
|
||
links?: LinkItem[];
|
||
lastmodfile?: string | Buffer | URL;
|
||
lastmodISO?: string;
|
||
lastmodrealtime?: boolean;
|
||
}
|
||
|
||
declare namespace Token {
|
||
type Nesting = 1 | 0 | -1;
|
||
}
|
||
|
||
/**
|
||
* Create new token and fill passed properties.
|
||
*/
|
||
declare class Token {
|
||
constructor(type: string, tag: string, nesting: Token.Nesting);
|
||
|
||
/**
|
||
* Type of the token, e.g. "paragraph_open"
|
||
*/
|
||
type: string;
|
||
|
||
/**
|
||
* HTML tag name, e.g. "p"
|
||
*/
|
||
tag: string;
|
||
|
||
/**
|
||
* HTML attributes. Format: `[[name1, value1], [name2, value2]]`
|
||
*/
|
||
attrs: [string, string][] | null;
|
||
|
||
/**
|
||
* Source map info. Format: `[line_begin, line_end]`
|
||
*/
|
||
map: [number, number] | null;
|
||
|
||
/**
|
||
* Level change (number in {-1, 0, 1} set), where:
|
||
*
|
||
* - `1` means the tag is opening
|
||
* - `0` means the tag is self-closing
|
||
* - `-1` means the tag is closing
|
||
*/
|
||
nesting: 1 | 0 | -1;
|
||
|
||
/**
|
||
* nesting level, the same as `state.level`
|
||
*/
|
||
level: number;
|
||
|
||
/**
|
||
* An array of child nodes (inline and img tokens)
|
||
*/
|
||
children: Token[] | null;
|
||
|
||
/**
|
||
* In a case of self-closing tag (code, html, fence, etc.),
|
||
* it has contents of this tag.
|
||
*/
|
||
content: string;
|
||
|
||
/**
|
||
* '*' or '_' for emphasis, fence string for fence, etc.
|
||
*/
|
||
markup: string;
|
||
|
||
/**
|
||
* Fence info string
|
||
*/
|
||
info: string;
|
||
|
||
/**
|
||
* A place for plugins to store an arbitrary data
|
||
*/
|
||
meta: any;
|
||
|
||
/**
|
||
* True for block-level tokens, false for inline tokens.
|
||
* Used in renderer to calculate line breaks
|
||
*/
|
||
block: boolean;
|
||
|
||
/**
|
||
* If it's true, ignore this element when rendering. Used for tight lists
|
||
* to hide paragraphs.
|
||
*/
|
||
hidden: boolean;
|
||
|
||
/**
|
||
* Search attribute index by name.
|
||
*/
|
||
attrIndex(name: string): number;
|
||
|
||
/**
|
||
* Add `[name, value]` attribute to list. Init attrs if necessary
|
||
*/
|
||
attrPush(attrData: [string, string]): void;
|
||
|
||
/**
|
||
* Set `name` attribute to `value`. Override old value if exists.
|
||
*/
|
||
attrSet(name: string, value: string): void;
|
||
|
||
/**
|
||
* Get the value of attribute `name`, or null if it does not exist.
|
||
*/
|
||
attrGet(name: string): string | null;
|
||
|
||
/**
|
||
*
|
||
* Join value to existing attribute via space. Or create new attribute if not
|
||
* exists. Useful to operate with token classes.
|
||
*/
|
||
attrJoin(name: string, value: string): void;
|
||
}
|
||
|
||
declare namespace __token {
|
||
export { Token as default };
|
||
}
|
||
|
||
// Type definitions for linkify-it 3.0.2
|
||
// Project: https://github.com/markdown-it/linkify-it
|
||
// Definitions by: Lindsey Smith <https://github.com/praxxis>
|
||
// Robert Coie <https://github.com/rapropos/typed-linkify-it>
|
||
// Alex Plumb <https://github.com/alexplumb>
|
||
// Rafa Gares <https://github.com/ragafus>
|
||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||
// TypeScript Version: 2.2
|
||
|
||
declare const LinkifyIt: {
|
||
(
|
||
schemas?: LinkifyIt.SchemaRules | LinkifyIt.Options,
|
||
options?: LinkifyIt.Options,
|
||
): LinkifyIt.LinkifyIt;
|
||
new(
|
||
schemas?: LinkifyIt.SchemaRules | LinkifyIt.Options,
|
||
options?: LinkifyIt.Options,
|
||
): LinkifyIt.LinkifyIt;
|
||
};
|
||
|
||
declare namespace LinkifyIt {
|
||
type Validate = (text: string, pos: number, self: LinkifyIt) => number | boolean;
|
||
|
||
interface FullRule {
|
||
validate: string | RegExp | Validate;
|
||
normalize?: ((match: Match) => void) | undefined;
|
||
}
|
||
|
||
type Rule = string | FullRule;
|
||
|
||
interface SchemaRules {
|
||
[schema: string]: Rule;
|
||
}
|
||
|
||
interface Options {
|
||
fuzzyLink?: boolean | undefined;
|
||
fuzzyIP?: boolean | undefined;
|
||
fuzzyEmail?: boolean | undefined;
|
||
}
|
||
|
||
interface Match {
|
||
index: number;
|
||
lastIndex: number;
|
||
raw: string;
|
||
schema: string;
|
||
text: string;
|
||
url: string;
|
||
}
|
||
|
||
interface LinkifyIt {
|
||
// Use overloads to provide contextual typing to `FullRule.normalize`, which is ambiguous with string.normalize
|
||
// This appears unneeded to the unified-signatures lint rule.
|
||
add(schema: string, rule: string): LinkifyIt;
|
||
// tslint:disable-next-line: unified-signatures
|
||
add(schema: string, rule: FullRule | null): LinkifyIt;
|
||
match(text: string): Match[] | null;
|
||
normalize(raw: string): string;
|
||
pretest(text: string): boolean;
|
||
set(options: Options): LinkifyIt;
|
||
test(text: string): boolean;
|
||
testSchemaAt(text: string, schemaName: string, pos: number): number;
|
||
tlds(list: string | string[], keepOld?: boolean): LinkifyIt;
|
||
re: {
|
||
[key: string]: RegExp;
|
||
};
|
||
}
|
||
}
|
||
|
||
declare namespace encode {
|
||
const defaultChars: string;
|
||
const componentChars: string;
|
||
}
|
||
declare function encode(str: string, exclude?: string, keepEscaped?: boolean): string;
|
||
|
||
declare namespace decode {
|
||
const defaultChars: string;
|
||
const componentChars: string;
|
||
}
|
||
declare function decode(input: string, exclude?: string): string;
|
||
|
||
declare function parse(input: string, slashesDenoteHost?: boolean): Url;
|
||
|
||
declare function format(url: Url): string;
|
||
|
||
// Type definitions for mdurl 1.0
|
||
// Project: https://github.com/markdown-it/mdurl#readme
|
||
// Definitions by: Junyoung Choi <https://github.com/rokt33r>
|
||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||
|
||
|
||
interface Url {
|
||
protocol: string;
|
||
slashes: string;
|
||
auth: string;
|
||
port: string;
|
||
hostname: string;
|
||
hash: string;
|
||
search: string;
|
||
pathname: string;
|
||
}
|
||
|
||
type mdurl_Url = Url;
|
||
declare const mdurl_decode: typeof decode;
|
||
declare const mdurl_encode: typeof encode;
|
||
declare const mdurl_format: typeof format;
|
||
declare const mdurl_parse: typeof parse;
|
||
declare namespace mdurl {
|
||
export { type mdurl_Url as Url, mdurl_decode as decode, mdurl_encode as encode, mdurl_format as format, mdurl_parse as parse };
|
||
}
|
||
|
||
// import ucmicro from 'uc.micro';
|
||
|
||
interface Utils {
|
||
lib: {
|
||
mdurl: typeof mdurl;
|
||
};
|
||
|
||
/**
|
||
* Merge objects
|
||
*/
|
||
assign(target: any, ...sources: any[]): any;
|
||
|
||
/**
|
||
* Check if the type is string or not
|
||
*/
|
||
isString(obj: any): obj is string;
|
||
|
||
/**
|
||
* has own property
|
||
*/
|
||
has(obj: any, key: keyof any): boolean;
|
||
|
||
unescapeMd(str: string): string;
|
||
unescapeAll(str: string): string;
|
||
|
||
isValidEntityCode(code: number): boolean;
|
||
fromCodePoint(code: number): string;
|
||
escapeHtml(str: string): string;
|
||
|
||
/**
|
||
* Remove element from array and put another array at those position.
|
||
* Useful for some operations with tokens.
|
||
* Return a new array.
|
||
*/
|
||
arrayReplaceAt<T>(src: T[], pos: number, newElements: T[]): T[];
|
||
|
||
isSpace(code: number): boolean;
|
||
|
||
/**
|
||
* Zs (unicode class) || [\t\f\v\r\n]
|
||
*/
|
||
isWhiteSpace(code: number): boolean;
|
||
|
||
/**
|
||
* Markdown ASCII punctuation characters.
|
||
*
|
||
* !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
|
||
* http://spec.commonmark.org/0.15/#ascii-punctuation-character
|
||
*
|
||
* Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
|
||
*/
|
||
isMdAsciiPunct(code: number): boolean;
|
||
|
||
/**
|
||
* Currently without astral characters support.
|
||
*/
|
||
isPunctChar(ch: string): boolean;
|
||
|
||
escapeRE(str: string): string;
|
||
|
||
/**
|
||
* Hepler to unify [reference labels].
|
||
*/
|
||
normalizeReference(str: string): string;
|
||
}
|
||
|
||
declare const utils: Utils;
|
||
|
||
declare namespace StateInline {
|
||
interface Scanned {
|
||
can_open: boolean;
|
||
can_close: boolean;
|
||
length: number;
|
||
}
|
||
|
||
interface Delimiter {
|
||
marker: number;
|
||
length: number;
|
||
jump: number;
|
||
token: number;
|
||
end: number;
|
||
open: boolean;
|
||
close: boolean;
|
||
}
|
||
|
||
interface TokenMata {
|
||
delimiters: Delimiter[];
|
||
}
|
||
}
|
||
|
||
declare class StateInline {
|
||
constructor(src: string, md: MarkdownIt, env: any, outTokens: Token[]);
|
||
|
||
src: string;
|
||
env: any;
|
||
md: MarkdownIt;
|
||
tokens: Token[];
|
||
tokens_meta: Array<StateInline.TokenMata | null>;
|
||
|
||
pos: number;
|
||
posMax: number;
|
||
level: number;
|
||
pending: string;
|
||
pendingLevel: number;
|
||
|
||
/**
|
||
* Stores { start: end } pairs. Useful for backtrack
|
||
* optimization of pairs parse (emphasis, strikes).
|
||
*/
|
||
cache: any;
|
||
|
||
/**
|
||
* List of emphasis-like delimiters for current tag
|
||
*/
|
||
delimiters: StateInline.Delimiter[];
|
||
|
||
// Stack of delimiter lists for upper level tags
|
||
// _prev_delimiters: StateInline.Delimiter[][];
|
||
|
||
/**
|
||
* Flush pending text
|
||
*/
|
||
pushPending(): Token;
|
||
|
||
/**
|
||
* Push new token to "stream".
|
||
* If pending text exists - flush it as text token
|
||
*/
|
||
push(type: string, tag: string, nesting: Token.Nesting): Token;
|
||
|
||
/**
|
||
* Scan a sequence of emphasis-like markers, and determine whether
|
||
* it can start an emphasis sequence or end an emphasis sequence.
|
||
*
|
||
* @param start position to scan from (it should point at a valid marker);
|
||
* @param canSplitWord determine if these markers can be found inside a word
|
||
*/
|
||
scanDelims(start: number, canSplitWord: boolean): StateInline.Scanned;
|
||
|
||
Token: typeof Token;
|
||
}
|
||
|
||
declare function parseLinkLabel(state: StateInline, start: number, disableNested?: boolean): number;
|
||
|
||
declare namespace parseLinkDestination {
|
||
interface ParseResult {
|
||
ok: boolean;
|
||
pos: number;
|
||
lines: number;
|
||
str: string;
|
||
}
|
||
}
|
||
|
||
declare function parseLinkDestination(str: string, pos: number, max: number): parseLinkDestination.ParseResult;
|
||
|
||
declare function parseLinkTitle(str: string, pos: number, max: number): parseLinkDestination.ParseResult;
|
||
|
||
interface Helpers {
|
||
parseLinkLabel: typeof parseLinkLabel;
|
||
parseLinkDestination: typeof parseLinkDestination;
|
||
parseLinkTitle: typeof parseLinkTitle;
|
||
}
|
||
|
||
declare const helpers: Helpers;
|
||
|
||
declare namespace Ruler {
|
||
interface RuleOptions {
|
||
/**
|
||
* array with names of "alternate" chains.
|
||
*/
|
||
alt: string[];
|
||
}
|
||
}
|
||
|
||
/**
|
||
* class Ruler
|
||
*
|
||
* Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
|
||
* [[MarkdownIt#inline]] to manage sequences of functions (rules):
|
||
*
|
||
* - keep rules in defined order
|
||
* - assign the name to each rule
|
||
* - enable/disable rules
|
||
* - add/replace rules
|
||
* - allow assign rules to additional named chains (in the same)
|
||
* - cacheing lists of active rules
|
||
*
|
||
* You will not need use this class directly until write plugins. For simple
|
||
* rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
|
||
* [[MarkdownIt.use]].
|
||
*/
|
||
declare class Ruler<T> {
|
||
/**
|
||
* Replace rule by name with new function & options. Throws error if name not
|
||
* found.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* Replace existing typographer replacement rule with new one:
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* md.core.ruler.at('replacements', function replace(state) {
|
||
* //...
|
||
* });
|
||
* ```
|
||
*
|
||
* @param name rule name to replace.
|
||
* @param fn new rule function.
|
||
* @param options new rule options (not mandatory).
|
||
*/
|
||
at(name: string, fn: T, options?: Ruler.RuleOptions): void;
|
||
|
||
/**
|
||
* Add new rule to chain before one with given name. See also
|
||
* [[Ruler.after]], [[Ruler.push]].
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
|
||
* //...
|
||
* });
|
||
* ```
|
||
*
|
||
* @param beforeName new rule will be added before this one.
|
||
* @param ruleName name of added rule.
|
||
* @param fn rule function.
|
||
* @param options rule options (not mandatory).
|
||
*/
|
||
before(beforeName: string, ruleName: string, fn: T, options?: Ruler.RuleOptions): void;
|
||
|
||
/**
|
||
* Add new rule to chain after one with given name. See also
|
||
* [[Ruler.before]], [[Ruler.push]].
|
||
*
|
||
* ##### Options:
|
||
*
|
||
* - __alt__ - array with names of "alternate" chains.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* md.inline.ruler.after('text', 'my_rule', function replace(state) {
|
||
* //...
|
||
* });
|
||
* ```
|
||
*
|
||
* @param afterName new rule will be added after this one.
|
||
* @param ruleName name of added rule.
|
||
* @param fn rule function.
|
||
* @param options rule options (not mandatory).
|
||
*/
|
||
after(afterName: string, ruleName: string, fn: T, options?: Ruler.RuleOptions): void;
|
||
|
||
/**
|
||
* Push new rule to the end of chain. See also
|
||
* [[Ruler.before]], [[Ruler.after]].
|
||
*
|
||
* ##### Options:
|
||
*
|
||
* - __alt__ - array with names of "alternate" chains.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* md.core.ruler.push('my_rule', function replace(state) {
|
||
* //...
|
||
* });
|
||
* ```
|
||
*
|
||
* @param ruleName name of added rule.
|
||
* @param fn rule function.
|
||
* @param options rule options (not mandatory).
|
||
*/
|
||
push(ruleName: string, fn: T, options?: Ruler.RuleOptions): void;
|
||
|
||
/**
|
||
* Enable rules with given names. If any rule name not found - throw Error.
|
||
* Errors can be disabled by second param.
|
||
*
|
||
* Returns list of found rule names (if no exception happened).
|
||
*
|
||
* See also [[Ruler.disable]], [[Ruler.enableOnly]].
|
||
*
|
||
* @param list list of rule names to enable.
|
||
* @param ignoreInvalid set `true` to ignore errors when rule not found.
|
||
*/
|
||
enable(list: string | string[], ignoreInvalid?: boolean): string[];
|
||
|
||
/**
|
||
* Enable rules with given names, and disable everything else. If any rule name
|
||
* not found - throw Error. Errors can be disabled by second param.
|
||
*
|
||
* See also [[Ruler.disable]], [[Ruler.enable]].
|
||
*
|
||
* @param list list of rule names to enable (whitelist).
|
||
* @param ignoreInvalid set `true` to ignore errors when rule not found.
|
||
*/
|
||
enableOnly(list: string | string[], ignoreInvalid?: boolean): string[];
|
||
|
||
/**
|
||
* Disable rules with given names. If any rule name not found - throw Error.
|
||
* Errors can be disabled by second param.
|
||
*
|
||
* Returns list of found rule names (if no exception happened).
|
||
*
|
||
* See also [[Ruler.enable]], [[Ruler.enableOnly]].
|
||
*
|
||
* @param list list of rule names to disable.
|
||
* @param ignoreInvalid set `true` to ignore errors when rule not found.
|
||
*/
|
||
disable(list: string | string[], ignoreInvalid?: boolean): string[];
|
||
|
||
/**
|
||
* Return array of active functions (rules) for given chain name. It analyzes
|
||
* rules configuration, compiles caches if not exists and returns result.
|
||
*
|
||
* Default chain name is `''` (empty string). It can't be skipped. That's
|
||
* done intentionally, to keep signature monomorphic for high speed.
|
||
*/
|
||
getRules(chainName: string): T[];
|
||
}
|
||
|
||
declare namespace StateBlock {
|
||
type ParentType = 'blockquote' | 'list' | 'root' | 'paragraph' | 'reference';
|
||
}
|
||
|
||
declare class StateBlock {
|
||
constructor(src: string, md: MarkdownIt, env: any, tokens: Token[]);
|
||
|
||
src: string;
|
||
|
||
/**
|
||
* link to parser instance
|
||
*/
|
||
md: MarkdownIt;
|
||
|
||
env: any;
|
||
|
||
//
|
||
// Internal state vartiables
|
||
//
|
||
|
||
tokens: Token[];
|
||
|
||
/**
|
||
* line begin offsets for fast jumps
|
||
*/
|
||
bMarks: number[];
|
||
/**
|
||
* line end offsets for fast jumps
|
||
*/
|
||
eMarks: number[];
|
||
/**
|
||
* offsets of the first non-space characters (tabs not expanded)
|
||
*/
|
||
tShift: number[];
|
||
/**
|
||
* indents for each line (tabs expanded)
|
||
*/
|
||
sCount: number[];
|
||
|
||
/**
|
||
* An amount of virtual spaces (tabs expanded) between beginning
|
||
* of each line (bMarks) and real beginning of that line.
|
||
*
|
||
* It exists only as a hack because blockquotes override bMarks
|
||
* losing information in the process.
|
||
*
|
||
* It's used only when expanding tabs, you can think about it as
|
||
* an initial tab length, e.g. bsCount=21 applied to string `\t123`
|
||
* means first tab should be expanded to 4-21%4 === 3 spaces.
|
||
*/
|
||
bsCount: number[];
|
||
|
||
// block parser variables
|
||
|
||
/**
|
||
* required block content indent (for example, if we are
|
||
* inside a list, it would be positioned after list marker)
|
||
*/
|
||
blkIndent: number;
|
||
/**
|
||
* line index in src
|
||
*/
|
||
line: number;
|
||
/**
|
||
* lines count
|
||
*/
|
||
lineMax: number;
|
||
/**
|
||
* loose/tight mode for lists
|
||
*/
|
||
tight: boolean;
|
||
/**
|
||
* indent of the current dd block (-1 if there isn't any)
|
||
*/
|
||
ddIndent: number;
|
||
/**
|
||
* indent of the current list block (-1 if there isn't any)
|
||
*/
|
||
listIndent: number;
|
||
|
||
/**
|
||
* can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
|
||
* used in lists to determine if they interrupt a paragraph
|
||
*/
|
||
parentType: StateBlock.ParentType;
|
||
|
||
level: number;
|
||
|
||
/**
|
||
* renderer
|
||
*/
|
||
result: string;
|
||
|
||
/**
|
||
* Push new token to "stream".
|
||
*/
|
||
push(type: string, tag: string, nesting: Token.Nesting): Token;
|
||
|
||
isEmpty(line: number): boolean;
|
||
|
||
skipEmptyLines(from: number): number;
|
||
|
||
/**
|
||
* Skip spaces from given position.
|
||
*/
|
||
skipSpaces(pos: number): number;
|
||
|
||
/**
|
||
* Skip spaces from given position in reverse.
|
||
*/
|
||
skipSpacesBack(pos: number, min: number): number;
|
||
|
||
/**
|
||
* Skip char codes from given position
|
||
*/
|
||
skipChars(pos: number, code: number): number;
|
||
|
||
/**
|
||
* Skip char codes reverse from given position - 1
|
||
*/
|
||
skipCharsBack(pos: number, code: number, min: number): number;
|
||
|
||
/**
|
||
* cut lines range from source.
|
||
*/
|
||
getLines(begin: number, end: number, indent: number, keepLastLF: boolean): string;
|
||
|
||
Token: typeof Token;
|
||
}
|
||
|
||
declare namespace ParserBlock {
|
||
type RuleBlock = (state: StateBlock, startLine: number, endLine: number, silent: boolean) => boolean;
|
||
}
|
||
|
||
declare class ParserBlock {
|
||
/**
|
||
* [[Ruler]] instance. Keep configuration of block rules.
|
||
*/
|
||
ruler: Ruler<ParserBlock.RuleBlock>;
|
||
|
||
/**
|
||
* Generate tokens for input range
|
||
*/
|
||
tokenize(state: StateBlock, startLine: number, endLine: number): void;
|
||
|
||
/**
|
||
* Process input string and push block tokens into `outTokens`
|
||
*/
|
||
parse(str: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||
|
||
State: typeof StateBlock;
|
||
}
|
||
|
||
declare class StateCore {
|
||
constructor(src: string, md: MarkdownIt, env: any);
|
||
|
||
src: string;
|
||
env: any;
|
||
tokens: Token[];
|
||
inlineMode: boolean;
|
||
|
||
/**
|
||
* link to parser instance
|
||
*/
|
||
md: MarkdownIt;
|
||
|
||
Token: typeof Token;
|
||
}
|
||
|
||
declare namespace Core {
|
||
type RuleCore = (state: StateCore) => void;
|
||
}
|
||
|
||
declare class Core {
|
||
ruler: Ruler<Core.RuleCore>;
|
||
|
||
/**
|
||
* Executes core chain rules.
|
||
*/
|
||
process(state: StateCore): void;
|
||
|
||
State: typeof StateCore;
|
||
}
|
||
|
||
declare namespace ParserInline {
|
||
type RuleInline = (state: StateInline, silent: boolean) => boolean;
|
||
type RuleInline2 = (state: StateInline) => boolean;
|
||
}
|
||
|
||
declare class ParserInline {
|
||
/**
|
||
* [[Ruler]] instance. Keep configuration of inline rules.
|
||
*/
|
||
ruler: Ruler<ParserInline.RuleInline>;
|
||
|
||
/**
|
||
* [[Ruler]] instance. Second ruler used for post-processing
|
||
* (e.g. in emphasis-like rules).
|
||
*/
|
||
ruler2: Ruler<ParserInline.RuleInline2>;
|
||
|
||
/**
|
||
* Skip single token by running all rules in validation mode;
|
||
* returns `true` if any rule reported success
|
||
*/
|
||
skipToken(state: StateInline): void;
|
||
|
||
/**
|
||
* Generate tokens for input range
|
||
*/
|
||
tokenize(state: StateInline): void;
|
||
|
||
/**
|
||
* Process input string and push inline tokens into `outTokens`
|
||
*/
|
||
parse(str: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||
|
||
State: typeof StateInline;
|
||
}
|
||
|
||
declare namespace Renderer {
|
||
type RenderRule = (tokens: Token[], idx: number, options: MarkdownIt.Options, env: any, self: Renderer) => string;
|
||
|
||
interface RenderRuleRecord {
|
||
[type: string]: RenderRule | undefined;
|
||
code_inline?: RenderRule | undefined;
|
||
code_block?: RenderRule | undefined;
|
||
fence?: RenderRule | undefined;
|
||
image?: RenderRule | undefined;
|
||
hardbreak?: RenderRule | undefined;
|
||
softbreak?: RenderRule | undefined;
|
||
text?: RenderRule | undefined;
|
||
html_block?: RenderRule | undefined;
|
||
html_inline?: RenderRule | undefined;
|
||
}
|
||
}
|
||
|
||
declare class Renderer {
|
||
/**
|
||
* Contains render rules for tokens. Can be updated and extended.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* md.renderer.rules.strong_open = function () { return '<b>'; };
|
||
* md.renderer.rules.strong_close = function () { return '</b>'; };
|
||
*
|
||
* var result = md.renderInline(...);
|
||
* ```
|
||
*
|
||
* Each rule is called as independent static function with fixed signature:
|
||
*
|
||
* ```javascript
|
||
* function my_token_render(tokens, idx, options, env, renderer) {
|
||
* // ...
|
||
* return renderedHTML;
|
||
* }
|
||
* ```
|
||
*
|
||
* See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
|
||
* for more details and examples.
|
||
*/
|
||
rules: Renderer.RenderRuleRecord;
|
||
|
||
/**
|
||
* Render token attributes to string.
|
||
*/
|
||
renderAttrs(token: Token): string;
|
||
|
||
/**
|
||
* Default token renderer. Can be overriden by custom function
|
||
* in [[Renderer#rules]].
|
||
*
|
||
* @param tokens list of tokens
|
||
* @param idx token index to render
|
||
* @param options params of parser instance
|
||
*/
|
||
renderToken(tokens: Token[], idx: number, options: MarkdownIt.Options): string;
|
||
|
||
/**
|
||
* The same as [[Renderer.render]], but for single token of `inline` type.
|
||
*
|
||
* @param tokens list on block tokens to renter
|
||
* @param options params of parser instance
|
||
* @param env additional data from parsed input (references, for example)
|
||
*/
|
||
renderInline(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
||
|
||
/**
|
||
* Special kludge for image `alt` attributes to conform CommonMark spec.
|
||
* Don't try to use it! Spec requires to show `alt` content with stripped markup,
|
||
* instead of simple escaping.
|
||
*
|
||
* @param tokens list on block tokens to renter
|
||
* @param options params of parser instance
|
||
* @param env additional data from parsed input (references, for example)
|
||
*/
|
||
renderInlineAsText(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
||
|
||
/**
|
||
* Takes token stream and generates HTML. Probably, you will never need to call
|
||
* this method directly.
|
||
*
|
||
* @param tokens list on block tokens to renter
|
||
* @param options params of parser instance
|
||
* @param env additional data from parsed input (references, for example)
|
||
*/
|
||
render(tokens: Token[], options: MarkdownIt.Options, env: any): string;
|
||
}
|
||
|
||
interface MarkdownItConstructor {
|
||
new (): MarkdownIt;
|
||
new (presetName: MarkdownIt.PresetName, options?: MarkdownIt.Options): MarkdownIt;
|
||
new (options: MarkdownIt.Options): MarkdownIt;
|
||
(): MarkdownIt;
|
||
(presetName: MarkdownIt.PresetName, options?: MarkdownIt.Options): MarkdownIt;
|
||
(options: MarkdownIt.Options): MarkdownIt;
|
||
}
|
||
|
||
declare namespace MarkdownIt {
|
||
type Token = typeof __token;
|
||
|
||
/**
|
||
* MarkdownIt provides named presets as a convenience to quickly
|
||
* enable/disable active syntax rules and options for common use cases.
|
||
*
|
||
* - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
|
||
* configures parser to strict [CommonMark](http://commonmark.org/) mode.
|
||
* - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
|
||
* similar to GFM, used when no preset name given. Enables all available rules,
|
||
* but still without html, typographer & autolinker.
|
||
* - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
|
||
* all rules disabled. Useful to quickly setup your config via `.enable()`.
|
||
* For example, when you need only `bold` and `italic` markup and nothing else.
|
||
*/
|
||
type PresetName = 'default' | 'zero' | 'commonmark';
|
||
|
||
interface Options {
|
||
/**
|
||
* Set `true` to enable HTML tags in source. Be careful!
|
||
* That's not safe! You may need external sanitizer to protect output from XSS.
|
||
* It's better to extend features via plugins, instead of enabling HTML.
|
||
* @default false
|
||
*/
|
||
html?: boolean | undefined;
|
||
|
||
/**
|
||
* Set `true` to add '/' when closing single tags
|
||
* (`<br />`). This is needed only for full CommonMark compatibility. In real
|
||
* world you will need HTML output.
|
||
* @default false
|
||
*/
|
||
xhtmlOut?: boolean | undefined;
|
||
|
||
/**
|
||
* Set `true` to convert `\n` in paragraphs into `<br>`.
|
||
* @default false
|
||
*/
|
||
breaks?: boolean | undefined;
|
||
|
||
/**
|
||
* CSS language class prefix for fenced blocks.
|
||
* Can be useful for external highlighters.
|
||
* @default 'language-'
|
||
*/
|
||
langPrefix?: string | undefined;
|
||
|
||
/**
|
||
* Set `true` to autoconvert URL-like text to links.
|
||
* @default false
|
||
*/
|
||
linkify?: boolean | undefined;
|
||
|
||
/**
|
||
* Set `true` to enable [some language-neutral replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
|
||
* quotes beautification (smartquotes).
|
||
* @default false
|
||
*/
|
||
typographer?: boolean | undefined;
|
||
|
||
/**
|
||
* Double + single quotes replacement
|
||
* pairs, when typographer enabled and smartquotes on. For example, you can
|
||
* use `'«»„“'` for Russian, `'„“‚‘'` for German, and
|
||
* `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
|
||
* @default '“”‘’'
|
||
*/
|
||
quotes?: string | string[];
|
||
|
||
/**
|
||
* Highlighter function for fenced code blocks.
|
||
* Highlighter `function (str, lang, attrs)` should return escaped HTML. It can
|
||
* also return empty string if the source was not changed and should be escaped
|
||
* externally. If result starts with <pre... internal wrapper is skipped.
|
||
* @default null
|
||
*/
|
||
highlight?: ((str: string, lang: string, attrs: string) => string) | null | undefined;
|
||
}
|
||
|
||
type PluginSimple = (md: MarkdownIt) => void;
|
||
type PluginWithOptions<T = any> = (md: MarkdownIt, options?: T) => void;
|
||
type PluginWithParams = (md: MarkdownIt, ...params: any[]) => void;
|
||
}
|
||
|
||
interface MarkdownIt {
|
||
/**
|
||
* Instance of [[ParserInline]]. You may need it to add new rules when
|
||
* writing plugins. For simple rules control use [[MarkdownIt.disable]] and
|
||
* [[MarkdownIt.enable]].
|
||
*/
|
||
readonly inline: ParserInline;
|
||
|
||
/**
|
||
* Instance of [[ParserBlock]]. You may need it to add new rules when
|
||
* writing plugins. For simple rules control use [[MarkdownIt.disable]] and
|
||
* [[MarkdownIt.enable]].
|
||
*/
|
||
readonly block: ParserBlock;
|
||
|
||
/**
|
||
* Instance of [[Core]] chain executor. You may need it to add new rules when
|
||
* writing plugins. For simple rules control use [[MarkdownIt.disable]] and
|
||
* [[MarkdownIt.enable]].
|
||
*/
|
||
readonly core: Core;
|
||
|
||
/**
|
||
* Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
|
||
* rules for new token types, generated by plugins.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* function myToken(tokens, idx, options, env, self) {
|
||
* //...
|
||
* return result;
|
||
* };
|
||
*
|
||
* md.renderer.rules['my_token'] = myToken
|
||
* ```
|
||
*
|
||
* See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
|
||
*/
|
||
readonly renderer: Renderer;
|
||
|
||
/**
|
||
* [linkify-it](https://github.com/markdown-it/linkify-it) instance.
|
||
* Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
|
||
* rule.
|
||
*/
|
||
readonly linkify: LinkifyIt.LinkifyIt;
|
||
|
||
/**
|
||
* Link validation function. CommonMark allows too much in links. By default
|
||
* we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
|
||
* except some embedded image types.
|
||
*
|
||
* You can change this behaviour:
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
* // enable everything
|
||
* md.validateLink = function () { return true; }
|
||
* ```
|
||
*/
|
||
validateLink(url: string): boolean;
|
||
|
||
/**
|
||
* Function used to encode link url to a machine-readable format,
|
||
* which includes url-encoding, punycode, etc.
|
||
*/
|
||
normalizeLink(url: string): string;
|
||
|
||
/**
|
||
* Function used to decode link url to a human-readable format`
|
||
*/
|
||
normalizeLinkText(url: string): string;
|
||
|
||
readonly utils: typeof utils;
|
||
|
||
readonly helpers: typeof helpers;
|
||
|
||
readonly options: MarkdownIt.Options;
|
||
|
||
/**
|
||
* *chainable*
|
||
*
|
||
* Set parser options (in the same format as in constructor). Probably, you
|
||
* will never need it, but you can change options after constructor call.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')()
|
||
* .set({ html: true, breaks: true })
|
||
* .set({ typographer: true });
|
||
* ```
|
||
*
|
||
* __Note:__ To achieve the best possible performance, don't modify a
|
||
* `markdown-it` instance options on the fly. If you need multiple configurations
|
||
* it's best to create multiple instances and initialize each with separate
|
||
* config.
|
||
*/
|
||
set(options: MarkdownIt.Options): this;
|
||
|
||
/**
|
||
* *chainable*, *internal*
|
||
*
|
||
* Batch load of all options and compenent settings. This is internal method,
|
||
* and you probably will not need it. But if you with - see available presets
|
||
* and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
|
||
*
|
||
* We strongly recommend to use presets instead of direct config loads. That
|
||
* will give better compatibility with next versions.
|
||
*/
|
||
configure(presets: MarkdownIt.PresetName): this;
|
||
|
||
/**
|
||
* *chainable*
|
||
*
|
||
* Enable list or rules. It will automatically find appropriate components,
|
||
* containing rules with given names. If rule not found, and `ignoreInvalid`
|
||
* not set - throws exception.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')()
|
||
* .enable(['sub', 'sup'])
|
||
* .disable('smartquotes');
|
||
* ```
|
||
*
|
||
* @param list rule name or list of rule names to enable
|
||
* @param ignoreInvalid set `true` to ignore errors when rule not found.
|
||
*/
|
||
enable(list: string | string[], ignoreInvalid?: boolean): this;
|
||
|
||
/**
|
||
* *chainable*
|
||
*
|
||
* The same as [[MarkdownIt.enable]], but turn specified rules off.
|
||
*
|
||
* @param list rule name or list of rule names to disable.
|
||
* @param ignoreInvalid set `true` to ignore errors when rule not found.
|
||
*/
|
||
disable(list: string | string[], ignoreInvalid?: boolean): this;
|
||
|
||
/**
|
||
* *chainable*
|
||
*
|
||
* Load specified plugin with given params into current parser instance.
|
||
* It's just a sugar to call `plugin(md, params)` with curring.
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* var iterator = require('markdown-it-for-inline');
|
||
* var md = require('markdown-it')()
|
||
* .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
|
||
* tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
|
||
* });
|
||
* ```
|
||
*/
|
||
use(plugin: MarkdownIt.PluginSimple): this;
|
||
use<T = any>(plugin: MarkdownIt.PluginWithOptions<T>, options?: T): this;
|
||
use(plugin: MarkdownIt.PluginWithParams, ...params: any[]): this;
|
||
|
||
/**
|
||
* *internal*
|
||
*
|
||
* Parse input string and returns list of block tokens (special token type
|
||
* "inline" will contain list of inline tokens). You should not call this
|
||
* method directly, until you write custom renderer (for example, to produce
|
||
* AST).
|
||
*
|
||
* `env` is used to pass data between "distributed" rules and return additional
|
||
* metadata like reference info, needed for the renderer. It also can be used to
|
||
* inject data in specific cases. Usually, you will be ok to pass `{}`,
|
||
* and then pass updated object to renderer.
|
||
*
|
||
* @param src source string
|
||
* @param env environment sandbox
|
||
*/
|
||
parse(src: string, env: any): Token[];
|
||
|
||
/**
|
||
* Render markdown string into html. It does all magic for you :).
|
||
*
|
||
* `env` can be used to inject additional metadata (`{}` by default).
|
||
* But you will not need it with high probability. See also comment
|
||
* in [[MarkdownIt.parse]].
|
||
*
|
||
* @param src source string
|
||
* @param env environment sandbox
|
||
*/
|
||
render(src: string, env?: any): string;
|
||
|
||
/**
|
||
* *internal*
|
||
*
|
||
* The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
|
||
* block tokens list with the single `inline` element, containing parsed inline
|
||
* tokens in `children` property. Also updates `env` object.
|
||
*
|
||
* @param src source string
|
||
* @param env environment sandbox
|
||
*/
|
||
parseInline(src: string, env: any): Token[];
|
||
|
||
/**
|
||
* Similar to [[MarkdownIt.render]] but for single paragraph content. Result
|
||
* will NOT be wrapped into `<p>` tags.
|
||
*
|
||
* @param src source string
|
||
* @param env environment sandbox
|
||
*/
|
||
renderInline(src: string, env?: any): string;
|
||
}
|
||
|
||
/**
|
||
* Main parser/renderer class.
|
||
*
|
||
* ##### Usage
|
||
*
|
||
* ```javascript
|
||
* // node.js, "classic" way:
|
||
* var MarkdownIt = require('markdown-it'),
|
||
* md = new MarkdownIt();
|
||
* var result = md.render('# markdown-it rulezz!');
|
||
*
|
||
* // node.js, the same, but with sugar:
|
||
* var md = require('markdown-it')();
|
||
* var result = md.render('# markdown-it rulezz!');
|
||
*
|
||
* // browser without AMD, added to "window" on script load
|
||
* // Note, there are no dash.
|
||
* var md = window.markdownit();
|
||
* var result = md.render('# markdown-it rulezz!');
|
||
* ```
|
||
*
|
||
* Single line rendering, without paragraph wrap:
|
||
*
|
||
* ```javascript
|
||
* var md = require('markdown-it')();
|
||
* var result = md.renderInline('__markdown-it__ rulezz!');
|
||
* ```
|
||
*
|
||
* ##### Example
|
||
*
|
||
* ```javascript
|
||
* // commonmark mode
|
||
* var md = require('markdown-it')('commonmark');
|
||
*
|
||
* // default mode
|
||
* var md = require('markdown-it')();
|
||
*
|
||
* // enable everything
|
||
* var md = require('markdown-it')({
|
||
* html: true,
|
||
* linkify: true,
|
||
* typographer: true
|
||
* });
|
||
* ```
|
||
*
|
||
* ##### Syntax highlighting
|
||
*
|
||
* ```js
|
||
* var hljs = require('highlight.js') // https://highlightjs.org/
|
||
*
|
||
* var md = require('markdown-it')({
|
||
* highlight: function (str, lang) {
|
||
* if (lang && hljs.getLanguage(lang)) {
|
||
* try {
|
||
* return hljs.highlight(lang, str, true).value;
|
||
* } catch (__) {}
|
||
* }
|
||
*
|
||
* return ''; // use external default escaping
|
||
* }
|
||
* });
|
||
* ```
|
||
*
|
||
* Or with full wrapper override (if you need assign class to `<pre>`):
|
||
*
|
||
* ```javascript
|
||
* var hljs = require('highlight.js') // https://highlightjs.org/
|
||
*
|
||
* // Actual default values
|
||
* var md = require('markdown-it')({
|
||
* highlight: function (str, lang) {
|
||
* if (lang && hljs.getLanguage(lang)) {
|
||
* try {
|
||
* return '<pre class="hljs"><code>' +
|
||
* hljs.highlight(lang, str, true).value +
|
||
* '</code></pre>';
|
||
* } catch (__) {}
|
||
* }
|
||
*
|
||
* return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
|
||
* }
|
||
* });
|
||
* ```
|
||
*/
|
||
declare const MarkdownIt: MarkdownItConstructor;
|
||
|
||
/**
|
||
* Options of @mdit-vue/plugin-component
|
||
*/
|
||
interface ComponentPluginOptions {
|
||
/**
|
||
* Extra tags to be treated as block tags.
|
||
*
|
||
* @default []
|
||
*/
|
||
blockTags?: string[];
|
||
/**
|
||
* Extra tags to be treated as inline tags.
|
||
*
|
||
* @default []
|
||
*/
|
||
inlineTags?: string[];
|
||
}
|
||
|
||
/**
|
||
* Takes a string or object with `content` property, extracts
|
||
* and parses front-matter from the string, then returns an object
|
||
* with `data`, `content` and other [useful properties](#returned-object).
|
||
*
|
||
* ```js
|
||
* var matter = require('gray-matter');
|
||
* console.log(matter('---\ntitle: Home\n---\nOther stuff'));
|
||
* //=> { data: { title: 'Home'}, content: 'Other stuff' }
|
||
* ```
|
||
* @param {Object|String} `input` String, or object with `content` string
|
||
* @param {Object} `options`
|
||
* @return {Object}
|
||
* @api public
|
||
*/
|
||
declare function matter<
|
||
I extends matter.Input,
|
||
O extends matter.GrayMatterOption<I, O>
|
||
>(input: I | { content: I }, options?: O): matter.GrayMatterFile<I>
|
||
|
||
declare namespace matter {
|
||
type Input = string | Buffer
|
||
interface GrayMatterOption<
|
||
I extends Input,
|
||
O extends GrayMatterOption<I, O>
|
||
> {
|
||
parser?: () => void
|
||
eval?: boolean
|
||
excerpt?: boolean | ((input: I, options: O) => string)
|
||
excerpt_separator?: string
|
||
engines?: {
|
||
[index: string]:
|
||
| ((input: string) => object)
|
||
| { parse: (input: string) => object; stringify?: (data: object) => string }
|
||
}
|
||
language?: string
|
||
delimiters?: string | [string, string]
|
||
}
|
||
interface GrayMatterFile<I extends Input> {
|
||
data: { [key: string]: any }
|
||
content: string
|
||
excerpt?: string
|
||
orig: Buffer | I
|
||
language: string
|
||
matter: string
|
||
stringify(lang: string): string
|
||
}
|
||
|
||
/**
|
||
* Stringify an object to YAML or the specified language, and
|
||
* append it to the given string. By default, only YAML and JSON
|
||
* can be stringified. See the [engines](#engines) section to learn
|
||
* how to stringify other languages.
|
||
*
|
||
* ```js
|
||
* console.log(matter.stringify('foo bar baz', {title: 'Home'}));
|
||
* // results in:
|
||
* // ---
|
||
* // title: Home
|
||
* // ---
|
||
* // foo bar baz
|
||
* ```
|
||
* @param {String|Object} `file` The content string to append to stringified front-matter, or a file object with `file.content` string.
|
||
* @param {Object} `data` Front matter to stringify.
|
||
* @param {Object} `options` [Options](#options) to pass to gray-matter and [js-yaml].
|
||
* @return {String} Returns a string created by wrapping stringified yaml with delimiters, and appending that to the given string.
|
||
*/
|
||
export function stringify<O extends GrayMatterOption<string, O>>(
|
||
file: string | { content: string },
|
||
data: object,
|
||
options?: GrayMatterOption<string, O>
|
||
): string
|
||
|
||
/**
|
||
* Synchronously read a file from the file system and parse
|
||
* front matter. Returns the same object as the [main function](#matter).
|
||
*
|
||
* ```js
|
||
* var file = matter.read('./content/blog-post.md');
|
||
* ```
|
||
* @param {String} `filepath` file path of the file to read.
|
||
* @param {Object} `options` [Options](#options) to pass to gray-matter.
|
||
* @return {Object} Returns [an object](#returned-object) with `data` and `content`
|
||
*/
|
||
export function read<O extends GrayMatterOption<string, O>>(
|
||
fp: string,
|
||
options?: GrayMatterOption<string, O>
|
||
): matter.GrayMatterFile<string>
|
||
|
||
/**
|
||
* Returns true if the given `string` has front matter.
|
||
* @param {String} `string`
|
||
* @param {Object} `options`
|
||
* @return {Boolean} True if front matter exists.
|
||
*/
|
||
export function test<O extends matter.GrayMatterOption<string, O>>(
|
||
str: string,
|
||
options?: GrayMatterOption<string, O>
|
||
): boolean
|
||
|
||
/**
|
||
* Detect the language to use, if one is defined after the
|
||
* first front-matter delimiter.
|
||
* @param {String} `string`
|
||
* @param {Object} `options`
|
||
* @return {Object} Object with `raw` (actual language string), and `name`, the language with whitespace trimmed
|
||
*/
|
||
export function language<O extends matter.GrayMatterOption<string, O>>(
|
||
str: string,
|
||
options?: GrayMatterOption<string, O>
|
||
): { name: string; raw: string }
|
||
}
|
||
|
||
type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>;
|
||
/**
|
||
* Options of @mdit-vue/plugin-frontmatter
|
||
*/
|
||
interface FrontmatterPluginOptions {
|
||
/**
|
||
* Options of gray-matter
|
||
*
|
||
* @see https://github.com/jonschlinkert/gray-matter#options
|
||
*/
|
||
grayMatterOptions?: GrayMatterOptions;
|
||
/**
|
||
* Render the excerpt or not
|
||
*
|
||
* @default true
|
||
*/
|
||
renderExcerpt?: boolean;
|
||
}
|
||
declare module '@mdit-vue/types' {
|
||
interface MarkdownItEnv {
|
||
/**
|
||
* The raw Markdown content without frontmatter
|
||
*/
|
||
content?: string;
|
||
/**
|
||
* The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
|
||
*
|
||
* - Would be the rendered HTML when `renderExcerpt` is enabled
|
||
* - Would be the raw Markdown when `renderExcerpt` is disabled
|
||
*/
|
||
excerpt?: string;
|
||
/**
|
||
* The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
|
||
*/
|
||
frontmatter?: Record<string, unknown>;
|
||
}
|
||
}
|
||
|
||
interface MarkdownItHeader {
|
||
/**
|
||
* The level of the header
|
||
*
|
||
* `1` to `6` for `<h1>` to `<h6>`
|
||
*/
|
||
level: number;
|
||
/**
|
||
* The title of the header
|
||
*/
|
||
title: string;
|
||
/**
|
||
* The slug of the header
|
||
*
|
||
* Typically the `id` attr of the header anchor
|
||
*/
|
||
slug: string;
|
||
/**
|
||
* Link of the header
|
||
*
|
||
* Typically using `#${slug}` as the anchor hash
|
||
*/
|
||
link: string;
|
||
/**
|
||
* The children of the header
|
||
*/
|
||
children: MarkdownItHeader[];
|
||
}
|
||
|
||
/**
|
||
* Options of @mdit-vue/plugin-headers
|
||
*/
|
||
interface HeadersPluginOptions {
|
||
/**
|
||
* A custom slugification function
|
||
*
|
||
* Should use the same slugify function with markdown-it-anchor
|
||
* to ensure the link is matched
|
||
*/
|
||
slugify?: (str: string) => string;
|
||
/**
|
||
* A function for formatting header title
|
||
*/
|
||
format?: (str: string) => string;
|
||
/**
|
||
* Heading level that going to be extracted
|
||
*
|
||
* Should be a subset of markdown-it-anchor's `level` option
|
||
* to ensure the slug is existed
|
||
*
|
||
* @default [2,3]
|
||
*/
|
||
level?: number[];
|
||
/**
|
||
* Should allow headers inside nested blocks or not
|
||
*
|
||
* If set to `true`, headers inside blockquote, list, etc. would also be extracted.
|
||
*
|
||
* @default false
|
||
*/
|
||
shouldAllowNested?: boolean;
|
||
}
|
||
declare module '@mdit-vue/types' {
|
||
interface MarkdownItEnv {
|
||
/**
|
||
* The headers that extracted by `@mdit-vue/plugin-headers`
|
||
*/
|
||
headers?: MarkdownItHeader[];
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Options of @mdit-vue/plugin-sfc
|
||
*/
|
||
interface SfcPluginOptions {
|
||
/**
|
||
* Custom blocks to be extracted
|
||
*
|
||
* @default []
|
||
*/
|
||
customBlocks?: string[];
|
||
}
|
||
/**
|
||
* SFC block that extracted from markdown
|
||
*/
|
||
interface SfcBlock {
|
||
/**
|
||
* The type of the block
|
||
*/
|
||
type: string;
|
||
/**
|
||
* The content, including open-tag and close-tag
|
||
*/
|
||
content: string;
|
||
/**
|
||
* The content that stripped open-tag and close-tag off
|
||
*/
|
||
contentStripped: string;
|
||
/**
|
||
* The open-tag
|
||
*/
|
||
tagOpen: string;
|
||
/**
|
||
* The close-tag
|
||
*/
|
||
tagClose: string;
|
||
}
|
||
interface MarkdownSfcBlocks {
|
||
/**
|
||
* The `<template>` block
|
||
*/
|
||
template: SfcBlock | null;
|
||
/**
|
||
* The common `<script>` block
|
||
*/
|
||
script: SfcBlock | null;
|
||
/**
|
||
* The `<script setup>` block
|
||
*/
|
||
scriptSetup: SfcBlock | null;
|
||
/**
|
||
* All `<script>` blocks.
|
||
*
|
||
* By default, SFC only allows one `<script>` block and one `<script setup>` block.
|
||
* However, some tools may support different types of `<script>`s, so we keep all of them here.
|
||
*/
|
||
scripts: SfcBlock[];
|
||
/**
|
||
* All `<style>` blocks.
|
||
*/
|
||
styles: SfcBlock[];
|
||
/**
|
||
* All custom blocks.
|
||
*/
|
||
customBlocks: SfcBlock[];
|
||
}
|
||
declare module '@mdit-vue/types' {
|
||
interface MarkdownItEnv {
|
||
/**
|
||
* SFC blocks that extracted by `@mdit-vue/plugin-sfc`
|
||
*/
|
||
sfcBlocks?: MarkdownSfcBlocks;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Options of @mdit-vue/plugin-toc
|
||
*/
|
||
interface TocPluginOptions {
|
||
/**
|
||
* The pattern serving as the TOC placeholder in your markdown
|
||
*
|
||
* @default /^\[\[toc\]\]$/i
|
||
*/
|
||
pattern?: RegExp;
|
||
/**
|
||
* A custom slugification function
|
||
*
|
||
* Should use the same slugify function with markdown-it-anchor
|
||
* to ensure the link is matched
|
||
*/
|
||
slugify?: (str: string) => string;
|
||
/**
|
||
* A function for formatting headings
|
||
*/
|
||
format?: (str: string) => string;
|
||
/**
|
||
* Heading level that going to be included in the TOC
|
||
*
|
||
* Should be a subset of markdown-it-anchor's `level` option
|
||
* to ensure the link is existed
|
||
*
|
||
* @default [2,3]
|
||
*/
|
||
level?: number[];
|
||
/**
|
||
* Should allow headers inside nested blocks or not
|
||
*
|
||
* If set to `true`, headers inside blockquote, list, etc. would also be included.
|
||
*
|
||
* @default false
|
||
*/
|
||
shouldAllowNested?: boolean;
|
||
/**
|
||
* HTML tag of the TOC container
|
||
*
|
||
* @default 'nav'
|
||
*/
|
||
containerTag?: string;
|
||
/**
|
||
* The class for the TOC container
|
||
*
|
||
* @default 'table-of-contents'
|
||
*/
|
||
containerClass?: string;
|
||
/**
|
||
* HTML tag of the TOC list
|
||
*
|
||
* @default 'ul'
|
||
*/
|
||
listTag?: 'ul' | 'ol';
|
||
/**
|
||
* The class for the TOC list
|
||
*
|
||
* @default ''
|
||
*/
|
||
listClass?: string;
|
||
/**
|
||
* The class for the `<li>` tag
|
||
*
|
||
* @default ''
|
||
*/
|
||
itemClass?: string;
|
||
/**
|
||
* The tag of the link inside `<li>` tag
|
||
*
|
||
* @default 'a'
|
||
*/
|
||
linkTag?: 'a' | 'router-link';
|
||
/**
|
||
* The class for the link inside the `<li>` tag
|
||
*
|
||
* @default ''
|
||
*/
|
||
linkClass?: string;
|
||
}
|
||
|
||
declare namespace anchor {
|
||
export type RenderHref = (slug: string, state: StateCore) => string;
|
||
export type RenderAttrs = (slug: string, state: StateCore) => Record<string, string | number>;
|
||
|
||
export interface PermalinkOptions {
|
||
class?: string,
|
||
symbol?: string,
|
||
renderHref?: RenderHref,
|
||
renderAttrs?: RenderAttrs
|
||
}
|
||
|
||
export interface HeaderLinkPermalinkOptions extends PermalinkOptions {
|
||
safariReaderFix?: boolean;
|
||
}
|
||
|
||
export interface LinkAfterHeaderPermalinkOptions extends PermalinkOptions {
|
||
style?: 'visually-hidden' | 'aria-label' | 'aria-describedby' | 'aria-labelledby',
|
||
assistiveText?: (title: string) => string,
|
||
visuallyHiddenClass?: string,
|
||
space?: boolean | string,
|
||
placement?: 'before' | 'after'
|
||
wrapper?: [string, string] | null
|
||
}
|
||
|
||
export interface LinkInsideHeaderPermalinkOptions extends PermalinkOptions {
|
||
space?: boolean | string,
|
||
placement?: 'before' | 'after',
|
||
ariaHidden?: boolean
|
||
}
|
||
|
||
export interface AriaHiddenPermalinkOptions extends PermalinkOptions {
|
||
space?: boolean | string,
|
||
placement?: 'before' | 'after'
|
||
}
|
||
|
||
export type PermalinkGenerator = (slug: string, opts: PermalinkOptions, state: StateCore, index: number) => void;
|
||
|
||
export interface AnchorInfo {
|
||
slug: string;
|
||
title: string;
|
||
}
|
||
|
||
export interface AnchorOptions {
|
||
level?: number | number[];
|
||
|
||
slugify?(str: string): string;
|
||
getTokensText?(tokens: Token[]): string;
|
||
|
||
uniqueSlugStartIndex?: number;
|
||
permalink?: PermalinkGenerator;
|
||
|
||
callback?(token: Token, anchor_info: AnchorInfo): void;
|
||
|
||
tabIndex?: number | false;
|
||
}
|
||
|
||
export const permalink: {
|
||
headerLink: (opts?: HeaderLinkPermalinkOptions) => PermalinkGenerator
|
||
linkAfterHeader: (opts?: LinkAfterHeaderPermalinkOptions) => PermalinkGenerator
|
||
linkInsideHeader: (opts?: LinkInsideHeaderPermalinkOptions) => PermalinkGenerator
|
||
ariaHidden: (opts?: AriaHiddenPermalinkOptions) => PermalinkGenerator
|
||
};
|
||
}
|
||
|
||
declare function anchor(md: MarkdownIt, opts?: anchor.AnchorOptions): void;
|
||
|
||
type ThemeOptions = IThemeRegistration | {
|
||
light: IThemeRegistration;
|
||
dark: IThemeRegistration;
|
||
};
|
||
interface MarkdownOptions extends MarkdownIt.Options {
|
||
lineNumbers?: boolean;
|
||
preConfig?: (md: MarkdownIt) => void;
|
||
config?: (md: MarkdownIt) => void;
|
||
anchor?: anchor.AnchorOptions;
|
||
attrs?: {
|
||
leftDelimiter?: string;
|
||
rightDelimiter?: string;
|
||
allowedAttributes?: Array<string | RegExp>;
|
||
disable?: boolean;
|
||
};
|
||
defaultHighlightLang?: string;
|
||
frontmatter?: FrontmatterPluginOptions;
|
||
headers?: HeadersPluginOptions | boolean;
|
||
sfc?: SfcPluginOptions;
|
||
theme?: ThemeOptions;
|
||
languages?: ILanguageRegistration[];
|
||
toc?: TocPluginOptions;
|
||
externalLinks?: Record<string, string>;
|
||
cache?: boolean;
|
||
component?: ComponentPluginOptions;
|
||
math?: boolean | any;
|
||
}
|
||
type MarkdownRenderer = MarkdownIt;
|
||
declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, 'warn'>) => Promise<MarkdownRenderer>;
|
||
|
||
type RawConfigExports<ThemeConfig = any> = Awaitable<UserConfig<ThemeConfig>> | (() => Awaitable<UserConfig<ThemeConfig>>);
|
||
interface TransformContext {
|
||
page: string;
|
||
siteConfig: SiteConfig;
|
||
siteData: SiteData;
|
||
pageData: PageData;
|
||
title: string;
|
||
description: string;
|
||
head: HeadConfig[];
|
||
content: string;
|
||
assets: string[];
|
||
}
|
||
interface UserRouteConfig {
|
||
params: Record<string, string>;
|
||
content?: string;
|
||
}
|
||
type ResolvedRouteConfig = UserRouteConfig & {
|
||
/**
|
||
* the raw route (relative to src root), e.g. foo/[bar].md
|
||
*/
|
||
route: string;
|
||
/**
|
||
* the actual path with params resolved (relative to src root), e.g. foo/1.md
|
||
*/
|
||
path: string;
|
||
/**
|
||
* absolute fs path
|
||
*/
|
||
fullPath: string;
|
||
};
|
||
interface TransformPageContext {
|
||
siteConfig: SiteConfig;
|
||
}
|
||
interface UserConfig<ThemeConfig = any> extends LocaleSpecificConfig<ThemeConfig> {
|
||
extends?: RawConfigExports<ThemeConfig>;
|
||
base?: string;
|
||
srcDir?: string;
|
||
srcExclude?: string[];
|
||
outDir?: string;
|
||
assetsDir?: string;
|
||
cacheDir?: string;
|
||
shouldPreload?: (link: string, page: string) => boolean;
|
||
locales?: LocaleConfig<ThemeConfig>;
|
||
appearance?: boolean | 'dark' | 'force-dark' | (Omit<UseDarkOptions, 'initialValue'> & {
|
||
initialValue?: 'dark';
|
||
});
|
||
lastUpdated?: boolean;
|
||
contentProps?: Record<string, any>;
|
||
/**
|
||
* MarkdownIt options
|
||
*/
|
||
markdown?: MarkdownOptions;
|
||
/**
|
||
* Options to pass on to `@vitejs/plugin-vue`
|
||
*/
|
||
vue?: Options$1;
|
||
/**
|
||
* Vite config
|
||
*/
|
||
vite?: UserConfig$1 & {
|
||
configFile?: string | false;
|
||
};
|
||
/**
|
||
* Configure the scroll offset when the theme has a sticky header.
|
||
* Can be a number or a selector element to get the offset from.
|
||
* Can also be an array of selectors in case some elements will be
|
||
* invisible due to responsive layout. VitePress will fallback to the next
|
||
* selector if a selector fails to match, or the matched element is not
|
||
* currently visible in viewport.
|
||
*/
|
||
scrollOffset?: number | string | string[] | {
|
||
selector: string | string[];
|
||
padding: number;
|
||
};
|
||
/**
|
||
* Enable MPA / zero-JS mode.
|
||
* @experimental
|
||
*/
|
||
mpa?: boolean;
|
||
/**
|
||
* Extracts metadata to a separate chunk.
|
||
* @experimental
|
||
*/
|
||
metaChunk?: boolean;
|
||
/**
|
||
* Don't fail builds due to dead links.
|
||
*
|
||
* @default false
|
||
*/
|
||
ignoreDeadLinks?: boolean | 'localhostLinks' | (string | RegExp | ((link: string) => boolean))[];
|
||
/**
|
||
* Don't force `.html` on URLs.
|
||
*
|
||
* @default false
|
||
*/
|
||
cleanUrls?: boolean;
|
||
/**
|
||
* Use web fonts instead of emitting font files to dist.
|
||
* The used theme should import a file named `fonts.(s)css` for this to work.
|
||
* If you are a theme author, to support this, place your web font import
|
||
* between `webfont-marker-begin` and `webfont-marker-end` comments.
|
||
*
|
||
* @default true in webcontainers, else false
|
||
*/
|
||
useWebFonts?: boolean;
|
||
/**
|
||
* @experimental
|
||
*
|
||
* source -> destination
|
||
*/
|
||
rewrites?: Record<string, string>;
|
||
/**
|
||
* @experimental
|
||
*/
|
||
sitemap?: SitemapStreamOptions & {
|
||
hostname: string;
|
||
transformItems?: (items: SitemapItem[]) => Awaitable<SitemapItem[]>;
|
||
};
|
||
/**
|
||
* Build end hook: called when SSG finish.
|
||
* @param siteConfig The resolved configuration.
|
||
*/
|
||
buildEnd?: (siteConfig: SiteConfig) => Awaitable<void>;
|
||
/**
|
||
* Render end hook: called when SSR rendering is done.
|
||
*/
|
||
postRender?: (context: SSGContext) => Awaitable<SSGContext | void>;
|
||
/**
|
||
* Head transform hook: runs before writing HTML to dist.
|
||
*
|
||
* This build hook will allow you to modify the head adding new entries that cannot be statically added.
|
||
*/
|
||
transformHead?: (context: TransformContext) => Awaitable<HeadConfig[] | void>;
|
||
/**
|
||
* HTML transform hook: runs before writing HTML to dist.
|
||
*/
|
||
transformHtml?: (code: string, id: string, ctx: TransformContext) => Awaitable<string | void>;
|
||
/**
|
||
* PageData transform hook: runs when rendering markdown to vue
|
||
*/
|
||
transformPageData?: (pageData: PageData, ctx: TransformPageContext) => Awaitable<Partial<PageData> | {
|
||
[key: string]: any;
|
||
} | void>;
|
||
}
|
||
interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'metaChunk' | 'lastUpdated' | 'ignoreDeadLinks' | 'cleanUrls' | 'useWebFonts' | 'postRender' | 'buildEnd' | 'transformHead' | 'transformHtml' | 'transformPageData' | 'sitemap'> {
|
||
root: string;
|
||
srcDir: string;
|
||
site: SiteData<ThemeConfig>;
|
||
configPath: string | undefined;
|
||
configDeps: string[];
|
||
themeDir: string;
|
||
outDir: string;
|
||
assetsDir: string;
|
||
cacheDir: string;
|
||
tempDir: string;
|
||
pages: string[];
|
||
dynamicRoutes: {
|
||
routes: ResolvedRouteConfig[];
|
||
fileToModulesMap: Record<string, Set<string>>;
|
||
};
|
||
rewrites: {
|
||
map: Record<string, string | undefined>;
|
||
inv: Record<string, string | undefined>;
|
||
};
|
||
logger: Logger;
|
||
userConfig: UserConfig;
|
||
}
|
||
|
||
declare function resolvePages(srcDir: string, userConfig: UserConfig): Promise<{
|
||
pages: string[];
|
||
dynamicRoutes: {
|
||
routes: ResolvedRouteConfig[];
|
||
fileToModulesMap: Record<string, Set<string>>;
|
||
};
|
||
rewrites: {
|
||
map: Record<string, string>;
|
||
inv: Record<string, string>;
|
||
};
|
||
}>;
|
||
|
||
type UserConfigFn<ThemeConfig> = (env: ConfigEnv) => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>;
|
||
type UserConfigExport<ThemeConfig> = UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>> | UserConfigFn<ThemeConfig>;
|
||
/**
|
||
* Type config helper
|
||
*/
|
||
declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
||
/**
|
||
* Type config helper for custom theme config
|
||
*/
|
||
declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
|
||
declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
||
declare function resolveUserConfig(root: string, command: 'serve' | 'build', mode: string): Promise<[UserConfig, string | undefined, string[]]>;
|
||
declare function resolveSiteData(root: string, userConfig?: UserConfig, command?: 'serve' | 'build', mode?: string): Promise<SiteData>;
|
||
|
||
interface ContentOptions<T = ContentData[]> {
|
||
/**
|
||
* Include src?
|
||
* @default false
|
||
*/
|
||
includeSrc?: boolean;
|
||
/**
|
||
* Render src to HTML and include in data?
|
||
* @default false
|
||
*/
|
||
render?: boolean;
|
||
/**
|
||
* If `boolean`, whether to parse and include excerpt? (rendered as HTML)
|
||
*
|
||
* If `function`, control how the excerpt is extracted from the content.
|
||
*
|
||
* If `string`, define a custom separator to be used for extracting the
|
||
* excerpt. Default separator is `---` if `excerpt` is `true`.
|
||
*
|
||
* @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt
|
||
* @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt_separator
|
||
*
|
||
* @default false
|
||
*/
|
||
excerpt?: boolean | ((file: {
|
||
data: {
|
||
[key: string]: any;
|
||
};
|
||
content: string;
|
||
excerpt?: string;
|
||
}, options?: any) => void) | string;
|
||
/**
|
||
* Transform the data. Note the data will be inlined as JSON in the client
|
||
* bundle if imported from components or markdown files.
|
||
*/
|
||
transform?: (data: ContentData[]) => T | Promise<T>;
|
||
/**
|
||
* Options to pass to `fast-glob`.
|
||
* You'll need to manually specify `node_modules` and `dist` in
|
||
* `globOptions.ignore` if you've overridden it.
|
||
*/
|
||
globOptions?: glob.Options;
|
||
}
|
||
interface ContentData {
|
||
url: string;
|
||
src: string | undefined;
|
||
html: string | undefined;
|
||
frontmatter: Record<string, any>;
|
||
excerpt: string | undefined;
|
||
}
|
||
/**
|
||
* Create a loader object that can be directly used as the default export
|
||
* of a data loader file.
|
||
*/
|
||
declare function createContentLoader<T = ContentData[]>(
|
||
/**
|
||
* files to glob / watch - relative to <project root>
|
||
*/
|
||
pattern: string | string[], { includeSrc, render, excerpt: renderExcerpt, transform, globOptions }?: ContentOptions<T>): {
|
||
watch: string | string[];
|
||
load: () => Promise<T>;
|
||
};
|
||
|
||
declare enum ScaffoldThemeType {
|
||
Default = "default theme",
|
||
DefaultCustom = "default theme + customization",
|
||
Custom = "custom theme"
|
||
}
|
||
interface ScaffoldOptions {
|
||
root: string;
|
||
title?: string;
|
||
description?: string;
|
||
theme: ScaffoldThemeType;
|
||
useTs: boolean;
|
||
injectNpmScripts: boolean;
|
||
}
|
||
declare function init(): Promise<void>;
|
||
declare function scaffold({ root, title, description, theme, useTs, injectNpmScripts }: ScaffoldOptions): string;
|
||
|
||
interface LoaderModule {
|
||
watch?: string[] | string;
|
||
load: (watchedFiles: string[]) => any;
|
||
}
|
||
/**
|
||
* Helper for defining loaders with type inference
|
||
*/
|
||
declare function defineLoader(loader: LoaderModule): LoaderModule;
|
||
|
||
// Type definitions for postcss-prefix-selector 1.16
|
||
// Project: https://github.com/RadValentin/postcss-prefix-selector
|
||
// Definitions by: robertmaier <https://github.com/robertmaier>
|
||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/types/postcss-prefix-selector
|
||
|
||
|
||
interface Options {
|
||
prefix?: string | undefined;
|
||
exclude?: ReadonlyArray<string | RegExp> | undefined;
|
||
ignoreFiles?: ReadonlyArray<string | RegExp> | undefined;
|
||
includeFiles?: ReadonlyArray<string | RegExp> | undefined;
|
||
transform?:
|
||
| ((
|
||
prefix: Readonly<string>,
|
||
selector: Readonly<string>,
|
||
prefixedSelector: Readonly<string>,
|
||
file: Readonly<string>,
|
||
) => string)
|
||
| undefined;
|
||
}
|
||
|
||
declare function postcssPrefixSelector(options: Readonly<Options>): (root: Root) => void;
|
||
|
||
declare function postcssIsolateStyles(options?: Parameters<typeof postcssPrefixSelector>[0]): ReturnType<typeof postcssPrefixSelector>;
|
||
|
||
interface ParsedURL {
|
||
pathname: string;
|
||
search: string;
|
||
query: Record<string, string | string[]> | void;
|
||
raw: string;
|
||
}
|
||
|
||
// Thank you: @fwilkerson, @stahlstift
|
||
// ---
|
||
|
||
/** @type {import('http').METHODS} */
|
||
type Methods = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' |'M-SEARCH' | 'MERGE' | 'MKACTIVITY' |'MKCALENDAR' | 'MKCOL' | 'MOVE' |'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PRI' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE';
|
||
|
||
type Pattern = RegExp | string;
|
||
|
||
declare class Trouter<T = Function> {
|
||
find(method: Methods, url: string): {
|
||
params: Record<string, string>;
|
||
handlers: T[];
|
||
};
|
||
add(method: Methods, pattern: Pattern, ...handlers: T[]): this;
|
||
use(pattern: Pattern, ...handlers: T[]): this;
|
||
all(pattern: Pattern, ...handlers: T[]): this;
|
||
get(pattern: Pattern, ...handlers: T[]): this;
|
||
head(pattern: Pattern, ...handlers: T[]): this;
|
||
patch(pattern: Pattern, ...handlers: T[]): this;
|
||
options(pattern: Pattern, ...handlers: T[]): this;
|
||
connect(pattern: Pattern, ...handlers: T[]): this;
|
||
delete(pattern: Pattern, ...handlers: T[]): this;
|
||
trace(pattern: Pattern, ...handlers: T[]): this;
|
||
post(pattern: Pattern, ...handlers: T[]): this;
|
||
put(pattern: Pattern, ...handlers: T[]): this;
|
||
}
|
||
|
||
type Promisable<T> = Promise<T> | T;
|
||
type ListenCallback = () => Promisable<void>;
|
||
|
||
interface IError extends Error {
|
||
code?: number;
|
||
status?: number;
|
||
details?: any;
|
||
}
|
||
|
||
type NextHandler = (err?: string | IError) => Promisable<void>;
|
||
type ErrorHandler<T extends Request = Request> = (err: string | IError, req: T, res: Response, next: NextHandler) => Promisable<void>;
|
||
type Middleware<T extends IncomingMessage = Request> = (req: T & Request, res: Response, next: NextHandler) => Promisable<void>;
|
||
|
||
type Response = ServerResponse;
|
||
|
||
interface Request extends IncomingMessage {
|
||
url: string;
|
||
method: string;
|
||
originalUrl: string;
|
||
params: Record<string, string>;
|
||
path: string;
|
||
search: string;
|
||
query: Record<string,string>;
|
||
body?: any;
|
||
_decoded?: true;
|
||
_parsedUrl: ParsedURL;
|
||
}
|
||
|
||
interface Polka<T extends Request = Request> extends Trouter<Middleware<T>> {
|
||
readonly server: Server;
|
||
readonly wares: Middleware<T>[];
|
||
|
||
readonly onError: ErrorHandler<T>;
|
||
readonly onNoMatch: Middleware<T>;
|
||
|
||
readonly handler: Middleware<T>;
|
||
parse: (req: IncomingMessage) => ParsedURL;
|
||
|
||
use(pattern: RegExp|string, ...handlers: (Polka<T> | Middleware<T>)[]): this;
|
||
use(...handlers: (Polka<T> | Middleware<T>)[]): this;
|
||
|
||
listen(port?: number, hostname?: string, backlog?: number, callback?: ListenCallback): this;
|
||
listen(port?: number, hostname?: string, callback?: ListenCallback): this;
|
||
listen(port?: number, backlog?: number, callback?: ListenCallback): this;
|
||
listen(port?: number, callback?: ListenCallback): this;
|
||
listen(path: string, backlog?: number, callback?: ListenCallback): this;
|
||
listen(path: string, callback?: ListenCallback): this;
|
||
listen(options: ListenOptions, callback?: ListenCallback): this;
|
||
listen(handle: any, backlog?: number, callback?: ListenCallback): this;
|
||
listen(handle: any, callback?: ListenCallback): this;
|
||
}
|
||
|
||
interface ServeOptions {
|
||
base?: string;
|
||
root?: string;
|
||
port?: number;
|
||
}
|
||
declare function serve(options?: ServeOptions): Promise<Polka<Request>>;
|
||
|
||
declare function createServer(root?: string, serverOptions?: ServerOptions & {
|
||
base?: string;
|
||
}, recreateServer?: () => Promise<void>): Promise<vite.ViteDevServer>;
|
||
|
||
export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, init, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
|