···11-- core-extensions/contextMenu: Fix patches
11+## Core
22+33+- Updated mappings
44+- Fixed using remapped paths as patch finds not working
+15-4
README.md
···11<h3 align="center">
22- <img src="./img/wordmark.png" alt="moonlight" />
22+ <picture>
33+ <source media="(prefers-color-scheme: dark)" srcset="./img/wordmark-light.png">
44+ <source media="(prefers-color-scheme: light)" srcset="./img/wordmark.png">
55+ <img src="./img/wordmark.png" alt="moonlight" />
66+ </picture>
3744-<a href="https://discord.gg/FdZBTFCP6F">Discord server</a>
88+<a href="https://moonlight-mod.github.io/using/install">Install</a>
99+\- <a href="https://moonlight-mod.github.io/ext-dev/getting-started">Docs</a>
1010+\- <a href="https://discord.gg/FdZBTFCP6F">Discord server</a>
511\- <a href="https://github.com/moonlight-mod/moonlight">GitHub</a>
66-\- <a href="https://moonlight-mod.github.io/">Docs</a>
712813 <hr />
1414+1515+ <picture>
1616+ <source media="(prefers-color-scheme: dark)" srcset="https://moonlight-mod.github.io/moonbase.png">
1717+ <source media="(prefers-color-scheme: light)" srcset="https://moonlight-mod.github.io/moonbase-light.png">
1818+ <img src="https://moonlight-mod.github.io/moonbase.png" alt="A screenshot of Moonbase, the moonlight UI" />
1919+ </picture>
920</h3>
10211122**moonlight** is yet another Discord client mod, focused on providing a decent user and developer experience.
12231324moonlight is heavily inspired by hh3 (a private client mod) and the projects before it that it is inspired by, namely EndPwn. All core code is original or used with permission from their respective authors where not copyleft.
14251515-**_This is an experimental passion project._** moonlight was not created out of malicious intent nor intended to seriously compete with other mods. Anything and everything is subject to change.
2626+moonlight is a **_passion project_** - things may break from time to time, but we try our best to keep things working in a timely manner.
16271728moonlight is licensed under the [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-3.0.html) (`LGPL-3.0-or-later`). See [the documentation](https://moonlight-mod.github.io/) for more information.
···11+// https://github.com/electron/asar
22+// http://formats.kaitai.io/python_pickle/
33+import { BinaryReader } from "./util/binary";
44+55+/*
66+ The asar format is kinda bad, especially because it uses multiple pickle
77+ entries. It spams sizes, expecting us to read small buffers and parse those,
88+ but we can just take it all through at once without having to create multiple
99+ BinaryReaders. This implementation might be wrong, though.
1010+1111+ This either has size/offset or files but I can't get the type to cooperate,
1212+ so pretend this is a union.
1313+*/
1414+1515+type AsarEntry = {
1616+ size: number;
1717+ offset: `${number}`; // who designed this
1818+1919+ files?: Record<string, AsarEntry>;
2020+};
2121+2222+export default function extractAsar(file: ArrayBuffer) {
2323+ const array = new Uint8Array(file);
2424+ const br = new BinaryReader(array);
2525+2626+ // two uints, one containing the number '4', to signify that the other uint takes up 4 bytes
2727+ // bravo, electron, bravo
2828+ const _payloadSize = br.readUInt32();
2929+ const _headerSize = br.readInt32();
3030+3131+ const headerStringStart = br.position;
3232+ const headerStringSize = br.readUInt32(); // How big the block is
3333+ const actualStringSize = br.readUInt32(); // How big the string in that block is
3434+3535+ const base = headerStringStart + headerStringSize + 4;
3636+3737+ const string = br.readString(actualStringSize);
3838+ const header: AsarEntry = JSON.parse(string);
3939+4040+ const ret: Record<string, Uint8Array> = {};
4141+ function addDirectory(dir: AsarEntry, path: string) {
4242+ for (const [name, data] of Object.entries(dir.files!)) {
4343+ const fullName = path + "/" + name;
4444+ if (data.files != null) {
4545+ addDirectory(data, fullName);
4646+ } else {
4747+ br.position = base + parseInt(data.offset);
4848+ const file = br.read(data.size);
4949+ ret[fullName] = file;
5050+ }
5151+ }
5252+ }
5353+5454+ addDirectory(header, "");
5555+5656+ return ret;
5757+}
+31-31
packages/core/src/config.ts
···11import { Config } from "@moonlight-mod/types";
22-import requireImport from "./util/import";
32import { getConfigPath } from "./util/data";
33+import * as constants from "@moonlight-mod/types/constants";
44+import Logger from "./util/logger";
55+66+const logger = new Logger("core/config");
4758const defaultConfig: Config = {
99+ // If you're updating this, update `builtinExtensions` in constants as well
610 extensions: {
711 moonbase: true,
812 disableSentry: true,
913 noTrack: true,
1014 noHideToken: true
1115 },
1212- repositories: ["https://moonlight-mod.github.io/extensions-dist/repo.json"]
1616+ repositories: [constants.mainRepo]
1317};
14181515-export function writeConfig(config: Config) {
1616- const fs = requireImport("fs");
1717- const configPath = getConfigPath();
1818- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
1919-}
2020-2121-function readConfigNode(): Config {
2222- const fs = requireImport("fs");
2323- const configPath = getConfigPath();
2424-2525- if (!fs.existsSync(configPath)) {
2626- writeConfig(defaultConfig);
2727- return defaultConfig;
1919+export async function writeConfig(config: Config) {
2020+ try {
2121+ const configPath = await getConfigPath();
2222+ await moonlightNodeSandboxed.fs.writeFileString(configPath, JSON.stringify(config, null, 2));
2323+ } catch (e) {
2424+ logger.error("Failed to write config", e);
2825 }
2929-3030- let config: Config = JSON.parse(fs.readFileSync(configPath, "utf8"));
3131-3232- // Assign the default values if they don't exist (newly added)
3333- config = { ...defaultConfig, ...config };
3434- writeConfig(config);
3535-3636- return config;
3726}
38273939-export function readConfig(): Config {
2828+export async function readConfig(): Promise<Config> {
4029 webPreload: {
4130 return moonlightNode.config;
4231 }
43324444- nodePreload: {
4545- return readConfigNode();
4646- }
3333+ const configPath = await getConfigPath();
3434+ if (!(await moonlightNodeSandboxed.fs.exists(configPath))) {
3535+ await writeConfig(defaultConfig);
3636+ return defaultConfig;
3737+ } else {
3838+ try {
3939+ let config: Config = JSON.parse(await moonlightNodeSandboxed.fs.readFileString(configPath));
4040+ // Assign the default values if they don't exist (newly added)
4141+ config = { ...defaultConfig, ...config };
4242+ await writeConfig(config);
47434848- injector: {
4949- return readConfigNode();
4444+ return config;
4545+ } catch (e) {
4646+ logger.error("Failed to read config, falling back to defaults", e);
4747+ // We don't want to write the default config here - if a user is manually
4848+ // editing their config and messes it up, we'll delete it all instead of
4949+ // letting them fix it
5050+ return defaultConfig;
5151+ }
5052 }
5151-5252- throw new Error("Called readConfig() in an impossible environment");
5353}
···11-import Flux from "@moonlight-mod/wp/common_flux";
11+import { Store } from "@moonlight-mod/wp/discord/packages/flux";
2233module.exports = new Proxy(
44 {},
55 {
66 get: function (target, key, receiver) {
77- const allStores = Flux.Store.getAll();
77+ const allStores = Store.getAll();
8899 let targetStore;
1010 for (const store of allStores) {
···11{
22+ "$schema": "https://moonlight-mod.github.io/manifest.schema.json",
23 "id": "noHideToken",
44+ "apiLevel": 2,
35 "meta": {
46 "name": "No Hide Token",
55- "tagline": "Disables removal of token from localStorage when opening dev tools",
77+ "tagline": "Prevents you from being logged-out on hard-crash",
88+ "description": "Prevents you from being logged-out on hard-crash by disabling removal of token from localStorage when opening dev tools",
69 "authors": ["adryd"],
710 "tags": ["dangerZone", "development"]
811 }
···11+{
22+ "$schema": "https://moonlight-mod.github.io/manifest.schema.json",
33+ "id": "rocketship",
44+ "apiLevel": 2,
55+ "environment": "desktop",
66+ "meta": {
77+ "name": "Rocketship",
88+ "tagline": "Adds new features when using rocketship",
99+ "description": "**This extension only works on Linux when using rocketship:**\nhttps://github.com/moonlight-mod/rocketship\n\nAdds new features to the Discord Linux client with rocketship, such as a better screensharing experience.",
1010+ "authors": ["NotNite", "Cynosphere", "adryd"],
1111+ "deprecated": true
1212+ }
1313+}
···11+export type AppPanels = {
22+ /**
33+ * Registers a new panel to be displayed around the user/voice controls.
44+ * @param section A unique name for your section
55+ * @param element A React component
66+ */
77+ addPanel: (section: string, element: React.FC<any>) => void;
88+99+ /**
1010+ * @private
1111+ */
1212+ getPanels: (el: React.FC<any>) => React.ReactNode;
1313+};
···11111212export type ASTNode = SingleASTNode | Array<SingleASTNode>;
13131414-export type Parser = (
1515- source: string,
1616- state?: State | null | undefined
1717-) => Array<SingleASTNode>;
1414+export type Parser = (source: string, state?: State | null | undefined) => Array<SingleASTNode>;
18151919-export type ParseFunction = (
2020- capture: Capture,
2121- nestedParse: Parser,
2222- state: State
2323-) => UntypedASTNode | ASTNode;
1616+export type ParseFunction = (capture: Capture, nestedParse: Parser, state: State) => UntypedASTNode | ASTNode;
24172518export type Capture =
2619 | (Array<string> & {
···38313932export type MatchFunction = {
4033 regex?: RegExp;
4141-} & ((
4242- source: string,
4343- state: State,
4444- prevCapture: string
4545-) => Capture | null | undefined);
3434+} & ((source: string, state: State, prevCapture: string) => Capture | null | undefined);
46354747-export type Output<Result> = (
4848- node: ASTNode,
4949- state?: State | null | undefined
5050-) => Result;
3636+export type Output<Result> = (node: ASTNode, state?: State | null | undefined) => Result;
51375252-export type SingleNodeOutput<Result> = (
5353- node: SingleASTNode,
5454- nestedOutput: Output<Result>,
5555- state: State
5656-) => Result;
3838+export type SingleNodeOutput<Result> = (node: SingleASTNode, nestedOutput: Output<Result>, state: State) => Result;
57395840// }}}
5941···10082 slateDecorators: Record<string, string>;
10183 ruleBlacklists: Record<Ruleset, Record<string, boolean>>;
102848585+ /**
8686+ * Registers a new Markdown rule with simple-markdown.
8787+ * @param name The name of the rule
8888+ * @param markdown A function that returns simple-markdown rules
8989+ * @param slate A function that returns Slate rules
9090+ * @param decorator A decorator name for Slate
9191+ * @see https://www.npmjs.com/package/simple-markdown#adding-a-simple-extension
9292+ * @see https://docs.slatejs.org/
9393+ */
10394 addRule: (
10495 name: string,
10596 markdown: (rules: Record<string, MarkdownRule>) => MarkdownRule,
10697 slate: (rules: Record<string, SlateRule>) => SlateRule,
10798 decorator?: string | undefined
10899 ) => void;
100100+101101+ /**
102102+ * Blacklist a rule from a ruleset.
103103+ * @param ruleset The ruleset name
104104+ * @param name The rule name
105105+ */
109106 blacklistFromRuleset: (ruleset: Ruleset, name: string) => void;
110107};
+17
packages/types/src/coreExtensions/moonbase.ts
···11+export type CustomComponentProps = {
22+ value: any;
33+ setValue: (value: any) => void;
44+};
55+66+export type CustomComponent = React.FC<CustomComponentProps>;
77+88+export type Moonbase = {
99+ /**
1010+ * Registers a custom component for an extension setting.
1111+ * The extension setting must be of type "custom".
1212+ * @param ext The extension ID
1313+ * @param option The setting ID
1414+ * @param component A React component
1515+ */
1616+ registerConfigComponent: (ext: string, option: string, component: CustomComponent) => void;
1717+};
+36
packages/types/src/coreExtensions/notices.ts
···11+import type { Store } from "@moonlight-mod/mappings/discord/packages/flux/Store";
22+33+export type NoticeButton = {
44+ name: string;
55+ onClick: () => boolean; // return true to dismiss the notice after the button is clicked
66+};
77+88+export type Notice = {
99+ element: React.ReactNode;
1010+ color?: string;
1111+ showClose?: boolean;
1212+ buttons?: NoticeButton[];
1313+ onDismiss?: () => void;
1414+};
1515+1616+export type Notices = Store<any> & {
1717+ /**
1818+ * Adds a custom notice to the top of the screen.
1919+ */
2020+ addNotice: (notice: Notice) => void;
2121+2222+ /**
2323+ * Removes the current notice from the top of the screen.
2424+ */
2525+ popNotice: () => void;
2626+2727+ /**
2828+ * @private
2929+ */
3030+ getCurrentNotice: () => Notice | null;
3131+3232+ /**
3333+ * @private
3434+ */
3535+ shouldShowNotice: () => boolean;
3636+};
+71
packages/types/src/coreExtensions/settings.ts
···11+import React, { ReactElement } from "react";
22+import type { Store } from "@moonlight-mod/mappings/discord/packages/flux/Store";
33+44+export type NoticeProps = {
55+ stores: Store<any>[];
66+ element: React.FunctionComponent;
77+};
88+99+export type SettingsSection =
1010+ | { section: "DIVIDER"; pos: number | ((sections: SettingsSection[]) => number) }
1111+ | { section: "HEADER"; label: string; pos: number | ((sections: SettingsSection[]) => number) }
1212+ | {
1313+ section: string;
1414+ label: string;
1515+ color: string | null;
1616+ element: React.FunctionComponent;
1717+ pos: number | ((sections: SettingsSection[]) => number);
1818+ notice?: NoticeProps;
1919+ onClick?: () => void;
2020+ _moonlight_submenu?: () => ReactElement | ReactElement[];
2121+ };
2222+2323+export type Settings = {
2424+ ourSections: SettingsSection[];
2525+ sectionNames: string[];
2626+ sectionMenuItems: Record<string, ReactElement[]>;
2727+2828+ /**
2929+ * Registers a new section in the settings menu.
3030+ * @param section The section ID
3131+ * @param label The label for the section
3232+ * @param element The React component to render
3333+ * @param color A color to use for the section
3434+ * @param pos The position in the settings menu to place the section
3535+ * @param notice A notice to display when in the section
3636+ * @param onClick A custom action to execute when clicked from the context menu
3737+ */
3838+ addSection: (
3939+ section: string,
4040+ label: string,
4141+ element: React.FunctionComponent,
4242+ color?: string | null,
4343+ pos?: number | ((sections: SettingsSection[]) => number),
4444+ notice?: NoticeProps,
4545+ onClick?: () => void
4646+ ) => void;
4747+4848+ /**
4949+ * Adds new items to a section in the settings menu.
5050+ * @param section The section ID
5151+ * @param items The React components to render
5252+ */
5353+ addSectionMenuItems: (section: string, ...items: ReactElement[]) => void;
5454+5555+ /**
5656+ * Places a divider in the settings menu.
5757+ * @param pos The position in the settings menu to place the divider
5858+ */
5959+ addDivider: (pos: number | ((sections: SettingsSection[]) => number) | null) => void;
6060+6161+ /**
6262+ * Places a header in the settings menu.
6363+ * @param pos The position in the settings menu to place the header
6464+ */
6565+ addHeader: (label: string, pos: number | ((sections: SettingsSection[]) => number) | null) => void;
6666+6767+ /**
6868+ * @private
6969+ */
7070+ _mutateSections: (sections: SettingsSection[]) => SettingsSection[];
7171+};
+97
packages/types/src/coreExtensions/spacepack.ts
···11+import { WebpackModule, WebpackModuleFunc, WebpackRequireType } from "../discord";
22+33+export type Spacepack = {
44+ /**
55+ * Given a Webpack module ID, returns the function for the Webpack module.
66+ * Can be double clicked to inspect in DevTools.
77+ * @param module The module ID
88+ * @returns The Webpack module, if found
99+ */
1010+ inspect: (module: number | string) => WebpackModuleFunc | null;
1111+1212+ /**
1313+ * Find Webpack modules based on matches in code.
1414+ * @param args A list of finds to match against
1515+ * @returns The Webpack modules, if found
1616+ */
1717+ findByCode: (...args: (string | RegExp)[]) => WebpackModule[];
1818+1919+ /**
2020+ * Find Webpack modules based on their exports.
2121+ * @deprecated This has race conditions. Consider using findByCode instead.
2222+ * @param args A list of finds to match exports against
2323+ * @returns The Webpack modules, if found
2424+ */
2525+ findByExports: (...args: string[]) => WebpackModule[];
2626+2727+ /**
2828+ * The Webpack require function.
2929+ */
3030+ require: WebpackRequireType;
3131+3232+ /**
3333+ * The Webpack module list.
3434+ * Re-export of require.m.
3535+ */
3636+ modules: Record<string, WebpackModuleFunc>;
3737+3838+ /**
3939+ * The Webpack module cache.
4040+ * Re-export of require.c.
4141+ */
4242+ cache: Record<string, any>;
4343+4444+ /**
4545+ * Finds an object from a module's exports using the given key.
4646+ * @param exports Exports from a Webpack module
4747+ * @param key The key to find with
4848+ * @returns The object, if found
4949+ */
5050+ findObjectFromKey: (exports: Record<string, any>, key: string) => any | null;
5151+5252+ /**
5353+ * Finds an object from a module's exports using the given value.
5454+ * @param exports Exports from a Webpack module
5555+ * @param value The value to find with
5656+ * @returns The object, if found
5757+ */
5858+ findObjectFromValue: (exports: Record<string, any>, value: any) => any | null;
5959+6060+ /**
6161+ * Finds an object from a module's exports using the given key-value pair.
6262+ * @param exports Exports from a Webpack module
6363+ * @param key The key to find with
6464+ * @param value The value to find with
6565+ * @returns The object, if found
6666+ */
6767+ findObjectFromKeyValuePair: (exports: Record<string, any>, key: string, value: any) => any | null;
6868+6969+ /**
7070+ * Finds a function from a module's exports using the given source find.
7171+ * This behaves like findByCode but localized to the exported function.
7272+ * @param exports A module's exports
7373+ * @param strings A list of finds to use
7474+ * @returns The function, if found
7575+ */
7676+ findFunctionByStrings: (
7777+ exports: Record<string, any>,
7878+ ...strings: (string | RegExp)[]
7979+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
8080+ ) => Function | null;
8181+8282+ /**
8383+ * Lazy load a Webpack module.
8484+ * @param find A list of finds to discover a target module with
8585+ * @param chunk A RegExp to match chunks to load
8686+ * @param module A RegExp to match the target Webpack module
8787+ * @returns The target Webpack module
8888+ */
8989+ lazyLoad: (find: string | RegExp | (string | RegExp)[], chunk: RegExp, module: RegExp) => Promise<any>;
9090+9191+ /**
9292+ * Filter a list of Webpack modules to "real" ones from the Discord client.
9393+ * @param modules A list of Webpack modules
9494+ * @returns A filtered list of Webpack modules
9595+ */
9696+ filterReal: (modules: WebpackModule[]) => WebpackModule[];
9797+};
+8-80
packages/types/src/coreExtensions.ts
···11-import { FluxDefault, Store } from "./discord/common/Flux";
22-import { CommonComponents as CommonComponents_ } from "./coreExtensions/components";
33-import { Dispatcher } from "flux";
44-import React, { ReactElement } from "react";
55-import {
66- WebpackModule,
77- WebpackModuleFunc,
88- WebpackRequireType
99-} from "./discord";
1010-1111-export type Spacepack = {
1212- inspect: (module: number | string) => WebpackModuleFunc | null;
1313- findByCode: (...args: (string | RegExp)[]) => any[];
1414- findByExports: (...args: string[]) => any[];
1515- require: WebpackRequireType;
1616- modules: Record<string, WebpackModuleFunc>;
1717- cache: Record<string, any>;
1818- findObjectFromKey: (exports: Record<string, any>, key: string) => any | null;
1919- findObjectFromValue: (exports: Record<string, any>, value: any) => any | null;
2020- findObjectFromKeyValuePair: (
2121- exports: Record<string, any>,
2222- key: string,
2323- value: any
2424- ) => any | null;
2525- findFunctionByStrings: (
2626- exports: Record<string, any>,
2727- ...strings: (string | RegExp)[]
2828- // eslint-disable-next-line @typescript-eslint/ban-types
2929- ) => Function | null;
3030- lazyLoad: (
3131- find: string | RegExp | (string | RegExp)[],
3232- chunk: RegExp,
3333- module: RegExp
3434- ) => Promise<any>;
3535- filterReal: (modules: WebpackModule[]) => WebpackModule[];
3636-};
3737-3838-export type NoticeProps = {
3939- stores: Store<any>[];
4040- element: React.FunctionComponent;
4141-};
4242-4343-export type SettingsSection =
4444- | { section: "DIVIDER"; pos: number }
4545- | { section: "HEADER"; label: string; pos: number }
4646- | {
4747- section: string;
4848- label: string;
4949- color: string | null;
5050- element: React.FunctionComponent;
5151- pos: number;
5252- notice?: NoticeProps;
5353- _moonlight_submenu?: () => ReactElement | ReactElement[];
5454- };
5555-5656-export type Settings = {
5757- ourSections: SettingsSection[];
5858- sectionNames: string[];
5959- sectionMenuItems: Record<string, ReactElement[]>;
6060-6161- addSection: (
6262- section: string,
6363- label: string,
6464- element: React.FunctionComponent,
6565- color?: string | null,
6666- pos?: number,
6767- notice?: NoticeProps
6868- ) => void;
6969- addSectionMenuItems: (section: string, ...items: ReactElement[]) => void;
7070-7171- addDivider: (pos: number | null) => void;
7272- addHeader: (label: string, pos: number | null) => void;
7373- _mutateSections: (sections: SettingsSection[]) => SettingsSection[];
7474-};
7575-7676-export type CommonReact = typeof import("react");
7777-export type CommonFlux = FluxDefault;
7878-export type CommonComponents = CommonComponents_; // lol
7979-export type CommonFluxDispatcher = Dispatcher<any>;
8080-11+export * as Spacepack from "./coreExtensions/spacepack";
22+export * as Settings from "./coreExtensions/settings";
813export * as Markdown from "./coreExtensions/markdown";
824export * as ContextMenu from "./coreExtensions/contextMenu";
55+export * as Notices from "./coreExtensions/notices";
66+export * as Moonbase from "./coreExtensions/moonbase";
77+export * as AppPanels from "./coreExtensions/appPanels";
88+export * as Commands from "./coreExtensions/commands";
99+export * as ComponentEditor from "./coreExtensions/componentEditor";
1010+export * as Common from "./coreExtensions/common";
-57
packages/types/src/discord/common/Flux.ts
···11-/*
22- It seems like Discord maintains their own version of Flux that doesn't match
33- the types on NPM. This is a heavy work in progress - if you encounter rough
44- edges, please contribute!
55-*/
66-77-import { DependencyList } from "react";
88-import { Store as FluxStore } from "flux/utils";
99-import { Dispatcher as FluxDispatcher } from "flux";
1010-import { ComponentConstructor } from "flux/lib/FluxContainer";
1111-1212-export declare abstract class Store<T> extends FluxStore<T> {
1313- static getAll: () => Store<any>[];
1414- getName: () => string;
1515- emitChange: () => void;
1616-}
1717-1818-interface ConnectStores {
1919- <T>(
2020- stores: Store<any>[],
2121- callback: T,
2222- context?: any
2323- ): ComponentConstructor<T>;
2424-}
2525-2626-export type FluxDefault = {
2727- DeviceSettingsStore: any; // TODO
2828- Emitter: any; // @types/fbemitter
2929- OfflineCacheStore: any; // TODO
3030- PersistedStore: any; // TODO
3131- Store: typeof Store;
3232- Dispatcher: typeof FluxDispatcher;
3333- connectStores: ConnectStores;
3434- initialize: () => void;
3535- initialized: Promise<boolean>;
3636- destroy: () => void;
3737- useStateFromStores: UseStateFromStores;
3838- useStateFromStoresArray: UseStateFromStoresArray;
3939- useStateFromStoresObject: UseStateFromStoresObject;
4040-};
4141-4242-interface UseStateFromStores {
4343- <T>(
4444- stores: Store<any>[],
4545- callback: () => T,
4646- deps?: DependencyList,
4747- shouldUpdate?: (oldState: T, newState: T) => boolean
4848- ): T;
4949-}
5050-5151-interface UseStateFromStoresArray {
5252- <T>(stores: Store<any>[], callback: () => T, deps?: DependencyList): T;
5353-}
5454-5555-interface UseStateFromStoresObject {
5656- <T>(stores: Store<any>[], callback: () => T, deps?: DependencyList): T;
5757-}
+31-22
packages/types/src/discord/require.ts
···11-import {
22- Spacepack,
33- CommonReact,
44- CommonFlux,
55- Settings,
66- CommonComponents,
77- CommonFluxDispatcher
88-} from "../coreExtensions";
11+import { AppPanels } from "../coreExtensions/appPanels";
22+import { Commands } from "../coreExtensions/commands";
33+import { ErrorBoundary, Icons } from "../coreExtensions/common";
44+import { DMList, MemberList, Messages } from "../coreExtensions/componentEditor";
95import { ContextMenu, EvilItemParser } from "../coreExtensions/contextMenu";
106import { Markdown } from "../coreExtensions/markdown";
77+import { Moonbase } from "../coreExtensions/moonbase";
88+import { Notices } from "../coreExtensions/notices";
99+import { Settings } from "../coreExtensions/settings";
1010+import { Spacepack } from "../coreExtensions/spacepack";
11111212declare function WebpackRequire(id: string): any;
1313-declare function WebpackRequire(id: "spacepack_spacepack"): {
1414- default: Spacepack;
1515- spacepack: Spacepack;
1616-};
1313+1414+declare function WebpackRequire(id: "appPanels_appPanels"): AppPanels;
1515+1616+declare function WebpackRequire(id: "commands_commands"): Commands;
1717+1818+declare function WebpackRequire(id: "common_ErrorBoundary"): ErrorBoundary;
1919+declare function WebpackRequire(id: "common_icons"): Icons;
2020+2121+declare function WebpackRequire(id: "componentEditor_dmList"): DMList;
2222+declare function WebpackRequire(id: "componentEditor_memberList"): MemberList;
2323+declare function WebpackRequire(id: "componentEditor_messages"): Messages;
17241818-declare function WebpackRequire(id: "common_components"): CommonComponents;
1919-declare function WebpackRequire(id: "common_flux"): CommonFlux;
2020-declare function WebpackRequire(
2121- id: "common_fluxDispatcher"
2222-): CommonFluxDispatcher;
2323-declare function WebpackRequire(id: "common_react"): CommonReact;
2525+declare function WebpackRequire(id: "contextMenu_evilMenu"): EvilItemParser;
2626+declare function WebpackRequire(id: "contextMenu_contextMenu"): ContextMenu;
2727+2828+declare function WebpackRequire(id: "markdown_markdown"): Markdown;
2929+3030+declare function WebpackRequire(id: "moonbase_moonbase"): Moonbase;
3131+3232+declare function WebpackRequire(id: "notices_notices"): Notices;
24332534declare function WebpackRequire(id: "settings_settings"): {
2635 Settings: Settings;
2736 default: Settings;
2837};
29383030-declare function WebpackRequire(id: "markdown_markdown"): Markdown;
3131-3232-declare function WebpackRequire(id: "contextMenu_evilMenu"): EvilItemParser;
3333-declare function WebpackRequire(id: "contextMenu_contextMenu"): ContextMenu;
3939+declare function WebpackRequire(id: "spacepack_spacepack"): {
4040+ default: Spacepack;
4141+ spacepack: Spacepack;
4242+};
34433544export default WebpackRequire;
···2828 };
29293030export type ExtensionManifest = {
3131+ $schema?: string;
3232+3333+ /**
3434+ * A unique identifier for your extension.
3535+ */
3136 id: string;
3737+3838+ /**
3939+ * A version string for your extension - doesn't need to follow a specific format. Required for publishing.
4040+ */
3241 version?: string;
33424343+ /**
4444+ * The API level this extension targets. If it does not match the current version, the extension will not be loaded.
4545+ */
4646+ apiLevel?: number;
4747+4848+ /**
4949+ * Which environment this extension is capable of running in.
5050+ */
5151+ environment?: ExtensionEnvironment;
5252+5353+ /**
5454+ * Metadata about your extension for use in Moonbase.
5555+ */
3456 meta?: {
5757+ /**
5858+ * A human friendly name for your extension as a proper noun.
5959+ */
3560 name?: string;
6161+6262+ /**
6363+ * A short tagline that appears below the name.
6464+ */
3665 tagline?: string;
6666+6767+ /**
6868+ * A longer description that can use Markdown.
6969+ */
3770 description?: string;
7171+7272+ /**
7373+ * List of authors that worked on this extension - accepts string or object with ID.
7474+ */
3875 authors?: ExtensionAuthor[];
3939- deprecated?: boolean;
7676+7777+ /**
7878+ * A list of tags that are relevant to the extension.
7979+ */
4080 tags?: ExtensionTag[];
8181+8282+ /**
8383+ * The URL to the source repository.
8484+ */
4185 source?: string;
8686+8787+ /**
8888+ * A donation link (or other method of support). If you don't want financial contributions, consider putting your favorite charity here!
8989+ */
9090+ donate?: string;
9191+9292+ /**
9393+ * A changelog to show in Moonbase.
9494+ * Moonbase will show the changelog for the latest version, even if it is not installed.
9595+ */
9696+ changelog?: string;
9797+9898+ /**
9999+ * Whether the extension is deprecated and no longer receiving updates.
100100+ */
101101+ deprecated?: boolean;
42102 };
43103104104+ /**
105105+ * A list of extension IDs that are required for the extension to load.
106106+ */
44107 dependencies?: string[];
108108+109109+ /**
110110+ * A list of extension IDs that the user may want to install.
111111+ */
45112 suggested?: string[];
113113+114114+ /**
115115+ * A list of extension IDs that the extension is incompatible with.
116116+ * If two incompatible extensions are enabled, one of them will not load.
117117+ */
46118 incompatible?: string[];
47119120120+ /**
121121+ * A list of settings for your extension, where the key is the settings ID.
122122+ */
48123 settings?: Record<string, ExtensionSettingsManifest>;
124124+125125+ /**
126126+ * A list of URLs to bypass CORS for.
127127+ * This is implemented by checking if the start of the URL matches.
128128+ * @example https://moonlight-mod.github.io/
129129+ */
49130 cors?: string[];
131131+132132+ /**
133133+ * A list of URLs to block all requests to.
134134+ * This is implemented by checking if the start of the URL matches.
135135+ * @example https://moonlight-mod.github.io/
136136+ */
137137+ blocked?: string[];
138138+139139+ /**
140140+ * A mapping from CSP directives to URLs to allow.
141141+ * @example { "script-src": ["https://example.com"] }
142142+ */
143143+ csp?: Record<string, string[]>;
50144};
51145146146+export enum ExtensionEnvironment {
147147+ /**
148148+ * The extension will run on both platforms, the host/native modules MAY be loaded
149149+ */
150150+ Both = "both",
151151+152152+ /**
153153+ * Extension will run on desktop only, the host/native modules are guaranteed to load
154154+ */
155155+ Desktop = "desktop",
156156+157157+ /**
158158+ * Currently equivalent to Both
159159+ */
160160+ Web = "web"
161161+}
162162+52163export enum ExtensionLoadSource {
53164 Developer,
54165 Core,
···65176 webpackModules?: Record<string, string>;
66177 nodePath?: string;
67178 hostPath?: string;
179179+ style?: string;
68180 };
69181};
70182···96208export type Patch = {
97209 find: PatchMatch;
98210 replace: PatchReplace | PatchReplace[];
211211+ hardFail?: boolean; // if any patches fail, all fail
99212 prerequisite?: () => boolean;
100213};
101214102215export type ExplicitExtensionDependency = {
103103- ext: string;
216216+ ext?: string;
104217 id: string;
105218};
106219···123236 id: number;
124237};
125238126126-export type IdentifiedWebpackModule = ExtensionWebpackModule &
127127- ExplicitExtensionDependency;
239239+export type IdentifiedWebpackModule = ExtensionWebpackModule & ExplicitExtensionDependency;