| |
| import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, InputOption, ModuleFormat, WatcherOptions, RollupOutput, RollupWatcher, PluginContext, InputOptions, CustomPluginOptions, LoadResult, SourceDescription, PluginContextMeta, RollupLog, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, TransformPluginContext, ExistingRawSourceMap, SourceMapInput, GetManualChunk } from 'rollup'; |
| import * as rollup from 'rollup'; |
| export { rollup as Rollup }; |
| export { parseAst, parseAstAsync } from 'rollup/parseAst'; |
| import * as http from 'node:http'; |
| import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http'; |
| import { Http2SecureServer } from 'node:http2'; |
| import * as fs from 'node:fs'; |
| import * as events from 'node:events'; |
| import { EventEmitter } from 'node:events'; |
| import { ServerOptions as HttpsServerOptions, Server as HttpsServer } from 'node:https'; |
| import * as net from 'node:net'; |
| import * as url from 'node:url'; |
| import { URL } from 'node:url'; |
| import * as stream from 'node:stream'; |
| import { Duplex, DuplexOptions } from 'node:stream'; |
| import { FetchFunctionOptions, FetchResult, ModuleRunnerOptions, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner'; |
| export { FetchFunction, FetchResult } from 'vite/module-runner'; |
| import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild'; |
| export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild'; |
| import { HotPayload, CustomPayload } from '../../types/hmrPayload.js'; |
| export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hmrPayload.js'; |
| import { InferCustomEventPayload } from '../../types/customEvent.js'; |
| export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js'; |
| import { SecureContextOptions } from 'node:tls'; |
| import { ZlibOptions } from 'node:zlib'; |
| import * as PostCSS from 'postcss'; |
| import { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js'; |
| export { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js'; |
| import { SassLegacyPreprocessBaseOptions, SassModernPreprocessBaseOptions, LessPreprocessorBaseOptions, StylusPreprocessorBaseOptions } from '../../types/internal/cssPreprocessorOptions.js'; |
| import { M as ModuleRunnerTransport } from './moduleRunnerTransport.d-DJ_mE5sf.js'; |
| export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js'; |
| export { ChunkMetadata, CustomPluginOptionsVite } from '../../types/metadata.js'; |
|
|
| interface Alias { |
| find: string | RegExp |
| replacement: string |
| |
| |
| |
| |
| |
| customResolver?: ResolverFunction | ResolverObject | null |
| } |
|
|
| type MapToFunction<T> = T extends Function ? T : never |
|
|
| type ResolverFunction = MapToFunction<PluginHooks['resolveId']> |
|
|
| interface ResolverObject { |
| buildStart?: PluginHooks['buildStart'] |
| resolveId: ResolverFunction |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| type AliasOptions = readonly Alias[] | { [find: string]: string } |
|
|
| type AnymatchFn = (testString: string) => boolean |
| type AnymatchPattern = string | RegExp | AnymatchFn |
| type AnymatchMatcher = AnymatchPattern | AnymatchPattern[] |
|
|
| |
|
|
| declare class FSWatcher extends EventEmitter implements fs.FSWatcher { |
| options: WatchOptions |
|
|
| |
| |
| |
| constructor(options?: WatchOptions) |
|
|
| |
| |
| |
| |
| ref(): this |
|
|
| |
| |
| |
| |
| |
| unref(): this |
|
|
| |
| |
| |
| |
| add(paths: string | ReadonlyArray<string>): this |
|
|
| |
| |
| |
| |
| unwatch(paths: string | ReadonlyArray<string>): this |
|
|
| |
| |
| |
| |
| |
| |
| getWatched(): { |
| [directory: string]: string[] |
| } |
|
|
| |
| |
| |
| close(): Promise<void> |
|
|
| on( |
| event: 'add' | 'addDir' | 'change', |
| listener: (path: string, stats?: fs.Stats) => void, |
| ): this |
|
|
| on( |
| event: 'all', |
| listener: ( |
| eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', |
| path: string, |
| stats?: fs.Stats, |
| ) => void, |
| ): this |
|
|
| |
| |
| |
| on(event: 'error', listener: (error: Error) => void): this |
|
|
| |
| |
| |
| on( |
| event: 'raw', |
| listener: (eventName: string, path: string, details: any) => void, |
| ): this |
|
|
| |
| |
| |
| on(event: 'ready', listener: () => void): this |
|
|
| on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this |
|
|
| on(event: string, listener: (...args: any[]) => void): this |
| } |
|
|
| interface WatchOptions { |
| |
| |
| |
| |
| |
| persistent?: boolean |
|
|
| |
| |
| |
| |
| |
| |
| |
| ignored?: AnymatchMatcher |
|
|
| |
| |
| |
| |
| ignoreInitial?: boolean |
|
|
| |
| |
| |
| |
| followSymlinks?: boolean |
|
|
| |
| |
| |
| |
| cwd?: string |
|
|
| |
| |
| |
| |
| |
| |
| disableGlobbing?: boolean |
|
|
| |
| |
| |
| |
| |
| |
| |
| usePolling?: boolean |
|
|
| |
| |
| |
| |
| |
| useFsEvents?: boolean |
|
|
| |
| |
| |
| |
| |
| alwaysStat?: boolean |
|
|
| |
| |
| |
| depth?: number |
|
|
| |
| |
| |
| interval?: number |
|
|
| |
| |
| |
| |
| binaryInterval?: number |
|
|
| |
| |
| |
| |
| |
| ignorePermissionErrors?: boolean |
|
|
| |
| |
| |
| |
| |
| |
| |
| atomic?: boolean | number |
|
|
| |
| |
| |
| awaitWriteFinish?: AwaitWriteFinishOptions | boolean |
| } |
|
|
| interface AwaitWriteFinishOptions { |
| |
| |
| |
| stabilityThreshold?: number |
|
|
| |
| |
| |
| pollInterval?: number |
| } |
|
|
| |
| |
|
|
| declare namespace Connect { |
| export type ServerHandle = HandleFunction | http.Server |
|
|
| export class IncomingMessage extends http.IncomingMessage { |
| originalUrl?: http.IncomingMessage['url'] | undefined |
| } |
|
|
| export type NextFunction = (err?: any) => void |
|
|
| export type SimpleHandleFunction = ( |
| req: IncomingMessage, |
| res: http.ServerResponse, |
| ) => void |
| export type NextHandleFunction = ( |
| req: IncomingMessage, |
| res: http.ServerResponse, |
| next: NextFunction, |
| ) => void |
| export type ErrorHandleFunction = ( |
| err: any, |
| req: IncomingMessage, |
| res: http.ServerResponse, |
| next: NextFunction, |
| ) => void |
| export type HandleFunction = |
| | SimpleHandleFunction |
| | NextHandleFunction |
| | ErrorHandleFunction |
|
|
| export interface ServerStackItem { |
| route: string |
| handle: ServerHandle |
| } |
|
|
| export interface Server extends NodeJS.EventEmitter { |
| (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void |
|
|
| route: string |
| stack: ServerStackItem[] |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| use(fn: NextHandleFunction): Server |
| use(fn: HandleFunction): Server |
| use(route: string, fn: NextHandleFunction): Server |
| use(route: string, fn: HandleFunction): Server |
|
|
| |
| |
| |
| |
| handle( |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| next: Function, |
| ): void |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| listen( |
| port: number, |
| hostname?: string, |
| backlog?: number, |
| callback?: Function, |
| ): http.Server |
| listen(port: number, hostname?: string, callback?: Function): http.Server |
| listen(path: string, callback?: Function): http.Server |
| listen(handle: any, listeningListener?: Function): http.Server |
| } |
| } |
|
|
| |
| |
|
|
| declare namespace HttpProxy { |
| export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed |
|
|
| export type ProxyTargetUrl = string | Partial<url.Url> |
|
|
| export interface ProxyTargetDetailed { |
| host: string |
| port: number |
| protocol?: string | undefined |
| hostname?: string | undefined |
| socketPath?: string | undefined |
| key?: string | undefined |
| passphrase?: string | undefined |
| pfx?: Buffer | string | undefined |
| cert?: string | undefined |
| ca?: string | undefined |
| ciphers?: string | undefined |
| secureProtocol?: string | undefined |
| } |
|
|
| export type ErrorCallback = ( |
| err: Error, |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| target?: ProxyTargetUrl, |
| ) => void |
|
|
| export class Server extends events.EventEmitter { |
| |
| |
| |
| |
| constructor(options?: ServerOptions) |
|
|
| |
| |
| |
| |
| |
| |
| |
| web( |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| options?: ServerOptions, |
| callback?: ErrorCallback, |
| ): void |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| ws( |
| req: http.IncomingMessage, |
| socket: unknown, |
| head: unknown, |
| options?: ServerOptions, |
| callback?: ErrorCallback, |
| ): void |
|
|
| |
| |
| |
| |
| listen(port: number): Server |
|
|
| |
| |
| |
| close(callback?: () => void): void |
|
|
| |
| |
| |
| |
| |
| static createProxyServer(options?: ServerOptions): Server |
|
|
| |
| |
| |
| |
| |
| static createServer(options?: ServerOptions): Server |
|
|
| |
| |
| |
| |
| |
| static createProxy(options?: ServerOptions): Server |
|
|
| addListener(event: string, listener: () => void): this |
| on(event: string, listener: () => void): this |
| on(event: 'error', listener: ErrorCallback): this |
| on( |
| event: 'start', |
| listener: ( |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| target: ProxyTargetUrl, |
| ) => void, |
| ): this |
| on( |
| event: 'proxyReq', |
| listener: ( |
| proxyReq: http.ClientRequest, |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| options: ServerOptions, |
| ) => void, |
| ): this |
| on( |
| event: 'proxyRes', |
| listener: ( |
| proxyRes: http.IncomingMessage, |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| ) => void, |
| ): this |
| on( |
| event: 'proxyReqWs', |
| listener: ( |
| proxyReq: http.ClientRequest, |
| req: http.IncomingMessage, |
| socket: net.Socket, |
| options: ServerOptions, |
| head: any, |
| ) => void, |
| ): this |
| on( |
| event: 'econnreset', |
| listener: ( |
| err: Error, |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| target: ProxyTargetUrl, |
| ) => void, |
| ): this |
| on( |
| event: 'end', |
| listener: ( |
| req: http.IncomingMessage, |
| res: http.ServerResponse, |
| proxyRes: http.IncomingMessage, |
| ) => void, |
| ): this |
| on( |
| event: 'close', |
| listener: ( |
| proxyRes: http.IncomingMessage, |
| proxySocket: net.Socket, |
| proxyHead: any, |
| ) => void, |
| ): this |
|
|
| once(event: string, listener: () => void): this |
| removeListener(event: string, listener: () => void): this |
| removeAllListeners(event?: string): this |
| getMaxListeners(): number |
| setMaxListeners(n: number): this |
| listeners(event: string): Array<() => void> |
| emit(event: string, ...args: any[]): boolean |
| listenerCount(type: string): number |
| } |
|
|
| export interface ServerOptions { |
| |
| target?: ProxyTarget | undefined |
| |
| forward?: ProxyTargetUrl | undefined |
| |
| agent?: any |
| |
| ssl?: any |
| |
| ws?: boolean | undefined |
| |
| xfwd?: boolean | undefined |
| |
| secure?: boolean | undefined |
| |
| toProxy?: boolean | undefined |
| |
| prependPath?: boolean | undefined |
| |
| ignorePath?: boolean | undefined |
| |
| localAddress?: string | undefined |
| |
| changeOrigin?: boolean | undefined |
| |
| preserveHeaderKeyCase?: boolean | undefined |
| |
| auth?: string | undefined |
| |
| hostRewrite?: string | undefined |
| |
| autoRewrite?: boolean | undefined |
| |
| protocolRewrite?: string | undefined |
| |
| cookieDomainRewrite?: |
| | false |
| | string |
| | { [oldDomain: string]: string } |
| | undefined |
| |
| cookiePathRewrite?: |
| | false |
| | string |
| | { [oldPath: string]: string } |
| | undefined |
| |
| headers?: { [header: string]: string } | undefined |
| |
| proxyTimeout?: number | undefined |
| |
| timeout?: number | undefined |
| |
| followRedirects?: boolean | undefined |
| |
| selfHandleResponse?: boolean | undefined |
| |
| buffer?: stream.Stream | undefined |
| } |
| } |
|
|
| interface ProxyOptions extends HttpProxy.ServerOptions { |
| |
| |
| |
| rewrite?: (path: string) => string; |
| |
| |
| |
| configure?: (proxy: HttpProxy.Server, options: ProxyOptions) => void; |
| |
| |
| |
| bypass?: (req: http.IncomingMessage, |
| |
| res: http.ServerResponse | undefined, options: ProxyOptions) => void | null | undefined | false | string | Promise<void | null | undefined | boolean | string>; |
| |
| |
| |
| |
| |
| rewriteWsOrigin?: boolean | undefined; |
| } |
|
|
| type LogType = 'error' | 'warn' | 'info'; |
| type LogLevel = LogType | 'silent'; |
| interface Logger { |
| info(msg: string, options?: LogOptions): void; |
| warn(msg: string, options?: LogOptions): void; |
| warnOnce(msg: string, options?: LogOptions): void; |
| error(msg: string, options?: LogErrorOptions): void; |
| clearScreen(type: LogType): void; |
| hasErrorLogged(error: Error | RollupError): boolean; |
| hasWarned: boolean; |
| } |
| interface LogOptions { |
| clear?: boolean; |
| timestamp?: boolean; |
| environment?: string; |
| } |
| interface LogErrorOptions extends LogOptions { |
| error?: Error | RollupError | null; |
| } |
| interface LoggerOptions { |
| prefix?: string; |
| allowClearScreen?: boolean; |
| customLogger?: Logger; |
| console?: Console; |
| } |
| declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger; |
|
|
| interface CommonServerOptions { |
| |
| |
| |
| |
| |
| port?: number; |
| |
| |
| |
| strictPort?: boolean; |
| |
| |
| |
| |
| host?: string | boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| allowedHosts?: string[] | true; |
| |
| |
| |
| |
| https?: HttpsServerOptions; |
| |
| |
| |
| open?: boolean | string; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proxy?: Record<string, string | ProxyOptions>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| cors?: CorsOptions | boolean; |
| |
| |
| |
| headers?: OutgoingHttpHeaders; |
| } |
| |
| |
| |
| interface CorsOptions { |
| |
| |
| |
| |
| |
| |
| origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void); |
| methods?: string | string[]; |
| allowedHeaders?: string | string[]; |
| exposedHeaders?: string | string[]; |
| credentials?: boolean; |
| maxAge?: number; |
| preflightContinue?: boolean; |
| optionsSuccessStatus?: number; |
| } |
| type CorsOrigin = boolean | string | RegExp | (string | RegExp)[]; |
|
|
| type RequiredExceptFor<T, K extends keyof T> = Pick<T, K> & Required<Omit<T, K>>; |
|
|
| interface PreviewOptions extends CommonServerOptions { |
| } |
| interface ResolvedPreviewOptions extends RequiredExceptFor<PreviewOptions, 'host' | 'https' | 'proxy'> { |
| } |
| interface PreviewServer { |
| |
| |
| |
| config: ResolvedConfig; |
| |
| |
| |
| close(): Promise<void>; |
| |
| |
| |
| |
| |
| |
| |
| |
| middlewares: Connect.Server; |
| |
| |
| |
| httpServer: HttpServer; |
| |
| |
| |
| |
| resolvedUrls: ResolvedServerUrls | null; |
| |
| |
| |
| printUrls(): void; |
| |
| |
| |
| bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void; |
| } |
| type PreviewServerHook = (this: void, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>; |
| |
| |
| |
| declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>; |
|
|
| type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = { |
| |
| |
| |
| print?: boolean; |
| |
| |
| |
| |
| |
| customShortcuts?: CLIShortcut<Server>[]; |
| }; |
| type CLIShortcut<Server = ViteDevServer | PreviewServer> = { |
| key: string; |
| description: string; |
| action?(server: Server): void | Promise<void>; |
| }; |
|
|
| declare class PartialEnvironment { |
| name: string; |
| getTopLevelConfig(): ResolvedConfig; |
| config: ResolvedConfig & ResolvedEnvironmentOptions; |
| |
| |
| |
| get options(): ResolvedEnvironmentOptions; |
| logger: Logger; |
| constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions); |
| } |
| declare class BaseEnvironment extends PartialEnvironment { |
| get plugins(): Plugin[]; |
| constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| declare class UnknownEnvironment extends BaseEnvironment { |
| mode: "unknown"; |
| } |
|
|
| declare class ScanEnvironment extends BaseEnvironment { |
| mode: "scan"; |
| get pluginContainer(): EnvironmentPluginContainer; |
| init(): Promise<void>; |
| } |
|
|
| type ExportsData = { |
| hasModuleSyntax: boolean; |
| exports: readonly string[]; |
| jsxLoader?: boolean; |
| }; |
| interface DepsOptimizer { |
| init: () => Promise<void>; |
| metadata: DepOptimizationMetadata; |
| scanProcessing?: Promise<void>; |
| registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo; |
| run: () => void; |
| isOptimizedDepFile: (id: string) => boolean; |
| isOptimizedDepUrl: (url: string) => boolean; |
| getOptimizedDepId: (depInfo: OptimizedDepInfo) => string; |
| close: () => Promise<void>; |
| options: DepOptimizationOptions; |
| } |
| interface DepOptimizationConfig { |
| |
| |
| |
| |
| include?: string[]; |
| |
| |
| |
| |
| exclude?: string[]; |
| |
| |
| |
| |
| |
| needsInterop?: string[]; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| extensions?: string[]; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| disabled?: boolean | 'build' | 'dev'; |
| |
| |
| |
| |
| |
| |
| |
| noDiscovery?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| holdUntilCrawlEnd?: boolean; |
| } |
| type DepOptimizationOptions = DepOptimizationConfig & { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| entries?: string | string[]; |
| |
| |
| |
| |
| force?: boolean; |
| }; |
| interface OptimizedDepInfo { |
| id: string; |
| file: string; |
| src?: string; |
| needsInterop?: boolean; |
| browserHash?: string; |
| fileHash?: string; |
| |
| |
| |
| |
| processing?: Promise<void>; |
| |
| |
| |
| |
| exportsData?: Promise<ExportsData>; |
| } |
| interface DepOptimizationMetadata { |
| |
| |
| |
| |
| hash: string; |
| |
| |
| |
| |
| lockfileHash: string; |
| |
| |
| |
| |
| configHash: string; |
| |
| |
| |
| |
| |
| browserHash: string; |
| |
| |
| |
| optimized: Record<string, OptimizedDepInfo>; |
| |
| |
| |
| chunks: Record<string, OptimizedDepInfo>; |
| |
| |
| |
| discovered: Record<string, OptimizedDepInfo>; |
| |
| |
| |
| depInfoList: OptimizedDepInfo[]; |
| } |
| |
| |
| |
| |
| |
| |
| declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>; |
|
|
| interface TransformResult { |
| code: string; |
| map: SourceMap | { |
| mappings: ''; |
| } | null; |
| ssr?: boolean; |
| etag?: string; |
| deps?: string[]; |
| dynamicDeps?: string[]; |
| } |
| interface TransformOptions { |
| |
| |
| |
| ssr?: boolean; |
| } |
|
|
| declare class EnvironmentModuleNode { |
| environment: string; |
| |
| |
| |
| url: string; |
| |
| |
| |
| id: string | null; |
| file: string | null; |
| type: 'js' | 'css'; |
| info?: ModuleInfo; |
| meta?: Record<string, any>; |
| importers: Set<EnvironmentModuleNode>; |
| importedModules: Set<EnvironmentModuleNode>; |
| acceptedHmrDeps: Set<EnvironmentModuleNode>; |
| acceptedHmrExports: Set<string> | null; |
| importedBindings: Map<string, Set<string>> | null; |
| isSelfAccepting?: boolean; |
| transformResult: TransformResult | null; |
| ssrModule: Record<string, any> | null; |
| ssrError: Error | null; |
| lastHMRTimestamp: number; |
| lastInvalidationTimestamp: number; |
| |
| |
| |
| constructor(url: string, environment: string, setIsSelfAccepting?: boolean); |
| } |
| type ResolvedUrl = [ |
| url: string, |
| resolvedId: string, |
| meta: object | null | undefined |
| ]; |
| declare class EnvironmentModuleGraph { |
| environment: string; |
| urlToModuleMap: Map<string, EnvironmentModuleNode>; |
| idToModuleMap: Map<string, EnvironmentModuleNode>; |
| etagToModuleMap: Map<string, EnvironmentModuleNode>; |
| fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>; |
| constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>); |
| getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>; |
| getModuleById(id: string): EnvironmentModuleNode | undefined; |
| getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined; |
| onFileChange(file: string): void; |
| onFileDelete(file: string): void; |
| invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean, |
| ): void; |
| invalidateAll(): void; |
| |
| |
| |
| |
| |
| |
| |
| |
| updateModuleInfo(mod: EnvironmentModuleNode, importedModules: Set<string | EnvironmentModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | EnvironmentModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, |
| ): Promise<Set<EnvironmentModuleNode> | undefined>; |
| ensureEntryFromUrl(rawUrl: string, setIsSelfAccepting?: boolean): Promise<EnvironmentModuleNode>; |
| createFileOnlyEntry(file: string): EnvironmentModuleNode; |
| resolveUrl(url: string): Promise<ResolvedUrl>; |
| updateModuleTransformResult(mod: EnvironmentModuleNode, result: TransformResult | null): void; |
| getModuleByEtag(etag: string): EnvironmentModuleNode | undefined; |
| } |
|
|
| declare class ModuleNode { |
| _moduleGraph: ModuleGraph; |
| _clientModule: EnvironmentModuleNode | undefined; |
| _ssrModule: EnvironmentModuleNode | undefined; |
| constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode); |
| _get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T]; |
| _set<T extends keyof EnvironmentModuleNode>(prop: T, value: EnvironmentModuleNode[T]): void; |
| _wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>; |
| _getModuleSetUnion(prop: 'importedModules' | 'importers'): Set<ModuleNode>; |
| _getModuleInfoUnion(prop: 'info'): ModuleInfo | undefined; |
| _getModuleObjectUnion(prop: 'meta'): Record<string, any> | undefined; |
| get url(): string; |
| set url(value: string); |
| get id(): string | null; |
| set id(value: string | null); |
| get file(): string | null; |
| set file(value: string | null); |
| get type(): 'js' | 'css'; |
| get info(): ModuleInfo | undefined; |
| get meta(): Record<string, any> | undefined; |
| get importers(): Set<ModuleNode>; |
| get clientImportedModules(): Set<ModuleNode>; |
| get ssrImportedModules(): Set<ModuleNode>; |
| get importedModules(): Set<ModuleNode>; |
| get acceptedHmrDeps(): Set<ModuleNode>; |
| get acceptedHmrExports(): Set<string> | null; |
| get importedBindings(): Map<string, Set<string>> | null; |
| get isSelfAccepting(): boolean | undefined; |
| get transformResult(): TransformResult | null; |
| set transformResult(value: TransformResult | null); |
| get ssrTransformResult(): TransformResult | null; |
| set ssrTransformResult(value: TransformResult | null); |
| get ssrModule(): Record<string, any> | null; |
| get ssrError(): Error | null; |
| get lastHMRTimestamp(): number; |
| set lastHMRTimestamp(value: number); |
| get lastInvalidationTimestamp(): number; |
| get invalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined; |
| get ssrInvalidationState(): TransformResult | 'HARD_INVALIDATED' | undefined; |
| } |
| declare class ModuleGraph { |
| urlToModuleMap: Map<string, ModuleNode>; |
| idToModuleMap: Map<string, ModuleNode>; |
| etagToModuleMap: Map<string, ModuleNode>; |
| fileToModulesMap: Map<string, Set<ModuleNode>>; |
| private moduleNodeCache; |
| constructor(moduleGraphs: { |
| client: () => EnvironmentModuleGraph; |
| ssr: () => EnvironmentModuleGraph; |
| }); |
| getModuleById(id: string): ModuleNode | undefined; |
| getModuleByUrl(url: string, _ssr?: boolean): Promise<ModuleNode | undefined>; |
| getModulesByFile(file: string): Set<ModuleNode> | undefined; |
| onFileChange(file: string): void; |
| onFileDelete(file: string): void; |
| invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean, |
| ): void; |
| invalidateAll(): void; |
| ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>; |
| createFileOnlyEntry(file: string): ModuleNode; |
| resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>; |
| updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void; |
| getModuleByEtag(etag: string): ModuleNode | undefined; |
| getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode; |
| getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode; |
| getBackwardCompatibleModuleNode(mod: EnvironmentModuleNode): ModuleNode; |
| getBackwardCompatibleModuleNodeDual(clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode): ModuleNode; |
| } |
| type ModuleSetNames = 'acceptedHmrDeps' | 'importedModules'; |
|
|
| interface HmrOptions { |
| protocol?: string; |
| host?: string; |
| port?: number; |
| clientPort?: number; |
| path?: string; |
| timeout?: number; |
| overlay?: boolean; |
| server?: HttpServer; |
| } |
| interface HotUpdateOptions { |
| type: 'create' | 'update' | 'delete'; |
| file: string; |
| timestamp: number; |
| modules: Array<EnvironmentModuleNode>; |
| read: () => string | Promise<string>; |
| server: ViteDevServer; |
| |
| |
| |
| environment: DevEnvironment; |
| } |
| interface HmrContext { |
| file: string; |
| timestamp: number; |
| modules: Array<ModuleNode>; |
| read: () => string | Promise<string>; |
| server: ViteDevServer; |
| } |
| interface HotChannelClient { |
| send(payload: HotPayload): void; |
| } |
| |
| type HMRBroadcasterClient = HotChannelClient; |
| type HotChannelListener<T extends string = string> = (data: InferCustomEventPayload<T>, client: HotChannelClient) => void; |
| interface HotChannel<Api = any> { |
| |
| |
| |
| |
| skipFsCheck?: boolean; |
| |
| |
| |
| send?(payload: HotPayload): void; |
| |
| |
| |
| on?<T extends string>(event: T, listener: HotChannelListener<T>): void; |
| on?(event: 'connection', listener: () => void): void; |
| |
| |
| |
| off?(event: string, listener: Function): void; |
| |
| |
| |
| listen?(): void; |
| |
| |
| |
| close?(): Promise<unknown> | void; |
| api?: Api; |
| } |
| |
| type HMRChannel = HotChannel; |
| interface NormalizedHotChannelClient { |
| |
| |
| |
| send(payload: HotPayload): void; |
| |
| |
| |
| send(event: string, payload?: CustomPayload['data']): void; |
| } |
| interface NormalizedHotChannel<Api = any> { |
| |
| |
| |
| send(payload: HotPayload): void; |
| |
| |
| |
| send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void; |
| |
| |
| |
| on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: NormalizedHotChannelClient) => void): void; |
| on(event: 'connection', listener: () => void): void; |
| |
| |
| |
| off(event: string, listener: Function): void; |
| handleInvoke(payload: HotPayload): Promise<{ |
| result: any; |
| } | { |
| error: any; |
| }>; |
| |
| |
| |
| listen(): void; |
| |
| |
| |
| close(): Promise<unknown> | void; |
| api?: Api; |
| } |
| type ServerHotChannelApi = { |
| innerEmitter: EventEmitter; |
| outsideEmitter: EventEmitter; |
| }; |
| type ServerHotChannel = HotChannel<ServerHotChannelApi>; |
| type NormalizedServerHotChannel = NormalizedHotChannel<ServerHotChannelApi>; |
| |
| type ServerHMRChannel = ServerHotChannel; |
| declare function createServerHotChannel(): ServerHotChannel; |
| |
| interface HotBroadcaster extends NormalizedHotChannel { |
| readonly channels: NormalizedHotChannel[]; |
| |
| |
| |
| |
| addChannel(channel: HotChannel): HotBroadcaster; |
| close(): Promise<unknown[]>; |
| } |
| |
| type HMRBroadcaster = HotBroadcaster; |
|
|
| |
| |
|
|
| declare const WebSocketAlias: typeof WebSocket |
| interface WebSocketAlias extends WebSocket {} |
|
|
| |
| declare class WebSocket extends EventEmitter { |
| |
| static readonly CONNECTING: 0 |
| |
| static readonly OPEN: 1 |
| |
| static readonly CLOSING: 2 |
| |
| static readonly CLOSED: 3 |
|
|
| binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments' |
| readonly bufferedAmount: number |
| readonly extensions: string |
| |
| readonly isPaused: boolean |
| readonly protocol: string |
| |
| readonly readyState: |
| | typeof WebSocket.CONNECTING |
| | typeof WebSocket.OPEN |
| | typeof WebSocket.CLOSING |
| | typeof WebSocket.CLOSED |
| readonly url: string |
|
|
| |
| readonly CONNECTING: 0 |
| |
| readonly OPEN: 1 |
| |
| readonly CLOSING: 2 |
| |
| readonly CLOSED: 3 |
|
|
| onopen: ((event: WebSocket.Event) => void) | null |
| onerror: ((event: WebSocket.ErrorEvent) => void) | null |
| onclose: ((event: WebSocket.CloseEvent) => void) | null |
| onmessage: ((event: WebSocket.MessageEvent) => void) | null |
|
|
| constructor(address: null) |
| constructor( |
| address: string | URL, |
| options?: WebSocket.ClientOptions | ClientRequestArgs, |
| ) |
| constructor( |
| address: string | URL, |
| protocols?: string | string[], |
| options?: WebSocket.ClientOptions | ClientRequestArgs, |
| ) |
|
|
| close(code?: number, data?: string | Buffer): void |
| ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void |
| pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void |
| send(data: any, cb?: (err?: Error) => void): void |
| send( |
| data: any, |
| options: { |
| mask?: boolean | undefined |
| binary?: boolean | undefined |
| compress?: boolean | undefined |
| fin?: boolean | undefined |
| }, |
| cb?: (err?: Error) => void, |
| ): void |
| terminate(): void |
|
|
| |
| |
| |
| |
| |
| pause(): void |
| |
| |
| |
| |
| resume(): void |
|
|
| |
| addEventListener( |
| method: 'message', |
| cb: (event: WebSocket.MessageEvent) => void, |
| options?: WebSocket.EventListenerOptions, |
| ): void |
| addEventListener( |
| method: 'close', |
| cb: (event: WebSocket.CloseEvent) => void, |
| options?: WebSocket.EventListenerOptions, |
| ): void |
| addEventListener( |
| method: 'error', |
| cb: (event: WebSocket.ErrorEvent) => void, |
| options?: WebSocket.EventListenerOptions, |
| ): void |
| addEventListener( |
| method: 'open', |
| cb: (event: WebSocket.Event) => void, |
| options?: WebSocket.EventListenerOptions, |
| ): void |
|
|
| removeEventListener( |
| method: 'message', |
| cb: (event: WebSocket.MessageEvent) => void, |
| ): void |
| removeEventListener( |
| method: 'close', |
| cb: (event: WebSocket.CloseEvent) => void, |
| ): void |
| removeEventListener( |
| method: 'error', |
| cb: (event: WebSocket.ErrorEvent) => void, |
| ): void |
| removeEventListener( |
| method: 'open', |
| cb: (event: WebSocket.Event) => void, |
| ): void |
|
|
| |
| on( |
| event: 'close', |
| listener: (this: WebSocket, code: number, reason: Buffer) => void, |
| ): this |
| on(event: 'error', listener: (this: WebSocket, err: Error) => void): this |
| on( |
| event: 'upgrade', |
| listener: (this: WebSocket, request: IncomingMessage) => void, |
| ): this |
| on( |
| event: 'message', |
| listener: ( |
| this: WebSocket, |
| data: WebSocket.RawData, |
| isBinary: boolean, |
| ) => void, |
| ): this |
| on(event: 'open', listener: (this: WebSocket) => void): this |
| on( |
| event: 'ping' | 'pong', |
| listener: (this: WebSocket, data: Buffer) => void, |
| ): this |
| on( |
| event: 'unexpected-response', |
| listener: ( |
| this: WebSocket, |
| request: ClientRequest, |
| response: IncomingMessage, |
| ) => void, |
| ): this |
| on( |
| event: string | symbol, |
| listener: (this: WebSocket, ...args: any[]) => void, |
| ): this |
|
|
| once( |
| event: 'close', |
| listener: (this: WebSocket, code: number, reason: Buffer) => void, |
| ): this |
| once(event: 'error', listener: (this: WebSocket, err: Error) => void): this |
| once( |
| event: 'upgrade', |
| listener: (this: WebSocket, request: IncomingMessage) => void, |
| ): this |
| once( |
| event: 'message', |
| listener: ( |
| this: WebSocket, |
| data: WebSocket.RawData, |
| isBinary: boolean, |
| ) => void, |
| ): this |
| once(event: 'open', listener: (this: WebSocket) => void): this |
| once( |
| event: 'ping' | 'pong', |
| listener: (this: WebSocket, data: Buffer) => void, |
| ): this |
| once( |
| event: 'unexpected-response', |
| listener: ( |
| this: WebSocket, |
| request: ClientRequest, |
| response: IncomingMessage, |
| ) => void, |
| ): this |
| once( |
| event: string | symbol, |
| listener: (this: WebSocket, ...args: any[]) => void, |
| ): this |
|
|
| off( |
| event: 'close', |
| listener: (this: WebSocket, code: number, reason: Buffer) => void, |
| ): this |
| off(event: 'error', listener: (this: WebSocket, err: Error) => void): this |
| off( |
| event: 'upgrade', |
| listener: (this: WebSocket, request: IncomingMessage) => void, |
| ): this |
| off( |
| event: 'message', |
| listener: ( |
| this: WebSocket, |
| data: WebSocket.RawData, |
| isBinary: boolean, |
| ) => void, |
| ): this |
| off(event: 'open', listener: (this: WebSocket) => void): this |
| off( |
| event: 'ping' | 'pong', |
| listener: (this: WebSocket, data: Buffer) => void, |
| ): this |
| off( |
| event: 'unexpected-response', |
| listener: ( |
| this: WebSocket, |
| request: ClientRequest, |
| response: IncomingMessage, |
| ) => void, |
| ): this |
| off( |
| event: string | symbol, |
| listener: (this: WebSocket, ...args: any[]) => void, |
| ): this |
|
|
| addListener( |
| event: 'close', |
| listener: (code: number, reason: Buffer) => void, |
| ): this |
| addListener(event: 'error', listener: (err: Error) => void): this |
| addListener( |
| event: 'upgrade', |
| listener: (request: IncomingMessage) => void, |
| ): this |
| addListener( |
| event: 'message', |
| listener: (data: WebSocket.RawData, isBinary: boolean) => void, |
| ): this |
| addListener(event: 'open', listener: () => void): this |
| addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this |
| addListener( |
| event: 'unexpected-response', |
| listener: (request: ClientRequest, response: IncomingMessage) => void, |
| ): this |
| addListener(event: string | symbol, listener: (...args: any[]) => void): this |
|
|
| removeListener( |
| event: 'close', |
| listener: (code: number, reason: Buffer) => void, |
| ): this |
| removeListener(event: 'error', listener: (err: Error) => void): this |
| removeListener( |
| event: 'upgrade', |
| listener: (request: IncomingMessage) => void, |
| ): this |
| removeListener( |
| event: 'message', |
| listener: (data: WebSocket.RawData, isBinary: boolean) => void, |
| ): this |
| removeListener(event: 'open', listener: () => void): this |
| removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this |
| removeListener( |
| event: 'unexpected-response', |
| listener: (request: ClientRequest, response: IncomingMessage) => void, |
| ): this |
| removeListener( |
| event: string | symbol, |
| listener: (...args: any[]) => void, |
| ): this |
| } |
|
|
| declare namespace WebSocket { |
| |
| |
| |
| type RawData = Buffer | ArrayBuffer | Buffer[] |
|
|
| |
| |
| |
| type Data = string | Buffer | ArrayBuffer | Buffer[] |
|
|
| |
| |
| |
| type CertMeta = string | string[] | Buffer | Buffer[] |
|
|
| |
| |
| |
| |
| |
| type VerifyClientCallbackSync = (info: { |
| origin: string |
| secure: boolean |
| req: IncomingMessage |
| }) => boolean |
|
|
| |
| |
| |
| |
| |
| type VerifyClientCallbackAsync = ( |
| info: { origin: string; secure: boolean; req: IncomingMessage }, |
| callback: ( |
| res: boolean, |
| code?: number, |
| message?: string, |
| headers?: OutgoingHttpHeaders, |
| ) => void, |
| ) => void |
|
|
| interface ClientOptions extends SecureContextOptions { |
| protocol?: string | undefined |
| followRedirects?: boolean | undefined |
| generateMask?(mask: Buffer): void |
| handshakeTimeout?: number | undefined |
| maxRedirects?: number | undefined |
| perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined |
| localAddress?: string | undefined |
| protocolVersion?: number | undefined |
| headers?: { [key: string]: string } | undefined |
| origin?: string | undefined |
| agent?: Agent | undefined |
| host?: string | undefined |
| family?: number | undefined |
| checkServerIdentity?(servername: string, cert: CertMeta): boolean |
| rejectUnauthorized?: boolean | undefined |
| maxPayload?: number | undefined |
| skipUTF8Validation?: boolean | undefined |
| } |
|
|
| interface PerMessageDeflateOptions { |
| serverNoContextTakeover?: boolean | undefined |
| clientNoContextTakeover?: boolean | undefined |
| serverMaxWindowBits?: number | undefined |
| clientMaxWindowBits?: number | undefined |
| zlibDeflateOptions?: |
| | { |
| flush?: number | undefined |
| finishFlush?: number | undefined |
| chunkSize?: number | undefined |
| windowBits?: number | undefined |
| level?: number | undefined |
| memLevel?: number | undefined |
| strategy?: number | undefined |
| dictionary?: Buffer | Buffer[] | DataView | undefined |
| info?: boolean | undefined |
| } |
| | undefined |
| zlibInflateOptions?: ZlibOptions | undefined |
| threshold?: number | undefined |
| concurrencyLimit?: number | undefined |
| } |
|
|
| interface Event { |
| type: string |
| target: WebSocket |
| } |
|
|
| interface ErrorEvent { |
| error: any |
| message: string |
| type: string |
| target: WebSocket |
| } |
|
|
| interface CloseEvent { |
| wasClean: boolean |
| code: number |
| reason: string |
| type: string |
| target: WebSocket |
| } |
|
|
| interface MessageEvent { |
| data: Data |
| type: string |
| target: WebSocket |
| } |
|
|
| interface EventListenerOptions { |
| once?: boolean | undefined |
| } |
|
|
| interface ServerOptions { |
| host?: string | undefined |
| port?: number | undefined |
| backlog?: number | undefined |
| server?: Server | HttpsServer | undefined |
| verifyClient?: |
| | VerifyClientCallbackAsync |
| | VerifyClientCallbackSync |
| | undefined |
| handleProtocols?: ( |
| protocols: Set<string>, |
| request: IncomingMessage, |
| ) => string | false |
| path?: string | undefined |
| noServer?: boolean | undefined |
| clientTracking?: boolean | undefined |
| perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined |
| maxPayload?: number | undefined |
| skipUTF8Validation?: boolean | undefined |
| WebSocket?: typeof WebSocket.WebSocket | undefined |
| } |
|
|
| interface AddressInfo { |
| address: string |
| family: string |
| port: number |
| } |
|
|
| |
| class Server<T extends WebSocket = WebSocket> extends EventEmitter { |
| options: ServerOptions |
| path: string |
| clients: Set<T> |
|
|
| constructor(options?: ServerOptions, callback?: () => void) |
|
|
| address(): AddressInfo | string |
| close(cb?: (err?: Error) => void): void |
| handleUpgrade( |
| request: IncomingMessage, |
| socket: Duplex, |
| upgradeHead: Buffer, |
| callback: (client: T, request: IncomingMessage) => void, |
| ): void |
| shouldHandle(request: IncomingMessage): boolean | Promise<boolean> |
|
|
| |
| on( |
| event: 'connection', |
| cb: (this: Server<T>, socket: T, request: IncomingMessage) => void, |
| ): this |
| on(event: 'error', cb: (this: Server<T>, error: Error) => void): this |
| on( |
| event: 'headers', |
| cb: ( |
| this: Server<T>, |
| headers: string[], |
| request: IncomingMessage, |
| ) => void, |
| ): this |
| on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this |
| on( |
| event: string | symbol, |
| listener: (this: Server<T>, ...args: any[]) => void, |
| ): this |
|
|
| once( |
| event: 'connection', |
| cb: (this: Server<T>, socket: T, request: IncomingMessage) => void, |
| ): this |
| once(event: 'error', cb: (this: Server<T>, error: Error) => void): this |
| once( |
| event: 'headers', |
| cb: ( |
| this: Server<T>, |
| headers: string[], |
| request: IncomingMessage, |
| ) => void, |
| ): this |
| once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this |
| once( |
| event: string | symbol, |
| listener: (this: Server<T>, ...args: any[]) => void, |
| ): this |
|
|
| off( |
| event: 'connection', |
| cb: (this: Server<T>, socket: T, request: IncomingMessage) => void, |
| ): this |
| off(event: 'error', cb: (this: Server<T>, error: Error) => void): this |
| off( |
| event: 'headers', |
| cb: ( |
| this: Server<T>, |
| headers: string[], |
| request: IncomingMessage, |
| ) => void, |
| ): this |
| off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this |
| off( |
| event: string | symbol, |
| listener: (this: Server<T>, ...args: any[]) => void, |
| ): this |
|
|
| addListener( |
| event: 'connection', |
| cb: (client: T, request: IncomingMessage) => void, |
| ): this |
| addListener(event: 'error', cb: (err: Error) => void): this |
| addListener( |
| event: 'headers', |
| cb: (headers: string[], request: IncomingMessage) => void, |
| ): this |
| addListener(event: 'close' | 'listening', cb: () => void): this |
| addListener( |
| event: string | symbol, |
| listener: (...args: any[]) => void, |
| ): this |
|
|
| removeListener(event: 'connection', cb: (client: T) => void): this |
| removeListener(event: 'error', cb: (err: Error) => void): this |
| removeListener( |
| event: 'headers', |
| cb: (headers: string[], request: IncomingMessage) => void, |
| ): this |
| removeListener(event: 'close' | 'listening', cb: () => void): this |
| removeListener( |
| event: string | symbol, |
| listener: (...args: any[]) => void, |
| ): this |
| } |
|
|
| const WebSocketServer: typeof Server |
| interface WebSocketServer extends Server {} |
| const WebSocket: typeof WebSocketAlias |
| interface WebSocket extends WebSocketAlias {} |
|
|
| |
| function createWebSocketStream( |
| websocket: WebSocket, |
| options?: DuplexOptions, |
| ): Duplex |
| } |
|
|
| type WebSocketCustomListener<T> = (data: T, client: WebSocketClient, invoke?: 'send' | `send:${string}`) => void; |
| declare const isWebSocketServer: unique symbol; |
| interface WebSocketServer extends NormalizedHotChannel { |
| |
| |
| |
| on: WebSocket.Server['on'] & { |
| <T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void; |
| }; |
| |
| |
| |
| off: WebSocket.Server['off'] & { |
| (event: string, listener: Function): void; |
| }; |
| |
| |
| |
| listen(): void; |
| |
| |
| |
| close(): Promise<void>; |
| [isWebSocketServer]: true; |
| |
| |
| |
| clients: Set<WebSocketClient>; |
| } |
| interface WebSocketClient extends NormalizedHotChannelClient { |
| |
| |
| |
| |
| socket: WebSocket; |
| } |
|
|
| interface DevEnvironmentContext { |
| hot: boolean; |
| transport?: HotChannel | WebSocketServer; |
| options?: EnvironmentOptions; |
| remoteRunner?: { |
| inlineSourceMap?: boolean; |
| }; |
| depsOptimizer?: DepsOptimizer; |
| } |
| declare class DevEnvironment extends BaseEnvironment { |
| mode: "dev"; |
| moduleGraph: EnvironmentModuleGraph; |
| depsOptimizer?: DepsOptimizer; |
| get pluginContainer(): EnvironmentPluginContainer; |
| |
| |
| |
| |
| |
| |
| |
| hot: NormalizedHotChannel; |
| constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext); |
| init(options?: { |
| watcher?: FSWatcher; |
| |
| |
| |
| |
| |
| previousInstance?: DevEnvironment; |
| }): Promise<void>; |
| |
| |
| |
| |
| |
| |
| listen(server: ViteDevServer): Promise<void>; |
| fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>; |
| reloadModule(module: EnvironmentModuleNode): Promise<void>; |
| transformRequest(url: string): Promise<TransformResult | null>; |
| warmupRequest(url: string): Promise<void>; |
| close(): Promise<void>; |
| |
| |
| |
| |
| |
| |
| |
| |
| waitForRequestsIdle(ignoredId?: string): Promise<void>; |
| } |
|
|
| interface RollupCommonJSOptions { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| include?: string | RegExp | readonly (string | RegExp)[] |
| |
| |
| |
| |
| |
| |
| |
| exclude?: string | RegExp | readonly (string | RegExp)[] |
| |
| |
| |
| |
| |
| |
| extensions?: ReadonlyArray<string> |
| |
| |
| |
| |
| ignoreGlobal?: boolean |
| |
| |
| |
| |
| |
| sourceMap?: boolean |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| ignoreDynamicRequires?: boolean |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| transformMixedEsModules?: boolean |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[] |
| |
| |
| |
| |
| |
| ignore?: ReadonlyArray<string> | ((id: string) => boolean) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| ignoreTryCatch?: |
| | boolean |
| | 'remove' |
| | ReadonlyArray<string> |
| | ((id: string) => boolean | 'remove') |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| requireReturnsDefault?: |
| | boolean |
| | 'auto' |
| | 'preferred' |
| | 'namespace' |
| | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace') |
|
|
| |
| |
| |
| defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto') |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| dynamicRequireTargets?: string | ReadonlyArray<string> |
| |
| |
| |
| |
| |
| |
| dynamicRequireRoot?: string |
| } |
|
|
| interface RollupDynamicImportVarsOptions { |
| |
| |
| |
| |
| include?: string | RegExp | (string | RegExp)[] |
| |
| |
| |
| |
| exclude?: string | RegExp | (string | RegExp)[] |
| |
| |
| |
| |
| warnOnError?: boolean |
| } |
|
|
| |
| |
| |
|
|
| declare namespace Terser { |
| export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 |
|
|
| export type ConsoleProperty = keyof typeof console |
| type DropConsoleOption = boolean | ConsoleProperty[] |
|
|
| export interface ParseOptions { |
| bare_returns?: boolean |
| |
| ecma?: ECMA |
| html5_comments?: boolean |
| shebang?: boolean |
| } |
|
|
| export interface CompressOptions { |
| arguments?: boolean |
| arrows?: boolean |
| booleans_as_integers?: boolean |
| booleans?: boolean |
| collapse_vars?: boolean |
| comparisons?: boolean |
| computed_props?: boolean |
| conditionals?: boolean |
| dead_code?: boolean |
| defaults?: boolean |
| directives?: boolean |
| drop_console?: DropConsoleOption |
| drop_debugger?: boolean |
| ecma?: ECMA |
| evaluate?: boolean |
| expression?: boolean |
| global_defs?: object |
| hoist_funs?: boolean |
| hoist_props?: boolean |
| hoist_vars?: boolean |
| ie8?: boolean |
| if_return?: boolean |
| inline?: boolean | InlineFunctions |
| join_vars?: boolean |
| keep_classnames?: boolean | RegExp |
| keep_fargs?: boolean |
| keep_fnames?: boolean | RegExp |
| keep_infinity?: boolean |
| loops?: boolean |
| module?: boolean |
| negate_iife?: boolean |
| passes?: number |
| properties?: boolean |
| pure_funcs?: string[] |
| pure_new?: boolean |
| pure_getters?: boolean | 'strict' |
| reduce_funcs?: boolean |
| reduce_vars?: boolean |
| sequences?: boolean | number |
| side_effects?: boolean |
| switches?: boolean |
| toplevel?: boolean |
| top_retain?: null | string | string[] | RegExp |
| typeofs?: boolean |
| unsafe_arrows?: boolean |
| unsafe?: boolean |
| unsafe_comps?: boolean |
| unsafe_Function?: boolean |
| unsafe_math?: boolean |
| unsafe_symbols?: boolean |
| unsafe_methods?: boolean |
| unsafe_proto?: boolean |
| unsafe_regexp?: boolean |
| unsafe_undefined?: boolean |
| unused?: boolean |
| } |
|
|
| export enum InlineFunctions { |
| Disabled = 0, |
| SimpleFunctions = 1, |
| WithArguments = 2, |
| WithArgumentsAndVariables = 3, |
| } |
|
|
| export interface MangleOptions { |
| eval?: boolean |
| keep_classnames?: boolean | RegExp |
| keep_fnames?: boolean | RegExp |
| module?: boolean |
| nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler |
| properties?: boolean | ManglePropertiesOptions |
| reserved?: string[] |
| safari10?: boolean |
| toplevel?: boolean |
| } |
|
|
| |
| |
| |
| export interface SimpleIdentifierMangler { |
| |
| |
| |
| |
| |
| |
| get(n: number): string |
| } |
|
|
| |
| |
| |
| export interface WeightedIdentifierMangler extends SimpleIdentifierMangler { |
| |
| |
| |
| |
| |
| |
| consider(chars: string, delta: number): number |
| |
| |
| |
| reset(): void |
| |
| |
| |
| sort(): void |
| } |
|
|
| export interface ManglePropertiesOptions { |
| builtins?: boolean |
| debug?: boolean |
| keep_quoted?: boolean | 'strict' |
| nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler |
| regex?: RegExp | string |
| reserved?: string[] |
| } |
|
|
| export interface FormatOptions { |
| ascii_only?: boolean |
| |
| beautify?: boolean |
| braces?: boolean |
| comments?: |
| | boolean |
| | 'all' |
| | 'some' |
| | RegExp |
| | (( |
| node: any, |
| comment: { |
| value: string |
| type: 'comment1' | 'comment2' | 'comment3' | 'comment4' |
| pos: number |
| line: number |
| col: number |
| }, |
| ) => boolean) |
| ecma?: ECMA |
| ie8?: boolean |
| keep_numbers?: boolean |
| indent_level?: number |
| indent_start?: number |
| inline_script?: boolean |
| keep_quoted_props?: boolean |
| max_line_len?: number | false |
| preamble?: string |
| preserve_annotations?: boolean |
| quote_keys?: boolean |
| quote_style?: OutputQuoteStyle |
| safari10?: boolean |
| semicolons?: boolean |
| shebang?: boolean |
| shorthand?: boolean |
| source_map?: SourceMapOptions |
| webkit?: boolean |
| width?: number |
| wrap_iife?: boolean |
| wrap_func_args?: boolean |
| } |
|
|
| export enum OutputQuoteStyle { |
| PreferDouble = 0, |
| AlwaysSingle = 1, |
| AlwaysDouble = 2, |
| AlwaysOriginal = 3, |
| } |
|
|
| export interface MinifyOptions { |
| compress?: boolean | CompressOptions |
| ecma?: ECMA |
| enclose?: boolean | string |
| ie8?: boolean |
| keep_classnames?: boolean | RegExp |
| keep_fnames?: boolean | RegExp |
| mangle?: boolean | MangleOptions |
| module?: boolean |
| nameCache?: object |
| format?: FormatOptions |
| |
| output?: FormatOptions |
| parse?: ParseOptions |
| safari10?: boolean |
| sourceMap?: boolean | SourceMapOptions |
| toplevel?: boolean |
| } |
|
|
| export interface MinifyOutput { |
| code?: string |
| map?: object | string |
| decoded_map?: object | null |
| } |
|
|
| export interface SourceMapOptions { |
| |
| content?: object | string |
| includeSources?: boolean |
| filename?: string |
| root?: string |
| asObject?: boolean |
| url?: string | 'inline' |
| } |
| } |
|
|
| interface TerserOptions extends Terser.MinifyOptions { |
| |
| |
| |
| |
| |
| |
| maxWorkers?: number; |
| } |
|
|
| interface EnvironmentResolveOptions { |
| |
| |
| |
| mainFields?: string[]; |
| conditions?: string[]; |
| externalConditions?: string[]; |
| |
| |
| |
| extensions?: string[]; |
| dedupe?: string[]; |
| |
| |
| |
| |
| |
| noExternal?: string | RegExp | (string | RegExp)[] | true; |
| |
| |
| |
| |
| |
| external?: string[] | true; |
| |
| |
| |
| builtins?: (string | RegExp)[]; |
| } |
| interface ResolveOptions extends EnvironmentResolveOptions { |
| |
| |
| |
| preserveSymlinks?: boolean; |
| } |
| interface ResolvePluginOptions { |
| root: string; |
| isBuild: boolean; |
| isProduction: boolean; |
| packageCache?: PackageCache; |
| |
| |
| |
| |
| |
| asSrc?: boolean; |
| tryIndex?: boolean; |
| tryPrefix?: string; |
| preferRelative?: boolean; |
| isRequire?: boolean; |
| |
| isFromTsImporter?: boolean; |
| scan?: boolean; |
| |
| |
| |
| ssrConfig?: SSROptions; |
| } |
| interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions { |
| } |
|
|
| |
| type PackageCache = Map<string, PackageData>; |
| interface PackageData { |
| dir: string; |
| hasSideEffects: (id: string) => boolean | 'no-treeshake' | null; |
| setResolvedCache: (key: string, entry: string, options: InternalResolveOptions) => void; |
| getResolvedCache: (key: string, options: InternalResolveOptions) => string | undefined; |
| data: { |
| [field: string]: any; |
| name: string; |
| type: string; |
| version: string; |
| main: string; |
| module: string; |
| browser: string | Record<string, string | false>; |
| exports: string | Record<string, any> | string[]; |
| imports: Record<string, any>; |
| dependencies: Record<string, string>; |
| }; |
| } |
|
|
| interface BuildEnvironmentOptions { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| target?: 'modules' | esbuild_TransformOptions['target'] | false; |
| |
| |
| |
| |
| |
| |
| polyfillModulePreload?: boolean; |
| |
| |
| |
| |
| |
| modulePreload?: boolean | ModulePreloadOptions; |
| |
| |
| |
| |
| |
| outDir?: string; |
| |
| |
| |
| |
| |
| assetsDir?: string; |
| |
| |
| |
| |
| |
| |
| |
| |
| assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined); |
| |
| |
| |
| |
| |
| |
| cssCodeSplit?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| cssTarget?: esbuild_TransformOptions['target'] | false; |
| |
| |
| |
| |
| |
| cssMinify?: boolean | 'esbuild' | 'lightningcss'; |
| |
| |
| |
| |
| |
| |
| |
| sourcemap?: boolean | 'inline' | 'hidden'; |
| |
| |
| |
| |
| |
| minify?: boolean | 'terser' | 'esbuild'; |
| |
| |
| |
| |
| |
| |
| |
| terserOptions?: TerserOptions; |
| |
| |
| |
| |
| rollupOptions?: RollupOptions; |
| |
| |
| |
| commonjsOptions?: RollupCommonJSOptions; |
| |
| |
| |
| dynamicImportVarsOptions?: RollupDynamicImportVarsOptions; |
| |
| |
| |
| |
| write?: boolean; |
| |
| |
| |
| |
| emptyOutDir?: boolean | null; |
| |
| |
| |
| |
| copyPublicDir?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| manifest?: boolean | string; |
| |
| |
| |
| |
| |
| |
| lib?: LibraryOptions | false; |
| |
| |
| |
| |
| |
| ssr?: boolean | string; |
| |
| |
| |
| |
| |
| ssrManifest?: boolean | string; |
| |
| |
| |
| |
| ssrEmitAssets?: boolean; |
| |
| |
| |
| |
| emitAssets?: boolean; |
| |
| |
| |
| |
| |
| reportCompressedSize?: boolean; |
| |
| |
| |
| |
| chunkSizeWarningLimit?: number; |
| |
| |
| |
| |
| |
| watch?: WatcherOptions | null; |
| |
| |
| |
| createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment; |
| } |
| type BuildOptions = BuildEnvironmentOptions; |
| interface LibraryOptions { |
| |
| |
| |
| entry: InputOption; |
| |
| |
| |
| |
| name?: string; |
| |
| |
| |
| |
| formats?: LibraryFormats[]; |
| |
| |
| |
| |
| |
| fileName?: string | ((format: ModuleFormat, entryName: string) => string); |
| |
| |
| |
| |
| |
| cssFileName?: string; |
| } |
| type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system'; |
| interface ModulePreloadOptions { |
| |
| |
| |
| |
| |
| polyfill?: boolean; |
| |
| |
| |
| |
| resolveDependencies?: ResolveModulePreloadDependenciesFn; |
| } |
| interface ResolvedModulePreloadOptions { |
| polyfill: boolean; |
| resolveDependencies?: ResolveModulePreloadDependenciesFn; |
| } |
| type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: { |
| hostId: string; |
| hostType: 'html' | 'js'; |
| }) => string[]; |
| interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> { |
| modulePreload: false | ResolvedModulePreloadOptions; |
| } |
| interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> { |
| modulePreload: false | ResolvedModulePreloadOptions; |
| } |
| |
| |
| |
| |
| declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>; |
| type RenderBuiltAssetUrl = (filename: string, type: { |
| type: 'asset' | 'public'; |
| hostId: string; |
| hostType: 'js' | 'css' | 'html'; |
| ssr: boolean; |
| }) => string | { |
| relative?: boolean; |
| runtime?: string; |
| } | undefined; |
| declare class BuildEnvironment extends BaseEnvironment { |
| mode: "build"; |
| constructor(name: string, config: ResolvedConfig, setup?: { |
| options?: EnvironmentOptions; |
| }); |
| init(): Promise<void>; |
| } |
| interface ViteBuilder { |
| environments: Record<string, BuildEnvironment>; |
| config: ResolvedConfig; |
| buildApp(): Promise<void>; |
| build(environment: BuildEnvironment): Promise<RollupOutput | RollupOutput[] | RollupWatcher>; |
| } |
| interface BuilderOptions { |
| |
| |
| |
| |
| |
| |
| sharedConfigBuild?: boolean; |
| |
| |
| |
| |
| |
| |
| sharedPlugins?: boolean; |
| buildApp?: (builder: ViteBuilder) => Promise<void>; |
| } |
| type ResolvedBuilderOptions = Required<BuilderOptions>; |
| |
| |
| |
| |
| declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>; |
|
|
| type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment; |
| |
| |
| |
| |
| |
| |
| |
| declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State; |
|
|
| type SkipInformation = { |
| id: string; |
| importer: string | undefined; |
| plugin: Plugin; |
| called?: boolean; |
| }; |
| declare class EnvironmentPluginContainer { |
| environment: Environment; |
| plugins: Plugin[]; |
| watcher?: FSWatcher | undefined; |
| private _pluginContextMap; |
| private _resolvedRollupOptions?; |
| private _processesing; |
| private _seenResolves; |
| private _moduleNodeToLoadAddedImports; |
| getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks']; |
| getSortedPlugins: PluginHookUtils['getSortedPlugins']; |
| moduleGraph: EnvironmentModuleGraph | undefined; |
| watchFiles: Set<string>; |
| minimalContext: MinimalPluginContext; |
| private _started; |
| private _buildStartPromise; |
| private _closed; |
| private _updateModuleLoadAddedImports; |
| private _getAddedImports; |
| getModuleInfo(id: string): ModuleInfo | null; |
| private handleHookPromise; |
| get options(): InputOptions; |
| resolveRollupOptions(): Promise<InputOptions>; |
| private _getPluginContext; |
| private hookParallel; |
| buildStart(_options?: InputOptions): Promise<void>; |
| resolveId(rawId: string, importer?: string | undefined, options?: { |
| attributes?: Record<string, string>; |
| custom?: CustomPluginOptions; |
| |
| skip?: Set<Plugin>; |
| skipCalls?: readonly SkipInformation[]; |
| isEntry?: boolean; |
| }): Promise<PartialResolvedId | null>; |
| load(id: string): Promise<LoadResult | null>; |
| transform(code: string, id: string, options?: { |
| inMap?: SourceDescription['map']; |
| }): Promise<{ |
| code: string; |
| map: SourceMap | { |
| mappings: ''; |
| } | null; |
| }>; |
| watchChange(id: string, change: { |
| event: 'create' | 'update' | 'delete'; |
| }): Promise<void>; |
| close(): Promise<void>; |
| } |
| declare class MinimalPluginContext implements rollup.MinimalPluginContext { |
| meta: PluginContextMeta; |
| environment: Environment; |
| constructor(meta: PluginContextMeta, environment: Environment); |
| debug(rawLog: string | RollupLog | (() => string | RollupLog)): void; |
| info(rawLog: string | RollupLog | (() => string | RollupLog)): void; |
| warn(rawLog: string | RollupLog | (() => string | RollupLog)): void; |
| error(e: string | RollupError): never; |
| private _normalizeRawLog; |
| } |
| declare class PluginContainer { |
| private environments; |
| constructor(environments: Record<string, Environment>); |
| private _getEnvironment; |
| private _getPluginContainer; |
| getModuleInfo(id: string): ModuleInfo | null; |
| get options(): InputOptions; |
| buildStart(_options?: InputOptions): Promise<void>; |
| watchChange(id: string, change: { |
| event: 'create' | 'update' | 'delete'; |
| }): Promise<void>; |
| resolveId(rawId: string, importer?: string, options?: { |
| attributes?: Record<string, string>; |
| custom?: CustomPluginOptions; |
| |
| skip?: Set<Plugin>; |
| skipCalls?: readonly SkipInformation[]; |
| ssr?: boolean; |
| isEntry?: boolean; |
| }): Promise<PartialResolvedId | null>; |
| load(id: string, options?: { |
| ssr?: boolean; |
| }): Promise<LoadResult | null>; |
| transform(code: string, id: string, options?: { |
| ssr?: boolean; |
| environment?: Environment; |
| inMap?: SourceDescription['map']; |
| }): Promise<{ |
| code: string; |
| map: SourceMap | { |
| mappings: ''; |
| } | null; |
| }>; |
| close(): Promise<void>; |
| } |
|
|
| interface ServerOptions extends CommonServerOptions { |
| |
| |
| |
| hmr?: HmrOptions | boolean; |
| |
| |
| |
| |
| ws?: false; |
| |
| |
| |
| |
| warmup?: { |
| |
| |
| |
| clientFiles?: string[]; |
| |
| |
| |
| ssrFiles?: string[]; |
| }; |
| |
| |
| |
| |
| watch?: WatchOptions | null; |
| |
| |
| |
| |
| middlewareMode?: boolean | { |
| |
| |
| |
| |
| |
| server: HttpServer; |
| }; |
| |
| |
| |
| fs?: FileSystemServeOptions; |
| |
| |
| |
| |
| |
| origin?: string; |
| |
| |
| |
| |
| preTransformRequests?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean); |
| |
| |
| |
| |
| |
| |
| perEnvironmentStartEndDuringDev?: boolean; |
| |
| |
| |
| |
| hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>; |
| } |
| interface ResolvedServerOptions extends Omit<RequiredExceptFor<ServerOptions, 'host' | 'https' | 'proxy' | 'hmr' | 'ws' | 'watch' | 'origin' | 'hotUpdateEnvironments'>, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> { |
| fs: Required<FileSystemServeOptions>; |
| middlewareMode: NonNullable<ServerOptions['middlewareMode']>; |
| sourcemapIgnoreList: Exclude<ServerOptions['sourcemapIgnoreList'], false | undefined>; |
| } |
| interface FileSystemServeOptions { |
| |
| |
| |
| |
| |
| |
| |
| strict?: boolean; |
| |
| |
| |
| |
| |
| |
| allow?: string[]; |
| |
| |
| |
| |
| |
| |
| |
| |
| deny?: string[]; |
| } |
| type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>; |
| type HttpServer = http.Server | Http2SecureServer; |
| interface ViteDevServer { |
| |
| |
| |
| config: ResolvedConfig; |
| |
| |
| |
| |
| |
| |
| |
| |
| middlewares: Connect.Server; |
| |
| |
| |
| |
| httpServer: HttpServer | null; |
| |
| |
| |
| |
| |
| watcher: FSWatcher; |
| |
| |
| |
| ws: WebSocketServer; |
| |
| |
| |
| |
| |
| |
| hot: HotBroadcaster; |
| |
| |
| |
| pluginContainer: PluginContainer; |
| |
| |
| |
| environments: Record<'client' | 'ssr' | (string & {}), DevEnvironment>; |
| |
| |
| |
| |
| moduleGraph: ModuleGraph; |
| |
| |
| |
| |
| resolvedUrls: ResolvedServerUrls | null; |
| |
| |
| |
| |
| transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>; |
| |
| |
| |
| |
| |
| warmupRequest(url: string, options?: TransformOptions): Promise<void>; |
| |
| |
| |
| transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>; |
| |
| |
| |
| ssrTransform(code: string, inMap: SourceMap | { |
| mappings: ''; |
| } | null, url: string, originalCode?: string): Promise<TransformResult | null>; |
| |
| |
| |
| ssrLoadModule(url: string, opts?: { |
| fixStacktrace?: boolean; |
| }): Promise<Record<string, any>>; |
| |
| |
| |
| ssrRewriteStacktrace(stack: string): string; |
| |
| |
| |
| ssrFixStacktrace(e: Error): void; |
| |
| |
| |
| |
| reloadModule(module: ModuleNode): Promise<void>; |
| |
| |
| |
| listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>; |
| |
| |
| |
| close(): Promise<void>; |
| |
| |
| |
| printUrls(): void; |
| |
| |
| |
| bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void; |
| |
| |
| |
| |
| |
| restart(forceOptimize?: boolean): Promise<void>; |
| |
| |
| |
| openBrowser(): void; |
| |
| |
| |
| |
| |
| |
| waitForRequestsIdle: (ignoredId?: string) => Promise<void>; |
| } |
| interface ResolvedServerUrls { |
| local: string[]; |
| network: string[]; |
| } |
| declare function createServer(inlineConfig?: InlineConfig | ResolvedConfig): Promise<ViteDevServer>; |
|
|
| interface HtmlTagDescriptor { |
| tag: string; |
| attrs?: Record<string, string | boolean | undefined>; |
| children?: string | HtmlTagDescriptor[]; |
| |
| |
| |
| injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend'; |
| } |
| type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | { |
| html: string; |
| tags: HtmlTagDescriptor[]; |
| }; |
| interface IndexHtmlTransformContext { |
| |
| |
| |
| path: string; |
| |
| |
| |
| filename: string; |
| server?: ViteDevServer; |
| bundle?: OutputBundle; |
| chunk?: OutputChunk; |
| originalUrl?: string; |
| } |
| type IndexHtmlTransformHook = (this: void, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>; |
| type IndexHtmlTransform = IndexHtmlTransformHook | { |
| order?: 'pre' | 'post' | null; |
| |
| |
| |
| enforce?: 'pre' | 'post'; |
| |
| |
| |
| transform: IndexHtmlTransformHook; |
| } | { |
| order?: 'pre' | 'post' | null; |
| |
| |
| |
| enforce?: 'pre' | 'post'; |
| handler: IndexHtmlTransformHook; |
| }; |
|
|
| type StringFilter<Value = string | RegExp> = Value | Array<Value> | { |
| include?: Value | Array<Value>; |
| exclude?: Value | Array<Value>; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| interface PluginContextExtension { |
| |
| |
| |
| environment: Environment; |
| } |
| interface HotUpdatePluginContext { |
| environment: DevEnvironment; |
| } |
| declare module 'rollup' { |
| interface MinimalPluginContext extends PluginContextExtension { |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| interface Plugin<A = any> extends rollup.Plugin<A> { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| hotUpdate?: ObjectHook<(this: HotUpdatePluginContext, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>; |
| |
| |
| |
| resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { |
| attributes: Record<string, string>; |
| custom?: CustomPluginOptions; |
| ssr?: boolean; |
| isEntry: boolean; |
| }) => Promise<ResolveIdResult> | ResolveIdResult, { |
| filter?: { |
| id?: StringFilter<RegExp>; |
| }; |
| }>; |
| load?: ObjectHook<(this: PluginContext, id: string, options?: { |
| ssr?: boolean; |
| }) => Promise<LoadResult> | LoadResult, { |
| filter?: { |
| id?: StringFilter; |
| }; |
| }>; |
| transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: { |
| ssr?: boolean; |
| }) => Promise<rollup.TransformResult> | rollup.TransformResult, { |
| filter?: { |
| id?: StringFilter; |
| code?: StringFilter; |
| }; |
| }>; |
| |
| |
| |
| |
| |
| |
| |
| |
| sharedDuringBuild?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| perEnvironmentStartEndDuringDev?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| enforce?: 'pre' | 'post'; |
| |
| |
| |
| apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean); |
| |
| |
| |
| |
| |
| applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption; |
| |
| |
| |
| |
| |
| |
| |
| |
| config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, 'plugins'> | null | void | Promise<Omit<UserConfig, 'plugins'> | null | void>>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv & { |
| /** |
| * Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`. |
| * Only intended to be used for backward compatibility. |
| */ |
| isSsrTargetWebworker?: boolean; |
| }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>; |
| |
| |
| |
| configResolved?: ObjectHook<(this: void, config: ResolvedConfig) => void | Promise<void>>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| configureServer?: ObjectHook<ServerHook>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| configurePreviewServer?: ObjectHook<PreviewServerHook>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| transformIndexHtml?: IndexHtmlTransform; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>; |
| } |
| type HookHandler<T> = T extends ObjectHook<infer H> ? H : T; |
| type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & { |
| [P in K]: NonNullable<Plugin[P]>; |
| }; |
| type Thenable<T> = T | Promise<T>; |
| type FalsyPlugin = false | null | undefined; |
| type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>; |
| |
| |
| |
| declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin; |
|
|
| interface CSSOptions { |
| |
| |
| |
| |
| |
| |
| |
| |
| transformer?: 'postcss' | 'lightningcss'; |
| |
| |
| |
| modules?: CSSModulesOptions | false; |
| |
| |
| |
| |
| |
| |
| preprocessorOptions?: { |
| scss?: SassPreprocessorOptions; |
| sass?: SassPreprocessorOptions; |
| less?: LessPreprocessorOptions; |
| styl?: StylusPreprocessorOptions; |
| stylus?: StylusPreprocessorOptions; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| preprocessorMaxWorkers?: number | true; |
| postcss?: string | (PostCSS.ProcessOptions & { |
| plugins?: PostCSS.AcceptedPlugin[]; |
| }); |
| |
| |
| |
| |
| |
| devSourcemap?: boolean; |
| |
| |
| |
| lightningcss?: LightningCSSOptions; |
| } |
| interface CSSModulesOptions { |
| getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void; |
| scopeBehaviour?: 'global' | 'local'; |
| globalModulePaths?: RegExp[]; |
| exportGlobals?: boolean; |
| generateScopedName?: string | ((name: string, filename: string, css: string) => string); |
| hashPrefix?: string; |
| |
| |
| |
| localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string); |
| } |
| type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer' | 'devSourcemap'>> & { |
| lightningcss?: LightningCSSOptions; |
| }; |
| interface PreprocessCSSResult { |
| code: string; |
| map?: SourceMapInput; |
| modules?: Record<string, string>; |
| deps?: Set<string>; |
| } |
| |
| |
| |
| declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>; |
| declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>; |
| type PreprocessorAdditionalDataResult = string | { |
| content: string; |
| map?: ExistingRawSourceMap; |
| }; |
| type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>); |
| type SassPreprocessorOptions = { |
| additionalData?: PreprocessorAdditionalData; |
| } & (({ |
| api: 'legacy'; |
| } & SassLegacyPreprocessBaseOptions) | ({ |
| api?: 'modern' | 'modern-compiler'; |
| } & SassModernPreprocessBaseOptions)); |
| type LessPreprocessorOptions = { |
| additionalData?: PreprocessorAdditionalData; |
| } & LessPreprocessorBaseOptions; |
| type StylusPreprocessorOptions = { |
| additionalData?: PreprocessorAdditionalData; |
| } & StylusPreprocessorBaseOptions; |
|
|
| interface ESBuildOptions extends esbuild_TransformOptions { |
| include?: string | RegExp | ReadonlyArray<string | RegExp>; |
| exclude?: string | RegExp | ReadonlyArray<string | RegExp>; |
| jsxInject?: string; |
| |
| |
| |
| minify?: never; |
| } |
| type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & { |
| map: SourceMap; |
| }; |
| declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<ESBuildTransformResult>; |
|
|
| interface JsonOptions { |
| |
| |
| |
| |
| namedExports?: boolean; |
| |
| |
| |
| |
| |
| |
| stringify?: boolean | 'auto'; |
| } |
|
|
| type SSRTarget = 'node' | 'webworker'; |
| type SsrDepOptimizationConfig = DepOptimizationConfig; |
| interface SSROptions { |
| noExternal?: string | RegExp | (string | RegExp)[] | true; |
| external?: string[] | true; |
| |
| |
| |
| |
| |
| |
| target?: SSRTarget; |
| |
| |
| |
| |
| |
| |
| |
| |
| optimizeDeps?: SsrDepOptimizationConfig; |
| resolve?: { |
| |
| |
| |
| |
| |
| |
| |
| conditions?: string[]; |
| |
| |
| |
| |
| |
| externalConditions?: string[]; |
| mainFields?: string[]; |
| }; |
| } |
| interface ResolvedSSROptions extends SSROptions { |
| target: SSRTarget; |
| optimizeDeps: SsrDepOptimizationConfig; |
| } |
|
|
| interface ConfigEnv { |
| |
| |
| |
| |
| command: 'build' | 'serve'; |
| mode: string; |
| isSsrBuild?: boolean; |
| isPreview?: boolean; |
| } |
| |
| |
| |
| |
| |
| |
| |
| type AppType = 'spa' | 'mpa' | 'custom'; |
| type UserConfigFnObject = (env: ConfigEnv) => UserConfig; |
| type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>; |
| type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>; |
| type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn; |
| |
| |
| |
| |
| |
| declare function defineConfig(config: UserConfig): UserConfig; |
| declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>; |
| declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject; |
| declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise; |
| declare function defineConfig(config: UserConfigFn): UserConfigFn; |
| declare function defineConfig(config: UserConfigExport): UserConfigExport; |
| interface CreateDevEnvironmentContext { |
| ws: WebSocketServer; |
| } |
| interface DevEnvironmentOptions { |
| |
| |
| |
| warmup?: string[]; |
| |
| |
| |
| |
| preTransformRequests?: boolean; |
| |
| |
| |
| |
| |
| sourcemap?: boolean | { |
| js?: boolean; |
| css?: boolean; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean); |
| |
| |
| |
| createEnvironment?: (name: string, config: ResolvedConfig, context: CreateDevEnvironmentContext) => Promise<DevEnvironment> | DevEnvironment; |
| |
| |
| |
| |
| |
| |
| recoverable?: boolean; |
| |
| |
| |
| |
| |
| moduleRunnerTransform?: boolean; |
| } |
| type ResolvedDevEnvironmentOptions = Omit<Required<DevEnvironmentOptions>, 'sourcemapIgnoreList'> & { |
| sourcemapIgnoreList: Exclude<DevEnvironmentOptions['sourcemapIgnoreList'], false | undefined>; |
| }; |
| type AllResolveOptions = ResolveOptions & { |
| alias?: AliasOptions; |
| }; |
| interface SharedEnvironmentOptions { |
| |
| |
| |
| |
| define?: Record<string, any>; |
| |
| |
| |
| resolve?: EnvironmentResolveOptions; |
| |
| |
| |
| |
| consumer?: 'client' | 'server'; |
| |
| |
| |
| |
| keepProcessEnv?: boolean; |
| |
| |
| |
| optimizeDeps?: DepOptimizationOptions; |
| } |
| interface EnvironmentOptions extends SharedEnvironmentOptions { |
| |
| |
| |
| dev?: DevEnvironmentOptions; |
| |
| |
| |
| build?: BuildEnvironmentOptions; |
| } |
| type ResolvedResolveOptions = Required<ResolveOptions>; |
| type ResolvedEnvironmentOptions = { |
| define?: Record<string, any>; |
| resolve: ResolvedResolveOptions; |
| consumer: 'client' | 'server'; |
| keepProcessEnv?: boolean; |
| optimizeDeps: DepOptimizationOptions; |
| dev: ResolvedDevEnvironmentOptions; |
| build: ResolvedBuildEnvironmentOptions; |
| }; |
| type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'consumer' | 'resolve' | 'keepProcessEnv'> & { |
| resolve?: AllResolveOptions; |
| }; |
| interface UserConfig extends DefaultEnvironmentOptions { |
| |
| |
| |
| |
| |
| root?: string; |
| |
| |
| |
| |
| base?: string; |
| |
| |
| |
| |
| |
| |
| |
| |
| publicDir?: string | false; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| cacheDir?: string; |
| |
| |
| |
| |
| mode?: string; |
| |
| |
| |
| plugins?: PluginOption[]; |
| |
| |
| |
| html?: HTMLOptions; |
| |
| |
| |
| css?: CSSOptions; |
| |
| |
| |
| json?: JsonOptions; |
| |
| |
| |
| |
| esbuild?: ESBuildOptions | false; |
| |
| |
| |
| assetsInclude?: string | RegExp | (string | RegExp)[]; |
| |
| |
| |
| |
| builder?: BuilderOptions; |
| |
| |
| |
| server?: ServerOptions; |
| |
| |
| |
| preview?: PreviewOptions; |
| |
| |
| |
| |
| |
| |
| |
| experimental?: ExperimentalOptions; |
| |
| |
| |
| future?: FutureOptions; |
| |
| |
| |
| |
| |
| |
| legacy?: LegacyOptions; |
| |
| |
| |
| |
| logLevel?: LogLevel; |
| |
| |
| |
| customLogger?: Logger; |
| |
| |
| |
| clearScreen?: boolean; |
| |
| |
| |
| |
| |
| envDir?: string | false; |
| |
| |
| |
| |
| envPrefix?: string | string[]; |
| |
| |
| |
| worker?: { |
| |
| |
| |
| |
| format?: 'es' | 'iife'; |
| |
| |
| |
| |
| |
| plugins?: () => PluginOption[]; |
| |
| |
| |
| rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>; |
| }; |
| |
| |
| |
| optimizeDeps?: DepOptimizationOptions; |
| |
| |
| |
| |
| |
| ssr?: SSROptions; |
| |
| |
| |
| environments?: Record<string, EnvironmentOptions>; |
| |
| |
| |
| |
| |
| |
| appType?: AppType; |
| } |
| interface HTMLOptions { |
| |
| |
| |
| |
| |
| cspNonce?: string; |
| } |
| interface FutureOptions { |
| removePluginHookHandleHotUpdate?: 'warn'; |
| removePluginHookSsrArgument?: 'warn'; |
| removeServerModuleGraph?: 'warn'; |
| removeServerHot?: 'warn'; |
| removeServerTransformRequest?: 'warn'; |
| removeSsrLoadModule?: 'warn'; |
| } |
| interface ExperimentalOptions { |
| |
| |
| |
| |
| |
| |
| importGlobRestoreExtension?: boolean; |
| |
| |
| |
| |
| |
| renderBuiltUrl?: RenderBuiltAssetUrl; |
| |
| |
| |
| |
| |
| |
| hmrPartialAccept?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| skipSsrTransform?: boolean; |
| } |
| interface LegacyOptions { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| proxySsrExternalModules?: boolean; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| skipWebSocketTokenCheck?: boolean; |
| } |
| interface ResolvedWorkerOptions { |
| format: 'es' | 'iife'; |
| plugins: (bundleChain: string[]) => Promise<ResolvedConfig>; |
| rollupOptions: RollupOptions; |
| } |
| interface InlineConfig extends UserConfig { |
| configFile?: string | false; |
| |
| configLoader?: 'bundle' | 'runner' | 'native'; |
| |
| envFile?: false; |
| forceOptimizeDeps?: boolean; |
| } |
| interface ResolvedConfig extends Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments' | 'server' | 'preview'> & { |
| configFile: string | undefined; |
| configFileDependencies: string[]; |
| inlineConfig: InlineConfig; |
| root: string; |
| base: string; |
| publicDir: string; |
| cacheDir: string; |
| command: 'build' | 'serve'; |
| mode: string; |
| isWorker: boolean; |
| isProduction: boolean; |
| envDir: string | false; |
| env: Record<string, any>; |
| resolve: Required<ResolveOptions> & { |
| alias: Alias[]; |
| }; |
| plugins: readonly Plugin[]; |
| css: ResolvedCSSOptions; |
| json: Required<JsonOptions>; |
| esbuild: ESBuildOptions | false; |
| server: ResolvedServerOptions; |
| dev: ResolvedDevEnvironmentOptions; |
| |
| builder: ResolvedBuilderOptions | undefined; |
| build: ResolvedBuildOptions; |
| preview: ResolvedPreviewOptions; |
| ssr: ResolvedSSROptions; |
| assetsInclude: (file: string) => boolean; |
| logger: Logger; |
| createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn; |
| optimizeDeps: DepOptimizationOptions; |
| worker: ResolvedWorkerOptions; |
| appType: AppType; |
| experimental: ExperimentalOptions; |
| environments: Record<string, ResolvedEnvironmentOptions>; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| webSocketToken: string; |
| } & PluginHookUtils> { |
| } |
| interface PluginHookUtils { |
| getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[]; |
| getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[]; |
| } |
| type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>; |
| declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean, |
| |
| ): Promise<ResolvedConfig>; |
| declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]]; |
| declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger, configLoader?: 'bundle' | 'runner' | 'native'): Promise<{ |
| path: string; |
| config: UserConfig; |
| dependencies: string[]; |
| } | null>; |
|
|
| type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>; |
| |
| |
| |
| |
| declare function createIdResolver(config: ResolvedConfig, options?: Partial<InternalResolveOptions>): ResolveIdFn; |
|
|
| declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string; |
|
|
| |
| |
| |
| interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | 'fetchModule' | 'hmr' | 'transport'> { |
| |
| |
| |
| hmr?: false | { |
| logger?: ModuleRunnerHmr['logger']; |
| }; |
| |
| |
| |
| evaluator?: ModuleEvaluator; |
| } |
| declare const createServerModuleRunnerTransport: (options: { |
| channel: NormalizedServerHotChannel; |
| }) => ModuleRunnerTransport; |
| |
| |
| |
| |
| declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner; |
|
|
| declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): RunnableDevEnvironment; |
| interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, 'hot'> { |
| runner?: (environment: RunnableDevEnvironment, options?: ServerModuleRunnerOptions) => ModuleRunner; |
| runnerOptions?: ServerModuleRunnerOptions; |
| hot?: boolean; |
| } |
| declare function isRunnableDevEnvironment(environment: Environment): environment is RunnableDevEnvironment; |
| declare class RunnableDevEnvironment extends DevEnvironment { |
| private _runner; |
| private _runnerFactory; |
| private _runnerOptions; |
| constructor(name: string, config: ResolvedConfig, context: RunnableDevEnvironmentContext); |
| get runner(): ModuleRunner; |
| close(): Promise<void>; |
| } |
|
|
| interface FetchableDevEnvironmentContext extends DevEnvironmentContext { |
| handleRequest(request: Request): Promise<Response> | Response; |
| } |
| declare function createFetchableDevEnvironment(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext): FetchableDevEnvironment; |
| declare function isFetchableDevEnvironment(environment: Environment): environment is FetchableDevEnvironment; |
| declare class FetchableDevEnvironment extends DevEnvironment { |
| private _handleRequest; |
| constructor(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext); |
| dispatchFetch(request: Request): Promise<Response>; |
| } |
|
|
| interface RunnerImportResult<T> { |
| module: T; |
| dependencies: string[]; |
| } |
| |
| |
| |
| |
| declare function runnerImport<T>(moduleId: string, inlineConfig?: InlineConfig): Promise<RunnerImportResult<T>>; |
|
|
| interface FetchModuleOptions { |
| cached?: boolean; |
| inlineSourceMap?: boolean; |
| startOffset?: number; |
| } |
| |
| |
| |
| |
| declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>; |
|
|
| interface ModuleRunnerTransformOptions { |
| json?: { |
| stringify?: boolean; |
| }; |
| } |
| declare function ssrTransform(code: string, inMap: SourceMap | { |
| mappings: ''; |
| } | null, url: string, originalCode: string, options?: ModuleRunnerTransformOptions): Promise<TransformResult | null>; |
|
|
| declare const VERSION: string; |
| declare const DEFAULT_CLIENT_MAIN_FIELDS: readonly string[]; |
| declare const DEFAULT_SERVER_MAIN_FIELDS: readonly string[]; |
| declare const DEFAULT_CLIENT_CONDITIONS: readonly string[]; |
| declare const DEFAULT_SERVER_CONDITIONS: readonly string[]; |
| declare const defaultAllowedOrigins: RegExp; |
|
|
| declare const isCSSRequest: (request: string) => boolean; |
| |
| |
| |
| declare class SplitVendorChunkCache { |
| cache: Map<string, boolean>; |
| constructor(); |
| reset(): void; |
| } |
| |
| |
| |
| declare function splitVendorChunk(options?: { |
| cache?: SplitVendorChunkCache; |
| }): GetManualChunk; |
| |
| |
| |
| declare function splitVendorChunkPlugin(): Plugin; |
|
|
| |
| |
| |
| type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null; |
| declare const createFilter: (include?: FilterPattern, exclude?: FilterPattern, options?: { |
| resolve?: string | false | null; |
| }) => (id: string | unknown) => boolean; |
| declare const rollupVersion: string; |
| declare function normalizePath(id: string): string; |
| declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>; |
| declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined; |
|
|
| interface SendOptions { |
| etag?: string; |
| cacheControl?: string; |
| headers?: OutgoingHttpHeaders; |
| map?: SourceMap | { |
| mappings: ''; |
| } | null; |
| } |
| declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, options: SendOptions): void; |
|
|
| |
| |
| |
| declare function searchForWorkspaceRoot(current: string, root?: string): string; |
|
|
| |
| |
| |
| |
| declare function isFileServingAllowed(config: ResolvedConfig, url: string): boolean; |
| declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean; |
| declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean; |
|
|
| declare function loadEnv(mode: string, envDir: string | false, prefixes?: string | string[]): Record<string, string>; |
| declare function resolveEnvPrefix({ envPrefix, }: UserConfig): string[]; |
|
|
| type Manifest = Record<string, ManifestChunk>; |
| interface ManifestChunk { |
| src?: string; |
| file: string; |
| css?: string[]; |
| assets?: string[]; |
| isEntry?: boolean; |
| name?: string; |
| isDynamicEntry?: boolean; |
| imports?: string[]; |
| dynamicImports?: string[]; |
| } |
|
|
| export { BuildEnvironment, Connect, DevEnvironment, EnvironmentModuleGraph, EnvironmentModuleNode, FSWatcher, FetchableDevEnvironment, HttpProxy, ModuleGraph, ModuleNode, PluginContainer, RunnableDevEnvironment, SplitVendorChunkCache, Terser, WebSocket, WebSocketAlias, WebSocketServer, build, buildErrorMessage, createBuilder, createFetchableDevEnvironment, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFetchableDevEnvironment, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version }; |
| export type { Alias, AliasOptions, AnymatchFn, AnymatchPattern, AppType, BindCLIShortcutsOptions, BuildEnvironmentOptions, BuildOptions, BuilderOptions, CLIShortcut, CSSModulesOptions, CSSOptions, CommonServerOptions, ConfigEnv, CorsOptions, CorsOrigin, DepOptimizationConfig, DepOptimizationMetadata, DepOptimizationOptions, DevEnvironmentContext, DevEnvironmentOptions, ESBuildOptions, ESBuildTransformResult, Environment, EnvironmentOptions, ExperimentalOptions, ExportsData, FetchModuleOptions, FetchableDevEnvironmentContext, FileSystemServeOptions, FilterPattern, HMRBroadcaster, HMRBroadcasterClient, HMRChannel, HTMLOptions, HmrContext, HmrOptions, HookHandler, HotChannel, HotChannelClient, HotChannelListener, HotUpdateOptions, HtmlTagDescriptor, HttpServer, IndexHtmlTransform, IndexHtmlTransformContext, IndexHtmlTransformHook, IndexHtmlTransformResult, InlineConfig, InternalResolveOptions, JsonOptions, LegacyOptions, LessPreprocessorOptions, LibraryFormats, LibraryOptions, LogErrorOptions, LogLevel, LogOptions, LogType, Logger, LoggerOptions, Manifest, ManifestChunk, MapToFunction, AnymatchMatcher as Matcher, ModulePreloadOptions, ModuleRunnerTransformOptions, NormalizedHotChannel, NormalizedHotChannelClient, NormalizedServerHotChannel, OptimizedDepInfo, Plugin, PluginHookUtils, PluginOption, PreprocessCSSResult, PreviewOptions, PreviewServer, PreviewServerHook, ProxyOptions, RenderBuiltAssetUrl, ResolveFn, ResolveModulePreloadDependenciesFn, ResolveOptions, ResolvedBuildEnvironmentOptions, ResolvedBuildOptions, ResolvedCSSOptions, ResolvedConfig, ResolvedDevEnvironmentOptions, ResolvedModulePreloadOptions, ResolvedPreviewOptions, ResolvedSSROptions, ResolvedServerOptions, ResolvedServerUrls, ResolvedUrl, ResolvedWorkerOptions, ResolverFunction, ResolverObject, RollupCommonJSOptions, RollupDynamicImportVarsOptions, RunnableDevEnvironmentContext, SSROptions, SSRTarget, SassPreprocessorOptions, SendOptions, ServerHMRChannel, ServerHook, ServerHotChannel, ServerModuleRunnerOptions, ServerOptions, SkipInformation, SsrDepOptimizationConfig, StylusPreprocessorOptions, TerserOptions, TransformOptions, TransformResult, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnObject, UserConfigFnPromise, ViteBuilder, ViteDevServer, WatchOptions, WebSocketClient, WebSocketCustomListener }; |
|
|