Skip to content

Commit

Permalink
Add types for mediawiki.debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien LESÉNÉCHAL committed Mar 8, 2024
1 parent dffd1ac commit 996aa4c
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
119 changes: 119 additions & 0 deletions mw/debug.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
type LogEntryType = "deprecated" | "log" | "warn";

interface Data {
debugLog: string[];
gitBranch: string | false;
gitRevision: string | false;
gitViewUrl: string | false;
includes: File[];
log: LogEntry[];
memory: string;
memoryPeak: string;
mwVersion: string;
phpVersion: string;
queries: Query[];
time: number;
}

interface File {
name: string;
size: string;
}

interface LogEntry {
caller: string;
msg: string;
type: LogEntryType;
typeText?: string;
}

interface Query {
function: string;
sql: string;
time: number;
}

declare global {
namespace mw {
/**
* Debug toolbar.
*
* Enabled server-side through `$wgDebugToolbar`.
*
* @since 1.19
*/
namespace Debug {
/**
* Toolbar container element.
*/
const $container: JQuery;

/**
* Object containing data for the debug toolbar.
*/
const data: Data;

/**
* Build the console panel.
*
* @returns {JQuery} Console panel
*/
function buildConsoleTable(): JQuery;

/**
* Build legacy debug log pane.
*
* @returns {JQuery}
*/
function buildDebugLogTable(): JQuery;

/**
* Construct the HTML for the debugging toolbar.
*/
function buildHtml(): void;

/**
* Build included files pane.
*
* @returns {JQuery}
*/
function buildIncludesPane(): JQuery;

/**
* Build query list pane.
*
* @returns {JQuery}
*/
function buildQueryTable(): JQuery;

/**
* Build request information pane.
*
* @returns {JQuery}
*/
function buildRequestPane(): JQuery;

/**
* Initialize the debugging pane.
*
* Shouldn't be called before the document is ready
* (since it binds to elements on the page).
*
* @param {Data} [data] Defaults to 'debugInfo' from {@link mw.config}
*/
function init(data?: Data): void;

/**
* Switch between panes.
*
* Should be called with an HTMLElement as its thisArg,
* because it's meant to be an event handler.
*
* @param {JQuery.Event} e
*/
function switchPane(e: JQuery.Event): void;
}
}
}

export {};
1 change: 1 addition & 0 deletions mw/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "./Api";
import "./config";
import "./confirmCloseWindow";
import "./cookie";
import "./debug";
import "./ForeignApi";
import "./ForeignRest";
import "./global";
Expand Down

0 comments on commit 996aa4c

Please sign in to comment.