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 nodePath?: string;
66 hostPath?: string;
67 };
68};
69
70export type ProcessedExtensions = {
71 extensions: DetectedExtension[];
72 dependencyGraph: Map<string, Set<string> | null>;
73};
74
75export type PatchMatch = string | RegExp;
76export type PatchReplaceFn = (substring: string, ...args: string[]) => string;
77export type PatchReplaceModule = (orig: string) => WebpackModuleFunc;
78
79export enum PatchReplaceType {
80 Normal,
81 Module
82}
83
84export type PatchReplace =
85 | {
86 type?: PatchReplaceType.Normal;
87 match: PatchMatch;
88 replacement: string | PatchReplaceFn;
89 }
90 | {
91 type: PatchReplaceType.Module;
92 replacement: PatchReplaceModule;
93 };
94
95export type Patch = {
96 find: PatchMatch;
97 replace: PatchReplace | PatchReplace[];
98 prerequisite?: () => boolean;
99};
100
101export type ExplicitExtensionDependency = {
102 ext: string;
103 id: string;
104};
105
106export type ExtensionDependency = string | RegExp | ExplicitExtensionDependency;
107
108export type ExtensionWebpackModule = {
109 entrypoint?: boolean;
110 dependencies?: ExtensionDependency[];
111 run: WebpackModuleFunc;
112};
113
114export type ExtensionWebExports = {
115 patches?: Patch[];
116 webpackModules?: Record<string, ExtensionWebpackModule>;
117};
118
119export type IdentifiedPatch = Patch & {
120 ext: string;
121 id: number;
122};
123
124export type IdentifiedWebpackModule = ExtensionWebpackModule &
125 ExplicitExtensionDependency;