Merge pull request #16094 from nuintun/hot-event-optimizing

fix: Fixed apply event callback and optimizing callback event type
This commit is contained in:
Sean Larkin 2023-05-16 08:15:43 -07:00 committed by GitHub
commit 284e71b878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 26 deletions

57
module.d.ts vendored
View File

@ -1,17 +1,5 @@
declare namespace webpack {
type HotEvent =
| {
type: "disposed";
/** The module in question. */
moduleId: number;
}
| {
type: "self-declined" | "unaccepted";
/** The module in question. */
moduleId: number;
/** the chain from where the update was propagated. */
chain: number[];
}
type DeclinedEvent =
| {
type: "declined";
/** The module in question. */
@ -22,6 +10,22 @@ declare namespace webpack {
parentId: number;
}
| {
type: "self-declined";
/** The module in question. */
moduleId: number;
/** the chain from where the update was propagated. */
chain: number[];
};
type UnacceptedEvent = {
type: "unaccepted";
/** The module in question. */
moduleId: number;
/** the chain from where the update was propagated. */
chain: number[];
};
type AcceptedEvent = {
type: "accepted";
/** The module in question. */
moduleId: number;
@ -33,7 +37,15 @@ declare namespace webpack {
outdatedDependencies: {
[id: number]: number[];
};
}
};
type DisposedEvent = {
type: "disposed";
/** The module in question. */
moduleId: number;
};
type ErroredEvent =
| {
type: "accept-error-handler-errored";
/** The module in question. */
@ -71,15 +83,22 @@ declare namespace webpack {
error: Error;
};
type HotEvent =
| DeclinedEvent
| UnacceptedEvent
| AcceptedEvent
| DisposedEvent
| ErroredEvent;
interface ApplyOptions {
ignoreUnaccepted?: boolean;
ignoreDeclined?: boolean;
ignoreErrored?: boolean;
onDeclined?(callback: (info: HotEvent) => void): void;
onUnaccepted?(callback: (info: HotEvent) => void): void;
onAccepted?(callback: (info: HotEvent) => void): void;
onDisposed?(callback: (info: HotEvent) => void): void;
onErrored?(callback: (info: HotEvent) => void): void;
onDeclined?: (event: DeclinedEvent) => void;
onUnaccepted?: (event: UnacceptedEvent) => void;
onAccepted?: (event: AcceptedEvent) => void;
onDisposed?: (event: DisposedEvent) => void;
onErrored?: (event: ErroredEvent) => void;
}
const enum HotUpdateStatus {