|
|
import { a as ExternalFetchResult, c as ViteFetchResult, i as createWebSocketModuleRunnerTransport, n as ModuleRunnerTransportHandlers, o as FetchFunctionOptions, r as NormalizedModuleRunnerTransport, s as FetchResult, t as ModuleRunnerTransport } from "./chunks/moduleRunnerTransport.js"; |
|
|
import { ModuleNamespace, ViteHotContext } from "#types/hot"; |
|
|
import { HotPayload, Update } from "#types/hmrPayload"; |
|
|
import { InferCustomEventPayload } from "#types/customEvent"; |
|
|
|
|
|
|
|
|
interface SourceMapLike { |
|
|
version: number; |
|
|
mappings?: string; |
|
|
names?: string[]; |
|
|
sources?: string[]; |
|
|
sourcesContent?: string[]; |
|
|
} |
|
|
declare class DecodedMap { |
|
|
map: SourceMapLike; |
|
|
_encoded: string; |
|
|
_decoded: undefined | number[][][]; |
|
|
_decodedMemo: Stats; |
|
|
url: string; |
|
|
file: string; |
|
|
version: number; |
|
|
names: string[]; |
|
|
resolvedSources: string[]; |
|
|
constructor(map: SourceMapLike, from: string); |
|
|
} |
|
|
interface Stats { |
|
|
lastKey: number; |
|
|
lastNeedle: number; |
|
|
lastIndex: number; |
|
|
} |
|
|
|
|
|
|
|
|
type CustomListenersMap = Map<string, ((data: any) => void)[]>; |
|
|
interface HotModule { |
|
|
id: string; |
|
|
callbacks: HotCallback[]; |
|
|
} |
|
|
interface HotCallback { |
|
|
deps: string[]; |
|
|
fn: (modules: Array<ModuleNamespace | undefined>) => void; |
|
|
} |
|
|
interface HMRLogger { |
|
|
error(msg: string | Error): void; |
|
|
debug(...msg: unknown[]): void; |
|
|
} |
|
|
declare class HMRClient { |
|
|
logger: HMRLogger; |
|
|
private transport; |
|
|
private importUpdatedModule; |
|
|
hotModulesMap: Map<string, HotModule>; |
|
|
disposeMap: Map<string, (data: any) => void | Promise<void>>; |
|
|
pruneMap: Map<string, (data: any) => void | Promise<void>>; |
|
|
dataMap: Map<string, any>; |
|
|
customListenersMap: CustomListenersMap; |
|
|
ctxToListenersMap: Map<string, CustomListenersMap>; |
|
|
currentFirstInvalidatedBy: string | undefined; |
|
|
constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>); |
|
|
notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>; |
|
|
send(payload: HotPayload): void; |
|
|
clear(): void; |
|
|
prunePaths(paths: string[]): Promise<void>; |
|
|
protected warnFailedUpdate(err: Error, path: string | string[]): void; |
|
|
private updateQueue; |
|
|
private pendingUpdateQueue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queueUpdate(payload: Update): Promise<void>; |
|
|
private fetchUpdate; |
|
|
} |
|
|
|
|
|
|
|
|
interface DefineImportMetadata { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
importedNames?: string[]; |
|
|
} |
|
|
interface SSRImportMetadata extends DefineImportMetadata { |
|
|
isDynamicImport?: boolean; |
|
|
} |
|
|
|
|
|
|
|
|
declare const ssrModuleExportsKey = "__vite_ssr_exports__"; |
|
|
declare const ssrImportKey = "__vite_ssr_import__"; |
|
|
declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__"; |
|
|
declare const ssrExportAllKey = "__vite_ssr_exportAll__"; |
|
|
declare const ssrExportNameKey = "__vite_ssr_exportName__"; |
|
|
declare const ssrImportMetaKey = "__vite_ssr_import_meta__"; |
|
|
|
|
|
|
|
|
interface ModuleRunnerDebugger { |
|
|
(formatter: unknown, ...args: unknown[]): void; |
|
|
} |
|
|
declare class ModuleRunner { |
|
|
options: ModuleRunnerOptions; |
|
|
evaluator: ModuleEvaluator; |
|
|
private debug?; |
|
|
evaluatedModules: EvaluatedModules; |
|
|
hmrClient?: HMRClient; |
|
|
private readonly transport; |
|
|
private readonly resetSourceMapSupport?; |
|
|
private readonly concurrentModuleNodePromises; |
|
|
private isBuiltin?; |
|
|
private builtinsPromise?; |
|
|
private closed; |
|
|
constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined); |
|
|
|
|
|
|
|
|
|
|
|
import<T = any>(url: string): Promise<T>; |
|
|
|
|
|
|
|
|
|
|
|
clearCache(): void; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close(): Promise<void>; |
|
|
|
|
|
|
|
|
|
|
|
isClosed(): boolean; |
|
|
private processImport; |
|
|
private isCircularModule; |
|
|
private isCircularImport; |
|
|
private cachedRequest; |
|
|
private cachedModule; |
|
|
private ensureBuiltins; |
|
|
private getModuleInformation; |
|
|
protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>; |
|
|
} |
|
|
|
|
|
|
|
|
interface RetrieveFileHandler { |
|
|
(path: string): string | null | undefined | false; |
|
|
} |
|
|
interface RetrieveSourceMapHandler { |
|
|
(path: string): null | { |
|
|
url: string; |
|
|
map: any; |
|
|
}; |
|
|
} |
|
|
interface InterceptorOptions { |
|
|
retrieveFile?: RetrieveFileHandler; |
|
|
retrieveSourceMap?: RetrieveSourceMapHandler; |
|
|
} |
|
|
|
|
|
|
|
|
interface ModuleRunnerImportMeta extends ImportMeta { |
|
|
url: string; |
|
|
env: ImportMetaEnv; |
|
|
hot?: ViteHotContext; |
|
|
[key: string]: any; |
|
|
} |
|
|
interface ModuleRunnerContext { |
|
|
[ssrModuleExportsKey]: Record<string, any>; |
|
|
[ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>; |
|
|
[ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>; |
|
|
[ssrExportAllKey]: (obj: any) => void; |
|
|
[ssrExportNameKey]: (name: string, getter: () => unknown) => void; |
|
|
[ssrImportMetaKey]: ModuleRunnerImportMeta; |
|
|
} |
|
|
interface ModuleEvaluator { |
|
|
|
|
|
|
|
|
|
|
|
startOffset?: number; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runExternalModule(file: string): Promise<any>; |
|
|
} |
|
|
type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & { |
|
|
url: string; |
|
|
id: string; |
|
|
}; |
|
|
type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>; |
|
|
interface ModuleRunnerHmr { |
|
|
|
|
|
|
|
|
|
|
|
logger?: false | HMRLogger; |
|
|
} |
|
|
interface ModuleRunnerOptions { |
|
|
|
|
|
|
|
|
|
|
|
transport: ModuleRunnerTransport; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sourcemapInterceptor?: false | "node" | "prepareStackTrace" | InterceptorOptions; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hmr?: boolean | ModuleRunnerHmr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createImportMeta?: (modulePath: string) => ModuleRunnerImportMeta | Promise<ModuleRunnerImportMeta>; |
|
|
|
|
|
|
|
|
|
|
|
evaluatedModules?: EvaluatedModules; |
|
|
} |
|
|
interface ImportMetaEnv { |
|
|
[key: string]: any; |
|
|
BASE_URL: string; |
|
|
MODE: string; |
|
|
DEV: boolean; |
|
|
PROD: boolean; |
|
|
SSR: boolean; |
|
|
} |
|
|
|
|
|
|
|
|
declare class EvaluatedModuleNode { |
|
|
id: string; |
|
|
url: string; |
|
|
importers: Set<string>; |
|
|
imports: Set<string>; |
|
|
evaluated: boolean; |
|
|
meta: ResolvedResult | undefined; |
|
|
promise: Promise<any> | undefined; |
|
|
exports: any | undefined; |
|
|
file: string; |
|
|
map: DecodedMap | undefined; |
|
|
constructor(id: string, url: string); |
|
|
} |
|
|
declare class EvaluatedModules { |
|
|
readonly idToModuleMap: Map<string, EvaluatedModuleNode>; |
|
|
readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>; |
|
|
readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getModuleById(id: string): EvaluatedModuleNode | undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getModuleByUrl(url: string): EvaluatedModuleNode | undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ensureModule(id: string, url: string): EvaluatedModuleNode; |
|
|
invalidateModule(node: EvaluatedModuleNode): void; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getModuleSourceMapById(id: string): DecodedMap | null; |
|
|
clear(): void; |
|
|
} |
|
|
declare function normalizeModuleId(file: string): string; |
|
|
|
|
|
|
|
|
declare class ESModulesEvaluator implements ModuleEvaluator { |
|
|
readonly startOffset: number; |
|
|
runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>; |
|
|
runExternalModule(filepath: string): Promise<any>; |
|
|
} |
|
|
|
|
|
|
|
|
declare function createDefaultImportMeta(modulePath: string): ModuleRunnerImportMeta; |
|
|
|
|
|
|
|
|
|
|
|
declare function createNodeImportMeta(modulePath: string): Promise<ModuleRunnerImportMeta>; |
|
|
|
|
|
export { ESModulesEvaluator, type EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRLogger, type InterceptorOptions, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, type ModuleRunnerTransport, type ModuleRunnerTransportHandlers, type ResolvedResult, type SSRImportMetadata, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey }; |