this repo has no description
at v1.2.0 2.9 kB view raw
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 }; 79}; 80 81export type ProcessedExtensions = { 82 extensions: DetectedExtension[]; 83 dependencyGraph: Map<string, Set<string> | null>; 84}; 85 86export type PatchMatch = string | RegExp; 87export type PatchReplaceFn = (substring: string, ...args: string[]) => string; 88export type PatchReplaceModule = (orig: string) => WebpackModuleFunc; 89 90export enum PatchReplaceType { 91 Normal, 92 Module 93} 94 95export type PatchReplace = 96 | { 97 type?: PatchReplaceType.Normal; 98 match: PatchMatch; 99 replacement: string | PatchReplaceFn; 100 } 101 | { 102 type: PatchReplaceType.Module; 103 replacement: PatchReplaceModule; 104 }; 105 106export type Patch = { 107 find: PatchMatch; 108 replace: PatchReplace | PatchReplace[]; 109 prerequisite?: () => boolean; 110}; 111 112export type ExplicitExtensionDependency = { 113 ext?: string; 114 id: string; 115}; 116 117export type ExtensionDependency = string | RegExp | ExplicitExtensionDependency; 118 119export type ExtensionWebpackModule = { 120 entrypoint?: boolean; 121 dependencies?: ExtensionDependency[]; 122 run?: WebpackModuleFunc; 123}; 124 125export type ExtensionWebExports = { 126 patches?: Patch[]; 127 webpackModules?: Record<string, ExtensionWebpackModule>; 128 styles?: string[]; 129}; 130 131export type IdentifiedPatch = Patch & { 132 ext: string; 133 id: number; 134}; 135 136export type IdentifiedWebpackModule = ExtensionWebpackModule & 137 ExplicitExtensionDependency;