2020-09-05 22:50:45 +02:00
import WebpackLoader from "./modules/WebpackLoader"
import Components from "./components/components"
import uuid from "./modules/uuid"
import Utils from "./modules/Utils"
import DiscordTools from "./modules/DiscordTools"
import * as patchers from "./modules/patchers"
import excludeProperties from "./modules/excludeProperties"
import cloneNullProto from "./modules/cloneNullProto"
import NOOP from "./modules/noop"
import unfreeze from "./modules/Unfreeze"
import { isNative , isImported } from "./modules/environnement"
import * as bandagedbdApi from "@bandagedbd/bdapi"
import "./alias/react"
import "./alias/react-dom"
import { LazyLoad } from "./modules/lazyLoader"
2020-09-12 14:52:50 +02:00
import settings from "./modules/settings"
2020-09-05 22:50:45 +02:00
patchers . patch ( )
2020-09-06 12:50:52 +02:00
/ * *
2020-09-12 14:52:50 +02:00
* Lightcord Api defined at [ / L i g h t c o r d A p i / s r c / i n d e x . t s ] ( h t t p s : / / g i t h u b . c o m / L i g h t c o r d / L i g h t c o r d / b l o b / m a s t e r / L i g h t c o r d A p i / s r c / i n d e x . t s # L 2 2 )
2020-09-06 12:50:52 +02:00
* /
2020-09-05 22:50:45 +02:00
const LightcordApi = {
2020-09-06 12:50:52 +02:00
/ * *
* WebpackLoader loads Internal Discord ' s module s with given filter .
* /
2020-09-05 22:50:45 +02:00
WebpackLoader : WebpackLoader ,
2020-09-06 12:50:52 +02:00
/ * *
* Lightcord 's exported component. You can see a list in the app settings when activating `Developer Options` in lightcord' s settings .
* /
2020-09-05 22:50:45 +02:00
Components : Components ,
2020-09-06 12:50:52 +02:00
/ * *
* Create uuids .
* @method
* /
2020-09-05 22:50:45 +02:00
uuid : uuid ,
2020-09-06 12:50:52 +02:00
/ * *
* Set of methods that can help you sometimes .
* /
2020-09-05 22:50:45 +02:00
Utils : Utils ,
DiscordTools : DiscordTools ,
_ : {
excludeProperties : excludeProperties ,
cloneNullProto : cloneNullProto ,
NOOP : NOOP ,
unfreeze : unfreeze
} ,
get isNative ( ) { return isNative } ,
get isImported ( ) { return isImported } ,
2020-09-12 14:52:50 +02:00
LazyLoad : LazyLoad ,
settings : settings
2020-09-05 22:50:45 +02:00
}
declare global {
var React :typeof import ( "react" )
var ReactDOM :typeof import ( "../node_modules/@types/react-dom" )
interface Window {
/ * *
* Lightcord is only availlaible in Lightcord ( native )
* /
Lightcord : LightcordGlobal ,
/ * *
* BDModules is only availlaible in Lightcord ( native )
* /
BDModules : {
module s : any [ ] ,
get ( filter : ( mod :any ) = > boolean , module s? : any [ ] ) : any [ ] ,
get ( id :number , module s? : any [ ] ) : any ,
get ( ids : [ number | ( ( mod :any ) = > boolean ) ] , module s? : any [ ] ) : any
} ,
BdApi : typeof bandagedbdApi . BdApi ,
EDApi : typeof bandagedbdApi . BdApi ,
ReactDOM : typeof ReactDOM ;
React :typeof React
}
var Lightcord :LightcordGlobal
var BdApi : typeof bandagedbdApi . BdApi
var EDApi : typeof bandagedbdApi . BdApi
}
export default LightcordApi
Object . assign ( window . Lightcord . Api , LightcordApi )
/ * *
* The main Lightcord exports . Can be accessed with ` window.Lightcord `
* /
export interface LightcordGlobal {
2020-09-06 12:50:52 +02:00
/ * *
* Some Discord Internal Module shortcuts .
* /
2020-09-05 22:50:45 +02:00
DiscordModules : {
/ * *
* Internal Discord ' s dispatcher - can be used to subscribe to gateway events / client events .
* /
dispatcher : import ( "./types/DiscordDispatcherTypes" ) . default ,
2020-09-06 12:50:52 +02:00
/ * *
* Discord 's constants - Can be used to retrieve some infos like Discord' s Api Link , Colors , Events , etc . . .
* /
2020-09-05 22:50:45 +02:00
constants : import ( "./types/DiscordConstantsTypes" ) . default
} ,
2020-09-06 12:50:52 +02:00
/** Lightcord's base settings. You don't need to use them. */
2020-09-05 22:50:45 +02:00
Settings : {
devMode : boolean ,
callRingingBeat : boolean
} ,
2020-09-06 12:50:52 +02:00
/ * *
* Lightcord ' s Api . This is where all methods / properties lightcord adds are .
* /
2020-09-05 22:50:45 +02:00
Api : LightcordApiGlobal ,
2020-09-06 12:50:52 +02:00
/** BetterDiscord's Internal Modules. Can be used as well. Example: `Lightcord.BetterDiscord.DOM` for DomTools. */
2020-09-05 22:50:45 +02:00
BetterDiscord : {
2020-09-06 12:50:52 +02:00
/** BetterDiscord's plugin api. Can also be accessed with the global variable: `BdApi` */
2020-09-05 22:50:45 +02:00
BdApi : typeof bandagedbdApi . BdApi ,
[ mod :string ] : any
}
}
/ * *
* The main Api . Can be accessed with ` window.Lightcord.Api `
* /
type LightcordApiGlobal = lightcordApiMainExports & typeof LightcordApi
2020-09-06 12:50:52 +02:00
/** Exports that are defined [here](https://github.com/Lightcord/Lightcord/blob/master/modules/discord_desktop_core/core/app/BetterDiscord/index.js#L278) */
2020-09-05 22:50:45 +02:00
type lightcordApiMainExports = {
/ * *
* Waits until the first module that match the filter gets exported
* @param filter The filter that specifies the module to match .
* /
ensureExported ( filter : ( mod :any ) = > boolean ) : Promise < any > ,
/ * *
* Recreate the object without the ` __proto__ ` and ` prototype ` properties - usefull for better formatting in console .
* @param obj The object to recreate
* /
cloneNullProto < Obj = any > ( obj :Obj ) : Obj
2020-07-04 22:42:26 +02:00
}