11/*!
2- * melonJS debug plugin - v14.6.5
2+ * melonJS debug plugin - v14.7.0
33 * http://www.melonjs.org
44 * @melonjs /debug-plugin is licensed under the MIT License.
55 * http://www.opensource.org/licenses/mit-license
66 * @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
77 */
8- import { Renderable , video , utils , BitmapText , Rect , event , plugins , input , plugin , Container , Entity , Text , Camera2d , ImageLayer , game , timer , collision , Math , pool } from 'melonjs' ;
8+ import { Renderable , video , utils , BitmapText , Rect , event , plugin , Container , Entity , Text , Camera2d , ImageLayer , game , input , timer , collision , Math , pool } from 'melonjs' ;
9+
10+ var name = "@melonjs/debug-plugin" ;
11+ var version = "14.7.0" ;
12+ var description = "melonJS debug plugin" ;
13+ var homepage = "https://github.com/melonjs/debug-plugin#readme" ;
14+ var type = "module" ;
15+ var keywords = [
16+ "2D" ,
17+ "HTML5" ,
18+ "javascript" ,
19+ "TypeScript" ,
20+ "es6" ,
21+ "Canvas" ,
22+ "WebGL" ,
23+ "WebGL2" ,
24+ "WebAudio" ,
25+ "game" ,
26+ "engine" ,
27+ "tiled" ,
28+ "tileset" ,
29+ "mapeditor" ,
30+ "browser" ,
31+ "electron" ,
32+ "mobile" ,
33+ "cordova"
34+ ] ;
35+ var repository = {
36+ type : "git" ,
37+ url : "git+https://github.com/melonjs/debug-plugin.git"
38+ } ;
39+ var bugs = {
40+ url : "https://github.com/melonjs/debug-plugin/issues"
41+ } ;
42+ var license = "MIT" ;
43+ var author = "Olivier Biot (AltByte Pte Ltd)" ;
44+ var funding = "https://github.com/sponsors/melonjs" ;
45+ var engines = {
46+ node : ">= 19"
47+ } ;
48+ var main = "dist/@melonjs/debug-plugin.js" ;
49+ var module = "dist/@melonjs/debug-plugin.js" ;
50+ var types = "dist/@melonjs/debug-plugin.d.ts" ;
51+ var sideEffects = false ;
52+ var files = [
53+ "dist/" ,
54+ "src/" ,
55+ "package.json" ,
56+ "README.md" ,
57+ "LICENSE"
58+ ] ;
59+ var peerDependencies = {
60+ melonjs : "15.5.0"
61+ } ;
62+ var devDependencies = {
63+ "@babel/eslint-parser" : "^7.22.15" ,
64+ "@babel/plugin-syntax-import-assertions" : "^7.22.5" ,
65+ "@rollup/plugin-commonjs" : "^25.0.4" ,
66+ "@rollup/plugin-image" : "^3.0.2" ,
67+ "@rollup/plugin-json" : "^6.0.0" ,
68+ "@rollup/plugin-node-resolve" : "^15.2.1" ,
69+ "@rollup/plugin-replace" : "^5.0.2" ,
70+ "del-cli" : "^5.1.0" ,
71+ eslint : "^8.49.0" ,
72+ "eslint-plugin-jsdoc" : "^46.5.1" ,
73+ rollup : "^3.29.0" ,
74+ "rollup-plugin-bundle-size" : "^1.0.3" ,
75+ "rollup-plugin-string" : "^3.0.0" ,
76+ typescript : "^5.2.2"
77+ } ;
78+ var scripts = {
79+ build : "npm run lint && rollup -c --silent && npm run types" ,
80+ lint : "eslint src/**.js rollup.config.mjs" ,
81+ prepublishOnly : "npm run build" ,
82+ clean : "del-cli --force dist/*" ,
83+ types : "tsc"
84+ } ;
85+ var _package = {
86+ name : name ,
87+ version : version ,
88+ description : description ,
89+ homepage : homepage ,
90+ type : type ,
91+ keywords : keywords ,
92+ repository : repository ,
93+ bugs : bugs ,
94+ license : license ,
95+ author : author ,
96+ funding : funding ,
97+ engines : engines ,
98+ main : main ,
99+ module : module ,
100+ types : types ,
101+ sideEffects : sideEffects ,
102+ files : files ,
103+ peerDependencies : peerDependencies ,
104+ devDependencies : devDependencies ,
105+ scripts : scripts
106+ } ;
9107
10108class Counters {
11109 constructor ( ) {
@@ -31,7 +129,7 @@ var fontDataSource = "info face=PressStart2P size=10 bold=0 italic=0 charset= un
31129const DEBUG_HEIGHT = 50 ;
32130
33131class DebugPanel extends Renderable {
34- constructor ( debugToggle = input . KEY . S ) {
132+ constructor ( debugToggle ) {
35133 // call the super constructor
36134 super ( 0 , 0 , video . renderer . getWidth ( ) , DEBUG_HEIGHT ) ;
37135
@@ -71,7 +169,7 @@ class DebugPanel extends Renderable {
71169 this . name = "debugPanel" ;
72170
73171 // the debug panel version
74- this . version = "14.6.5 " ;
172+ this . version = "14.7.0 " ;
75173
76174 // persistent
77175 this . isPersistent = true ;
@@ -118,11 +216,6 @@ class DebugPanel extends Renderable {
118216
119217 // add some keyboard shortcuts
120218 this . debugToggle = debugToggle ;
121- this . keyHandler = event . on ( event . KEYDOWN , ( action , keyCode ) => {
122- if ( keyCode === this . debugToggle ) {
123- plugins . debugPanel . toggle ( ) ;
124- }
125- } ) ;
126219
127220 // some internal string/length
128221 this . help_str = "[" + String . fromCharCode ( 32 + this . debugToggle ) + "]show/hide" ;
@@ -560,8 +653,6 @@ class DebugPanel extends Renderable {
560653 onDestroyEvent ( ) {
561654 // hide the panel
562655 this . hide ( ) ;
563- // unbind keys event
564- input . unbindKey ( this . toggleKey ) ;
565656 }
566657}
567658
@@ -591,16 +682,30 @@ class DebugPanel extends Renderable {
591682 * @augments plugin.BasePlugin
592683 */
593684class DebugPanelPlugin extends plugin . BasePlugin {
594-
595- constructor ( debugToggle ) {
685+ /**
686+ * @param {number } [debugToggle=input.KEY.S] - a default key to toggle the debug panel visibility state
687+ * @see input.KEY for default key options
688+ */
689+ constructor ( debugToggle = input . KEY . S ) {
596690 // call the super constructor
597691 super ( ) ;
598692
599693 // minimum melonJS version expected
600- this . version = "15.2.0" ;
694+ this . version = peerDependencies [ "melonjs" ] ;
695+
696+ // hello world
697+ console . log ( `${ name } ${ version } | ${ homepage } ` ) ;
698+
699+ this . debugToggle = debugToggle ;
601700
602701 this . panel = new DebugPanel ( debugToggle ) ;
603702
703+ this . keyHandler = event . on ( event . KEYDOWN , ( action , keyCode ) => {
704+ if ( keyCode === this . debugToggle ) {
705+ this . toggle ( ) ;
706+ }
707+ } ) ;
708+
604709 // if "#debug" is present in the URL
605710 if ( utils . getUriFragment ( ) . debug === true ) {
606711 this . show ( ) ;
0 commit comments