@melonjs/debug-plugin 14.8.2 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@ Installation
9
9
  -------------------------------------------------------------------------------
10
10
  `$ [sudo] npm install @melonjs/debug-plugin`
11
11
 
12
- Then import and instantiante the debug plugin in your project. For example:
12
+ Then import and instantiate the debug plugin in your project. For example:
13
13
  ```JavaScript
14
14
  import { utils, plugin } from 'melonjs';
15
15
 
@@ -23,30 +23,34 @@ import("@melonjs/debug-plugin").then((debugPlugin) => {
23
23
  Usage
24
24
  -------------------------------------------------------------------------------
25
25
 
26
- The Debug Panel is hidden by default and can be displayed using the `S` key, it will then provide the below information :
27
- ![debug-panel](https://user-images.githubusercontent.com/4033090/138006717-cf3165a4-a52d-4855-a7c7-16b2a09ed124.png)
26
+ The Debug Panel is hidden by default and can be displayed using the `S` key. It provides a compact HUD overlay with real-time engine diagnostics:
28
27
 
29
- * Amount of objects currently active in the current scene
30
- * Amount of draws operation
31
- * Amount of body shape (requires to enable the hitbox checkbox)
32
- * Amount of bounding box
33
- * Amount of sprites objects
34
- * Amount of objects currently inactive in the the object pool
35
- * Heap/memory usage
36
- * Frame update time (in ms)
37
- * Frame draw time (in ms)
38
- * Current fps rate vs target fps
28
+ ![debug-panel](debug-panel.png)
39
29
 
40
- > Note: Heap information requires starting Chrome [with](http://www.chromium.org/developers/how-tos/run-chromium-with-flags) `--enable-precise-memory-info`
30
+ The panel displays the following information across three rows:
41
31
 
42
- Additionally, using the checkbox in the panel it is also possible to draw :
43
- * Shape and Bounding box for all objects
32
+ * **#objects** number of objects currently active in the scene
33
+ * **#draws** number of draw operations per frame
34
+ * **hitbox / velocity / quadtree** — toggle checkboxes for debug overlays
35
+ * **Update / Draw** — frame update and draw time in milliseconds
36
+ * **Heap** — JS heap memory usage (used/total in MB, Chrome only)
37
+ * **Pool** — number of objects currently in the object pool
38
+ * **FPS** — current vs target frame rate
39
+ * **Shapes / Sprites / Velocity / Bounds / Children** — per-frame counters for active engine objects
40
+
41
+ Below the stats, two sparkline graphs show:
42
+ * **Frame time graph** — stacked update (cyan) and draw (amber) times with a target frame time indicator
43
+ * **Memory graph** — JS heap usage over time (Chrome only)
44
+
45
+ > Note: Heap memory information is only available in Chromium-based browsers (Chrome, Edge, Opera) via the `performance.memory` API, which is deprecated but has no real-time alternative yet.
46
+
47
+ Additionally, using the checkboxes in the panel it is also possible to draw:
48
+ * Shape and bounding box for all objects
44
49
  * Current velocity vector
45
50
  * Quadtree spatial visualization
46
51
 
47
52
  Questions, need help ?
48
53
  -------------------------------------------------------------------------------
49
54
  If you need technical support, you can contact us through the following channels :
50
- * Forums: with melonJS 2 we moved to a new discourse [forum](https://melonjs.discourse.group), but we can still also find the previous one [here](http://www.html5gamedevs.com/forum/32-melonjs/)
51
55
  * Chat: come and chat with us on [discord](https://discord.gg/aur7JMk)
52
- * we tried to keep our [wikipage](https://github.com/melonjs/melonJS/wiki) up-to-date with useful links, tutorials, and anything related melonJS.
56
+ * [Wiki](https://github.com/melonjs/melonJS/wiki) with useful links, tutorials, and anything related to melonJS
@@ -0,0 +1,6 @@
1
+ export default class Counters extends Map<any, any> {
2
+ constructor(keys: any);
3
+ reset(): void;
4
+ inc(stat: any, value?: number): void;
5
+ }
6
+ //# sourceMappingURL=counters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counters.d.ts","sourceRoot":"","sources":["../src/counters.js"],"names":[],"mappings":"AAAA;IACC,uBAMC;IAED,cAIC;IAED,qCAEC;CACD"}
@@ -0,0 +1,51 @@
1
+ export class DebugPanel {
2
+ constructor(debugToggle: any);
3
+ counters: Counters;
4
+ visible: boolean;
5
+ version: string;
6
+ debugToggle: any;
7
+ options: {
8
+ hitbox: string | boolean;
9
+ velocity: string | boolean;
10
+ quadtree: string | boolean;
11
+ };
12
+ updateHistory: Float32Array<ArrayBuffer>;
13
+ drawHistory: Float32Array<ArrayBuffer>;
14
+ memHistory: Float32Array<ArrayBuffer>;
15
+ historyIndex: number;
16
+ panel: HTMLDivElement | null;
17
+ panelWrap: HTMLDivElement | null;
18
+ stats: {};
19
+ frameUpdateStartTime: number;
20
+ frameDrawStartTime: number;
21
+ frameUpdateTime: number;
22
+ frameDrawTime: number;
23
+ _onResize: () => void;
24
+ _onBeforeUpdate: (time: any) => void;
25
+ _onAfterUpdate: (time: any) => void;
26
+ _onBeforeDraw: (time: any) => void;
27
+ _onAfterDraw: (time: any) => void;
28
+ /** @private */
29
+ private _buildPanel;
30
+ graphCanvas: HTMLCanvasElement | undefined;
31
+ memCanvas: HTMLCanvasElement | undefined;
32
+ /** @private */
33
+ private _syncPosition;
34
+ /** @private */
35
+ private _updatePanel;
36
+ /**
37
+ * show the debug panel
38
+ */
39
+ show(): void;
40
+ /**
41
+ * hide the debug panel
42
+ */
43
+ hide(): void;
44
+ /** @private */
45
+ private _drawQuadTree;
46
+ /** @private */
47
+ private _drawQuadTreeNode;
48
+ destroy(): void;
49
+ }
50
+ import Counters from "./counters";
51
+ //# sourceMappingURL=debugPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugPanel.d.ts","sourceRoot":"","sources":["../src/debugPanel.js"],"names":[],"mappings":"AAOA;IACC,8BAwEC;IAvEA,mBAME;IAEF,iBAAoB;IACpB,gBAA4B;IAC5B,iBAA8B;IAI9B;;;;MAIC;IAGD,yCAAoD;IACpD,uCAAkD;IAClD,sCAAiD;IACjD,qBAAqB;IAIrB,6BAAiB;IACjB,iCAAqB;IACrB,UAAe;IAIf,6BAA6B;IAC7B,2BAA2B;IAC3B,wBAAwB;IACxB,sBAAsB;IAGtB,sBAEC;IACD,qCAEC;IACD,oCAKC;IACD,mCAGC;IACD,kCAMC;IAWF,eAAe;IACf,oBAuHC;IApCA,2CAAmD;IAkBlD,yCAAiD;IAoBnD,eAAe;IACf,sBAMC;IAED,eAAe;IACf,qBAiDC;IAED;;OAEG;IACH,aAOC;IAED;;OAEG;IACH,aAMC;IAED,eAAe;IACf,sBAWC;IAED,eAAe;IACf,0BAmBC;IAED,gBAWC;CACD;qBA9UoB,YAAY"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Draw the stacked frame-time sparkline (update + draw).
3
+ * @param {HTMLCanvasElement} canvas
4
+ * @param {Float32Array} updateHistory
5
+ * @param {Float32Array} drawHistory
6
+ * @param {number} historyIndex - current write position in the ring buffer
7
+ * @param {HTMLElement} peakEl - element to display peak value
8
+ */
9
+ export function drawFrameGraph(canvas: HTMLCanvasElement, updateHistory: Float32Array, drawHistory: Float32Array, historyIndex: number, peakEl: HTMLElement): void;
10
+ /**
11
+ * Draw the memory heap area graph.
12
+ * @param {HTMLCanvasElement} canvas
13
+ * @param {Float32Array} memHistory - heap usage in MB
14
+ * @param {number} historyIndex - current write position in the ring buffer
15
+ * @param {HTMLElement} peakEl - element to display peak value
16
+ */
17
+ export function drawMemGraph(canvas: HTMLCanvasElement, memHistory: Float32Array, historyIndex: number, peakEl: HTMLElement): void;
18
+ //# sourceMappingURL=graphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphs.d.ts","sourceRoot":"","sources":["../src/graphs.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,uCANW,iBAAiB,iBACjB,YAAY,eACZ,YAAY,gBACZ,MAAM,UACN,WAAW,QAqErB;AAED;;;;;;GAMG;AACH,qCALW,iBAAiB,cACjB,YAAY,gBACZ,MAAM,UACN,WAAW,QA2DrB"}
@@ -1,14 +1,10 @@
1
- import { utils, plugin, input, event } from "melonjs";
2
- import { name, version, homepage, peerDependencies } from "../package.json";
3
- import { DebugPanel } from "./debugPanel";
4
-
5
1
  /**
6
2
  * @classdesc
7
3
  * a simple debug panel plugin <br>
8
4
  * <img src="images/debugPanel.png"/> <br>
9
5
  * <b>usage : </b><br>
10
6
  * &bull; upon loading the debug panel, it will be automatically registered under me.plugins.debugPanel <br>
11
- * &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>
7
+ * &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.hide(), or add #debug as a parameter to your URL e.g. http://myURL/index.html#debug <br>
12
8
  * &bull; default key can be configured using the following parameters in the url : e.g. http://myURL/index.html#debugToggleKey=d <br>
13
9
  * <b>the debug panel provides the following information : </b><br>
14
10
  * &bull; amount of total objects currently active in the current stage <br>
@@ -32,54 +28,27 @@ export class DebugPanelPlugin extends plugin.BasePlugin {
32
28
  * @param {number} [debugToggle=input.KEY.S] - a default key to toggle the debug panel visibility state
33
29
  * @see input.KEY for default key options
34
30
  */
35
- constructor(debugToggle = input.KEY.S) {
36
- // call the super constructor
37
- super();
38
-
39
- // minimum melonJS version expected
40
- this.version = peerDependencies["melonjs"];
41
-
42
- // hello world
43
- console.log(`${name} ${version} | ${homepage}`);
44
-
45
- this.debugToggle = debugToggle;
46
-
47
- this.panel = new DebugPanel(debugToggle);
48
-
49
- this.keyHandler = event.on(event.KEYDOWN, (action, keyCode) => {
50
- if (keyCode === this.debugToggle) {
51
- this.toggle();
52
- }
53
- });
54
-
55
- // if "#debug" is present in the URL
56
- if (utils.getUriFragment().debug === true) {
57
- this.show();
58
- } // else keep it hidden
59
- }
60
-
31
+ constructor(debugToggle?: number);
32
+ debugToggle: number;
33
+ panel: DebugPanel;
34
+ _onKeyDown: (_action: any, keyCode: any) => void;
35
+ /**
36
+ * destroy the debug plugin
37
+ */
38
+ destroy(): void;
61
39
  /**
62
40
  * show the debug panel
63
41
  */
64
- show() {
65
- this.panel.show();
66
- }
67
-
42
+ show(): void;
68
43
  /**
69
44
  * hide the debug panel
70
45
  */
71
- hide() {
72
- this.panel.hide();
73
- }
74
-
46
+ hide(): void;
75
47
  /**
76
48
  * toggle the debug panel visibility state
77
49
  */
78
- toggle() {
79
- if (this.panel.visible) {
80
- this.panel.hide();
81
- } else {
82
- this.panel.show();
83
- }
84
- }
50
+ toggle(): void;
85
51
  }
52
+ import { plugin } from "melonjs";
53
+ import { DebugPanel } from "./debugPanel.js";
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACC;;;OAGG;IACH,0BAHW,MAAM,EAwBhB;IAdA,oBAA8B;IAC9B,kBAAwC;IAExC,iDAIC;IASF;;OAEG;IACH,gBAGC;IAED;;OAEG;IACH,aAEC;IAED;;OAEG;IACH,aAEC;IAED;;OAEG;IACH,eAMC;CACD;uBAzF2C,SAAS;2BAE1B,iBAAiB"}