-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathplugin.ts
More file actions
52 lines (40 loc) · 1.33 KB
/
plugin.ts
File metadata and controls
52 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as puppeteer from "puppeteer";
import {Instagram, TFullApiPost, TPost, TSearchResult, TSinglePost} from "..";
export type DType = TPost | TSinglePost | TFullApiPost | TSearchResult;
export interface IPluginContext<Plugin, PostType> {
plugin: Plugin;
state: Instagram<PostType>;
}
export interface IPlugin<PostType> {
constructionEvent?(this: IPluginContext<IPlugin<PostType>, PostType>): void;
requestEvent?(
this: IPluginContext<IPlugin<PostType>, PostType>,
req: puppeteer.Request,
overrides: puppeteer.Overrides,
): Promise<void>;
responseEvent?(
this: IPluginContext<IPlugin<PostType>, PostType>,
res: puppeteer.Response,
data: {[key: string]: any},
): Promise<void>;
postPageEvent?(
this: IPluginContext<IPlugin<PostType>, PostType>,
data: PostType,
): Promise<void>;
graftingEvent?(
this: IPluginContext<IPlugin<PostType>, PostType>,
): Promise<void>;
}
export enum AsyncPluginEvents {
browser,
grafting,
postPage,
request,
response,
}
export type AsyncPluginEventsType = keyof typeof AsyncPluginEvents;
export enum SyncPluginEvents {
construction,
}
export type SyncPluginEventsType = keyof typeof SyncPluginEvents;
export type PluginEventsType = SyncPluginEventsType | AsyncPluginEventsType;