2021-08-14 12:59:08 +00:00
|
|
|
declare namespace SocketIO {
|
2021-05-09 13:23:58 +00:00
|
|
|
type EventType = NumEventType | NullEventType | SpecialEventType;
|
|
|
|
|
|
|
|
type NumEventType =
|
2021-05-08 14:25:29 +00:00
|
|
|
| "movie"
|
|
|
|
| "series"
|
|
|
|
| "episode"
|
|
|
|
| "episode-wanted"
|
2021-05-09 13:23:58 +00:00
|
|
|
| "movie-wanted";
|
|
|
|
|
|
|
|
type NullEventType =
|
|
|
|
| "connect"
|
|
|
|
| "connect_error"
|
|
|
|
| "disconnect"
|
|
|
|
| "episode-blacklist"
|
|
|
|
| "episode-history"
|
2021-05-08 14:25:29 +00:00
|
|
|
| "movie-blacklist"
|
2021-05-09 13:23:58 +00:00
|
|
|
| "movie-history"
|
2021-08-30 02:05:54 +00:00
|
|
|
| "reset-episode-wanted"
|
|
|
|
| "reset-movie-wanted"
|
2021-05-08 14:25:29 +00:00
|
|
|
| "badges"
|
|
|
|
| "task"
|
|
|
|
| "settings"
|
2021-05-09 13:23:58 +00:00
|
|
|
| "languages";
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2021-05-09 13:23:58 +00:00
|
|
|
type SpecialEventType = "message" | "progress";
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2021-08-14 12:59:08 +00:00
|
|
|
type ActionType = "update" | "delete";
|
|
|
|
|
2022-03-16 06:26:15 +00:00
|
|
|
type PayloadType = number | string | CustomEvent.Progress;
|
|
|
|
|
|
|
|
type ReducerGroup<
|
|
|
|
E extends EventType,
|
|
|
|
U extends PayloadType | undefined,
|
|
|
|
D = U
|
|
|
|
> = ValueOf<{
|
|
|
|
[P in E]: {
|
|
|
|
key: P;
|
|
|
|
any?: ActionHandler<undefined>;
|
|
|
|
update?: ActionHandler<U>;
|
|
|
|
delete?: ActionHandler<D>;
|
|
|
|
};
|
|
|
|
}>;
|
2021-05-09 13:23:58 +00:00
|
|
|
|
|
|
|
type Event = {
|
2021-05-08 14:25:29 +00:00
|
|
|
type: EventType;
|
2021-08-14 12:59:08 +00:00
|
|
|
action: ActionType;
|
2022-03-16 06:26:15 +00:00
|
|
|
payload?: PayloadType;
|
2021-05-09 13:23:58 +00:00
|
|
|
};
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2022-03-16 06:26:15 +00:00
|
|
|
type ActionHandler<T> = T extends undefined
|
|
|
|
? () => void
|
|
|
|
: (payload: T[]) => void;
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2021-05-09 13:23:58 +00:00
|
|
|
type Reducer =
|
2022-03-16 06:26:15 +00:00
|
|
|
| ReducerGroup<NumEventType, number>
|
|
|
|
| ReducerGroup<NullEventType, undefined>
|
|
|
|
| ReducerGroup<"message", string>
|
|
|
|
| ReducerGroup<"progress", CustomEvent.Progress, string>;
|
2021-05-08 14:25:29 +00:00
|
|
|
|
2021-08-14 12:59:08 +00:00
|
|
|
type ActionRecord = {
|
|
|
|
[P in EventType]?: {
|
2022-03-16 06:26:15 +00:00
|
|
|
[R in ActionType]?: PayloadType[];
|
2021-08-14 12:59:08 +00:00
|
|
|
};
|
|
|
|
};
|
2021-05-09 08:41:19 +00:00
|
|
|
|
|
|
|
namespace CustomEvent {
|
2021-08-21 16:44:52 +00:00
|
|
|
type Progress = Site.Progress;
|
2021-05-09 08:41:19 +00:00
|
|
|
}
|
2021-05-08 14:25:29 +00:00
|
|
|
}
|