this repo has no description
1import { ExtensionSettingsManifest } from "./config";
2import { Snowflake } from "./discord";
3import { WebpackModuleFunc } from "./discord/webpack";
4
5export enum ExtensionTag {
6 Accessibility = "accessibility",
7 Appearance = "appearance",
8 Chat = "chat",
9 Commands = "commands",
10 ContextMenu = "contextMenu",
11 DangerZone = "dangerZone",
12 Development = "development",
13 Fixes = "fixes",
14 Fun = "fun",
15 Markdown = "markdown",
16 Voice = "voice",
17 Privacy = "privacy",
18 Profiles = "profiles",
19 QualityOfLife = "qol",
20 Library = "library"
21}
22
23export type ExtensionAuthor =
24 | string
25 | {
26 name: string;
27 id?: Snowflake;
28 };
29
30export type ExtensionManifest = {
31 id: string;
32 version?: string;
33
34 meta?: {
35 name?: string;
36 tagline?: string;
37 description?: string;
38 authors?: ExtensionAuthor[];
39 deprecated?: boolean;
40 tags?: ExtensionTag[];
41 source?: string;
42 };
43
44 dependencies?: string[];
45 suggested?: string[];
46 incompatible?: string[]; // TODO: implement
47
48 settings?: Record<string, ExtensionSettingsManifest>;
49 cors?: string[];
50};
51
52export enum ExtensionLoadSource {
53 Developer,
54 Core,
55 Normal
56}
57
58export type DetectedExtension = {
59 id: string;
60 manifest: ExtensionManifest;
61 source: { type: ExtensionLoadSource; url?: string };
62 scripts: {
63 web?: string;
64 webPath?: string;
65 webpackModules?: Record<string, string>;
66 nodePath?: string;
67 hostPath?: string;
68 };
69};
70
71export type ProcessedExtensions = {
72 extensions: DetectedExtension[];
73 dependencyGraph: Map<string, Set<string> | null>;
74};
75
76export type PatchMatch = string | RegExp;
77export type PatchReplaceFn = (substring: string, ...args: string[]) => string;
78export type PatchReplaceModule = (orig: string) => WebpackModuleFunc;
79
80export enum PatchReplaceType {
81 Normal,
82 Module
83}
84
85export type PatchReplace =
86 | {
87 type?: PatchReplaceType.Normal;
88 match: PatchMatch;
89 replacement: string | PatchReplaceFn;
90 }
91 | {
92 type: PatchReplaceType.Module;
93 replacement: PatchReplaceModule;
94 };
95
96export type Patch = {
97 find: PatchMatch;
98 replace: PatchReplace | PatchReplace[];
99 prerequisite?: () => boolean;
100};
101
102export type ExplicitExtensionDependency = {
103 ext: string;
104 id: string;
105};
106
107export type ExtensionDependency = string | RegExp | ExplicitExtensionDependency;
108
109export type ExtensionWebpackModule = {
110 entrypoint?: boolean;
111 dependencies?: ExtensionDependency[];
112 run?: WebpackModuleFunc;
113};
114
115export type ExtensionWebExports = {
116 patches?: Patch[];
117 webpackModules?: Record<string, ExtensionWebpackModule>;
118 styles?: string[];
119};
120
121export type IdentifiedPatch = Patch & {
122 ext: string;
123 id: number;
124};
125
126export type IdentifiedWebpackModule = ExtensionWebpackModule &
127 ExplicitExtensionDependency;