this repo has no description

Add doc comments for all core extensions

+138 -5
+9
packages/types/src/coreExtensions/appPanels.ts
··· 1 1 export type AppPanels = { 2 + /** 3 + * Registers a new panel to be displayed around the user/voice controls. 4 + * @param section A unique name for your section 5 + * @param element A React component 6 + */ 2 7 addPanel: (section: string, element: React.FC<any>) => void; 8 + 9 + /** 10 + * @private 11 + */ 3 12 getPanels: (el: React.FC<any>) => React.ReactNode; 4 13 };
+7
packages/types/src/coreExtensions/contextMenu.ts
··· 10 10 } from "@moonlight-mod/mappings/discord/components/common/index"; 11 11 12 12 export type ContextMenu = { 13 + /** 14 + * Registers a new context menu item for a given context menu type. 15 + * @param navId The navigation ID for the target context menu (e.g. "user-context", "message") 16 + * @param item A React component 17 + * @param anchorId An existing item's ID to anchor the new item to 18 + * @param before Whether to insert the new item before the anchor item 19 + */ 13 20 addItem: (navId: string, item: React.FC<any>, anchorId: string, before?: boolean) => void; 14 21 15 22 MenuCheckboxItem: MenuCheckboxItem;
+15
packages/types/src/coreExtensions/markdown.ts
··· 82 82 slateDecorators: Record<string, string>; 83 83 ruleBlacklists: Record<Ruleset, Record<string, boolean>>; 84 84 85 + /** 86 + * Registers a new Markdown rule with simple-markdown. 87 + * @param name The name of the rule 88 + * @param markdown A function that returns simple-markdown rules 89 + * @param slate A function that returns Slate rules 90 + * @param decorator A decorator name for Slate 91 + * @see https://www.npmjs.com/package/simple-markdown#adding-a-simple-extension 92 + * @see https://docs.slatejs.org/ 93 + */ 85 94 addRule: ( 86 95 name: string, 87 96 markdown: (rules: Record<string, MarkdownRule>) => MarkdownRule, 88 97 slate: (rules: Record<string, SlateRule>) => SlateRule, 89 98 decorator?: string | undefined 90 99 ) => void; 100 + 101 + /** 102 + * Blacklist a rule from a ruleset. 103 + * @param ruleset The ruleset name 104 + * @param name The rule name 105 + */ 91 106 blacklistFromRuleset: (ruleset: Ruleset, name: string) => void; 92 107 };
+7
packages/types/src/coreExtensions/moonbase.ts
··· 4 4 }>; 5 5 6 6 export type Moonbase = { 7 + /** 8 + * Registers a custom component for an extension setting. 9 + * The extension setting must be of type "custom". 10 + * @param ext The extension ID 11 + * @param option The setting ID 12 + * @param component A React component 13 + */ 7 14 registerConfigComponent: (ext: string, option: string, component: CustomComponent) => void; 8 15 };
+15
packages/types/src/coreExtensions/notices.ts
··· 14 14 }; 15 15 16 16 export type Notices = Store<any> & { 17 + /** 18 + * Adds a custom notice to the top of the screen. 19 + */ 17 20 addNotice: (notice: Notice) => void; 21 + 22 + /** 23 + * Removes the current notice from the top of the screen. 24 + */ 18 25 popNotice: () => void; 26 + 27 + /** 28 + * @private 29 + */ 19 30 getCurrentNotice: () => Notice | null; 31 + 32 + /** 33 + * @private 34 + */ 20 35 shouldShowNotice: () => boolean; 21 36 };
+28
packages/types/src/coreExtensions/settings.ts
··· 24 24 sectionNames: string[]; 25 25 sectionMenuItems: Record<string, ReactElement[]>; 26 26 27 + /** 28 + * Registers a new section in the settings menu. 29 + * @param section The section ID 30 + * @param label The label for the section 31 + * @param element The React component to render 32 + * @param color A color to use for the section 33 + * @param pos The position in the settings menu to place the section 34 + * @param notice A notice to display when in the section 35 + */ 27 36 addSection: ( 28 37 section: string, 29 38 label: string, ··· 32 41 pos?: number, 33 42 notice?: NoticeProps 34 43 ) => void; 44 + 45 + /** 46 + * Adds new items to a section in the settings menu. 47 + * @param section The section ID 48 + * @param items The React components to render 49 + */ 35 50 addSectionMenuItems: (section: string, ...items: ReactElement[]) => void; 36 51 52 + /** 53 + * Places a divider in the settings menu. 54 + * @param pos The position in the settings menu to place the divider 55 + */ 37 56 addDivider: (pos: number | null) => void; 57 + 58 + /** 59 + * Places a header in the settings menu. 60 + * @param pos The position in the settings menu to place the header 61 + */ 38 62 addHeader: (label: string, pos: number | null) => void; 63 + 64 + /** 65 + * @private 66 + */ 39 67 _mutateSections: (sections: SettingsSection[]) => SettingsSection[]; 40 68 };
+57 -5
packages/types/src/coreExtensions/spacepack.ts
··· 1 1 import { WebpackModule, WebpackModuleFunc, WebpackRequireType } from "../discord"; 2 2 3 - // Only bothered TSDoc'ing the hard-to-understand functions 4 - 5 3 export type Spacepack = { 4 + /** 5 + * Given a Webpack module ID, returns the function for the Webpack module. 6 + * Can be double clicked to inspect in DevTools. 7 + * @param module The module ID 8 + * @returns The Webpack module, if found 9 + */ 6 10 inspect: (module: number | string) => WebpackModuleFunc | null; 11 + 12 + /** 13 + * Find Webpack modules based on matches in code. 14 + * @param args A list of finds to match against 15 + * @returns The Webpack modules, if found 16 + */ 7 17 findByCode: (...args: (string | RegExp)[]) => WebpackModule[]; 18 + 19 + /** 20 + * Find Webpack modules based on their exports. 21 + * @param args A list of finds to match exports against 22 + * @returns The Webpack modules, if found 23 + */ 8 24 findByExports: (...args: string[]) => WebpackModule[]; 9 - // re-export of require 25 + 26 + /** 27 + * The Webpack require function. 28 + */ 10 29 require: WebpackRequireType; 11 - // re-export of require.m 30 + 31 + /** 32 + * The Webpack module list. 33 + * Re-export of require.m. 34 + */ 12 35 modules: Record<string, WebpackModuleFunc>; 13 - // re-export of require.c 36 + 37 + /** 38 + * The Webpack module cache. 39 + * Re-export of require.c. 40 + */ 14 41 cache: Record<string, any>; 42 + 43 + /** 44 + * Finds an object from a module's exports using the given key. 45 + * @param exports Exports from a Webpack module 46 + * @param key The key to find with 47 + * @returns The object, if found 48 + */ 15 49 findObjectFromKey: (exports: Record<string, any>, key: string) => any | null; 50 + 51 + /** 52 + * Finds an object from a module's exports using the given value. 53 + * @param exports Exports from a Webpack module 54 + * @param value The value to find with 55 + * @returns The object, if found 56 + */ 16 57 findObjectFromValue: (exports: Record<string, any>, value: any) => any | null; 58 + 59 + /** 60 + * Finds an object from a module's exports using the given key-value pair. 61 + * @param exports Exports from a Webpack module 62 + * @param key The key to find with 63 + * @param value The value to find with 64 + * @returns The object, if found 65 + */ 17 66 findObjectFromKeyValuePair: (exports: Record<string, any>, key: string, value: any) => any | null; 67 + 18 68 /** 19 69 * Finds a function from a module's exports using the given source find. 20 70 * This behaves like findByCode but localized to the exported function. ··· 27 77 ...strings: (string | RegExp)[] 28 78 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type 29 79 ) => Function | null; 80 + 30 81 /** 31 82 * Lazy load a Webpack module. 32 83 * @param find A list of finds to discover a target module with ··· 35 86 * @returns The target Webpack module 36 87 */ 37 88 lazyLoad: (find: string | RegExp | (string | RegExp)[], chunk: RegExp, module: RegExp) => Promise<any>; 89 + 38 90 /** 39 91 * Filter a list of Webpack modules to "real" ones from the Discord client. 40 92 * @param modules A list of Webpack modules