melonjs 15.14.0 → 16.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.
Files changed (187) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +2 -2
  2. package/dist/melonjs.mjs/_virtual/earcut.js +2 -2
  3. package/dist/melonjs.mjs/_virtual/howler.js +2 -2
  4. package/dist/melonjs.mjs/_virtual/index.js +2 -2
  5. package/dist/melonjs.mjs/application/application.js +2 -2
  6. package/dist/melonjs.mjs/application/header.js +2 -2
  7. package/dist/melonjs.mjs/application/resize.js +2 -2
  8. package/dist/melonjs.mjs/application/settings.js +5 -3
  9. package/dist/melonjs.mjs/audio/audio.js +2 -2
  10. package/dist/melonjs.mjs/camera/camera2d.js +2 -2
  11. package/dist/melonjs.mjs/const.js +2 -2
  12. package/dist/melonjs.mjs/geometries/ellipse.js +6 -8
  13. package/dist/melonjs.mjs/geometries/line.js +2 -2
  14. package/dist/melonjs.mjs/geometries/path2d.js +131 -5
  15. package/dist/melonjs.mjs/geometries/point.js +7 -9
  16. package/dist/melonjs.mjs/geometries/poly.js +4 -14
  17. package/dist/melonjs.mjs/geometries/rectangle.js +2 -2
  18. package/dist/melonjs.mjs/geometries/roundrect.js +2 -2
  19. package/dist/melonjs.mjs/geometries/toarccanvas.js +103 -0
  20. package/dist/melonjs.mjs/index.js +3 -3
  21. package/dist/melonjs.mjs/input/gamepad.js +2 -2
  22. package/dist/melonjs.mjs/input/input.js +2 -2
  23. package/dist/melonjs.mjs/input/keyboard.js +2 -2
  24. package/dist/melonjs.mjs/input/pointer.js +2 -2
  25. package/dist/melonjs.mjs/input/pointerevent.js +2 -2
  26. package/dist/melonjs.mjs/lang/console.js +2 -2
  27. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  28. package/dist/melonjs.mjs/level/level.js +2 -2
  29. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +2 -2
  30. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +2 -2
  31. package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -2
  32. package/dist/melonjs.mjs/level/tiled/TMXTile.js +2 -2
  33. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
  34. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +2 -2
  35. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
  36. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +2 -2
  37. package/dist/melonjs.mjs/level/tiled/constants.js +2 -2
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
  43. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +2 -2
  44. package/dist/melonjs.mjs/loader/cache.js +2 -2
  45. package/dist/melonjs.mjs/loader/loader.js +2 -2
  46. package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
  47. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +3 -4
  48. package/dist/melonjs.mjs/loader/parsers/binary.js +15 -22
  49. package/dist/melonjs.mjs/loader/parsers/fetchdata.js +62 -0
  50. package/dist/melonjs.mjs/loader/parsers/fontface.js +2 -2
  51. package/dist/melonjs.mjs/loader/parsers/image.js +47 -11
  52. package/dist/melonjs.mjs/loader/parsers/json.js +14 -31
  53. package/dist/melonjs.mjs/loader/parsers/script.js +2 -2
  54. package/dist/melonjs.mjs/loader/parsers/tmx.js +48 -74
  55. package/dist/melonjs.mjs/loader/settings.js +2 -2
  56. package/dist/melonjs.mjs/math/color.js +2 -2
  57. package/dist/melonjs.mjs/math/math.js +13 -3
  58. package/dist/melonjs.mjs/math/matrix2.js +2 -2
  59. package/dist/melonjs.mjs/math/matrix3.js +2 -2
  60. package/dist/melonjs.mjs/math/observable_vector2.js +2 -2
  61. package/dist/melonjs.mjs/math/observable_vector3.js +2 -2
  62. package/dist/melonjs.mjs/math/vector2.js +7 -9
  63. package/dist/melonjs.mjs/math/vector3.js +6 -10
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +2 -2
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +2 -2
  66. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +2 -2
  67. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
  68. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +2 -2
  69. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +2 -2
  70. package/dist/melonjs.mjs/particles/emitter.js +2 -2
  71. package/dist/melonjs.mjs/particles/particle.js +2 -2
  72. package/dist/melonjs.mjs/particles/settings.js +3 -5
  73. package/dist/melonjs.mjs/physics/body.js +6 -8
  74. package/dist/melonjs.mjs/physics/bounds.js +2 -2
  75. package/dist/melonjs.mjs/physics/collision.js +3 -5
  76. package/dist/melonjs.mjs/physics/detector.js +2 -2
  77. package/dist/melonjs.mjs/physics/quadtree.js +2 -2
  78. package/dist/melonjs.mjs/physics/response.js +2 -2
  79. package/dist/melonjs.mjs/physics/sat.js +2 -2
  80. package/dist/melonjs.mjs/physics/world.js +2 -2
  81. package/dist/melonjs.mjs/plugin/plugin.js +5 -5
  82. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  83. package/dist/melonjs.mjs/renderable/colorlayer.js +2 -2
  84. package/dist/melonjs.mjs/renderable/container.js +2 -2
  85. package/dist/melonjs.mjs/renderable/draggable.js +2 -2
  86. package/dist/melonjs.mjs/renderable/dragndrop.js +2 -2
  87. package/dist/melonjs.mjs/renderable/entity/entity.js +2 -2
  88. package/dist/melonjs.mjs/renderable/imagelayer.js +13 -12
  89. package/dist/melonjs.mjs/renderable/light2d.js +2 -2
  90. package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
  91. package/dist/melonjs.mjs/renderable/renderable.js +20 -2
  92. package/dist/melonjs.mjs/renderable/sprite.js +2 -2
  93. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +2 -2
  94. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +2 -2
  95. package/dist/melonjs.mjs/renderable/text/glyph.js +2 -2
  96. package/dist/melonjs.mjs/renderable/text/text.js +2 -2
  97. package/dist/melonjs.mjs/renderable/text/textmetrics.js +2 -2
  98. package/dist/melonjs.mjs/renderable/text/textstyle.js +2 -2
  99. package/dist/melonjs.mjs/renderable/trigger.js +2 -2
  100. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +2 -2
  101. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +2 -2
  102. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +2 -2
  103. package/dist/melonjs.mjs/state/stage.js +2 -2
  104. package/dist/melonjs.mjs/state/state.js +3 -4
  105. package/dist/melonjs.mjs/system/device.js +2 -2
  106. package/dist/melonjs.mjs/system/dom.js +2 -2
  107. package/dist/melonjs.mjs/system/event.js +2 -2
  108. package/dist/melonjs.mjs/system/platform.js +2 -2
  109. package/dist/melonjs.mjs/system/pooling.js +3 -20
  110. package/dist/melonjs.mjs/system/save.js +2 -2
  111. package/dist/melonjs.mjs/system/timer.js +3 -19
  112. package/dist/melonjs.mjs/tweens/easing.js +2 -2
  113. package/dist/melonjs.mjs/tweens/interpolation.js +2 -2
  114. package/dist/melonjs.mjs/tweens/tween.js +2 -2
  115. package/dist/melonjs.mjs/utils/agent.js +2 -2
  116. package/dist/melonjs.mjs/utils/array.js +2 -2
  117. package/dist/melonjs.mjs/utils/file.js +2 -2
  118. package/dist/melonjs.mjs/utils/function.js +2 -2
  119. package/dist/melonjs.mjs/utils/string.js +2 -2
  120. package/dist/melonjs.mjs/utils/utils.js +2 -2
  121. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +2 -2
  122. package/dist/melonjs.mjs/video/renderer.js +14 -17
  123. package/dist/melonjs.mjs/video/texture/atlas.js +28 -14
  124. package/dist/melonjs.mjs/video/texture/cache.js +3 -4
  125. package/dist/melonjs.mjs/video/texture/canvas_texture.js +16 -19
  126. package/dist/melonjs.mjs/video/utils/autodetect.js +2 -2
  127. package/dist/melonjs.mjs/video/video.js +2 -2
  128. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +2 -2
  129. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +2 -2
  130. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +2 -2
  131. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +5 -3
  132. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
  133. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +2 -2
  134. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
  135. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +2 -2
  136. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
  137. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
  138. package/dist/melonjs.mjs/video/webgl/utils/precision.js +2 -2
  139. package/dist/melonjs.mjs/video/webgl/utils/program.js +2 -2
  140. package/dist/melonjs.mjs/video/webgl/utils/string.js +2 -2
  141. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +2 -2
  142. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +2 -2
  143. package/dist/melonjs.module.js +1187 -325
  144. package/dist/types/application/application.d.ts +1 -1
  145. package/dist/types/application/settings.d.ts +5 -0
  146. package/dist/types/geometries/path2d.d.ts +24 -0
  147. package/dist/types/geometries/rectangle.d.ts +4 -4
  148. package/dist/types/geometries/roundrect.d.ts +1 -1
  149. package/dist/types/geometries/toarccanvas.d.ts +10 -0
  150. package/dist/types/loader/parsers/binary.d.ts +0 -8
  151. package/dist/types/loader/parsers/fetchdata.d.ts +15 -0
  152. package/dist/types/loader/parsers/tmx.d.ts +1 -0
  153. package/dist/types/math/color.d.ts +4 -4
  154. package/dist/types/math/math.d.ts +6 -0
  155. package/dist/types/math/observable_vector2.d.ts +2 -2
  156. package/dist/types/math/observable_vector3.d.ts +3 -3
  157. package/dist/types/physics/bounds.d.ts +4 -4
  158. package/dist/types/renderable/entity/entity.d.ts +1 -1
  159. package/dist/types/renderable/imagelayer.d.ts +2 -2
  160. package/dist/types/renderable/renderable.d.ts +9 -3
  161. package/dist/types/renderable/text/bitmaptext.d.ts +1 -1
  162. package/dist/types/video/renderer.d.ts +11 -23
  163. package/dist/types/video/texture/canvas_texture.d.ts +11 -23
  164. package/package.json +18 -17
  165. package/src/application/settings.js +3 -1
  166. package/src/geometries/ellipse.js +4 -6
  167. package/src/geometries/path2d.js +129 -4
  168. package/src/geometries/point.js +5 -7
  169. package/src/geometries/poly.js +2 -12
  170. package/src/geometries/toarccanvas.js +94 -0
  171. package/src/loader/parsers/binary.js +13 -56
  172. package/src/loader/parsers/fetchdata.js +53 -0
  173. package/src/loader/parsers/image.js +45 -12
  174. package/src/loader/parsers/json.js +12 -30
  175. package/src/loader/parsers/tmx.js +46 -72
  176. package/src/math/math.js +10 -0
  177. package/src/math/vector2.js +5 -7
  178. package/src/math/vector3.js +4 -8
  179. package/src/physics/body.js +4 -6
  180. package/src/plugin/plugin.js +1 -1
  181. package/src/polyfill/index.js +3 -0
  182. package/src/renderable/imagelayer.js +10 -9
  183. package/src/renderable/renderable.js +18 -0
  184. package/src/video/renderer.js +12 -15
  185. package/src/video/texture/atlas.js +26 -12
  186. package/src/video/texture/canvas_texture.js +14 -17
  187. package/src/video/webgl/compositors/quad_compositor.js +3 -1
