melonjs 15.1.5 → 15.2.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.
Files changed (168) hide show
  1. package/README.md +2 -2
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  6. package/dist/melonjs.mjs/application/application.js +3 -3
  7. package/dist/melonjs.mjs/application/header.js +1 -1
  8. package/dist/melonjs.mjs/application/resize.js +1 -1
  9. package/dist/melonjs.mjs/application/settings.js +1 -1
  10. package/dist/melonjs.mjs/audio/audio.js +1 -1
  11. package/dist/melonjs.mjs/camera/camera2d.js +3 -3
  12. package/dist/melonjs.mjs/const.js +1 -1
  13. package/dist/melonjs.mjs/entity/entity.js +1 -1
  14. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  15. package/dist/melonjs.mjs/geometries/line.js +1 -1
  16. package/dist/melonjs.mjs/geometries/path2d.js +1 -1
  17. package/dist/melonjs.mjs/geometries/point.js +1 -1
  18. package/dist/melonjs.mjs/geometries/poly.js +1 -1
  19. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  20. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  21. package/dist/melonjs.mjs/index.js +12 -7
  22. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  23. package/dist/melonjs.mjs/input/input.js +1 -1
  24. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  25. package/dist/melonjs.mjs/input/pointer.js +1 -1
  26. package/dist/melonjs.mjs/input/pointerevent.js +1 -1
  27. package/dist/melonjs.mjs/lang/console.js +1 -1
  28. package/dist/melonjs.mjs/lang/deprecated.js +3 -2
  29. package/dist/melonjs.mjs/level/level.js +5 -4
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +6 -8
  38. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  45. package/dist/melonjs.mjs/loader/cache.js +1 -1
  46. package/dist/melonjs.mjs/loader/loader.js +1 -1
  47. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  48. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  49. package/dist/melonjs.mjs/loader/parser.js +1 -1
  50. package/dist/melonjs.mjs/loader/settings.js +1 -1
  51. package/dist/melonjs.mjs/math/color.js +1 -1
  52. package/dist/melonjs.mjs/math/math.js +1 -1
  53. package/dist/melonjs.mjs/math/matrix2.js +1 -1
  54. package/dist/melonjs.mjs/math/matrix3.js +1 -1
  55. package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
  56. package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
  57. package/dist/melonjs.mjs/math/vector2.js +1 -1
  58. package/dist/melonjs.mjs/math/vector3.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  65. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  66. package/dist/melonjs.mjs/particles/particle.js +1 -1
  67. package/dist/melonjs.mjs/particles/settings.js +1 -1
  68. package/dist/melonjs.mjs/physics/body.js +3 -3
  69. package/dist/melonjs.mjs/physics/bounds.js +1 -1
  70. package/dist/melonjs.mjs/physics/collision.js +1 -1
  71. package/dist/melonjs.mjs/physics/detector.js +4 -4
  72. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  73. package/dist/melonjs.mjs/physics/response.js +1 -1
  74. package/dist/melonjs.mjs/physics/sat.js +9 -9
  75. package/dist/melonjs.mjs/physics/world.js +1 -1
  76. package/dist/melonjs.mjs/plugin/plugin.js +106 -108
  77. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  78. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  79. package/dist/melonjs.mjs/renderable/container.js +20 -19
  80. package/dist/melonjs.mjs/renderable/draggable.js +121 -0
  81. package/dist/melonjs.mjs/renderable/dragndrop.js +3 -113
  82. package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
  83. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  84. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  85. package/dist/melonjs.mjs/renderable/renderable.js +2 -2
  86. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  87. package/dist/melonjs.mjs/renderable/trigger.js +2 -2
  88. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  89. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  90. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  91. package/dist/melonjs.mjs/state/stage.js +1 -1
  92. package/dist/melonjs.mjs/state/state.js +1 -1
  93. package/dist/melonjs.mjs/system/device.js +1 -1
  94. package/dist/melonjs.mjs/system/dom.js +1 -1
  95. package/dist/melonjs.mjs/system/event.js +1 -1
  96. package/dist/melonjs.mjs/system/platform.js +1 -1
  97. package/dist/melonjs.mjs/system/pooling.js +1 -1
  98. package/dist/melonjs.mjs/system/save.js +1 -1
  99. package/dist/melonjs.mjs/system/timer.js +4 -4
  100. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  101. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  102. package/dist/melonjs.mjs/text/glyph.js +1 -1
  103. package/dist/melonjs.mjs/text/text.js +1 -1
  104. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  105. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  106. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  107. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  108. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  109. package/dist/melonjs.mjs/utils/agent.js +1 -1
  110. package/dist/melonjs.mjs/utils/array.js +1 -1
  111. package/dist/melonjs.mjs/utils/file.js +1 -1
  112. package/dist/melonjs.mjs/utils/function.js +1 -1
  113. package/dist/melonjs.mjs/utils/string.js +1 -1
  114. package/dist/melonjs.mjs/utils/utils.js +105 -111
  115. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
  116. package/dist/melonjs.mjs/video/renderer.js +1 -1
  117. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  118. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  119. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  120. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  121. package/dist/melonjs.mjs/video/video.js +4 -4
  122. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  123. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
  124. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
  125. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
  126. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  127. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  129. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  130. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
  137. package/dist/melonjs.module.js +516 -500
  138. package/dist/types/camera/camera2d.d.ts +4 -4
  139. package/dist/types/index.d.ts +4 -4
  140. package/dist/types/physics/body.d.ts +4 -4
  141. package/dist/types/physics/detector.d.ts +5 -5
  142. package/dist/types/physics/sat.d.ts +12 -12
  143. package/dist/types/plugin/plugin.d.ts +60 -5
  144. package/dist/types/renderable/container.d.ts +25 -25
  145. package/dist/types/renderable/draggable.d.ts +53 -0
  146. package/dist/types/renderable/dragndrop.d.ts +0 -52
  147. package/dist/types/renderable/renderable.d.ts +2 -2
  148. package/dist/types/utils/utils.d.ts +56 -17
  149. package/package.json +8 -8
  150. package/src/application/application.js +2 -2
  151. package/src/camera/camera2d.js +2 -2
  152. package/src/index.js +5 -3
  153. package/src/lang/deprecated.js +2 -1
  154. package/src/level/level.js +4 -3
  155. package/src/level/tiled/TMXTileMap.js +2 -2
  156. package/src/level/tiled/TMXUtils.js +4 -3
  157. package/src/physics/body.js +2 -2
  158. package/src/physics/detector.js +3 -3
  159. package/src/physics/sat.js +8 -8
  160. package/src/plugin/plugin.js +103 -105
  161. package/src/renderable/container.js +19 -18
  162. package/src/renderable/draggable.js +114 -0
  163. package/src/renderable/dragndrop.js +0 -109
  164. package/src/renderable/renderable.js +1 -1
  165. package/src/renderable/trigger.js +1 -1
  166. package/src/system/timer.js +3 -3
  167. package/src/utils/utils.js +102 -111
  168. package/src/video/video.js +3 -3
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -23,7 +23,7 @@ import Point from '../geometries/point.js';
23
23
  */
