Add doc comments for all core extensions
Changed files
@@ -1,4 +1,13 @@export type AppPanels = {+ /**+ * Registers a new panel to be displayed around the user/voice controls.+ * @param section A unique name for your section+ * @param element A React component+ */addPanel: (section: string, element: React.FC<any>) => void;++ /**+ * @private+ */getPanels: (el: React.FC<any>) => React.ReactNode;};
@@ -10,6 +10,13 @@ MenuElement} from "@moonlight-mod/mappings/discord/components/common/index";export type ContextMenu = {+ /**+ * Registers a new context menu item for a given context menu type.+ * @param navId The navigation ID for the target context menu (e.g. "user-context", "message")+ * @param item A React component+ * @param anchorId An existing item's ID to anchor the new item to+ * @param before Whether to insert the new item before the anchor item+ */addItem: (navId: string, item: React.FC<any>, anchorId: string, before?: boolean) => void;MenuCheckboxItem: MenuCheckboxItem;
@@ -82,11 +82,26 @@ slateRules: Record<string, SlateRule>;slateDecorators: Record<string, string>;ruleBlacklists: Record<Ruleset, Record<string, boolean>>;+ /**+ * Registers a new Markdown rule with simple-markdown.+ * @param name The name of the rule+ * @param markdown A function that returns simple-markdown rules+ * @param slate A function that returns Slate rules+ * @param decorator A decorator name for Slate+ * @see https://www.npmjs.com/package/simple-markdown#adding-a-simple-extension+ * @see https://docs.slatejs.org/+ */addRule: (name: string,markdown: (rules: Record<string, MarkdownRule>) => MarkdownRule,slate: (rules: Record<string, SlateRule>) => SlateRule,decorator?: string | undefined) => void;++ /**+ * Blacklist a rule from a ruleset.+ * @param ruleset The ruleset name+ * @param name The rule name+ */blacklistFromRuleset: (ruleset: Ruleset, name: string) => void;};
@@ -4,5 +4,12 @@ setValue: (value: any) => void;}>;export type Moonbase = {+ /**+ * Registers a custom component for an extension setting.+ * The extension setting must be of type "custom".+ * @param ext The extension ID+ * @param option The setting ID+ * @param component A React component+ */registerConfigComponent: (ext: string, option: string, component: CustomComponent) => void;};
@@ -14,8 +14,23 @@ onDismiss?: () => void;};export type Notices = Store<any> & {+ /**+ * Adds a custom notice to the top of the screen.+ */addNotice: (notice: Notice) => void;++ /**+ * Removes the current notice from the top of the screen.+ */popNotice: () => void;++ /**+ * @private+ */getCurrentNotice: () => Notice | null;++ /**+ * @private+ */shouldShowNotice: () => boolean;};
@@ -24,6 +24,15 @@ ourSections: SettingsSection[];sectionNames: string[];sectionMenuItems: Record<string, ReactElement[]>;+ /**+ * Registers a new section in the settings menu.+ * @param section The section ID+ * @param label The label for the section+ * @param element The React component to render+ * @param color A color to use for the section+ * @param pos The position in the settings menu to place the section+ * @param notice A notice to display when in the section+ */addSection: (section: string,label: string,@@ -32,9 +41,28 @@ color?: string | null,pos?: number,notice?: NoticeProps) => void;++ /**+ * Adds new items to a section in the settings menu.+ * @param section The section ID+ * @param items The React components to render+ */addSectionMenuItems: (section: string, ...items: ReactElement[]) => void;+ /**+ * Places a divider in the settings menu.+ * @param pos The position in the settings menu to place the divider+ */addDivider: (pos: number | null) => void;++ /**+ * Places a header in the settings menu.+ * @param pos The position in the settings menu to place the header+ */addHeader: (label: string, pos: number | null) => void;++ /**+ * @private+ */_mutateSections: (sections: SettingsSection[]) => SettingsSection[];};
@@ -1,20 +1,70 @@import { WebpackModule, WebpackModuleFunc, WebpackRequireType } from "../discord";-// Only bothered TSDoc'ing the hard-to-understand functions-export type Spacepack = {+ /**+ * Given a Webpack module ID, returns the function for the Webpack module.+ * Can be double clicked to inspect in DevTools.+ * @param module The module ID+ * @returns The Webpack module, if found+ */inspect: (module: number | string) => WebpackModuleFunc | null;++ /**+ * Find Webpack modules based on matches in code.+ * @param args A list of finds to match against+ * @returns The Webpack modules, if found+ */findByCode: (...args: (string | RegExp)[]) => WebpackModule[];++ /**+ * Find Webpack modules based on their exports.+ * @param args A list of finds to match exports against+ * @returns The Webpack modules, if found+ */findByExports: (...args: string[]) => WebpackModule[];- // re-export of require++ /**+ * The Webpack require function.+ */require: WebpackRequireType;- // re-export of require.m++ /**+ * The Webpack module list.+ * Re-export of require.m.+ */modules: Record<string, WebpackModuleFunc>;- // re-export of require.c++ /**+ * The Webpack module cache.+ * Re-export of require.c.+ */cache: Record<string, any>;++ /**+ * Finds an object from a module's exports using the given key.+ * @param exports Exports from a Webpack module+ * @param key The key to find with+ * @returns The object, if found+ */findObjectFromKey: (exports: Record<string, any>, key: string) => any | null;++ /**+ * Finds an object from a module's exports using the given value.+ * @param exports Exports from a Webpack module+ * @param value The value to find with+ * @returns The object, if found+ */findObjectFromValue: (exports: Record<string, any>, value: any) => any | null;++ /**+ * Finds an object from a module's exports using the given key-value pair.+ * @param exports Exports from a Webpack module+ * @param key The key to find with+ * @param value The value to find with+ * @returns The object, if found+ */findObjectFromKeyValuePair: (exports: Record<string, any>, key: string, value: any) => any | null;+/*** Finds a function from a module's exports using the given source find.* This behaves like findByCode but localized to the exported function.@@ -27,6 +77,7 @@ exports: Record<string, any>,...strings: (string | RegExp)[]// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type) => Function | null;+/*** Lazy load a Webpack module.* @param find A list of finds to discover a target module with@@ -35,6 +86,7 @@ * @param module A RegExp to match the target Webpack module* @returns The target Webpack module*/lazyLoad: (find: string | RegExp | (string | RegExp)[], chunk: RegExp, module: RegExp) => Promise<any>;+/*** Filter a list of Webpack modules to "real" ones from the Discord client.* @param modules A list of Webpack modules