@@ -102,7 +102,7 @@ export default class Application {
102
102
  * destroy all current objects
103
103
  */
104
104
  reset(): void;
105
- set sortOn(arg: string);
105
+ set sortOn(value: string);
106
106
  /**
107
107
  * Specify the property to be used when sorting renderables for this application game world.
108
108
  * Accepted values : "x", "y", "z", "depth"
@@ -17,6 +17,7 @@ export namespace defaultSettings {
17
17
  let verbose: boolean;
18
18
  let consoleHeader: boolean;
19
19
  let legacy: boolean;
20
+ let canvas: undefined;
20
21
  }
21
22
  /**
22
23
  * Application & Renderer Settings definition.
@@ -26,6 +27,10 @@ export type Settings = {
26
27
  * - the DOM parent element to hold the canvas in the HTML file
27
28
  */
28
29
  parent?: string | HTMLElement | undefined;
30
+ /**
31
+ * - an existing canvas element to use as the renderer target (by default melonJS will create its own canvas based on given parameters)
32
+ */
33
+ canvas?: HTMLCanvasElement | undefined;
29
34
  /**
30
35
  * - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
31
36
  */
@@ -3,6 +3,7 @@
3
3
  * a simplified path2d implementation, supporting only one path
4
4
  */
5
5
  export default class Path2D {
6
+ constructor(svgPath: any);
6
7
  /**
7
8
  * the points defining the current path
8
9
  * @type {Point[]}
@@ -17,6 +18,11 @@ export default class Path2D {
17
18
  vertices: any[];
18
19
  startPoint: object;
19
20
  isDirty: boolean;
21
+ /**
22
+ * Parses an SVG path string and adds the points to the current path.
23
+ * @param {string} svgPath - The SVG path string to parse.
24
+ */
25
+ parseSVGPath(svgPath: string): void;
20
26
  /**
21
27
  * begin a new path
22
28
  */
@@ -77,6 +83,24 @@ export default class Path2D {
77
83
  * @param {boolean} [anticlockwise=false] - an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
78
84
  */
79
85
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
86
+ /**
87
+ * Adds a quadratic Bézier curve to the path.
88
+ * @param {number} cpX - The x-coordinate of the control point.
89
+ * @param {number} cpY - The y-coordinate of the control point.
90
+ * @param {number} x - The x-coordinate of the end point of the curve.
91
+ * @param {number} y - The y-coordinate of the end point of the curve.
92
+ */
93
+ quadraticCurveTo(cpX: number, cpY: number, x: number, y: number): void;
94
+ /**
95
+ * Adds a cubic Bézier curve to the path.
96
+ * @param {number} cp1X - The x-coordinate of the first control point.
97
+ * @param {number} cp1Y - The y-coordinate of the first control point.
98
+ * @param {number} cp2X - The x-coordinate of the second control point.
99
+ * @param {number} cp2Y - The y-coordinate of the second control point.
100
+ * @param {number} x - The x-coordinate of the end point of the curve.
101
+ * @param {number} y - The y-coordinate of the end point of the curve.
102
+ */
103
+ bezierCurveTo(cp1X: number, cp1Y: number, cp2X: number, cp2Y: number, x: number, y: number): void;
80
104
  /**
81
105
  * creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
82
106
  * @param {number} x - the x-axis coordinate of the rectangle's starting point.
@@ -42,25 +42,25 @@ export default class Rect extends Polygon {
42
42
  * @type {number}
43
43
  */
44
44
  get bottom(): number;
45
- set width(arg: number);
45
+ set width(value: number);
46
46
  /**
47
47
  * width of the Rectangle
48
48
  * @type {number}
49
49
  */
50
50
  get width(): number;
51
- set height(arg: number);
51
+ set height(value: number);
52
52
  /**
53
53
  * height of the Rectangle
54
54
  * @type {number}
55
55
  */
56
56
  get height(): number;
57
- set centerX(arg: number);
57
+ set centerX(value: number);
58
58
  /**
59
59
  * absolute center of this rectangle on the horizontal axis
60
60
  * @type {number}
61
61
  */
62
62
  get centerX(): number;
63
- set centerY(arg: number);
63
+ set centerY(value: number);
64
64
  /**
65
65
  * absolute center of this rectangle on the vertical axis
66
66
  * @type {number}
@@ -12,7 +12,7 @@ export default class RoundRect extends Rect {
12
12
  * @param {number} [radius=20] - the radius of the rounded corner
13
13
  */
14
14
  constructor(x: number, y: number, width: number, height: number, radius?: number | undefined);
15
- set radius(arg: number);
15
+ set radius(value: number);
16
16
  /**
17
17
  * the radius of the rounded corner
18
18
  * @type {number}
@@ -0,0 +1,10 @@
1
+ export function endpointToCenterParameterization(x1: any, y1: any, x2: any, y2: any, largeArcFlag: any, sweepFlag: any, srx: any, sry: any, xAxisRotationDeg: any): {
2
+ cx: any;
3
+ cy: any;
4
+ rx: number;
5
+ ry: number;
6
+ startAngle: number;
7
+ endAngle: number;
8
+ xAxisRotation: number;
9
+ anticlockwise: boolean;
10
+ };
@@ -7,11 +7,3 @@
7
7
  * @ignore
8
8
  */
9
9
  export function preloadBinary(data: loader.Asset, onload?: Function | undefined, onerror?: Function | undefined): number;
10
- /**
11
- * parse/preload a Javascript files
12
- * @param {loader.Asset} data - asset data
13
- * @param {Function} [onload] - function to be called when the asset is loaded
14
- * @param {Function} [onerror] - function to be called in case of error
15
- * @ignore
16
- */
17
- export function preloadJavascript(data: loader.Asset, onload?: Function | undefined, onerror?: Function | undefined): number;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Fetches data from the specified URL.
3
+ * @param {string} url - The URL to fetch the data from.
4
+ * @param {string} responseType - The type of response expected ('json', 'text', 'blob', 'arrayBuffer').
5
+ * @returns {Promise} A promise that resolves with the fetched data or rejects with an error.
6
+ * @example
7
+ * fetchData('https://api.example.com/data', 'json')
8
+ * .then(data => {
9
+ * // Handle the fetched JSON data
10
+ * })
11
+ * .catch(error => {
12
+ * // Handle the error
13
+ * });
14
+ */
15
+ export function fetchData(url: string, responseType: string): Promise<any>;
@@ -3,6 +3,7 @@
3
3
  * @param {loader.Asset} data - asset data
4
4
  * @param {Function} [onload] - function to be called when the asset is loaded
5
5
  * @param {Function} [onerror] - function to be called in case of error
6
+ * @param {Function} [fetchData] - function to use instead of default window.fetch, has some error handling and things
6
7
  * @returns {number} the amount of corresponding resource parsed/preloaded
7
8
  * @ignore
8
9
  */
@@ -15,25 +15,25 @@ export default class Color {
15
15
  */
16
16
  onResetEvent(r?: number, g?: number, b?: number, alpha?: number): void;
17
17
  glArray: Float32Array | undefined;
18
- set r(arg: number);
18
+ set r(value: number);
19
19
  /**
20
20
  * Color Red Component [0 .. 255]
21
21
  * @type {number}
22
22
  */
23
23
  get r(): number;
24
- set g(arg: number);
24
+ set g(value: number);
25
25
  /**
26
26
  * Color Green Component [0 .. 255]
27
27
  * @type {number}
28
28
  */
29
29
  get g(): number;
30
- set b(arg: number);
30
+ set b(value: number);
31
31
  /**
32
32
  * Color Blue Component [0 .. 255]
33
33
  * @type {number}
34
34
  */
35
35
  get b(): number;
36
- set alpha(arg: number);
36
+ set alpha(value: number);
37
37
  /**
38
38
  * Color Alpha Component [0.0 .. 1.0]
39
39
  * @type {number}
@@ -119,6 +119,12 @@ export function round(num: number, dec?: number | undefined): number;
119
119
  * }
120
120
  */
121
121
  export function toBeCloseTo(expected: number, actual: number, precision?: number | undefined): boolean;
122
+ /**
123
+ * Calculates the power of a number.
124
+ * @param {number} n - The number to be raised to the power of 2.
125
+ * @returns {number} The result of raising the number to the power of 2.
126
+ */
127
+ export function pow(n: number): number;
122
128
  /**
123
129
  * a collection of math utility functions
124
130
  * @namespace Math
@@ -19,7 +19,7 @@ export default class ObservableVector2d extends Vector2d {
19
19
  * @ignore
20
20
  */
21
21
  onResetEvent(x: number | undefined, y: number | undefined, settings: any): void;
22
- public set x(arg: number);
22
+ public set x(value: number);
23
23
  /**
24
24
  * x value of the vector
25
25
  * @public
@@ -29,7 +29,7 @@ export default class ObservableVector2d extends Vector2d {
29
29
  */
30
30
  public get x(): number;
31
31
  _x: any;
32
- public set y(arg: number);
32
+ public set y(value: number);
33
33
  /**
34
34
  * y value of the vector
35
35
  * @public
@@ -20,7 +20,7 @@ export default class ObservableVector3d extends Vector3d {
20
20
  * @ignore
21
21
  */
22
22
  onResetEvent(x: number | undefined, y: number | undefined, z: number | undefined, settings: any): this;
23
- public set x(arg: number);
23
+ public set x(value: number);
24
24
  /**
25
25
  * x value of the vector
26
26
  * @public
@@ -30,7 +30,7 @@ export default class ObservableVector3d extends Vector3d {
30
30
  */
31
31
  public get x(): number;
32
32
  _x: any;
33
- public set y(arg: number);
33
+ public set y(value: number);
34
34
  /**
35
35
  * y value of the vector
36
36
  * @public
@@ -40,7 +40,7 @@ export default class ObservableVector3d extends Vector3d {
40
40
  */
41
41
  public get y(): number;
42
42
  _y: any;
43
- public set z(arg: number);
43
+ public set z(value: number);
44
44
  /**
45
45
  * z value of the vector
46
46
  * @public
@@ -38,25 +38,25 @@ export default class Bounds {
38
38
  * @param {number} maxY
39
39
  */
40
40
  setMinMax(minX: number, minY: number, maxX: number, maxY: number): void;
41
- set x(arg: number);
41
+ set x(value: number);
42
42
  /**
43
43
  * x position of the bound
44
44
  * @type {number}
45
45
  */
46
46
  get x(): number;
47
- set y(arg: number);
47
+ set y(value: number);
48
48
  /**
49
49
  * y position of the bounds
50
50
  * @type {number}
51
51
  */
52
52
  get y(): number;
53
- set width(arg: number);
53
+ set width(value: number);
54
54
  /**
55
55
  * width of the bounds
56
56
  * @type {number}
57
57
  */
58
58
  get width(): number;
59
- set height(arg: number);
59
+ set height(value: number);
60
60
  /**
61
61
  * width of the bounds
62
62
  * @type {number}
@@ -39,7 +39,7 @@ export default class Entity extends Renderable {
39
39
  * @ignore
40
40
  */
41
41
  children: any[];
42
- set renderable(arg: Renderable);
42
+ set renderable(value: Renderable);
43
43
  /**
44
44
  * The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
45
45
  * @type {Renderable}
@@ -40,7 +40,7 @@ export default class ImageLayer extends Sprite {
40
40
  * @default <1.0,1.0>
41
41
  */
42
42
  ratio: Vector2d;
43
- set repeat(arg: string);
43
+ set repeat(value: string);
44
44
  /**
45
45
  * Define if and how an Image Layer should be repeated.<br>
46
46
  * By default, an Image Layer is repeated both vertically and horizontally.<br>
@@ -67,7 +67,7 @@ export default class ImageLayer extends Sprite {
67
67
  * updateLayer function
68
68
  * @ignore
69
69
  */
70
- updateLayer(vpos: any): void;
70
+ updateLayer(): void;
71
71
  /**
72
72
  * override the default predraw function
73
73
  * as repeat and anchor are managed directly in the draw method
@@ -199,14 +199,20 @@ export default class Renderable extends Rect {
199
199
  y: boolean;
200
200
  };
201
201
  _inViewport: boolean;
202
+ _parentApp: any;
202
203
  _tint: object;
204
+ /**
205
+ * returns the parent application (or game) to which this renderable is attached to
206
+ * @return {Application} the parent application or undefined if not attached to any container/app
207
+ */
208
+ get parentApp(): Application;
203
209
  /**
204
210
  * Whether the renderable object is floating (i.e. used screen coordinates), or contained in a floating parent container
205
211
  * @see Renderable#floating
206
212
  * @type {boolean}
207
213
  */
208
214
  get isFloating(): boolean;
209
- set tint(arg: Color);
215
+ set tint(value: Color);
210
216
  /**
211
217
  * define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
212
218
  * @type {Color}
@@ -218,13 +224,13 @@ export default class Renderable extends Rect {
218
224
  * this.tint.setColor(255, 255, 255);
219
225
  */
220
226
  get tint(): Color;
221
- set depth(arg: number);
227
+ set depth(value: number);
222
228
  /**
223
229
  * the depth of this renderable on the z axis
224
230
  * @type {number}
225
231
  */
226
232
  get depth(): number;
227
- set inViewport(arg: boolean);
233
+ set inViewport(value: boolean);
228
234
  /**
229
235
  * Whether the renderable object is visible and within the viewport
230
236
  * @type {boolean}
@@ -98,7 +98,7 @@ export default class BitmapText extends Renderable {
98
98
  * @private
99
99
  */
100
100
  private fontData;
101
- public set fillStyle(arg: Color);
101
+ public set fillStyle(value: Color);
102
102
  /**
103
103
  * defines the color used to tint the bitmap text
104
104
  * @public
@@ -65,13 +65,13 @@ export default class Renderer {
65
65
  currentTint: Color;
66
66
  projectionMatrix: Matrix3d;
67
67
  uvOffset: number;
68
- set height(arg: number);
68
+ set height(value: number);
69
69
  /**
70
70
  * return the height of the canvas which this renderer draws to
71
71
  * @returns {number} height of the system Canvas
72
72
  */
73
73
  get height(): number;
74
- set width(arg: number);
74
+ set width(value: number);
75
75
  /**
76
76
  * return the width of the canvas which this renderer draws to
77
77
  * @returns {number} width of the system Canvas
@@ -190,44 +190,32 @@ export default class Renderer {
190
190
  clearTint(): void;
191
191
  /**
192
192
  * creates a Blob object representing the last rendered frame
193
- * @param {object} [options] - An object with the following properties:
194
- * @param {string} [options.type="image/png"] - A string indicating the image format
195
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
193
+ * @param {string} [type="image/png"] - A string indicating the image format
194
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
196
195
  * @returns {Promise} A Promise returning a Blob object representing the last rendered frame
197
196
  * @example
198
197
  * renderer.convertToBlob().then((blob) => console.log(blob));
199
198
  */
200
- toBlob(options?: {
201
- type?: string | undefined;
202
- quality?: number | undefined;
203
- } | undefined): Promise<any>;
199
+ toBlob(type?: string | undefined, quality?: number | undefined): Promise<any>;
204
200
  /**
205
201
  * creates an ImageBitmap object of the last frame rendered
206
202
  * (not supported by standard Canvas)
207
- * @param {object} [options] - An object with the following properties:
208
- * @param {string} [options.type="image/png"] - A string indicating the image format
209
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
203
+ * @param {string} [type="image/png"] - A string indicating the image format
204
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
210
205
  * @returns {Promise} A Promise returning an ImageBitmap.
211
206
  * @example
212
207
  * renderer.transferToImageBitmap().then((image) => console.log(image));
213
208
  */
214
- toImageBitmap(options?: {
215
- type?: string | undefined;
216
- quality?: number | undefined;
217
- } | undefined): Promise<any>;
209
+ toImageBitmap(type?: string | undefined, quality?: number | undefined): Promise<any>;
218
210
  /**
219
211
  * returns a data URL containing a representation of the last frame rendered
220
- * @param {object} [options] - An object with the following properties:
221
- * @param {string} [options.type="image/png"] - A string indicating the image format
222
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
212
+ * @param {string} [type="image/png"] - A string indicating the image format
213
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
223
214
  * @returns {Promise} A Promise returning a string containing the requested data URL.
224
215
  * @example
225
216
  * renderer.toDataURL().then((dataURL) => console.log(dataURL));
226
217
  */
227
- toDataURL(options?: {
228
- type?: string | undefined;
229
- quality?: number | undefined;
230
- } | undefined): Promise<any>;
218
+ toDataURL(type?: string | undefined, quality?: number | undefined): Promise<any>;
231
219
  }
232
220
  import Vector2d from "../math/vector2.js";
233
221
  import Path2D from "./../geometries/path2d.js";
@@ -60,44 +60,32 @@ declare class CanvasTexture {
60
60
  getImageData(x: number, y: number, width: number, height: number): ImageData;
61
61
  /**
62
62
  * creates a Blob object representing the image contained in this canvas texture
63
- * @param {object} [options] - An object with the following properties:
64
- * @param {string} [options.type="image/png"] - A string indicating the image format
65
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
63
+ * @param {string} [type="image/png"] - A string indicating the image format
64
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
66
65
  * @returns {Promise} A Promise returning a Blob object representing the image contained in this canvas texture
67
66
  * @example
68
67
  * canvasTexture.convertToBlob().then((blob) => console.log(blob));
69
68
  */
70
- toBlob(options?: {
71
- type?: string | undefined;
72
- quality?: number | undefined;
73
- } | undefined): Promise<any>;
69
+ toBlob(type?: string | undefined, quality?: number | undefined): Promise<any>;
74
70
  /**
75
71
  * creates an ImageBitmap object from the most recently rendered image of this canvas texture
76
- * @param {object} [options] - An object with the following properties:
77
- * @param {string} [options.type="image/png"] - A string indicating the image format
78
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
72
+ * @param {string} [type="image/png"] - A string indicating the image format
73
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
79
74
  * @returns {Promise} A Promise returning an ImageBitmap.
80
75
  * @example
81
76
  * canvasTexture.transferToImageBitmap().then((bitmap) => console.log(bitmap));
82
77
  */
83
- toImageBitmap(options?: {
84
- type?: string | undefined;
85
- quality?: number | undefined;
86
- } | undefined): Promise<any>;
78
+ toImageBitmap(type?: string | undefined, quality?: number | undefined): Promise<any>;
87
79
  /**
88
80
  * returns a data URL containing a representation of the most recently rendered image of this canvas texture
89
81
  * (not supported by OffscreenCanvas)
90
- * @param {object} [options] - An object with the following properties:
91
- * @param {string} [options.type="image/png"] - A string indicating the image format
92
- * @param {number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
82
+ * @param {string} [type="image/png"] - A string indicating the image format
83
+ * @param {number} [quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
93
84
  * @returns {Promise} A Promise returning a string containing the requested data URL.
94
85
  * @example
95
86
  * renderer.toDataURL().then((dataURL) => console.log(dataURL));
96
87
  */
97
- toDataURL(options?: {
98
- type?: string | undefined;
99
- quality?: number | undefined;
100
- } | undefined): Promise<any>;
88
+ toDataURL(type?: string | undefined, quality?: number | undefined): Promise<any>;
101
89
  /**
102
90
  * invalidate the current CanvasTexture, and force a reupload of the corresponding texture
103
91
  * (call this if you modify the canvas content between two draw calls)
@@ -109,14 +97,14 @@ declare class CanvasTexture {
109
97
  * @ignore
110
98
  */
111
99
  destroy(): void;
112
- public set width(arg: number);
100
+ public set width(val: number);
113
101
  /**
114
102
  * The width of this canvas texture in pixels
115
103
  * @public
116
104
  * @type {number}
117
105
  */
118
106
  public get width(): number;
119
- public set height(arg: number);
107
+ public set height(val: number);
120
108
  /**
121
109
  * The height of this canvas texture in pixels
122
110
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "15.14.0",
3
+ "version": "16.0.0",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  "author": "Olivier Biot (AltByte Pte Ltd)",
36
36
  "funding": "https://github.com/sponsors/melonjs",
37
37
  "engines": {
38
- "node": ">= 19"
38
+ "node": ">= 20"
39
39
  },
40
40
  "main": "dist/melonjs.module.js",
41
41
  "module": "dist/melonjs.module.js",
@@ -53,37 +53,38 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@teppeis/multimaps": "^3.0.0",
56
- "core-js": "^3.33.0",
56
+ "core-js": "^3.35.1",
57
57
  "earcut": "2.2.4",
58
58
  "eventemitter3": "^5.0.1",
59
- "howler": "2.2.4"
59
+ "howler": "2.2.4",
60
+ "whatwg-fetch": "^3.6.20"
60
61
  },
61
62
  "devDependencies": {
62
- "@babel/eslint-parser": "^7.22.15",
63
- "@babel/plugin-syntax-import-assertions": "^7.22.5",
64
- "@fastify/static": "^6.11.2",
63
+ "@babel/eslint-parser": "^7.23.10",
64
+ "@babel/plugin-syntax-import-assertions": "^7.23.3",
65
+ "@fastify/static": "^7.0.0",
65
66
  "@melonjs/webdoc-theme": "^1.1.1",
66
67
  "@rollup/plugin-commonjs": "^25.0.7",
67
68
  "@rollup/plugin-image": "^3.0.3",
68
69
  "@rollup/plugin-node-resolve": "^15.2.3",
69
- "@rollup/plugin-replace": "^5.0.4",
70
+ "@rollup/plugin-replace": "^5.0.5",
70
71
  "@webdoc/cli": "^2.2.0",
71
- "chromedriver": "^118.0.0",
72
+ "chromedriver": "^121.0.0",
72
73
  "cross-env": "^7.0.3",
73
74
  "del-cli": "^5.1.0",
74
- "eslint": "^8.51.0",
75
- "eslint-plugin-jsdoc": "^46.8.2",
75
+ "eslint": "^8.56.0",
76
+ "eslint-plugin-jsdoc": "^48.0.4",
76
77
  "expect": "^29.7.0",
77
- "expect-mocha-image-snapshot": "^3.0.15",
78
- "fastify": "^4.24.2",
78
+ "expect-mocha-image-snapshot": "^3.0.16",
79
+ "fastify": "^4.26.0",
79
80
  "mocha": "^10.2.0",
80
81
  "npm-self-link": "^1.1.7",
81
- "puppeteer": "^21.3.8",
82
- "rollup": "^4.1.3",
82
+ "puppeteer": "^21.10.0",
83
+ "rollup": "^4.9.6",
83
84
  "rollup-plugin-bundle-size": "^1.0.3",
84
85
  "rollup-plugin-string": "^3.0.0",
85
- "terser": "^5.21.0",
86
- "typescript": "^5.2.2"
86
+ "terser": "^5.27.0",
87
+ "typescript": "^5.3.3"
87
88
  },
88
89
  "scripts": {
89
90
  "build": "npm run lint && rollup -c --silent",
@@ -17,13 +17,15 @@ export const defaultSettings = {
17
17
  powerPreference : "default",
18
18
  verbose : false,
19
19
  consoleHeader : true,
20
- legacy : false
20
+ legacy : false,
21
+ canvas : undefined
21
22
  };
22
23
 
23
24
  /**
24
25
  * Application & Renderer Settings definition.
25
26
  * @typedef {object} Settings
26
27
  * @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
28
+ * @property {HTMLCanvasElement} [canvas] - an existing canvas element to use as the renderer target (by default melonJS will create its own canvas based on given parameters)
27
29
  * @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
28
30
  * @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
29
31
  * @property {"fit"|"fill-min"|"fill-max"|"flex"|"flex-width"|"flex-height"|"stretch"} [scaleMethod="fit"] - screen scaling modes : <br>
@@ -189,17 +189,15 @@ export default class Ellipse {
189
189
  * // do something
190
190
  * }
191
191
  */
192
- contains() {
192
+ contains(...args) {
193
193
  let _x, _y;
194
194
 
195
- if (arguments.length === 2) {
195
+ if (args.length === 2) {
196
196
  // x, y
197
- _x = arguments[0];
198
- _y = arguments[1];
197
+ [_x, _y] = args;
199
198
  } else {
200
199
  // vector
201
- _x = arguments[0].x;
202
- _y = arguments[0].y;
200
+ [_x, _y] = [args[0].x, args[0].y];
203
201
  }
204
202
 
205
203
  // Make position relative to object center point.