24
24
  class Body {
25
25
  /**
26
- * @param {Renderable} ancestor - the parent object this body is attached to
26
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} ancestor - the parent object this body is attached to
27
27
  * @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] - a initial shape, list of shapes, or JSON object defining the body
28
28
  * @param {Function} [onBodyUpdate] - callback for when the body is updated (e.g. add/remove shapes)
29
29
  */
@@ -33,7 +33,7 @@ import Point from '../geometries/point.js';
33
33
  * a reference to the parent object that contains this body,
34
34
  * or undefined if it has not been added to one.
35
35
  * @public
36
- * @type {Renderable}
36
+ * @type {Renderable|Container|Entity|Sprite|NineSliceSprite}
37
37
  * @default undefined
38
38
  */
39
39
  this.ancestor = ancestor;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -47,8 +47,8 @@ class Detector {
47
47
  /**
48
48
  * determine if two objects should collide (based on both respective objects body collision mask and type).<br>
49
49
  * you can redefine this function if you need any specific rules over what should collide with what.
50
- * @param {Renderable} a - a reference to the object A.
51
- * @param {Renderable} b - a reference to the object B.
50
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
51
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
52
52
  * @returns {boolean} true if they should collide, false otherwise
53
53
  */
54
54
  shouldCollide(a, b) {
@@ -101,7 +101,7 @@ class Detector {
101
101
  /**
102
102
  * find all the collisions for the specified object using a broadphase algorithm
103
103
  * @ignore
104
- * @param {Renderable} objA - object to be tested for collision
104
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision
105
105
  * @returns {boolean} in case of collision, false otherwise
106
106
  */
107
107
  collisions(objA) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -195,9 +195,9 @@ function vornoiRegion(line, point) {
195
195
  /**
196
196
  * Checks whether polygons collide.
197
197
  * @ignore
198
- * @param {Renderable} a - a reference to the object A.
198
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
199
199
  * @param {Polygon} polyA - a reference to the object A Polygon to be tested
200
- * @param {Renderable} b - a reference to the object B.
200
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
201
201
  * @param {Polygon} polyB - a reference to the object B Polygon to be tested
202
202
  * @param {Response=} response - Response object (optional) that will be populated if they intersect.
203
203
  * @returns {boolean} true if they intersect, false if they don't.
@@ -249,9 +249,9 @@ function testPolygonPolygon(a, polyA, b, polyB, response) {
249
249
  /**
250
250
  * Check if two Ellipse collide.
251
251
  * @ignore
252
- * @param {Renderable} a - a reference to the object A.
252
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
253
253
  * @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
254
- * @param {Renderable} b - a reference to the object B.
254
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
255
255
  * @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
256
256
  * @param {Response=} response - Response object (optional) that will be populated if
257
257
  * the circles intersect.
@@ -290,9 +290,9 @@ function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
290
290
  /**
291
291
  * Check if a polygon and an ellipse collide.
292
292
  * @ignore
293
- * @param {Renderable} a - a reference to the object A.
293
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
294
294
  * @param {Polygon} polyA - a reference to the object A Polygon to be tested
295
- * @param {Renderable} b - a reference to the object B.
295
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
296
296
  * @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
297
297
  * @param {Response=} response - Response object (optional) that will be populated if they intersect.
298
298
  * @returns {boolean} true if they intersect, false if they don't.
@@ -456,9 +456,9 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
456
456
  * **NOTE:** This is slightly less efficient than testPolygonEllipse as it just
457
457
  * runs testPolygonEllipse and reverses the response at the end.
458
458
  * @ignore
459
- * @param {Renderable} a - a reference to the object A.
459
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
460
460
  * @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
461
- * @param {Renderable} b - a reference to the object B.
461
+ * @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
462
462
  * @param {Polygon} polyB - a reference to the object B Polygon to be tested
463
463
  * @param {Response=} response - Response object (optional) that will be populated if
464
464
  * they intersect.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,141 +1,139 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
6
6
  * @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
7
7
  */
8
- import utils from '../utils/utils.js';
8
+ import { checkVersion } from '../utils/utils.js';
9
9
  import { version } from '../index.js';
10
10
 
11
11
  /**
12
- * This namespace is a container for all registered plugins.
13
- * @see plugin.register
14
- * @namespace plugins
12
+ * Contains all registered plugins.
13
+ * @name cache
14
+ * @memberof plugin
15
15
  */
16
- let plugins = {};
16
+ let cache = {};
17
17
 
18
+ /**
19
+ * @namespace plugin
20
+ */
18
21
 
22
+ /**
23
+ * a base Object class for plugin
24
+ * (plugin must be installed using the register function)
25
+ * @class
26
+ * @name BasePlugin
27
+ * @memberof plugin
28
+ */
19
29
  class BasePlugin {
20
30
 
21
31
  constructor() {
22
32
  /**
23
33
  * define the minimum required version of melonJS<br>
24
34
  * this can be overridden by the plugin
25
- * @public
26
35
  * @type {string}
27
- * @default "15.1.5"
28
- * @name plugin.Base#version
36
+ * @default "15.2.0"
29
37
  */
30
- this.version = "15.1.5";
38
+ this.version = "15.2.0";
31
39
  }
32
40
  }
33
41
 
42
+
34
43
  /**
35
- * @namespace plugin
44
+ * @class
45
+ * @name Base
46
+ * @memberof plugin
47
+ * @deprecated since 15.1.6, see {@link plugin.BasePlugin}
36
48
  */
37
- let plugin = {
38
-
39
- /**
40
- * a base Object for plugin <br>
41
- * plugin must be installed using the register function
42
- * @see plugin
43
- * @class
44
- * @name Base
45
- * @memberof plugin
46
- */
47
- Base : BasePlugin,
48
-
49
- /**
50
- * patch a melonJS function
51
- * @name patch
52
- * @memberof plugin
53
- * @public
54
- * @param {object} proto - target object
55
- * @param {string} name - target function
56
- * @param {Function} fn - replacement function
57
- * @example
58
- * // redefine the me.game.update function with a new one
59
- * me.plugin.patch(me.game, "update", function () {
60
- * // display something in the console
61
- * console.log("duh");
62
- * // call the original me.game.update function
63
- * this._patched();
64
- * });
65
- */
66
- patch : function (proto, name, fn) {
67
- // use the object prototype if possible
68
- if (typeof proto.prototype !== "undefined") {
69
- proto = proto.prototype;
70
- }
71
- // reuse the logic behind object extends
72
- if (typeof(proto[name]) === "function") {
73
- // save the original function
74
- let _parent = proto[name];
75
- // override the function with the new one
76
- Object.defineProperty(proto, name, {
77
- "configurable" : true,
78
- "value" : (function (name, fn) {
79
- return function () {
80
- this._patched = _parent;
81
- let ret = fn.apply(this, arguments);
82
- this._patched = null;
83
- return ret;
84
- };
85
- })(name, fn)
86
- });
87
- }
88
- else {
89
- throw new Error(name + " is not an existing function");
90
- }
91
- },
49
+ class Base extends BasePlugin {}
92
50
 
93
- /**
94
- * Register a plugin.
95
- * @name register
96
- * @memberof plugin
97
- * @see Base
98
- * @public
99
- * @param {plugin.Base} pluginObj - Plugin object to instantiate and register
100
- * @param {string} [name=pluginObj.constructor.name] - a unique name for this plugin
101
- * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
102
- * @example
103
- * // register a new plugin
104
- * me.plugin.register(TestPlugin, "testPlugin");
105
- * // the plugin then also become available
106
- * // under then me.plugins namespace
107
- * me.plugins.testPlugin.myfunction ();
108
- */
109
- register : function (pluginObj, name = pluginObj.toString().match(/ (\w+)/)[1]) {
110
- // ensure me.plugins[name] is not already "used"
111
- if (plugins[name]) {
112
- throw new Error("plugin " + name + " already registered");
113
- }
51
+ /**
52
+ * patch a melonJS function
53
+ * @name patch
54
+ * @memberof plugin
55
+ * @param {object} proto - target object
56
+ * @param {string} name - target function
57
+ * @param {Function} fn - replacement function
58
+ * @example
59
+ * // redefine the me.game.update function with a new one
60
+ * me.plugin.patch(me.game, "update", function () {
61
+ * // display something in the console
62
+ * console.log("duh");
63
+ * // call the original me.game.update function
64
+ * this._patched();
65
+ * });
66
+ */
67
+ function patch(proto, name, fn) {
68
+ // use the object prototype if possible
69
+ if (typeof proto.prototype !== "undefined") {
70
+ proto = proto.prototype;
71
+ }
72
+ // reuse the logic behind object extends
73
+ if (typeof(proto[name]) === "function") {
74
+ // save the original function
75
+ let _parent = proto[name];
76
+ // override the function with the new one
77
+ Object.defineProperty(proto, name, {
78
+ "configurable" : true,
79
+ "value" : (function (name, fn) {
80
+ return function () {
81
+ this._patched = _parent;
82
+ let ret = fn.apply(this, arguments);
83
+ this._patched = null;
84
+ return ret;
85
+ };
86
+ })(name, fn)
87
+ });
88
+ }
89
+ else {
90
+ throw new Error(name + " is not an existing function");
91
+ }
92
+ }
114
93
 
115
- // get extra arguments
116
- let _args = [];
117
- if (arguments.length > 2) {
118
- // store extra arguments if any
119
- _args = Array.prototype.slice.call(arguments, 1);
120
- }
94
+ /**
95
+ * Register a plugin.
96
+ * @name register
97
+ * @memberof plugin
98
+ * @param {plugin.BasePlugin} plugin - Plugin object to instantiate and register
99
+ * @param {string} [name=plugin.constructor.name] - a unique name for this plugin
100
+ * @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
101
+ * @example
102
+ * // register a new plugin
103
+ * me.plugin.register(TestPlugin, "testPlugin");
104
+ * // the plugin then also become available
105
+ * // under then me.plugins namespace
106
+ * me.plugins.testPlugin.myfunction ();
107
+ */
108
+ function register(plugin, name = plugin.toString().match(/ (\w+)/)[1]) {
109
+ // ensure me.plugins[name] is not already "used"
110
+ if (cache[name]) {
111
+ throw new Error("plugin " + name + " already registered");
112
+ }
121
113
 
122
- // try to instantiate the plugin
123
- _args[0] = pluginObj;
124
- let instance = new (pluginObj.bind.apply(pluginObj, _args))();
114
+ // get extra arguments
115
+ let _args = [];
116
+ if (arguments.length > 2) {
117
+ // store extra arguments if any
118
+ _args = Array.prototype.slice.call(arguments, 1);
119
+ }
125
120
 
126
- // inheritance check
127
- if (typeof instance === "undefined" || !(instance instanceof plugin.Base)) {
128
- throw new Error("Plugin should extend the me.plugin.Base Class !");
129
- }
121
+ // try to instantiate the plugin
122
+ _args[0] = plugin;
123
+ let instance = new (plugin.bind.apply(plugin, _args))();
130
124
 
131
- // compatibility testing
132
- if (utils.checkVersion(instance.version, version) > 0) {
133
- throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
134
- }
125
+ // inheritance check
126
+ if (typeof instance === "undefined" || !(instance instanceof BasePlugin)) {
127
+ throw new Error("Plugin should extend the BasePlugin Class !");
128
+ }
135
129
 
136
- // create a reference to the new plugin
137
- plugins[name] = instance;
130
+ // compatibility testing
131
+ if (checkVersion(instance.version, version) > 0) {
132
+ throw new Error("Plugin version mismatch, expected: " + instance.version + ", got: " + version);
138
133
  }
139
- };
140
134
 
141
- export { plugin, plugins };
135
+ // create a reference to the new plugin
136
+ cache[name] = instance;
137
+ }
138
+
139
+ export { Base, BasePlugin, cache, patch, register };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.5
2
+ * melonJS Game Engine - v15.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license