module.d.ts 5.8 KB

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