Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Commit b202d6a

Browse files
committed
add TypeScript definition to the generated plugin build
1 parent 31088fd commit b202d6a

7 files changed

Lines changed: 124 additions & 6 deletions

File tree

dist/@melonjs/debug-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* melonJS debug plugin - v14.5.2
2+
* melonJS debug plugin - v14.6.0
33
* http://www.melonjs.org
44
* @melonjs/debug-plugin is licensed under the MIT License.
55
* http://www.opensource.org/licenses/mit-license
@@ -71,7 +71,7 @@ class DebugPanel extends Renderable {
7171
this.name = "debugPanel";
7272

7373
// the debug panel version
74-
this.version = "14.5.2";
74+
this.version = "14.6.0";
7575

7676
// persistent
7777
this.isPersistent = true;

dist/counters.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default Counters;
2+
declare class Counters {
3+
stats: any[];
4+
reset(): void;
5+
inc(stat: any, value: any): void;
6+
get(stat: any): any;
7+
}

dist/debugPanel.d.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
export default DebugPanel;
2+
declare class DebugPanel extends Renderable {
3+
constructor(debugToggle?: number);
4+
checkbox: {};
5+
counters: Counters;
6+
visible: boolean;
7+
frameUpdateTime: number;
8+
frameDrawTime: number;
9+
version: string;
10+
canvas: HTMLCanvasElement | OffscreenCanvas;
11+
font_size: number;
12+
mod: number;
13+
font: BitmapText;
14+
debugToggle: number;
15+
keyHandler: import("eventemitter3").EventEmitter<string | symbol, any>;
16+
help_str: string;
17+
help_str_len: number;
18+
fps_str_len: number;
19+
memoryPositionX: number;
20+
frameUpdateStartTime: number;
21+
frameDrawStartTime: number;
22+
/**
23+
* patch system fn to draw debug information
24+
*/
25+
patchSystemFn(): void;
26+
/**
27+
* show the debug panel
28+
*/
29+
show(): void;
30+
/**
31+
* hide the debug panel
32+
*/
33+
hide(): void;
34+
update(): boolean;
35+
onClick(e: any): void;
36+
drawQuadTreeNode(renderer: any, node: any): void;
37+
drawQuadTree(renderer: any): void;
38+
/** @private */
39+
private drawMemoryGraph;
40+
draw(renderer: any): void;
41+
}
42+
import { Renderable } from "melonjs";
43+
import Counters from "./counters";
44+
import { BitmapText } from "melonjs";

dist/index.d.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
declare const DebugPanelPlugin_base: any;
2+
/**
3+
* @classdesc
4+
* a simple debug panel plugin <br>
5+
* <img src="images/debugPanel.png"/> <br>
6+
* <b>usage : </b><br>
7+
* &bull; upon loading the debug panel, it will be automatically registered under me.plugins.debugPanel <br>
8+
* &bull; you can then press the default "s" key to show or hide the panel, or use me.plugins.debugPanel.show() and me.plugins.debugPanel.show(), or add #debug as a parameter to your URL e.g. http://myURL/index.html#debug <br>
9+
* &bull; default key can be configured using the following parameters in the url : e.g. http://myURL/index.html#debugToggleKey=d <br>
10+
* <b>the debug panel provides the following information : </b><br>
11+
* &bull; amount of total objects currently active in the current stage <br>
12+
* &bull; amount of draws operation <br>
13+
* &bull; amount of body shape (for collision) <br>
14+
* &bull; amount of bounding box <br>
15+
* &bull; amount of sprites objects <br>
16+
* &bull; amount of objects currently inactive in the the object pool <br>
17+
* &bull; memory usage (Heap Memory information is only available under Chrome) <br>
18+
* &bull; frame update time (in ms) <br>
19+
* &bull; frame draw time (in ms) <br>
20+
* &bull; current fps rate vs target fps <br>
21+
* additionally, using the checkbox in the panel it is also possible to display : <br>
22+
* &bull; the hitbox or bounding box for all objects <br>
23+
* &bull; current velocity vector <br>
24+
* &bull; quadtree spatial visualization <br>
25+
* @augments plugin.Base
26+
*/
27+
export class DebugPanelPlugin extends DebugPanelPlugin_base {
28+
[x: string]: any;
29+
constructor(debugToggle: any);
30+
version: string;
31+
panel: DebugPanel;
32+
/**
33+
* show the debug panel
34+
*/
35+
show(): void;
36+
/**
37+
* hide the debug panel
38+
*/
39+
hide(): void;
40+
/**
41+
* toggle the debug panel visibility state
42+
*/
43+
toggle(): void;
44+
}
45+
import DebugPanel from "./debugPanel";
46+
export {};

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"main": "dist/@melonjs/debug-plugin.js",
4040
"module": "dist/@melonjs/debug-plugin.js",
41+
"types": "dist/index.d.ts",
4142
"sideEffects": false,
4243
"files": [
4344
"dist/@melonjs/debug-plugin.js",
@@ -61,12 +62,14 @@
6162
"eslint-plugin-jsdoc": "^44.2.2",
6263
"rollup": "^3.21.6",
6364
"rollup-plugin-bundle-size": "^1.0.3",
64-
"rollup-plugin-string": "^3.0.0"
65+
"rollup-plugin-string": "^3.0.0",
66+
"typescript": "^5.0.4"
6567
},
6668
"scripts": {
67-
"build": "npm run lint && rollup -c --silent",
69+
"build": "npm run lint && rollup -c --silent && npm run types",
6870
"lint": "eslint src/**.js rollup.config.mjs",
6971
"prepublishOnly": "npm run build",
70-
"clean": "del-cli --force build/*.*"
72+
"clean": "del-cli --force dist/*.*",
73+
"types": "tsc"
7174
}
7275
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { utils, plugin } from "melonjs";
2-
import DebugPanel from "./debugPanel.js";
2+
import DebugPanel from "./debugPanel";
33

44
/**
55
* @classdesc

tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"allowJs": true,
5+
"checkJs": false,
6+
"skipLibCheck": true,
7+
"emitDeclarationOnly": true,
8+
"declaration": true,
9+
"declarationDir": "dist",
10+
"removeComments": false,
11+
"strict": true,
12+
"noImplicitAny": true,
13+
"moduleResolution": "node",
14+
"resolveJsonModule": true,
15+
},
16+
"include": ["src/index.js"],
17+
"exclude": ["node_modules"]
18+
}

0 commit comments

Comments
 (0)