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