gdcore-tools 2.0.0-beta6 → 2.0.0-beta8

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 (139) hide show
  1. package/dist/Runtime/Cordova/config.xml +4 -0
  2. package/dist/Runtime/Cordova/package.json +12 -20
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
  10. package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  12. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  13. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  14. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
  16. package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
  17. package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
  18. package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
  19. package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
  20. package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
  21. package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
  22. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  23. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  24. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
  25. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  26. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  27. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  28. package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
  29. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  30. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  31. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
  32. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  33. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
  35. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
  37. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
  39. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
  41. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
  43. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
  45. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
  46. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
  47. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
  48. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
  49. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  50. package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
  51. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
  52. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  53. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +15 -0
  54. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  55. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  56. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  57. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  58. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  59. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
  60. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  61. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  62. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  63. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +76 -24
  64. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  65. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  66. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  67. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  68. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  69. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  70. package/dist/Runtime/Extensions/Spine/JsExtension.js +45 -36
  71. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TextInput/JsExtension.js +52 -55
  74. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  75. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  76. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  77. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  78. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
  79. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  80. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  81. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  82. package/dist/Runtime/Extensions/TileMap/JsExtension.js +430 -261
  83. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
  84. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  85. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
  86. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  87. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  88. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  89. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
  90. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
  91. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
  92. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  93. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  94. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  95. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  96. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  97. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  98. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  99. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  100. package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
  101. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  102. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  103. package/dist/Runtime/ResourceLoader.js +1 -1
  104. package/dist/Runtime/ResourceLoader.js.map +2 -2
  105. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  106. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  107. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  108. package/dist/Runtime/events-tools/inputtools.js +1 -1
  109. package/dist/Runtime/events-tools/inputtools.js.map +2 -2
  110. package/dist/Runtime/events-tools/objecttools.js +1 -1
  111. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  112. package/dist/Runtime/gd.js +1 -1
  113. package/dist/Runtime/gd.js.map +2 -2
  114. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  115. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  116. package/dist/Runtime/inputmanager.js +1 -1
  117. package/dist/Runtime/inputmanager.js.map +2 -2
  118. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  119. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  120. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
  121. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  122. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  123. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
  125. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  126. package/dist/Runtime/runtimegame.js +1 -1
  127. package/dist/Runtime/runtimegame.js.map +1 -1
  128. package/dist/Runtime/runtimeobject.js +1 -1
  129. package/dist/Runtime/runtimeobject.js.map +2 -2
  130. package/dist/Runtime/spriteruntimeobject.js +1 -1
  131. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  132. package/dist/Runtime/types/project-data.d.ts +5 -0
  133. package/dist/lib/libGD.cjs +1 -1
  134. package/dist/lib/libGD.d.cts +5 -0
  135. package/dist/lib/libGD.wasm +0 -0
  136. package/dist/loaders.cjs +3 -1
  137. package/dist/loaders.d.cts +2 -0
  138. package/gd.d.ts +74 -30
  139. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/events-tools/objecttools.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n export namespace evtTools {\n export namespace object {\n /**\n * Keep only the specified object in the lists of picked objects.\n *\n * @param objectsLists The lists of objects to trim\n * @param runtimeObject The object to keep in the lists\n */\n export const pickOnly = function (\n objectsLists: ObjectsLists,\n runtimeObject: gdjs.RuntimeObject\n ) {\n for (const listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n const list = objectsLists.items[listName];\n\n //Be sure not to lose the reference to the original array\n if (list.indexOf(runtimeObject) === -1) {\n list.length = 0;\n } else {\n list.length = 0;\n\n //Be sure not to lose the reference to the original array\n list.push(runtimeObject);\n }\n }\n }\n };\n\n /**\n * Do a test on two tables of objects so as to pick only the pair of objects for which the test is true.\n *\n * Note that the predicate method is not called strictly for each pair: When considering a pair of objects, if\n * these objects have already been marked as picked, the predicate method won't be called again.\n *\n * Cost (Worst case, predicate being always false):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*NbObjList1*NbObjList2\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n * + Cost(Removing NbObjList1+NbObjList2 objects from all the lists)\n *\n * Cost (Best case, predicate being always true):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*(NbObjList1+NbObjList2)\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n *\n *\n * @param predicate The predicate function is called with the two objects to compare, and an optional argument `extraArg`\n * @param objectsLists1 The first lists of objects\n * @param objectsLists2 The second lists of objects\n * @param inverted If `inverted` == true, only the objects of the first table are filtered.\n * @param extraArg (optional) This argument should be used to avoid declaring the predicate as a closure that would be created and destroyed at each call to twoListsTest (potentially multiple time per frame).\n */\n export const twoListsTest = function (\n predicate: (\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n extraArg: any\n ) => boolean,\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n extraArg: any\n ) {\n let isTrue = false;\n const objects1Lists = gdjs.staticArray(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists1.values(objects1Lists);\n const objects2Lists = gdjs.staticArray2(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists2.values(objects2Lists);\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n\n //Launch the function for each object of the first list with each object\n //of the second list.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n const arr1 = objects1Lists[i];\n for (let k = 0, lenk = arr1.length; k < lenk; ++k) {\n let atLeastOneObject = false;\n for (let j = 0, lenj = objects2Lists.length; j < lenj; ++j) {\n const arr2 = objects2Lists[j];\n for (let l = 0, lenl = arr2.length; l < lenl; ++l) {\n if (arr1[k].pick && arr2[l].pick) {\n continue;\n }\n\n //Avoid unnecessary costly call to predicate.\n if (\n arr1[k].id !== arr2[l].id &&\n predicate(arr1[k], arr2[l], extraArg)\n ) {\n if (!inverted) {\n isTrue = true;\n\n //Pick the objects\n arr1[k].pick = true;\n arr2[l].pick = true;\n }\n atLeastOneObject = true;\n }\n }\n }\n if (!atLeastOneObject && inverted) {\n //For example, the object is not overlapping any other object.\n isTrue = true;\n arr1[k].pick = true;\n }\n }\n }\n\n //Trim not picked objects from lists.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n if (!inverted) {\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n }\n return isTrue;\n };\n\n /**\n * Filter objects to keep only the one that fullfil the predicate\n *\n * Objects that do not fullfil the predicate are removed from objects lists.\n *\n * @param predicate The function applied to each object: must return true if the object fulfill the predicate.\n * @param objectsLists The lists of objects to trim\n * @param negatePredicate If set to true, the result of the predicate is negated.\n * @param extraArg Argument passed to the predicate (along with the object). Useful for avoiding relying on temporary closures.\n * @return true if at least one object fulfill the predicate.\n */\n export const pickObjectsIf = function (\n predicate: Function,\n objectsLists: ObjectsLists,\n negatePredicate: boolean,\n extraArg: any\n ): boolean {\n let isTrue = false;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickObjectsIf);\n objectsLists.values(lists);\n\n // Pick only objects that are fulfilling the predicate.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n const arr = lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const object = arr[k];\n // @ts-ignore\n if (negatePredicate ^ predicate(object, extraArg)) {\n isTrue = true;\n object.pick = true;\n } else {\n object.pick = false;\n }\n }\n }\n\n // Trim not picked objects from lists.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n gdjs.evtTools.object.filterPickedObjectsList(lists[i]);\n }\n return isTrue;\n };\n\n /**\n * Filter in-place the specified array to remove objects for which\n * `pick` property is set to false.\n */\n export const filterPickedObjectsList = function (\n arr: gdjs.RuntimeObject[]\n ) {\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const obj = arr[k];\n if (obj.pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n };\n\n export const hitBoxesCollisionTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n instanceContainer: gdjs.RuntimeInstanceContainer,\n ignoreTouchingEdges: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.RuntimeObject.collisionTest,\n objectsLists1,\n objectsLists2,\n inverted,\n ignoreTouchingEdges\n );\n };\n\n export const _distanceBetweenObjects = function (obj1, obj2, distance) {\n return obj1.getSqDistanceToObject(obj2) <= distance;\n };\n\n export const distanceTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n distance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._distanceBetweenObjects,\n objectsLists1,\n objectsLists2,\n inverted,\n distance * distance\n );\n };\n\n export const _movesToward = function (obj1, obj2, tolerance) {\n if (obj1.hasNoForces()) {\n return false;\n }\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAverageForce().getAngle(),\n objAngle\n )\n ) <=\n tolerance / 2\n );\n };\n\n export const movesTowardTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._movesToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const _turnedToward = function (obj1, obj2, tolerance) {\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(obj1.getAngle(), objAngle)\n ) <=\n tolerance / 2\n );\n };\n\n export const turnedTowardTest = function (\n objectsLists1,\n objectsLists2,\n tolerance,\n inverted\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._turnedToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const pickAllObjects = function (objectsContext, objectsLists) {\n for (const name in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(name)) {\n const allObjects = objectsContext.getObjects(name);\n const objectsList = objectsLists.items[name];\n objectsList.length = 0;\n objectsList.push.apply(objectsList, allObjects);\n }\n }\n return true;\n };\n\n export const pickRandomObject = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectsLists: ObjectsLists\n ) {\n // Compute one many objects we have\n let objectsCount = 0;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n objectsCount += list.length;\n }\n }\n if (objectsCount === 0) {\n return false;\n }\n\n // Pick one random object\n let index = Math.floor(Math.random() * objectsCount);\n if (index >= objectsCount) {\n index = objectsCount - 1;\n }\n\n //Should never happen.\n\n // Find the object\n let startIndex = 0;\n let theChosenOne: gdjs.RuntimeObject | null = null;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n if (index - startIndex < list.length) {\n theChosenOne = list[index - startIndex];\n break;\n }\n startIndex += list.length;\n }\n }\n // @ts-ignore\n gdjs.evtTools.object.pickOnly(objectsLists, theChosenOne);\n return true;\n };\n\n export const pickNearestObject = function (objectsLists, x, y, inverted) {\n let bestObject = null;\n let best = 0;\n let first = true;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickNearestObject);\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n const list = lists[i];\n for (let j = 0; j < list.length; ++j) {\n const object = list[j];\n const distance = object.getSqDistanceToPosition(x, y);\n // @ts-ignore\n if (first || (distance < best) ^ inverted) {\n best = distance;\n bestObject = object;\n }\n first = false;\n }\n }\n if (!bestObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, bestObject);\n return true;\n };\n\n export const raycastObject = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n angle: float,\n dist: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.raycastObjectToPosition(\n objectsLists,\n x,\n y,\n x + dist * Math.cos((angle * Math.PI) / 180.0),\n y + dist * Math.sin((angle * Math.PI) / 180.0),\n varX,\n varY,\n inverted\n );\n };\n\n export const raycastObjectToPosition = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n endX: float,\n endY: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n let matchObject: gdjs.RuntimeObject | null = null;\n let testSqDist = inverted\n ? 0\n : (endX - x) * (endX - x) + (endY - y) * (endY - y);\n let resultX = 0;\n let resultY = 0;\n const lists: RuntimeObject[][] = gdjs.staticArray(\n gdjs.evtTools.object.raycastObjectToPosition\n );\n objectsLists.values(lists);\n for (let i = 0; i < lists.length; i++) {\n const list = lists[i];\n for (let j = 0; j < list.length; j++) {\n const object = list[j];\n const result = object.raycastTest(x, y, endX, endY, !inverted);\n if (result.collision) {\n if (!inverted && result.closeSqDist <= testSqDist) {\n testSqDist = result.closeSqDist;\n matchObject = object;\n resultX = result.closeX;\n resultY = result.closeY;\n } else {\n if (inverted && result.farSqDist >= testSqDist) {\n testSqDist = result.farSqDist;\n matchObject = object;\n resultX = result.farX;\n resultY = result.farY;\n }\n }\n }\n }\n }\n if (!matchObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, matchObject);\n varX.setNumber(resultX);\n varY.setNumber(resultY);\n return true;\n };\n\n /**\n * Do the work of creating a new object\n */\n export const doCreateObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectName: string,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n // objectsContext will either be the gdjs.RuntimeScene or, in an events function, the\n // eventsFunctionContext. We can't directly use runtimeScene because the object name could\n // be different than the real object name (this is the case in a function. The eventsFunctionContext\n // will take care of this in createObject).\n const obj = objectsContext.createObject(objectName);\n const layer = objectsContext.getLayer(layerName);\n if (obj !== null) {\n //Do some extra setup\n obj.setPosition(x, y);\n obj.setLayer(layerName);\n obj.setZOrder(layer.getDefaultZOrder());\n\n //Let the new object be picked by next actions/conditions.\n if (objectsLists.containsKey(objectName)) {\n objectsLists.get(objectName).push(obj);\n }\n }\n return obj;\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n return gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectsLists.firstKey() as string,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectFromGroupOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n objectName: string,\n x: float,\n y: float,\n layerName: string\n ) {\n gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectName,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Return the number of instances in the specified lists of objects.\n */\n export const getPickedInstancesCount = (objectsLists: ObjectsLists) => {\n let count = 0;\n const lists = gdjs.staticArray(\n gdjs.evtTools.object.getPickedInstancesCount\n );\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n count += lists[i].length;\n }\n return count;\n };\n\n /**\n * Return the number of instances of the specified objects living on the scene.\n */\n export const getSceneInstancesCount = (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists\n ) => {\n let count = 0;\n\n const objectNames = gdjs.staticArray(\n gdjs.evtTools.object.getSceneInstancesCount\n );\n objectsLists.keys(objectNames);\n\n const uniqueObjectNames = new Set(objectNames);\n for (const objectName of uniqueObjectNames) {\n count += objectsContext.getInstancesCountOnScene(objectName);\n }\n return count;\n };\n\n /** @deprecated */\n export const pickedObjectsCount = getPickedInstancesCount;\n }\n }\n\n /**\n * A container for objects lists that should last more than the current frame.\n * It automatically removes objects that were destroyed from the objects lists.\n */\n export class LongLivedObjectsList {\n private objectsLists = new Map<string, Array<RuntimeObject>>();\n private localVariablesContainers: Array<gdjs.VariablesContainer> = [];\n private callbacks = new Map<RuntimeObject, () => void>();\n private parent: LongLivedObjectsList | null = null;\n\n /**\n * Create a new container for objects lists, inheriting from another one. This is\n * useful should we get the objects that have not been saved in this context (using\n * `addObject`) but saved in a parent context.\n * This avoids to save all object lists every time we create a new `LongLivedObjectsList`,\n * despite not all objects lists being used.\n *\n * @param parent\n * @returns\n */\n static from(parent: LongLivedObjectsList): LongLivedObjectsList {\n const newList = new LongLivedObjectsList();\n newList.parent = parent;\n return newList;\n }\n\n private getOrCreateList(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName))\n this.objectsLists.set(objectName, []);\n return this.objectsLists.get(objectName)!;\n }\n\n getObjects(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName) && this.parent)\n return this.parent.getObjects(objectName);\n return this.objectsLists.get(objectName) || [];\n }\n\n addObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n if (list.includes(runtimeObject)) return;\n list.push(runtimeObject);\n\n // Register callbacks for when the object is destroyed\n const onDestroy = () => this.removeObject(objectName, runtimeObject);\n this.callbacks.set(runtimeObject, onDestroy);\n runtimeObject.registerDestroyCallback(onDestroy);\n }\n\n removeObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n const index = list.indexOf(runtimeObject);\n if (index === -1) return;\n list.splice(index, 1);\n\n // Properly remove callbacks to not leak the object\n runtimeObject.unregisterDestroyCallback(\n this.callbacks.get(runtimeObject)!\n );\n this.callbacks.delete(runtimeObject);\n }\n\n restoreLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(this.localVariablesContainers, variablesContainers);\n }\n\n backupLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(variablesContainers, this.localVariablesContainers);\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CAOE,AAAM,WAAW,SACtB,EACA,EACA,CACA,SAAW,KAAY,GAAa,MAClC,GAAI,EAAa,MAAM,eAAe,GAAW,CAC/C,KAAM,GAAO,EAAa,MAAM,GAGhC,AAAI,EAAK,QAAQ,KAAmB,GAClC,EAAK,OAAS,EAEd,GAAK,OAAS,EAGd,EAAK,KAAK,MA8BL,eAAe,SAC1B,EAKA,EACA,EACA,EACA,EACA,CACA,GAAI,GAAS,GACb,K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EtC,EAAM,yBAhlBL",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n export namespace evtTools {\n export namespace object {\n /**\n * Keep only the specified object in the lists of picked objects.\n *\n * @param objectsLists The lists of objects to trim\n * @param runtimeObject The object to keep in the lists\n */\n export const pickOnly = function (\n objectsLists: ObjectsLists,\n runtimeObject: gdjs.RuntimeObject\n ) {\n for (const listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n const list = objectsLists.items[listName];\n\n //Be sure not to lose the reference to the original array\n if (list.indexOf(runtimeObject) === -1) {\n list.length = 0;\n } else {\n list.length = 0;\n\n //Be sure not to lose the reference to the original array\n list.push(runtimeObject);\n }\n }\n }\n };\n\n /**\n * Do a test on two tables of objects so as to pick only the pair of objects for which the test is true.\n *\n * Note that the predicate method is not called strictly for each pair: When considering a pair of objects, if\n * these objects have already been marked as picked, the predicate method won't be called again.\n *\n * Cost (Worst case, predicate being always false):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*NbObjList1*NbObjList2\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n * + Cost(Removing NbObjList1+NbObjList2 objects from all the lists)\n *\n * Cost (Best case, predicate being always true):\n * Cost(Setting property 'picked' of NbObjList1+NbObjList2 objects to false)\n * + Cost(predicate)*(NbObjList1+NbObjList2)\n * + Cost(Testing NbObjList1+NbObjList2 booleans)\n *\n *\n * @param predicate The predicate function is called with the two objects to compare, and an optional argument `extraArg`\n * @param objectsLists1 The first lists of objects\n * @param objectsLists2 The second lists of objects\n * @param inverted If `inverted` == true, only the objects of the first table are filtered.\n * @param extraArg (optional) This argument should be used to avoid declaring the predicate as a closure that would be created and destroyed at each call to twoListsTest (potentially multiple time per frame).\n */\n export const twoListsTest = function (\n predicate: (\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n extraArg: any\n ) => boolean,\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n extraArg: any\n ) {\n let isTrue = false;\n const objects1Lists = gdjs.staticArray(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists1.values(objects1Lists);\n const objects2Lists = gdjs.staticArray2(\n gdjs.evtTools.object.twoListsTest\n );\n objectsLists2.values(objects2Lists);\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n arr[k].pick = false;\n }\n }\n\n //Launch the function for each object of the first list with each object\n //of the second list.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n const arr1 = objects1Lists[i];\n for (let k = 0, lenk = arr1.length; k < lenk; ++k) {\n let atLeastOneObject = false;\n for (let j = 0, lenj = objects2Lists.length; j < lenj; ++j) {\n const arr2 = objects2Lists[j];\n for (let l = 0, lenl = arr2.length; l < lenl; ++l) {\n if (arr1[k].pick && arr2[l].pick) {\n continue;\n }\n\n //Avoid unnecessary costly call to predicate.\n if (\n arr1[k].id !== arr2[l].id &&\n predicate(arr1[k], arr2[l], extraArg)\n ) {\n if (!inverted) {\n isTrue = true;\n\n //Pick the objects\n arr1[k].pick = true;\n arr2[l].pick = true;\n }\n atLeastOneObject = true;\n }\n }\n }\n if (!atLeastOneObject && inverted) {\n //For example, the object is not overlapping any other object.\n isTrue = true;\n arr1[k].pick = true;\n }\n }\n }\n\n //Trim not picked objects from lists.\n for (let i = 0, leni = objects1Lists.length; i < leni; ++i) {\n let arr = objects1Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n if (!inverted) {\n for (let i = 0, leni = objects2Lists.length; i < leni; ++i) {\n let arr = objects2Lists[i];\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n let obj = arr[k];\n if (arr[k].pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n }\n }\n return isTrue;\n };\n\n /**\n * Filter objects to keep only the one that fullfil the predicate\n *\n * Objects that do not fullfil the predicate are removed from objects lists.\n *\n * @param predicate The function applied to each object: must return true if the object fulfill the predicate.\n * @param objectsLists The lists of objects to trim\n * @param negatePredicate If set to true, the result of the predicate is negated.\n * @param extraArg Argument passed to the predicate (along with the object). Useful for avoiding relying on temporary closures.\n * @return true if at least one object fulfill the predicate.\n */\n export const pickObjectsIf = function (\n predicate: Function,\n objectsLists: ObjectsLists,\n negatePredicate: boolean,\n extraArg: any\n ): boolean {\n let isTrue = false;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickObjectsIf);\n objectsLists.values(lists);\n\n // Pick only objects that are fulfilling the predicate.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n const arr = lists[i];\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const object = arr[k];\n // @ts-ignore\n if (negatePredicate ^ predicate(object, extraArg)) {\n isTrue = true;\n object.pick = true;\n } else {\n object.pick = false;\n }\n }\n }\n\n // Trim not picked objects from lists.\n for (let i = 0, leni = lists.length; i < leni; ++i) {\n gdjs.evtTools.object.filterPickedObjectsList(lists[i]);\n }\n return isTrue;\n };\n\n /**\n * Filter in-place the specified array to remove objects for which\n * `pick` property is set to false.\n */\n export const filterPickedObjectsList = function (\n arr: gdjs.RuntimeObject[]\n ) {\n let finalSize = 0;\n for (let k = 0, lenk = arr.length; k < lenk; ++k) {\n const obj = arr[k];\n if (obj.pick) {\n arr[finalSize] = obj;\n finalSize++;\n }\n }\n arr.length = finalSize;\n };\n\n export const hitBoxesCollisionTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n inverted: boolean,\n instanceContainer: gdjs.RuntimeInstanceContainer,\n ignoreTouchingEdges: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.RuntimeObject.collisionTest,\n objectsLists1,\n objectsLists2,\n inverted,\n ignoreTouchingEdges\n );\n };\n\n export const _distanceBetweenObjects = function (obj1, obj2, distance) {\n return obj1.getSqDistanceToObject(obj2) <= distance;\n };\n\n export const distanceTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n distance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._distanceBetweenObjects,\n objectsLists1,\n objectsLists2,\n inverted,\n distance * distance\n );\n };\n\n export const _movesToward = function (obj1, obj2, tolerance) {\n if (obj1.hasNoForces()) {\n return false;\n }\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAverageForce().getAngle(),\n objAngle\n )\n ) <=\n tolerance / 2\n );\n };\n\n export const movesTowardTest = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._movesToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n // Deprecated\n export const _turnedToward = function (obj1, obj2, tolerance) {\n let objAngle = Math.atan2(\n obj2.getDrawableY() +\n obj2.getCenterY() -\n (obj1.getDrawableY() + obj1.getCenterY()),\n obj2.getDrawableX() +\n obj2.getCenterX() -\n (obj1.getDrawableX() + obj1.getCenterX())\n );\n objAngle *= 180 / 3.14159;\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(obj1.getAngle(), objAngle)\n ) <=\n tolerance / 2\n );\n };\n\n // Deprecated\n export const turnedTowardTest = function (\n objectsLists1,\n objectsLists2,\n tolerance,\n inverted\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._turnedToward,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const _isTurnedTowardObject = function (\n obj1: gdjs.RuntimeObject,\n obj2: gdjs.RuntimeObject,\n tolerance: float\n ) {\n return (\n Math.abs(\n gdjs.evtTools.common.angleDifference(\n obj1.getAngle(),\n obj1.getAngleToObject(obj2)\n )\n ) <= tolerance\n );\n };\n\n export const isTurnedTowardObject = function (\n objectsLists1: ObjectsLists,\n objectsLists2: ObjectsLists,\n tolerance: float,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.twoListsTest(\n gdjs.evtTools.object._isTurnedTowardObject,\n objectsLists1,\n objectsLists2,\n inverted,\n tolerance\n );\n };\n\n export const pickAllObjects = function (objectsContext, objectsLists) {\n for (const name in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(name)) {\n const allObjects = objectsContext.getObjects(name);\n const objectsList = objectsLists.items[name];\n objectsList.length = 0;\n objectsList.push.apply(objectsList, allObjects);\n }\n }\n return true;\n };\n\n export const pickRandomObject = function (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n objectsLists: ObjectsLists\n ) {\n // Compute one many objects we have\n let objectsCount = 0;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n objectsCount += list.length;\n }\n }\n if (objectsCount === 0) {\n return false;\n }\n\n // Pick one random object\n let index = Math.floor(Math.random() * objectsCount);\n if (index >= objectsCount) {\n index = objectsCount - 1;\n }\n\n //Should never happen.\n\n // Find the object\n let startIndex = 0;\n let theChosenOne: gdjs.RuntimeObject | null = null;\n for (let listName in objectsLists.items) {\n if (objectsLists.items.hasOwnProperty(listName)) {\n let list = objectsLists.items[listName];\n if (index - startIndex < list.length) {\n theChosenOne = list[index - startIndex];\n break;\n }\n startIndex += list.length;\n }\n }\n // @ts-ignore\n gdjs.evtTools.object.pickOnly(objectsLists, theChosenOne);\n return true;\n };\n\n export const pickNearestObject = function (objectsLists, x, y, inverted) {\n let bestObject = null;\n let best = 0;\n let first = true;\n const lists = gdjs.staticArray(gdjs.evtTools.object.pickNearestObject);\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n const list = lists[i];\n for (let j = 0; j < list.length; ++j) {\n const object = list[j];\n const distance = object.getSqDistanceToPosition(x, y);\n // @ts-ignore\n if (first || (distance < best) ^ inverted) {\n best = distance;\n bestObject = object;\n }\n first = false;\n }\n }\n if (!bestObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, bestObject);\n return true;\n };\n\n export const raycastObject = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n angle: float,\n dist: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n return gdjs.evtTools.object.raycastObjectToPosition(\n objectsLists,\n x,\n y,\n x + dist * Math.cos((angle * Math.PI) / 180.0),\n y + dist * Math.sin((angle * Math.PI) / 180.0),\n varX,\n varY,\n inverted\n );\n };\n\n export const raycastObjectToPosition = function (\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n endX: float,\n endY: float,\n varX: gdjs.Variable,\n varY: gdjs.Variable,\n inverted: boolean\n ) {\n let matchObject: gdjs.RuntimeObject | null = null;\n let testSqDist = inverted\n ? 0\n : (endX - x) * (endX - x) + (endY - y) * (endY - y);\n let resultX = 0;\n let resultY = 0;\n const lists: RuntimeObject[][] = gdjs.staticArray(\n gdjs.evtTools.object.raycastObjectToPosition\n );\n objectsLists.values(lists);\n for (let i = 0; i < lists.length; i++) {\n const list = lists[i];\n for (let j = 0; j < list.length; j++) {\n const object = list[j];\n const result = object.raycastTest(x, y, endX, endY, !inverted);\n if (result.collision) {\n if (!inverted && result.closeSqDist <= testSqDist) {\n testSqDist = result.closeSqDist;\n matchObject = object;\n resultX = result.closeX;\n resultY = result.closeY;\n } else {\n if (inverted && result.farSqDist >= testSqDist) {\n testSqDist = result.farSqDist;\n matchObject = object;\n resultX = result.farX;\n resultY = result.farY;\n }\n }\n }\n }\n }\n if (!matchObject) {\n return false;\n }\n gdjs.evtTools.object.pickOnly(objectsLists, matchObject);\n varX.setNumber(resultX);\n varY.setNumber(resultY);\n return true;\n };\n\n /**\n * Do the work of creating a new object\n */\n export const doCreateObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectName: string,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n // objectsContext will either be the gdjs.RuntimeScene or, in an events function, the\n // eventsFunctionContext. We can't directly use runtimeScene because the object name could\n // be different than the real object name (this is the case in a function. The eventsFunctionContext\n // will take care of this in createObject).\n const obj = objectsContext.createObject(objectName);\n const layer = objectsContext.getLayer(layerName);\n if (obj !== null) {\n //Do some extra setup\n obj.setPosition(x, y);\n obj.setLayer(layerName);\n obj.setZOrder(layer.getDefaultZOrder());\n\n //Let the new object be picked by next actions/conditions.\n if (objectsLists.containsKey(objectName)) {\n objectsLists.get(objectName).push(obj);\n }\n }\n return obj;\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n x: float,\n y: float,\n layerName: string\n ): gdjs.RuntimeObject | null {\n return gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectsLists.firstKey() as string,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Allows events to create a new object on a scene.\n */\n export const createObjectFromGroupOnScene = function (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists,\n objectName: string,\n x: float,\n y: float,\n layerName: string\n ) {\n gdjs.evtTools.object.doCreateObjectOnScene(\n objectsContext,\n objectName,\n objectsLists,\n x,\n y,\n layerName\n );\n };\n\n /**\n * Return the number of instances in the specified lists of objects.\n */\n export const getPickedInstancesCount = (objectsLists: ObjectsLists) => {\n let count = 0;\n const lists = gdjs.staticArray(\n gdjs.evtTools.object.getPickedInstancesCount\n );\n objectsLists.values(lists);\n for (let i = 0, len = lists.length; i < len; ++i) {\n count += lists[i].length;\n }\n return count;\n };\n\n /**\n * Return the number of instances of the specified objects living on the scene.\n */\n export const getSceneInstancesCount = (\n objectsContext: EventsFunctionContext | gdjs.RuntimeScene,\n objectsLists: ObjectsLists\n ) => {\n let count = 0;\n\n const objectNames = gdjs.staticArray(\n gdjs.evtTools.object.getSceneInstancesCount\n );\n objectsLists.keys(objectNames);\n\n const uniqueObjectNames = new Set(objectNames);\n for (const objectName of uniqueObjectNames) {\n count += objectsContext.getInstancesCountOnScene(objectName);\n }\n return count;\n };\n\n /** @deprecated */\n export const pickedObjectsCount = getPickedInstancesCount;\n }\n }\n\n /**\n * A container for objects lists that should last more than the current frame.\n * It automatically removes objects that were destroyed from the objects lists.\n */\n export class LongLivedObjectsList {\n private objectsLists = new Map<string, Array<RuntimeObject>>();\n private localVariablesContainers: Array<gdjs.VariablesContainer> = [];\n private callbacks = new Map<RuntimeObject, () => void>();\n private parent: LongLivedObjectsList | null = null;\n\n /**\n * Create a new container for objects lists, inheriting from another one. This is\n * useful should we get the objects that have not been saved in this context (using\n * `addObject`) but saved in a parent context.\n * This avoids to save all object lists every time we create a new `LongLivedObjectsList`,\n * despite not all objects lists being used.\n *\n * @param parent\n * @returns\n */\n static from(parent: LongLivedObjectsList): LongLivedObjectsList {\n const newList = new LongLivedObjectsList();\n newList.parent = parent;\n return newList;\n }\n\n private getOrCreateList(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName))\n this.objectsLists.set(objectName, []);\n return this.objectsLists.get(objectName)!;\n }\n\n getObjects(objectName: string): RuntimeObject[] {\n if (!this.objectsLists.has(objectName) && this.parent)\n return this.parent.getObjects(objectName);\n return this.objectsLists.get(objectName) || [];\n }\n\n addObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n if (list.includes(runtimeObject)) return;\n list.push(runtimeObject);\n\n // Register callbacks for when the object is destroyed\n const onDestroy = () => this.removeObject(objectName, runtimeObject);\n this.callbacks.set(runtimeObject, onDestroy);\n runtimeObject.registerDestroyCallback(onDestroy);\n }\n\n removeObject(objectName: string, runtimeObject: gdjs.RuntimeObject): void {\n const list = this.getOrCreateList(objectName);\n const index = list.indexOf(runtimeObject);\n if (index === -1) return;\n list.splice(index, 1);\n\n // Properly remove callbacks to not leak the object\n runtimeObject.unregisterDestroyCallback(\n this.callbacks.get(runtimeObject)!\n );\n this.callbacks.delete(runtimeObject);\n }\n\n restoreLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(this.localVariablesContainers, variablesContainers);\n }\n\n backupLocalVariablesContainers(\n variablesContainers: Array<gdjs.VariablesContainer>\n ): void {\n gdjs.copyArray(variablesContainers, this.localVariablesContainers);\n }\n }\n}\n"],
5
+ "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACS,GAAU,GAAV,UAAU,EAAV,CACE,GAAU,GAAV,UAAU,EAAV,CAOE,AAAM,WAAW,SACtB,EACA,EACA,CACA,SAAW,KAAY,GAAa,MAClC,GAAI,EAAa,MAAM,eAAe,GAAW,CAC/C,KAAM,GAAO,EAAa,MAAM,GAGhC,AAAI,EAAK,QAAQ,KAAmB,GAClC,EAAK,OAAS,EAEd,GAAK,OAAS,EAGd,EAAK,KAAK,MA8BL,eAAe,SAC1B,EAKA,EACA,EACA,EACA,EACA,CACA,GAAI,GAAS,GACb,KAAM,GAAgB,EAAK,YACzB,EAAK,SAAS,OAAO,cAEvB,EAAc,OAAO,GACrB,KAAM,GAAgB,EAAK,aACzB,EAAK,SAAS,OAAO,cAEvB,EAAc,OAAO,GACrB,OAAS,GAAI,EAAG,EAAO,EAAc,OAAQ,EAAI,EAAM,EAAE,EAAG,CAC1D,GAAI,G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AqB,KAAK,2BAnEtC,EAAM,yBAhnBL",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(t){const i=new t.Logger("Engine runtime");let u;(function(n){const e=!0})(u=t.evtTools||(t.evtTools={})),t.objectsTypes=new Hashtable,t.behaviorsTypes=new Hashtable,t.callbacksFirstRuntimeSceneLoaded=[],t.callbacksRuntimeSceneLoaded=[],t.callbacksRuntimeScenePreEvents=[],t.callbacksRuntimeScenePostEvents=[],t.callbacksRuntimeScenePaused=[],t.callbacksRuntimeSceneResumed=[],t.callbacksRuntimeSceneUnloading=[],t.callbacksRuntimeSceneUnloaded=[],t.callbacksObjectDeletedFromScene=[],t.gdevelopLogo="",t.rgbToHex=function(e,n,r){return""+((1<<24)+(e<<16)+(n<<8)+r).toString(16).slice(1)},t.hexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[n>>16&255,n>>8&255,n&255]:[0,0,0]},t.rgbOrHexToRGBColor=function(e){const n=e.split(";");return n.length===3?[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]:t.hexToRGBColor(e)},t.rgbOrHexStringToNumber=e=>{const n=t.rgbOrHexToRGBColor(e);return t.rgbToHexNumber(n[0],n[1],n[2])},t.rgbToHexNumber=function(e,n,r){return(e<<16)+(n<<8)+r},t.hexNumberToRGB=e=>({r:e>>16&255,g:e>>8&255,b:e&255,a:255}),t.hexNumberToRGBArray=e=>[e>>16&255,e>>8&255,e&255],t.random=function(e){return e<=0?0:Math.floor(Math.random()*(e+1))},t.randomInRange=function(e,n){return e+t.random(n-e)},t.randomFloat=function(e){return e<=0?0:Math.random()*e},t.randomFloatInRange=function(e,n){return e+t.randomFloat(n-e)},t.randomWithStep=function(e,n,r){return r<=0?e+t.random(n-e):e+t.random(Math.floor((n-e)/r))*r},t.toRad=function(e){return e/180*Math.PI},t.toDegrees=function(e){return e*180/Math.PI},t.registerObject=function(e,n){t.objectsTypes.put(e,n)},t.registerBehavior=function(e,n){t.behaviorsTypes.put(e,n)},t.registerFirstRuntimeSceneLoadedCallback=function(e){t.callbacksFirstRuntimeSceneLoaded.push(e)},t.registerRuntimeSceneLoadedCallback=function(e){t.callbacksRuntimeSceneLoaded.push(e)},t.registerRuntimeScenePreEventsCallback=function(e){t.callbacksRuntimeScenePreEvents.push(e)},t.registerRuntimeScenePostEventsCallback=function(e){t.callbacksRuntimeScenePostEvents.push(e)},t.registerRuntimeScenePausedCallback=function(e){t.callbacksRuntimeScenePaused.push(e)},t.registerRuntimeSceneResumedCallback=function(e){t.callbacksRuntimeSceneResumed.push(e)},t.registerRuntimeSceneUnloadingCallback=function(e){t.callbacksRuntimeSceneUnloading.push(e)},t.registerRuntimeSceneUnloadedCallback=function(e){t.callbacksRuntimeSceneUnloaded.push(e)},t.registerObjectDeletedFromSceneCallback=function(e){t.callbacksObjectDeletedFromScene.push(e)},t._unregisterCallback=function(e){const n=r=>{for(let o=0;o<r.length;)r[o]===e?r.splice(o,1):o++};n(t.callbacksFirstRuntimeSceneLoaded),n(t.callbacksRuntimeSceneLoaded),n(t.callbacksRuntimeScenePreEvents),n(t.callbacksRuntimeScenePostEvents),n(t.callbacksRuntimeScenePaused),n(t.callbacksRuntimeSceneResumed),n(t.callbacksRuntimeSceneUnloading),n(t.callbacksRuntimeSceneUnloaded),n(t.callbacksObjectDeletedFromScene)},t.registerGlobalCallbacks=function(){i.warn("You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.")},t.getObjectConstructor=function(e){return e!==void 0&&t.objectsTypes.containsKey(e)?t.objectsTypes.get(e):(i.warn('Object type "'+e+'" was not found.'),t.objectsTypes.get(""))},t.getBehaviorConstructor=function(e){return e!==void 0&&t.behaviorsTypes.containsKey(e)?t.behaviorsTypes.get(e):(i.warn('Behavior type "'+e+'" was not found.'),t.behaviorsTypes.get(""))},t.staticArray=function(e){return e._staticArray=e._staticArray||[],e._staticArray},t.staticArray2=function(e){return e._staticArray2=e._staticArray2||[],e._staticArray2},t.staticObject=function(e){return e._staticObject=e._staticObject||{},e._staticObject},t.objectsListsToArray=function(e){var n=t.staticArray(t.objectsListsToArray);e.values(n);for(var r=[],o=0;o<n.length;++o)for(var a=n[o],c=0;c<a.length;++c)r.push(a[c]);return r},t.copyArray=function(e,n){for(var r=e.length,o=0;o<r;++o)n[o]=e[o];n.length=r},t.makeUuid=function(){if(typeof crypto=="undefined"||!crypto.getRandomValues){const o=a=>a?(a^Math.random()*16>>a/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o);return o()}if(!t.makeUuid.hex){t.makeUuid.hex=[];for(var e=0;e<256;e++)t.makeUuid.hex[e]=(e<16?"0":"")+e.toString(16)}const n=t.makeUuid.hex;var r=crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},t.nearlyEqual=(e,n,r)=>{const o=Math.abs(e),a=Math.abs(n),c=Math.abs(e-n);return e===n?!0:e==0||n==0||o+a<Number.EPSILON?c<r*Number.EPSILON:c/Math.min(o+a,Number.MAX_VALUE)<r};const l=[];t.registerAsynchronouslyLoadingLibraryPromise=e=>{l.push(e)},t.getAllAsynchronouslyLoadingLibraryPromise=()=>Promise.all(l)})(gdjs||(gdjs={})),console.warn=console.warn||console.log,console.error=console.error||console.log;
1
+ var gdjs;(function(t){const i=new t.Logger("Engine runtime"),l=/^(#{0,1}[A-Fa-f0-9]{6})$/,s=/^(#{0,1}[A-Fa-f0-9]{3})$/,b=/^(\d{1,3};\d{1,3};\d{1,3})/;let f;(function(n){const e=!0})(f=t.evtTools||(t.evtTools={})),t.objectsTypes=new Hashtable,t.behaviorsTypes=new Hashtable,t.callbacksFirstRuntimeSceneLoaded=[],t.callbacksRuntimeSceneLoaded=[],t.callbacksRuntimeScenePreEvents=[],t.callbacksRuntimeScenePostEvents=[],t.callbacksRuntimeScenePaused=[],t.callbacksRuntimeSceneResumed=[],t.callbacksRuntimeSceneUnloading=[],t.callbacksRuntimeSceneUnloaded=[],t.callbacksObjectDeletedFromScene=[],t.gdevelopLogo="",t.rgbToHex=function(e,n,r){return""+((1<<24)+(e<<16)+(n<<8)+r).toString(16).slice(1)},t.hexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[n>>16&255,n>>8&255,n&255]:[0,0,0]},t.shorthandHexToRGBColor=function(e){const n=parseInt(e.replace("#",""),16);return Number.isFinite(n)?[17*(n>>8&15),17*(n>>4&15),17*(n&15)]:[0,0,0]},t.rgbOrHexToRGBColor=function(e){const n=t.extractRGBString(e);if(n){const a=n.split(";");if(a.length===3)return[Math.min(255,parseInt(a[0],10)),Math.min(255,parseInt(a[1],10)),Math.min(255,parseInt(a[2],10))]}const r=t.extractHexString(e);if(r)return t.hexToRGBColor(r);const o=t.extractShorthandHexString(e);return o?t.shorthandHexToRGBColor(o):[0,0,0]},t.rgbOrHexStringToNumber=e=>{const n=t.rgbOrHexToRGBColor(e);return t.rgbToHexNumber(n[0],n[1],n[2])},t.rgbToHexNumber=function(e,n,r){return(e<<16)+(n<<8)+r},t.hexNumberToRGB=e=>({r:e>>16&255,g:e>>8&255,b:e&255,a:255}),t.hexNumberToRGBArray=e=>[e>>16&255,e>>8&255,e&255],t.extractHexString=e=>{const n=e.match(l);return n?n[0]:null},t.extractShorthandHexString=e=>{const n=e.match(s);return n?n[0]:null},t.extractRGBString=e=>{const n=e.match(b);return n?n[0]:null},t.random=function(e){return e<=0?0:Math.floor(Math.random()*(e+1))},t.randomInRange=function(e,n){return e+t.random(n-e)},t.randomFloat=function(e){return e<=0?0:Math.random()*e},t.randomFloatInRange=function(e,n){return e+t.randomFloat(n-e)},t.randomWithStep=function(e,n,r){return r<=0?e+t.random(n-e):e+t.random(Math.floor((n-e)/r))*r},t.toRad=function(e){return e/180*Math.PI},t.toDegrees=function(e){return e*180/Math.PI},t.registerObject=function(e,n){t.objectsTypes.put(e,n)},t.registerBehavior=function(e,n){t.behaviorsTypes.put(e,n)},t.registerFirstRuntimeSceneLoadedCallback=function(e){t.callbacksFirstRuntimeSceneLoaded.push(e)},t.registerRuntimeSceneLoadedCallback=function(e){t.callbacksRuntimeSceneLoaded.push(e)},t.registerRuntimeScenePreEventsCallback=function(e){t.callbacksRuntimeScenePreEvents.push(e)},t.registerRuntimeScenePostEventsCallback=function(e){t.callbacksRuntimeScenePostEvents.push(e)},t.registerRuntimeScenePausedCallback=function(e){t.callbacksRuntimeScenePaused.push(e)},t.registerRuntimeSceneResumedCallback=function(e){t.callbacksRuntimeSceneResumed.push(e)},t.registerRuntimeSceneUnloadingCallback=function(e){t.callbacksRuntimeSceneUnloading.push(e)},t.registerRuntimeSceneUnloadedCallback=function(e){t.callbacksRuntimeSceneUnloaded.push(e)},t.registerObjectDeletedFromSceneCallback=function(e){t.callbacksObjectDeletedFromScene.push(e)},t._unregisterCallback=function(e){const n=r=>{for(let o=0;o<r.length;)r[o]===e?r.splice(o,1):o++};n(t.callbacksFirstRuntimeSceneLoaded),n(t.callbacksRuntimeSceneLoaded),n(t.callbacksRuntimeScenePreEvents),n(t.callbacksRuntimeScenePostEvents),n(t.callbacksRuntimeScenePaused),n(t.callbacksRuntimeSceneResumed),n(t.callbacksRuntimeSceneUnloading),n(t.callbacksRuntimeSceneUnloaded),n(t.callbacksObjectDeletedFromScene)},t.registerGlobalCallbacks=function(){i.warn("You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.")},t.getObjectConstructor=function(e){return e!==void 0&&t.objectsTypes.containsKey(e)?t.objectsTypes.get(e):(i.warn('Object type "'+e+'" was not found.'),t.objectsTypes.get(""))},t.getBehaviorConstructor=function(e){return e!==void 0&&t.behaviorsTypes.containsKey(e)?t.behaviorsTypes.get(e):(i.warn('Behavior type "'+e+'" was not found.'),t.behaviorsTypes.get(""))},t.staticArray=function(e){return e._staticArray=e._staticArray||[],e._staticArray},t.staticArray2=function(e){return e._staticArray2=e._staticArray2||[],e._staticArray2},t.staticObject=function(e){return e._staticObject=e._staticObject||{},e._staticObject},t.objectsListsToArray=function(e){var n=t.staticArray(t.objectsListsToArray);e.values(n);for(var r=[],o=0;o<n.length;++o)for(var a=n[o],c=0;c<a.length;++c)r.push(a[c]);return r},t.copyArray=function(e,n){for(var r=e.length,o=0;o<r;++o)n[o]=e[o];n.length=r},t.makeUuid=function(){if(typeof crypto=="undefined"||!crypto.getRandomValues){const o=a=>a?(a^Math.random()*16>>a/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,o);return o()}if(!t.makeUuid.hex){t.makeUuid.hex=[];for(var e=0;e<256;e++)t.makeUuid.hex[e]=(e<16?"0":"")+e.toString(16)}const n=t.makeUuid.hex;var r=crypto.getRandomValues(new Uint8Array(16));return r[6]=r[6]&15|64,r[8]=r[8]&63|128,n[r[0]]+n[r[1]]+n[r[2]]+n[r[3]]+"-"+n[r[4]]+n[r[5]]+"-"+n[r[6]]+n[r[7]]+"-"+n[r[8]]+n[r[9]]+"-"+n[r[10]]+n[r[11]]+n[r[12]]+n[r[13]]+n[r[14]]+n[r[15]]},t.nearlyEqual=(e,n,r)=>{const o=Math.abs(e),a=Math.abs(n),c=Math.abs(e-n);return e===n?!0:e==0||n==0||o+a<Number.EPSILON?c<r*Number.EPSILON:c/Math.min(o+a,Number.MAX_VALUE)<r};const u=[];t.registerAsynchronouslyLoadingLibraryPromise=e=>{u.push(e)},t.getAllAsynchronouslyLoadingLibraryPromise=()=>Promise.all(u)})(gdjs||(gdjs={})),console.warn=console.warn||console.log,console.error=console.error||console.log;
2
2
  //# sourceMappingURL=gd.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/gd.ts"],
4
- "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\n\n/**\n * The `gdjs` namespace contains all classes and objects of the game engine.\n * @namespace gdjs\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Engine runtime');\n\n /**\n * Contains functions used by events (this is a convention only, functions can actually\n * be anywhere).\n * @namespace\n * @memberOf gdjs\n */\n export namespace evtTools {\n // @ts-ignore - This variable is unused on purpose.\n const thisIsUnusedButEnsureTheNamespaceIsDeclared = true;\n }\n\n export const objectsTypes = new Hashtable<typeof gdjs.RuntimeObject>();\n export const behaviorsTypes = new Hashtable<typeof gdjs.RuntimeBehavior>();\n\n type RuntimeSceneCallback = (runtimeScene: gdjs.RuntimeScene) => void;\n type RuntimeSceneRuntimeObjectCallback = (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n runtimeObject: gdjs.RuntimeObject\n ) => void;\n\n export const callbacksFirstRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePreEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePostEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePaused: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneResumed: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloading: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloaded: Array<RuntimeSceneCallback> = [];\n export const callbacksObjectDeletedFromScene: Array<RuntimeSceneRuntimeObjectCallback> = [];\n\n /** Base64 encoded logo of GDevelop for the splash screen. */\n export let gdevelopLogo: string = '';\n\n /**\n * Convert a RGB object to a Hex string.\n *\n * No \"#\" or \"0x\" are added.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHex = function (\n r: integer,\n g: integer,\n b: integer\n ): string {\n return '' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n };\n\n /**\n * Convert a Hex string to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const hexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [(hexNumber >> 16) & 0xff, (hexNumber >> 8) & 0xff, hexNumber & 0xff]\n : [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color array ([r,g,b] with each component going from 0 to 255).\n * @param value The color as a RGB string or Hex string\n */\n export const rgbOrHexToRGBColor = function (\n value: string\n ): [number, number, number] {\n const splitValue = value.split(';');\n // If a RGB string is provided, return the RGB object.\n if (splitValue.length === 3) {\n return [\n parseInt(splitValue[0], 10),\n parseInt(splitValue[1], 10),\n parseInt(splitValue[2], 10),\n ];\n }\n // Otherwise, convert the Hex to RGB.\n return hexToRGBColor(value);\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color number.\n * @param rgbOrHexString The color as a RGB string or Hex string\n */\n export const rgbOrHexStringToNumber = (rgbOrHexString: string): integer => {\n const components = gdjs.rgbOrHexToRGBColor(rgbOrHexString);\n return gdjs.rgbToHexNumber(components[0], components[1], components[2]);\n };\n\n /**\n * Convert a RGB object to a Hex number.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHexNumber = function (\n r: integer,\n g: integer,\n b: integer\n ): integer {\n return (r << 16) + (g << 8) + b;\n };\n\n /**\n * Convert a Hex number to a RGB color object ({r,g,b,a} with each component going from 0 to 255 and alpha set to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGB = (\n hexNumber: number\n ): { r: integer; g: integer; b: integer; a: integer } => {\n return {\n r: (hexNumber >> 16) & 0xff,\n g: (hexNumber >> 8) & 0xff,\n b: hexNumber & 0xff,\n a: 255,\n };\n };\n\n /**\n * Convert a Hex number to a RGB color array([r,g,b] with each component going from 0 to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGBArray = (\n hexNumber: number\n ): [integer, integer, integer] => {\n return [\n (hexNumber >> 16) & 0xff,\n (hexNumber >> 8) & 0xff,\n hexNumber & 0xff,\n ];\n };\n\n /**\n * Get a random integer between 0 and max.\n * @param max The maximum value (inclusive).\n */\n export const random = function (max: float): float {\n if (max <= 0) return 0;\n return Math.floor(Math.random() * (max + 1));\n };\n\n /**\n * Get a random integer between min and max.\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n\n */\n export const randomInRange = function (min: float, max: float): float {\n return min + gdjs.random(max - min); // return min if min >= max\n };\n\n /**\n * Get a random float in the range 0 to less than max (inclusive of 0, but not max).\n * @param max The maximum value (exclusive).\n */\n export const randomFloat = function (max: float): float {\n if (max <= 0) return 0;\n return Math.random() * max;\n };\n\n /**\n * Get a random float between min and max\n * @param min The minimum value (inclusive).\n * @param max The maximum value (exclusive).\n * @returns {number}\n */\n export const randomFloatInRange = function (min: float, max: float): float {\n return min + gdjs.randomFloat(max - min); // return min if min >= max\n };\n\n /**\n * Get a random number between min and max in steps\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @param step The interval between each value.\n * @returns {number}\n */\n export const randomWithStep = function (\n min: float,\n max: float,\n step: float\n ): float {\n if (step <= 0) return min + gdjs.random(max - min);\n return min + gdjs.random(Math.floor((max - min) / step)) * step; // return min if min >= max\n };\n\n /**\n * Convert an angle in degrees to radians.\n * @param angleInDegrees The angle in degrees.\n */\n export const toRad = function (angleInDegrees: float): float {\n return (angleInDegrees / 180) * Math.PI;\n };\n\n /**\n * Convert an angle in radians to degrees.\n * @param angleInRadians The angle in radians.\n */\n export const toDegrees = function (angleInRadians: float): float {\n return (angleInRadians * 180) / Math.PI;\n };\n\n /**\n * Register a runtime object (class extending {@link gdjs.RuntimeObject}) that can be used in a scene.\n *\n * The name of the type of the object must be complete, with the namespace if any. For\n * example, if you are providing a Text object in the TextObject extension, the full name\n * of the type of the object is \"TextObject::Text\".\n *\n * @param objectTypeName The name of the type of the Object.\n * @param Ctor The constructor of the Object.\n */\n export const registerObject = function (\n objectTypeName: string,\n Ctor: typeof gdjs.RuntimeObject\n ): void {\n gdjs.objectsTypes.put(objectTypeName, Ctor);\n };\n\n /**\n * Register a runtime behavior (class extending {@link gdjs.RuntimeBehavior}) that can be used by a\n * {@link gdjs.RuntimeObject}.\n *\n * The type of the behavior must be complete, with the namespace of the extension. For\n * example, if you are providing a Draggable behavior in the DraggableBehavior extension,\n * the full name of the type of the behavior is \"DraggableBehavior::Draggable\".\n *\n * @param behaviorTypeName The name of the type of the behavior.\n * @param Ctor The constructor of the Object.\n */\n export const registerBehavior = function (\n behaviorTypeName: string,\n Ctor: typeof gdjs.RuntimeBehavior\n ): void {\n gdjs.behaviorsTypes.put(behaviorTypeName, Ctor);\n };\n\n /**\n * Register a function to be called when the first {@link gdjs.RuntimeScene} is loaded, after\n * resources loading is done. This can be considered as the \"start of the game\".\n *\n * @param callback The function to be called.\n */\n export const registerFirstRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksFirstRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is loaded.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * before events are run.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePreEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePreEvents.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * after events are run and before rendering.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePostEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePostEvents.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is paused.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePausedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePaused.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is resumed.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneResumedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneResumed.push(callback);\n };\n\n /**\n * Register a function to be called when a scene unload started. This is\n * before the object deletion and renderer destruction. It is safe to\n * manipulate these. It is **not** be safe to release resources as other\n * callbacks might do operations on objects or the scene.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadingCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloading.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is unloaded. The objects\n * and renderer are now destroyed - it is **not** safe to do anything apart\n * from releasing resources.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloaded.push(callback);\n };\n\n /**\n * Register a function to be called when an object is deleted from a scene.\n * @param callback The function to be called.\n */\n export const registerObjectDeletedFromSceneCallback = function (\n callback: RuntimeSceneRuntimeObjectCallback\n ): void {\n gdjs.callbacksObjectDeletedFromScene.push(callback);\n };\n\n /**\n * Unregister a callback.\n * This should not be used apart from the code generated from extensions\n * events functions, to handle hot-reloading.\n * In any other case, a callback should be registered once, and only once.\n *\n * @internal\n */\n export const _unregisterCallback = function (callback: unknown): void {\n const filterArrayInPlace = (array: unknown[]) => {\n for (let i = 0; i < array.length; ) {\n if (array[i] === callback) {\n array.splice(i, 1);\n } else {\n i++;\n }\n }\n };\n\n filterArrayInPlace(callbacksFirstRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeScenePreEvents);\n filterArrayInPlace(callbacksRuntimeScenePostEvents);\n filterArrayInPlace(callbacksRuntimeScenePaused);\n filterArrayInPlace(callbacksRuntimeSceneResumed);\n filterArrayInPlace(callbacksRuntimeSceneUnloading);\n filterArrayInPlace(callbacksRuntimeSceneUnloaded);\n filterArrayInPlace(callbacksObjectDeletedFromScene);\n };\n\n /**\n * Keep this function until we're sure now client is using it anymore.\n * @deprecated\n * @private\n */\n export const registerGlobalCallbacks = function (): void {\n logger.warn(\n \"You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.\"\n );\n };\n\n /**\n * Get the constructor of an object.\n *\n * @param name The name of the type of the object.\n */\n export const getObjectConstructor = function (\n name: string\n ): typeof gdjs.RuntimeObject {\n if (name !== undefined && gdjs.objectsTypes.containsKey(name))\n return gdjs.objectsTypes.get(name);\n\n logger.warn('Object type \"' + name + '\" was not found.');\n return gdjs.objectsTypes.get(''); //Create a base empty runtime object.\n };\n\n /**\n * Get the constructor of a behavior.\n *\n * @param name The name of the type of the behavior.\n */\n export const getBehaviorConstructor = function (\n name: string\n ): typeof gdjs.RuntimeBehavior {\n if (name !== undefined && gdjs.behaviorsTypes.containsKey(name))\n return gdjs.behaviorsTypes.get(name);\n\n logger.warn('Behavior type \"' + name + '\" was not found.');\n return gdjs.behaviorsTypes.get(''); //Create a base empty runtime behavior.\n };\n\n /**\n * Create a static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray = function (owner: any): Array<any> {\n owner._staticArray = owner._staticArray || [];\n return owner._staticArray;\n };\n\n /**\n * Create a second static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray2 = function (owner: any): Array<any> {\n owner._staticArray2 = owner._staticArray2 || [];\n return owner._staticArray2;\n };\n\n /**\n * Create a static object that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticObject = function (owner: any): Object {\n owner._staticObject = owner._staticObject || {};\n return owner._staticObject;\n };\n\n /**\n * Return a new array of objects that is the concatenation of all the objects passed\n * as parameters.\n * @param objectsLists\n * @returns {Array}\n */\n export const objectsListsToArray = function (\n objectsLists: Hashtable<RuntimeObject>\n ): Array<RuntimeObject> {\n var lists = gdjs.staticArray(gdjs.objectsListsToArray);\n objectsLists.values(lists);\n\n var result: Array<RuntimeObject> = [];\n for (var i = 0; i < lists.length; ++i) {\n var arr = lists[i];\n for (var k = 0; k < arr.length; ++k) {\n result.push(arr[k]);\n }\n }\n return result;\n };\n\n /**\n * Copy the element for the first array into the second array, so that\n * both array contains the same elements.\n * @param src The source array\n * @param dst The destination array\n */\n export const copyArray = function <T>(src: Array<T>, dst: Array<T>): void {\n var len = src.length;\n for (var i = 0; i < len; ++i) {\n dst[i] = src[i];\n }\n dst.length = len;\n };\n\n interface MakeUUID {\n (): string;\n hex?: string[];\n }\n\n /**\n * Generate a UUID v4.\n * @returns The generated UUID.\n */\n export const makeUuid = <MakeUUID>function (): string {\n // Fallback to non cryptographically secure UUIDs if not supported\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n const makeMathRandomUuid = (a?: any): string => {\n return a\n ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)\n : ('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(\n /[018]/g,\n makeMathRandomUuid\n );\n };\n\n return makeMathRandomUuid();\n }\n\n if (!gdjs.makeUuid.hex) {\n gdjs.makeUuid.hex = [];\n\n for (var i = 0; i < 256; i++) {\n gdjs.makeUuid.hex[i] = (i < 16 ? '0' : '') + i.toString(16);\n }\n }\n const hex = gdjs.makeUuid.hex;\n\n var r = crypto.getRandomValues(new Uint8Array(16));\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return (\n hex[r[0]] +\n hex[r[1]] +\n hex[r[2]] +\n hex[r[3]] +\n '-' +\n hex[r[4]] +\n hex[r[5]] +\n '-' +\n hex[r[6]] +\n hex[r[7]] +\n '-' +\n hex[r[8]] +\n hex[r[9]] +\n '-' +\n hex[r[10]] +\n hex[r[11]] +\n hex[r[12]] +\n hex[r[13]] +\n hex[r[14]] +\n hex[r[15]]\n );\n };\n\n /**\n * See https://floating-point-gui.de/errors/comparison/\n * @param a\n * @param b\n * @param epsilon the relative margin error\n * @returns true when a and b are within a relative margin error.\n */\n export const nearlyEqual = (a: float, b: float, epsilon: float): boolean => {\n const absA = Math.abs(a);\n const absB = Math.abs(b);\n const diff = Math.abs(a - b);\n\n if (a === b) {\n // shortcut, handles infinities\n return true;\n } else if (a == 0 || b == 0 || absA + absB < Number.EPSILON) {\n // a or b is zero or both are extremely close to it\n // relative error is less meaningful here\n return diff < epsilon * Number.EPSILON;\n } else {\n // use relative error\n return diff / Math.min(absA + absB, Number.MAX_VALUE) < epsilon;\n }\n };\n\n const asynchronouslyLoadingLibraryPromises: Array<Promise<any>> = [];\n\n /**\n * Register a promise which will be resolved when a third party library has\n * finished loading (and is required to load before launching the game).\n *\n * This method must be called by any library that loads asynchronously.\n */\n export const registerAsynchronouslyLoadingLibraryPromise = (\n promise: Promise<any>\n ): void => {\n asynchronouslyLoadingLibraryPromises.push(promise);\n };\n\n /**\n * @returns a promise resolved when all all third party libraries, which need\n * to be loaded before the game startup, are loaded. If a library fails\n * loading, this will be rejected.\n */\n export const getAllAsynchronouslyLoadingLibraryPromise = (): Promise<\n any[]\n > => {\n return Promise.all(asynchronouslyLoadingLibraryPromises);\n };\n}\n\n// Make sure console.warn and console.error are available.\nconsole.warn = console.warn || console.log;\nconsole.error = console.error || console.log;\n"],
5
- "mappings": "AAUA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBAQxB,GAAU,GAAV,UAAU,EAAV,CAEL,KAAM,GAA8C,KAFrC,+BAKJ,eAAe,GAAI,WACnB,iBAAiB,GAAI,WAQrB,mCAAgE,GAChE,8BAA2D,GAC3D,iCAA8D,GAC9D,kCAA+D,GAC/D,8BAA2D,GAC3D,+BAA4D,GAC5D,iCAA8D,GAC9D,gCAA6D,GAC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9C,SAAE,GAAM,EAAE,GAAK,GAAQ,GACvB,EAAE,GAAM,EAAE,GAAK,GAAQ,IAGrB,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,MAWG,cAAc,CAAC,EAAU,EAAU,IAA4B,CAC1E,KAAM,GAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,EAAI,GAE1B,MAAI,KAAM,EAED,GACE,GAAK,GAAK,GAAK,GAAK,EAAO,EAAO,OAAO,QAG3C,EAAO,EAAU,OAAO,QAGxB,EAAO,KAAK,IAAI,EAAO,EAAM,OAAO,WAAa,GAI5D,KAAM,GAA4D,GAQ3D,AAAM,8CAA8C,AACzD,GACS,CACT,EAAqC,KAAK,IAQ/B,4CAA4C,IAGhD,QAAQ,IAAI,KA1kBb,iBA+kBV,QAAQ,KAAO,QAAQ,MAAQ,QAAQ,IACvC,QAAQ,MAAQ,QAAQ,OAAS,QAAQ",
4
+ "sourcesContent": ["/*\n * GDevelop JS Platform\n * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\n\n/**\n * The `gdjs` namespace contains all classes and objects of the game engine.\n * @namespace gdjs\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Engine runtime');\n const hexStringRegex = /^(#{0,1}[A-Fa-f0-9]{6})$/;\n const shorthandHexStringRegex = /^(#{0,1}[A-Fa-f0-9]{3})$/;\n const rgbStringRegex = /^(\\d{1,3};\\d{1,3};\\d{1,3})/;\n\n /**\n * Contains functions used by events (this is a convention only, functions can actually\n * be anywhere).\n * @namespace\n * @memberOf gdjs\n */\n export namespace evtTools {\n // @ts-ignore - This variable is unused on purpose.\n const thisIsUnusedButEnsureTheNamespaceIsDeclared = true;\n }\n\n export const objectsTypes = new Hashtable<typeof gdjs.RuntimeObject>();\n export const behaviorsTypes = new Hashtable<typeof gdjs.RuntimeBehavior>();\n\n type RuntimeSceneCallback = (runtimeScene: gdjs.RuntimeScene) => void;\n type RuntimeSceneRuntimeObjectCallback = (\n instanceContainer: gdjs.RuntimeInstanceContainer,\n runtimeObject: gdjs.RuntimeObject\n ) => void;\n\n export const callbacksFirstRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneLoaded: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePreEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePostEvents: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeScenePaused: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneResumed: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloading: Array<RuntimeSceneCallback> = [];\n export const callbacksRuntimeSceneUnloaded: Array<RuntimeSceneCallback> = [];\n export const callbacksObjectDeletedFromScene: Array<RuntimeSceneRuntimeObjectCallback> = [];\n\n /** Base64 encoded logo of GDevelop for the splash screen. */\n export let gdevelopLogo: string = '';\n\n /**\n * Convert a RGB object to a Hex string.\n *\n * No \"#\" or \"0x\" are added.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHex = function (\n r: integer,\n g: integer,\n b: integer\n ): string {\n return '' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);\n };\n\n /**\n * Convert a Hex string (#124FE4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const hexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [(hexNumber >> 16) & 0xff, (hexNumber >> 8) & 0xff, hexNumber & 0xff]\n : [0, 0, 0];\n };\n\n /**\n * Convert a shorthand Hex string (#1F4) to an RGB color array [r, g, b], where each component is in the range [0, 255].\n *\n * @param {string} hex Color hexadecimal\n */\n export const shorthandHexToRGBColor = function (\n hexString: string\n ): [number, number, number] {\n const hexNumber = parseInt(hexString.replace('#', ''), 16);\n return Number.isFinite(hexNumber)\n ? [\n 17 * ((hexNumber >> 8) & 0xf),\n 17 * ((hexNumber >> 4) & 0xf),\n 17 * (hexNumber & 0xf),\n ]\n : [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color array ([r,g,b] with each component going from 0 to 255).\n * @param value The color as a RGB string or Hex string\n */\n export const rgbOrHexToRGBColor = function (\n value: string\n ): [number, number, number] {\n const rgbColor = extractRGBString(value);\n if (rgbColor) {\n const splitValue = rgbColor.split(';');\n // If a RGB string is provided, return the RGB object.\n if (splitValue.length === 3) {\n return [\n Math.min(255, parseInt(splitValue[0], 10)),\n Math.min(255, parseInt(splitValue[1], 10)),\n Math.min(255, parseInt(splitValue[2], 10)),\n ];\n }\n }\n\n const hexColor = extractHexString(value);\n if (hexColor) {\n return hexToRGBColor(hexColor);\n }\n const shorthandHexColor = extractShorthandHexString(value);\n if (shorthandHexColor) {\n return shorthandHexToRGBColor(shorthandHexColor);\n }\n return [0, 0, 0];\n };\n\n /**\n * Convert a RGB string (\"rrr;ggg;bbb\") or a Hex string (\"#rrggbb\") to a RGB color number.\n * @param rgbOrHexString The color as a RGB string or Hex string\n */\n export const rgbOrHexStringToNumber = (rgbOrHexString: string): integer => {\n const components = gdjs.rgbOrHexToRGBColor(rgbOrHexString);\n return gdjs.rgbToHexNumber(components[0], components[1], components[2]);\n };\n\n /**\n * Convert a RGB object to a Hex number.\n * @param r Red\n * @param g Green\n * @param b Blue\n */\n export const rgbToHexNumber = function (\n r: integer,\n g: integer,\n b: integer\n ): integer {\n return (r << 16) + (g << 8) + b;\n };\n\n /**\n * Convert a Hex number to a RGB color object ({r,g,b,a} with each component going from 0 to 255 and alpha set to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGB = (\n hexNumber: number\n ): { r: integer; g: integer; b: integer; a: integer } => {\n return {\n r: (hexNumber >> 16) & 0xff,\n g: (hexNumber >> 8) & 0xff,\n b: hexNumber & 0xff,\n a: 255,\n };\n };\n\n /**\n * Convert a Hex number to a RGB color array([r,g,b] with each component going from 0 to 255).\n * @param hex Hex color\n */\n export const hexNumberToRGBArray = (\n hexNumber: number\n ): [integer, integer, integer] => {\n return [\n (hexNumber >> 16) & 0xff,\n (hexNumber >> 8) & 0xff,\n hexNumber & 0xff,\n ];\n };\n\n export const extractHexString = (str: string): string | null => {\n const matches = str.match(hexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n export const extractShorthandHexString = (str: string): string | null => {\n const matches = str.match(shorthandHexStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n\n export const extractRGBString = (str: string): string | null => {\n const matches = str.match(rgbStringRegex);\n if (!matches) return null;\n return matches[0];\n };\n\n /**\n * Get a random integer between 0 and max.\n * @param max The maximum value (inclusive).\n */\n export const random = function (max: float): float {\n if (max <= 0) return 0;\n return Math.floor(Math.random() * (max + 1));\n };\n\n /**\n * Get a random integer between min and max.\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n\n */\n export const randomInRange = function (min: float, max: float): float {\n return min + gdjs.random(max - min); // return min if min >= max\n };\n\n /**\n * Get a random float in the range 0 to less than max (inclusive of 0, but not max).\n * @param max The maximum value (exclusive).\n */\n export const randomFloat = function (max: float): float {\n if (max <= 0) return 0;\n return Math.random() * max;\n };\n\n /**\n * Get a random float between min and max\n * @param min The minimum value (inclusive).\n * @param max The maximum value (exclusive).\n * @returns {number}\n */\n export const randomFloatInRange = function (min: float, max: float): float {\n return min + gdjs.randomFloat(max - min); // return min if min >= max\n };\n\n /**\n * Get a random number between min and max in steps\n * @param min The minimum value (inclusive).\n * @param max The maximum value (inclusive).\n * @param step The interval between each value.\n * @returns {number}\n */\n export const randomWithStep = function (\n min: float,\n max: float,\n step: float\n ): float {\n if (step <= 0) return min + gdjs.random(max - min);\n return min + gdjs.random(Math.floor((max - min) / step)) * step; // return min if min >= max\n };\n\n /**\n * Convert an angle in degrees to radians.\n * @param angleInDegrees The angle in degrees.\n */\n export const toRad = function (angleInDegrees: float): float {\n return (angleInDegrees / 180) * Math.PI;\n };\n\n /**\n * Convert an angle in radians to degrees.\n * @param angleInRadians The angle in radians.\n */\n export const toDegrees = function (angleInRadians: float): float {\n return (angleInRadians * 180) / Math.PI;\n };\n\n /**\n * Register a runtime object (class extending {@link gdjs.RuntimeObject}) that can be used in a scene.\n *\n * The name of the type of the object must be complete, with the namespace if any. For\n * example, if you are providing a Text object in the TextObject extension, the full name\n * of the type of the object is \"TextObject::Text\".\n *\n * @param objectTypeName The name of the type of the Object.\n * @param Ctor The constructor of the Object.\n */\n export const registerObject = function (\n objectTypeName: string,\n Ctor: typeof gdjs.RuntimeObject\n ): void {\n gdjs.objectsTypes.put(objectTypeName, Ctor);\n };\n\n /**\n * Register a runtime behavior (class extending {@link gdjs.RuntimeBehavior}) that can be used by a\n * {@link gdjs.RuntimeObject}.\n *\n * The type of the behavior must be complete, with the namespace of the extension. For\n * example, if you are providing a Draggable behavior in the DraggableBehavior extension,\n * the full name of the type of the behavior is \"DraggableBehavior::Draggable\".\n *\n * @param behaviorTypeName The name of the type of the behavior.\n * @param Ctor The constructor of the Object.\n */\n export const registerBehavior = function (\n behaviorTypeName: string,\n Ctor: typeof gdjs.RuntimeBehavior\n ): void {\n gdjs.behaviorsTypes.put(behaviorTypeName, Ctor);\n };\n\n /**\n * Register a function to be called when the first {@link gdjs.RuntimeScene} is loaded, after\n * resources loading is done. This can be considered as the \"start of the game\".\n *\n * @param callback The function to be called.\n */\n export const registerFirstRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksFirstRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is loaded.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneLoadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneLoaded.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * before events are run.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePreEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePreEvents.push(callback);\n };\n\n /**\n * Register a function to be called each time a scene is stepped (i.e: at every frame),\n * after events are run and before rendering.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePostEventsCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePostEvents.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is paused.\n * @param callback The function to be called.\n */\n export const registerRuntimeScenePausedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeScenePaused.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is resumed.\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneResumedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneResumed.push(callback);\n };\n\n /**\n * Register a function to be called when a scene unload started. This is\n * before the object deletion and renderer destruction. It is safe to\n * manipulate these. It is **not** be safe to release resources as other\n * callbacks might do operations on objects or the scene.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadingCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloading.push(callback);\n };\n\n /**\n * Register a function to be called when a scene is unloaded. The objects\n * and renderer are now destroyed - it is **not** safe to do anything apart\n * from releasing resources.\n *\n * @param callback The function to be called.\n */\n export const registerRuntimeSceneUnloadedCallback = function (\n callback: RuntimeSceneCallback\n ): void {\n gdjs.callbacksRuntimeSceneUnloaded.push(callback);\n };\n\n /**\n * Register a function to be called when an object is deleted from a scene.\n * @param callback The function to be called.\n */\n export const registerObjectDeletedFromSceneCallback = function (\n callback: RuntimeSceneRuntimeObjectCallback\n ): void {\n gdjs.callbacksObjectDeletedFromScene.push(callback);\n };\n\n /**\n * Unregister a callback.\n * This should not be used apart from the code generated from extensions\n * events functions, to handle hot-reloading.\n * In any other case, a callback should be registered once, and only once.\n *\n * @internal\n */\n export const _unregisterCallback = function (callback: unknown): void {\n const filterArrayInPlace = (array: unknown[]) => {\n for (let i = 0; i < array.length; ) {\n if (array[i] === callback) {\n array.splice(i, 1);\n } else {\n i++;\n }\n }\n };\n\n filterArrayInPlace(callbacksFirstRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeSceneLoaded);\n filterArrayInPlace(callbacksRuntimeScenePreEvents);\n filterArrayInPlace(callbacksRuntimeScenePostEvents);\n filterArrayInPlace(callbacksRuntimeScenePaused);\n filterArrayInPlace(callbacksRuntimeSceneResumed);\n filterArrayInPlace(callbacksRuntimeSceneUnloading);\n filterArrayInPlace(callbacksRuntimeSceneUnloaded);\n filterArrayInPlace(callbacksObjectDeletedFromScene);\n };\n\n /**\n * Keep this function until we're sure now client is using it anymore.\n * @deprecated\n * @private\n */\n export const registerGlobalCallbacks = function (): void {\n logger.warn(\n \"You're calling gdjs.registerGlobalCallbacks. This method is now useless and you must not call it anymore.\"\n );\n };\n\n /**\n * Get the constructor of an object.\n *\n * @param name The name of the type of the object.\n */\n export const getObjectConstructor = function (\n name: string\n ): typeof gdjs.RuntimeObject {\n if (name !== undefined && gdjs.objectsTypes.containsKey(name))\n return gdjs.objectsTypes.get(name);\n\n logger.warn('Object type \"' + name + '\" was not found.');\n return gdjs.objectsTypes.get(''); //Create a base empty runtime object.\n };\n\n /**\n * Get the constructor of a behavior.\n *\n * @param name The name of the type of the behavior.\n */\n export const getBehaviorConstructor = function (\n name: string\n ): typeof gdjs.RuntimeBehavior {\n if (name !== undefined && gdjs.behaviorsTypes.containsKey(name))\n return gdjs.behaviorsTypes.get(name);\n\n logger.warn('Behavior type \"' + name + '\" was not found.');\n return gdjs.behaviorsTypes.get(''); //Create a base empty runtime behavior.\n };\n\n /**\n * Create a static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray = function (owner: any): Array<any> {\n owner._staticArray = owner._staticArray || [];\n return owner._staticArray;\n };\n\n /**\n * Create a second static array that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticArray2 = function (owner: any): Array<any> {\n owner._staticArray2 = owner._staticArray2 || [];\n return owner._staticArray2;\n };\n\n /**\n * Create a static object that won't need a new allocation each time it's used.\n * @param owner The owner of the Array.\n */\n export const staticObject = function (owner: any): Object {\n owner._staticObject = owner._staticObject || {};\n return owner._staticObject;\n };\n\n /**\n * Return a new array of objects that is the concatenation of all the objects passed\n * as parameters.\n * @param objectsLists\n * @returns {Array}\n */\n export const objectsListsToArray = function (\n objectsLists: Hashtable<RuntimeObject>\n ): Array<RuntimeObject> {\n var lists = gdjs.staticArray(gdjs.objectsListsToArray);\n objectsLists.values(lists);\n\n var result: Array<RuntimeObject> = [];\n for (var i = 0; i < lists.length; ++i) {\n var arr = lists[i];\n for (var k = 0; k < arr.length; ++k) {\n result.push(arr[k]);\n }\n }\n return result;\n };\n\n /**\n * Copy the element for the first array into the second array, so that\n * both array contains the same elements.\n * @param src The source array\n * @param dst The destination array\n */\n export const copyArray = function <T>(src: Array<T>, dst: Array<T>): void {\n var len = src.length;\n for (var i = 0; i < len; ++i) {\n dst[i] = src[i];\n }\n dst.length = len;\n };\n\n interface MakeUUID {\n (): string;\n hex?: string[];\n }\n\n /**\n * Generate a UUID v4.\n * @returns The generated UUID.\n */\n export const makeUuid = <MakeUUID>function (): string {\n // Fallback to non cryptographically secure UUIDs if not supported\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n const makeMathRandomUuid = (a?: any): string => {\n return a\n ? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)\n : ('' + 1e7 + -1e3 + -4e3 + -8e3 + -1e11).replace(\n /[018]/g,\n makeMathRandomUuid\n );\n };\n\n return makeMathRandomUuid();\n }\n\n if (!gdjs.makeUuid.hex) {\n gdjs.makeUuid.hex = [];\n\n for (var i = 0; i < 256; i++) {\n gdjs.makeUuid.hex[i] = (i < 16 ? '0' : '') + i.toString(16);\n }\n }\n const hex = gdjs.makeUuid.hex;\n\n var r = crypto.getRandomValues(new Uint8Array(16));\n r[6] = (r[6] & 0x0f) | 0x40;\n r[8] = (r[8] & 0x3f) | 0x80;\n\n return (\n hex[r[0]] +\n hex[r[1]] +\n hex[r[2]] +\n hex[r[3]] +\n '-' +\n hex[r[4]] +\n hex[r[5]] +\n '-' +\n hex[r[6]] +\n hex[r[7]] +\n '-' +\n hex[r[8]] +\n hex[r[9]] +\n '-' +\n hex[r[10]] +\n hex[r[11]] +\n hex[r[12]] +\n hex[r[13]] +\n hex[r[14]] +\n hex[r[15]]\n );\n };\n\n /**\n * See https://floating-point-gui.de/errors/comparison/\n * @param a\n * @param b\n * @param epsilon the relative margin error\n * @returns true when a and b are within a relative margin error.\n */\n export const nearlyEqual = (a: float, b: float, epsilon: float): boolean => {\n const absA = Math.abs(a);\n const absB = Math.abs(b);\n const diff = Math.abs(a - b);\n\n if (a === b) {\n // shortcut, handles infinities\n return true;\n } else if (a == 0 || b == 0 || absA + absB < Number.EPSILON) {\n // a or b is zero or both are extremely close to it\n // relative error is less meaningful here\n return diff < epsilon * Number.EPSILON;\n } else {\n // use relative error\n return diff / Math.min(absA + absB, Number.MAX_VALUE) < epsilon;\n }\n };\n\n const asynchronouslyLoadingLibraryPromises: Array<Promise<any>> = [];\n\n /**\n * Register a promise which will be resolved when a third party library has\n * finished loading (and is required to load before launching the game).\n *\n * This method must be called by any library that loads asynchronously.\n */\n export const registerAsynchronouslyLoadingLibraryPromise = (\n promise: Promise<any>\n ): void => {\n asynchronouslyLoadingLibraryPromises.push(promise);\n };\n\n /**\n * @returns a promise resolved when all all third party libraries, which need\n * to be loaded before the game startup, are loaded. If a library fails\n * loading, this will be rejected.\n */\n export const getAllAsynchronouslyLoadingLibraryPromise = (): Promise<\n any[]\n > => {\n return Promise.all(asynchronouslyLoadingLibraryPromises);\n };\n}\n\n// Make sure console.warn and console.error are available.\nconsole.warn = console.warn || console.log;\nconsole.error = console.error || console.log;\n"],
5
+ "mappings": "AAUA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,kBACzB,EAAiB,2BACjB,EAA0B,2BAC1B,EAAiB,6BAQhB,GAAU,GAAV,UAAU,EAAV,CAEL,KAAM,GAA8C,KAFrC,+BAKJ,eAAe,GAAI,WACnB,iBAAiB,GAAI,WAQrB,mCAAgE,GAChE,8BAA2D,GAC3D,iCAA8D,GAC9D,kCAA+D,GAC/D,8BAA2D,GAC3D,+BAA4D,GAC5D,iCAA8D,GAC9D,gCAA6D,GAC7D,kCAA4E,GAG9E,eAAuB,GAUrB,WAAW,SACtB,EACA,EACA,EACQ,CACR,MAAO,GAAO,KAAK,IAAO,IAAK,IAAO,IAAK,GAAK,GAAG,SAAS,IAAI,MAAM,IAQ3D,gBAAgB,SAC3B,EAC0B,CAC1B,KAAM,GAAY,SAAS,EAAU,QAAQ,IAAK,IAAK,IACvD,MAAO,QAAO,SAAS,GACnB,CAAE,GAAa,GAAM,IAAO,GAAa,EAAK,IAAM,EAAY,KAChE,CAAC,EAAG,EAAG,IAQA,yBAAyB,SACpC,EAC0B,CAC1B,KAAM,GAAY,SAAS,EAAU,QAAQ,IAAK,IAAK,IACvD,MAAO,QAAO,SAAS,GACnB,CACE,GAAO,IAAa,EAAK,IACzB,GAAO,IAAa,EAAK,IACzB,GAAM,GAAY,KAEpB,CAAC,EAAG,EAAG,IAOA,qBAAqB,SAChC,EAC0B,CAC1B,KAAM,GAAW,mBAAiB,GAClC,GAAI,EAAU,CACZ,KAAM,GAAa,EAAS,MAAM,KAElC,GAAI,EAAW,SAAW,EACxB,MAAO,CACL,KAAK,IAAI,IAAK,SAAS,EAAW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SAAE,GAAM,EAAE,GAAK,GAAQ,GACvB,EAAE,GAAM,EAAE,GAAK,GAAQ,IAGrB,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,IACN,EAAI,EAAE,IACN,IACA,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,KACN,EAAI,EAAE,MAWG,cAAc,CAAC,EAAU,EAAU,IAA4B,CAC1E,KAAM,GAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,GAChB,EAAO,KAAK,IAAI,EAAI,GAE1B,MAAI,KAAM,EAED,GACE,GAAK,GAAK,GAAK,GAAK,EAAO,EAAO,OAAO,QAG3C,EAAO,EAAU,OAAO,QAGxB,EAAO,KAAK,IAAI,EAAO,EAAM,OAAO,WAAa,GAI5D,KAAM,GAA4D,GAQ3D,AAAM,8CAA8C,AACzD,GACS,CACT,EAAqC,KAAK,IAQ/B,4CAA4C,IAGhD,QAAQ,IAAI,KA3nBb,iBAgoBV,QAAQ,KAAO,QAAQ,MAAQ,QAAQ,IACvC,QAAQ,MAAQ,QAAQ,OAAS,QAAQ",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(a){const h=new a.Logger("Audio manager"),f=["audio"],c={preload:!0,onplayerror:(u,e)=>h.error("Can't play an audio file: "+e),onloaderror:(u,e)=>h.error("Error while loading an audio file: "+e)},d=u=>u>1?1:u<0?0:u;class g{constructor(e,s,o,t){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=d(s),this._loop=o,this._rate=t}isLoaded(){return this._howl.state()==="loaded"}play(){if(this.isLoaded()){const e=this._howl.play(this._id===null?"__default":this._id);this._id=e,this._howl.volume(this._initialVolume,e),this._howl.loop(this._loop,e),this._howl.rate(a.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(s=>{this.on("play",s),s(e)}),this._oncePlay.forEach(s=>s(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play());return this}pause(){return this._id!==null&&this._howl.pause(this._id),this}stop(){return this._id!==null&&this._howl.stop(this._id),this}playing(){return(this._id!==null?this._howl.playing(this._id):!0)||!this.isLoaded()}paused(){return!this.playing()}stopped(){return this.paused()&&this.getSeek()===0}getRate(){return this._rate}setRate(e){return this._rate=e,this._id!==null&&(e=a.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id)),this}getLoop(){return this._loop}setLoop(e){return this._loop=e,this._id!==null&&this._howl.loop(e,this._id),this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){return this._initialVolume=d(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id),this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){return this._id!==null&&this._howl.mute(e,this._id),this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){return this._id!==null&&this._howl.seek(e,this._id),this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,s,o){return this._id!==null&&this._howl.pos(e,s,o,this._id),this}fade(e,s,o){return this._id!==null&&this._howl.fade(d(e),d(s),o,this._id),this}on(e,s){return e==="play"?this._id===null?this._onPlay.push(s):this._howl.on(e,s,this._id):this._id===null?this.once("play",()=>this.on(e,s)):this._howl.on(e,s,this._id),this}once(e,s){return e==="play"?this._id===null?this._oncePlay.push(s):this.playing()?s(this._id):this._howl.once(e,s,this._id):this._id===null?this.once("play",()=>this.once(e,s)):this._howl.once(e,s,this._id),this}off(e,s){return this._id!==null&&this._howl.off(e,s,this._id),this}}a.HowlerSound=g;class p{constructor(e){this._loadedMusics=new a.ResourceCache;this._loadedSounds=new a.ResourceCache;this._availableResources={};this._globalVolume=100;this._sounds={};this._musics={};this._freeSounds=[];this._freeMusics=[];this._pausedSounds=[];this._paused=!1;this._getAudioResource=e=>{const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e;const s=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){const o=s._freeSounds.concat(s._freeMusics);for(let t in s._sounds)s._sounds.hasOwnProperty(t)&&o.push(s._sounds[t]);for(let t in s._musics)s._musics.hasOwnProperty(t)&&o.push(s._musics[t]);for(let t=0;t<o.length;t++){const i=o[t];!i.paused()&&!i.stopped()&&(i.pause(),s._pausedSounds.push(i))}s._paused=!0},!1),document.addEventListener("resume",function(){for(let o=0;o<s._pausedSounds.length;o++){const t=s._pausedSounds[o];t.stopped()||t.play()}s._pausedSounds.length=0,s._paused=!1},!1)})}getResourceKinds(){return f}static clampRate(e){return e>4?4:e<.5?.5:e}_storeSoundInArray(e,s){for(let o=0,t=e.length;o<t;++o)if(!e[o]||e[o].stopped())return e[o]=s,s;return e.push(s),s}createHowlerSound(e,s,o,t,i){const l=s?this._loadedMusics:this._loadedSounds,r=this._getAudioResource(e);let n=l.get(r);if(!n){const _=r?r.file:e;n=new Howl(Object.assign({src:[this._resourceLoader.getFullUrl(_)],html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(_)},volume:0},c)),l.set(r,n)}return new a.HowlerSound(n,o,t,i)}loadAudio(e,s){const o=s?this._loadedMusics:this._loadedSounds,t=this._getAudioResource(e);o.get(t)||o.set(t,new Howl(Object.assign({src:[this._resourceLoader.getFullUrl(t.file)],html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(t.file)},volume:0},c)))}unloadAudio(e,s){const o=s?this._loadedMusics:this._loadedSounds,t=this._getAudioResource(e),i=o.get(t);if(!i)return;function l(r){for(let n in r)r[n]&&r[n]._howl===i&&(r[n].stop(),delete r[n])}l(this._freeMusics),l(this._freeSounds),l(Object.values(this._musics)),l(Object.values(this._sounds)),l(this._pausedSounds),i.unload(),o.delete(t)}unloadAll(){Howler.unload(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0,this._loadedMusics.clear(),this._loadedSounds.clear()}playSound(e,s,o,t){const i=this.createHowlerSound(e,!1,o/100,s,t);this._storeSoundInArray(this._freeSounds,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playSoundOnChannel(e,s,o,t,i){this._sounds[s]&&this._sounds[s].stop();const l=this.createHowlerSound(e,!1,t/100,o,i);this._sounds[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,s,o,t){const i=this.createHowlerSound(e,!0,o/100,s,t);this._storeSoundInArray(this._freeMusics,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playMusicOnChannel(e,s,o,t,i){this._musics[s]&&this._musics[s].stop();const l=this.createHowlerSound(e,!0,t/100,o,i);this._musics[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getMusicOnChannel(e){return this._musics[e]||null}setGlobalVolume(e){this._globalVolume=e,this._globalVolume>100&&(this._globalVolume=100),this._globalVolume<0&&(this._globalVolume=0),Howler.volume(this._globalVolume/100)}getGlobalVolume(){return this._globalVolume}clearAll(){Howler.stop(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0}async processResource(e){}async loadResource(e){const s=this._resourceLoader.getResource(e);if(!s){h.warn('Unable to find audio for resource "'+e+'".');return}if(s.file){if(this._availableResources[s.name])return;this._availableResources[s.name]=s}const o=(i,l)=>new Promise((r,n)=>{const _=l?this._loadedMusics:this._loadedSounds;_[i]=new Howl(Object.assign({},c,{src:[this._resourceLoader.getFullUrl(i)],onload:r,onloaderror:(S,w)=>n(w),html5:l,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(i)},volume:0}))}),t=s.file;if(s.preloadAsMusic)try{await o(t,!0)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}if(s.preloadAsSound)try{await o(t,!1)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}else if(s.preloadInCache||!s.preloadAsMusic)try{await new Promise((i,l)=>{const r=new XMLHttpRequest;r.withCredentials=this._resourceLoader.checkIfCredentialsRequired(t),r.addEventListener("load",i),r.addEventListener("error",n=>l("XHR error: "+t)),r.addEventListener("abort",n=>l("XHR abort: "+t)),r.open("GET",this._resourceLoader.getFullUrl(t)),r.send()})}catch(i){h.warn("There was an error while preloading an audio file: "+i)}}}a.HowlerSoundManager=p,a.SoundManager=p})(gdjs||(gdjs={}));
1
+ var gdjs;(function(a){const h=new a.Logger("Audio manager"),f=["audio"],c={preload:!0,onplayerror:(u,e)=>h.error("Can't play an audio file: "+e),onloaderror:(u,e)=>h.error("Error while loading an audio file: "+e)},d=u=>u>1?1:u<0?0:u;class g{constructor(e,s,t,o){this._id=null;this._oncePlay=[];this._onPlay=[];this._howl=e,this._initialVolume=d(s),this._loop=t,this._rate=o}isLoaded(){return this._howl.state()==="loaded"}play(){if(this.isLoaded()){const e=this._howl.play(this._id===null?"__default":this._id);this._id=e,this._howl.volume(this._initialVolume,e),this._howl.loop(this._loop,e),this._howl.rate(a.HowlerSoundManager.clampRate(this._rate),e),this._onPlay.forEach(s=>{this.on("play",s),s(e)}),this._oncePlay.forEach(s=>s(e)),this._onPlay=[],this._oncePlay=[]}else this._howl.once("load",()=>this.play());return this}pause(){return this._id!==null&&this._howl.pause(this._id),this}stop(){return this._id!==null&&this._howl.stop(this._id),this}playing(){return(this._id!==null?this._howl.playing(this._id):!0)||!this.isLoaded()}paused(){return!this.playing()}stopped(){return this.paused()&&this.getSeek()===0}getRate(){return this._rate}setRate(e){return this._rate=e,this._id!==null&&(e=a.HowlerSoundManager.clampRate(e),this._howl.rate(e,this._id)),this}getLoop(){return this._loop}setLoop(e){return this._loop=e,this._id!==null&&this._howl.loop(e,this._id),this}getVolume(){return this._id===null?this._initialVolume:this._howl.volume(this._id)}setVolume(e){return this._initialVolume=d(e),this._id!==null&&this._howl.volume(this._initialVolume,this._id),this}getMute(){return this._id===null?!1:this._howl.mute(this._id)}setMute(e){return this._id!==null&&this._howl.mute(e,this._id),this}getSeek(){return this._id===null?0:this._howl.seek(this._id)}setSeek(e){return this._id!==null&&this._howl.seek(e,this._id),this}getSpatialPosition(e){return this._id===null?0:this._howl.pos(this._id)[e==="x"?0:e==="y"?1:2]}setSpatialPosition(e,s,t){return this._id!==null&&this._howl.pos(e,s,t,this._id),this}fade(e,s,t){return this._id!==null&&this._howl.fade(d(e),d(s),t,this._id),this}on(e,s){return e==="play"?this._id===null?this._onPlay.push(s):this._howl.on(e,s,this._id):this._id===null?this.once("play",()=>this.on(e,s)):this._howl.on(e,s,this._id),this}once(e,s){return e==="play"?this._id===null?this._oncePlay.push(s):this.playing()?s(this._id):this._howl.once(e,s,this._id):this._id===null?this.once("play",()=>this.once(e,s)):this._howl.once(e,s,this._id),this}off(e,s){return this._id!==null&&this._howl.off(e,s,this._id),this}}a.HowlerSound=g;class p{constructor(e){this._loadedMusics=new a.ResourceCache;this._loadedSounds=new a.ResourceCache;this._availableResources={};this._globalVolume=100;this._sounds={};this._musics={};this._freeSounds=[];this._freeMusics=[];this._pausedSounds=[];this._paused=!1;this._getAudioResource=e=>{const s=this._resourceLoader.getResource(e);return s&&this.getResourceKinds().includes(s.kind)?s:{file:e,kind:"audio",metadata:"",name:e}};this._resourceLoader=e;const s=this;document.addEventListener("deviceready",function(){document.addEventListener("pause",function(){const t=s._freeSounds.concat(s._freeMusics);for(let o in s._sounds)s._sounds.hasOwnProperty(o)&&t.push(s._sounds[o]);for(let o in s._musics)s._musics.hasOwnProperty(o)&&t.push(s._musics[o]);for(let o=0;o<t.length;o++){const i=t[o];!i.paused()&&!i.stopped()&&(i.pause(),s._pausedSounds.push(i))}s._paused=!0},!1),document.addEventListener("resume",function(){try{for(let t=0;t<s._pausedSounds.length;t++){const o=s._pausedSounds[t];o.stopped()||o.play()}}catch(t){if(t.message&&typeof t.message=="string"&&t.message.startsWith("Maximum call stack size exceeded"))console.warn("An error occurred when resuming paused sounds while the game was in background:",t);else throw t}s._pausedSounds.length=0,s._paused=!1},!1)})}getResourceKinds(){return f}static clampRate(e){return e>4?4:e<.5?.5:e}_storeSoundInArray(e,s){for(let t=0,o=e.length;t<o;++t)if(!e[t]||e[t].stopped())return e[t]=s,s;return e.push(s),s}createHowlerSound(e,s,t,o,i){const l=s?this._loadedMusics:this._loadedSounds,r=this._getAudioResource(e);let n=l.get(r);if(!n){const _=r?r.file:e;n=new Howl(Object.assign({src:[this._resourceLoader.getFullUrl(_)],html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(_)},volume:0},c)),l.set(r,n)}return new a.HowlerSound(n,t,o,i)}loadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,o=this._getAudioResource(e);t.get(o)||t.set(o,new Howl(Object.assign({src:[this._resourceLoader.getFullUrl(o.file)],html5:s,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(o.file)},volume:0},c)))}unloadAudio(e,s){const t=s?this._loadedMusics:this._loadedSounds,o=this._getAudioResource(e),i=t.get(o);if(!i)return;function l(r){for(let n in r)r[n]&&r[n]._howl===i&&(r[n].stop(),delete r[n])}l(this._freeMusics),l(this._freeSounds),l(Object.values(this._musics)),l(Object.values(this._sounds)),l(this._pausedSounds),i.unload(),t.delete(o)}unloadAll(){Howler.unload(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0,this._loadedMusics.clear(),this._loadedSounds.clear()}playSound(e,s,t,o){const i=this.createHowlerSound(e,!1,t/100,s,o);this._storeSoundInArray(this._freeSounds,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playSoundOnChannel(e,s,t,o,i){this._sounds[s]&&this._sounds[s].stop();const l=this.createHowlerSound(e,!1,o/100,t,i);this._sounds[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getSoundOnChannel(e){return this._sounds[e]||null}playMusic(e,s,t,o){const i=this.createHowlerSound(e,!0,t/100,s,o);this._storeSoundInArray(this._freeMusics,i),i.once("play",()=>{this._paused&&(i.pause(),this._pausedSounds.push(i))}),i.play()}playMusicOnChannel(e,s,t,o,i){this._musics[s]&&this._musics[s].stop();const l=this.createHowlerSound(e,!0,o/100,t,i);this._musics[s]=l,l.once("play",()=>{this._paused&&(l.pause(),this._pausedSounds.push(l))}),l.play()}getMusicOnChannel(e){return this._musics[e]||null}setGlobalVolume(e){this._globalVolume=e,this._globalVolume>100&&(this._globalVolume=100),this._globalVolume<0&&(this._globalVolume=0),Howler.volume(this._globalVolume/100)}getGlobalVolume(){return this._globalVolume}clearAll(){Howler.stop(),this._freeSounds.length=0,this._freeMusics.length=0,this._sounds={},this._musics={},this._pausedSounds.length=0}async processResource(e){}async loadResource(e){const s=this._resourceLoader.getResource(e);if(!s){h.warn('Unable to find audio for resource "'+e+'".');return}if(s.file){if(this._availableResources[s.name])return;this._availableResources[s.name]=s}const t=(i,l)=>new Promise((r,n)=>{const _=l?this._loadedMusics:this._loadedSounds;_[i]=new Howl(Object.assign({},c,{src:[this._resourceLoader.getFullUrl(i)],onload:r,onloaderror:(y,w)=>n(w),html5:l,xhr:{withCredentials:this._resourceLoader.checkIfCredentialsRequired(i)},volume:0}))}),o=s.file;if(s.preloadAsMusic)try{await t(o,!0)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}if(s.preloadAsSound)try{await t(o,!1)}catch(i){h.warn("There was an error while preloading an audio file: "+i)}else if(s.preloadInCache||!s.preloadAsMusic)try{await new Promise((i,l)=>{const r=new XMLHttpRequest;r.withCredentials=this._resourceLoader.checkIfCredentialsRequired(o),r.addEventListener("load",i),r.addEventListener("error",n=>l("XHR error: "+o)),r.addEventListener("abort",n=>l("XHR abort: "+o)),r.open("GET",this._resourceLoader.getFullUrl(o)),r.send()})}catch(i){h.warn("There was an error while preloading an audio file: "+i)}}}a.HowlerSoundManager=p,a.SoundManager=p})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=howler-sound-manager.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/howler-sound-manager/howler-sound-manager.ts"],
4
- "sourcesContent": ["///<reference path='../types/howler'>\n/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Audio manager');\n\n const resourceKinds: Array<ResourceKind> = ['audio'];\n\n const HowlParameters: HowlOptions = {\n preload: true,\n onplayerror: (_, error) =>\n logger.error(\"Can't play an audio file: \" + error),\n onloaderror: (_, error) =>\n logger.error('Error while loading an audio file: ' + error),\n };\n\n /**\n * Ensure the volume is between 0 and 1.\n */\n const clampVolume = (volume: float): float => {\n if (volume > 1.0) {\n return 1.0;\n }\n if (volume < 0) {\n return 0;\n }\n return volume;\n };\n\n /**\n * A thin wrapper around a Howl object with:\n * * Handling of callbacks when the sound is not yet loaded.\n * * Automatic clamping when calling `setRate` to ensure a valid value is passed to Howler.js.\n * * Automatic clamping when calling `setVolume` so that the volume is always between 0 and 1.\n *\n * @memberof gdjs\n * @class HowlerSound\n */\n export class HowlerSound {\n /**\n * The ID of the played sound.\n */\n private _id: integer | null = null;\n\n /**\n * The Howl passed to the constructor.\n * It defines the sound file that is being played.\n */\n private _howl: Howl;\n\n /**\n * The **initial** volume at which the sound is being played.\n * Once the sound is started, this volume can be not in sync\n * (in the case the sound is faded by Howler), so volume must\n * be gotten from `this._howl` directly.\n *\n * This value is clamped between 0 and 1.\n */\n private _initialVolume: float;\n\n /**\n * Whether the sound is being played in a loop or not.\n */\n private _loop: boolean;\n\n /**\n * The rate (speed) the sound is being played at.\n * This value is not clamped, though technically Howler.js will only\n * accepts values between a specific range (so we clamp this when\n * passing it to Howler.js, but keep the original value here).\n */\n private _rate: float;\n\n /**\n * An array of callbacks to call once the sound starts to play.\n */\n private _oncePlay: Array<HowlCallback> = [];\n\n /**\n * An array of callbacks to call everytime the sound starts to play.\n */\n private _onPlay: Array<HowlCallback> = [];\n\n constructor(howl: Howl, volume: float, loop: boolean, rate: float) {\n this._howl = howl;\n this._initialVolume = clampVolume(volume);\n this._loop = loop;\n this._rate = rate;\n }\n\n /**\n * Returns true if the associated howl is fully loaded.\n */\n isLoaded(): boolean {\n return this._howl.state() === 'loaded';\n }\n\n /**\n * Begins playback of the sound, or if the Howl is still loading, schedule playing for once it loads.\n * @returns The current instance for chaining.\n */\n play(): this {\n if (this.isLoaded()) {\n const newID = this._howl.play(\n this._id === null ? '__default' : this._id\n );\n this._id = newID;\n\n // Set the howl properties as soon as the sound is played and we have its ID.\n this._howl.volume(this._initialVolume, newID); // this._initialVolume is already clamped between 0 and 1.\n this._howl.loop(this._loop, newID);\n // this._rate is not clamped, but we need to clamp it when passing it to Howler.js as it\n // only supports a specific range.\n this._howl.rate(gdjs.HowlerSoundManager.clampRate(this._rate), newID);\n\n // Manually handle the play event before we have an ID.\n // Before loading, howler won't register events as without an ID we cannot set a listener.\n // Once we have an ID, we can transfer control of the events to howler.\n // We also need to call them once as Howler doesn't for the first play event.\n this._onPlay.forEach((func) => {\n // Transfer the event to howler now that we have an ID\n this.on('play', func);\n func(newID);\n });\n this._oncePlay.forEach((func) => func(newID));\n this._onPlay = [];\n this._oncePlay = [];\n } else this._howl.once('load', () => this.play()); // Play only once the howl is fully loaded\n\n return this;\n }\n\n /**\n * Pauses playback of the sound, saving the seek of playback.\n * @returns The current instance for chaining.\n */\n pause(): this {\n if (this._id !== null) this._howl.pause(this._id);\n return this;\n }\n\n /**\n * Stops playback of the sound, resetting seek to 0.\n * @returns The current instance for chaining.\n */\n stop(): this {\n if (this._id !== null) this._howl.stop(this._id);\n return this;\n }\n\n /**\n * Check if the sound is currently playing.\n * Note that a loading sound is considered as playing (as it will be\n * played as soon as it's loaded). To avoid loading at runtime, prefer\n * to preload the sounds.\n */\n playing(): boolean {\n return (\n (this._id !== null ? this._howl.playing(this._id) : true) ||\n !this.isLoaded() // Loading is considered playing\n );\n }\n\n /**\n * Check if the sound is currently paused.\n */\n paused(): boolean {\n return !this.playing();\n }\n\n /**\n * Check if the sound is currently stopped.\n */\n stopped(): boolean {\n return this.paused() && this.getSeek() === 0;\n }\n\n /**\n * Get the sound playback rate. This 1 for the default speed.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n */\n getRate(): float {\n return this._rate;\n }\n\n /**\n * Set the playback rate.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n * @returns The current instance for chaining.\n */\n setRate(rate: float): this {\n this._rate = rate;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) {\n rate = gdjs.HowlerSoundManager.clampRate(rate);\n this._howl.rate(rate, this._id);\n }\n return this;\n }\n\n /**\n * Get if the sound is looping.\n */\n getLoop(): boolean {\n return this._loop;\n }\n\n /**\n * Set if the sound is looping.\n * @returns The current instance for chaining.\n */\n setLoop(loop: boolean): this {\n this._loop = loop;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.loop(loop, this._id);\n return this;\n }\n\n //TODO: Replace float type in those 2 methods with RangeOf<0..1> once it is standardized (https://github.com/Microsoft/TypeScript/issues/15480)\n /**\n * Get the sound volume.\n * @returns A float from 0 to 1.\n */\n getVolume(): float {\n if (this._id === null) return this._initialVolume;\n return this._howl.volume(this._id);\n }\n\n /**\n * Set the sound volume.\n * @param volume A float from 0 to 1. The value is clamped if too high or too low.\n * @returns The current instance for chaining.\n */\n setVolume(volume: float): this {\n this._initialVolume = clampVolume(volume);\n\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.volume(this._initialVolume, this._id);\n return this;\n }\n\n /**\n * Get if the sound is muted.\n */\n getMute(): boolean {\n if (this._id === null) return false;\n return this._howl.mute(this._id);\n }\n\n /**\n * Set if the sound is muted.\n * @returns The current instance for chaining.\n */\n setMute(mute: boolean): this {\n if (this._id !== null) this._howl.mute(mute, this._id);\n return this;\n }\n\n /**\n * Get the sound seek.\n */\n getSeek(): float {\n if (this._id === null) return 0;\n return this._howl.seek(this._id);\n }\n\n /**\n * Set the sound seek.\n * @returns The current instance for chaining.\n */\n setSeek(seek: float): this {\n if (this._id !== null) this._howl.seek(seek, this._id);\n return this;\n }\n\n /**\n * Get the sound spatial position.\n */\n getSpatialPosition(axis: 'x' | 'y' | 'z'): float {\n if (this._id === null) return 0;\n return this._howl.pos(this._id)[axis === 'x' ? 0 : axis === 'y' ? 1 : 2];\n }\n\n /**\n * Set the sound spatial position.\n * @returns The current instance for chaining.\n */\n setSpatialPosition(x: float, y: float, z: float): this {\n if (this._id !== null) this._howl.pos(x, y, z, this._id);\n return this;\n }\n\n /**\n * Fade the volume sound.\n * @returns The current instance for chaining.\n */\n fade(from: float, to: float, duration: float): this {\n if (this._id !== null)\n this._howl.fade(clampVolume(from), clampVolume(to), duration, this._id);\n return this;\n }\n\n /**\n * Adds an event listener to the howl.\n */\n on(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._onPlay.push(handler);\n } else {\n this._howl.on(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.on(event, handler));\n else this._howl.on(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Adds an event listener to the howl that removes itself after being called.\n * If the event is `play` and the sound is being played, the handler is\n * called synchronously.\n */\n once(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._oncePlay.push(handler);\n } else if (this.playing()) {\n // Immediately call the handler if the sound is already playing.\n // This is useful for sounds that were just started and have a `.once('play', ...)`\n // handler added on them to set up the volume/rate/loop. If we don't do it\n // synchronously, the sound can play for a tiny bit at the default volume and rate.\n // See https://github.com/4ian/GDevelop/issues/2490.\n handler(this._id);\n } else {\n this._howl.once(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.once(event, handler));\n else this._howl.once(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Removes an event listener to the howl.\n */\n off(event: HowlEvent, handler: HowlCallback): this {\n if (this._id !== null) this._howl.off(event, handler, this._id);\n return this;\n }\n }\n\n /**\n * HowlerSoundManager is used to manage the sounds and musics of a RuntimeScene.\n *\n * It is basically a container to associate channels to sounds and keep a list\n * of all sounds being played.\n */\n export class HowlerSoundManager {\n _loadedMusics = new gdjs.ResourceCache<Howl>();\n _loadedSounds = new gdjs.ResourceCache<Howl>();\n _availableResources: Record<string, ResourceData> = {};\n _globalVolume: float = 100;\n _sounds: Record<integer, HowlerSound> = {};\n _musics: Record<integer, HowlerSound> = {};\n _freeSounds: HowlerSound[] = []; // Sounds without an assigned channel.\n _freeMusics: HowlerSound[] = []; // Musics without an assigned channel.\n\n /** Paused sounds or musics that should be played once the game is resumed. */\n _pausedSounds: HowlerSound[] = [];\n _paused: boolean = false;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resources The resources data of the game.\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n const that = this;\n document.addEventListener('deviceready', function () {\n // pause/resume sounds in Cordova when the app is being paused/resumed\n document.addEventListener(\n 'pause',\n function () {\n const soundList = that._freeSounds.concat(that._freeMusics);\n for (let key in that._sounds) {\n if (that._sounds.hasOwnProperty(key)) {\n soundList.push(that._sounds[key]);\n }\n }\n for (let key in that._musics) {\n if (that._musics.hasOwnProperty(key)) {\n soundList.push(that._musics[key]);\n }\n }\n for (let i = 0; i < soundList.length; i++) {\n const sound = soundList[i];\n if (!sound.paused() && !sound.stopped()) {\n sound.pause();\n that._pausedSounds.push(sound);\n }\n }\n that._paused = true;\n },\n false\n );\n document.addEventListener(\n 'resume',\n function () {\n for (let i = 0; i < that._pausedSounds.length; i++) {\n const sound = that._pausedSounds[i];\n if (!sound.stopped()) {\n sound.play();\n }\n }\n that._pausedSounds.length = 0;\n that._paused = false;\n },\n false\n );\n });\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Ensure rate is in a range valid for Howler.js\n * @return The clamped rate\n */\n static clampRate(rate: float): float {\n if (rate > 4.0) {\n return 4.0;\n }\n if (rate < 0.5) {\n return 0.5;\n }\n return rate;\n }\n\n /**\n * Return the file associated to the given sound name.\n *\n * Names and files are loaded from resources when preloadAudio is called. If no\n * file is associated to the given name, then the name will be considered as a\n * filename and will be returned.\n *\n * @return The associated resource\n */\n private _getAudioResource = (resourceName: string): ResourceData => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : ({\n file: resourceName,\n kind: 'audio',\n metadata: '',\n name: resourceName,\n } as ResourceData);\n };\n\n /**\n * Store the sound in the specified array, put it at the first index that\n * is free, or add it at the end if no element is free\n * (\"free\" means that the gdjs.HowlerSound can be destroyed).\n *\n * @param arr The array containing the sounds.\n * @param arr The gdjs.HowlerSound to add.\n * @return The gdjs.HowlerSound that have been added (i.e: the second parameter).\n */\n private _storeSoundInArray(\n arr: Array<HowlerSound>,\n sound: HowlerSound\n ): HowlerSound {\n // Try to recycle an old sound.\n for (let i = 0, len = arr.length; i < len; ++i) {\n if (!arr[i] || arr[i].stopped()) {\n arr[i] = sound;\n return sound;\n }\n }\n\n arr.push(sound);\n return sound;\n }\n\n /**\n * Creates a new gdjs.HowlerSound using preloaded/cached Howl instances.\n * @param soundName The name of the file or resource to play.\n * @param isMusic True if a music, false if a sound.\n * @param volume Between 0 and 1.\n * @param loop True if it should be played looping.\n * @param rate speed at which it is played.\n */\n createHowlerSound(\n soundName: string,\n isMusic: boolean,\n volume: float,\n loop: boolean,\n rate: float\n ): HowlerSound {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n let howl = cacheContainer.get(resource);\n if (!howl) {\n const fileName = resource ? resource.file : soundName;\n howl = new Howl(\n Object.assign(\n {\n src: [this._resourceLoader.getFullUrl(fileName)],\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n fileName\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n );\n cacheContainer.set(resource, howl);\n }\n\n return new gdjs.HowlerSound(howl, volume, loop, rate);\n }\n\n /**\n * Preloads a sound or a music in memory.\n * @param soundName The name of the file or resource to preload.\n * @param isMusic True if a music, false if a sound.\n */\n loadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n // Do not reload if it is already loaded.\n if (cacheContainer.get(resource)) {\n return;\n }\n\n cacheContainer.set(\n resource,\n new Howl(\n Object.assign(\n {\n src: [this._resourceLoader.getFullUrl(resource.file)],\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n )\n );\n }\n\n /**\n * Unloads a sound or a music from memory. This will stop any sound/music using it.\n * @param soundName The name of the file or resource to unload.\n * @param isMusic True if a music, false if a sound.\n */\n unloadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n const howl = cacheContainer.get(resource);\n if (!howl) {\n return;\n }\n\n // Make sure any sound using the howl is deleted so\n // that the howl can be garbage collected\n // and no weird \"zombies\" using the unloaded howl can exist.\n function clearContainer(howlerSoundContainer: HowlerSound[]) {\n for (let i in howlerSoundContainer) {\n if (\n howlerSoundContainer[i] &&\n //@ts-ignore We really need to access the raw howl here.\n howlerSoundContainer[i]._howl === howl\n ) {\n howlerSoundContainer[i].stop();\n delete howlerSoundContainer[i];\n }\n }\n }\n\n clearContainer(this._freeMusics);\n clearContainer(this._freeSounds);\n clearContainer(Object.values(this._musics));\n clearContainer(Object.values(this._sounds));\n clearContainer(this._pausedSounds);\n\n howl.unload();\n cacheContainer.delete(resource);\n }\n\n /**\n * Unloads all audio from memory.\n * This will clear the Howl cache.\n * This will also stop any running music or sounds.\n */\n unloadAll() {\n Howler.unload();\n\n // Clean up old sounds that still have the dead Howl instances.\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n this._loadedMusics.clear();\n this._loadedSounds.clear();\n }\n\n playSound(soundName: string, loop: boolean, volume: float, pitch: float) {\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeSounds, sound);\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n playSoundOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._sounds[channel]) this._sounds[channel].stop();\n\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._sounds[channel] = sound;\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n getSoundOnChannel(channel: integer): HowlerSound | null {\n return this._sounds[channel] || null;\n }\n\n playMusic(soundName: string, loop: boolean, volume: float, pitch: float) {\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeMusics, music);\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n playMusicOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._musics[channel]) this._musics[channel].stop();\n\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._musics[channel] = music;\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n getMusicOnChannel(channel: integer): HowlerSound | null {\n return this._musics[channel] || null;\n }\n\n setGlobalVolume(volume: float): void {\n this._globalVolume = volume;\n if (this._globalVolume > 100) {\n this._globalVolume = 100;\n }\n if (this._globalVolume < 0) {\n this._globalVolume = 0;\n }\n Howler.volume(this._globalVolume / 100);\n }\n\n getGlobalVolume(): float {\n return this._globalVolume;\n }\n\n clearAll() {\n Howler.stop();\n\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because sounds are light enough to be parsed in background.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find audio for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (resource.file) {\n if (this._availableResources[resource.name]) {\n return;\n }\n\n this._availableResources[resource.name] = resource;\n }\n\n const preloadAudioFile = (\n file: string,\n isMusic: boolean\n ): Promise<number> => {\n return new Promise((resolve, reject) => {\n const container = isMusic ? this._loadedMusics : this._loadedSounds;\n container[file] = new Howl(\n Object.assign({}, HowlParameters, {\n src: [this._resourceLoader.getFullUrl(file)],\n onload: resolve,\n onloaderror: (soundId: number, error?: string) => reject(error),\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n })\n );\n });\n };\n\n const file = resource.file;\n if (resource.preloadAsMusic) {\n try {\n await preloadAudioFile(file, /* isMusic= */ true);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n\n if (resource.preloadAsSound) {\n try {\n await preloadAudioFile(file, /* isMusic= */ false);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n } else if (\n resource.preloadInCache ||\n // Force downloading of sounds.\n // TODO Decide if sounds should be allowed to be downloaded after the scene starts.\n // - they should be requested automatically at the end of the scene loading\n // - they will be downloaded while the scene is playing\n // - other scenes will be pre-loaded only when all the sounds for the current scene are in cache\n !resource.preloadAsMusic\n ) {\n // preloading as sound already does a XHR request, hence \"else if\"\n try {\n await new Promise((resolve, reject) => {\n const sound = new XMLHttpRequest();\n sound.withCredentials = this._resourceLoader.checkIfCredentialsRequired(\n file\n );\n sound.addEventListener('load', resolve);\n sound.addEventListener('error', (_) =>\n reject('XHR error: ' + file)\n );\n sound.addEventListener('abort', (_) =>\n reject('XHR abort: ' + file)\n );\n sound.open('GET', this._resourceLoader.getFullUrl(file));\n sound.send();\n });\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n }\n }\n\n // Register the class to let the engine use it.\n export const SoundManager = HowlerSoundManager;\n export type SoundManager = HowlerSoundManager;\n}\n"],
5
- "mappings": "AAMA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,iBAEzB,EAAqC,CAAC,SAEtC,EAA8B,CAClC,QAAS,GACT,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,6BAA+B,GAC9C,YAAa,CAAC,EAAG,IACf,EAAO,MAAM,sCAAwC,IAMnD,EAAc,AAAC,GACf,EAAS,EACJ,EAEL,EAAS,EACJ,EAEF,EAYF,OAAkB,CA6CvB,YAAY,EAAY,EAAe,EAAe,EAAa,CAzC3D,SAAsB,KAkCtB,eAAiC,GAKjC,aAA+B,GAGrC,KAAK,MAAQ,EACb,KAAK,eAAiB,EAAY,GAClC,KAAK,MAAQ,EACb,KAAK,MAAQ,E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,CACA,EAAO,KACL,sDAAwD,GAK9D,GAAI,EAAS,eACX,GAAI,CACF,KAAM,GAAiB,EAAqB,UACrC,EAAP,CACA,EAAO,KACL,sDAAwD,WAI5D,EAAS,gBAMT,CAAC,EAAS,eAGV,GAAI,CACF,KAAM,IAAI,SAAQ,CAAC,EAAS,IAAW,CACrC,KAAM,GAAQ,GAAI,gBAClB,EAAM,gBAAkB,KAAK,gBAAgB,2BAC3C,GAEF,EAAM,iBAAiB,OAAQ,GAC/B,EAAM,iBAAiB,QAAS,AAAC,GAC/B,EAAO,cAAgB,IAEzB,EAAM,iBAAiB,QAAS,AAAC,GAC/B,EAAO,cAAgB,IAEzB,EAAM,KAAK,MAAO,KAAK,gBAAgB,WAAW,IAClD,EAAM,eAED,EAAP,CACA,EAAO,KACL,sDAAwD,KAne3D,EAAM,qBA2eA,eAAe,IAp1BpB",
4
+ "sourcesContent": ["///<reference path='../types/howler'>\n/*\n * GDevelop JS Platform\n * Copyright 2013-present Florian Rival (Florian.Rival@gmail.com). All rights reserved.\n * This project is released under the MIT License.\n */\nnamespace gdjs {\n const logger = new gdjs.Logger('Audio manager');\n\n const resourceKinds: Array<ResourceKind> = ['audio'];\n\n const HowlParameters: HowlOptions = {\n preload: true,\n onplayerror: (_, error) =>\n logger.error(\"Can't play an audio file: \" + error),\n onloaderror: (_, error) =>\n logger.error('Error while loading an audio file: ' + error),\n };\n\n /**\n * Ensure the volume is between 0 and 1.\n */\n const clampVolume = (volume: float): float => {\n if (volume > 1.0) {\n return 1.0;\n }\n if (volume < 0) {\n return 0;\n }\n return volume;\n };\n\n /**\n * A thin wrapper around a Howl object with:\n * * Handling of callbacks when the sound is not yet loaded.\n * * Automatic clamping when calling `setRate` to ensure a valid value is passed to Howler.js.\n * * Automatic clamping when calling `setVolume` so that the volume is always between 0 and 1.\n *\n * @memberof gdjs\n * @class HowlerSound\n */\n export class HowlerSound {\n /**\n * The ID of the played sound.\n */\n private _id: integer | null = null;\n\n /**\n * The Howl passed to the constructor.\n * It defines the sound file that is being played.\n */\n private _howl: Howl;\n\n /**\n * The **initial** volume at which the sound is being played.\n * Once the sound is started, this volume can be not in sync\n * (in the case the sound is faded by Howler), so volume must\n * be gotten from `this._howl` directly.\n *\n * This value is clamped between 0 and 1.\n */\n private _initialVolume: float;\n\n /**\n * Whether the sound is being played in a loop or not.\n */\n private _loop: boolean;\n\n /**\n * The rate (speed) the sound is being played at.\n * This value is not clamped, though technically Howler.js will only\n * accepts values between a specific range (so we clamp this when\n * passing it to Howler.js, but keep the original value here).\n */\n private _rate: float;\n\n /**\n * An array of callbacks to call once the sound starts to play.\n */\n private _oncePlay: Array<HowlCallback> = [];\n\n /**\n * An array of callbacks to call everytime the sound starts to play.\n */\n private _onPlay: Array<HowlCallback> = [];\n\n constructor(howl: Howl, volume: float, loop: boolean, rate: float) {\n this._howl = howl;\n this._initialVolume = clampVolume(volume);\n this._loop = loop;\n this._rate = rate;\n }\n\n /**\n * Returns true if the associated howl is fully loaded.\n */\n isLoaded(): boolean {\n return this._howl.state() === 'loaded';\n }\n\n /**\n * Begins playback of the sound, or if the Howl is still loading, schedule playing for once it loads.\n * @returns The current instance for chaining.\n */\n play(): this {\n if (this.isLoaded()) {\n const newID = this._howl.play(\n this._id === null ? '__default' : this._id\n );\n this._id = newID;\n\n // Set the howl properties as soon as the sound is played and we have its ID.\n this._howl.volume(this._initialVolume, newID); // this._initialVolume is already clamped between 0 and 1.\n this._howl.loop(this._loop, newID);\n // this._rate is not clamped, but we need to clamp it when passing it to Howler.js as it\n // only supports a specific range.\n this._howl.rate(gdjs.HowlerSoundManager.clampRate(this._rate), newID);\n\n // Manually handle the play event before we have an ID.\n // Before loading, howler won't register events as without an ID we cannot set a listener.\n // Once we have an ID, we can transfer control of the events to howler.\n // We also need to call them once as Howler doesn't for the first play event.\n this._onPlay.forEach((func) => {\n // Transfer the event to howler now that we have an ID\n this.on('play', func);\n func(newID);\n });\n this._oncePlay.forEach((func) => func(newID));\n this._onPlay = [];\n this._oncePlay = [];\n } else this._howl.once('load', () => this.play()); // Play only once the howl is fully loaded\n\n return this;\n }\n\n /**\n * Pauses playback of the sound, saving the seek of playback.\n * @returns The current instance for chaining.\n */\n pause(): this {\n if (this._id !== null) this._howl.pause(this._id);\n return this;\n }\n\n /**\n * Stops playback of the sound, resetting seek to 0.\n * @returns The current instance for chaining.\n */\n stop(): this {\n if (this._id !== null) this._howl.stop(this._id);\n return this;\n }\n\n /**\n * Check if the sound is currently playing.\n * Note that a loading sound is considered as playing (as it will be\n * played as soon as it's loaded). To avoid loading at runtime, prefer\n * to preload the sounds.\n */\n playing(): boolean {\n return (\n (this._id !== null ? this._howl.playing(this._id) : true) ||\n !this.isLoaded() // Loading is considered playing\n );\n }\n\n /**\n * Check if the sound is currently paused.\n */\n paused(): boolean {\n return !this.playing();\n }\n\n /**\n * Check if the sound is currently stopped.\n */\n stopped(): boolean {\n return this.paused() && this.getSeek() === 0;\n }\n\n /**\n * Get the sound playback rate. This 1 for the default speed.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n */\n getRate(): float {\n return this._rate;\n }\n\n /**\n * Set the playback rate.\n * This value is not clamped (any value greater than 0 is valid),\n * but the underlying audio system might not play the sound at the required\n * rate if it's very low or very high.\n * @returns The current instance for chaining.\n */\n setRate(rate: float): this {\n this._rate = rate;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) {\n rate = gdjs.HowlerSoundManager.clampRate(rate);\n this._howl.rate(rate, this._id);\n }\n return this;\n }\n\n /**\n * Get if the sound is looping.\n */\n getLoop(): boolean {\n return this._loop;\n }\n\n /**\n * Set if the sound is looping.\n * @returns The current instance for chaining.\n */\n setLoop(loop: boolean): this {\n this._loop = loop;\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.loop(loop, this._id);\n return this;\n }\n\n //TODO: Replace float type in those 2 methods with RangeOf<0..1> once it is standardized (https://github.com/Microsoft/TypeScript/issues/15480)\n /**\n * Get the sound volume.\n * @returns A float from 0 to 1.\n */\n getVolume(): float {\n if (this._id === null) return this._initialVolume;\n return this._howl.volume(this._id);\n }\n\n /**\n * Set the sound volume.\n * @param volume A float from 0 to 1. The value is clamped if too high or too low.\n * @returns The current instance for chaining.\n */\n setVolume(volume: float): this {\n this._initialVolume = clampVolume(volume);\n\n // If the sound has already started playing, then change the value directly.\n if (this._id !== null) this._howl.volume(this._initialVolume, this._id);\n return this;\n }\n\n /**\n * Get if the sound is muted.\n */\n getMute(): boolean {\n if (this._id === null) return false;\n return this._howl.mute(this._id);\n }\n\n /**\n * Set if the sound is muted.\n * @returns The current instance for chaining.\n */\n setMute(mute: boolean): this {\n if (this._id !== null) this._howl.mute(mute, this._id);\n return this;\n }\n\n /**\n * Get the sound seek.\n */\n getSeek(): float {\n if (this._id === null) return 0;\n return this._howl.seek(this._id);\n }\n\n /**\n * Set the sound seek.\n * @returns The current instance for chaining.\n */\n setSeek(seek: float): this {\n if (this._id !== null) this._howl.seek(seek, this._id);\n return this;\n }\n\n /**\n * Get the sound spatial position.\n */\n getSpatialPosition(axis: 'x' | 'y' | 'z'): float {\n if (this._id === null) return 0;\n return this._howl.pos(this._id)[axis === 'x' ? 0 : axis === 'y' ? 1 : 2];\n }\n\n /**\n * Set the sound spatial position.\n * @returns The current instance for chaining.\n */\n setSpatialPosition(x: float, y: float, z: float): this {\n if (this._id !== null) this._howl.pos(x, y, z, this._id);\n return this;\n }\n\n /**\n * Fade the volume sound.\n * @returns The current instance for chaining.\n */\n fade(from: float, to: float, duration: float): this {\n if (this._id !== null)\n this._howl.fade(clampVolume(from), clampVolume(to), duration, this._id);\n return this;\n }\n\n /**\n * Adds an event listener to the howl.\n */\n on(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._onPlay.push(handler);\n } else {\n this._howl.on(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.on(event, handler));\n else this._howl.on(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Adds an event listener to the howl that removes itself after being called.\n * If the event is `play` and the sound is being played, the handler is\n * called synchronously.\n */\n once(event: HowlEvent, handler: HowlCallback): this {\n if (event === 'play') {\n if (this._id === null) {\n this._oncePlay.push(handler);\n } else if (this.playing()) {\n // Immediately call the handler if the sound is already playing.\n // This is useful for sounds that were just started and have a `.once('play', ...)`\n // handler added on them to set up the volume/rate/loop. If we don't do it\n // synchronously, the sound can play for a tiny bit at the default volume and rate.\n // See https://github.com/4ian/GDevelop/issues/2490.\n handler(this._id);\n } else {\n this._howl.once(event, handler, this._id);\n }\n } else if (this._id === null)\n this.once('play', () => this.once(event, handler));\n else this._howl.once(event, handler, this._id);\n\n return this;\n }\n\n /**\n * Removes an event listener to the howl.\n */\n off(event: HowlEvent, handler: HowlCallback): this {\n if (this._id !== null) this._howl.off(event, handler, this._id);\n return this;\n }\n }\n\n /**\n * HowlerSoundManager is used to manage the sounds and musics of a RuntimeScene.\n *\n * It is basically a container to associate channels to sounds and keep a list\n * of all sounds being played.\n */\n export class HowlerSoundManager {\n _loadedMusics = new gdjs.ResourceCache<Howl>();\n _loadedSounds = new gdjs.ResourceCache<Howl>();\n _availableResources: Record<string, ResourceData> = {};\n _globalVolume: float = 100;\n _sounds: Record<integer, HowlerSound> = {};\n _musics: Record<integer, HowlerSound> = {};\n _freeSounds: HowlerSound[] = []; // Sounds without an assigned channel.\n _freeMusics: HowlerSound[] = []; // Musics without an assigned channel.\n\n /** Paused sounds or musics that should be played once the game is resumed. */\n _pausedSounds: HowlerSound[] = [];\n _paused: boolean = false;\n\n _resourceLoader: gdjs.ResourceLoader;\n\n /**\n * @param resources The resources data of the game.\n * @param resourceLoader The resources loader of the game.\n */\n constructor(resourceLoader: gdjs.ResourceLoader) {\n this._resourceLoader = resourceLoader;\n\n const that = this;\n document.addEventListener('deviceready', function () {\n // pause/resume sounds in Cordova when the app is being paused/resumed\n document.addEventListener(\n 'pause',\n function () {\n const soundList = that._freeSounds.concat(that._freeMusics);\n for (let key in that._sounds) {\n if (that._sounds.hasOwnProperty(key)) {\n soundList.push(that._sounds[key]);\n }\n }\n for (let key in that._musics) {\n if (that._musics.hasOwnProperty(key)) {\n soundList.push(that._musics[key]);\n }\n }\n for (let i = 0; i < soundList.length; i++) {\n const sound = soundList[i];\n if (!sound.paused() && !sound.stopped()) {\n sound.pause();\n that._pausedSounds.push(sound);\n }\n }\n that._paused = true;\n },\n false\n );\n document.addEventListener(\n 'resume',\n function () {\n try {\n for (let i = 0; i < that._pausedSounds.length; i++) {\n const sound = that._pausedSounds[i];\n if (!sound.stopped()) {\n sound.play();\n }\n }\n } catch (error) {\n if (\n error.message &&\n typeof error.message === 'string' &&\n error.message.startsWith('Maximum call stack size exceeded')\n ) {\n console.warn(\n 'An error occurred when resuming paused sounds while the game was in background:',\n error\n );\n } else {\n throw error;\n }\n }\n that._pausedSounds.length = 0;\n that._paused = false;\n },\n false\n );\n });\n }\n\n getResourceKinds(): ResourceKind[] {\n return resourceKinds;\n }\n\n /**\n * Ensure rate is in a range valid for Howler.js\n * @return The clamped rate\n */\n static clampRate(rate: float): float {\n if (rate > 4.0) {\n return 4.0;\n }\n if (rate < 0.5) {\n return 0.5;\n }\n return rate;\n }\n\n /**\n * Return the file associated to the given sound name.\n *\n * Names and files are loaded from resources when preloadAudio is called. If no\n * file is associated to the given name, then the name will be considered as a\n * filename and will be returned.\n *\n * @return The associated resource\n */\n private _getAudioResource = (resourceName: string): ResourceData => {\n const resource = this._resourceLoader.getResource(resourceName);\n return resource && this.getResourceKinds().includes(resource.kind)\n ? resource\n : ({\n file: resourceName,\n kind: 'audio',\n metadata: '',\n name: resourceName,\n } as ResourceData);\n };\n\n /**\n * Store the sound in the specified array, put it at the first index that\n * is free, or add it at the end if no element is free\n * (\"free\" means that the gdjs.HowlerSound can be destroyed).\n *\n * @param arr The array containing the sounds.\n * @param arr The gdjs.HowlerSound to add.\n * @return The gdjs.HowlerSound that have been added (i.e: the second parameter).\n */\n private _storeSoundInArray(\n arr: Array<HowlerSound>,\n sound: HowlerSound\n ): HowlerSound {\n // Try to recycle an old sound.\n for (let i = 0, len = arr.length; i < len; ++i) {\n if (!arr[i] || arr[i].stopped()) {\n arr[i] = sound;\n return sound;\n }\n }\n\n arr.push(sound);\n return sound;\n }\n\n /**\n * Creates a new gdjs.HowlerSound using preloaded/cached Howl instances.\n * @param soundName The name of the file or resource to play.\n * @param isMusic True if a music, false if a sound.\n * @param volume Between 0 and 1.\n * @param loop True if it should be played looping.\n * @param rate speed at which it is played.\n */\n createHowlerSound(\n soundName: string,\n isMusic: boolean,\n volume: float,\n loop: boolean,\n rate: float\n ): HowlerSound {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n let howl = cacheContainer.get(resource);\n if (!howl) {\n const fileName = resource ? resource.file : soundName;\n howl = new Howl(\n Object.assign(\n {\n src: [this._resourceLoader.getFullUrl(fileName)],\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n fileName\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n );\n cacheContainer.set(resource, howl);\n }\n\n return new gdjs.HowlerSound(howl, volume, loop, rate);\n }\n\n /**\n * Preloads a sound or a music in memory.\n * @param soundName The name of the file or resource to preload.\n * @param isMusic True if a music, false if a sound.\n */\n loadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n // Do not reload if it is already loaded.\n if (cacheContainer.get(resource)) {\n return;\n }\n\n cacheContainer.set(\n resource,\n new Howl(\n Object.assign(\n {\n src: [this._resourceLoader.getFullUrl(resource.file)],\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n resource.file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n },\n HowlParameters\n )\n )\n );\n }\n\n /**\n * Unloads a sound or a music from memory. This will stop any sound/music using it.\n * @param soundName The name of the file or resource to unload.\n * @param isMusic True if a music, false if a sound.\n */\n unloadAudio(soundName: string, isMusic: boolean) {\n const cacheContainer = isMusic ? this._loadedMusics : this._loadedSounds;\n const resource = this._getAudioResource(soundName);\n\n const howl = cacheContainer.get(resource);\n if (!howl) {\n return;\n }\n\n // Make sure any sound using the howl is deleted so\n // that the howl can be garbage collected\n // and no weird \"zombies\" using the unloaded howl can exist.\n function clearContainer(howlerSoundContainer: HowlerSound[]) {\n for (let i in howlerSoundContainer) {\n if (\n howlerSoundContainer[i] &&\n //@ts-ignore We really need to access the raw howl here.\n howlerSoundContainer[i]._howl === howl\n ) {\n howlerSoundContainer[i].stop();\n delete howlerSoundContainer[i];\n }\n }\n }\n\n clearContainer(this._freeMusics);\n clearContainer(this._freeSounds);\n clearContainer(Object.values(this._musics));\n clearContainer(Object.values(this._sounds));\n clearContainer(this._pausedSounds);\n\n howl.unload();\n cacheContainer.delete(resource);\n }\n\n /**\n * Unloads all audio from memory.\n * This will clear the Howl cache.\n * This will also stop any running music or sounds.\n */\n unloadAll() {\n Howler.unload();\n\n // Clean up old sounds that still have the dead Howl instances.\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n this._loadedMusics.clear();\n this._loadedSounds.clear();\n }\n\n playSound(soundName: string, loop: boolean, volume: float, pitch: float) {\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeSounds, sound);\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n playSoundOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._sounds[channel]) this._sounds[channel].stop();\n\n const sound = this.createHowlerSound(\n soundName,\n /* isMusic= */ false,\n volume / 100,\n loop,\n pitch\n );\n this._sounds[channel] = sound;\n sound.once('play', () => {\n if (this._paused) {\n sound.pause();\n this._pausedSounds.push(sound);\n }\n });\n sound.play();\n }\n\n getSoundOnChannel(channel: integer): HowlerSound | null {\n return this._sounds[channel] || null;\n }\n\n playMusic(soundName: string, loop: boolean, volume: float, pitch: float) {\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._storeSoundInArray(this._freeMusics, music);\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n playMusicOnChannel(\n soundName: string,\n channel: integer,\n loop: boolean,\n volume: float,\n pitch: float\n ) {\n if (this._musics[channel]) this._musics[channel].stop();\n\n const music = this.createHowlerSound(\n soundName,\n /* isMusic= */ true,\n volume / 100,\n loop,\n pitch\n );\n this._musics[channel] = music;\n music.once('play', () => {\n if (this._paused) {\n music.pause();\n this._pausedSounds.push(music);\n }\n });\n music.play();\n }\n\n getMusicOnChannel(channel: integer): HowlerSound | null {\n return this._musics[channel] || null;\n }\n\n setGlobalVolume(volume: float): void {\n this._globalVolume = volume;\n if (this._globalVolume > 100) {\n this._globalVolume = 100;\n }\n if (this._globalVolume < 0) {\n this._globalVolume = 0;\n }\n Howler.volume(this._globalVolume / 100);\n }\n\n getGlobalVolume(): float {\n return this._globalVolume;\n }\n\n clearAll() {\n Howler.stop();\n\n this._freeSounds.length = 0;\n this._freeMusics.length = 0;\n this._sounds = {};\n this._musics = {};\n this._pausedSounds.length = 0;\n }\n\n async processResource(resourceName: string): Promise<void> {\n // Do nothing because sounds are light enough to be parsed in background.\n }\n\n async loadResource(resourceName: string): Promise<void> {\n const resource = this._resourceLoader.getResource(resourceName);\n if (!resource) {\n logger.warn(\n 'Unable to find audio for resource \"' + resourceName + '\".'\n );\n return;\n }\n if (resource.file) {\n if (this._availableResources[resource.name]) {\n return;\n }\n\n this._availableResources[resource.name] = resource;\n }\n\n const preloadAudioFile = (\n file: string,\n isMusic: boolean\n ): Promise<number> => {\n return new Promise((resolve, reject) => {\n const container = isMusic ? this._loadedMusics : this._loadedSounds;\n container[file] = new Howl(\n Object.assign({}, HowlParameters, {\n src: [this._resourceLoader.getFullUrl(file)],\n onload: resolve,\n onloaderror: (soundId: number, error?: string) => reject(error),\n html5: isMusic,\n xhr: {\n withCredentials: this._resourceLoader.checkIfCredentialsRequired(\n file\n ),\n },\n // Cache the sound with no volume. This avoids a bug where it plays at full volume\n // for a split second before setting its correct volume.\n volume: 0,\n })\n );\n });\n };\n\n const file = resource.file;\n if (resource.preloadAsMusic) {\n try {\n await preloadAudioFile(file, /* isMusic= */ true);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n\n if (resource.preloadAsSound) {\n try {\n await preloadAudioFile(file, /* isMusic= */ false);\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n } else if (\n resource.preloadInCache ||\n // Force downloading of sounds.\n // TODO Decide if sounds should be allowed to be downloaded after the scene starts.\n // - they should be requested automatically at the end of the scene loading\n // - they will be downloaded while the scene is playing\n // - other scenes will be pre-loaded only when all the sounds for the current scene are in cache\n !resource.preloadAsMusic\n ) {\n // preloading as sound already does a XHR request, hence \"else if\"\n try {\n await new Promise((resolve, reject) => {\n const sound = new XMLHttpRequest();\n sound.withCredentials = this._resourceLoader.checkIfCredentialsRequired(\n file\n );\n sound.addEventListener('load', resolve);\n sound.addEventListener('error', (_) =>\n reject('XHR error: ' + file)\n );\n sound.addEventListener('abort', (_) =>\n reject('XHR abort: ' + file)\n );\n sound.open('GET', this._resourceLoader.getFullUrl(file));\n sound.send();\n });\n } catch (error) {\n logger.warn(\n 'There was an error while preloading an audio file: ' + error\n );\n }\n }\n }\n }\n\n // Register the class to let the engine use it.\n export const SoundManager = HowlerSoundManager;\n export type SoundManager = HowlerSoundManager;\n}\n"],
5
+ "mappings": "AAMA,GAAU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0;this._isMouseInsideCanvas=!0;this._mouseWheelDelta=0;this._touches={firstKey:()=>{for(const e in this._mouseOrTouches.items)if(e!=="1")return e;return null}};this._startedTouches=[];this._endedTouches=[];this._touchSimulateMouse=!0;this._lastStartedTouchIndex=0;this._lastEndedTouchIndex=0;this._pressedKeys=new Hashtable,this._releasedKeys=new Hashtable,this._pressedMouseButtons=new Array(5),this._releasedMouseButtons=new Array(5),this._mouseOrTouches=new Hashtable}_getLocationAwareKeyCode(e,s){return s?96<=e&&e<=105?e:e+1e3*s:o._DEFAULT_LEFT_VARIANT_KEYS.indexOf(e)!==-1?e+1e3:e}onKeyPressed(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!0),this._lastPressedKey=t}onKeyReleased(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!1),this._releasedKeys.put(t,!0)}getLastPressedKey(){return this._lastPressedKey}isKeyPressed(e){return this._pressedKeys.containsKey(e)&&this._pressedKeys.get(e)}wasKeyReleased(e){return this._releasedKeys.containsKey(e)&&this._releasedKeys.get(e)}anyKeyPressed(){for(const e in this._pressedKeys.items)if(this._pressedKeys.items.hasOwnProperty(e)&&this._pressedKeys.items[e])return!0;return!1}anyKeyReleased(){for(const e in this._releasedKeys.items)if(this._releasedKeys.items.hasOwnProperty(e)&&this._releasedKeys.items[e])return!0;return!1}onMouseMove(e,s){this._setCursorPosition(e,s),this._mouseX=e,this._mouseY=s,this.isMouseButtonPressed(o.MOUSE_LEFT_BUTTON)&&this._moveTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setCursorPosition(e,s){this._cursorX=e,this._cursorY=s}getCursorX(){return this._cursorX}getCursorY(){return this._cursorY}getMouseX(){return this._mouseX}getMouseY(){return this._mouseY}onMouseLeave(){this._isMouseInsideCanvas=!1}onMouseEnter(){this._isMouseInsideCanvas=!0}isMouseInsideCanvas(){return this._isMouseInsideCanvas}onMouseButtonPressed(e){this._setMouseButtonPressed(e),e===o.MOUSE_LEFT_BUTTON&&this._addTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setMouseButtonPressed(e){this._pressedMouseButtons[e]=!0,this._releasedMouseButtons[e]=!1}onMouseButtonReleased(e){this._setMouseButtonReleased(e),e===o.MOUSE_LEFT_BUTTON&&this._removeTouch(o.MOUSE_TOUCH_ID)}_setMouseButtonReleased(e){this._pressedMouseButtons[e]=!1,this._releasedMouseButtons[e]=!0}isMouseButtonPressed(e){return this._pressedMouseButtons[e]!==void 0&&this._pressedMouseButtons[e]}isMouseButtonReleased(e){return this._releasedMouseButtons[e]!==void 0&&this._releasedMouseButtons[e]}onMouseWheel(e){this._mouseWheelDelta=e}getMouseWheelDelta(){return this._mouseWheelDelta}getTouchX(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).x:0}getTouchY(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).y:0}hasTouchEnded(e){return this._endedTouches.includes(e)&&this._mouseOrTouches.get(e).justEnded}getAllTouchIdentifiers(){o._allTouchIds.length=0;for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&o._allTouchIds.push(parseInt(e,10));return o._allTouchIds}onTouchStart(e,s,t){this._addTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&(this._setCursorPosition(s,t),this._setMouseButtonPressed(o.MOUSE_LEFT_BUTTON))}_addTouch(e,s,t){this._endedTouches.includes(e)||(this._startedTouches.push(e),this._mouseOrTouches.put(e,{x:s,y:t,justEnded:!1}))}onTouchMove(e,s,t){this._moveTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&this._setCursorPosition(s,t)}_moveTouch(e,s,t){const r=this._mouseOrTouches.get(e);!r||(r.x=s,r.y=t)}onTouchEnd(e){this._removeTouch(this.getPublicTouchIdentifier(e)),this._touchSimulateMouse&&this._setMouseButtonReleased(o.MOUSE_LEFT_BUTTON)}onTouchCancel(e){this.onTouchEnd(e)}_removeTouch(e){this._endedTouches.push(e),this._mouseOrTouches.containsKey(e)&&(this._mouseOrTouches.get(e).justEnded=!0)}getPublicTouchIdentifier(e){return e+2}getStartedTouchIdentifiers(){return this._startedTouches}popStartedTouch(){const e=this._startedTouches[this._lastStartedTouchIndex];return this._lastStartedTouchIndex++,e}popEndedTouch(){const e=this._endedTouches[this._lastEndedTouchIndex];return this._lastEndedTouchIndex++,e}touchSimulateMouse(e){e===void 0&&(e=!0),this._touchSimulateMouse=e}isSimulatingMouseWithTouch(){return this._touchSimulateMouse}onFrameEnded(){for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&this._mouseOrTouches.items[e].justEnded&&this._mouseOrTouches.remove(e);this._startedTouches.length=0,this._endedTouches.length=0,this._releasedKeys.clear(),this._releasedMouseButtons.length=0,this._mouseWheelDelta=0,this._lastStartedTouchIndex=0,this._lastEndedTouchIndex=0}isScrollingUp(){return this.getMouseWheelDelta()>0}isScrollingDown(){return this.getMouseWheelDelta()<0}};let u=o;u.MOUSE_LEFT_BUTTON=0,u.MOUSE_RIGHT_BUTTON=1,u.MOUSE_MIDDLE_BUTTON=2,u.MOUSE_BACK_BUTTON=3,u.MOUSE_FORWARD_BUTTON=4,u.MOUSE_TOUCH_ID=1,u._DEFAULT_LEFT_VARIANT_KEYS=[16,17,18,91],u._allTouchIds=[],i.InputManager=u})(gdjs||(gdjs={}));
1
+ var gdjs;(function(i){const o=class{constructor(){this._lastPressedKey=0;this._cursorX=0;this._cursorY=0;this._mouseX=0;this._mouseY=0;this._isMouseInsideCanvas=!0;this._mouseWheelDelta=0;this._touches={firstKey:()=>{for(const e in this._mouseOrTouches.items)if(e!=="1")return e;return null}};this._startedTouches=[];this._endedTouches=[];this._touchSimulateMouse=!0;this._lastStartedTouchIndex=0;this._lastEndedTouchIndex=0;this._pressedKeys=new Hashtable,this._releasedKeys=new Hashtable,this._pressedMouseButtons=new Array(5),this._releasedMouseButtons=new Array(5),this._mouseOrTouches=new Hashtable}_getLocationAwareKeyCode(e,s){return s?96<=e&&e<=105?e:e+1e3*s:o._DEFAULT_LEFT_VARIANT_KEYS.indexOf(e)!==-1?e+1e3:e}onKeyPressed(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!0),this._lastPressedKey=t}onKeyReleased(e,s){const t=this._getLocationAwareKeyCode(e,s);this._pressedKeys.put(t,!1),this._releasedKeys.put(t,!0)}getLastPressedKey(){return this._lastPressedKey}isKeyPressed(e){return this._pressedKeys.containsKey(e)&&this._pressedKeys.get(e)}wasKeyReleased(e){return this._releasedKeys.containsKey(e)&&this._releasedKeys.get(e)}anyKeyPressed(){for(const e in this._pressedKeys.items)if(this._pressedKeys.items.hasOwnProperty(e)&&this._pressedKeys.items[e])return!0;return!1}anyKeyReleased(){for(const e in this._releasedKeys.items)if(this._releasedKeys.items.hasOwnProperty(e)&&this._releasedKeys.items[e])return!0;return!1}onMouseMove(e,s){this._setCursorPosition(e,s),this._mouseX=e,this._mouseY=s,this.isMouseButtonPressed(o.MOUSE_LEFT_BUTTON)&&this._moveTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setCursorPosition(e,s){this._cursorX=e,this._cursorY=s}getCursorX(){return this._cursorX}getCursorY(){return this._cursorY}getMouseX(){return this._mouseX}getMouseY(){return this._mouseY}onMouseLeave(){this._isMouseInsideCanvas=!1}onMouseEnter(){this._isMouseInsideCanvas=!0}isMouseInsideCanvas(){return this._isMouseInsideCanvas}onMouseButtonPressed(e){this._setMouseButtonPressed(e),e===o.MOUSE_LEFT_BUTTON&&this._addTouch(o.MOUSE_TOUCH_ID,this.getCursorX(),this.getCursorY())}_setMouseButtonPressed(e){this._pressedMouseButtons[e]=!0,this._releasedMouseButtons[e]=!1}onMouseButtonReleased(e){this._setMouseButtonReleased(e),e===o.MOUSE_LEFT_BUTTON&&this._removeTouch(o.MOUSE_TOUCH_ID)}_setMouseButtonReleased(e){this._pressedMouseButtons[e]=!1,this._releasedMouseButtons[e]=!0}isMouseButtonPressed(e){return this._pressedMouseButtons[e]!==void 0&&this._pressedMouseButtons[e]}isMouseButtonReleased(e){return this._releasedMouseButtons[e]!==void 0&&this._releasedMouseButtons[e]}onMouseWheel(e){this._mouseWheelDelta=e}getMouseWheelDelta(){return this._mouseWheelDelta}getTouchX(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).x:0}getTouchY(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).y:0}hasTouchEnded(e){return this._mouseOrTouches.containsKey(e)?this._mouseOrTouches.get(e).justEnded:!1}getAllTouchIdentifiers(){o._allTouchIds.length=0;for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&o._allTouchIds.push(parseInt(e,10));return o._allTouchIds}onTouchStart(e,s,t){this._addTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&(this._setCursorPosition(s,t),this._setMouseButtonPressed(o.MOUSE_LEFT_BUTTON))}_addTouch(e,s,t){this._endedTouches.includes(e)||(this._startedTouches.push(e),this._mouseOrTouches.put(e,{x:s,y:t,justEnded:!1}))}onTouchMove(e,s,t){this._moveTouch(this.getPublicTouchIdentifier(e),s,t),this._touchSimulateMouse&&this._setCursorPosition(s,t)}_moveTouch(e,s,t){const u=this._mouseOrTouches.get(e);!u||(u.x=s,u.y=t)}onTouchEnd(e){this._removeTouch(this.getPublicTouchIdentifier(e)),this._touchSimulateMouse&&this._setMouseButtonReleased(o.MOUSE_LEFT_BUTTON)}onTouchCancel(e){this.onTouchEnd(e)}_removeTouch(e){this._endedTouches.push(e),this._mouseOrTouches.containsKey(e)&&(this._mouseOrTouches.get(e).justEnded=!0)}getPublicTouchIdentifier(e){return e+2}getStartedTouchIdentifiers(){return this._startedTouches}popStartedTouch(){const e=this._startedTouches[this._lastStartedTouchIndex];return this._lastStartedTouchIndex++,e}popEndedTouch(){const e=this._endedTouches[this._lastEndedTouchIndex];return this._lastEndedTouchIndex++,e}touchSimulateMouse(e){e===void 0&&(e=!0),this._touchSimulateMouse=e}isSimulatingMouseWithTouch(){return this._touchSimulateMouse}onFrameEnded(){for(const e in this._mouseOrTouches.items)this._mouseOrTouches.items.hasOwnProperty(e)&&this._mouseOrTouches.items[e].justEnded&&this._mouseOrTouches.remove(e);this._startedTouches.length=0,this._endedTouches.length=0,this._releasedKeys.clear(),this._releasedMouseButtons.length=0,this._mouseWheelDelta=0,this._lastStartedTouchIndex=0,this._lastEndedTouchIndex=0}isScrollingUp(){return this.getMouseWheelDelta()>0}isScrollingDown(){return this.getMouseWheelDelta()<0}clearAllPressedKeys(){this._pressedKeys.clear()}};let r=o;r.MOUSE_LEFT_BUTTON=0,r.MOUSE_RIGHT_BUTTON=1,r.MOUSE_MIDDLE_BUTTON=2,r.MOUSE_BACK_BUTTON=3,r.MOUSE_FORWARD_BUTTON=4,r.MOUSE_TOUCH_ID=1,r._DEFAULT_LEFT_VARIANT_KEYS=[16,17,18,91],r._allTouchIds=[],i.InputManager=r})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=inputmanager.js.map