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