runtime.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { V as ViteRuntimeOptions, b as ViteModuleRunner, M as ModuleCacheMap, c as HMRClient, R as ResolvedResult, d as ViteRuntimeModuleContext } from './types.d-aGj9QkWt.js';
  2. export { a as FetchFunction, F as FetchResult, e as HMRConnection, H as HMRLogger, g as HMRRuntimeConnection, f as ModuleCache, S as SSRImportMetadata, h as ViteRuntimeImportMeta, s as ssrDynamicImportKey, i as ssrExportAllKey, j as ssrImportKey, k as ssrImportMetaKey, l as ssrModuleExportsKey } from './types.d-aGj9QkWt.js';
  3. import '../../types/hot.js';
  4. import '../../types/hmrPayload.js';
  5. import '../../types/customEvent.js';
  6. interface ViteRuntimeDebugger {
  7. (formatter: unknown, ...args: unknown[]): void;
  8. }
  9. declare class ViteRuntime {
  10. options: ViteRuntimeOptions;
  11. runner: ViteModuleRunner;
  12. private debug?;
  13. /**
  14. * Holds the cache of modules
  15. * Keys of the map are ids
  16. */
  17. moduleCache: ModuleCacheMap;
  18. hmrClient?: HMRClient;
  19. entrypoints: Set<string>;
  20. private idToUrlMap;
  21. private fileToIdMap;
  22. private envProxy;
  23. private _destroyed;
  24. private _resetSourceMapSupport?;
  25. constructor(options: ViteRuntimeOptions, runner: ViteModuleRunner, debug?: ViteRuntimeDebugger | undefined);
  26. /**
  27. * URL to execute. Accepts file path, server path or id relative to the root.
  28. */
  29. executeUrl<T = any>(url: string): Promise<T>;
  30. /**
  31. * Entrypoint URL to execute. Accepts file path, server path or id relative to the root.
  32. * In the case of a full reload triggered by HMR, this is the module that will be reloaded.
  33. * If this method is called multiple times, all entrypoints will be reloaded one at a time.
  34. */
  35. executeEntrypoint<T = any>(url: string): Promise<T>;
  36. /**
  37. * Clear all caches including HMR listeners.
  38. */
  39. clearCache(): void;
  40. /**
  41. * Clears all caches, removes all HMR listeners, and resets source map support.
  42. * This method doesn't stop the HMR connection.
  43. */
  44. destroy(): Promise<void>;
  45. /**
  46. * Returns `true` if the runtime has been destroyed by calling `destroy()` method.
  47. */
  48. isDestroyed(): boolean;
  49. private invalidateFiles;
  50. private normalizeEntryUrl;
  51. private processImport;
  52. private cachedRequest;
  53. private cachedModule;
  54. protected directRequest(id: string, fetchResult: ResolvedResult, _callstack: string[]): Promise<any>;
  55. }
  56. declare class ESModulesRunner implements ViteModuleRunner {
  57. runViteModule(context: ViteRuntimeModuleContext, code: string): Promise<any>;
  58. runExternalModule(filepath: string): Promise<any>;
  59. }
  60. export { ESModulesRunner, ModuleCacheMap, ResolvedResult, ViteModuleRunner, ViteRuntime, ViteRuntimeModuleContext, ViteRuntimeOptions };