module.d.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. declare namespace webpack {
  2. type DeclinedEvent =
  3. | {
  4. type: "declined";
  5. /** The module in question. */
  6. moduleId: number | string;
  7. /** the chain from where the update was propagated. */
  8. chain: (number | string)[];
  9. /** the module id of the declining parent */
  10. parentId: number | string;
  11. }
  12. | {
  13. type: "self-declined";
  14. /** The module in question. */
  15. moduleId: number | string;
  16. /** the chain from where the update was propagated. */
  17. chain: (number | string)[];
  18. };
  19. type UnacceptedEvent = {
  20. type: "unaccepted";
  21. /** The module in question. */
  22. moduleId: number | string;
  23. /** the chain from where the update was propagated. */
  24. chain: (number | string)[];
  25. };
  26. type AcceptedEvent = {
  27. type: "accepted";
  28. /** The module in question. */
  29. moduleId: number | string;
  30. /** the modules that are outdated and will be disposed */
  31. outdatedModules: (number | string)[];
  32. /** the accepted dependencies that are outdated */
  33. outdatedDependencies: {
  34. [id: number]: (number | string)[];
  35. };
  36. };
  37. type DisposedEvent = {
  38. type: "disposed";
  39. /** The module in question. */
  40. moduleId: number | string;
  41. };
  42. type ErroredEvent =
  43. | {
  44. type: "accept-error-handler-errored";
  45. /** The module in question. */
  46. moduleId: number | string;
  47. /** the module id owning the accept handler. */
  48. dependencyId: number | string;
  49. /** the thrown error */
  50. error: Error;
  51. /** the error thrown by the module before the error handler tried to handle it. */
  52. originalError: Error;
  53. }
  54. | {
  55. type: "self-accept-error-handler-errored";
  56. /** The module in question. */
  57. moduleId: number | string;
  58. /** the thrown error */
  59. error: Error;
  60. /** the error thrown by the module before the error handler tried to handle it. */
  61. originalError: Error;
  62. }
  63. | {
  64. type: "accept-errored";
  65. /** The module in question. */
  66. moduleId: number | string;
  67. /** the module id owning the accept handler. */
  68. dependencyId: number | string;
  69. /** the thrown error */
  70. error: Error;
  71. }
  72. | {
  73. type: "self-accept-errored";
  74. /** The module in question. */
  75. moduleId: number | string;
  76. /** the thrown error */
  77. error: Error;
  78. };
  79. type HotEvent =
  80. | DeclinedEvent
  81. | UnacceptedEvent
  82. | AcceptedEvent
  83. | DisposedEvent
  84. | ErroredEvent;
  85. interface ApplyOptions {
  86. ignoreUnaccepted?: boolean;
  87. ignoreDeclined?: boolean;
  88. ignoreErrored?: boolean;
  89. onDeclined?: (event: DeclinedEvent) => void;
  90. onUnaccepted?: (event: UnacceptedEvent) => void;
  91. onAccepted?: (event: AcceptedEvent) => void;
  92. onDisposed?: (event: DisposedEvent) => void;
  93. onErrored?: (event: ErroredEvent) => void;
  94. }
  95. const enum HotUpdateStatus {
  96. idle = "idle",
  97. check = "check",
  98. prepare = "prepare",
  99. ready = "ready",
  100. dispose = "dispose",
  101. apply = "apply",
  102. abort = "abort",
  103. fail = "fail"
  104. }
  105. interface Hot {
  106. accept: {
  107. (
  108. modules: string | string[],
  109. callback?: (outdatedDependencies: string[]) => void,
  110. errorHandler?: (
  111. err: Error,
  112. context: { moduleId: string | number; dependencyId: string | number }
  113. ) => void
  114. ): void;
  115. (
  116. errorHandler?: (
  117. err: Error,
  118. ids: { moduleId: string | number; module: NodeJS.Module }
  119. ) => void
  120. ): void;
  121. };
  122. status(): HotUpdateStatus;
  123. decline(module?: string | string[]): void;
  124. dispose(callback: (data: object) => void): void;
  125. addDisposeHandler(callback: (data: object) => void): void;
  126. removeDisposeHandler(callback: (data: object) => void): void;
  127. invalidate(): void;
  128. addStatusHandler(callback: (status: HotUpdateStatus) => void): void;
  129. removeStatusHandler(callback: (status: HotUpdateStatus) => void): void;
  130. data: object;
  131. check(
  132. autoApply?: boolean | ApplyOptions
  133. ): Promise<(string | number)[] | null>;
  134. apply(options?: ApplyOptions): Promise<(string | number)[] | null>;
  135. }
  136. interface ExportInfo {
  137. used: boolean;
  138. provideInfo: boolean | null | undefined;
  139. useInfo: boolean | null | undefined;
  140. canMangle: boolean;
  141. }
  142. interface ExportsInfo {
  143. [k: string]: ExportInfo & ExportsInfo;
  144. }
  145. interface Context {
  146. resolve(dependency: string): string | number;
  147. keys(): Array<string>;
  148. id: string | number;
  149. (dependency: string): unknown;
  150. }
  151. type ImportMetaGlobPattern = string | readonly string[];
  152. type ImportMetaGlobQuery = string | Record<string, string | number | boolean>;
  153. type ImportMetaGlobOptions<Eager extends boolean = boolean> = {
  154. eager?: Eager;
  155. import?: string;
  156. query?: ImportMetaGlobQuery;
  157. exhaustive?: boolean;
  158. base?: string;
  159. caseSensitive?: boolean;
  160. };
  161. }
  162. interface ImportMetaEnv {
  163. [key: string]: string | boolean | undefined;
  164. }
  165. interface ImportMeta {
  166. url: string;
  167. webpack: number;
  168. webpackHot: webpack.Hot;
  169. env: ImportMetaEnv;
  170. webpackContext: (
  171. request: string,
  172. options?: {
  173. recursive?: boolean;
  174. regExp?: RegExp;
  175. include?: RegExp;
  176. exclude?: RegExp;
  177. preload?: boolean | number;
  178. prefetch?: boolean | number;
  179. fetchPriority?: "low" | "high" | "auto";
  180. chunkName?: string;
  181. exports?: string | string[][];
  182. mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
  183. }
  184. ) => webpack.Context;
  185. glob: {
  186. <T = unknown>(
  187. pattern: webpack.ImportMetaGlobPattern,
  188. options?: webpack.ImportMetaGlobOptions<false>
  189. ): Record<string, () => Promise<T>>;
  190. <T = unknown>(
  191. pattern: webpack.ImportMetaGlobPattern,
  192. options: webpack.ImportMetaGlobOptions<true>
  193. ): Record<string, T>;
  194. };
  195. }
  196. declare const __resourceQuery: string;
  197. declare var __webpack_public_path__: string;
  198. declare var __webpack_nonce__: string;
  199. declare const __webpack_chunkname__: string;
  200. declare var __webpack_base_uri__: string;
  201. declare var __webpack_runtime_id__: string;
  202. declare const __webpack_hash__: string;
  203. declare const __webpack_css_server_styles__: string;
  204. declare const __webpack_modules__: Record<string | number, NodeJS.Module>;
  205. declare const __webpack_require__: (id: string | number) => unknown;
  206. declare var __webpack_chunk_load__: (chunkId: string | number) => Promise<void>;
  207. declare var __webpack_get_script_filename__: (
  208. chunkId: string | number
  209. ) => string;
  210. declare var __webpack_is_included__: (request: string) => boolean;
  211. declare var __webpack_exports_info__: webpack.ExportsInfo;
  212. declare const __webpack_share_scopes__: Record<
  213. string,
  214. Record<
  215. string,
  216. { loaded?: 1; get: () => Promise<unknown>; from: string; eager: boolean }
  217. >
  218. >;
  219. declare var __webpack_init_sharing__: (scope: string) => Promise<void>;
  220. declare var __non_webpack_require__: (id: any) => unknown;
  221. declare const __system_context__: object;
  222. declare namespace NodeJS {
  223. interface Module {
  224. hot: webpack.Hot;
  225. }
  226. interface Require {
  227. ensure(
  228. dependencies: string[],
  229. callback: (require: (module: string) => void) => void,
  230. errorCallback?: (error: Error) => void,
  231. chunkName?: string
  232. ): void;
  233. context(
  234. request: string,
  235. includeSubdirectories?: boolean,
  236. filter?: RegExp,
  237. mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once"
  238. ): webpack.Context;
  239. include(dependency: string): void;
  240. resolveWeak(dependency: string): void;
  241. onError?: (error: Error) => void;
  242. }
  243. }