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 apiLevel?: number;
34 environment?: ExtensionEnvironment;
35
36 meta?: {
37 name?: string;
38 tagline?: string;
39 description?: string;
40 authors?: ExtensionAuthor[];
41 deprecated?: boolean;
42 tags?: ExtensionTag[];
43 source?: string;
44 };
45
46 dependencies?: string[];
47 suggested?: string[];
48 incompatible?: string[];
49
50 settings?: Record<string, ExtensionSettingsManifest>;
51
52 cors?: string[];
53 blocked?: string[];
54};
55
56export enum ExtensionEnvironment {
57 Both = "both",
58 Desktop = "desktop",
59 Web = "web"
60}
61
62export enum ExtensionLoadSource {
63 Developer,
64 Core,
65 Normal
66}
67
68export type DetectedExtension = {
69 id: string;
70 manifest: ExtensionManifest;
71 source: { type: ExtensionLoadSource; url?: string };
72 scripts: {
73 web?: string;
74 webPath?: string;
75 webpackModules?: Record<string, string>;
76 nodePath?: string;
77 hostPath?: string;
78 style?: string;
79 };
80};
81
82export type ProcessedExtensions = {
83 extensions: DetectedExtension[];
84 dependencyGraph: Map<string, Set<string> | null>;
85};
86
87export type PatchMatch = string | RegExp;
88export type PatchReplaceFn = (substring: string, ...args: string[]) => string;
89export type PatchReplaceModule = (orig: string) => WebpackModuleFunc;
90
91export enum PatchReplaceType {
92 Normal,
93 Module
94}
95
96export type PatchReplace =
97 | {
98 type?: PatchReplaceType.Normal;
99 match: PatchMatch;
100 replacement: string | PatchReplaceFn;
101 }
102 | {
103 type: PatchReplaceType.Module;
104 replacement: PatchReplaceModule;
105 };
106
107export type Patch = {
108 find: PatchMatch;
109 replace: PatchReplace | PatchReplace[];
110 prerequisite?: () => boolean;
111};
112
113export type ExplicitExtensionDependency = {
114 ext?: string;
115 id: string;
116};
117
118export type ExtensionDependency = string | RegExp | ExplicitExtensionDependency;
119
120export type ExtensionWebpackModule = {
121 entrypoint?: boolean;
122 dependencies?: ExtensionDependency[];
123 run?: WebpackModuleFunc;
124};
125
126export type ExtensionWebExports = {
127 patches?: Patch[];
128 webpackModules?: Record<string, ExtensionWebpackModule>;
129 styles?: string[];
130};
131
132export type IdentifiedPatch = Patch & {
133 ext: string;
134 id: number;
135};
136
137export type IdentifiedWebpackModule = ExtensionWebpackModule & ExplicitExtensionDependency;