melonjs 14.0.1 → 14.1.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 (214) hide show
  1. package/README.md +2 -0
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
  4. package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
  5. package/dist/melonjs.mjs/_virtual/howler.js +10 -0
  6. package/dist/melonjs.mjs/_virtual/index.js +10 -0
  7. package/dist/melonjs.mjs/_virtual/index2.js +10 -0
  8. package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
  10. package/dist/melonjs.mjs/application/application.js +240 -0
  11. package/dist/melonjs.mjs/audio/audio.js +536 -0
  12. package/dist/melonjs.mjs/camera/camera2d.js +732 -0
  13. package/dist/melonjs.mjs/entity/entity.js +248 -0
  14. package/dist/melonjs.mjs/game.js +29 -0
  15. package/dist/melonjs.mjs/geometries/ellipse.js +275 -0
  16. package/dist/melonjs.mjs/geometries/line.js +116 -0
  17. package/dist/melonjs.mjs/geometries/path2d.js +319 -0
  18. package/dist/melonjs.mjs/geometries/point.js +89 -0
  19. package/dist/melonjs.mjs/geometries/poly.js +500 -0
  20. package/dist/melonjs.mjs/geometries/rectangle.js +375 -0
  21. package/dist/melonjs.mjs/geometries/roundrect.js +168 -0
  22. package/dist/melonjs.mjs/index.js +248 -0
  23. package/dist/melonjs.mjs/input/gamepad.js +501 -0
  24. package/dist/melonjs.mjs/input/input.js +26 -0
  25. package/dist/melonjs.mjs/input/keyboard.js +470 -0
  26. package/dist/melonjs.mjs/input/pointer.js +393 -0
  27. package/dist/melonjs.mjs/input/pointerevent.js +818 -0
  28. package/dist/melonjs.mjs/lang/deprecated.js +157 -0
  29. package/dist/melonjs.mjs/level/level.js +297 -0
  30. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
  31. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +448 -0
  32. package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
  33. package/dist/melonjs.mjs/level/tiled/TMXTile.js +194 -0
  34. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +639 -0
  35. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +311 -0
  36. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +83 -0
  37. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +506 -0
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +220 -0
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +157 -0
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +125 -0
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +109 -0
  43. package/dist/melonjs.mjs/loader/loader.js +801 -0
  44. package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
  45. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
  46. package/dist/melonjs.mjs/math/color.js +618 -0
  47. package/dist/melonjs.mjs/math/math.js +218 -0
  48. package/dist/melonjs.mjs/math/matrix2.js +503 -0
  49. package/dist/melonjs.mjs/math/matrix3.js +681 -0
  50. package/dist/melonjs.mjs/math/observable_vector2.js +471 -0
  51. package/dist/melonjs.mjs/math/observable_vector3.js +561 -0
  52. package/dist/melonjs.mjs/math/vector2.js +528 -0
  53. package/dist/melonjs.mjs/math/vector3.js +569 -0
  54. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
  55. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
  56. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
  57. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
  58. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
  59. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
  60. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
  61. package/dist/melonjs.mjs/particles/emitter.js +267 -0
  62. package/dist/melonjs.mjs/particles/particle.js +188 -0
  63. package/dist/melonjs.mjs/particles/settings.js +319 -0
  64. package/dist/melonjs.mjs/physics/body.js +704 -0
  65. package/dist/melonjs.mjs/physics/bounds.js +460 -0
  66. package/dist/melonjs.mjs/physics/collision.js +132 -0
  67. package/dist/melonjs.mjs/physics/detector.js +194 -0
  68. package/dist/melonjs.mjs/physics/quadtree.js +391 -0
  69. package/dist/melonjs.mjs/physics/response.js +57 -0
  70. package/dist/melonjs.mjs/physics/sat.js +483 -0
  71. package/dist/melonjs.mjs/physics/world.js +221 -0
  72. package/dist/melonjs.mjs/plugin/plugin.js +141 -0
  73. package/dist/melonjs.mjs/renderable/collectable.js +62 -0
  74. package/dist/melonjs.mjs/renderable/colorlayer.js +80 -0
  75. package/dist/melonjs.mjs/renderable/container.js +1018 -0
  76. package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
  77. package/dist/melonjs.mjs/renderable/imagelayer.js +306 -0
  78. package/dist/melonjs.mjs/renderable/light2d.js +156 -0
  79. package/dist/melonjs.mjs/renderable/nineslicesprite.js +247 -0
  80. package/dist/melonjs.mjs/renderable/renderable.js +783 -0
  81. package/dist/melonjs.mjs/renderable/sprite.js +654 -0
  82. package/dist/melonjs.mjs/renderable/trigger.js +157 -0
  83. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +213 -0
  84. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +226 -0
  85. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +128 -0
  86. package/dist/melonjs.mjs/state/stage.js +237 -0
  87. package/dist/melonjs.mjs/state/state.js +596 -0
  88. package/dist/melonjs.mjs/system/device.js +909 -0
  89. package/dist/melonjs.mjs/system/dom.js +78 -0
  90. package/dist/melonjs.mjs/system/event.js +537 -0
  91. package/dist/melonjs.mjs/system/platform.js +41 -0
  92. package/dist/melonjs.mjs/system/pooling.js +209 -0
  93. package/dist/melonjs.mjs/system/save.js +157 -0
  94. package/dist/melonjs.mjs/system/timer.js +286 -0
  95. package/dist/melonjs.mjs/text/bitmaptext.js +364 -0
  96. package/dist/melonjs.mjs/text/bitmaptextdata.js +199 -0
  97. package/dist/melonjs.mjs/text/glyph.js +66 -0
  98. package/dist/melonjs.mjs/text/text.js +453 -0
  99. package/dist/melonjs.mjs/text/textmetrics.js +176 -0
  100. package/dist/melonjs.mjs/text/textstyle.js +23 -0
  101. package/dist/melonjs.mjs/tweens/easing.js +336 -0
  102. package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
  103. package/dist/melonjs.mjs/tweens/tween.js +480 -0
  104. package/dist/melonjs.mjs/utils/agent.js +76 -0
  105. package/dist/melonjs.mjs/utils/array.js +63 -0
  106. package/dist/melonjs.mjs/utils/file.js +42 -0
  107. package/dist/melonjs.mjs/utils/function.js +70 -0
  108. package/dist/melonjs.mjs/utils/string.js +82 -0
  109. package/dist/melonjs.mjs/utils/utils.js +173 -0
  110. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +807 -0
  111. package/dist/melonjs.mjs/video/renderer.js +411 -0
  112. package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
  113. package/dist/melonjs.mjs/video/texture/cache.js +143 -0
  114. package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
  115. package/dist/melonjs.mjs/video/video.js +462 -0
  116. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +143 -0
  117. package/dist/melonjs.mjs/video/webgl/glshader.js +168 -0
  118. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
  119. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
  120. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
  121. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
  122. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
  123. package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
  124. package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
  125. package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
  126. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
  127. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +495 -0
  128. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1036 -0
  129. package/dist/melonjs.module.d.ts +1163 -1163
  130. package/dist/melonjs.module.js +1903 -3274
  131. package/package.json +22 -17
  132. package/src/application/application.js +3 -3
  133. package/src/audio/audio.js +32 -32
  134. package/src/camera/camera2d.js +31 -31
  135. package/src/entity/entity.js +17 -17
  136. package/src/geometries/ellipse.js +16 -16
  137. package/src/geometries/line.js +5 -5
  138. package/src/geometries/path2d.js +32 -32
  139. package/src/geometries/poly.js +15 -15
  140. package/src/geometries/rectangle.js +18 -18
  141. package/src/geometries/roundrect.js +8 -8
  142. package/src/input/gamepad.js +15 -15
  143. package/src/input/keyboard.js +12 -12
  144. package/src/input/pointer.js +6 -6
  145. package/src/input/pointerevent.js +12 -12
  146. package/src/lang/deprecated.js +12 -12
  147. package/src/level/level.js +25 -25
  148. package/src/level/tiled/TMXLayer.js +22 -22
  149. package/src/level/tiled/TMXTile.js +5 -5
  150. package/src/level/tiled/TMXTileMap.js +6 -6
  151. package/src/level/tiled/TMXTileset.js +2 -2
  152. package/src/level/tiled/TMXUtils.js +5 -5
  153. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  154. package/src/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
  155. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  156. package/src/level/tiled/renderer/TMXRenderer.js +19 -19
  157. package/src/loader/loader.js +20 -20
  158. package/src/math/color.js +20 -20
  159. package/src/math/math.js +16 -16
  160. package/src/math/matrix2.js +16 -16
  161. package/src/math/matrix3.js +25 -25
  162. package/src/math/observable_vector2.js +14 -14
  163. package/src/math/observable_vector3.js +16 -16
  164. package/src/math/vector2.js +9 -9
  165. package/src/math/vector3.js +10 -10
  166. package/src/particles/emitter.js +6 -6
  167. package/src/particles/particle.js +2 -2
  168. package/src/physics/body.js +28 -28
  169. package/src/physics/bounds.js +8 -8
  170. package/src/physics/collision.js +2 -2
  171. package/src/physics/detector.js +6 -6
  172. package/src/physics/quadtree.js +11 -11
  173. package/src/physics/sat.js +31 -31
  174. package/src/physics/world.js +5 -5
  175. package/src/plugin/plugin.js +5 -5
  176. package/src/renderable/collectable.js +3 -3
  177. package/src/renderable/colorlayer.js +5 -5
  178. package/src/renderable/container.js +21 -21
  179. package/src/renderable/dragndrop.js +14 -14
  180. package/src/renderable/imagelayer.js +13 -13
  181. package/src/renderable/light2d.js +3 -3
  182. package/src/renderable/nineslicesprite.js +16 -16
  183. package/src/renderable/renderable.js +23 -23
  184. package/src/renderable/sprite.js +28 -28
  185. package/src/renderable/trigger.js +15 -15
  186. package/src/renderable/ui/uibaseelement.js +7 -7
  187. package/src/renderable/ui/uispriteelement.js +6 -6
  188. package/src/renderable/ui/uitextbutton.js +13 -13
  189. package/src/state/stage.js +7 -7
  190. package/src/state/state.js +17 -17
  191. package/src/system/device.js +11 -11
  192. package/src/system/event.js +10 -10
  193. package/src/system/pooling.js +9 -9
  194. package/src/system/save.js +2 -2
  195. package/src/system/timer.js +10 -10
  196. package/src/text/bitmaptext.js +18 -18
  197. package/src/text/bitmaptextdata.js +2 -2
  198. package/src/text/text.js +23 -23
  199. package/src/text/textmetrics.js +8 -8
  200. package/src/tweens/tween.js +19 -19
  201. package/src/utils/agent.js +5 -5
  202. package/src/utils/array.js +4 -4
  203. package/src/utils/file.js +2 -2
  204. package/src/utils/function.js +6 -6
  205. package/src/utils/string.js +5 -5
  206. package/src/utils/utils.js +4 -4
  207. package/src/video/canvas/canvas_renderer.js +70 -70
  208. package/src/video/renderer.js +26 -26
  209. package/src/video/texture/atlas.js +22 -22
  210. package/src/video/texture/canvas_texture.js +9 -9
  211. package/src/video/video.js +17 -17
  212. package/src/video/webgl/glshader.js +10 -10
  213. package/src/video/webgl/webgl_compositor.js +41 -41
  214. package/src/video/webgl/webgl_renderer.js +75 -75
