this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #62 from moonlight-mod/lunast

API v2

authored by notnite.com and committed by

GitHub 0373e985 0498ec0c

+518 -916
+1 -1
.prettierignore
··· 1 - pnpm-lock.yml 1 + pnpm-lock.yaml
+1
build.mjs
··· 21 21 "module", 22 22 "events", 23 23 "original-fs", // wtf asar? 24 + "discord", // mappings 24 25 25 26 // Silence an esbuild warning 26 27 "./node-preload.js"
+4 -29
packages/core-extensions/src/common/index.ts
··· 1 1 import { ExtensionWebExports } from "@moonlight-mod/types"; 2 2 3 3 export const webpackModules: ExtensionWebExports["webpackModules"] = { 4 - components: { 4 + stores: { 5 5 dependencies: [ 6 - { ext: "spacepack", id: "spacepack" }, 7 - "MasonryList:", 8 - ".flexGutterSmall," 6 + { 7 + id: "discord/packages/flux" 8 + } 9 9 ] 10 - }, 11 - 12 - flux: { 13 - dependencies: [{ ext: "spacepack", id: "spacepack" }, "connectStores:"] 14 - }, 15 - 16 - fluxDispatcher: { 17 - dependencies: [ 18 - { ext: "spacepack", id: "spacepack" }, 19 - "isDispatching", 20 - "dispatch" 21 - ] 22 - }, 23 - 24 - react: { 25 - dependencies: [ 26 - { ext: "spacepack", id: "spacepack" }, 27 - "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", 28 - /\.?version(?:=|:)/, 29 - /\.?createElement(?:=|:)/ 30 - ] 31 - }, 32 - 33 - stores: { 34 - dependencies: [{ ext: "common", id: "flux" }] 35 10 } 36 11 };
+1
packages/core-extensions/src/common/manifest.json
··· 1 1 { 2 2 "id": "common", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Common", 5 6 "tagline": "A *lot* of common clientmodding utilities from the Discord client",
-41
packages/core-extensions/src/common/webpackModules/components.ts
··· 1 - import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 2 - 3 - const Components = spacepack.findByCode("MasonryList:function")[0].exports; 4 - const MarkdownParser = spacepack.findByCode( 5 - "parseAutoModerationSystemMessage:" 6 - )[0].exports.Z; 7 - const LegacyText = spacepack.findByCode(".selectable", ".colorStandard")[0] 8 - .exports.default; 9 - const Flex = Object.values( 10 - spacepack.findByCode(".flex" + "GutterSmall,")[0].exports 11 - )[0]; 12 - 13 - const CardClasses = {}; 14 - spacepack 15 - .lazyLoad( 16 - "renderArtisanalHack", 17 - /\[(?:.\.e\("\d+?"\),?)+\][^}]+?webpackId:\d+,name:"ChannelSettings"/, 18 - /webpackId:(\d+),name:"ChannelSettings"/ 19 - ) 20 - .then(() => 21 - Object.assign( 22 - CardClasses, 23 - spacepack.findByExports("card", "cardHeader", "inModal")[0].exports 24 - ) 25 - ); 26 - 27 - const ControlClasses = spacepack.findByCode( 28 - "title", 29 - "titleDefault", 30 - "dividerDefault" 31 - )[0].exports; 32 - 33 - // We use CJS export here because merging the exports from Components is annoying as shit 34 - module.exports = { 35 - ...Components, 36 - MarkdownParser, 37 - LegacyText, 38 - Flex, 39 - CardClasses, 40 - ControlClasses 41 - };
-28
packages/core-extensions/src/common/webpackModules/flux.ts
··· 1 - import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 2 - 3 - const mod = spacepack.findByCode("connectStores:")[0].exports; 4 - 5 - const useStateFromStores = spacepack.findFunctionByStrings( 6 - mod, 7 - '"useStateFromStores"' 8 - )!; 9 - 10 - module.exports = { 11 - BatchedStoreListener: spacepack.findFunctionByStrings( 12 - mod, 13 - " tried to load a non-existent store." 14 - ), 15 - Dispatcher: spacepack.findFunctionByStrings(mod, "_dispatchWithDevtools("), 16 - Store: spacepack.findFunctionByStrings(mod, "registerActionHandlers("), 17 - default: mod.ZP, 18 - statesWillNeverBeEqual: spacepack.findFunctionByStrings(mod, "return!1"), 19 - useStateFromStores, 20 - useStateFromStoresArray: spacepack.findFunctionByStrings( 21 - mod, 22 - new RegExp(`return ${useStateFromStores.name}\\(.+?\\.[^Z]\\)`) 23 - ), 24 - useStateFromStoresObject: spacepack.findFunctionByStrings( 25 - mod, 26 - new RegExp(`return ${useStateFromStores.name}\\(.+?\\.Z\\)`) 27 - ) 28 - };
-6
packages/core-extensions/src/common/webpackModules/fluxDispatcher.ts
··· 1 - import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 2 - 3 - module.exports = spacepack.findByExports( 4 - "isDispatching", 5 - "dispatch" 6 - )[0].exports.Z;
-7
packages/core-extensions/src/common/webpackModules/react.ts
··· 1 - import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 2 - 3 - module.exports = spacepack.findByCode( 4 - "__SECRET_INTERNALS_DO_NOT_USE" + "_OR_YOU_WILL_BE_FIRED", 5 - /\.?version(?:=|:)/, 6 - /\.?createElement(?:=|:)/ 7 - )[0].exports;
+2 -2
packages/core-extensions/src/common/webpackModules/stores.ts
··· 1 - import Flux from "@moonlight-mod/wp/common_flux"; 1 + import { Store } from "@moonlight-mod/wp/discord/packages/flux"; 2 2 3 3 module.exports = new Proxy( 4 4 {}, 5 5 { 6 6 get: function (target, key, receiver) { 7 - const allStores = Flux.Store.getAll(); 7 + const allStores = Store.getAll(); 8 8 9 9 let targetStore; 10 10 for (const store of allStores) {
+1
packages/core-extensions/src/contextMenu/manifest.json
··· 1 1 { 2 2 "id": "contextMenu", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Context Menu", 5 6 "tagline": "A library for patching and creating context menus",
+1
packages/core-extensions/src/disableSentry/manifest.json
··· 1 1 { 2 2 "id": "disableSentry", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Disable Sentry", 5 6 "tagline": "Turns off Discord's error reporting systems",
+1
packages/core-extensions/src/experiments/manifest.json
··· 1 1 { 2 2 "id": "experiments", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Experiments", 5 6 "tagline": "Allows you to configure Discord's internal A/B testing features",
+1
packages/core-extensions/src/markdown/manifest.json
··· 1 1 { 2 2 "id": "markdown", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Markdown", 5 6 "tagline": "A library for adding new markdown rules",
+6 -6
packages/core-extensions/src/moonbase/index.tsx
··· 3 3 export const webpackModules: ExtensionWebExports["webpackModules"] = { 4 4 stores: { 5 5 dependencies: [ 6 - { ext: "common", id: "flux" }, 7 - { ext: "common", id: "fluxDispatcher" } 6 + { id: "discord/packages/flux" }, 7 + { id: "discord/Dispatcher" } 8 8 ] 9 9 }, 10 10 11 11 ui: { 12 12 dependencies: [ 13 13 { ext: "spacepack", id: "spacepack" }, 14 - { ext: "common", id: "react" }, 15 - { ext: "common", id: "components" }, 14 + { id: "react" }, 15 + { id: "discord/components/common/index" }, 16 16 { ext: "moonbase", id: "stores" }, 17 + { id: "discord/modules/guild_settings/IntegrationCard.css" }, 17 18 "Masks.PANEL_BUTTON", 18 - "renderArtisanalHack(){", 19 19 '"Missing channel in Channel.openChannelContextMenu"', 20 20 ".forumOrHome]:" 21 21 ] ··· 25 25 dependencies: [ 26 26 { ext: "spacepack", id: "spacepack" }, 27 27 { ext: "settings", id: "settings" }, 28 - { ext: "common", id: "react" }, 28 + { id: "react" }, 29 29 { ext: "moonbase", id: "ui" } 30 30 ], 31 31 entrypoint: true
+1
packages/core-extensions/src/moonbase/manifest.json
··· 1 1 { 2 2 "id": "moonbase", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Moonbase", 5 6 "tagline": "The official settings UI for moonlight",
+2 -2
packages/core-extensions/src/moonbase/webpackModules/moonbase.tsx
··· 1 1 import settings from "@moonlight-mod/wp/settings_settings"; 2 - import React from "@moonlight-mod/wp/common_react"; 2 + import React from "@moonlight-mod/wp/react"; 3 3 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 4 4 import { Moonbase, pages } from "@moonlight-mod/wp/moonbase_ui"; 5 5 6 6 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 7 - import { MenuItem } from "@moonlight-mod/wp/common_components"; 7 + import { MenuItem } from "@moonlight-mod/wp/discord/components/common/index"; 8 8 9 9 const { open } = spacepack.findByExports("setSection", "clearSubsection")[0] 10 10 .exports.Z;
+6 -3
packages/core-extensions/src/moonbase/webpackModules/stores.ts
··· 1 1 import { Config, ExtensionLoadSource } from "@moonlight-mod/types"; 2 2 import { ExtensionState, MoonbaseExtension, MoonbaseNatives } from "../types"; 3 - import Flux from "@moonlight-mod/wp/common_flux"; 4 - import Dispatcher from "@moonlight-mod/wp/common_fluxDispatcher"; 3 + import { Store } from "@moonlight-mod/wp/discord/packages/flux"; 4 + import Dispatcher from "@moonlight-mod/wp/discord/Dispatcher"; 5 5 6 6 const natives: MoonbaseNatives = moonlight.getNatives("moonbase"); 7 7 const logger = moonlight.getLogger("moonbase"); 8 8 9 - class MoonbaseSettingsStore extends Flux.Store<any> { 9 + class MoonbaseSettingsStore extends Store<any> { 10 10 private origConfig: Config; 11 11 private config: Config; 12 12 private extensionIndex: number; ··· 46 46 for (const [repo, exts] of Object.entries(ret)) { 47 47 try { 48 48 for (const ext of exts) { 49 + const level = ext.apiLevel ?? 1; 50 + if (level !== window.moonlight.apiLevel) continue; 51 + 49 52 const uniqueId = this.extensionIndex++; 50 53 const extensionData = { 51 54 id: ext.id,
+7 -5
packages/core-extensions/src/moonbase/webpackModules/ui/config/index.tsx
··· 4 4 (v) => typeof v === "string" 5 5 ) as string[]; 6 6 7 - import React from "@moonlight-mod/wp/common_react"; 7 + import React from "@moonlight-mod/wp/react"; 8 8 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 9 9 import { 10 10 FormDivider, ··· 12 12 FormText, 13 13 FormSwitch, 14 14 TextInput, 15 - Flex, 16 15 Button, 17 16 SingleSelect, 18 17 Tooltip, 19 18 Clickable 20 - } from "@moonlight-mod/wp/common_components"; 21 - import CommonComponents from "@moonlight-mod/wp/common_components"; 19 + } from "@moonlight-mod/wp/discord/components/common/index"; 20 + import Flex from "@moonlight-mod/wp/discord/uikit/Flex"; 21 + import * as Components from "@moonlight-mod/wp/discord/components/common/index"; 22 22 23 23 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 24 24 ··· 38 38 .exports) 39 39 ); 40 40 41 - const { CircleXIcon } = CommonComponents; 41 + // FIXME: type component keys 42 + const { CircleXIcon } = Components; 43 + 42 44 function RemoveEntryButton({ onClick }: { onClick: () => void }) { 43 45 return ( 44 46 <div className={RemoveButtonClasses.removeButtonContainer}>
+14 -22
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/card.tsx
··· 1 1 import { ExtensionState } from "../../../types"; 2 2 import { ExtensionLoadSource } from "@moonlight-mod/types"; 3 3 4 - import React from "@moonlight-mod/wp/common_react"; 5 4 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 6 - import CommonComponents from "@moonlight-mod/wp/common_components"; 7 - import * as Flux from "@moonlight-mod/wp/common_flux"; 5 + import * as Components from "@moonlight-mod/wp/discord/components/common/index"; 6 + import React from "@moonlight-mod/wp/react"; 7 + import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux"; 8 + import Flex from "@moonlight-mod/wp/discord/uikit/Flex"; 9 + import MarkupUtils from "@moonlight-mod/wp/discord/modules/markup/MarkupUtils"; 10 + import IntegrationCard from "@moonlight-mod/wp/discord/modules/guild_settings/IntegrationCard.css"; 8 11 9 12 import ExtensionInfo from "./info"; 10 13 import Settings from "./settings"; ··· 17 20 18 21 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 19 22 20 - const { DownloadIcon, TrashIcon, CircleWarningIcon } = CommonComponents; 23 + const { DownloadIcon, TrashIcon, CircleWarningIcon } = Components; 21 24 22 25 const PanelButton = spacepack.findByCode("Masks.PANEL_BUTTON")[0].exports.Z; 23 26 const TabBarClasses = spacepack.findByExports( ··· 30 33 const [tab, setTab] = React.useState(ExtensionPage.Info); 31 34 const [restartNeeded, setRestartNeeded] = React.useState(false); 32 35 33 - const { ext, enabled, busy, update, conflicting } = Flux.useStateFromStores( 36 + const { ext, enabled, busy, update, conflicting } = useStateFromStores( 34 37 [MoonbaseSettingsStore], 35 38 () => { 36 39 return { ··· 46 49 // Why it work like that :sob: 47 50 if (ext == null) return <></>; 48 51 49 - const { 50 - Card, 51 - CardClasses, 52 - Flex, 53 - Text, 54 - MarkdownParser, 55 - Switch, 56 - TabBar, 57 - Button 58 - } = CommonComponents; 52 + const { Card, Text, Switch, TabBar, Button } = Components; 59 53 60 54 const tagline = ext.manifest?.meta?.tagline; 61 55 const settings = ext.manifest?.settings; 62 56 const description = ext.manifest?.meta?.description; 63 57 64 58 return ( 65 - <Card editable={true} className={CardClasses.card}> 66 - <div className={CardClasses.cardHeader}> 59 + <Card editable={true} className={IntegrationCard.card}> 60 + <div className={IntegrationCard.cardHeader}> 67 61 <Flex direction={Flex.Direction.VERTICAL}> 68 62 <Flex direction={Flex.Direction.HORIZONTAL}> 69 63 <Text variant="text-md/semibold"> ··· 72 66 </Flex> 73 67 74 68 {tagline != null && ( 75 - <Text variant="text-sm/normal"> 76 - {MarkdownParser.parse(tagline)} 77 - </Text> 69 + <Text variant="text-sm/normal">{MarkupUtils.parse(tagline)}</Text> 78 70 )} 79 71 </Flex> 80 72 ··· 127 119 <PanelButton 128 120 icon={() => ( 129 121 <CircleWarningIcon 130 - color={CommonComponents.tokens.colors.STATUS_DANGER} 122 + color={Components.tokens.colors.STATUS_DANGER} 131 123 /> 132 124 )} 133 125 onClick={() => window.location.reload()} ··· 195 187 {tab === ExtensionPage.Info && <ExtensionInfo ext={ext} />} 196 188 {tab === ExtensionPage.Description && ( 197 189 <Text variant="text-md/normal"> 198 - {MarkdownParser.parse(description ?? "*No description*")} 190 + {MarkupUtils.parse(description ?? "*No description*")} 199 191 </Text> 200 192 )} 201 193 {tab === ExtensionPage.Settings && <Settings ext={ext} />}
+7 -6
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/filterBar.tsx
··· 1 1 import { tagNames } from "./info"; 2 2 3 3 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 4 - import React from "@moonlight-mod/wp/common_react"; 5 - import * as Flux from "@moonlight-mod/wp/common_flux"; 4 + import * as React from "@moonlight-mod/wp/react"; 5 + import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux"; 6 6 import { WindowStore } from "@moonlight-mod/wp/common_stores"; 7 7 import { 8 8 Button, ··· 14 14 MenuGroup, 15 15 MenuCheckboxItem, 16 16 MenuItem 17 - } from "@moonlight-mod/wp/common_components"; 18 - import CommonComponents from "@moonlight-mod/wp/common_components"; 17 + } from "@moonlight-mod/wp/discord/components/common/index"; 18 + import * as Components from "@moonlight-mod/wp/discord/components/common/index"; 19 19 20 20 export enum Filter { 21 21 Core = 1 << 0, ··· 51 51 const TagItem = spacepack.findByCode(".FORUM_TAG_A11Y_FILTER_BY_TAG")[0].exports 52 52 .Z; 53 53 54 + // FIXME: type component keys 54 55 const { ChevronSmallDownIcon, ChevronSmallUpIcon, ArrowsUpDownIcon } = 55 - CommonComponents; 56 + Components; 56 57 57 58 function toggleTag( 58 59 selectedTags: Set<string>, ··· 217 218 selectedTags: Set<string>; 218 219 setSelectedTags: (tags: Set<string>) => void; 219 220 }) { 220 - const windowSize = Flux.useStateFromStores([WindowStore], () => 221 + const windowSize = useStateFromStores([WindowStore], () => 221 222 WindowStore.windowSize() 222 223 ); 223 224
+3 -3
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/index.tsx
··· 3 3 import FilterBar, { Filter, defaultFilter } from "./filterBar"; 4 4 import ExtensionCard from "./card"; 5 5 6 - import React from "@moonlight-mod/wp/common_react"; 6 + import React from "@moonlight-mod/wp/react"; 7 7 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 8 - import * as Flux from "@moonlight-mod/wp/common_flux"; 8 + import { useStateFromStoresObject } from "@moonlight-mod/wp/discord/packages/flux"; 9 9 10 10 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 11 11 ··· 15 15 16 16 export default function ExtensionsPage() { 17 17 const moonbaseId = MoonbaseSettingsStore.getExtensionUniqueId("moonbase")!; 18 - const { extensions, savedFilter } = Flux.useStateFromStoresObject( 18 + const { extensions, savedFilter } = useStateFromStoresObject( 19 19 [MoonbaseSettingsStore], 20 20 () => { 21 21 return {
+8 -10
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/info.tsx
··· 1 1 import { ExtensionTag } from "@moonlight-mod/types"; 2 2 import { MoonbaseExtension } from "../../../types"; 3 3 4 - import React from "@moonlight-mod/wp/common_react"; 5 - import CommonComponents from "@moonlight-mod/wp/common_components"; 4 + import React from "@moonlight-mod/wp/react"; 5 + import * as Components from "@moonlight-mod/wp/discord/components/common/index"; 6 6 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 7 7 8 8 type Dependency = { ··· 42 42 43 43 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 44 44 45 + // FIXME: type component keys 46 + const { Text } = Components; 47 + 45 48 function InfoSection({ 46 49 title, 47 50 children ··· 55 58 marginRight: "1em" 56 59 }} 57 60 > 58 - <CommonComponents.Text 59 - variant="eyebrow" 60 - className={UserInfoClasses.userInfoSectionHeader} 61 - > 61 + <Text variant="eyebrow" className={UserInfoClasses.userInfoSectionHeader}> 62 62 {title} 63 - </CommonComponents.Text> 63 + </Text> 64 64 65 - <CommonComponents.Text variant="text-sm/normal"> 66 - {children} 67 - </CommonComponents.Text> 65 + <Text variant="text-sm/normal">{children}</Text> 68 66 </div> 69 67 ); 70 68 }
+19 -17
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/settings.tsx
··· 9 9 10 10 import { ExtensionState, MoonbaseExtension } from "../../../types"; 11 11 12 - import React from "@moonlight-mod/wp/common_react"; 13 - import CommonComponents from "@moonlight-mod/wp/common_components"; 14 - import * as Flux from "@moonlight-mod/wp/common_flux"; 15 12 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 13 + import React from "@moonlight-mod/wp/react"; 14 + import * as Components from "@moonlight-mod/wp/discord/components/common/index"; 15 + import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux"; 16 + import Flex from "@moonlight-mod/wp/discord/uikit/Flex"; 16 17 17 18 type SettingsProps = { 18 19 ext: MoonbaseExtension; ··· 24 25 type SettingsComponent = React.ComponentType<SettingsProps>; 25 26 26 27 import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; 27 - 28 - const Margins = spacepack.findByCode("marginCenterHorz:")[0].exports; 28 + const Margins = spacepack.require("discord/styles/shared/Margins.css"); 29 29 30 30 function useConfigEntry<T>(uniqueId: number, name: string) { 31 - return Flux.useStateFromStores( 31 + return useStateFromStores( 32 32 [MoonbaseSettingsStore], 33 33 () => { 34 34 return { ··· 48 48 } 49 49 50 50 function Boolean({ ext, name, setting, disabled }: SettingsProps) { 51 - const { FormSwitch } = CommonComponents; 51 + const { FormSwitch } = Components; 52 52 const { value, displayName, description } = useConfigEntry<boolean>( 53 53 ext.uniqueId, 54 54 name ··· 71 71 } 72 72 73 73 function Number({ ext, name, setting, disabled }: SettingsProps) { 74 - const { FormItem, FormText, Slider } = CommonComponents; 74 + const { FormItem, FormText, Slider } = Components; 75 75 const { value, displayName, description } = useConfigEntry<number>( 76 76 ext.uniqueId, 77 77 name ··· 99 99 } 100 100 101 101 function String({ ext, name, setting, disabled }: SettingsProps) { 102 - const { FormItem, FormText, TextInput } = CommonComponents; 102 + const { FormItem, FormText, TextInput } = Components; 103 103 const { value, displayName, description } = useConfigEntry<string>( 104 104 ext.uniqueId, 105 105 name ··· 122 122 } 123 123 124 124 function MultilineString({ ext, name, setting, disabled }: SettingsProps) { 125 - const { FormItem, FormText, TextArea } = CommonComponents; 125 + const { FormItem, FormText, TextArea } = Components; 126 126 const { value, displayName, description } = useConfigEntry<string>( 127 127 ext.uniqueId, 128 128 name ··· 147 147 } 148 148 149 149 function Select({ ext, name, setting, disabled }: SettingsProps) { 150 - const { FormItem, FormText, SingleSelect } = CommonComponents; 150 + const { FormItem, FormText, SingleSelect } = Components; 151 151 const { value, displayName, description } = useConfigEntry<string>( 152 152 ext.uniqueId, 153 153 name ··· 179 179 180 180 function MultiSelect({ ext, name, setting, disabled }: SettingsProps) { 181 181 const { FormItem, FormText, Select, useVariableSelect, multiSelect } = 182 - CommonComponents; 182 + Components; 183 183 const { value, displayName, description } = useConfigEntry<string | string[]>( 184 184 ext.uniqueId, 185 185 name ··· 219 219 220 220 const RemoveButtonClasses = spacepack.findByCode("removeButtonContainer")[0] 221 221 .exports; 222 - const CircleXIcon = CommonComponents.CircleXIcon; 222 + 223 + // FIXME: type component keys 224 + const { CircleXIcon } = Components; 225 + 223 226 function RemoveEntryButton({ 224 227 onClick, 225 228 disabled ··· 227 230 onClick: () => void; 228 231 disabled: boolean; 229 232 }) { 230 - const { Tooltip, Clickable } = CommonComponents; 233 + const { Tooltip, Clickable } = Components; 231 234 return ( 232 235 <div className={RemoveButtonClasses.removeButtonContainer}> 233 236 <Tooltip text="Remove entry" position="top"> ··· 246 249 } 247 250 248 251 function List({ ext, name, setting, disabled }: SettingsProps) { 249 - const { FormItem, FormText, TextInput, Button, Flex } = CommonComponents; 252 + const { FormItem, FormText, TextInput, Button } = Components; 250 253 const { value, displayName, description } = useConfigEntry<string[]>( 251 254 ext.uniqueId, 252 255 name ··· 312 315 } 313 316 314 317 function Dictionary({ ext, name, setting, disabled }: SettingsProps) { 315 - const { FormItem, FormText, TextInput, Button, Flex } = CommonComponents; 318 + const { FormItem, FormText, TextInput, Button } = Components; 316 319 const { value, displayName, description } = useConfigEntry< 317 320 Record<string, string> 318 321 >(ext.uniqueId, name); ··· 406 409 } 407 410 408 411 export default function Settings({ ext }: { ext: MoonbaseExtension }) { 409 - const { Flex } = CommonComponents; 410 412 return ( 411 413 <Flex className="moonbase-settings" direction={Flex.Direction.VERTICAL}> 412 414 {Object.entries(ext.manifest.settings!).map(([name, setting]) => (
+8 -6
packages/core-extensions/src/moonbase/webpackModules/ui/index.tsx
··· 1 - import React from "@moonlight-mod/wp/common_react"; 1 + import React from "@moonlight-mod/wp/react"; 2 2 import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; 3 - import { Text, TabBar } from "@moonlight-mod/wp/common_components"; 4 - import * as Flux from "@moonlight-mod/wp/common_flux"; 3 + import { 4 + Text, 5 + TabBar 6 + } from "@moonlight-mod/wp/discord/components/common/index"; 7 + import { useStateFromStores } from "@moonlight-mod/wp/discord/packages/flux"; 5 8 import { UserSettingsModalStore } from "@moonlight-mod/wp/common_stores"; 6 9 7 10 import ExtensionsPage from "./extensions"; 8 11 import ConfigPage from "./config"; 9 - 10 - const Margins = spacepack.findByCode("marginCenterHorz:")[0].exports; 11 12 12 13 const { Divider } = spacepack.findByCode(".forumOrHome]:")[0].exports.Z; 13 14 const TitleBarClasses = spacepack.findByCode("iconWrapper:", "children:")[0] ··· 17 18 "setSection", 18 19 "clearSubsection" 19 20 )[0].exports.Z; 21 + const Margins = spacepack.require("discord/styles/shared/Margins.css"); 20 22 21 23 export const pages: { 22 24 id: string; ··· 36 38 ]; 37 39 38 40 export function Moonbase(props: { initialTab?: number } = {}) { 39 - const subsection = Flux.useStateFromStores( 41 + const subsection = useStateFromStores( 40 42 [UserSettingsModalStore], 41 43 () => UserSettingsModalStore.getSubsection() ?? 0 42 44 );
+1
packages/core-extensions/src/noHideToken/manifest.json
··· 1 1 { 2 2 "id": "noHideToken", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "No Hide Token", 5 6 "tagline": "Disables removal of token from localStorage when opening dev tools",
+1
packages/core-extensions/src/noTrack/manifest.json
··· 1 1 { 2 2 "id": "noTrack", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "No Track", 5 6 "tagline": "Disables /api/science and analytics",
+1
packages/core-extensions/src/quietLoggers/manifest.json
··· 1 1 { 2 2 "id": "quietLoggers", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Quiet Loggers", 5 6 "tagline": "Quiet errors on startup, and disable unnecesary loggers",
+1
packages/core-extensions/src/settings/manifest.json
··· 1 1 { 2 2 "id": "settings", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Settings", 5 6 "tagline": "An API for adding to Discord's settings menu",
+1 -1
packages/core-extensions/src/settings/webpackModules/settings.ts
··· 1 1 import { 2 2 SettingsSection, 3 3 Settings as SettingsType 4 - } from "@moonlight-mod/types/coreExtensions"; 4 + } from "@moonlight-mod/types/coreExtensions/settings"; 5 5 6 6 export const Settings: SettingsType = { 7 7 ourSections: [],
+1 -1
packages/core-extensions/src/spacepack/index.ts
··· 1 1 import { ExtensionWebExports } from "@moonlight-mod/types"; 2 - import { Spacepack } from "@moonlight-mod/types/coreExtensions"; 2 + import { Spacepack } from "@moonlight-mod/types/coreExtensions/spacepack"; 3 3 4 4 declare global { 5 5 interface Window {
+1
packages/core-extensions/src/spacepack/manifest.json
··· 1 1 { 2 2 "id": "spacepack", 3 + "apiLevel": 2, 3 4 "meta": { 4 5 "name": "Spacepack", 5 6 "tagline": "Search utilities across all Webpack modules",
+5 -1
packages/core-extensions/src/spacepack/webpackModules/spacepack.ts
··· 3 3 WebpackModuleFunc, 4 4 WebpackRequireType 5 5 } from "@moonlight-mod/types"; 6 - import { Spacepack } from "@moonlight-mod/types/coreExtensions"; 6 + import { Spacepack } from "@moonlight-mod/types/coreExtensions/spacepack"; 7 7 8 8 const webpackRequire = require as unknown as WebpackRequireType; 9 9 const cache = webpackRequire.c; ··· 19 19 inspect: (module: number | string) => { 20 20 if (typeof module === "number") { 21 21 module = module.toString(); 22 + } 23 + 24 + if (module in moonlight.moonmap.modules) { 25 + module = moonlight.moonmap.modules[module]; 22 26 } 23 27 24 28 if (!(module in modules)) {
+4
packages/core/src/extension.ts
··· 44 44 const manifest: ExtensionManifest = JSON.parse( 45 45 fs.readFileSync(manifestPath, "utf8") 46 46 ); 47 + const level = manifest.apiLevel ?? 1; 48 + if (level !== constants.apiLevel) { 49 + continue; 50 + } 47 51 48 52 const webPath = path.join(dir, "index.js"); 49 53 const nodePath = path.join(dir, "node.js");
+1 -2
packages/core/src/extension/loader.ts
··· 17 17 async function loadExt(ext: DetectedExtension) { 18 18 webPreload: { 19 19 if (ext.scripts.web != null) { 20 - const source = 21 - ext.scripts.web + "\n//# sourceURL=file:///" + ext.scripts.webPath; 20 + const source = ext.scripts.web; 22 21 const fn = new Function("require", "module", "exports", source); 23 22 24 23 const module = { id: ext.id, exports: {} };
+107 -44
packages/core/src/patch.ts
··· 6 6 IdentifiedWebpackModule, 7 7 WebpackJsonp, 8 8 WebpackJsonpEntry, 9 - WebpackModuleFunc 9 + WebpackModuleFunc, 10 + WebpackRequireType 10 11 } from "@moonlight-mod/types"; 11 12 import Logger from "./util/logger"; 12 13 import calculateDependencies, { Dependency } from "./util/dependency"; ··· 18 19 // Can't be Set because we need splice 19 20 const patches: IdentifiedPatch[] = []; 20 21 let webpackModules: Set<IdentifiedWebpackModule> = new Set(); 22 + let webpackRequire: WebpackRequireType | null = null; 21 23 22 24 const moduleLoadSubscriptions: Map<string, ((moduleId: string) => void)[]> = 23 25 new Map(); ··· 66 68 const patched: Record<string, Array<string>> = {}; 67 69 68 70 function patchModules(entry: WebpackJsonpEntry[1]) { 71 + function patchModule(id: string, patchId: string, replaced: string) { 72 + // Store what extensions patched what modules for easier debugging 73 + patched[id] = patched[id] || []; 74 + patched[id].push(patchId); 75 + 76 + // Webpack module arguments are minified, so we replace them with consistent names 77 + // We have to wrap it so things don't break, though 78 + const patchedStr = patched[id].sort().join(", "); 79 + 80 + const wrapped = 81 + `(${replaced}).apply(this, arguments)\n` + 82 + `// Patched by moonlight: ${patchedStr}\n` + 83 + `//# sourceURL=Webpack-Module-${id}`; 84 + 85 + try { 86 + const func = new Function( 87 + "module", 88 + "exports", 89 + "require", 90 + wrapped 91 + ) as WebpackModuleFunc; 92 + entry[id] = func; 93 + entry[id].__moonlight = true; 94 + return true; 95 + } catch (e) { 96 + logger.warn("Error constructing function for patch", patchId, e); 97 + patched[id].pop(); 98 + return false; 99 + } 100 + } 101 + 102 + // Populate the module cache 69 103 for (const [id, func] of Object.entries(entry)) { 70 - let moduleString = Object.prototype.hasOwnProperty.call(moduleCache, id) 71 - ? moduleCache[id] 72 - : func.toString().replace(/\n/g, ""); 104 + if (!Object.hasOwn(moduleCache, id) && func.__moonlight !== true) { 105 + moduleCache[id] = func.toString().replace(/\n/g, ""); 106 + moonlight.moonmap.parseScript(id, moduleCache[id]); 107 + } 108 + } 109 + 110 + for (const [id, func] of Object.entries(entry)) { 111 + if (func.__moonlight === true) continue; 112 + let moduleString = moduleCache[id]; 73 113 74 114 for (let i = 0; i < patches.length; i++) { 75 115 const patch = patches[i]; ··· 123 163 continue; 124 164 } 125 165 126 - // Store what extensions patched what modules for easier debugging 127 - patched[id] = patched[id] || []; 128 - patched[id].push(`${patch.ext}#${patch.id}`); 129 - 130 - // Webpack module arguments are minified, so we replace them with consistent names 131 - // We have to wrap it so things don't break, though 132 - const patchedStr = patched[id].sort().join(", "); 133 - 134 - const wrapped = 135 - `(${replaced}).apply(this, arguments)\n` + 136 - `// Patched by moonlight: ${patchedStr}\n` + 137 - `//# sourceURL=Webpack-Module-${id}`; 138 - 139 - try { 140 - const func = new Function( 141 - "module", 142 - "exports", 143 - "require", 144 - wrapped 145 - ) as WebpackModuleFunc; 146 - entry[id] = func; 147 - entry[id].__moonlight = true; 166 + if (patchModule(id, `${patch.ext}#${patch.id}`, replaced)) { 148 167 moduleString = replaced; 149 - } catch (e) { 150 - logger.warn("Error constructing function for patch", patch, e); 151 - patched[id].pop(); 152 168 } 153 169 } else if (replace.type === PatchReplaceType.Module) { 154 170 // Directly replace the module with a new one ··· 166 182 } 167 183 } 168 184 185 + moduleCache[id] = moduleString; 186 + 187 + try { 188 + const parsed = moonlight.lunast.parseScript(id, moduleString); 189 + if (parsed != null) { 190 + for (const [parsedId, parsedScript] of Object.entries(parsed)) { 191 + if (patchModule(parsedId, "lunast", parsedScript)) { 192 + moduleCache[parsedId] = parsedScript; 193 + } 194 + } 195 + } 196 + } catch (e) { 197 + logger.error("Failed to parse script for LunAST", id, e); 198 + } 199 + 169 200 if (moonlightNode.config.patchAll === true) { 170 201 if ( 171 202 (typeof id !== "string" || !id.includes("_")) && 172 203 !entry[id].__moonlight 173 204 ) { 174 205 const wrapped = 175 - `(${moduleString}).apply(this, arguments)\n` + 206 + `(${moduleCache[id]}).apply(this, arguments)\n` + 176 207 `//# sourceURL=Webpack-Module-${id}`; 177 208 entry[id] = new Function( 178 209 "module", ··· 207 238 mark when we've completed it already. 208 239 */ 209 240 let chunkId = Number.MAX_SAFE_INTEGER; 241 + 242 + function depToString(x: ExplicitExtensionDependency) { 243 + return x.ext != null ? `${x.ext}_${x.id}` : x.id; 244 + } 210 245 211 246 function handleModuleDependencies() { 212 247 const modules = Array.from(webpackModules.values()); ··· 214 249 const dependencies: Dependency<string, IdentifiedWebpackModule>[] = 215 250 modules.map((wp) => { 216 251 return { 217 - id: `${wp.ext}_${wp.id}`, 252 + id: depToString(wp), 218 253 data: wp 219 254 }; 220 255 }); 221 256 222 257 const [sorted, _] = calculateDependencies(dependencies, { 223 258 fetchDep: (id) => { 224 - return modules.find((x) => id === `${x.ext}_${x.id}`) ?? null; 259 + return modules.find((x) => id === depToString(x)) ?? null; 225 260 }, 226 261 227 262 getDeps: (item) => { ··· 229 264 return ( 230 265 deps.filter( 231 266 (dep) => 232 - !( 233 - dep instanceof RegExp || 234 - typeof dep === "string" || 235 - dep.ext === undefined 236 - ) 267 + !(dep instanceof RegExp || typeof dep === "string") && 268 + dep.ext != null 237 269 ) as ExplicitExtensionDependency[] 238 - ).map((x) => `${x.ext}_${x.id}`); 270 + ).map(depToString); 239 271 } 240 272 }); 241 273 ··· 251 283 for (const [_modId, mod] of Object.entries(entry)) { 252 284 const modStr = mod.toString(); 253 285 for (const wpModule of webpackModules) { 254 - const id = wpModule.ext ? wpModule.ext + "_" + wpModule.id : wpModule.id; 286 + const id = depToString(wpModule); 255 287 if (wpModule.dependencies) { 256 288 const deps = new Set(wpModule.dependencies); 257 289 ··· 264 296 } else if (dep instanceof RegExp) { 265 297 if (dep.test(modStr)) deps.delete(dep); 266 298 } else if ( 267 - injectedWpModules.find((x) => 268 - wpModule.ext 269 - ? x.ext === dep.ext && x.id === dep.id 270 - : x.id === dep.id 271 - ) 299 + dep.ext != null 300 + ? injectedWpModules.find( 301 + (x) => x.ext === dep.ext && x.id === dep.id 302 + ) 303 + : injectedWpModules.find((x) => x.id === dep.id) 272 304 ) { 273 305 deps.delete(dep); 274 306 } ··· 298 330 if (!webpackModules.size) break; 299 331 } 300 332 333 + for (const [name, func] of Object.entries( 334 + moonlight.moonmap.getWebpackModules("window.moonlight.moonmap") 335 + )) { 336 + injectedWpModules.push({ id: name, run: func }); 337 + modules[name] = func; 338 + inject = true; 339 + } 340 + 341 + if (webpackRequire != null) { 342 + for (const id of moonlight.moonmap.getLazyModules()) { 343 + webpackRequire.e(id); 344 + } 345 + } 346 + 301 347 if (inject) { 302 348 logger.debug("Injecting modules:", modules, entrypoints); 303 349 window.webpackChunkdiscord_app.push([ ··· 312 358 interface Window { 313 359 webpackChunkdiscord_app: WebpackJsonp; 314 360 } 361 + } 362 + 363 + function moduleSourceGetter(id: string) { 364 + return moduleCache[id] ?? null; 315 365 } 316 366 317 367 /* ··· 324 374 */ 325 375 export async function installWebpackPatcher() { 326 376 await handleModuleDependencies(); 377 + 378 + moonlight.lunast.setModuleSourceGetter(moduleSourceGetter); 379 + moonlight.moonmap.setModuleSourceGetter(moduleSourceGetter); 380 + 381 + const wpRequireFetcher: WebpackModuleFunc = (module, exports, require) => { 382 + webpackRequire = require; 383 + }; 384 + wpRequireFetcher.__moonlight = true; 385 + webpackModules.add({ 386 + id: "moonlight", 387 + entrypoint: true, 388 + run: wpRequireFetcher 389 + }); 327 390 328 391 let realWebpackJsonp: WebpackJsonp | null = null; 329 392 Object.defineProperty(window, "webpackChunkdiscord_app", {
+10
packages/core/src/persist.ts
··· 11 11 const logger = new Logger("core/persist"); 12 12 13 13 export default function persist(asarPath: string) { 14 + try { 15 + if (process.platform === "win32") { 16 + persistWin32(asarPath); 17 + } 18 + } catch (e) { 19 + logger.error(`Failed to persist moonlight: ${e}`); 20 + } 21 + } 22 + 23 + function persistWin32(asarPath: string) { 14 24 const updaterModule = require(join(asarPath, "common", "updater")); 15 25 const updater = updaterModule.Updater; 16 26
packages/core/src/util/clone.ts

This is a binary file and will not be displayed.

+4 -2
packages/types/package.json
··· 9 9 "./*": "./src/*.ts" 10 10 }, 11 11 "dependencies": { 12 - "@types/flux": "^3.1.12", 13 - "@types/react": "^18.2.22", 12 + "@moonlight-mod/lunast": "^1.0.0", 13 + "@moonlight-mod/mappings": "^1.0.0", 14 + "@moonlight-mod/moonmap": "^1.0.2", 15 + "@types/react": "^18.3.10", 14 16 "csstype": "^3.1.2", 15 17 "standalone-electron-types": "^1.0.0" 16 18 }
+2
packages/types/src/constants.ts
··· 8 8 export const ipcGetIsMoonlightDesktop = "_moonlight_getIsMoonlightDesktop"; 9 9 export const ipcMessageBox = "_moonlight_messageBox"; 10 10 export const ipcSetCorsList = "_moonlight_setCorsList"; 11 + 12 + export const apiLevel = 2;
+2 -102
packages/types/src/coreExtensions.ts
··· 1 - import { FluxDefault, Store } from "./discord/common/Flux"; 2 - import { CommonComponents as CommonComponents_ } from "./coreExtensions/components"; 3 - import { Dispatcher } from "flux"; 4 - import React, { ReactElement } from "react"; 5 - import { 6 - WebpackModule, 7 - WebpackModuleFunc, 8 - WebpackRequireType 9 - } from "./discord"; 10 - 11 - export type Spacepack = { 12 - inspect: (module: number | string) => WebpackModuleFunc | null; 13 - findByCode: (...args: (string | RegExp)[]) => any[]; 14 - findByExports: (...args: string[]) => any[]; 15 - require: WebpackRequireType; 16 - modules: Record<string, WebpackModuleFunc>; 17 - cache: Record<string, any>; 18 - findObjectFromKey: (exports: Record<string, any>, key: string) => any | null; 19 - findObjectFromValue: (exports: Record<string, any>, value: any) => any | null; 20 - findObjectFromKeyValuePair: ( 21 - exports: Record<string, any>, 22 - key: string, 23 - value: any 24 - ) => any | null; 25 - findFunctionByStrings: ( 26 - exports: Record<string, any>, 27 - ...strings: (string | RegExp)[] 28 - // eslint-disable-next-line @typescript-eslint/ban-types 29 - ) => Function | null; 30 - lazyLoad: ( 31 - find: string | RegExp | (string | RegExp)[], 32 - chunk: RegExp, 33 - module: RegExp 34 - ) => Promise<any>; 35 - filterReal: (modules: WebpackModule[]) => WebpackModule[]; 36 - }; 37 - 38 - export type NoticeProps = { 39 - stores: Store<any>[]; 40 - element: React.FunctionComponent; 41 - }; 42 - 43 - export type SettingsSection = 44 - | { section: "DIVIDER"; pos: number } 45 - | { section: "HEADER"; label: string; pos: number } 46 - | { 47 - section: string; 48 - label: string; 49 - color: string | null; 50 - element: React.FunctionComponent; 51 - pos: number; 52 - notice?: NoticeProps; 53 - _moonlight_submenu?: () => ReactElement | ReactElement[]; 54 - }; 55 - 56 - export type Settings = { 57 - ourSections: SettingsSection[]; 58 - sectionNames: string[]; 59 - sectionMenuItems: Record<string, ReactElement[]>; 60 - 61 - addSection: ( 62 - section: string, 63 - label: string, 64 - element: React.FunctionComponent, 65 - color?: string | null, 66 - pos?: number, 67 - notice?: NoticeProps 68 - ) => void; 69 - addSectionMenuItems: (section: string, ...items: ReactElement[]) => void; 70 - 71 - addDivider: (pos: number | null) => void; 72 - addHeader: (label: string, pos: number | null) => void; 73 - _mutateSections: (sections: SettingsSection[]) => SettingsSection[]; 74 - }; 75 - 76 - export type CommonReact = typeof import("react"); 77 - export type CommonFlux = FluxDefault; 78 - export type CommonComponents = CommonComponents_; // lol 79 - export type CommonFluxDispatcher = Dispatcher<any> & { 80 - dispatch: (payload: any) => void; 81 - isDispatching: () => boolean; 82 - 83 - addInterceptor: (interceptor: (event: any) => boolean | undefined) => void; 84 - 85 - flushWaitQueue: () => void; 86 - wait: (callback: () => void) => void; 87 - 88 - subscribe: (eventType: string, callback: (event: any) => void) => void; 89 - unsubscribe: (eventType: string, callback: (event: any) => void) => void; 90 - 91 - register: ( 92 - name: string, 93 - actionHandlers: Record<string, (event: any) => void>, 94 - storeDidChange: (event: any) => void, 95 - band: number, 96 - token: string 97 - ) => number; 98 - 99 - createToken: () => string; 100 - addDependencies: (id: string, deps: string[]) => void; 101 - }; 102 - 1 + export * as Spacepack from "./coreExtensions/spacepack"; 2 + export * as Settings from "./coreExtensions/settings"; 103 3 export * as Markdown from "./coreExtensions/markdown"; 104 4 export * as ContextMenu from "./coreExtensions/contextMenu";
-409
packages/types/src/coreExtensions/components.ts
··· 1 - import type { 2 - Component, 3 - Ref, 4 - PropsWithChildren, 5 - PropsWithoutRef, 6 - CSSProperties, 7 - ReactNode, 8 - ReactElement, 9 - ComponentClass, 10 - ComponentType, 11 - MouseEventHandler, 12 - KeyboardEventHandler 13 - } from "react"; 14 - import * as CSS from "csstype"; 15 - 16 - export enum TextInputSizes { 17 - DEFAULT = "inputDefault", 18 - MINI = "inputMini" 19 - } 20 - 21 - interface TextInput 22 - extends ComponentClass< 23 - PropsWithoutRef<{ 24 - value?: string; 25 - name?: string; 26 - className?: string; 27 - inputClassName?: string; 28 - inputPrefix?: string; 29 - disabled?: boolean; 30 - size?: TextInputSizes; 31 - editable?: boolean; 32 - inputRef?: Ref<any>; 33 - prefixElement?: Component; 34 - focusProps?: PropsWithoutRef<any>; 35 - error?: string; 36 - minLength?: number; 37 - maxLength?: number; 38 - onChange?: (value: string, name: string) => void; 39 - onFocus?: (event: any, name: string) => void; 40 - onBlur?: (event: any, name: string) => void; 41 - }> 42 - > { 43 - Sizes: typeof TextInputSizes; 44 - } 45 - 46 - export enum TextAreaAutoComplete { 47 - ON = "on", 48 - OFF = "off" 49 - } 50 - 51 - export enum TextAreaWrap { 52 - HARD = "hard", 53 - SOFT = "soft", 54 - OFF = "off" 55 - } 56 - 57 - interface TextArea 58 - extends ComponentClass< 59 - PropsWithoutRef<{ 60 - value?: string; 61 - defaultValue?: string; 62 - autoComplete?: TextAreaAutoComplete; 63 - autoFocus?: boolean; 64 - cols?: number; 65 - disabled?: boolean; 66 - form?: string; 67 - maxLength?: number; 68 - minLength?: number; 69 - name?: string; 70 - onChange?: (value: string, name: string) => void; 71 - onChangeCapture?: (value: string, name: string) => void; 72 - onInput?: (value: string, name: string) => void; 73 - onInputCapture?: (value: string, name: string) => void; 74 - onInvalid?: (value: string, name: string) => void; 75 - onInvalidCapture?: (value: string, name: string) => void; 76 - onSelect?: (value: string, name: string) => void; 77 - onSelectCapture?: (value: string, name: string) => void; 78 - placeholder?: string; 79 - readOnly?: boolean; 80 - required?: boolean; 81 - rows?: number; 82 - wrap?: TextAreaWrap; 83 - className?: string; 84 - }> 85 - > { 86 - AutoCompletes: typeof TextAreaAutoComplete; 87 - Wraps: typeof TextAreaWrap; 88 - } 89 - 90 - export enum FormTextTypes { 91 - DEFAULT = "default", 92 - DESCRIPTION = "description", 93 - ERROR = "error", 94 - INPUT_PLACEHOLDER = "placeholder", 95 - LABEL_BOLD = "labelBold", 96 - LABEL_DESCRIPTOR = "labelDescriptor", 97 - LABEL_SELECTED = "labelSelected", 98 - SUCCESS = "success" 99 - } 100 - 101 - interface FormText 102 - extends ComponentClass< 103 - PropsWithChildren<{ 104 - type?: FormTextTypes; 105 - className?: string; 106 - disabled?: boolean; 107 - selectable?: boolean; 108 - style?: CSSProperties; 109 - }> 110 - > { 111 - Types: FormTextTypes; 112 - } 113 - 114 - declare enum SliderMarkerPosition { 115 - ABOVE, 116 - BELOW 117 - } 118 - 119 - declare enum ButtonLooks { 120 - FILLED = "lookFilled", 121 - INVERTED = "lookInverted", 122 - OUTLINED = "lookOutlined", 123 - LINK = "lookLink", 124 - BLANK = "lookBlank" 125 - } 126 - declare enum ButtonColors { 127 - BRAND = "colorBrand", 128 - RED = "colorRed", 129 - GREEN = "colorGreen", 130 - YELLOW = "colorYellow", 131 - PRIMARY = "colorPrimary", 132 - LINK = "colorLink", 133 - WHITE = "colorWhite", 134 - BLACK = "colorBlack", 135 - TRANSPARENT = "colorTransparent", 136 - BRAND_NEW = "colorBrandNew", 137 - CUSTOM = "" 138 - } 139 - declare enum ButtonBorderColors { 140 - BRAND = "borderBrand", 141 - RED = "borderRed", 142 - GREEN = "borderGreen", 143 - YELLOW = "borderYellow", 144 - PRIMARY = "borderPrimary", 145 - LINK = "borderLink", 146 - WHITE = "borderWhite", 147 - BLACK = "borderBlack", 148 - TRANSPARENT = "borderTransparent", 149 - BRAND_NEW = "borderBrandNew" 150 - } 151 - declare enum ButtonHovers { 152 - DEFAULT = "", 153 - BRAND = "hoverBrand", 154 - RED = "hoverRed", 155 - GREEN = "hoverGreen", 156 - YELLOW = "hoverYellow", 157 - PRIMARY = "hoverPrimary", 158 - LINK = "hoverLink", 159 - WHITE = "hoverWhite", 160 - BLACK = "hoverBlack", 161 - TRANSPARENT = "hoverTransparent" 162 - } 163 - declare enum ButtonSizes { 164 - NONE = "", 165 - TINY = "sizeTiny", 166 - SMALL = "sizeSmall", 167 - MEDIUM = "sizeMedium", 168 - LARGE = "sizeLarge", 169 - XLARGE = "sizeXlarge", 170 - MIN = "sizeMin", 171 - MAX = "sizeMax", 172 - ICON = "sizeIcon" 173 - } 174 - 175 - type Button = ComponentType< 176 - PropsWithChildren<{ 177 - look?: ButtonLooks; 178 - color?: ButtonColors; 179 - borderColor?: ButtonBorderColors; 180 - hover?: ButtonHovers; 181 - size?: ButtonSizes; 182 - fullWidth?: boolean; 183 - grow?: boolean; 184 - disabled?: boolean; 185 - submitting?: boolean; 186 - type?: string; 187 - style?: CSSProperties; 188 - wrapperClassName?: string; 189 - className?: string; 190 - innerClassName?: string; 191 - onClick?: MouseEventHandler; 192 - onDoubleClick?: MouseEventHandler; 193 - onMouseDown?: MouseEventHandler; 194 - onMouseUp?: MouseEventHandler; 195 - onMouseEnter?: MouseEventHandler; 196 - onMouseLeave?: MouseEventHandler; 197 - onKeyDown?: KeyboardEventHandler; 198 - rel?: any; 199 - buttonRef?: Ref<any>; 200 - focusProps?: PropsWithChildren<any>; 201 - "aria-label"?: string; 202 - submittingStartedLabel?: string; 203 - submittingFinishedLabel?: string; 204 - }> 205 - > & { 206 - Looks: typeof ButtonLooks; 207 - Colors: typeof ButtonColors; 208 - BorderColors: typeof ButtonBorderColors; 209 - Hovers: typeof ButtonHovers; 210 - Sizes: typeof ButtonSizes; 211 - }; 212 - 213 - export enum FlexDirection { 214 - VERTICAL = "vertical", 215 - HORIZONTAL = "horizontal", 216 - HORIZONTAL_REVERSE = "horizontalReverse" 217 - } 218 - 219 - declare enum FlexAlign { 220 - START = "alignStart", 221 - END = "alignEnd", 222 - CENTER = "alignCenter", 223 - STRETCH = "alignStretch", 224 - BASELINE = "alignBaseline" 225 - } 226 - declare enum FlexJustify { 227 - START = "justifyStart", 228 - END = "justifyEnd", 229 - CENTER = "justifyCenter", 230 - BETWEEN = "justifyBetween", 231 - AROUND = "justifyAround" 232 - } 233 - declare enum FlexWrap { 234 - NO_WRAP = "noWrap", 235 - WRAP = "wrap", 236 - WRAP_REVERSE = "wrapReverse" 237 - } 238 - interface Flex 239 - extends ComponentClass< 240 - PropsWithChildren<{ 241 - className?: string; 242 - direction?: FlexDirection; 243 - justify?: FlexJustify; 244 - align?: FlexAlign; 245 - wrap?: FlexWrap; 246 - shrink?: CSS.Property.FlexShrink; 247 - grow?: CSS.Property.FlexGrow; 248 - basis?: CSS.Property.FlexBasis; 249 - style?: CSSProperties; 250 - }> 251 - > { 252 - Direction: typeof FlexDirection; 253 - Align: typeof FlexAlign; 254 - Justify: typeof FlexJustify; 255 - Wrap: typeof FlexWrap; 256 - Child: Component< 257 - PropsWithChildren<{ 258 - className?: string; 259 - shrink?: CSS.Property.FlexShrink; 260 - grow?: CSS.Property.FlexGrow; 261 - basis?: CSS.Property.FlexBasis; 262 - style?: CSSProperties; 263 - wrap?: boolean; 264 - }> 265 - >; 266 - } 267 - 268 - // TODO: wtaf is up with react types not working in jsx 269 - export type CommonComponents = { 270 - [index: string]: any; 271 - Clickable: ComponentClass< 272 - PropsWithChildren<{ 273 - onClick?: () => void; 274 - href?: any; 275 - onKeyPress?: () => void; 276 - ignoreKeyPress?: boolean; 277 - innerRef?: Ref<any>; 278 - focusProps?: any; 279 - tag?: string | Component; 280 - role?: any; 281 - tabIndex?: any; 282 - className?: string; 283 - }> 284 - >; 285 - TextInput: TextInput; 286 - TextArea: TextArea; 287 - FormDivider: ComponentClass<any>; 288 - FormSection: ComponentClass< 289 - PropsWithChildren<{ 290 - className?: string; 291 - titleClassName?: string; 292 - title?: ReactNode; 293 - icon?: ReactNode; 294 - disabled?: boolean; 295 - htmlFor?: any; 296 - tag?: string; 297 - }> 298 - >; 299 - FormText: FormText; 300 - FormTitle: ComponentClass< 301 - PropsWithChildren<{ 302 - tag?: string; 303 - className?: string; 304 - faded?: boolean; 305 - disabled?: boolean; 306 - required?: boolean; 307 - error?: string; 308 - }> 309 - >; 310 - FormSwitch: ComponentClass<PropsWithChildren<any>>; 311 - FormItem: ComponentClass<PropsWithChildren<any>>; 312 - Slider: ComponentClass< 313 - PropsWithChildren<{ 314 - disabled?: boolean; 315 - stickToMarkers?: boolean; 316 - className?: string; 317 - barStyles?: CSSProperties; 318 - fillStyles?: CSSProperties; 319 - mini?: boolean; 320 - hideBubble?: boolean; 321 - initialValue?: number; 322 - orientation?: "horizontal" | "vertical"; 323 - onValueRender?: (value: number) => string; 324 - renderMarker?: (marker: number) => ReactNode; 325 - getAriaValueText?: (value: number) => string; 326 - barClassName?: string; 327 - grabberClassName?: string; 328 - grabberStyles?: CSSProperties; 329 - markerPosition?: SliderMarkerPosition; 330 - "aria-hidden"?: "true" | "false"; 331 - "aria-label"?: string; 332 - "aria-labelledby"?: string; 333 - "aria-describedby"?: string; 334 - minValue?: number; 335 - maxValue?: number; 336 - asValueChanges?: (value: number) => void; 337 - onValueChange?: (value: number) => void; 338 - keyboardStep?: number; 339 - }> 340 - >; 341 - Switch: ComponentClass<PropsWithChildren<any>>; 342 - Button: Button; 343 - Tooltip: ComponentClass<PropsWithChildren<any>>; 344 - SmallSlider: Component; 345 - Avatar: Component; 346 - Scroller: Component; 347 - Text: ComponentClass<PropsWithChildren<any>>; 348 - Heading: ComponentClass<PropsWithChildren<any>>; 349 - LegacyText: Component; 350 - Flex: Flex; 351 - Card: ComponentClass<PropsWithChildren<any>>; 352 - Popout: ComponentClass<PropsWithChildren<any>>; 353 - Dialog: ComponentClass<PropsWithChildren<any>>; 354 - Menu: ComponentClass<PropsWithChildren<any>>; 355 - MenuItem: ComponentClass<PropsWithChildren<any>>; 356 - MenuGroup: ComponentClass<PropsWithChildren<any>>; 357 - MenuCheckboxItem: ComponentClass<PropsWithChildren<any>>; 358 - CardClasses: { 359 - card: string; 360 - cardHeader: string; 361 - }; 362 - ControlClasses: { 363 - container: string; 364 - control: string; 365 - disabled: string; 366 - dividerDefault: string; 367 - labelRow: string; 368 - note: string; 369 - title: string; 370 - titleDefault: string; 371 - titleMini: string; 372 - }; 373 - MarkdownParser: { 374 - parse: (text: string) => ReactElement; 375 - }; 376 - SettingsNotice: React.ComponentType<{ 377 - submitting: boolean; 378 - onReset: () => void; 379 - onSave: () => void; 380 - }>; 381 - TabBar: React.ComponentType<any> & { 382 - Item: React.ComponentType<any>; 383 - }; 384 - SingleSelect: React.ComponentType<{ 385 - autofocus?: boolean; 386 - clearable?: boolean; 387 - value?: string; 388 - options?: { 389 - value: string; 390 - label: string; 391 - }[]; 392 - onChange?: (value: string) => void; 393 - }>; 394 - Select: React.ComponentType<{ 395 - autofocus?: boolean; 396 - clearable?: boolean; 397 - value?: string[]; 398 - options?: { 399 - value: string; 400 - label: string; 401 - }[]; 402 - onChange?: (value: string[]) => void; 403 - }>; 404 - 405 - // TODO 406 - useVariableSelect: any; 407 - multiSelect: any; 408 - tokens: any; 409 - };
+40
packages/types/src/coreExtensions/settings.ts
··· 1 + import React, { ReactElement } from "react"; 2 + import type { Store } from "@moonlight-mod/mappings/discord/packages/flux"; 3 + 4 + export type NoticeProps = { 5 + stores: Store<any>[]; 6 + element: React.FunctionComponent; 7 + }; 8 + 9 + export type SettingsSection = 10 + | { section: "DIVIDER"; pos: number } 11 + | { section: "HEADER"; label: string; pos: number } 12 + | { 13 + section: string; 14 + label: string; 15 + color: string | null; 16 + element: React.FunctionComponent; 17 + pos: number; 18 + notice?: NoticeProps; 19 + _moonlight_submenu?: () => ReactElement | ReactElement[]; 20 + }; 21 + 22 + export type Settings = { 23 + ourSections: SettingsSection[]; 24 + sectionNames: string[]; 25 + sectionMenuItems: Record<string, ReactElement[]>; 26 + 27 + addSection: ( 28 + section: string, 29 + label: string, 30 + element: React.FunctionComponent, 31 + color?: string | null, 32 + pos?: number, 33 + notice?: NoticeProps 34 + ) => void; 35 + addSectionMenuItems: (section: string, ...items: ReactElement[]) => void; 36 + 37 + addDivider: (pos: number | null) => void; 38 + addHeader: (label: string, pos: number | null) => void; 39 + _mutateSections: (sections: SettingsSection[]) => SettingsSection[]; 40 + };
+32
packages/types/src/coreExtensions/spacepack.ts
··· 1 + import { 2 + WebpackModule, 3 + WebpackModuleFunc, 4 + WebpackRequireType 5 + } from "../discord"; 6 + 7 + export type Spacepack = { 8 + inspect: (module: number | string) => WebpackModuleFunc | null; 9 + findByCode: (...args: (string | RegExp)[]) => any[]; 10 + findByExports: (...args: string[]) => any[]; 11 + require: WebpackRequireType; 12 + modules: Record<string, WebpackModuleFunc>; 13 + cache: Record<string, any>; 14 + findObjectFromKey: (exports: Record<string, any>, key: string) => any | null; 15 + findObjectFromValue: (exports: Record<string, any>, value: any) => any | null; 16 + findObjectFromKeyValuePair: ( 17 + exports: Record<string, any>, 18 + key: string, 19 + value: any 20 + ) => any | null; 21 + findFunctionByStrings: ( 22 + exports: Record<string, any>, 23 + ...strings: (string | RegExp)[] 24 + // eslint-disable-next-line @typescript-eslint/ban-types 25 + ) => Function | null; 26 + lazyLoad: ( 27 + find: string | RegExp | (string | RegExp)[], 28 + chunk: RegExp, 29 + module: RegExp 30 + ) => Promise<any>; 31 + filterReal: (modules: WebpackModule[]) => WebpackModule[]; 32 + };
-57
packages/types/src/discord/common/Flux.ts
··· 1 - /* 2 - It seems like Discord maintains their own version of Flux that doesn't match 3 - the types on NPM. This is a heavy work in progress - if you encounter rough 4 - edges, please contribute! 5 - */ 6 - 7 - import { DependencyList } from "react"; 8 - import { Store as FluxStore } from "flux/utils"; 9 - import { Dispatcher as FluxDispatcher } from "flux"; 10 - import { ComponentConstructor } from "flux/lib/FluxContainer"; 11 - 12 - export declare abstract class Store<T> extends FluxStore<T> { 13 - static getAll: () => Store<any>[]; 14 - getName: () => string; 15 - emitChange: () => void; 16 - } 17 - 18 - interface ConnectStores { 19 - <T>( 20 - stores: Store<any>[], 21 - callback: T, 22 - context?: any 23 - ): ComponentConstructor<T>; 24 - } 25 - 26 - export type FluxDefault = { 27 - DeviceSettingsStore: any; // TODO 28 - Emitter: any; // @types/fbemitter 29 - OfflineCacheStore: any; // TODO 30 - PersistedStore: any; // TODO 31 - Store: typeof Store; 32 - Dispatcher: typeof FluxDispatcher; 33 - connectStores: ConnectStores; 34 - initialize: () => void; 35 - initialized: Promise<boolean>; 36 - destroy: () => void; 37 - useStateFromStores: UseStateFromStores; 38 - useStateFromStoresArray: UseStateFromStoresArray; 39 - useStateFromStoresObject: UseStateFromStoresObject; 40 - }; 41 - 42 - interface UseStateFromStores { 43 - <T>( 44 - stores: Store<any>[], 45 - callback: () => T, 46 - deps?: DependencyList, 47 - shouldUpdate?: (oldState: T, newState: T) => boolean 48 - ): T; 49 - } 50 - 51 - interface UseStateFromStoresArray { 52 - <T>(stores: Store<any>[], callback: () => T, deps?: DependencyList): T; 53 - } 54 - 55 - interface UseStateFromStoresObject { 56 - <T>(stores: Store<any>[], callback: () => T, deps?: DependencyList): T; 57 - }
+10 -22
packages/types/src/discord/require.ts
··· 1 - import { 2 - Spacepack, 3 - CommonReact, 4 - CommonFlux, 5 - Settings, 6 - CommonComponents, 7 - CommonFluxDispatcher 8 - } from "../coreExtensions"; 9 1 import { ContextMenu, EvilItemParser } from "../coreExtensions/contextMenu"; 10 2 import { Markdown } from "../coreExtensions/markdown"; 3 + import { Settings } from "../coreExtensions/settings"; 4 + import { Spacepack } from "../coreExtensions/spacepack"; 11 5 12 6 declare function WebpackRequire(id: string): any; 13 - declare function WebpackRequire(id: "spacepack_spacepack"): { 14 - default: Spacepack; 15 - spacepack: Spacepack; 16 - }; 17 7 18 - declare function WebpackRequire(id: "common_components"): CommonComponents; 19 - declare function WebpackRequire(id: "common_flux"): CommonFlux; 20 - declare function WebpackRequire( 21 - id: "common_fluxDispatcher" 22 - ): CommonFluxDispatcher; 23 - declare function WebpackRequire(id: "common_react"): CommonReact; 8 + declare function WebpackRequire(id: "contextMenu_evilMenu"): EvilItemParser; 9 + declare function WebpackRequire(id: "contextMenu_contextMenu"): ContextMenu; 10 + 11 + declare function WebpackRequire(id: "markdown_markdown"): Markdown; 24 12 25 13 declare function WebpackRequire(id: "settings_settings"): { 26 14 Settings: Settings; 27 15 default: Settings; 28 16 }; 29 17 30 - declare function WebpackRequire(id: "markdown_markdown"): Markdown; 31 - 32 - declare function WebpackRequire(id: "contextMenu_evilMenu"): EvilItemParser; 33 - declare function WebpackRequire(id: "contextMenu_contextMenu"): ContextMenu; 18 + declare function WebpackRequire(id: "spacepack_spacepack"): { 19 + default: Spacepack; 20 + spacepack: Spacepack; 21 + }; 34 22 35 23 export default WebpackRequire;
+1
packages/types/src/extension.ts
··· 30 30 export type ExtensionManifest = { 31 31 id: string; 32 32 version?: string; 33 + apiLevel?: number; 33 34 34 35 meta?: { 35 36 name?: string;
+9 -4
packages/types/src/globals.ts
··· 1 - import { Logger } from "./logger"; 2 - import { Config, ConfigExtension } from "./config"; 3 - import { 1 + import type { Logger } from "./logger"; 2 + import type { Config, ConfigExtension } from "./config"; 3 + import type { 4 4 DetectedExtension, 5 5 IdentifiedPatch, 6 6 IdentifiedWebpackModule, 7 7 ProcessedExtensions 8 8 } from "./extension"; 9 - import EventEmitter from "events"; 9 + import type EventEmitter from "events"; 10 + import type LunAST from "@moonlight-mod/lunast"; 11 + import type Moonmap from "@moonlight-mod/moonmap"; 10 12 import { EventPayloads, EventType, MoonlightEventEmitter } from "./core/event"; 11 13 12 14 export type MoonlightHost = { ··· 40 42 unpatched: Set<IdentifiedPatch>; 41 43 pendingModules: Set<IdentifiedWebpackModule>; 42 44 enabledExtensions: Set<string>; 45 + apiLevel: number; 43 46 events: MoonlightEventEmitter<EventType, EventPayloads>; 44 47 patchingInternals: { 45 48 onModuleLoad: ( ··· 54 57 getConfigOption: <T>(ext: string, name: string) => T | undefined; 55 58 getNatives: (ext: string) => any | undefined; 56 59 getLogger: (id: string) => Logger; 60 + lunast: LunAST; 61 + moonmap: Moonmap; 57 62 }; 58 63 59 64 export enum MoonlightEnv {
+13 -38
packages/types/src/import.d.ts
··· 1 - declare module "@moonlight-mod/wp/spacepack_spacepack" { 2 - import { CoreExtensions } from "@moonlight-mod/types"; 3 - export const spacepack: CoreExtensions.Spacepack; 4 - export default spacepack; 5 - } 1 + declare module "@moonlight-mod/wp/common_stores"; 6 2 7 - declare module "@moonlight-mod/wp/common_components" { 8 - import { CoreExtensions } from "@moonlight-mod/types"; 9 - const CommonComponent: CoreExtensions.CommonComponents; 10 - export = CommonComponent; 11 - } 12 - 13 - declare module "@moonlight-mod/wp/common_flux" { 3 + declare module "@moonlight-mod/wp/contextMenu_evilMenu" { 14 4 import { CoreExtensions } from "@moonlight-mod/types"; 15 - const Flux: CoreExtensions.CommonFlux; 16 - // FIXME: This is wrong, the default export differs from the named exports. 17 - export = Flux; 5 + const EvilParser: CoreExtensions.ContextMenu.EvilItemParser; 6 + export = EvilParser; 18 7 } 19 - 20 - declare module "@moonlight-mod/wp/common_fluxDispatcher" { 8 + declare module "@moonlight-mod/wp/contextMenu_contextMenu" { 21 9 import { CoreExtensions } from "@moonlight-mod/types"; 22 - const Dispatcher: CoreExtensions.CommonFluxDispatcher; 23 - export default Dispatcher; 24 - } 25 - 26 - declare module "@moonlight-mod/wp/common_stores"; 27 - 28 - declare module "@moonlight-mod/wp/common_react" { 29 - import React from "react"; 30 - export = React; 31 - } 32 - 33 - declare module "@moonlight-mod/wp/settings_settings" { 34 - import { CoreExtensions } from "@moonlight-mod/types"; 35 - export const Settings: CoreExtensions.Settings; 36 - export default Settings; 10 + const ContextMenu: CoreExtensions.ContextMenu.ContextMenu; 11 + export = ContextMenu; 37 12 } 38 13 39 14 declare module "@moonlight-mod/wp/markdown_markdown" { ··· 42 17 export = Markdown; 43 18 } 44 19 45 - declare module "@moonlight-mod/wp/contextMenu_evilMenu" { 20 + declare module "@moonlight-mod/wp/settings_settings" { 46 21 import { CoreExtensions } from "@moonlight-mod/types"; 47 - const EvilParser: CoreExtensions.ContextMenu.EvilItemParser; 48 - export = EvilParser; 22 + export const Settings: CoreExtensions.Settings.Settings; 23 + export default Settings; 49 24 } 50 25 51 - declare module "@moonlight-mod/wp/contextMenu_contextMenu" { 26 + declare module "@moonlight-mod/wp/spacepack_spacepack" { 52 27 import { CoreExtensions } from "@moonlight-mod/types"; 53 - const ContextMenu: CoreExtensions.ContextMenu.ContextMenu; 54 - export = ContextMenu; 28 + export const spacepack: CoreExtensions.Spacepack.Spacepack; 29 + export default spacepack; 55 30 }
+4 -1
packages/types/src/index.ts
··· 1 1 /// <reference types="standalone-electron-types" /> 2 2 /// <reference types="react" /> 3 - /// <reference types="flux" /> 4 3 /// <reference types="./import" /> 4 + /// <reference types="./mappings" /> 5 5 /* eslint-disable no-var */ 6 6 7 7 import { ··· 18 18 export * from "./globals"; 19 19 export * from "./logger"; 20 20 export * as constants from "./constants"; 21 + 22 + export type { AST } from "@moonlight-mod/lunast"; 23 + export { ModuleExport, ModuleExportType } from "@moonlight-mod/moonmap"; 21 24 22 25 declare global { 23 26 const MOONLIGHT_ENV: MoonlightEnv;
+42
packages/types/src/mappings.d.ts
··· 1 + // auto-generated 2 + declare module "@moonlight-mod/wp/discord/Dispatcher" { 3 + import { MappedModules } from "@moonlight-mod/mappings"; 4 + const _: MappedModules["discord/Dispatcher"]; 5 + export = _; 6 + } 7 + 8 + declare module "@moonlight-mod/wp/discord/components/common/index" { 9 + import { MappedModules } from "@moonlight-mod/mappings"; 10 + const _: MappedModules["discord/components/common/index"]; 11 + export = _; 12 + } 13 + 14 + declare module "@moonlight-mod/wp/discord/modules/guild_settings/IntegrationCard.css" { 15 + import { MappedModules } from "@moonlight-mod/mappings"; 16 + const _: MappedModules["discord/modules/guild_settings/IntegrationCard.css"]; 17 + export = _; 18 + } 19 + 20 + declare module "@moonlight-mod/wp/discord/modules/markup/MarkupUtils" { 21 + import { MappedModules } from "@moonlight-mod/mappings"; 22 + const _: MappedModules["discord/modules/markup/MarkupUtils"]; 23 + export = _; 24 + } 25 + 26 + declare module "@moonlight-mod/wp/discord/packages/flux" { 27 + import { MappedModules } from "@moonlight-mod/mappings"; 28 + const _: MappedModules["discord/packages/flux"]; 29 + export = _; 30 + } 31 + 32 + declare module "@moonlight-mod/wp/discord/uikit/Flex" { 33 + import { MappedModules } from "@moonlight-mod/mappings"; 34 + const _: MappedModules["discord/uikit/Flex"]; 35 + export = _; 36 + } 37 + 38 + declare module "@moonlight-mod/wp/react" { 39 + import { MappedModules } from "@moonlight-mod/mappings"; 40 + const _: MappedModules["react"]; 41 + export = _; 42 + }
+3
packages/web-preload/package.json
··· 3 3 "private": true, 4 4 "dependencies": { 5 5 "@moonlight-mod/core": "workspace:*", 6 + "@moonlight-mod/lunast": "^1.0.0", 7 + "@moonlight-mod/mappings": "^1.0.0", 8 + "@moonlight-mod/moonmap": "^1.0.2", 6 9 "@moonlight-mod/types": "workspace:*" 7 10 } 8 11 }
+10 -2
packages/web-preload/src/index.ts
··· 5 5 registerPatch, 6 6 registerWebpackModule 7 7 } from "@moonlight-mod/core/patch"; 8 + import { constants } from "@moonlight-mod/types"; 8 9 import { installStyles } from "@moonlight-mod/core/styles"; 9 10 import Logger from "@moonlight-mod/core/util/logger"; 11 + import LunAST from "@moonlight-mod/lunast"; 12 + import Moonmap from "@moonlight-mod/moonmap"; 13 + import loadMappings from "@moonlight-mod/mappings"; 10 14 import { createEventEmitter } from "@moonlight-mod/core/util/event"; 11 15 import { EventPayloads, EventType } from "@moonlight-mod/types/core/event"; 12 16 ··· 14 18 const logger = new Logger("web-preload"); 15 19 16 20 window.moonlight = { 21 + apiLevel: constants.apiLevel, 17 22 unpatched: new Set(), 18 23 pendingModules: new Set(), 19 24 enabledExtensions: new Set(), ··· 27 32 getConfig: moonlightNode.getConfig.bind(moonlightNode), 28 33 getConfigOption: moonlightNode.getConfigOption.bind(moonlightNode), 29 34 getNatives: moonlightNode.getNatives.bind(moonlightNode), 30 - getLogger: (id: string) => { 35 + getLogger(id) { 31 36 return new Logger(id); 32 - } 37 + }, 38 + lunast: new LunAST(), 39 + moonmap: new Moonmap() 33 40 }; 34 41 35 42 try { 43 + loadMappings(window.moonlight.moonmap, window.moonlight.lunast); 36 44 await loadProcessedExtensions(moonlightNode.processedExtensions); 37 45 await installWebpackPatcher(); 38 46 } catch (e) {
+114 -35
pnpm-lock.yaml
··· 77 77 78 78 packages/types: 79 79 dependencies: 80 - '@types/flux': 81 - specifier: ^3.1.12 82 - version: 3.1.12 80 + '@moonlight-mod/lunast': 81 + specifier: ^1.0.0 82 + version: 1.0.0 83 + '@moonlight-mod/mappings': 84 + specifier: ^1.0.0 85 + version: 1.0.0(@moonlight-mod/lunast@1.0.0)(@moonlight-mod/moonmap@1.0.2) 86 + '@moonlight-mod/moonmap': 87 + specifier: ^1.0.2 88 + version: 1.0.2 83 89 '@types/react': 84 - specifier: ^18.2.22 85 - version: 18.2.22 90 + specifier: ^18.3.10 91 + version: 18.3.10 86 92 csstype: 87 93 specifier: ^3.1.2 88 94 version: 3.1.2 ··· 95 101 '@moonlight-mod/core': 96 102 specifier: workspace:* 97 103 version: link:../core 104 + '@moonlight-mod/lunast': 105 + specifier: ^1.0.0 106 + version: 1.0.0 107 + '@moonlight-mod/mappings': 108 + specifier: ^1.0.0 109 + version: 1.0.0(@moonlight-mod/lunast@1.0.0)(@moonlight-mod/moonmap@1.0.2) 110 + '@moonlight-mod/moonmap': 111 + specifier: ^1.0.2 112 + version: 1.0.2 98 113 '@moonlight-mod/types': 99 114 specifier: workspace:* 100 115 version: link:../types ··· 263 278 '@humanwhocodes/config-array@0.11.13': 264 279 resolution: {integrity: sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==} 265 280 engines: {node: '>=10.10.0'} 281 + deprecated: Use @eslint/config-array instead 266 282 267 283 '@humanwhocodes/module-importer@1.0.1': 268 284 resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} ··· 270 286 271 287 '@humanwhocodes/object-schema@2.0.1': 272 288 resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} 289 + deprecated: Use @eslint/object-schema instead 290 + 291 + '@moonlight-mod/lunast@1.0.0': 292 + resolution: {integrity: sha512-kJgf41K12i6/2LbXK97CNO+pNO7ADGh9N4bCQcOPwosocKMcwKHDEZUgPqeihNshY3c3AEW1LiyXjlsl24PdDw==} 293 + 294 + '@moonlight-mod/mappings@1.0.0': 295 + resolution: {integrity: sha512-n6ybbTqFxXVKvTHcIGEtCS9208an6BFnTojK56giWE/bjuqq6DvFrk/0+C3ZRDEjgohGf/DuUKc9f0qe9UH6Rg==} 296 + peerDependencies: 297 + '@moonlight-mod/lunast': ^1.0.0 298 + '@moonlight-mod/moonmap': ^1.0.0 299 + 300 + '@moonlight-mod/moonmap@1.0.2': 301 + resolution: {integrity: sha512-dqMFwk8o0duRfvBNYo6EwalEUWWR3bNF5V2N04ogHp4gYON6/5+XOUrTlQ9BFBDj9anZwGgVwGqnxV42Qs9pPw==} 273 302 274 303 '@nodelib/fs.scandir@2.1.5': 275 304 resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} ··· 287 316 resolution: {integrity: sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==} 288 317 engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} 289 318 290 - '@types/fbemitter@2.0.33': 291 - resolution: {integrity: sha512-KcSilwdl0D8YgXGL6l9d+rTBm2W7pDyTZrDEw0+IzqQ724676KJtMeO+xHodJewKFWZT+GFWaJubA5mpMxSkcg==} 319 + '@types/estree-jsx@1.0.5': 320 + resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==} 321 + 322 + '@types/estree@1.0.6': 323 + resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} 324 + 325 + '@types/fbemitter@2.0.35': 326 + resolution: {integrity: sha512-Xem6d7qUfmouCHntCrRYgDBwbf+WWRd6G+7WEFlEZFZ67LZXiYRvT2LV8wcZa6mIaAil95+ABQdKgB6hPIsnng==} 292 327 293 - '@types/flux@3.1.12': 294 - resolution: {integrity: sha512-HZ8o/DTVNgcgnXoDyn0ZnjqEZMT4Chr4w5ktMQSbQAnqVDklasmRqNGd2agZDsk5i0jYHQLgQQuM782bWG7fUA==} 328 + '@types/flux@3.1.14': 329 + resolution: {integrity: sha512-WRXN0kQPCnqxN0/PgNgc7WBF6c8rbSHsEep3/qBLpsQ824RONdOmTs0TV7XhIW2GDNRAHO2CqCgAFLR5PChosw==} 295 330 296 331 '@types/json-schema@7.0.15': 297 332 resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} ··· 299 334 '@types/node@18.17.17': 300 335 resolution: {integrity: sha512-cOxcXsQ2sxiwkykdJqvyFS+MLQPLvIdwh5l6gNg8qF6s+C7XSkEWOZjK+XhUZd+mYvHV/180g2cnCcIl4l06Pw==} 301 336 302 - '@types/prop-types@15.7.6': 303 - resolution: {integrity: sha512-RK/kBbYOQQHLYj9Z95eh7S6t7gq4Ojt/NT8HTk8bWVhA5DaF+5SMnxHKkP4gPNN3wAZkKP+VjAf0ebtYzf+fxg==} 337 + '@types/prop-types@15.7.13': 338 + resolution: {integrity: sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==} 304 339 305 - '@types/react@18.2.22': 306 - resolution: {integrity: sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==} 307 - 308 - '@types/scheduler@0.16.3': 309 - resolution: {integrity: sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==} 340 + '@types/react@18.3.10': 341 + resolution: {integrity: sha512-02sAAlBnP39JgXwkAq3PeU9DVaaGpZyF3MGcC0MKgQVkZor5IiiDAipVaxQHtDJAmO4GIy/rVBy/LzVj76Cyqg==} 310 342 311 343 '@types/semver@7.5.6': 312 344 resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} ··· 377 409 peerDependencies: 378 410 acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 379 411 380 - acorn@8.11.2: 381 - resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} 412 + acorn@8.12.1: 413 + resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} 382 414 engines: {node: '>=0.4.0'} 383 415 hasBin: true 384 416 ··· 422 454 resolution: {integrity: sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==} 423 455 engines: {node: '>= 0.4'} 424 456 457 + astring@1.9.0: 458 + resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==} 459 + hasBin: true 460 + 425 461 asynciterator.prototype@1.0.0: 426 462 resolution: {integrity: sha512-wwHYEIS0Q80f5mosx3L/dfG5t5rjEa9Ft51GTaNt862EnpyGHpgz2RkZvLPp1oF5TnAiTohkEKVEu8pQPJI7Vg==} 427 463 ··· 474 510 engines: {node: '>= 6'} 475 511 476 512 concat-map@0.0.1: 477 - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} 513 + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} 478 514 479 515 cross-spawn@7.0.3: 480 516 resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} ··· 483 519 csstype@3.1.2: 484 520 resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} 485 521 522 + csstype@3.1.3: 523 + resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} 524 + 486 525 debug@4.3.4: 487 526 resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} 488 527 engines: {node: '>=6.0'} ··· 611 650 estraverse@5.3.0: 612 651 resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} 613 652 engines: {node: '>=4.0'} 653 + 654 + estree-toolkit@1.7.8: 655 + resolution: {integrity: sha512-v0Q0L+0agSDFe3x9Sj7aAzrI9afvsfr5r7AM2SNk/8bKYRQ3tUf4PQEUWe99LkWysmT1PsuSpW+W1w/xZmCKeg==} 614 656 615 657 esutils@2.0.3: 616 658 resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} ··· 699 741 700 742 glob@7.2.3: 701 743 resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} 744 + deprecated: Glob versions prior to v9 are no longer supported 702 745 703 746 globals@13.23.0: 704 747 resolution: {integrity: sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==} ··· 771 814 772 815 inflight@1.0.6: 773 816 resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} 817 + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. 774 818 775 819 inherits@2.0.4: 776 820 resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} ··· 954 998 resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} 955 999 engines: {node: '>= 8'} 956 1000 1001 + meriyah@6.0.1: 1002 + resolution: {integrity: sha512-OyvYIOgpzXREySYJ1cqEb2pOKdeQMTfF9M8dRU6nC4hi/GXMmNpe9ssZCrSoTHazu05BSAoRBN/uYeco+ymfOg==} 1003 + engines: {node: '>=18.0.0'} 1004 + 957 1005 micromatch@4.0.5: 958 1006 resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} 959 1007 engines: {node: '>=8.6'} ··· 1122 1170 1123 1171 rimraf@3.0.2: 1124 1172 resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} 1173 + deprecated: Rimraf versions prior to v4 are no longer supported 1125 1174 hasBin: true 1126 1175 1127 1176 run-applescript@5.0.0: ··· 1415 1464 1416 1465 '@humanwhocodes/object-schema@2.0.1': {} 1417 1466 1467 + '@moonlight-mod/lunast@1.0.0': 1468 + dependencies: 1469 + astring: 1.9.0 1470 + estree-toolkit: 1.7.8 1471 + meriyah: 6.0.1 1472 + 1473 + '@moonlight-mod/mappings@1.0.0(@moonlight-mod/lunast@1.0.0)(@moonlight-mod/moonmap@1.0.2)': 1474 + dependencies: 1475 + '@moonlight-mod/lunast': 1.0.0 1476 + '@moonlight-mod/moonmap': 1.0.2 1477 + '@types/flux': 3.1.14 1478 + '@types/react': 18.3.10 1479 + csstype: 3.1.3 1480 + 1481 + '@moonlight-mod/moonmap@1.0.2': {} 1482 + 1418 1483 '@nodelib/fs.scandir@2.1.5': 1419 1484 dependencies: 1420 1485 '@nodelib/fs.stat': 2.0.5 ··· 1436 1501 picocolors: 1.0.0 1437 1502 tslib: 2.6.2 1438 1503 1439 - '@types/fbemitter@2.0.33': {} 1504 + '@types/estree-jsx@1.0.5': 1505 + dependencies: 1506 + '@types/estree': 1.0.6 1507 + 1508 + '@types/estree@1.0.6': {} 1440 1509 1441 - '@types/flux@3.1.12': 1510 + '@types/fbemitter@2.0.35': {} 1511 + 1512 + '@types/flux@3.1.14': 1442 1513 dependencies: 1443 - '@types/fbemitter': 2.0.33 1444 - '@types/react': 18.2.22 1514 + '@types/fbemitter': 2.0.35 1515 + '@types/react': 18.3.10 1445 1516 1446 1517 '@types/json-schema@7.0.15': {} 1447 1518 1448 1519 '@types/node@18.17.17': {} 1449 1520 1450 - '@types/prop-types@15.7.6': {} 1521 + '@types/prop-types@15.7.13': {} 1451 1522 1452 - '@types/react@18.2.22': 1523 + '@types/react@18.3.10': 1453 1524 dependencies: 1454 - '@types/prop-types': 15.7.6 1455 - '@types/scheduler': 0.16.3 1456 - csstype: 3.1.2 1457 - 1458 - '@types/scheduler@0.16.3': {} 1525 + '@types/prop-types': 15.7.13 1526 + csstype: 3.1.3 1459 1527 1460 1528 '@types/semver@7.5.6': {} 1461 1529 ··· 1546 1614 1547 1615 '@ungap/structured-clone@1.2.0': {} 1548 1616 1549 - acorn-jsx@5.3.2(acorn@8.11.2): 1617 + acorn-jsx@5.3.2(acorn@8.12.1): 1550 1618 dependencies: 1551 - acorn: 8.11.2 1619 + acorn: 8.12.1 1552 1620 1553 - acorn@8.11.2: {} 1621 + acorn@8.12.1: {} 1554 1622 1555 1623 ajv@6.12.6: 1556 1624 dependencies: ··· 1614 1682 is-array-buffer: 3.0.2 1615 1683 is-shared-array-buffer: 1.0.2 1616 1684 1685 + astring@1.9.0: {} 1686 + 1617 1687 asynciterator.prototype@1.0.0: 1618 1688 dependencies: 1619 1689 has-symbols: 1.0.3 ··· 1671 1741 which: 2.0.2 1672 1742 1673 1743 csstype@3.1.2: {} 1744 + 1745 + csstype@3.1.3: {} 1674 1746 1675 1747 debug@4.3.4: 1676 1748 dependencies: ··· 1905 1977 1906 1978 espree@9.6.1: 1907 1979 dependencies: 1908 - acorn: 8.11.2 1909 - acorn-jsx: 5.3.2(acorn@8.11.2) 1980 + acorn: 8.12.1 1981 + acorn-jsx: 5.3.2(acorn@8.12.1) 1910 1982 eslint-visitor-keys: 3.4.3 1911 1983 1912 1984 esquery@1.5.0: ··· 1918 1990 estraverse: 5.3.0 1919 1991 1920 1992 estraverse@5.3.0: {} 1993 + 1994 + estree-toolkit@1.7.8: 1995 + dependencies: 1996 + '@types/estree': 1.0.6 1997 + '@types/estree-jsx': 1.0.5 1921 1998 1922 1999 esutils@2.0.3: {} 1923 2000 ··· 2267 2344 merge-stream@2.0.0: {} 2268 2345 2269 2346 merge2@1.4.1: {} 2347 + 2348 + meriyah@6.0.1: {} 2270 2349 2271 2350 micromatch@4.0.5: 2272 2351 dependencies:
+4 -1
tsconfig.json
··· 1 1 { 2 2 "compilerOptions": { 3 - "target": "es2016", 3 + "target": "es2022", 4 4 "module": "es6", 5 5 "esModuleInterop": true, 6 6 "forceConsistentCasingInFileNames": true, ··· 9 9 "baseUrl": "./packages/", 10 10 "jsx": "react", 11 11 "noEmit": true, 12 + 13 + // meriyah has a broken import lol 14 + "skipLibCheck": true, 12 15 13 16 // disable unreachable code detection because it breaks with esbuild labels 14 17 "allowUnreachableCode": true