module.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. }
  152. interface ImportMeta {
  153. url: string;
  154. webpack: number;
  155. webpackHot: webpack.Hot;
  156. webpackContext: (
  157. request: string,
  158. options?: {
  159. recursive?: boolean;
  160. regExp?: RegExp;
  161. include?: RegExp;
  162. exclude?: RegExp;
  163. preload?: boolean | number;
  164. prefetch?: boolean | number;
  165. fetchPriority?: "low" | "high" | "auto";
  166. chunkName?: string;
  167. exports?: string | string[][];
  168. mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
  169. }
  170. ) => webpack.Context;
  171. }
  172. declare const __resourceQuery: string;
  173. declare var __webpack_public_path__: string;
  174. declare var __webpack_nonce__: string;
  175. declare const __webpack_chunkname__: string;
  176. declare var __webpack_base_uri__: string;
  177. declare var __webpack_runtime_id__: string;
  178. declare const __webpack_hash__: string;
  179. declare const __webpack_modules__: Record<string | number, NodeJS.Module>;
  180. declare const __webpack_require__: (id: string | number) => unknown;
  181. declare var __webpack_chunk_load__: (chunkId: string | number) => Promise<void>;
  182. declare var __webpack_get_script_filename__: (
  183. chunkId: string | number
  184. ) => string;
  185. declare var __webpack_is_included__: (request: string) => boolean;
  186. declare var __webpack_exports_info__: webpack.ExportsInfo;
  187. declare const __webpack_share_scopes__: Record<
  188. string,
  189. Record<
  190. string,
  191. { loaded?: 1; get: () => Promise<unknown>; from: string; eager: boolean }
  192. >
  193. >;
  194. declare var __webpack_init_sharing__: (scope: string) => Promise<void>;
  195. declare var __non_webpack_require__: (id: any) => unknown;
  196. declare const __system_context__: object;
  197. declare namespace NodeJS {
  198. interface Module {
  199. hot: webpack.Hot;
  200. }
  201. interface Require {
  202. ensure(
  203. dependencies: string[],
  204. callback: (require: (module: string) => void) => void,
  205. errorCallback?: (error: Error) => void,
  206. chunkName?: string
  207. ): void;
  208. context(
  209. request: string,
  210. includeSubdirectories?: boolean,
  211. filter?: RegExp,
  212. mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once"
  213. ): webpack.Context;
  214. include(dependency: string): void;
  215. resolveWeak(dependency: string): void;
  216. onError?: (error: Error) => void;
  217. }
  218. }