@@ -0,0 +1,70 @@
1
+ /*!
2
+ * melonJS Game Engine - v14.1.0
3
+ * http://www.melonjs.org
4
+ * melonjs is licensed under the MIT License.
5
+ * http://www.opensource.org/licenses/mit-license
6
+ * @copyright (C) 2011 - 2022 Olivier Biot (AltByte Pte Ltd)
7
+ */
8
+ /**
9
+ * a collection of utility functions
10
+ * @namespace utils.function
11
+ */
12
+
13
+ /**
14
+ * Executes a function as soon as the interpreter is idle (stack empty).
15
+ * @public
16
+ * @memberof utils.function
17
+ * @name defer
18
+ * @param {Function} func - The function to be deferred.
19
+ * @param {object} thisArg - The value to be passed as the this parameter to the target function when the deferred function is called
20
+ * @param {...*} args - Optional additional arguments to carry for the function.
21
+ * @returns {number} id that can be used to clear the deferred function using
22
+ * clearTimeout
23
+ * @example
24
+ * // execute myFunc() when the stack is empty,
25
+ * // with the current context and [1, 2, 3] as parameter
26
+ * me.utils.function.defer(myFunc, this, 1, 2, 3);
27
+ */
28
+ function defer(func, thisArg, ...args) {
29
+ return setTimeout(func.bind(thisArg), 0.01, ...args);
30
+ }
31
+
32
+ /**
33
+ * returns a function that, when invoked will only be triggered at most
34
+ * once during a given window of time
35
+ * @public
36
+ * @memberof utils.function
37
+ * @name throttle
38
+ * @param {Function} fn - the function to be throttled.
39
+ * @param {number} delay - The delay in ms
40
+ * @param {no_trailing} no_trailing - disable the execution on the trailing edge
41
+ * @returns {Function} the function that will be throttled
42
+ */
43
+ function throttle(fn, delay, no_trailing) {
44
+ var last = globalThis.performance.now(), deferTimer;
45
+ // `no_trailing` defaults to false.
46
+ if (typeof no_trailing !== "boolean") {
47
+ no_trailing = false;
48
+ }
49
+ return function () {
50
+ var now = globalThis.performance.now();
51
+ var elasped = now - last;
52
+ var args = arguments;
53
+ if (elasped < delay) {
54
+ if (no_trailing === false) {
55
+ // hold on to it
56
+ clearTimeout(deferTimer);
57
+ deferTimer = setTimeout(() => {
58
+ last = now;
59
+ return fn.apply(null, args);
60
+ }, elasped);
61
+ }
62
+ }
63
+ else {
64
+ last = now;
65
+ return fn.apply(null, args);
66
+ }
67
+ };
68
+ }
69
+
70
+ export { defer, throttle };
@@ -0,0 +1,82 @@
1
+ /*!
2
+ * melonJS Game Engine - v14.1.0
3
+ * http://www.melonjs.org
4
+ * melonjs is licensed under the MIT License.
5
+ * http://www.opensource.org/licenses/mit-license
6
+ * @copyright (C) 2011 - 2022 Olivier Biot (AltByte Pte Ltd)
7
+ */
8
+ /**
9
+ * a collection of string utility functions
10
+ * @namespace utils.string
11
+ */
12
+
13
+ /**
14
+ * converts the first character of the given string to uppercase
15
+ * @public
16
+ * @memberof utils.string
17
+ * @name capitalize
18
+ * @param {string} str - the string to be capitalized
19
+ * @returns {string} the capitalized string
20
+ */
21
+ function capitalize(str) {
22
+ return str.charAt(0).toUpperCase() + str.slice(1);
23
+ }
24
+
25
+ /**
26
+ * returns true if the given string contains a numeric integer or float value
27
+ * @public
28
+ * @memberof utils.string
29
+ * @name isNumeric
30
+ * @param {string} str - the string to be tested
31
+ * @returns {boolean} true if string contains only digits
32
+ */
33
+ function isNumeric(str) {
34
+ if (typeof str === "string") {
35
+ str = str.trim();
36
+ }
37
+ return !isNaN(str) && /[+-]?([0-9]*[.])?[0-9]+/.test(str);
38
+ }
39
+
40
+ /**
41
+ * returns true if the given string contains a true or false
42
+ * @public
43
+ * @memberof utils.string
44
+ * @name isBoolean
45
+ * @param {string} str - the string to be tested
46
+ * @returns {boolean} true if the string is either true or false
47
+ */
48
+ function isBoolean(str) {
49
+ var trimmed = str.trim();
50
+ return (trimmed === "true") || (trimmed === "false");
51
+ }
52
+
53
+ /**
54
+ * convert a string to the corresponding hexadecimal value
55
+ * @public
56
+ * @memberof utils.string
57
+ * @name toHex
58
+ * @param {string} str - the string to be converted
59
+ * @returns {string} the converted hexadecimal value
60
+ */
61
+ function toHex(str) {
62
+ var res = "", c = 0;
63
+ while (c < str.length) {
64
+ res += str.charCodeAt(c++).toString(16);
65
+ }
66
+ return res;
67
+ }
68
+
69
+ /**
70
+ * returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
71
+ * (this will not test the validity of the Data or Base64 encoding)
72
+ * @public
73
+ * @memberof utils.string
74
+ * @name isDataUrl
75
+ * @param {string} str - the string (url) to be tested
76
+ * @returns {boolean} true if the string is a data url
77
+ */
78
+ function isDataUrl(str) {
79
+ return /^data:(.+);base64,(.+)$/.test(str);
80
+ }
81
+
82
+ export { capitalize, isBoolean, isDataUrl, isNumeric, toHex };
@@ -0,0 +1,173 @@
1
+ /*!
2
+ * melonJS Game Engine - v14.1.0
3
+ * http://www.melonjs.org
4
+ * melonjs is licensed under the MIT License.
5
+ * http://www.opensource.org/licenses/mit-license
6
+ * @copyright (C) 2011 - 2022 Olivier Biot (AltByte Pte Ltd)
7
+ */
8
+ import * as agent from './agent.js';
9
+ import * as array from './array.js';
10
+ import * as file from './file.js';
11
+ import * as string from './string.js';
12
+ import { toHex } from './string.js';
13
+ import * as _function from './function.js';
14
+ import { createCanvas } from '../video/video.js';
15
+ import CanvasRenderer from '../video/canvas/canvas_renderer.js';
16
+ import { version } from '../index.js';
17
+
18
+ /**
19
+ * a collection of utility functions
20
+ * @namespace utils
21
+ */
22
+
23
+ // guid default value
24
+ var GUID_base = "";
25
+ var GUID_index = 0;
26
+
27
+ var utils = {
28
+
29
+ agent : agent,
30
+ array : array,
31
+ file : file,
32
+ string : string,
33
+ function : _function,
34
+
35
+ /**
36
+ * Get image pixels
37
+ * @public
38
+ * @memberof utils
39
+ * @name getPixels
40
+ * @param {HTMLImageElement|HTMLCanvasElement} image - Image to read
41
+ * @returns {ImageData} ImageData object
42
+ */
43
+ getPixels : function (image) {
44
+ if (image instanceof HTMLImageElement) {
45
+ var _context = CanvasRenderer.getContext2d(
46
+ createCanvas(image.width, image.height)
47
+ );
48
+ _context.drawImage(image, 0, 0);
49
+ return _context.getImageData(0, 0, image.width, image.height);
50
+ }
51
+ else {
52
+ // canvas !
53
+ return image.getContext("2d").getImageData(0, 0, image.width, image.height);
54
+ }
55
+ },
56
+
57
+ /**
58
+ * Compare two version strings
59
+ * @public
60
+ * @memberof utils
61
+ * @name checkVersion
62
+ * @param {string} first - First version string to compare
63
+ * @param {string} [second=version] - Second version string to compare
64
+ * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
65
+ * 0 : first == second<br>
66
+ * &gt; 0 : first &gt; second
67
+ * @example
68
+ * if (me.utils.checkVersion("7.0.0") > 0) {
69
+ * console.error(
70
+ * "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
71
+ * );
72
+ * }
73
+ */
74
+ checkVersion : function (first, second = version) {
75
+ var a = first.split(".");
76
+ var b = second.split(".");
77
+ var len = Math.min(a.length, b.length);
78
+ var result = 0;
79
+
80
+ for (var i = 0; i < len; i++) {
81
+ if ((result = +a[i] - +b[i])) {
82
+ break;
83
+ }
84
+ }
85
+
86
+ return result ? result : a.length - b.length;
87
+ },
88
+
89
+ /**
90
+ * parse the fragment (hash) from a URL and returns them into
91
+ * @public
92
+ * @memberof utils
93
+ * @name getUriFragment
94
+ * @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
95
+ * @returns {object} an object representing the deserialized params string.
96
+ * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
97
+ * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
98
+ * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
99
+ * @property {boolean} [webgl=false] force the renderer to WebGL
100
+ * @property {boolean} [debug=false] display the debug panel (if preloaded)
101
+ * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
102
+ * @example
103
+ * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
104
+ * var UriFragment = me.utils.getUriFragment();
105
+ * console.log(UriFragment["mytag"]); //> "value"
106
+ */
107
+ getUriFragment : function (url) {
108
+ var hash = {};
109
+
110
+ if (typeof url === "undefined") {
111
+ if (typeof globalThis.document !== "undefined") {
112
+ var location = globalThis.document.location;
113
+
114
+ if (location && location.hash) {
115
+ url = location.hash;
116
+ } else {
117
+ // No "document.location" exist for Wechat mini game platform.
118
+ return hash;
119
+ }
120
+ } else {
121
+ // "document" undefined on node.js
122
+ return hash;
123
+ }
124
+ } else {
125
+ // never cache if a url is passed as parameter
126
+ var index = url.indexOf("#");
127
+ if (index !== -1) {
128
+ url = url.slice(index, url.length);
129
+ } else {
130
+ return hash;
131
+ }
132
+ }
133
+
134
+ // parse the url
135
+ url.slice(1).split("&").filter((value) => {
136
+ return (value !== "");
137
+ }).forEach((value) => {
138
+ var kv = value.split("=");
139
+ var k = kv.shift();
140
+ var v = kv.join("=");
141
+ hash[k] = v || true;
142
+ });
143
+
144
+ return hash;
145
+ },
146
+
147
+ /**
148
+ * reset the GUID Base Name
149
+ * the idea here being to have a unique ID
150
+ * per level / object
151
+ * @ignore
152
+ */
153
+ resetGUID : function (base, index = 0) {
154
+ // also ensure it's only 8bit ASCII characters
155
+ GUID_base = toHex(base.toString().toUpperCase());
156
+ GUID_index = index;
157
+ },
158
+
159
+ /**
160
+ * create and return a very simple GUID
161
+ * Game Unique ID
162
+ * @ignore
163
+ */
164
+ createGUID : function (index = 1) {
165
+ // to cover the case of undefined id for groups
166
+ GUID_index += index;
167
+ return GUID_base + "-" + (index || GUID_index);
168
+ }
169
+ };
170
+
171
+ var utils$1 = utils;
172
+
173
+ export { utils$1 as default };