UNPKG

5.95 kBTypeScriptView Raw
1declare 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
74 interface ApplyOptions {
75 ignoreUnaccepted?: boolean;
76 ignoreDeclined?: boolean;
77 ignoreErrored?: boolean;
78 onDeclined?(callback: (info: HotEvent) => void): void;
79 onUnaccepted?(callback: (info: HotEvent) => void): void;
80 onAccepted?(callback: (info: HotEvent) => void): void;
81 onDisposed?(callback: (info: HotEvent) => void): void;
82 onErrored?(callback: (info: HotEvent) => void): void;
83 }
84
85 const enum HotUpdateStatus {
86 idle = "idle",
87 check = "check",
88 prepare = "prepare",
89 ready = "ready",
90 dispose = "dispose",
91 apply = "apply",
92 abort = "abort",
93 fail = "fail"
94 }
95
96 interface Hot {
97 accept: {
98 (
99 modules: string | string[],
100 callback?: (outdatedDependencies: string[]) => void,
101 errorHandler?: (
102 err: Error,
103 context: { moduleId: string | number; dependencyId: string | number }
104 ) => void
105 ): void;
106 (
107 errorHandler?: (
108 err: Error,
109 ids: { moduleId: string | number; module: NodeJS.Module }
110 ) => void
111 ): void;
112 };
113 status(): HotUpdateStatus;
114 decline(module?: string | string[]): void;
115 dispose(callback: (data: object) => void): void;
116 addDisposeHandler(callback: (data: object) => void): void;
117 removeDisposeHandler(callback: (data: object) => void): void;
118 invalidate(): void;
119 addStatusHandler(callback: (status: HotUpdateStatus) => void): void;
120 removeStatusHandler(callback: (status: HotUpdateStatus) => void): void;
121 data: object;
122 check(
123 autoApply?: boolean | ApplyOptions
124 ): Promise<(string | number)[] | null>;
125 apply(options?: ApplyOptions): Promise<(string | number)[] | null>;
126 }
127
128 interface ExportInfo {
129 used: boolean;
130 provideInfo: boolean | null | undefined;
131 useInfo: boolean | null | undefined;
132 canMangle: boolean;
133 }
134
135 interface ExportsInfo {
136 [k: string]: ExportInfo & ExportsInfo;
137 }
138
139 interface Context {
140 resolve(dependency: string): string | number;
141 keys(): Array<string>;
142 id: string | number;
143 (dependency: string): unknown;
144 }
145}
146
147interface ImportMeta {
148 url: string;
149 webpack: number;
150 webpackHot: webpack.Hot;
151 webpackContext: (
152 request: string,
153 options?: {
154 recursive?: boolean;
155 regExp?: RegExp;
156 include?: RegExp;
157 exclude?: RegExp;
158 preload?: boolean | number;
159 prefetch?: boolean | number;
160 chunkName?: string;
161 exports?: string | string[][];
162 mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
163 }
164 ) => webpack.Context;
165}
166
167declare const __resourceQuery: string;
168declare var __webpack_public_path__: string;
169declare var __webpack_nonce__: string;
170declare const __webpack_chunkname__: string;
171declare var __webpack_base_uri__: string;
172declare var __webpack_runtime_id__: string;
173declare const __webpack_hash__: string;
174declare const __webpack_modules__: Record<string | number, NodeJS.Module>;
175declare const __webpack_require__: (id: string | number) => unknown;
176declare var __webpack_chunk_load__: (chunkId: string | number) => Promise<void>;
177declare var __webpack_get_script_filename__: (
178 chunkId: string | number
179) => string;
180declare var __webpack_is_included__: (request: string) => boolean;
181declare var __webpack_exports_info__: webpack.ExportsInfo;
182declare const __webpack_share_scopes__: Record<
183 string,
184 Record<
185 string,
186 { loaded?: 1; get: () => Promise<unknown>; from: string; eager: boolean }
187 >
188>;
189declare var __webpack_init_sharing__: (scope: string) => Promise<void>;
190declare var __non_webpack_require__: (id: any) => unknown;
191declare const __system_context__: object;
192
193declare namespace NodeJS {
194 interface Module {
195 hot: webpack.Hot;
196 }
197
198 interface Require {
199 ensure(
200 dependencies: string[],
201 callback: (require: (module: string) => void) => void,
202 errorCallback?: (error: Error) => void,
203 chunkName?: string
204 ): void;
205 context(
206 request: string,
207 includeSubdirectories?: boolean,
208 filter?: RegExp,
209 mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once"
210 ): webpack.Context;
211 include(dependency: string): void;
212 resolveWeak(dependency: string): void;
213 onError?: (error: Error) => void;
214 }
215}