Skip to content

Commit

Permalink
typedef: add typings
Browse files Browse the repository at this point in the history
  • Loading branch information
WorriedArrow committed Jan 15, 2023
1 parent 5622d92 commit d13432e
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import components from "../src/api/components";

type HTMLParseResult = NodeListOf<ChildNode> | ChildNode;

interface Client {
/**
* Completely relaunches the client.
*/
relaunch(): void;
}

interface DiscordWindow {
/**
* Minimizes the window.
*/
minimize(): void;
/**
* Restores the window, reopening the window if it is closed.
*/
restore(): void;
/**
* Maximizes the window, restoring if it is minimized and reopening the window if it is closed.
*/
maximize(): void;
/**
* Closes the window, remains in system tray.
*/
close(): void;
}

interface StyleInjector {
/**
* Injects `css` into the Discord client.
* @param css The CSS to be injected.
*/
inject(css: string): void;
}

interface ComponentBuilder {
/**
* Creates a component.
*
* @param component The component to create.
* @param options The options to pass to the component function.
* @returns the output element of the component function.
*/
createComponent(component: Function, options: any): HTMLElement;
/**
*
* @param category The category, which can be something like "hello.world" to have hello as the category and world as the subcategory.
* @param methodName The name of the method or component.
* @param method
* @param createCategory
*/
createMethod(category: string, methodName: string, method: Function, createCategory: boolean): void;
parseHTML(html: string, fragment: boolean): HTMLParseResult;
}

type NativeComponents = typeof components;

export default interface OpenLoader {
client: Client;
window: DiscordWindow,
styleInjector: StyleInjector,
componentBuilder: ComponentBuilder,
components: NativeComponents;
}

0 comments on commit d13432e

Please sign in to comment.