gdcore-tools 2.0.0-beta9 → 2.0.0-gd-v5.4.218-autobuild

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 (110) hide show
  1. package/README.md +64 -64
  2. package/dist/Runtime/Extensions/3D/JsExtension.js +7 -3
  3. package/dist/Runtime/Extensions/DialogueTree/JsExtension.js +44 -32
  4. package/dist/Runtime/Extensions/DialogueTree/bondage.js/dist/bondage.min.js +10 -10
  5. package/dist/Runtime/Extensions/DialogueTree/bondage.js/version.txt +5 -5
  6. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js +2 -2
  7. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  8. package/dist/Runtime/Extensions/Firebase/A_firebasejs/NOTICE.txt +6 -6
  9. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  10. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  11. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  12. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  13. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  14. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  15. package/dist/Runtime/Extensions/PhysicsBehavior/box2djs/box2d.js +804 -804
  16. package/dist/Runtime/Extensions/Shopify/shopify-buy.umd.polyfilled.min.js +1 -1
  17. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  18. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  19. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  20. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  21. package/dist/Runtime/Extensions/TileMap/example/anotherIsland.json +5768 -5768
  22. package/dist/Runtime/Extensions/TileMap/example/island.json +5822 -5822
  23. package/dist/Runtime/Model3DManager.js +1 -1
  24. package/dist/Runtime/Model3DManager.js.map +2 -2
  25. package/dist/Runtime/ResourceLoader.js +1 -1
  26. package/dist/Runtime/ResourceLoader.js.map +2 -2
  27. package/dist/Runtime/capturemanager.js +2 -0
  28. package/dist/Runtime/capturemanager.js.map +7 -0
  29. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js +1 -1
  30. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  31. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  32. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  33. package/dist/Runtime/jsonmanager.js +1 -1
  34. package/dist/Runtime/jsonmanager.js.map +2 -2
  35. package/dist/Runtime/layer.js +1 -1
  36. package/dist/Runtime/layer.js.map +2 -2
  37. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js +1 -1
  38. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  39. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  40. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  41. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  42. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  43. package/dist/Runtime/runtimegame.js +1 -1
  44. package/dist/Runtime/runtimegame.js.map +2 -2
  45. package/dist/Runtime/runtimewatermark.js +2 -2
  46. package/dist/Runtime/runtimewatermark.js.map +2 -2
  47. package/dist/Runtime/scenestack.js +1 -1
  48. package/dist/Runtime/scenestack.js.map +2 -2
  49. package/dist/Runtime/spriteruntimeobject.js +1 -1
  50. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  51. package/dist/lib/libGD.cjs +21 -21
  52. package/dist/lib/libGD.wasm +0 -0
  53. package/gd.d.ts +22 -6
  54. package/package.json +1 -1
  55. package/dist/Runtime/Extensions/TileMap/helper/node_modules/.package-lock.json +0 -19
  56. package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/index.d.ts +0 -165
  57. package/dist/Runtime/Extensions/TileMap/helper/node_modules/@types/pako/package.json +0 -35
  58. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js +0 -2
  59. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.js.map +0 -7
  60. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.es5.min.js +0 -2
  61. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js +0 -2
  62. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.js.map +0 -7
  63. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako.min.js +0 -2
  64. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js +0 -2
  65. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.js.map +0 -7
  66. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.es5.min.js +0 -2
  67. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js +0 -2
  68. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.js.map +0 -7
  69. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_deflate.min.js +0 -2
  70. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js +0 -2
  71. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.js.map +0 -7
  72. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.es5.min.js +0 -2
  73. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js +0 -2
  74. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.js.map +0 -7
  75. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/dist/pako_inflate.min.js +0 -2
  76. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js +0 -2
  77. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/index.js.map +0 -7
  78. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js +0 -2
  79. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/deflate.js.map +0 -7
  80. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js +0 -2
  81. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/inflate.js.map +0 -7
  82. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js +0 -2
  83. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/common.js.map +0 -7
  84. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js +0 -2
  85. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/utils/strings.js.map +0 -7
  86. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js +0 -2
  87. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/adler32.js.map +0 -7
  88. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js +0 -2
  89. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/constants.js.map +0 -7
  90. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js +0 -2
  91. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/crc32.js.map +0 -7
  92. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js +0 -2
  93. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/deflate.js.map +0 -7
  94. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js +0 -2
  95. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/gzheader.js.map +0 -7
  96. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js +0 -2
  97. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inffast.js.map +0 -7
  98. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js +0 -2
  99. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inflate.js.map +0 -7
  100. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js +0 -2
  101. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/inftrees.js.map +0 -7
  102. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js +0 -2
  103. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/messages.js.map +0 -7
  104. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js +0 -2
  105. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/trees.js.map +0 -7
  106. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js +0 -2
  107. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/lib/zlib/zstream.js.map +0 -7
  108. package/dist/Runtime/Extensions/TileMap/helper/node_modules/pako/package.json +0 -64
  109. package/types/index.d.ts +0 -23
  110. package/types/open_project.d.ts +0 -25
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../GDevelop/GDJS/Runtime/pixi-renderers/runtimegame-pixi-renderer.ts"],
4
- "sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('PIXI game renderer');\n\n /**\n * Codes (as in `event.code`) of keys that should have their event `preventDefault`\n * called. This is used to avoid scrolling in a webpage when these keys are pressed\n * in the game.\n */\n const defaultPreventedKeyCodes = [\n 37, // ArrowLeft\n 38, // ArrowUp\n 39, // ArrowRight\n 40, // ArrowDown\n ];\n\n /**\n * The renderer for a gdjs.RuntimeGame using Pixi.js.\n */\n export class RuntimeGamePixiRenderer {\n _game: gdjs.RuntimeGame;\n _isFullPage: boolean = true;\n\n //Used to track if the canvas is displayed on the full page.\n _isFullscreen: boolean = false;\n\n //Used to track if the window is displayed as fullscreen (see setFullscreen method).\n _forceFullscreen: any;\n\n _pixiRenderer: PIXI.Renderer | null = null;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _gameCanvas: HTMLCanvasElement | null = null;\n private _domElementsContainer: HTMLDivElement | null = null;\n\n // Current width of the canvas (might be scaled down/up compared to renderer)\n _canvasWidth: float = 0;\n // Current height of the canvas (might be scaled down/up compared to renderer)\n _canvasHeight: float = 0;\n\n _keepRatio: boolean = true;\n _marginLeft: any;\n _marginTop: any;\n _marginRight: any;\n _marginBottom: any;\n\n _nextFrameId: integer = 0;\n\n /**\n * @param game The game that is being rendered\n * @param forceFullscreen If fullscreen should be always activated\n */\n constructor(game: gdjs.RuntimeGame, forceFullscreen: boolean) {\n this._game = game;\n this._forceFullscreen = forceFullscreen;\n\n //If set to true, the canvas will always be displayed as fullscreen, even if _isFullscreen == false.\n this._marginLeft = this._marginTop = this._marginRight = this._marginBottom = 0;\n this._setupOrientation();\n }\n\n /**\n * Create a standard canvas inside canvasArea.\n *\n */\n createStandardCanvas(parentElement: HTMLElement) {\n let gameCanvas: HTMLCanvasElement;\n if (typeof THREE !== 'undefined') {\n gameCanvas = document.createElement('canvas');\n this._threeRenderer = new THREE.WebGLRenderer({\n canvas: gameCanvas,\n antialias:\n this._game.getAntialiasingMode() !== 'none' &&\n (this._game.isAntialisingEnabledOnMobile() ||\n !gdjs.evtTools.common.isMobile()),\n });\n this._threeRenderer.useLegacyLights = true;\n this._threeRenderer.autoClear = false;\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n // Create a PixiJS renderer that use the same GL context as Three.js\n // so that both can render to the canvas and even have PixiJS rendering\n // reused in Three.js (by using a RenderTexture and the same internal WebGL texture).\n this._pixiRenderer = new PIXI.Renderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n view: gameCanvas,\n // @ts-ignore - reuse the context from Three.js.\n context: this._threeRenderer.getContext(),\n clearBeforeRender: false,\n preserveDrawingBuffer: true,\n antialias: false,\n backgroundAlpha: 0,\n // TODO (3D): add a setting for pixel ratio (`resolution: window.devicePixelRatio`)\n });\n\n gameCanvas = this._threeRenderer.domElement;\n } else {\n // Create the renderer and setup the rendering area.\n // \"preserveDrawingBuffer: true\" is needed to avoid flickering\n // and background issues on some mobile phones (see #585 #572 #566 #463).\n this._pixiRenderer = PIXI.autoDetectRenderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n preserveDrawingBuffer: true,\n antialias: false,\n }) as PIXI.Renderer;\n\n gameCanvas = this._pixiRenderer.view as HTMLCanvasElement;\n }\n\n // Deactivating accessibility support in PixiJS renderer, as we want to be in control of this.\n // See https://github.com/pixijs/pixijs/issues/5111#issuecomment-420047824\n this._pixiRenderer.plugins.accessibility.destroy();\n delete this._pixiRenderer.plugins.accessibility;\n\n // Add the renderer view element to the DOM\n parentElement.appendChild(gameCanvas);\n this._gameCanvas = gameCanvas;\n\n gameCanvas.style.position = 'absolute';\n\n // Ensure that the canvas has the focus.\n gameCanvas.tabIndex = 1;\n\n // Ensure long press can't create a selection\n gameCanvas.style.userSelect = 'none';\n gameCanvas.style.outline = 'none'; // No selection/focus ring on the canvas.\n\n // Set up the container for HTML elements on top of the game canvas.\n const domElementsContainer = document.createElement('div');\n domElementsContainer.style.position = 'absolute';\n domElementsContainer.style.overflow = 'hidden'; // Never show anything outside the container.\n domElementsContainer.style.outline = 'none'; // No selection/focus ring on this container.\n domElementsContainer.style.pointerEvents = 'none'; // Clicks go through the container.\n\n // The container should *never* scroll.\n // Elements are put inside with the same coordinates (with a scaling factor)\n // as on the game canvas.\n domElementsContainer.addEventListener('scroll', (event) => {\n domElementsContainer.scrollLeft = 0;\n domElementsContainer.scrollTop = 0;\n event.preventDefault();\n });\n\n // When clicking outside an input, (or other HTML element),\n // give back focus to the game canvas so that this element is blurred.\n gameCanvas.addEventListener('pointerdown', () => {\n gameCanvas.focus();\n });\n\n // Prevent magnifying glass on iOS with a long press.\n // Note that there are related bugs on iOS 15 (see https://bugs.webkit.org/show_bug.cgi?id=231161)\n // but it seems not to affect us as the `domElementsContainer` has `pointerEvents` set to `none`.\n domElementsContainer.style['-webkit-user-select'] = 'none';\n\n parentElement.appendChild(domElementsContainer);\n this._domElementsContainer = domElementsContainer;\n\n this._resizeCanvas();\n\n // Handle scale mode.\n if (this._game.getScaleMode() === 'nearest') {\n gameCanvas.style['image-rendering'] = '-moz-crisp-edges';\n gameCanvas.style['image-rendering'] = '-webkit-optimize-contrast';\n gameCanvas.style['image-rendering'] = '-webkit-crisp-edges';\n gameCanvas.style['image-rendering'] = 'pixelated';\n }\n\n // Handle pixels rounding.\n if (this._game.getPixelsRounding()) {\n PIXI.settings.ROUND_PIXELS = true;\n }\n\n // Handle resize: immediately adjust the game canvas (and dom element container)\n // and notify the game (that may want to adjust to the new size of the window).\n window.addEventListener('resize', () => {\n this._game.onWindowInnerSizeChanged();\n this._resizeCanvas();\n });\n\n // Focus the canvas when created.\n gameCanvas.focus();\n }\n\n static getWindowInnerWidth() {\n return typeof window !== 'undefined' ? window.innerWidth : 800;\n }\n\n static getWindowInnerHeight() {\n return typeof window !== 'undefined' ? window.innerHeight : 800;\n }\n\n /**\n * Update the game renderer size according to the \"game resolution\".\n * Called when game resolution changes.\n *\n * Note that if the canvas is fullscreen, it won't be resized, but when going back to\n * non fullscreen mode, the requested size will be used.\n */\n updateRendererSize(): void {\n this._resizeCanvas();\n }\n\n /**\n * Set the proper screen orientation from the project properties.\n */\n private _setupOrientation() {\n if (\n typeof window === 'undefined' ||\n !window.screen ||\n !window.screen.orientation\n ) {\n return;\n }\n const gameOrientation = this._game.getGameData().properties.orientation;\n try {\n // We ignore the error as some platforms may not supporting locking (i.e: desktop).\n if (gameOrientation === 'default') {\n const promise = window.screen.orientation.unlock();\n // @ts-ignore\n if (promise) {\n // @ts-ignore\n promise.catch(() => {});\n }\n } else {\n // @ts-ignore\n window.screen.orientation.lock(gameOrientation).catch(() => {});\n }\n } catch (error) {\n logger.error('Unexpected error while setting up orientation: ', error);\n }\n }\n\n /**\n * Resize the renderer (the \"game resolution\") and the canvas (which can be larger\n * or smaller to fill the page, with optional margins).\n *\n */\n private _resizeCanvas() {\n if (!this._pixiRenderer || !this._domElementsContainer) return;\n\n // Set the Pixi (and/or Three) renderer size to the game size.\n // There is no \"smart\" resizing to be done here: the rendering of the game\n // should be done with the size set on the game.\n if (\n this._pixiRenderer.width !== this._game.getGameResolutionWidth() ||\n this._pixiRenderer.height !== this._game.getGameResolutionHeight()\n ) {\n // TODO (3D): It might be useful to resize pixi view in 3D depending on FOV value\n // to enable a mode where pixi always fills the whole screen.\n this._pixiRenderer.resize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n if (this._threeRenderer) {\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n }\n }\n\n // Set the canvas size.\n // Resizing is done according to the settings. This is a \"CSS\" resize\n // only, so won't create visual artifacts during the rendering.\n const isFullPage =\n this._forceFullscreen || this._isFullPage || this._isFullscreen;\n let canvasWidth = this._game.getGameResolutionWidth();\n let canvasHeight = this._game.getGameResolutionHeight();\n let maxWidth = window.innerWidth - this._marginLeft - this._marginRight;\n let maxHeight = window.innerHeight - this._marginTop - this._marginBottom;\n if (maxWidth < 0) {\n maxWidth = 0;\n }\n if (maxHeight < 0) {\n maxHeight = 0;\n }\n if (isFullPage && !this._keepRatio) {\n canvasWidth = maxWidth;\n canvasHeight = maxHeight;\n } else {\n if (\n (isFullPage && this._keepRatio) ||\n canvasWidth > maxWidth ||\n canvasHeight > maxHeight\n ) {\n let factor = maxWidth / canvasWidth;\n if (canvasHeight * factor > maxHeight) {\n factor = maxHeight / canvasHeight;\n }\n canvasWidth *= factor;\n canvasHeight *= factor;\n }\n }\n\n // Apply the calculations to the canvas element...\n if (this._gameCanvas) {\n this._gameCanvas.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._gameCanvas.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._gameCanvas.style.width = canvasWidth + 'px';\n this._gameCanvas.style.height = canvasHeight + 'px';\n }\n\n // ...and to the div on top of it showing DOM elements (like inputs).\n this._domElementsContainer.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._domElementsContainer.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._domElementsContainer.style.width = canvasWidth + 'px';\n this._domElementsContainer.style.height = canvasHeight + 'px';\n\n // Store the canvas size for fast access to it.\n this._canvasWidth = canvasWidth;\n this._canvasHeight = canvasHeight;\n }\n\n /**\n * Set if the aspect ratio must be kept when the game canvas is resized to fill\n * the page.\n */\n keepAspectRatio(enable) {\n if (this._keepRatio === enable) {\n return;\n }\n this._keepRatio = enable;\n this._resizeCanvas();\n }\n\n /**\n * Change the margin that must be preserved around the game canvas.\n */\n setMargins(top, right, bottom, left): void {\n if (\n this._marginTop === top &&\n this._marginRight === right &&\n this._marginBottom === bottom &&\n this._marginLeft === left\n ) {\n return;\n }\n this._marginTop = top;\n this._marginRight = right;\n this._marginBottom = bottom;\n this._marginLeft = left;\n this._resizeCanvas();\n }\n\n /**\n * Update the window size, if possible.\n * @param width The new width, in pixels.\n * @param height The new height, in pixels.\n */\n setWindowSize(width: float, height: float): void {\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\n }\n } catch (error) {\n logger.error(\n `Window size setting to width ${width} and height ${height} failed. See error:`,\n error\n );\n }\n } else {\n logger.warn(\"Window size can't be changed on this platform.\");\n }\n }\n\n /**\n * Center the window on screen.\n */\n centerWindow() {\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.center();\n }\n } catch (error) {\n logger.error('Window centering failed. See error:', error);\n }\n } else {\n logger.warn(\"Window can't be centered on this platform.\");\n }\n }\n\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\n if (this._forceFullscreen) {\n return;\n }\n if (this._isFullscreen !== enable) {\n this._isFullscreen = !!enable;\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\n }\n } catch (error) {\n logger.error(\n `Full screen setting to ${this._isFullscreen} failed. See error:`,\n error\n );\n }\n } else {\n // Use HTML5 Fullscreen API\n //TODO: Do this on a user gesture, otherwise most browsers won't activate fullscreen\n if (this._isFullscreen) {\n // @ts-ignore\n if (document.documentElement.requestFullscreen) {\n // @ts-ignore\n document.documentElement.requestFullscreen();\n } else {\n // @ts-ignore\n if (document.documentElement.mozRequestFullScreen) {\n // @ts-ignore\n document.documentElement.mozRequestFullScreen();\n } else {\n // @ts-ignore\n if (document.documentElement.webkitRequestFullScreen) {\n // @ts-ignore\n document.documentElement.webkitRequestFullScreen();\n }\n }\n }\n } else {\n // @ts-ignore\n if (document.exitFullscreen) {\n // @ts-ignore\n document.exitFullscreen();\n } else {\n // @ts-ignore\n if (document.mozCancelFullScreen) {\n // @ts-ignore\n document.mozCancelFullScreen();\n } else {\n // @ts-ignore\n if (document.webkitCancelFullScreen) {\n // @ts-ignore\n document.webkitCancelFullScreen();\n }\n }\n }\n }\n }\n this._resizeCanvas();\n }\n }\n\n /**\n * Checks if the game is in full screen.\n */\n isFullScreen(): boolean {\n const remote = this.getElectronRemote();\n if (remote) {\n try {\n return remote.getCurrentWindow().isFullScreen();\n } catch (error) {\n logger.error(`Full screen detection failed. See error:`, error);\n return false;\n }\n }\n\n // Height check is used to detect user triggered full screen (for example F11 shortcut).\n return this._isFullscreen || window.screen.height === window.innerHeight;\n }\n\n /**\n * Convert a point from the canvas coordinates to the dom element container coordinates.\n *\n * @param canvasCoords The point in the canvas coordinates.\n * @param result The point to return.\n * @returns The point in the dom element container coordinates.\n */\n convertCanvasToDomElementContainerCoords(\n canvasCoords: FloatPoint,\n result: FloatPoint\n ): FloatPoint {\n const pageCoords = result || [0, 0];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pageCoords[0] =\n (canvasCoords[0] * this._canvasWidth) /\n this._game.getGameResolutionWidth();\n pageCoords[1] =\n (canvasCoords[1] * this._canvasHeight) /\n this._game.getGameResolutionHeight();\n\n return pageCoords;\n }\n\n /**\n * Return the scale factor between the renderer height and the actual canvas height,\n * which is also the height of the container for DOM elements to be superimposed on top of it.\n *\n * Useful to scale font sizes of DOM elements so that they follow the size of the game.\n */\n getCanvasToDomElementContainerHeightScale(): float {\n return (this._canvasHeight || 1) / this._game.getGameResolutionHeight();\n }\n\n /**\n * Add the standard events handler.\n */\n bindStandardEvents(\n manager: gdjs.InputManager,\n window: Window,\n document: Document\n ) {\n const canvas = this._gameCanvas;\n if (!canvas) return;\n\n //Translate an event (mouse or touch) made on the canvas on the page\n //to game coordinates.\n const getEventPosition = (e: MouseEvent | Touch) => {\n const pos = [e.pageX - canvas.offsetLeft, e.pageY - canvas.offsetTop];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pos[0] *=\n this._game.getGameResolutionWidth() / (this._canvasWidth || 1);\n pos[1] *=\n this._game.getGameResolutionHeight() / (this._canvasHeight || 1);\n return pos;\n };\n\n const isInsideCanvas = (e: MouseEvent | Touch) => {\n const x = e.pageX - canvas.offsetLeft;\n const y = e.pageY - canvas.offsetTop;\n\n return (\n 0 <= x &&\n x < (this._canvasWidth || 1) &&\n 0 <= y &&\n y < (this._canvasHeight || 1)\n );\n };\n\n //Some browsers lacks definition of some variables used to do calculations\n //in getEventPosition. They are defined to 0 as they are useless.\n\n (function ensureOffsetsExistence() {\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n if (isNaN(document.body.scrollLeft)) {\n document.body.scrollLeft = 0;\n document.body.scrollTop = 0;\n }\n if (\n document.documentElement === undefined ||\n document.documentElement === null\n ) {\n // @ts-ignore\n document.documentElement = {};\n }\n if (isNaN(document.documentElement.scrollLeft)) {\n document.documentElement.scrollLeft = 0;\n document.documentElement.scrollTop = 0;\n }\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n })();\n\n // Keyboard: listen at the document level to capture even when the canvas\n // is not focused.\n\n const isFocusingDomElement = () => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Also check the document body or null for activeElement, as all of these should go\n // to the game.\n if (\n document.activeElement === canvas ||\n document.activeElement === document.body ||\n document.activeElement === null\n )\n return false;\n\n return true;\n };\n const isTargetDomElement = (event: TouchEvent) => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Any event with a target that is not the body or the canvas should\n // not go to the game (<input> or <a> elements for instances).\n if (event.target === canvas || event.target === document.body)\n return false;\n return true;\n };\n document.onkeydown = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyPressed(e.keyCode, e.location);\n };\n document.onkeyup = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyReleased(e.keyCode, e.location);\n };\n\n // Mouse:\n\n // Converts HTML mouse button to InputManager mouse button.\n // This function is used to align HTML button values with GDevelop 3 C++ SFML Mouse button enum values,\n // notably the middle and right buttons.\n function convertHtmlMouseButtonToInputManagerMouseButton(button: number) {\n switch (button) {\n case 1: // Middle button\n return gdjs.InputManager.MOUSE_MIDDLE_BUTTON;\n case 2: // Right button\n return gdjs.InputManager.MOUSE_RIGHT_BUTTON;\n }\n return button;\n }\n canvas.onmousemove = function (e) {\n const pos = getEventPosition(e);\n manager.onMouseMove(pos[0], pos[1]);\n };\n canvas.onmousedown = function (e) {\n manager.onMouseButtonPressed(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n };\n canvas.onmouseup = function (e) {\n manager.onMouseButtonReleased(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n return false;\n };\n canvas.onmouseleave = function (e) {\n manager.onMouseLeave();\n };\n canvas.onmouseenter = function (e) {\n manager.onMouseEnter();\n // There is no mouse event when the cursor is outside of the canvas.\n // We catchup what happened.\n const buttons = [\n gdjs.InputManager.MOUSE_LEFT_BUTTON,\n gdjs.InputManager.MOUSE_RIGHT_BUTTON,\n gdjs.InputManager.MOUSE_MIDDLE_BUTTON,\n gdjs.InputManager.MOUSE_BACK_BUTTON,\n gdjs.InputManager.MOUSE_FORWARD_BUTTON,\n ];\n for (let i = 0, len = buttons.length; i < len; ++i) {\n const button = buttons[i];\n const buttonIsPressed = (e.buttons & (1 << i)) !== 0;\n const buttonWasPressed = manager.isMouseButtonPressed(button);\n if (buttonIsPressed && !buttonWasPressed) {\n manager.onMouseButtonPressed(button);\n } else if (!buttonIsPressed && buttonWasPressed) {\n manager.onMouseButtonReleased(button);\n }\n }\n };\n window.addEventListener(\n 'click',\n function (e) {\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n },\n false\n );\n canvas.oncontextmenu = function (event) {\n event.preventDefault();\n event.stopPropagation();\n return false;\n };\n // @ts-ignore\n canvas.onwheel = function (event) {\n manager.onMouseWheel(-event.deltaY);\n };\n\n // Touches:\n window.addEventListener(\n 'touchmove',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchMove(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n // This works because touch events are sent\n // when they continue outside of the canvas.\n if (manager.isSimulatingMouseWithTouch()) {\n if (isInsideCanvas(e.changedTouches[i])) {\n manager.onMouseEnter();\n } else {\n manager.onMouseLeave();\n }\n }\n }\n }\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchstart',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchStart(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchend',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchEnd(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchcancel',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchCancel(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n }\n\n setWindowTitle(title): void {\n if (typeof document !== 'undefined') {\n document.title = title;\n }\n }\n\n getWindowTitle() {\n return typeof document !== 'undefined' ? document.title : '';\n }\n\n startGameLoop(fn) {\n let oldTime = 0;\n const gameLoop = (time: float) => {\n // Schedule the next frame now to be sure it's called as soon\n // as possible after this one is finished.\n this._nextFrameId = requestAnimationFrame(gameLoop);\n\n const dt = oldTime ? time - oldTime : 0;\n oldTime = time;\n if (!fn(dt)) {\n // Stop the game loop if requested.\n cancelAnimationFrame(this._nextFrameId);\n }\n };\n\n requestAnimationFrame(gameLoop);\n }\n\n getPIXIRenderer() {\n return this._pixiRenderer;\n }\n\n /**\n * Get the Three.js renderer for the game - if any.\n */\n getThreeRenderer(): THREE.WebGLRenderer | null {\n return this._threeRenderer;\n }\n\n /**\n * Get the DOM element used as a container for HTML elements to display\n * on top of the game.\n */\n getDomElementContainer() {\n return this._domElementsContainer;\n }\n\n /**\n * Open the given URL in the system browser (or a new tab)\n */\n openURL(url: string) {\n // Try to detect the environment to use the most adapted\n // way of opening an URL.\n\n if (typeof window !== 'undefined') {\n const electron = this.getElectron();\n if (electron) {\n electron.shell.openExternal(url);\n } else if (\n // @ts-ignore\n typeof window.cordova !== 'undefined' &&\n // @ts-ignore\n typeof window.cordova.InAppBrowser !== 'undefined'\n ) {\n // @ts-ignore\n window.cordova.InAppBrowser.open(url, '_system', 'location=yes');\n } else {\n window.open(url, '_blank');\n }\n }\n }\n\n /**\n * Close the game, if applicable.\n */\n stopGame() {\n // Try to detect the environment to use the most adapted\n // way of closing the app\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n try {\n browserWindow.close();\n } catch (error) {\n logger.error('Window closing failed. See error:', error);\n }\n }\n } else {\n if (\n typeof navigator !== 'undefined' &&\n // @ts-ignore\n navigator.app &&\n // @ts-ignore\n navigator.app.exitApp\n ) {\n // @ts-ignore\n navigator.app.exitApp();\n }\n }\n // HTML5 games on mobile/browsers don't have a way to close their window/page.\n }\n\n /**\n * Get the canvas DOM element.\n */\n getCanvas(): HTMLCanvasElement | null {\n return this._gameCanvas;\n }\n\n /**\n * Check if the device supports WebGL.\n * @returns true if WebGL is supported\n */\n isWebGLSupported(): boolean {\n return (\n !!this._pixiRenderer &&\n this._pixiRenderer.type === PIXI.RENDERER_TYPE.WEBGL\n );\n }\n\n /**\n * Get the electron module, if running as a electron renderer process.\n */\n getElectron() {\n if (typeof require === 'function') {\n return require('electron');\n }\n return null;\n }\n\n /**\n * Helper to get the electron remote module, if running on Electron.\n * Note that is not guaranteed to be supported in the future - avoid if possible.\n */\n getElectronRemote = () => {\n if (typeof require === 'function') {\n const runtimeGameOptions = this._game.getAdditionalOptions();\n const moduleId =\n runtimeGameOptions && runtimeGameOptions.electronRemoteRequirePath\n ? runtimeGameOptions.electronRemoteRequirePath\n : '@electron/remote';\n\n try {\n return require(moduleId);\n } catch (requireError) {\n console.error(\n `Could not load @electron/remote from \"${moduleId}\". Error is:`,\n requireError\n );\n }\n }\n\n return null;\n };\n\n getGame() {\n return this._game;\n }\n }\n\n //Register the class to let the engine use it.\n export type RuntimeGameRenderer = RuntimeGamePixiRenderer;\n export const RuntimeGameRenderer = RuntimeGamePixiRenderer;\n}\n"],
5
- "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAOzB,EAA2B,CAC/B,GACA,GACA,GACA,IAMK,OAA8B,CAgCnC,YAAY,EAAwB,EAA0B,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EAAI,CAChB,GAAI,GAAU,EACd,KAAM,GAAW,AAAC,GAAgB,CAGhC,KAAK,aAAe,sBAAsB,GAE1C,KAAM,GAAK,EAAU,EAAO,EAAU,EACtC,EAAU,EACL,EAAG,IAEN,qBAAqB,KAAK,eAI9B,sBAAsB,GAGxB,iBAAkB,CAChB,MAAO,MAAK,cAMd,kBAA+C,CAC7C,MAAO,MAAK,eAOd,wBAAyB,CACvB,MAAO,MAAK,sBAMd,QAAQ,EAAa,CAInB,GAAI,MAAO,SAAW,YAAa,CACjC,KAAM,GAAW,KAAK,cACtB,AAAI,EACF,EAAS,MAAM,aAAa,GACvB,AAEL,MAAO,QAAO,SAAY,aAE1B,MAAO,QAAO,QAAQ,cAAiB,YAGvC,OAAO,QAAQ,aAAa,KAAK,EAAK,UAAW,gBAEjD,OAAO,KAAK,EAAK,WAQvB,UAAW,CAGT,KAAM,GAAS,KAAK,oBACpB,GAAI,EAAQ,CACV,KAAM,GAAgB,EAAO,mBAC7B,GAAI,EACF,GAAI,CACF,EAAc,cACP,EAAP,CACA,EAAO,MAAM,oCAAqC,QAItD,AACE,OAAO,YAAc,aAErB,UAAU,KAEV,UAAU,IAAI,SAGd,UAAU,IAAI,UASpB,WAAsC,CACpC,MAAO,MAAK,YAOd,kBAA4B,CAC1B,MACE,CAAC,CAAC,KAAK,eACP,KAAK,cAAc,OAAS,KAAK,cAAc,MAOnD,aAAc,CACZ,MAAI,OAAO,UAAY,WACd,QAAQ,YAEV,KA4BT,SAAU,CACR,MAAO,MAAK,OAl8BT,EAAM,0BAw8BA,sBAAsB,IA19B3B",
4
+ "sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('PIXI game renderer');\n\n /**\n * Codes (as in `event.code`) of keys that should have their event `preventDefault`\n * called. This is used to avoid scrolling in a webpage when these keys are pressed\n * in the game.\n */\n const defaultPreventedKeyCodes = [\n 37, // ArrowLeft\n 38, // ArrowUp\n 39, // ArrowRight\n 40, // ArrowDown\n ];\n\n /**\n * The renderer for a gdjs.RuntimeGame using Pixi.js.\n */\n export class RuntimeGamePixiRenderer {\n _game: gdjs.RuntimeGame;\n _isFullPage: boolean = true;\n\n //Used to track if the canvas is displayed on the full page.\n _isFullscreen: boolean = false;\n\n //Used to track if the window is displayed as fullscreen (see setFullscreen method).\n _forceFullscreen: any;\n\n _pixiRenderer: PIXI.Renderer | null = null;\n private _threeRenderer: THREE.WebGLRenderer | null = null;\n private _gameCanvas: HTMLCanvasElement | null = null;\n private _domElementsContainer: HTMLDivElement | null = null;\n\n // Current width of the canvas (might be scaled down/up compared to renderer)\n _canvasWidth: float = 0;\n // Current height of the canvas (might be scaled down/up compared to renderer)\n _canvasHeight: float = 0;\n\n _keepRatio: boolean = true;\n _marginLeft: any;\n _marginTop: any;\n _marginRight: any;\n _marginBottom: any;\n\n _nextFrameId: integer = 0;\n\n _wasDisposed: boolean = false;\n\n /**\n * @param game The game that is being rendered\n * @param forceFullscreen If fullscreen should be always activated\n */\n constructor(game: gdjs.RuntimeGame, forceFullscreen: boolean) {\n this._game = game;\n this._forceFullscreen = forceFullscreen;\n\n //If set to true, the canvas will always be displayed as fullscreen, even if _isFullscreen == false.\n this._marginLeft = this._marginTop = this._marginRight = this._marginBottom = 0;\n this._setupOrientation();\n }\n\n /**\n * Create a standard canvas inside canvasArea.\n *\n */\n createStandardCanvas(parentElement: HTMLElement) {\n this._throwIfDisposed();\n\n let gameCanvas: HTMLCanvasElement;\n if (typeof THREE !== 'undefined') {\n gameCanvas = document.createElement('canvas');\n this._threeRenderer = new THREE.WebGLRenderer({\n canvas: gameCanvas,\n antialias:\n this._game.getAntialiasingMode() !== 'none' &&\n (this._game.isAntialisingEnabledOnMobile() ||\n !gdjs.evtTools.common.isMobile()),\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n });\n this._threeRenderer.useLegacyLights = true;\n this._threeRenderer.autoClear = false;\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n // Create a PixiJS renderer that use the same GL context as Three.js\n // so that both can render to the canvas and even have PixiJS rendering\n // reused in Three.js (by using a RenderTexture and the same internal WebGL texture).\n this._pixiRenderer = new PIXI.Renderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n view: gameCanvas,\n // @ts-ignore - reuse the context from Three.js.\n context: this._threeRenderer.getContext(),\n clearBeforeRender: false,\n preserveDrawingBuffer: true, // Keep to true to allow screenshots.\n antialias: false,\n backgroundAlpha: 0,\n // TODO (3D): add a setting for pixel ratio (`resolution: window.devicePixelRatio`)\n });\n\n gameCanvas = this._threeRenderer.domElement;\n } else {\n // Create the renderer and setup the rendering area.\n // \"preserveDrawingBuffer: true\" is needed to avoid flickering\n // and background issues on some mobile phones (see #585 #572 #566 #463).\n this._pixiRenderer = PIXI.autoDetectRenderer({\n width: this._game.getGameResolutionWidth(),\n height: this._game.getGameResolutionHeight(),\n preserveDrawingBuffer: true,\n antialias: false,\n }) as PIXI.Renderer;\n\n gameCanvas = this._pixiRenderer.view as HTMLCanvasElement;\n }\n\n // Deactivating accessibility support in PixiJS renderer, as we want to be in control of this.\n // See https://github.com/pixijs/pixijs/issues/5111#issuecomment-420047824\n this._pixiRenderer.plugins.accessibility.destroy();\n delete this._pixiRenderer.plugins.accessibility;\n\n // Add the renderer view element to the DOM\n parentElement.appendChild(gameCanvas);\n this._gameCanvas = gameCanvas;\n\n gameCanvas.style.position = 'absolute';\n\n // Ensure that the canvas has the focus.\n gameCanvas.tabIndex = 1;\n\n // Ensure long press can't create a selection\n gameCanvas.style.userSelect = 'none';\n gameCanvas.style.outline = 'none'; // No selection/focus ring on the canvas.\n\n // Set up the container for HTML elements on top of the game canvas.\n const domElementsContainer = document.createElement('div');\n domElementsContainer.style.position = 'absolute';\n domElementsContainer.style.overflow = 'hidden'; // Never show anything outside the container.\n domElementsContainer.style.outline = 'none'; // No selection/focus ring on this container.\n domElementsContainer.style.pointerEvents = 'none'; // Clicks go through the container.\n\n // The container should *never* scroll.\n // Elements are put inside with the same coordinates (with a scaling factor)\n // as on the game canvas.\n domElementsContainer.addEventListener('scroll', (event) => {\n domElementsContainer.scrollLeft = 0;\n domElementsContainer.scrollTop = 0;\n event.preventDefault();\n });\n\n // When clicking outside an input, (or other HTML element),\n // give back focus to the game canvas so that this element is blurred.\n gameCanvas.addEventListener('pointerdown', () => {\n gameCanvas.focus();\n });\n\n // Prevent magnifying glass on iOS with a long press.\n // Note that there are related bugs on iOS 15 (see https://bugs.webkit.org/show_bug.cgi?id=231161)\n // but it seems not to affect us as the `domElementsContainer` has `pointerEvents` set to `none`.\n domElementsContainer.style['-webkit-user-select'] = 'none';\n\n parentElement.appendChild(domElementsContainer);\n this._domElementsContainer = domElementsContainer;\n\n this._resizeCanvas();\n\n // Handle scale mode.\n if (this._game.getScaleMode() === 'nearest') {\n gameCanvas.style['image-rendering'] = '-moz-crisp-edges';\n gameCanvas.style['image-rendering'] = '-webkit-optimize-contrast';\n gameCanvas.style['image-rendering'] = '-webkit-crisp-edges';\n gameCanvas.style['image-rendering'] = 'pixelated';\n }\n\n // Handle pixels rounding.\n if (this._game.getPixelsRounding()) {\n PIXI.settings.ROUND_PIXELS = true;\n }\n\n // Handle resize: immediately adjust the game canvas (and dom element container)\n // and notify the game (that may want to adjust to the new size of the window).\n window.addEventListener('resize', () => {\n this._game.onWindowInnerSizeChanged();\n this._resizeCanvas();\n });\n\n // Focus the canvas when created.\n gameCanvas.focus();\n }\n\n static getWindowInnerWidth() {\n return typeof window !== 'undefined' ? window.innerWidth : 800;\n }\n\n static getWindowInnerHeight() {\n return typeof window !== 'undefined' ? window.innerHeight : 800;\n }\n\n /**\n * Update the game renderer size according to the \"game resolution\".\n * Called when game resolution changes.\n *\n * Note that if the canvas is fullscreen, it won't be resized, but when going back to\n * non fullscreen mode, the requested size will be used.\n */\n updateRendererSize(): void {\n this._resizeCanvas();\n }\n\n /**\n * Set the proper screen orientation from the project properties.\n */\n private _setupOrientation() {\n if (\n typeof window === 'undefined' ||\n !window.screen ||\n !window.screen.orientation\n ) {\n return;\n }\n const gameOrientation = this._game.getGameData().properties.orientation;\n try {\n // We ignore the error as some platforms may not supporting locking (i.e: desktop).\n if (gameOrientation === 'default') {\n const promise = window.screen.orientation.unlock();\n // @ts-ignore\n if (promise) {\n // @ts-ignore\n promise.catch(() => {});\n }\n } else {\n // @ts-ignore\n window.screen.orientation.lock(gameOrientation).catch(() => {});\n }\n } catch (error) {\n logger.error('Unexpected error while setting up orientation: ', error);\n }\n }\n\n /**\n * Resize the renderer (the \"game resolution\") and the canvas (which can be larger\n * or smaller to fill the page, with optional margins).\n *\n */\n private _resizeCanvas() {\n if (!this._pixiRenderer || !this._domElementsContainer) return;\n\n // Set the Pixi (and/or Three) renderer size to the game size.\n // There is no \"smart\" resizing to be done here: the rendering of the game\n // should be done with the size set on the game.\n if (\n this._pixiRenderer.width !== this._game.getGameResolutionWidth() ||\n this._pixiRenderer.height !== this._game.getGameResolutionHeight()\n ) {\n // TODO (3D): It might be useful to resize pixi view in 3D depending on FOV value\n // to enable a mode where pixi always fills the whole screen.\n this._pixiRenderer.resize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n\n if (this._threeRenderer) {\n this._threeRenderer.setSize(\n this._game.getGameResolutionWidth(),\n this._game.getGameResolutionHeight()\n );\n }\n }\n\n // Set the canvas size.\n // Resizing is done according to the settings. This is a \"CSS\" resize\n // only, so won't create visual artifacts during the rendering.\n const isFullPage =\n this._forceFullscreen || this._isFullPage || this._isFullscreen;\n let canvasWidth = this._game.getGameResolutionWidth();\n let canvasHeight = this._game.getGameResolutionHeight();\n let maxWidth = window.innerWidth - this._marginLeft - this._marginRight;\n let maxHeight = window.innerHeight - this._marginTop - this._marginBottom;\n if (maxWidth < 0) {\n maxWidth = 0;\n }\n if (maxHeight < 0) {\n maxHeight = 0;\n }\n if (isFullPage && !this._keepRatio) {\n canvasWidth = maxWidth;\n canvasHeight = maxHeight;\n } else {\n if (\n (isFullPage && this._keepRatio) ||\n canvasWidth > maxWidth ||\n canvasHeight > maxHeight\n ) {\n let factor = maxWidth / canvasWidth;\n if (canvasHeight * factor > maxHeight) {\n factor = maxHeight / canvasHeight;\n }\n canvasWidth *= factor;\n canvasHeight *= factor;\n }\n }\n\n // Apply the calculations to the canvas element...\n if (this._gameCanvas) {\n this._gameCanvas.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._gameCanvas.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._gameCanvas.style.width = canvasWidth + 'px';\n this._gameCanvas.style.height = canvasHeight + 'px';\n }\n\n // ...and to the div on top of it showing DOM elements (like inputs).\n this._domElementsContainer.style.top =\n this._marginTop + (maxHeight - canvasHeight) / 2 + 'px';\n this._domElementsContainer.style.left =\n this._marginLeft + (maxWidth - canvasWidth) / 2 + 'px';\n this._domElementsContainer.style.width = canvasWidth + 'px';\n this._domElementsContainer.style.height = canvasHeight + 'px';\n\n // Store the canvas size for fast access to it.\n this._canvasWidth = canvasWidth;\n this._canvasHeight = canvasHeight;\n }\n\n /**\n * Set if the aspect ratio must be kept when the game canvas is resized to fill\n * the page.\n */\n keepAspectRatio(enable) {\n if (this._keepRatio === enable) {\n return;\n }\n this._keepRatio = enable;\n this._resizeCanvas();\n }\n\n /**\n * Change the margin that must be preserved around the game canvas.\n */\n setMargins(top, right, bottom, left): void {\n this._throwIfDisposed();\n if (\n this._marginTop === top &&\n this._marginRight === right &&\n this._marginBottom === bottom &&\n this._marginLeft === left\n ) {\n return;\n }\n this._marginTop = top;\n this._marginRight = right;\n this._marginBottom = bottom;\n this._marginLeft = left;\n this._resizeCanvas();\n }\n\n /**\n * Update the window size, if possible.\n * @param width The new width, in pixels.\n * @param height The new height, in pixels.\n */\n setWindowSize(width: float, height: float): void {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setContentSize(width, height);\n }\n } catch (error) {\n logger.error(\n `Window size setting to width ${width} and height ${height} failed. See error:`,\n error\n );\n }\n } else {\n logger.warn(\"Window size can't be changed on this platform.\");\n }\n }\n\n /**\n * Center the window on screen.\n */\n centerWindow() {\n this._throwIfDisposed();\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.center();\n }\n } catch (error) {\n logger.error('Window centering failed. See error:', error);\n }\n } else {\n logger.warn(\"Window can't be centered on this platform.\");\n }\n }\n\n /**\n * De/activate fullscreen for the game.\n */\n setFullScreen(enable): void {\n this._throwIfDisposed();\n if (this._forceFullscreen) {\n return;\n }\n if (this._isFullscreen !== enable) {\n this._isFullscreen = !!enable;\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n try {\n if (browserWindow) {\n browserWindow.setFullScreen(this._isFullscreen);\n }\n } catch (error) {\n logger.error(\n `Full screen setting to ${this._isFullscreen} failed. See error:`,\n error\n );\n }\n } else {\n // Use HTML5 Fullscreen API\n //TODO: Do this on a user gesture, otherwise most browsers won't activate fullscreen\n if (this._isFullscreen) {\n // @ts-ignore\n if (document.documentElement.requestFullscreen) {\n // @ts-ignore\n document.documentElement.requestFullscreen();\n } else {\n // @ts-ignore\n if (document.documentElement.mozRequestFullScreen) {\n // @ts-ignore\n document.documentElement.mozRequestFullScreen();\n } else {\n // @ts-ignore\n if (document.documentElement.webkitRequestFullScreen) {\n // @ts-ignore\n document.documentElement.webkitRequestFullScreen();\n }\n }\n }\n } else {\n // @ts-ignore\n if (document.exitFullscreen) {\n // @ts-ignore\n document.exitFullscreen();\n } else {\n // @ts-ignore\n if (document.mozCancelFullScreen) {\n // @ts-ignore\n document.mozCancelFullScreen();\n } else {\n // @ts-ignore\n if (document.webkitCancelFullScreen) {\n // @ts-ignore\n document.webkitCancelFullScreen();\n }\n }\n }\n }\n }\n this._resizeCanvas();\n }\n }\n\n /**\n * Checks if the game is in full screen.\n */\n isFullScreen(): boolean {\n const remote = this.getElectronRemote();\n if (remote) {\n try {\n return remote.getCurrentWindow().isFullScreen();\n } catch (error) {\n logger.error(`Full screen detection failed. See error:`, error);\n return false;\n }\n }\n\n // Height check is used to detect user triggered full screen (for example F11 shortcut).\n return this._isFullscreen || window.screen.height === window.innerHeight;\n }\n\n /**\n * Convert a point from the canvas coordinates to the dom element container coordinates.\n *\n * @param canvasCoords The point in the canvas coordinates.\n * @param result The point to return.\n * @returns The point in the dom element container coordinates.\n */\n convertCanvasToDomElementContainerCoords(\n canvasCoords: FloatPoint,\n result: FloatPoint\n ): FloatPoint {\n const pageCoords = result || [0, 0];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pageCoords[0] =\n (canvasCoords[0] * this._canvasWidth) /\n this._game.getGameResolutionWidth();\n pageCoords[1] =\n (canvasCoords[1] * this._canvasHeight) /\n this._game.getGameResolutionHeight();\n\n return pageCoords;\n }\n\n /**\n * Return the scale factor between the renderer height and the actual canvas height,\n * which is also the height of the container for DOM elements to be superimposed on top of it.\n *\n * Useful to scale font sizes of DOM elements so that they follow the size of the game.\n */\n getCanvasToDomElementContainerHeightScale(): float {\n return (this._canvasHeight || 1) / this._game.getGameResolutionHeight();\n }\n\n /**\n * Add the standard events handler.\n */\n bindStandardEvents(\n manager: gdjs.InputManager,\n window: Window,\n document: Document\n ) {\n this._throwIfDisposed();\n const canvas = this._gameCanvas;\n if (!canvas) return;\n\n //Translate an event (mouse or touch) made on the canvas on the page\n //to game coordinates.\n const getEventPosition = (e: MouseEvent | Touch) => {\n const pos = [e.pageX - canvas.offsetLeft, e.pageY - canvas.offsetTop];\n\n // Handle the fact that the game is stretched to fill the canvas.\n pos[0] *=\n this._game.getGameResolutionWidth() / (this._canvasWidth || 1);\n pos[1] *=\n this._game.getGameResolutionHeight() / (this._canvasHeight || 1);\n return pos;\n };\n\n const isInsideCanvas = (e: MouseEvent | Touch) => {\n const x = e.pageX - canvas.offsetLeft;\n const y = e.pageY - canvas.offsetTop;\n\n return (\n 0 <= x &&\n x < (this._canvasWidth || 1) &&\n 0 <= y &&\n y < (this._canvasHeight || 1)\n );\n };\n\n //Some browsers lacks definition of some variables used to do calculations\n //in getEventPosition. They are defined to 0 as they are useless.\n\n (function ensureOffsetsExistence() {\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n if (isNaN(document.body.scrollLeft)) {\n document.body.scrollLeft = 0;\n document.body.scrollTop = 0;\n }\n if (\n document.documentElement === undefined ||\n document.documentElement === null\n ) {\n // @ts-ignore\n document.documentElement = {};\n }\n if (isNaN(document.documentElement.scrollLeft)) {\n document.documentElement.scrollLeft = 0;\n document.documentElement.scrollTop = 0;\n }\n if (isNaN(canvas.offsetLeft)) {\n // @ts-ignore\n canvas.offsetLeft = 0;\n // @ts-ignore\n canvas.offsetTop = 0;\n }\n })();\n\n // Keyboard: listen at the document level to capture even when the canvas\n // is not focused.\n\n const isFocusingDomElement = () => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Also check the document body or null for activeElement, as all of these should go\n // to the game.\n if (\n document.activeElement === canvas ||\n document.activeElement === document.body ||\n document.activeElement === null\n )\n return false;\n\n return true;\n };\n const isTargetDomElement = (event: TouchEvent) => {\n // Fast bailout when the game canvas should receive the inputs (i.e: almost always).\n // Any event with a target that is not the body or the canvas should\n // not go to the game (<input> or <a> elements for instances).\n if (event.target === canvas || event.target === document.body)\n return false;\n return true;\n };\n document.onkeydown = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyPressed(e.keyCode, e.location);\n };\n document.onkeyup = function (e) {\n if (isFocusingDomElement()) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // arrow keys events.\n return;\n }\n\n if (defaultPreventedKeyCodes.includes(e.keyCode)) {\n // Some keys are \"default prevented\" to avoid scrolling when the game\n // is integrated in a page as an iframe.\n e.preventDefault();\n }\n\n manager.onKeyReleased(e.keyCode, e.location);\n };\n\n // Mouse:\n\n // Converts HTML mouse button to InputManager mouse button.\n // This function is used to align HTML button values with GDevelop 3 C++ SFML Mouse button enum values,\n // notably the middle and right buttons.\n function convertHtmlMouseButtonToInputManagerMouseButton(button: number) {\n switch (button) {\n case 1: // Middle button\n return gdjs.InputManager.MOUSE_MIDDLE_BUTTON;\n case 2: // Right button\n return gdjs.InputManager.MOUSE_RIGHT_BUTTON;\n }\n return button;\n }\n canvas.onmousemove = function (e) {\n const pos = getEventPosition(e);\n manager.onMouseMove(pos[0], pos[1]);\n };\n canvas.onmousedown = function (e) {\n manager.onMouseButtonPressed(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n };\n canvas.onmouseup = function (e) {\n manager.onMouseButtonReleased(\n convertHtmlMouseButtonToInputManagerMouseButton(e.button)\n );\n return false;\n };\n canvas.onmouseleave = function (e) {\n manager.onMouseLeave();\n };\n canvas.onmouseenter = function (e) {\n manager.onMouseEnter();\n // There is no mouse event when the cursor is outside of the canvas.\n // We catchup what happened.\n const buttons = [\n gdjs.InputManager.MOUSE_LEFT_BUTTON,\n gdjs.InputManager.MOUSE_RIGHT_BUTTON,\n gdjs.InputManager.MOUSE_MIDDLE_BUTTON,\n gdjs.InputManager.MOUSE_BACK_BUTTON,\n gdjs.InputManager.MOUSE_FORWARD_BUTTON,\n ];\n for (let i = 0, len = buttons.length; i < len; ++i) {\n const button = buttons[i];\n const buttonIsPressed = (e.buttons & (1 << i)) !== 0;\n const buttonWasPressed = manager.isMouseButtonPressed(button);\n if (buttonIsPressed && !buttonWasPressed) {\n manager.onMouseButtonPressed(button);\n } else if (!buttonIsPressed && buttonWasPressed) {\n manager.onMouseButtonReleased(button);\n }\n }\n };\n window.addEventListener(\n 'click',\n function (e) {\n if (window.focus !== undefined) {\n window.focus();\n }\n return false;\n },\n false\n );\n canvas.oncontextmenu = function (event) {\n event.preventDefault();\n event.stopPropagation();\n return false;\n };\n // @ts-ignore\n canvas.onwheel = function (event) {\n manager.onMouseWheel(-event.deltaY);\n };\n\n // Touches:\n window.addEventListener(\n 'touchmove',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchMove(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n // This works because touch events are sent\n // when they continue outside of the canvas.\n if (manager.isSimulatingMouseWithTouch()) {\n if (isInsideCanvas(e.changedTouches[i])) {\n manager.onMouseEnter();\n } else {\n manager.onMouseLeave();\n }\n }\n }\n }\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchstart',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n const pos = getEventPosition(e.changedTouches[i]);\n manager.onTouchStart(\n e.changedTouches[i].identifier,\n pos[0],\n pos[1]\n );\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchend',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchEnd(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n window.addEventListener(\n 'touchcancel',\n function (e) {\n if (isTargetDomElement(e)) {\n // Bail out if the game canvas is not focused. For example,\n // an `<input>` element can be focused, and needs to receive\n // touch events to move the selection (and do other native gestures).\n return;\n }\n\n e.preventDefault();\n if (e.changedTouches) {\n for (let i = 0; i < e.changedTouches.length; ++i) {\n manager.onTouchCancel(e.changedTouches[i].identifier);\n }\n }\n return false;\n },\n // This is important so that we can use e.preventDefault() and block possible following mouse events.\n { passive: false }\n );\n }\n\n setWindowTitle(title): void {\n if (typeof document !== 'undefined') {\n document.title = title;\n }\n }\n\n getWindowTitle() {\n return typeof document !== 'undefined' ? document.title : '';\n }\n\n startGameLoop(fn) {\n this._throwIfDisposed();\n let oldTime = 0;\n const gameLoop = (time: float) => {\n // Schedule the next frame now to be sure it's called as soon\n // as possible after this one is finished.\n this._nextFrameId = requestAnimationFrame(gameLoop);\n\n const dt = oldTime ? time - oldTime : 0;\n oldTime = time;\n if (!fn(dt)) {\n // Stop the game loop if requested.\n cancelAnimationFrame(this._nextFrameId);\n }\n };\n\n requestAnimationFrame(gameLoop);\n }\n\n stopGameLoop(): void {\n cancelAnimationFrame(this._nextFrameId);\n }\n\n getPIXIRenderer() {\n return this._pixiRenderer;\n }\n\n /**\n * Get the Three.js renderer for the game - if any.\n */\n getThreeRenderer(): THREE.WebGLRenderer | null {\n return this._threeRenderer;\n }\n\n /**\n * Get the DOM element used as a container for HTML elements to display\n * on top of the game.\n */\n getDomElementContainer() {\n return this._domElementsContainer;\n }\n\n /**\n * Open the given URL in the system browser (or a new tab)\n */\n openURL(url: string) {\n // Try to detect the environment to use the most adapted\n // way of opening an URL.\n\n if (typeof window !== 'undefined') {\n const electron = this.getElectron();\n if (electron) {\n electron.shell.openExternal(url);\n } else if (\n // @ts-ignore\n typeof window.cordova !== 'undefined' &&\n // @ts-ignore\n typeof window.cordova.InAppBrowser !== 'undefined'\n ) {\n // @ts-ignore\n window.cordova.InAppBrowser.open(url, '_system', 'location=yes');\n } else {\n window.open(url, '_blank');\n }\n }\n }\n\n /**\n * Close the game, if applicable.\n */\n stopGame() {\n // Try to detect the environment to use the most adapted\n // way of closing the app\n const remote = this.getElectronRemote();\n if (remote) {\n const browserWindow = remote.getCurrentWindow();\n if (browserWindow) {\n try {\n browserWindow.close();\n } catch (error) {\n logger.error('Window closing failed. See error:', error);\n }\n }\n } else {\n if (\n typeof navigator !== 'undefined' &&\n // @ts-ignore\n navigator.app &&\n // @ts-ignore\n navigator.app.exitApp\n ) {\n // @ts-ignore\n navigator.app.exitApp();\n }\n }\n // HTML5 games on mobile/browsers don't have a way to close their window/page.\n }\n\n /**\n * Dispose PixiRenderer, ThreeRenderer and remove canvas from DOM.\n */\n dispose() {\n this._pixiRenderer?.destroy(true);\n this._threeRenderer?.dispose();\n this._pixiRenderer = null;\n this._threeRenderer = null;\n this._gameCanvas = null;\n this._domElementsContainer = null;\n this._wasDisposed = true;\n }\n\n /**\n * Get the canvas DOM element.\n */\n getCanvas(): HTMLCanvasElement | null {\n return this._gameCanvas;\n }\n\n /**\n * Check if the device supports WebGL.\n * @returns true if WebGL is supported\n */\n isWebGLSupported(): boolean {\n return (\n !!this._pixiRenderer &&\n this._pixiRenderer.type === PIXI.RENDERER_TYPE.WEBGL\n );\n }\n\n /**\n * Get the electron module, if running as a electron renderer process.\n */\n getElectron() {\n if (typeof require === 'function') {\n return require('electron');\n }\n return null;\n }\n\n /**\n * Helper to get the electron remote module, if running on Electron.\n * Note that is not guaranteed to be supported in the future - avoid if possible.\n */\n getElectronRemote = () => {\n if (typeof require === 'function') {\n const runtimeGameOptions = this._game.getAdditionalOptions();\n const moduleId =\n runtimeGameOptions && runtimeGameOptions.electronRemoteRequirePath\n ? runtimeGameOptions.electronRemoteRequirePath\n : '@electron/remote';\n\n try {\n return require(moduleId);\n } catch (requireError) {\n console.error(\n `Could not load @electron/remote from \"${moduleId}\". Error is:`,\n requireError\n );\n }\n }\n\n return null;\n };\n\n getGame() {\n return this._game;\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw 'The RuntimeGameRenderer has been disposed and should not be used anymore.';\n }\n }\n }\n\n //Register the class to let the engine use it.\n export type RuntimeGameRenderer = RuntimeGamePixiRenderer;\n export const RuntimeGameRenderer = RuntimeGamePixiRenderer;\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAS,GAAI,GAAK,OAAO,sBAOzB,EAA2B,CAC/B,GACA,GACA,GACA,IAMK,OAA8B,CAkCnC,YAAY,EAAwB,EAA0B,CAhC9D,iBAAuB,GAGvB,mBAAyB,GAKzB,mBAAsC,KAC9B,oBAA6C,KAC7C,iBAAwC,KACxC,2BAA+C,KAGvD,kBAAsB,EAEtB,mBAAuB,EAEvB,gBAAsB,GAMtB,kBAAwB,EAExB,kBAAwB,GA46BxB,uBAAoB,IAAM,CACxB,GAAI,MAAO,UAAY,WAAY,CACjC,KAAM,GAAqB,KAAK,MAAM,uBAChC,EACJ,GAAsB,EAAmB,0BACrC,EAAmB,0BACnB,mBAEN,GAAI,CACF,MAAO,SAAQ,SACR,EAAP,CACA,QAAQ,MACN,yCAAyC,gBACzC,IAKN,MAAO,OAv7BP,KAAK,MAAQ,EACb,KAAK,iBAAmB,EAGxB,KAAK,YAAc,KAAK,WAAa,KAAK,aAAe,KAAK,cAAgB,EAC9E,KAAK,oBAOP,qBAAqB,EAA4B,CAC/C,KAAK,mBAEL,GAAI,GACJ,AAAI,MAAO,QAAU,YACnB,GAAa,SAAS,cAAc,UACpC,KAAK,eAAiB,GAAI,OAAM,cAAc,CAC5C,OAAQ,EACR,UACE,KAAK,MAAM,wBAA0B,QACpC,MAAK,MAAM,gCACV,CAAC,EAAK,SAAS,OAAO,YAC1B,sBAAuB,KAEzB,KAAK,eAA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B,GAAI,EACF,GAAI,CACF,EAAc,cACP,EAAP,CACA,EAAO,MAAM,oCAAqC,QAItD,AACE,OAAO,YAAc,aAErB,UAAU,KAEV,UAAU,IAAI,SAGd,UAAU,IAAI,UASpB,SAAU,CACR,KAAK,eAAe,QAAQ,IAC5B,KAAK,gBAAgB,UACrB,KAAK,cAAgB,KACrB,KAAK,eAAiB,KACtB,KAAK,YAAc,KACnB,KAAK,sBAAwB,KAC7B,KAAK,aAAe,GAMtB,WAAsC,CACpC,MAAO,MAAK,YAOd,kBAA4B,CAC1B,MACE,CAAC,CAAC,KAAK,eACP,KAAK,cAAc,OAAS,KAAK,cAAc,MAOnD,aAAc,CACZ,MAAI,OAAO,UAAY,WACd,QAAQ,YAEV,KA4BT,SAAU,CACR,MAAO,MAAK,MAGN,kBAAyB,CAC/B,GAAI,KAAK,aACP,KAAM,6EAn+BL,EAAM,0BA0+BA,sBAAsB,IA5/B3B",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(i){const g=new i.Logger("Game manager"),h=u=>new Promise(e=>setTimeout(e,u)),c=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class m{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new i.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new i.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new i.ResourceLoader(this,e.resources.resources,c(e),e.layouts),this._effectsManager=new i.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new i.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new i.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new i.SceneStack(this),this._inputManager=new i.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=i.DebuggerClient?new i.DebuggerClient(this):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const n=JSON.parse(s.metadata);n?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,n.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,c(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t<s;++t){const n=this._sceneAndExtensionsData[t];if(e===void 0||n.sceneData.name===e)return n}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let t=0,s=this._data.layouts.length;t<s;++t){const n=this._data.layouts[t];if(e===void 0||n.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,n=this._data.externalLayouts.length;s<n;++s){const r=this._data.externalLayouts[s];if(r.name===e){t=r;break}}return t}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,t){if(this._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&i.RuntimeGameRenderer&&i.RuntimeGameRenderer.getWindowInnerWidth&&i.RuntimeGameRenderer.getWindowInnerHeight){const s=i.RuntimeGameRenderer.getWindowInnerWidth(),n=i.RuntimeGameRenderer.getWindowInnerHeight();this._resizeMode==="adaptWidth"?this._gameResolutionWidth=this._gameResolutionHeight*s/n:this._resizeMode==="adaptHeight"&&(this._gameResolutionHeight=this._gameResolutionWidth*n/s)}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}loadAllAssets(e,t){this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),t).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,t){try{const s=this._data.properties.loadingScreen.backgroundImageResourceName;s&&await this._resourcesLoader.getImageManager().loadResource(s),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async n=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,n),this._resourcesLoader.loadAllSceneInBackground()},t),i.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const n=new i.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);n.setPercent(d),s&&s(d),n.renderIfNeeded()&&await h(1)}),await n.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents();let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,n=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-n,n=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?n=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{n=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=i.makeUuid();return localStorage.setItem(e,s),s}catch{return i.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((n,r)=>{const o=n.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],n=this.getVariablesForExtension(t);n&&n.updateFromNetworkSyncData(s)}}}i.RuntimeGame=m})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const g=new n.Logger("Game manager"),c=u=>new Promise(e=>setTimeout(e,u)),h=u=>u.usedResources.map(e=>e.name);let l=null;const p=()=>{if(l)return l;l=[];try{new CompressionStream("gzip"),l.push("cs:gzip")}catch{}try{new CompressionStream("deflate"),l.push("cs:deflate")}catch{}return l};class _{constructor(e,t){this._sceneAndExtensionsData=[];this._notifyScenesForGameResolutionResize=!1;this._paused=!1;this._hasJustResumed=!1;this._sessionMetricsInitialized=!1;this._disableMetrics=!1;this._wasDisposed=!1;this.getPlatformInfo=()=>({isCordova:!!window.cordova,devicePlatform:typeof device!="undefined"&&device.platform||"",navigatorPlatform:typeof navigator!="undefined"?navigator.platform:"",hasTouch:typeof navigator!="undefined"?!!navigator.maxTouchPoints&&navigator.maxTouchPoints>2:!1,supportedCompressionMethods:p()});this._options=t||{},this._variables=new n.VariablesContainer(e.variables),this._variablesByExtensionName=new Map;for(const s of e.eventsFunctionsExtensions)s.globalVariables.length>0&&this._variablesByExtensionName.set(s.name,new n.VariablesContainer(s.globalVariables));this._eventsBasedObjectDatas=new Map,this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader=new n.ResourceLoader(this,e.resources.resources,h(e),e.layouts),this._effectsManager=new n.EffectsManager,this._maxFPS=this._data.properties.maxFPS,this._minFPS=this._data.properties.minFPS,this._gameResolutionWidth=this._data.properties.windowWidth,this._gameResolutionHeight=this._data.properties.windowHeight,this._originalWidth=this._gameResolutionWidth,this._originalHeight=this._gameResolutionHeight,this._resizeMode=this._data.properties.sizeOnStartupMode,this._adaptGameResolutionAtRuntime=this._data.properties.adaptGameResolutionAtRuntime,this._scaleMode=e.properties.scaleMode||"linear",this._pixelsRounding=this._data.properties.pixelsRounding,this._antialiasingMode=this._data.properties.antialiasingMode,this._isAntialisingEnabledOnMobile=this._data.properties.antialisingEnabledOnMobile,this._renderer=new n.RuntimeGameRenderer(this,this._options.forceFullscreen||!1),this._watermark=new n.watermark.RuntimeWatermark(this,e.properties.authorUsernames,this._data.properties.watermark),this._sceneStack=new n.SceneStack(this),this._inputManager=new n.InputManager,this._injectExternalLayout=this._options.injectExternalLayout||"",this._debuggerClient=n.DebuggerClient?new n.DebuggerClient(this):null,this._captureManager=n.CaptureManager?new n.CaptureManager(this._renderer,this._options.captureOptions||{}):null,this._isPreview=this._options.isPreview||!1,this._sessionId=null,this._playerId=null,this._embeddedResourcesMappings=new Map;for(const s of this._data.resources.resources)if(s.metadata)try{const i=JSON.parse(s.metadata);i?.embeddedResourcesMapping&&this._embeddedResourcesMappings.set(s.name,i.embeddedResourcesMapping)}catch{g.error("Some metadata of resources can not be successfully parsed.")}this.isUsingGDevelopDevelopmentEnvironment()&&g.info("This game will run on the development version of GDevelop APIs.")}setProjectData(e){this._data=e,this._updateSceneAndExtensionsData(),this._resourcesLoader.setResources(e.resources.resources,h(e),e.layouts)}_updateSceneAndExtensionsData(){const e=this._data.eventsFunctionsExtensions.filter(t=>t.sceneVariables.length>0);if(this._sceneAndExtensionsData=this._data.layouts.map(t=>({sceneData:t,usedExtensionsWithVariablesData:e})),this._eventsBasedObjectDatas.clear(),this._data.eventsFunctionsExtensions)for(const t of this._data.eventsFunctionsExtensions)for(const s of t.eventsBasedObjects)this._eventsBasedObjectDatas.set(t.name+"::"+s.name,s)}getAdditionalOptions(){return this._options}getRenderer(){return this._renderer}getVariables(){return this._variables}getVariablesForExtension(e){return this._variablesByExtensionName.get(e)||null}getSoundManager(){return this._resourcesLoader.getSoundManager()}getImageManager(){return this._resourcesLoader.getImageManager()}getFontManager(){return this._resourcesLoader.getFontManager()}getBitmapFontManager(){return this._resourcesLoader.getBitmapFontManager()}getJsonManager(){return this._resourcesLoader.getJsonManager()}getModel3DManager(){return this._resourcesLoader.getModel3DManager()}getSpineManager(){return this._resourcesLoader.getSpineManager()}getSpineAtlasManager(){return this._resourcesLoader.getSpineAtlasManager()}getInputManager(){return this._inputManager}getEffectsManager(){return this._effectsManager}getGameData(){return this._data}getEventsBasedObjectData(e){const t=this._eventsBasedObjectDatas.get(e);return t||(g.error('The game has no events-based object of the type "'+e+'"'),null)}getSceneAndExtensionsData(e){for(let t=0,s=this._sceneAndExtensionsData.length;t<s;++t){const i=this._sceneAndExtensionsData[t];if(e===void 0||i.sceneData.name===e)return i}return g.error('The game has no scene called "'+e+'"'),null}hasScene(e){for(let t=0,s=this._data.layouts.length;t<s;++t){const i=this._data.layouts[t];if(e===void 0||i.name==e)return!0}return!1}getExternalLayoutData(e){let t=null;for(let s=0,i=this._data.externalLayouts.length;s<i;++s){const r=this._data.externalLayouts[s];if(r.name===e){t=r;break}}return t}getInitialObjectsData(){return this._data.objects||[]}getOriginalWidth(){return this._originalWidth}getOriginalHeight(){return this._originalHeight}getGameResolutionWidth(){return this._gameResolutionWidth}getGameResolutionHeight(){return this._gameResolutionHeight}setGameResolutionSize(e,t){if(this._throwIfDisposed(),this._gameResolutionWidth=e,this._gameResolutionHeight=t,this._adaptGameResolutionAtRuntime&&n.RuntimeGameRenderer&&n.RuntimeGameRenderer.getWindowInnerWidth&&n.RuntimeGameRenderer.getWindowInnerHeight){const s=n.RuntimeGameRenderer.getWindowInnerWidth(),i=n.RuntimeGameRenderer.getWindowInnerHeight();this._resizeMode==="adaptWidth"?this._gameResolutionWidth=this._gameResolutionHeight*s/i:this._resizeMode==="adaptHeight"&&(this._gameResolutionHeight=this._gameResolutionWidth*i/s)}this._renderer.updateRendererSize(),this._notifyScenesForGameResolutionResize=!0}setGameResolutionResizeMode(e){this._resizeMode=e,this._forceGameResolutionUpdate()}getGameResolutionResizeMode(){return this._resizeMode}setAdaptGameResolutionAtRuntime(e){this._adaptGameResolutionAtRuntime=e,this._forceGameResolutionUpdate()}getAdaptGameResolutionAtRuntime(){return this._adaptGameResolutionAtRuntime}getMinimalFramerate(){return this._minFPS}getScaleMode(){return this._scaleMode}getPixelsRounding(){return this._pixelsRounding}getAntialiasingMode(){return this._antialiasingMode}isAntialisingEnabledOnMobile(){return this._isAntialisingEnabledOnMobile}pause(e){this._paused!==e&&(this._paused=e,this._debuggerClient&&(this._paused?this._debuggerClient.sendGamePaused():this._debuggerClient.sendGameResumed()))}hasJustResumed(){return this._hasJustResumed}prioritizeLoadingOfScene(e){this._resourcesLoader.loadSceneResources(e)}getSceneLoadingProgress(e){return this._resourcesLoader.getSceneLoadingProgress(e)}areSceneAssetsLoaded(e){return this._resourcesLoader.areSceneAssetsLoaded(e)}areSceneAssetsReady(e){return this._resourcesLoader.areSceneAssetsReady(e)}loadAllAssets(e,t){this._throwIfDisposed(),this.loadFirstAssetsAndStartBackgroundLoading(this._getFirstSceneName(),t).then(e)}async loadFirstAssetsAndStartBackgroundLoading(e,t){try{const s=this._data.properties.loadingScreen.backgroundImageResourceName;s&&await this._resourcesLoader.getImageManager().loadResource(s),await Promise.all([this._loadAssetsWithLoadingScreen(!0,async i=>{await this._resourcesLoader.loadGlobalAndFirstSceneResources(e,i),this._resourcesLoader.loadAllSceneInBackground()},t),n.getAllAsynchronouslyLoadingLibraryPromise()])}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}async loadSceneAssets(e,t){await this._loadAssetsWithLoadingScreen(!1,async s=>{await this._resourcesLoader.loadAndProcessSceneResources(e,s)},t)}async _loadAssetsWithLoadingScreen(e,t,s){this.pause(!0);const i=new n.LoadingScreenRenderer(this.getRenderer(),this._resourcesLoader.getImageManager(),this._data.properties.loadingScreen,this._data.properties.watermark.showWatermark,e);await t(async(o,a)=>{const d=Math.floor(100*o/a);i.setPercent(d),s&&s(d),i.renderIfNeeded()&&await c(1)}),await i.unload(),this.pause(!1)}_getFirstSceneName(){const e=this._data.firstLayout;return this.hasScene(e)?e:this.getSceneAndExtensionsData().sceneData.name}startGameLoop(){this._throwIfDisposed();try{if(!this.hasScene()){g.error("The game has no scene.");return}this._forceGameResolutionUpdate(),this._sceneStack.push(this._getFirstSceneName(),this._injectExternalLayout),this._watermark.displayAtStartup(),this._setupGameVisibilityEvents();let e=0;this._hasJustResumed=!1,this._renderer.startGameLoop(t=>{try{if(this._paused||(e+=t,this._maxFPS>0&&1e3/e>this._maxFPS+7))return!0;const s=e;return e=0,this._notifyScenesForGameResolutionResize&&(this._sceneStack.onGameResolutionResized(),this._notifyScenesForGameResolutionResize=!1),this._sceneStack.step(s)?(this.getInputManager().onFrameEnded(),this._hasJustResumed=!1,!0):!1}catch(s){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(s),s}}),setTimeout(()=>{this._setupSessionMetrics()},4e3),this._captureManager&&this._captureManager.setupCaptureOptions(this._isPreview)}catch(e){throw this._debuggerClient&&this._debuggerClient.onUncaughtException(e),e}}dispose(){this._renderer.stopGameLoop(),this._sceneStack.dispose(),this._renderer.dispose(),this._resourcesLoader.dispose(),this._wasDisposed=!0}enableMetrics(e){this._disableMetrics=!e,e&&this._setupSessionMetrics()}_setupGameVisibilityEvents(){typeof navigator!="undefined"&&typeof document!="undefined"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&(this._hasJustResumed=!0)}),window.addEventListener("resume",()=>{this._hasJustResumed=!0},!1))}_setupSessionMetrics(){if(this._sessionMetricsInitialized||this._disableMetrics||this.isPreview()||typeof fetch=="undefined"||!this._data.properties.projectUuid)return;const e="https://api.gdevelop-app.com/analytics";this._playerId=this._makePlayerUuid();let t=0,s=0,i=Date.now();const r=this.getPlatformInfo();fetch(e+"/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,game:{name:this._data.properties.name||"",packageName:this._data.properties.packageName||"",version:this._data.properties.version||"",location:window.location.href},platform:{isCordova:r.isCordova,devicePlatform:r.devicePlatform,navigatorPlatform:r.navigatorPlatform,hasTouch:r.hasTouch}})}).then(a=>{if(!a.ok)throw console.error("Error while creating the session",a),new Error("Error while creating the session");return a}).then(a=>a.text()).then(a=>{this._sessionId=a}).catch(()=>{});const o=()=>{if(!this._sessionId)return;const a=Date.now();if(s+=a-i,i=a,s<5*1e3)return;const d=Math.floor(s/1e3)*1e3;t+=d,s-=d,navigator.sendBeacon(e+"/session-hit",JSON.stringify({gameId:this._data.properties.projectUuid,playerId:this._playerId,sessionId:this._sessionId,duration:Math.floor(t/1e3)}))};if(typeof navigator!="undefined"&&typeof document!="undefined"){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?i=Date.now():o()}),window.addEventListener("pagehide",o,!1),window.addEventListener("pause",o,!1),window.addEventListener("resume",()=>{i=Date.now()},!1);const a=typeof safari=="object"&&safari.pushNotification,d=/electron/i.test(navigator.userAgent);(a||d)&&window.addEventListener("beforeunload",()=>{o()})}this._sessionMetricsInitialized=!0,this._sessionId=this._sessionId}_makePlayerUuid(){try{const e="GDJS-internal-player-uuid",t=localStorage.getItem(e);if(t)return t;const s=n.makeUuid();return localStorage.setItem(e,s),s}catch{return n.makeUuid()}}getSessionId(){return this._sessionId}getPlayerId(){return this._playerId}onWindowInnerSizeChanged(){this._forceGameResolutionUpdate()}_forceGameResolutionUpdate(){this.setGameResolutionSize(this._gameResolutionWidth,this._gameResolutionHeight)}startCurrentSceneProfiler(e){this._throwIfDisposed();const t=this._sceneStack.getCurrentScene();return t?(t.startProfiler(e),!0):!1}stopCurrentSceneProfiler(){this._throwIfDisposed();const e=this._sceneStack.getCurrentScene();!e||e.stopProfiler()}wasFirstSceneLoaded(){return this._sceneStack.wasFirstSceneLoaded()}getSceneStack(){return this._sceneStack}isPreview(){return this._isPreview}isUsingGDevelopDevelopmentEnvironment(){return this._options.environment==="dev"}getExtensionProperty(e,t){for(let s of this._data.properties.extensionProperties)if(s.extension===e&&s.property===t)return s.value;return null}resolveEmbeddedResource(e,t){const s=this._embeddedResourcesMappings.get(e);return s&&s[t]?s[t]:t}getEmbeddedResourcesNames(e){return this._embeddedResourcesMappings.has(e)?Object.keys(this._embeddedResourcesMappings.get(e)):[]}getNetworkSyncData(e){const t={var:this._variables.getNetworkSyncData(e),ss:this._sceneStack.getNetworkSyncData(e)||void 0},s={};return this._variablesByExtensionName.forEach((i,r)=>{const o=i.getNetworkSyncData(e);o.length&&(s[r]=o)}),t.extVar=s,(!t.var||t.var.length===0)&&!t.ss&&(!t.extVar||Object.keys(t.extVar).length===0)?null:t}updateFromNetworkSyncData(e){if(this._throwIfDisposed(),e.var&&this._variables.updateFromNetworkSyncData(e.var),e.ss&&this._sceneStack.updateFromNetworkSyncData(e.ss),e.extVar)for(const t in e.extVar){if(!e.extVar.hasOwnProperty(t))continue;const s=e.extVar[t],i=this.getVariablesForExtension(t);i&&i.updateFromNetworkSyncData(s)}}_throwIfDisposed(){if(this._wasDisposed)throw"The RuntimeGame has been disposed and should not be used anymore."}}n.RuntimeGame=_})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=runtimegame.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../GDevelop/GDJS/Runtime/runtimegame.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 const logger = new gdjs.Logger('Game manager');\n\n const sleep = (ms: float) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n /** Identify a script file, with its content hash (useful for hot-reloading). */\n export type RuntimeGameOptionsScriptFile = {\n /** The path for this script file. */\n path: string;\n /** The hash of the script file content. */\n hash: number;\n };\n\n const getGlobalResourceNames = (projectData: ProjectData): Array<string> =>\n projectData.usedResources.map((resource) => resource.name);\n\n let supportedCompressionMethods: ('cs:gzip' | 'cs:deflate')[] | null = null;\n const getSupportedCompressionMethods = (): ('cs:gzip' | 'cs:deflate')[] => {\n if (!!supportedCompressionMethods) {\n return supportedCompressionMethods;\n }\n supportedCompressionMethods = [];\n\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('gzip');\n supportedCompressionMethods.push('cs:gzip');\n } catch (e) {}\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('deflate');\n supportedCompressionMethods.push('cs:deflate');\n } catch (e) {}\n\n return supportedCompressionMethods;\n };\n\n /** Options given to the game at startup. */\n export type RuntimeGameOptions = {\n /** if true, force fullscreen. */\n forceFullscreen?: boolean;\n /** if true, game is run as a preview launched from an editor. */\n isPreview?: boolean;\n /** The name of the external layout to create in the scene at position 0;0. */\n injectExternalLayout?: string;\n /** Script files, used for hot-reloading. */\n scriptFiles?: Array<RuntimeGameOptionsScriptFile>;\n /** if true, export is a partial preview without events. */\n projectDataOnlyExport?: boolean;\n /** if true, preview is launched from GDevelop native mobile app. */\n nativeMobileApp?: boolean;\n /** The address of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerAddress?: string;\n /** The port of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerPort?: string;\n\n /**\n * The path to require `@electron/remote` module.\n * This is only useful in a preview, where this can't be required from\n * `@electron/remote` directly as previews don't have any node_modules.\n * On the contrary, a game packaged with Electron as a standalone app\n * has its node_modules.\n * This can be removed once there are no more dependencies on\n * `@electron/remote` in the game engine and extensions.\n */\n electronRemoteRequirePath?: string;\n\n /**\n * The token to use by the game engine when requiring any resource stored on\n * GDevelop Cloud buckets. Note that this is only useful during previews.\n */\n gdevelopResourceToken?: string;\n\n /**\n * Check if, in some exceptional cases, we allow authentication\n * to be done through a iframe.\n * This is usually discouraged as the user can't verify that the authentication\n * window is a genuine one. It's only to be used in trusted contexts.\n */\n allowAuthenticationUsingIframeForPreview?: boolean;\n\n /** If set, the game will send crash reports to GDevelop APIs. */\n crashReportUploadLevel?: 'all' | 'exclude-javascript-code-events' | 'none';\n\n /** Arbitrary string explaining in which context the game is being played. */\n previewContext?: string;\n\n /** The GDevelop version used to build the game. */\n gdevelopVersionWithHash?: string;\n\n /** The template slug that was used to create the project. */\n projectTemplateSlug?: string;\n\n /** The source game id that was used to create the project. */\n sourceGameId?: string;\n\n /**\n * If set, this data is used to authenticate automatically when launching the game.\n * This is only useful during previews.\n */\n playerUsername?: string;\n playerId?: string;\n playerToken?: string;\n\n /**\n * If set, the game should use the specified environment for making calls\n * to GDevelop APIs (\"dev\" = development APIs).\n */\n environment?: 'dev';\n };\n\n /**\n * Represents a game being played.\n */\n export class RuntimeGame {\n _resourcesLoader: gdjs.ResourceLoader;\n _variables: VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _data: ProjectData;\n _sceneAndExtensionsData: Array<SceneAndExtensionsData> = [];\n _eventsBasedObjectDatas: Map<String, EventsBasedObjectData>;\n _effectsManager: EffectsManager;\n _maxFPS: integer;\n _minFPS: integer;\n _gameResolutionWidth: integer;\n _gameResolutionHeight: integer;\n _originalWidth: float;\n _originalHeight: float;\n _resizeMode: 'adaptWidth' | 'adaptHeight' | string;\n _adaptGameResolutionAtRuntime: boolean;\n _scaleMode: 'linear' | 'nearest';\n _pixelsRounding: boolean;\n _antialiasingMode: 'none' | 'MSAA';\n _isAntialisingEnabledOnMobile: boolean;\n /**\n * Game loop management (see startGameLoop method)\n */\n _renderer: RuntimeGameRenderer;\n _sessionId: string | null;\n _playerId: string | null;\n _watermark: watermark.RuntimeWatermark;\n\n _sceneStack: SceneStack;\n /**\n * When set to true, the scenes are notified that game resolution size changed.\n */\n _notifyScenesForGameResolutionResize: boolean = false;\n\n /**\n * When paused, the game won't step and will be freezed. Useful for debugging.\n */\n _paused: boolean = false;\n\n /**\n * True during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n _hasJustResumed: boolean = false;\n\n //Inputs :\n _inputManager: InputManager;\n\n /**\n * Allow to specify an external layout to insert in the first scene.\n */\n _injectExternalLayout: any;\n _options: RuntimeGameOptions;\n\n /**\n * The mappings for embedded resources\n */\n _embeddedResourcesMappings: Map<string, Record<string, string>>;\n\n /**\n * Optional client to connect to a debugger server.\n */\n _debuggerClient: gdjs.AbstractDebuggerClient | null;\n _sessionMetricsInitialized: boolean = false;\n _disableMetrics: boolean = false;\n _isPreview: boolean;\n\n /**\n * @param data The object (usually stored in data.json) containing the full project data\n * @param\n */\n constructor(data: ProjectData, options?: RuntimeGameOptions) {\n this._options = options || {};\n this._variables = new gdjs.VariablesContainer(data.variables);\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n for (const extensionData of data.eventsFunctionsExtensions) {\n if (extensionData.globalVariables.length > 0) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.globalVariables)\n );\n }\n }\n this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();\n this._data = data;\n this._updateSceneAndExtensionsData();\n\n this._resourcesLoader = new gdjs.ResourceLoader(\n this,\n data.resources.resources,\n getGlobalResourceNames(data),\n data.layouts\n );\n\n this._effectsManager = new gdjs.EffectsManager();\n this._maxFPS = this._data.properties.maxFPS;\n this._minFPS = this._data.properties.minFPS;\n this._gameResolutionWidth = this._data.properties.windowWidth;\n this._gameResolutionHeight = this._data.properties.windowHeight;\n this._originalWidth = this._gameResolutionWidth;\n this._originalHeight = this._gameResolutionHeight;\n this._resizeMode = this._data.properties.sizeOnStartupMode;\n this._adaptGameResolutionAtRuntime = this._data.properties.adaptGameResolutionAtRuntime;\n this._scaleMode = data.properties.scaleMode || 'linear';\n this._pixelsRounding = this._data.properties.pixelsRounding;\n this._antialiasingMode = this._data.properties.antialiasingMode;\n this._isAntialisingEnabledOnMobile = this._data.properties.antialisingEnabledOnMobile;\n this._renderer = new gdjs.RuntimeGameRenderer(\n this,\n this._options.forceFullscreen || false\n );\n this._watermark = new gdjs.watermark.RuntimeWatermark(\n this,\n data.properties.authorUsernames,\n this._data.properties.watermark\n );\n this._sceneStack = new gdjs.SceneStack(this);\n this._inputManager = new gdjs.InputManager();\n this._injectExternalLayout = this._options.injectExternalLayout || '';\n this._debuggerClient = gdjs.DebuggerClient\n ? new gdjs.DebuggerClient(this)\n : null;\n this._isPreview = this._options.isPreview || false;\n this._sessionId = null;\n this._playerId = null;\n\n this._embeddedResourcesMappings = new Map();\n for (const resource of this._data.resources.resources) {\n if (resource.metadata) {\n try {\n const metadata = JSON.parse(resource.metadata);\n if (metadata?.embeddedResourcesMapping) {\n this._embeddedResourcesMappings.set(\n resource.name,\n metadata.embeddedResourcesMapping\n );\n }\n } catch {\n logger.error(\n 'Some metadata of resources can not be successfully parsed.'\n );\n }\n }\n }\n\n if (this.isUsingGDevelopDevelopmentEnvironment()) {\n logger.info(\n 'This game will run on the development version of GDevelop APIs.'\n );\n }\n }\n\n /**\n * Update the project data. Useful for hot-reloading, should not be used otherwise.\n *\n * @param projectData The object (usually stored in data.json) containing the full project data\n */\n setProjectData(projectData: ProjectData): void {\n this._data = projectData;\n this._updateSceneAndExtensionsData();\n this._resourcesLoader.setResources(\n projectData.resources.resources,\n getGlobalResourceNames(projectData),\n projectData.layouts\n );\n }\n\n private _updateSceneAndExtensionsData(): void {\n const usedExtensionsWithVariablesData = this._data.eventsFunctionsExtensions.filter(\n (extensionData) => extensionData.sceneVariables.length > 0\n );\n this._sceneAndExtensionsData = this._data.layouts.map((sceneData) => ({\n sceneData,\n usedExtensionsWithVariablesData,\n }));\n\n this._eventsBasedObjectDatas.clear();\n if (this._data.eventsFunctionsExtensions) {\n for (const extension of this._data.eventsFunctionsExtensions) {\n for (const eventsBasedObject of extension.eventsBasedObjects) {\n this._eventsBasedObjectDatas.set(\n extension.name + '::' + eventsBasedObject.name,\n eventsBasedObject\n );\n }\n }\n }\n }\n\n /**\n * Return the additional options passed to the RuntimeGame when created.\n * @returns The additional options, if any.\n */\n getAdditionalOptions(): RuntimeGameOptions {\n return this._options;\n }\n\n getRenderer(): gdjs.RuntimeGameRenderer {\n return this._renderer;\n }\n\n /**\n * Get the variables of the RuntimeGame.\n * @return The global variables\n */\n getVariables(): gdjs.VariablesContainer {\n return this._variables;\n }\n\n /**\n * Get the extension's global variables.\n * @param extensionName The extension name.\n * @returns The extension's global variables.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._resourcesLoader.getSoundManager();\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._resourcesLoader.getImageManager();\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._resourcesLoader.getFontManager();\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._resourcesLoader.getBitmapFontManager();\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._resourcesLoader.getJsonManager();\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._resourcesLoader.getModel3DManager();\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._resourcesLoader.getSpineManager();\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._resourcesLoader.getSpineAtlasManager();\n }\n\n /**\n * Get the input manager of the game, storing mouse, keyboard\n * and touches states.\n * @return The input manager owned by the game\n */\n getInputManager(): gdjs.InputManager {\n return this._inputManager;\n }\n\n /**\n * Get the effects manager of the game, which allows to manage\n * effects on runtime objects or runtime layers.\n * @return The effects manager for the game\n */\n getEffectsManager(): gdjs.EffectsManager {\n return this._effectsManager;\n }\n\n /**\n * Get the object containing the game data\n * @return The object associated to the game.\n */\n getGameData(): ProjectData {\n return this._data;\n }\n\n getEventsBasedObjectData(type: string): EventsBasedObjectData | null {\n const eventsBasedObjectData = this._eventsBasedObjectDatas.get(type);\n if (!eventsBasedObjectData) {\n logger.error(\n 'The game has no events-based object of the type \"' + type + '\"'\n );\n return null;\n }\n return eventsBasedObjectData;\n }\n\n /**\n * Get the data associated to a scene.\n *\n * @param sceneName The name of the scene. If not defined, the first scene will be returned.\n * @return The data associated to the scene.\n */\n getSceneAndExtensionsData(\n sceneName?: string\n ): SceneAndExtensionsData | null {\n for (let i = 0, len = this._sceneAndExtensionsData.length; i < len; ++i) {\n const sceneAndExtensionsData = this._sceneAndExtensionsData[i];\n if (\n sceneName === undefined ||\n sceneAndExtensionsData.sceneData.name === sceneName\n ) {\n return sceneAndExtensionsData;\n }\n }\n logger.error('The game has no scene called \"' + sceneName + '\"');\n return null;\n }\n\n /**\n * Check if a scene exists\n *\n * @param sceneName The name of the scene to search.\n * @return true if the scene exists. If sceneName is undefined, true if the game has a scene.\n */\n hasScene(sceneName?: string): boolean {\n for (let i = 0, len = this._data.layouts.length; i < len; ++i) {\n const sceneData = this._data.layouts[i];\n if (sceneName === undefined || sceneData.name == sceneName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Get the data associated to an external layout.\n *\n * @param name The name of the external layout.\n * @return The data associated to the external layout or null if not found.\n */\n getExternalLayoutData(name: string): ExternalLayoutData | null {\n let externalLayout: ExternalLayoutData | null = null;\n for (let i = 0, len = this._data.externalLayouts.length; i < len; ++i) {\n const layoutData = this._data.externalLayouts[i];\n if (layoutData.name === name) {\n externalLayout = layoutData;\n break;\n }\n }\n return externalLayout;\n }\n\n /**\n * Get the data representing all the global objects of the game.\n * @return The data associated to the global objects.\n */\n getInitialObjectsData(): ObjectData[] {\n return this._data.objects || [];\n }\n\n /**\n * Get the original width of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalWidth(): float {\n return this._originalWidth;\n }\n\n /**\n * Get the original height of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalHeight(): float {\n return this._originalHeight;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) width.\n * @returns The game resolution width, in pixels.\n */\n getGameResolutionWidth(): float {\n return this._gameResolutionWidth;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) height.\n * @returns The game resolution height, in pixels.\n */\n getGameResolutionHeight(): float {\n return this._gameResolutionHeight;\n }\n\n /**\n * Change the game resolution.\n *\n * @param width The new width\n * @param height The new height\n */\n setGameResolutionSize(width: float, height: float): void {\n this._gameResolutionWidth = width;\n this._gameResolutionHeight = height;\n if (this._adaptGameResolutionAtRuntime) {\n if (\n gdjs.RuntimeGameRenderer &&\n gdjs.RuntimeGameRenderer.getWindowInnerWidth &&\n gdjs.RuntimeGameRenderer.getWindowInnerHeight\n ) {\n const windowInnerWidth = gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight = gdjs.RuntimeGameRenderer.getWindowInnerHeight();\n\n // Enlarge either the width or the eight to fill the inner window space.\n if (this._resizeMode === 'adaptWidth') {\n this._gameResolutionWidth =\n (this._gameResolutionHeight * windowInnerWidth) /\n windowInnerHeight;\n } else {\n if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n }\n }\n }\n } else {\n }\n\n // Don't alter the game resolution. The renderer\n // will maybe adapt the size of the canvas or whatever is used to render the\n // game in the window, but this does not change the \"game resolution\".\n\n // Notify the renderer that game resolution changed (so that the renderer size\n // can be updated, and maybe other things like the canvas size), and let the\n // scenes know too.\n this._renderer.updateRendererSize();\n this._notifyScenesForGameResolutionResize = true;\n }\n\n /**\n * Set if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically.\n *\n * @param resizeMode Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n setGameResolutionResizeMode(resizeMode: string): void {\n this._resizeMode = resizeMode;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically (empty string).\n *\n * @returns Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n getGameResolutionResizeMode(): string {\n return this._resizeMode;\n }\n\n /**\n * Set if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @param enable true to change the game resolution according to the window/screen size.\n */\n setAdaptGameResolutionAtRuntime(enable: boolean): void {\n this._adaptGameResolutionAtRuntime = enable;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @returns true if the game resolution is automatically changed according to the window/screen size.\n */\n getAdaptGameResolutionAtRuntime(): boolean {\n return this._adaptGameResolutionAtRuntime;\n }\n\n /**\n * Return the minimal fps that must be guaranteed by the game\n * (otherwise, game is slowed down).\n */\n getMinimalFramerate(): integer {\n return this._minFPS;\n }\n\n /**\n * Return the scale mode of the game (\"linear\" or \"nearest\").\n */\n getScaleMode(): 'linear' | 'nearest' {\n return this._scaleMode;\n }\n\n /**\n * Return if the game is rounding pixels when rendering.\n */\n getPixelsRounding(): boolean {\n return this._pixelsRounding;\n }\n\n /**\n * Return the antialiasing mode used by the game (\"none\" or \"MSAA\").\n */\n getAntialiasingMode(): 'none' | 'MSAA' {\n return this._antialiasingMode;\n }\n\n /**\n * Return true if antialising is enabled on mobiles.\n */\n isAntialisingEnabledOnMobile(): boolean {\n return this._isAntialisingEnabledOnMobile;\n }\n\n /**\n * Set or unset the game as paused.\n * When paused, the game won't step and will be freezed. Useful for debugging.\n * @param enable true to pause the game, false to unpause\n */\n pause(enable: boolean) {\n if (this._paused === enable) return;\n\n this._paused = enable;\n if (this._debuggerClient) {\n if (this._paused) this._debuggerClient.sendGamePaused();\n else this._debuggerClient.sendGameResumed();\n }\n }\n\n /**\n * @returns true during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n hasJustResumed() {\n return this._hasJustResumed;\n }\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n prioritizeLoadingOfScene(sceneName: string) {\n // Don't await the scene assets to be loaded.\n this._resourcesLoader.loadSceneResources(sceneName);\n }\n\n /**\n * @return The progress of assets loading in background for a scene\n * (between 0 and 1).\n */\n getSceneLoadingProgress(sceneName: string): number {\n return this._resourcesLoader.getSceneLoadingProgress(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsLoaded(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsReady(sceneName);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n */\n loadAllAssets(\n callback: () => void,\n progressCallback?: (progress: float) => void\n ) {\n this.loadFirstAssetsAndStartBackgroundLoading(\n this._getFirstSceneName(),\n progressCallback\n ).then(callback);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n *\n * When a game is hot-reload, this method can be called with the current\n * scene.\n */\n async loadFirstAssetsAndStartBackgroundLoading(\n firstSceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n try {\n // Download the loading screen background image first to be able to\n // display the loading screen as soon as possible.\n const backgroundImageResourceName = this._data.properties.loadingScreen\n .backgroundImageResourceName;\n if (backgroundImageResourceName) {\n await this._resourcesLoader\n .getImageManager()\n .loadResource(backgroundImageResourceName);\n }\n await Promise.all([\n this._loadAssetsWithLoadingScreen(\n /* isFirstScene = */ true,\n async (onProgress) => {\n // TODO Is a setting needed?\n if (false) {\n await this._resourcesLoader.loadAllResources(onProgress);\n } else {\n await this._resourcesLoader.loadGlobalAndFirstSceneResources(\n firstSceneName,\n onProgress\n );\n // Don't await as it must not block the first scene from starting.\n this._resourcesLoader.loadAllSceneInBackground();\n }\n },\n progressCallback\n ),\n // TODO This is probably not necessary in case of hot reload.\n gdjs.getAllAsynchronouslyLoadingLibraryPromise(),\n ]);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Load all assets for a given scene, displaying progress in renderer.\n */\n async loadSceneAssets(\n sceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n await this._loadAssetsWithLoadingScreen(\n /* isFirstLayout = */ false,\n async (onProgress) => {\n await this._resourcesLoader.loadAndProcessSceneResources(\n sceneName,\n onProgress\n );\n },\n progressCallback\n );\n }\n\n /**\n * Load assets, displaying progress in renderer.\n */\n private async _loadAssetsWithLoadingScreen(\n isFirstScene: boolean,\n loadAssets: (\n onProgress: (count: integer, total: integer) => Promise<void>\n ) => Promise<void>,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n this.pause(true);\n const loadingScreen = new gdjs.LoadingScreenRenderer(\n this.getRenderer(),\n this._resourcesLoader.getImageManager(),\n this._data.properties.loadingScreen,\n this._data.properties.watermark.showWatermark,\n isFirstScene\n );\n\n const onProgress = async (count: integer, total: integer) => {\n const percent = Math.floor((100 * count) / total);\n loadingScreen.setPercent(percent);\n if (progressCallback) {\n progressCallback(percent);\n }\n const hasRendered = loadingScreen.renderIfNeeded();\n if (hasRendered) {\n // Give a chance to draw calls from the renderer to be handled.\n await sleep(1);\n }\n };\n await loadAssets(onProgress);\n\n await loadingScreen.unload();\n this.pause(false);\n }\n\n private _getFirstSceneName(): string {\n const firstSceneName = this._data.firstLayout;\n return this.hasScene(firstSceneName)\n ? firstSceneName\n : // There is always at least a scene\n this.getSceneAndExtensionsData()!.sceneData.name;\n }\n\n /**\n * Start the game loop, to be called once assets are loaded.\n */\n startGameLoop() {\n try {\n if (!this.hasScene()) {\n logger.error('The game has no scene.');\n return;\n }\n this._forceGameResolutionUpdate();\n\n // Load the first scene\n this._sceneStack.push(\n this._getFirstSceneName(),\n this._injectExternalLayout\n );\n this._watermark.displayAtStartup();\n\n //Uncomment to profile the first x frames of the game.\n // var x = 500;\n // var startTime = Date.now();\n // console.profile(\"Stepping for \" + x + \" frames\")\n // for(var i = 0; i < x; ++i) {\n // this._sceneStack.step(16);\n // }\n // console.profileEnd();\n // var time = Date.now() - startTime;\n // logger.log(\"Took\", time, \"ms\");\n // return;\n\n this._setupGameVisibilityEvents();\n\n // The standard game loop\n let accumulatedElapsedTime = 0;\n this._hasJustResumed = false;\n this._renderer.startGameLoop((lastCallElapsedTime) => {\n try {\n if (this._paused) {\n return true;\n }\n\n // Skip the frame if we rendering frames too fast\n accumulatedElapsedTime += lastCallElapsedTime;\n if (\n this._maxFPS > 0 &&\n 1000.0 / accumulatedElapsedTime > this._maxFPS + 7\n ) {\n // Only skip frame if the framerate is 7 frames above the maximum framerate.\n // Most browser/engines will try to run at slightly more than 60 frames per second.\n // If game is set to have a maximum FPS to 60, then one out of two frames will be dropped.\n // Hence, we use a 7 frames margin to ensure that we're not skipping frames too much.\n return true;\n }\n const elapsedTime = accumulatedElapsedTime;\n accumulatedElapsedTime = 0;\n\n // Manage resize events.\n if (this._notifyScenesForGameResolutionResize) {\n this._sceneStack.onGameResolutionResized();\n this._notifyScenesForGameResolutionResize = false;\n }\n\n // Render and step the scene.\n if (this._sceneStack.step(elapsedTime)) {\n this.getInputManager().onFrameEnded();\n this._hasJustResumed = false;\n return true;\n }\n return false;\n } catch (e) {\n if (this._debuggerClient)\n this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n });\n setTimeout(() => {\n this._setupSessionMetrics();\n }, 4000);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Set if the session should be registered.\n */\n enableMetrics(enable: boolean): void {\n this._disableMetrics = !enable;\n if (enable) {\n this._setupSessionMetrics();\n }\n }\n\n /**\n * Helper function to get information about the platform running the game.\n */\n getPlatformInfo = () => {\n return {\n // @ts-ignore\n isCordova: !!window.cordova,\n devicePlatform:\n // @ts-ignore\n typeof device !== 'undefined' ? device.platform || '' : '',\n navigatorPlatform:\n typeof navigator !== 'undefined' ? navigator.platform : '',\n hasTouch:\n typeof navigator !== 'undefined'\n ? !!navigator.maxTouchPoints && navigator.maxTouchPoints > 2\n : false,\n supportedCompressionMethods: getSupportedCompressionMethods(),\n };\n };\n\n _setupGameVisibilityEvents() {\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this._hasJustResumed = true;\n }\n });\n window.addEventListener(\n 'resume',\n () => {\n this._hasJustResumed = true;\n },\n false\n );\n }\n }\n\n /**\n * Register a new session for the game, and set up listeners to follow the session\n * time.\n */\n _setupSessionMetrics() {\n if (this._sessionMetricsInitialized) {\n return;\n }\n if (this._disableMetrics) {\n return;\n }\n if (this.isPreview()) {\n return;\n }\n if (typeof fetch === 'undefined') {\n return;\n }\n if (!this._data.properties.projectUuid) {\n return;\n }\n const baseUrl = 'https://api.gdevelop-app.com/analytics';\n this._playerId = this._makePlayerUuid();\n /**\n * The duration that is already sent to the service\n * (in milliseconds).\n **/\n let sentDuration = 0;\n /**\n * The duration that is not yet sent to the service to avoid flooding\n * (in milliseconds).\n **/\n let notYetSentDuration = 0;\n /**\n * The last time when duration has been counted\n * either in sendedDuration or notYetSentDuration.\n **/\n let lastSessionResumeTime = Date.now();\n const platform = this.getPlatformInfo();\n fetch(baseUrl + '/session', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n // It's important to ensure that the data sent here does not contain\n // any personal information from the player or that would allow to\n // precisely identify someone.\n body: JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n game: {\n name: this._data.properties.name || '',\n packageName: this._data.properties.packageName || '',\n version: this._data.properties.version || '',\n location: window.location.href,\n },\n platform: {\n isCordova: platform.isCordova,\n devicePlatform: platform.devicePlatform,\n navigatorPlatform: platform.navigatorPlatform,\n hasTouch: platform.hasTouch,\n },\n }),\n })\n .then((response) => {\n // Ensure the session is correctly created to avoid sending hits that will fail.\n if (!response.ok) {\n console.error('Error while creating the session', response);\n throw new Error('Error while creating the session');\n }\n return response;\n })\n .then((response) => response.text())\n .then((returnedSessionId) => {\n this._sessionId = returnedSessionId;\n })\n .catch(() => {});\n\n /* Ignore any error */\n const sendSessionHit = () => {\n if (!this._sessionId) {\n return;\n }\n\n const now = Date.now();\n notYetSentDuration += now - lastSessionResumeTime;\n lastSessionResumeTime = now;\n\n // Group repeated calls to sendSessionHit - which could\n // happen because of multiple event listeners being fired.\n if (notYetSentDuration < 5 * 1000) {\n return;\n }\n // The backend use seconds for duration.\n // The milliseconds will stay in notYetSentDuration.\n const toBeSentDuration = Math.floor(notYetSentDuration / 1000) * 1000;\n sentDuration += toBeSentDuration;\n notYetSentDuration -= toBeSentDuration;\n\n navigator.sendBeacon(\n baseUrl + '/session-hit',\n JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n sessionId: this._sessionId,\n duration: Math.floor(sentDuration / 1000),\n })\n );\n };\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n } else {\n sendSessionHit();\n }\n });\n window.addEventListener('pagehide', sendSessionHit, false);\n // Cordova events\n window.addEventListener('pause', sendSessionHit, false);\n window.addEventListener(\n 'resume',\n () => {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n },\n false\n );\n\n // Detect Safari to work around Safari-specific bugs:\n // - https://bugs.webkit.org/show_bug.cgi?id=151610\n // - https://bugs.webkit.org/show_bug.cgi?id=151234\n // @ts-ignore\n const isSafari = typeof safari === 'object' && safari.pushNotification;\n const isElectron = /electron/i.test(navigator.userAgent);\n if (isSafari || isElectron) {\n window.addEventListener('beforeunload', () => {\n sendSessionHit();\n });\n }\n }\n this._sessionMetricsInitialized = true;\n this._sessionId = this._sessionId;\n }\n\n /**\n * Generate an anonymous unique identifier to differentiate\n * the player from others in the game metrics.\n */\n _makePlayerUuid(): string {\n try {\n const key = 'GDJS-internal-player-uuid';\n const existingPlayerUuid = localStorage.getItem(key);\n if (existingPlayerUuid) {\n return existingPlayerUuid;\n }\n const newPlayerUuid = gdjs.makeUuid();\n localStorage.setItem(key, newPlayerUuid);\n return newPlayerUuid;\n } catch (err) {\n return gdjs.makeUuid();\n }\n }\n\n getSessionId(): string | null {\n return this._sessionId;\n }\n\n getPlayerId(): string | null {\n return this._playerId;\n }\n\n /**\n * Called by the game renderer when the window containing the game\n * has changed size (this can result from a resize of the window,\n * but also other factors like a device orientation change on mobile).\n */\n onWindowInnerSizeChanged() {\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Enlarge/reduce the width (or the height) of the game to fill the inner window.\n */\n _forceGameResolutionUpdate() {\n this.setGameResolutionSize(\n this._gameResolutionWidth,\n this._gameResolutionHeight\n );\n }\n\n /**\n * Start a profiler for the currently running scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startCurrentSceneProfiler(\n onProfilerStopped: (oldProfiler: Profiler) => void\n ) {\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return false;\n }\n currentScene.startProfiler(onProfilerStopped);\n return true;\n }\n\n /**\n * Stop the profiler for the currently running scene.\n */\n stopCurrentSceneProfiler() {\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return;\n }\n currentScene.stopProfiler();\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._sceneStack.wasFirstSceneLoaded();\n }\n\n /**\n * Return the stack of {@link gdjs.RuntimeScene} being played.\n */\n getSceneStack(): gdjs.SceneStack {\n return this._sceneStack;\n }\n\n /**\n * Check if the game is running as a preview, launched from an editor.\n * @returns true if the current game is a preview.\n */\n isPreview(): boolean {\n return this._isPreview;\n }\n\n /**\n * Check if the game should call GDevelop development APIs or not.\n *\n * Unless you are contributing to GDevelop, avoid using this.\n */\n isUsingGDevelopDevelopmentEnvironment(): boolean {\n return this._options.environment === 'dev';\n }\n\n /**\n * Gets an extension property from the project data.\n * @param extensionName The extension name.\n * @param propertyName The property name.\n * @return The property value.\n */\n getExtensionProperty(\n extensionName: string,\n propertyName: string\n ): string | null {\n for (let property of this._data.properties.extensionProperties) {\n if (\n property.extension === extensionName &&\n property.property === propertyName\n ) {\n return property.value;\n }\n }\n return null;\n }\n\n /**\n * Resolves the name of an embedded resource.\n * @param mainResourceName The name of the resource containing the embedded resource.\n * @param embeddedResourceName The name of the embedded resource.\n * @return The resource name.\n */\n resolveEmbeddedResource(\n mainResourceName: string,\n embeddedResourceName: string\n ): string {\n const mapping = this._embeddedResourcesMappings.get(mainResourceName);\n return mapping && mapping[embeddedResourceName]\n ? mapping[embeddedResourceName]\n : embeddedResourceName;\n }\n\n /**\n * Returns the array of resources that are embedded to passed one.\n * @param resourceName The name of resource to find embedded resources of.\n * @returns The array of related resources names.\n */\n getEmbeddedResourcesNames(resourceName: string): string[] {\n return this._embeddedResourcesMappings.has(resourceName)\n ? Object.keys(this._embeddedResourcesMappings.get(resourceName)!)\n : [];\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): GameNetworkSyncData | null {\n const syncData: GameNetworkSyncData = {\n var: this._variables.getNetworkSyncData(syncOptions),\n ss: this._sceneStack.getNetworkSyncData(syncOptions) || undefined,\n };\n\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[\n extensionName\n ] = extensionVariablesSyncData;\n }\n });\n syncData.extVar = extensionsVariablesSyncData;\n\n if (\n (!syncData.var || syncData.var.length === 0) &&\n !syncData.ss &&\n (!syncData.extVar || Object.keys(syncData.extVar).length === 0)\n ) {\n // Nothing to sync.\n return null;\n }\n\n return syncData;\n }\n\n updateFromNetworkSyncData(syncData: GameNetworkSyncData) {\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var);\n }\n if (syncData.ss) {\n this._sceneStack.updateFromNetworkSyncData(syncData.ss);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables = this.getVariablesForExtension(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\n }\n }\n }\n}\n"],
5
- "mappings": "AAKA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAA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AAgC,CACpC,IAAK,KAAK,WAAW,mBAAmB,GACxC,GAAI,KAAK,YAAY,mBAAmB,IAAgB,QAGpD,EAA8B,GAcpC,MAbA,MAAK,0BAA0B,QAAQ,CAAC,EAAW,IAAkB,CACnE,KAAM,GAA6B,EAAU,mBAC3C,GAGF,AAAI,EAA2B,QAC7B,GACE,GACE,KAGR,EAAS,OAAS,EAGf,EAAC,EAAS,KAAO,EAAS,IAAI,SAAW,IAC1C,CAAC,EAAS,IACT,EAAC,EAAS,QAAU,OAAO,KAAK,EAAS,QAAQ,SAAW,GAGtD,KAGF,EAGT,0BAA0B,EAA+B,CAOvD,GANI,EAAS,KACX,KAAK,WAAW,0BAA0B,EAAS,KAEjD,EAAS,IACX,KAAK,YAAY,0BAA0B,EAAS,IAElD,EAAS,OACX,SAAW,KAAiB,GAAS,OAAQ,CAC3C,GAAI,CAAC,EAAS,OAAO,eAAe,GAClC,SAEF,KAAM,GAAyB,EAAS,OAAO,GACzC,EAAqB,KAAK,yBAC9B,GAEF,AAAI,GACF,EAAmB,0BACjB,KA5rCL,EAAM,gBAnHL",
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 const logger = new gdjs.Logger('Game manager');\n\n const sleep = (ms: float) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n /** Identify a script file, with its content hash (useful for hot-reloading). */\n export type RuntimeGameOptionsScriptFile = {\n /** The path for this script file. */\n path: string;\n /** The hash of the script file content. */\n hash: number;\n };\n\n const getGlobalResourceNames = (projectData: ProjectData): Array<string> =>\n projectData.usedResources.map((resource) => resource.name);\n\n let supportedCompressionMethods: ('cs:gzip' | 'cs:deflate')[] | null = null;\n const getSupportedCompressionMethods = (): ('cs:gzip' | 'cs:deflate')[] => {\n if (!!supportedCompressionMethods) {\n return supportedCompressionMethods;\n }\n supportedCompressionMethods = [];\n\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('gzip');\n supportedCompressionMethods.push('cs:gzip');\n } catch (e) {}\n try {\n // @ts-ignore - We are checking if the CompressionStream is available.\n new CompressionStream('deflate');\n supportedCompressionMethods.push('cs:deflate');\n } catch (e) {}\n\n return supportedCompressionMethods;\n };\n\n /** Options given to the game at startup. */\n export type RuntimeGameOptions = {\n /** if true, force fullscreen. */\n forceFullscreen?: boolean;\n /** if true, game is run as a preview launched from an editor. */\n isPreview?: boolean;\n /** The name of the external layout to create in the scene at position 0;0. */\n injectExternalLayout?: string;\n /** Script files, used for hot-reloading. */\n scriptFiles?: Array<RuntimeGameOptionsScriptFile>;\n /** if true, export is a partial preview without events. */\n projectDataOnlyExport?: boolean;\n /** if true, preview is launched from GDevelop native mobile app. */\n nativeMobileApp?: boolean;\n /** The address of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerAddress?: string;\n /** The port of the debugger server, to reach out using WebSocket. */\n websocketDebuggerServerPort?: string;\n\n /**\n * The path to require `@electron/remote` module.\n * This is only useful in a preview, where this can't be required from\n * `@electron/remote` directly as previews don't have any node_modules.\n * On the contrary, a game packaged with Electron as a standalone app\n * has its node_modules.\n * This can be removed once there are no more dependencies on\n * `@electron/remote` in the game engine and extensions.\n */\n electronRemoteRequirePath?: string;\n\n /**\n * The token to use by the game engine when requiring any resource stored on\n * GDevelop Cloud buckets. Note that this is only useful during previews.\n */\n gdevelopResourceToken?: string;\n\n /**\n * Check if, in some exceptional cases, we allow authentication\n * to be done through a iframe.\n * This is usually discouraged as the user can't verify that the authentication\n * window is a genuine one. It's only to be used in trusted contexts.\n */\n allowAuthenticationUsingIframeForPreview?: boolean;\n\n /** If set, the game will send crash reports to GDevelop APIs. */\n crashReportUploadLevel?: 'all' | 'exclude-javascript-code-events' | 'none';\n\n /** Arbitrary string explaining in which context the game is being played. */\n previewContext?: string;\n\n /** The GDevelop version used to build the game. */\n gdevelopVersionWithHash?: string;\n\n /** The template slug that was used to create the project. */\n projectTemplateSlug?: string;\n\n /** The source game id that was used to create the project. */\n sourceGameId?: string;\n\n /** Any capture that should be done during the preview. */\n captureOptions?: CaptureOptions;\n\n /**\n * If set, this data is used to authenticate automatically when launching the game.\n * This is only useful during previews.\n */\n playerUsername?: string;\n playerId?: string;\n playerToken?: string;\n\n /**\n * If set, the game should use the specified environment for making calls\n * to GDevelop APIs (\"dev\" = development APIs).\n */\n environment?: 'dev';\n };\n\n /**\n * Represents a game being played.\n */\n export class RuntimeGame {\n _resourcesLoader: gdjs.ResourceLoader;\n _variables: VariablesContainer;\n _variablesByExtensionName: Map<string, gdjs.VariablesContainer>;\n _data: ProjectData;\n _sceneAndExtensionsData: Array<SceneAndExtensionsData> = [];\n _eventsBasedObjectDatas: Map<String, EventsBasedObjectData>;\n _effectsManager: EffectsManager;\n _maxFPS: integer;\n _minFPS: integer;\n _gameResolutionWidth: integer;\n _gameResolutionHeight: integer;\n _originalWidth: float;\n _originalHeight: float;\n _resizeMode: 'adaptWidth' | 'adaptHeight' | string;\n _adaptGameResolutionAtRuntime: boolean;\n _scaleMode: 'linear' | 'nearest';\n _pixelsRounding: boolean;\n _antialiasingMode: 'none' | 'MSAA';\n _isAntialisingEnabledOnMobile: boolean;\n /**\n * Game loop management (see startGameLoop method)\n */\n _renderer: RuntimeGameRenderer;\n _sessionId: string | null;\n _playerId: string | null;\n _watermark: watermark.RuntimeWatermark;\n\n _sceneStack: SceneStack;\n /**\n * When set to true, the scenes are notified that game resolution size changed.\n */\n _notifyScenesForGameResolutionResize: boolean = false;\n\n /**\n * When paused, the game won't step and will be freezed. Useful for debugging.\n */\n _paused: boolean = false;\n\n /**\n * True during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n _hasJustResumed: boolean = false;\n\n //Inputs :\n _inputManager: InputManager;\n\n /**\n * Allow to specify an external layout to insert in the first scene.\n */\n _injectExternalLayout: any;\n _options: RuntimeGameOptions;\n\n /**\n * The mappings for embedded resources\n */\n _embeddedResourcesMappings: Map<string, Record<string, string>>;\n\n /**\n * Optional client to connect to a debugger server.\n */\n _debuggerClient: gdjs.AbstractDebuggerClient | null;\n _sessionMetricsInitialized: boolean = false;\n _disableMetrics: boolean = false;\n _isPreview: boolean;\n\n /**\n * The capture manager, used to manage captures (screenshots, videos, etc...).\n */\n _captureManager: CaptureManager | null;\n\n /** True if the RuntimeGame has been disposed and should not be used anymore. */\n _wasDisposed: boolean = false;\n\n /**\n * @param data The object (usually stored in data.json) containing the full project data\n * @param\n */\n constructor(data: ProjectData, options?: RuntimeGameOptions) {\n this._options = options || {};\n this._variables = new gdjs.VariablesContainer(data.variables);\n this._variablesByExtensionName = new Map<\n string,\n gdjs.VariablesContainer\n >();\n for (const extensionData of data.eventsFunctionsExtensions) {\n if (extensionData.globalVariables.length > 0) {\n this._variablesByExtensionName.set(\n extensionData.name,\n new gdjs.VariablesContainer(extensionData.globalVariables)\n );\n }\n }\n this._eventsBasedObjectDatas = new Map<String, EventsBasedObjectData>();\n this._data = data;\n this._updateSceneAndExtensionsData();\n\n this._resourcesLoader = new gdjs.ResourceLoader(\n this,\n data.resources.resources,\n getGlobalResourceNames(data),\n data.layouts\n );\n\n this._effectsManager = new gdjs.EffectsManager();\n this._maxFPS = this._data.properties.maxFPS;\n this._minFPS = this._data.properties.minFPS;\n this._gameResolutionWidth = this._data.properties.windowWidth;\n this._gameResolutionHeight = this._data.properties.windowHeight;\n this._originalWidth = this._gameResolutionWidth;\n this._originalHeight = this._gameResolutionHeight;\n this._resizeMode = this._data.properties.sizeOnStartupMode;\n this._adaptGameResolutionAtRuntime = this._data.properties.adaptGameResolutionAtRuntime;\n this._scaleMode = data.properties.scaleMode || 'linear';\n this._pixelsRounding = this._data.properties.pixelsRounding;\n this._antialiasingMode = this._data.properties.antialiasingMode;\n this._isAntialisingEnabledOnMobile = this._data.properties.antialisingEnabledOnMobile;\n this._renderer = new gdjs.RuntimeGameRenderer(\n this,\n this._options.forceFullscreen || false\n );\n this._watermark = new gdjs.watermark.RuntimeWatermark(\n this,\n data.properties.authorUsernames,\n this._data.properties.watermark\n );\n this._sceneStack = new gdjs.SceneStack(this);\n this._inputManager = new gdjs.InputManager();\n this._injectExternalLayout = this._options.injectExternalLayout || '';\n this._debuggerClient = gdjs.DebuggerClient\n ? new gdjs.DebuggerClient(this)\n : null;\n this._captureManager = gdjs.CaptureManager\n ? new gdjs.CaptureManager(\n this._renderer,\n this._options.captureOptions || {}\n )\n : null;\n this._isPreview = this._options.isPreview || false;\n this._sessionId = null;\n this._playerId = null;\n\n this._embeddedResourcesMappings = new Map();\n for (const resource of this._data.resources.resources) {\n if (resource.metadata) {\n try {\n const metadata = JSON.parse(resource.metadata);\n if (metadata?.embeddedResourcesMapping) {\n this._embeddedResourcesMappings.set(\n resource.name,\n metadata.embeddedResourcesMapping\n );\n }\n } catch {\n logger.error(\n 'Some metadata of resources can not be successfully parsed.'\n );\n }\n }\n }\n\n if (this.isUsingGDevelopDevelopmentEnvironment()) {\n logger.info(\n 'This game will run on the development version of GDevelop APIs.'\n );\n }\n }\n\n /**\n * Update the project data. Useful for hot-reloading, should not be used otherwise.\n *\n * @param projectData The object (usually stored in data.json) containing the full project data\n */\n setProjectData(projectData: ProjectData): void {\n this._data = projectData;\n this._updateSceneAndExtensionsData();\n this._resourcesLoader.setResources(\n projectData.resources.resources,\n getGlobalResourceNames(projectData),\n projectData.layouts\n );\n }\n\n private _updateSceneAndExtensionsData(): void {\n const usedExtensionsWithVariablesData = this._data.eventsFunctionsExtensions.filter(\n (extensionData) => extensionData.sceneVariables.length > 0\n );\n this._sceneAndExtensionsData = this._data.layouts.map((sceneData) => ({\n sceneData,\n usedExtensionsWithVariablesData,\n }));\n\n this._eventsBasedObjectDatas.clear();\n if (this._data.eventsFunctionsExtensions) {\n for (const extension of this._data.eventsFunctionsExtensions) {\n for (const eventsBasedObject of extension.eventsBasedObjects) {\n this._eventsBasedObjectDatas.set(\n extension.name + '::' + eventsBasedObject.name,\n eventsBasedObject\n );\n }\n }\n }\n }\n\n /**\n * Return the additional options passed to the RuntimeGame when created.\n * @returns The additional options, if any.\n */\n getAdditionalOptions(): RuntimeGameOptions {\n return this._options;\n }\n\n getRenderer(): gdjs.RuntimeGameRenderer {\n return this._renderer;\n }\n\n /**\n * Get the variables of the RuntimeGame.\n * @return The global variables\n */\n getVariables(): gdjs.VariablesContainer {\n return this._variables;\n }\n\n /**\n * Get the extension's global variables.\n * @param extensionName The extension name.\n * @returns The extension's global variables.\n */\n getVariablesForExtension(extensionName: string) {\n return this._variablesByExtensionName.get(extensionName) || null;\n }\n\n /**\n * Get the gdjs.SoundManager of the RuntimeGame.\n * @return The sound manager.\n */\n getSoundManager(): gdjs.HowlerSoundManager {\n return this._resourcesLoader.getSoundManager();\n }\n\n /**\n * Get the gdjs.ImageManager of the RuntimeGame.\n * @return The image manager.\n */\n getImageManager(): gdjs.PixiImageManager {\n return this._resourcesLoader.getImageManager();\n }\n\n /**\n * Get the gdjs.FontManager of the RuntimeGame.\n * @return The font manager.\n */\n getFontManager(): gdjs.FontFaceObserverFontManager {\n return this._resourcesLoader.getFontManager();\n }\n\n /**\n * Get the gdjs.BitmapFontManager of the RuntimeGame.\n * @return The bitmap font manager.\n */\n getBitmapFontManager(): gdjs.BitmapFontManager {\n return this._resourcesLoader.getBitmapFontManager();\n }\n\n /**\n * Get the JSON manager of the game, used to load JSON from game\n * resources.\n * @return The json manager for the game\n */\n getJsonManager(): gdjs.JsonManager {\n return this._resourcesLoader.getJsonManager();\n }\n\n /**\n * Get the 3D model manager of the game, used to load 3D model from game\n * resources.\n * @return The 3D model manager for the game\n */\n getModel3DManager(): gdjs.Model3DManager {\n return this._resourcesLoader.getModel3DManager();\n }\n\n /**\n * Get the Spine manager of the game, used to load and construct spine skeletons from game\n * resources.\n * @return The Spine manager for the game\n */\n getSpineManager(): gdjs.SpineManager | null {\n return this._resourcesLoader.getSpineManager();\n }\n\n /**\n * Get the Spine Atlas manager of the game, used to load atlases from game\n * resources.\n * @return The Spine Atlas manager for the game\n */\n getSpineAtlasManager(): gdjs.SpineAtlasManager | null {\n return this._resourcesLoader.getSpineAtlasManager();\n }\n\n /**\n * Get the input manager of the game, storing mouse, keyboard\n * and touches states.\n * @return The input manager owned by the game\n */\n getInputManager(): gdjs.InputManager {\n return this._inputManager;\n }\n\n /**\n * Get the effects manager of the game, which allows to manage\n * effects on runtime objects or runtime layers.\n * @return The effects manager for the game\n */\n getEffectsManager(): gdjs.EffectsManager {\n return this._effectsManager;\n }\n\n /**\n * Get the object containing the game data\n * @return The object associated to the game.\n */\n getGameData(): ProjectData {\n return this._data;\n }\n\n getEventsBasedObjectData(type: string): EventsBasedObjectData | null {\n const eventsBasedObjectData = this._eventsBasedObjectDatas.get(type);\n if (!eventsBasedObjectData) {\n logger.error(\n 'The game has no events-based object of the type \"' + type + '\"'\n );\n return null;\n }\n return eventsBasedObjectData;\n }\n\n /**\n * Get the data associated to a scene.\n *\n * @param sceneName The name of the scene. If not defined, the first scene will be returned.\n * @return The data associated to the scene.\n */\n getSceneAndExtensionsData(\n sceneName?: string\n ): SceneAndExtensionsData | null {\n for (let i = 0, len = this._sceneAndExtensionsData.length; i < len; ++i) {\n const sceneAndExtensionsData = this._sceneAndExtensionsData[i];\n if (\n sceneName === undefined ||\n sceneAndExtensionsData.sceneData.name === sceneName\n ) {\n return sceneAndExtensionsData;\n }\n }\n logger.error('The game has no scene called \"' + sceneName + '\"');\n return null;\n }\n\n /**\n * Check if a scene exists\n *\n * @param sceneName The name of the scene to search.\n * @return true if the scene exists. If sceneName is undefined, true if the game has a scene.\n */\n hasScene(sceneName?: string): boolean {\n for (let i = 0, len = this._data.layouts.length; i < len; ++i) {\n const sceneData = this._data.layouts[i];\n if (sceneName === undefined || sceneData.name == sceneName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Get the data associated to an external layout.\n *\n * @param name The name of the external layout.\n * @return The data associated to the external layout or null if not found.\n */\n getExternalLayoutData(name: string): ExternalLayoutData | null {\n let externalLayout: ExternalLayoutData | null = null;\n for (let i = 0, len = this._data.externalLayouts.length; i < len; ++i) {\n const layoutData = this._data.externalLayouts[i];\n if (layoutData.name === name) {\n externalLayout = layoutData;\n break;\n }\n }\n return externalLayout;\n }\n\n /**\n * Get the data representing all the global objects of the game.\n * @return The data associated to the global objects.\n */\n getInitialObjectsData(): ObjectData[] {\n return this._data.objects || [];\n }\n\n /**\n * Get the original width of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalWidth(): float {\n return this._originalWidth;\n }\n\n /**\n * Get the original height of the game, as set on the startup of the game.\n *\n * This is guaranteed to never change, even if the size of the game is changed afterwards.\n */\n getOriginalHeight(): float {\n return this._originalHeight;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) width.\n * @returns The game resolution width, in pixels.\n */\n getGameResolutionWidth(): float {\n return this._gameResolutionWidth;\n }\n\n /**\n * Get the game resolution (the size at which the game is played and rendered) height.\n * @returns The game resolution height, in pixels.\n */\n getGameResolutionHeight(): float {\n return this._gameResolutionHeight;\n }\n\n /**\n * Change the game resolution.\n *\n * @param width The new width\n * @param height The new height\n */\n setGameResolutionSize(width: float, height: float): void {\n this._throwIfDisposed();\n\n this._gameResolutionWidth = width;\n this._gameResolutionHeight = height;\n if (this._adaptGameResolutionAtRuntime) {\n if (\n gdjs.RuntimeGameRenderer &&\n gdjs.RuntimeGameRenderer.getWindowInnerWidth &&\n gdjs.RuntimeGameRenderer.getWindowInnerHeight\n ) {\n const windowInnerWidth = gdjs.RuntimeGameRenderer.getWindowInnerWidth();\n const windowInnerHeight = gdjs.RuntimeGameRenderer.getWindowInnerHeight();\n\n // Enlarge either the width or the eight to fill the inner window space.\n if (this._resizeMode === 'adaptWidth') {\n this._gameResolutionWidth =\n (this._gameResolutionHeight * windowInnerWidth) /\n windowInnerHeight;\n } else {\n if (this._resizeMode === 'adaptHeight') {\n this._gameResolutionHeight =\n (this._gameResolutionWidth * windowInnerHeight) /\n windowInnerWidth;\n }\n }\n }\n } else {\n }\n\n // Don't alter the game resolution. The renderer\n // will maybe adapt the size of the canvas or whatever is used to render the\n // game in the window, but this does not change the \"game resolution\".\n\n // Notify the renderer that game resolution changed (so that the renderer size\n // can be updated, and maybe other things like the canvas size), and let the\n // scenes know too.\n this._renderer.updateRendererSize();\n this._notifyScenesForGameResolutionResize = true;\n }\n\n /**\n * Set if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically.\n *\n * @param resizeMode Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n setGameResolutionResizeMode(resizeMode: string): void {\n this._resizeMode = resizeMode;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the width or the height of the game resolution\n * should be changed to fit the game window - or if the game\n * resolution should not be updated automatically (empty string).\n *\n * @returns Either \"\" (don't change game resolution), \"adaptWidth\" or \"adaptHeight\".\n */\n getGameResolutionResizeMode(): string {\n return this._resizeMode;\n }\n\n /**\n * Set if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @param enable true to change the game resolution according to the window/screen size.\n */\n setAdaptGameResolutionAtRuntime(enable: boolean): void {\n this._adaptGameResolutionAtRuntime = enable;\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Returns if the game resolution should be automatically adapted\n * when the game window or screen size change. This will only\n * be the case if the game resolution resize mode is\n * configured to adapt the width or the height of the game.\n * @returns true if the game resolution is automatically changed according to the window/screen size.\n */\n getAdaptGameResolutionAtRuntime(): boolean {\n return this._adaptGameResolutionAtRuntime;\n }\n\n /**\n * Return the minimal fps that must be guaranteed by the game\n * (otherwise, game is slowed down).\n */\n getMinimalFramerate(): integer {\n return this._minFPS;\n }\n\n /**\n * Return the scale mode of the game (\"linear\" or \"nearest\").\n */\n getScaleMode(): 'linear' | 'nearest' {\n return this._scaleMode;\n }\n\n /**\n * Return if the game is rounding pixels when rendering.\n */\n getPixelsRounding(): boolean {\n return this._pixelsRounding;\n }\n\n /**\n * Return the antialiasing mode used by the game (\"none\" or \"MSAA\").\n */\n getAntialiasingMode(): 'none' | 'MSAA' {\n return this._antialiasingMode;\n }\n\n /**\n * Return true if antialising is enabled on mobiles.\n */\n isAntialisingEnabledOnMobile(): boolean {\n return this._isAntialisingEnabledOnMobile;\n }\n\n /**\n * Set or unset the game as paused.\n * When paused, the game won't step and will be freezed. Useful for debugging.\n * @param enable true to pause the game, false to unpause\n */\n pause(enable: boolean) {\n if (this._paused === enable) return;\n\n this._paused = enable;\n if (this._debuggerClient) {\n if (this._paused) this._debuggerClient.sendGamePaused();\n else this._debuggerClient.sendGameResumed();\n }\n }\n\n /**\n * @returns true during the first frame the game is back from being hidden.\n * This has nothing to do with `_paused`.\n */\n hasJustResumed() {\n return this._hasJustResumed;\n }\n\n /**\n * Preload a scene assets as soon as possible in background.\n */\n prioritizeLoadingOfScene(sceneName: string) {\n // Don't await the scene assets to be loaded.\n this._resourcesLoader.loadSceneResources(sceneName);\n }\n\n /**\n * @return The progress of assets loading in background for a scene\n * (between 0 and 1).\n */\n getSceneLoadingProgress(sceneName: string): number {\n return this._resourcesLoader.getSceneLoadingProgress(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded\n * (but maybe not parsed).\n */\n areSceneAssetsLoaded(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsLoaded(sceneName);\n }\n\n /**\n * @returns true when all the resources of the given scene are loaded and\n * parsed.\n */\n areSceneAssetsReady(sceneName: string): boolean {\n return this._resourcesLoader.areSceneAssetsReady(sceneName);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n */\n loadAllAssets(\n callback: () => void,\n progressCallback?: (progress: float) => void\n ) {\n this._throwIfDisposed();\n this.loadFirstAssetsAndStartBackgroundLoading(\n this._getFirstSceneName(),\n progressCallback\n ).then(callback);\n }\n\n /**\n * Load all assets needed to display the 1st scene, displaying progress in\n * renderer.\n *\n * When a game is hot-reload, this method can be called with the current\n * scene.\n */\n async loadFirstAssetsAndStartBackgroundLoading(\n firstSceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n try {\n // Download the loading screen background image first to be able to\n // display the loading screen as soon as possible.\n const backgroundImageResourceName = this._data.properties.loadingScreen\n .backgroundImageResourceName;\n if (backgroundImageResourceName) {\n await this._resourcesLoader\n .getImageManager()\n .loadResource(backgroundImageResourceName);\n }\n await Promise.all([\n this._loadAssetsWithLoadingScreen(\n /* isFirstScene = */ true,\n async (onProgress) => {\n // TODO Is a setting needed?\n if (false) {\n await this._resourcesLoader.loadAllResources(onProgress);\n } else {\n await this._resourcesLoader.loadGlobalAndFirstSceneResources(\n firstSceneName,\n onProgress\n );\n // Don't await as it must not block the first scene from starting.\n this._resourcesLoader.loadAllSceneInBackground();\n }\n },\n progressCallback\n ),\n // TODO This is probably not necessary in case of hot reload.\n gdjs.getAllAsynchronouslyLoadingLibraryPromise(),\n ]);\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Load all assets for a given scene, displaying progress in renderer.\n */\n async loadSceneAssets(\n sceneName: string,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n await this._loadAssetsWithLoadingScreen(\n /* isFirstLayout = */ false,\n async (onProgress) => {\n await this._resourcesLoader.loadAndProcessSceneResources(\n sceneName,\n onProgress\n );\n },\n progressCallback\n );\n }\n\n /**\n * Load assets, displaying progress in renderer.\n */\n private async _loadAssetsWithLoadingScreen(\n isFirstScene: boolean,\n loadAssets: (\n onProgress: (count: integer, total: integer) => Promise<void>\n ) => Promise<void>,\n progressCallback?: (progress: float) => void\n ): Promise<void> {\n this.pause(true);\n const loadingScreen = new gdjs.LoadingScreenRenderer(\n this.getRenderer(),\n this._resourcesLoader.getImageManager(),\n this._data.properties.loadingScreen,\n this._data.properties.watermark.showWatermark,\n isFirstScene\n );\n\n const onProgress = async (count: integer, total: integer) => {\n const percent = Math.floor((100 * count) / total);\n loadingScreen.setPercent(percent);\n if (progressCallback) {\n progressCallback(percent);\n }\n const hasRendered = loadingScreen.renderIfNeeded();\n if (hasRendered) {\n // Give a chance to draw calls from the renderer to be handled.\n await sleep(1);\n }\n };\n await loadAssets(onProgress);\n\n await loadingScreen.unload();\n this.pause(false);\n }\n\n private _getFirstSceneName(): string {\n const firstSceneName = this._data.firstLayout;\n return this.hasScene(firstSceneName)\n ? firstSceneName\n : // There is always at least a scene\n this.getSceneAndExtensionsData()!.sceneData.name;\n }\n\n /**\n * Start the game loop, to be called once assets are loaded.\n */\n startGameLoop() {\n this._throwIfDisposed();\n try {\n if (!this.hasScene()) {\n logger.error('The game has no scene.');\n return;\n }\n this._forceGameResolutionUpdate();\n\n // Load the first scene\n this._sceneStack.push(\n this._getFirstSceneName(),\n this._injectExternalLayout\n );\n this._watermark.displayAtStartup();\n\n //Uncomment to profile the first x frames of the game.\n // var x = 500;\n // var startTime = Date.now();\n // console.profile(\"Stepping for \" + x + \" frames\")\n // for(var i = 0; i < x; ++i) {\n // this._sceneStack.step(16);\n // }\n // console.profileEnd();\n // var time = Date.now() - startTime;\n // logger.log(\"Took\", time, \"ms\");\n // return;\n\n this._setupGameVisibilityEvents();\n\n // The standard game loop\n let accumulatedElapsedTime = 0;\n this._hasJustResumed = false;\n this._renderer.startGameLoop((lastCallElapsedTime) => {\n try {\n if (this._paused) {\n return true;\n }\n\n // Skip the frame if we rendering frames too fast\n accumulatedElapsedTime += lastCallElapsedTime;\n if (\n this._maxFPS > 0 &&\n 1000.0 / accumulatedElapsedTime > this._maxFPS + 7\n ) {\n // Only skip frame if the framerate is 7 frames above the maximum framerate.\n // Most browser/engines will try to run at slightly more than 60 frames per second.\n // If game is set to have a maximum FPS to 60, then one out of two frames will be dropped.\n // Hence, we use a 7 frames margin to ensure that we're not skipping frames too much.\n return true;\n }\n const elapsedTime = accumulatedElapsedTime;\n accumulatedElapsedTime = 0;\n\n // Manage resize events.\n if (this._notifyScenesForGameResolutionResize) {\n this._sceneStack.onGameResolutionResized();\n this._notifyScenesForGameResolutionResize = false;\n }\n\n // Render and step the scene.\n if (this._sceneStack.step(elapsedTime)) {\n this.getInputManager().onFrameEnded();\n this._hasJustResumed = false;\n return true;\n }\n return false;\n } catch (e) {\n if (this._debuggerClient)\n this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n });\n setTimeout(() => {\n this._setupSessionMetrics();\n }, 4000);\n if (this._captureManager) {\n this._captureManager.setupCaptureOptions(this._isPreview);\n }\n } catch (e) {\n if (this._debuggerClient) this._debuggerClient.onUncaughtException(e);\n\n throw e;\n }\n }\n\n /**\n * Stop game loop, unload all scenes, dispose renderer and resources.\n * After calling this method, the RuntimeGame should not be used anymore.\n */\n dispose(): void {\n this._renderer.stopGameLoop();\n this._sceneStack.dispose();\n this._renderer.dispose();\n this._resourcesLoader.dispose();\n\n this._wasDisposed = true;\n }\n\n /**\n * Set if the session should be registered.\n */\n enableMetrics(enable: boolean): void {\n this._disableMetrics = !enable;\n if (enable) {\n this._setupSessionMetrics();\n }\n }\n\n /**\n * Helper function to get information about the platform running the game.\n */\n getPlatformInfo = () => {\n return {\n // @ts-ignore\n isCordova: !!window.cordova,\n devicePlatform:\n // @ts-ignore\n typeof device !== 'undefined' ? device.platform || '' : '',\n navigatorPlatform:\n typeof navigator !== 'undefined' ? navigator.platform : '',\n hasTouch:\n typeof navigator !== 'undefined'\n ? !!navigator.maxTouchPoints && navigator.maxTouchPoints > 2\n : false,\n supportedCompressionMethods: getSupportedCompressionMethods(),\n };\n };\n\n _setupGameVisibilityEvents() {\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this._hasJustResumed = true;\n }\n });\n window.addEventListener(\n 'resume',\n () => {\n this._hasJustResumed = true;\n },\n false\n );\n }\n }\n\n /**\n * Register a new session for the game, and set up listeners to follow the session\n * time.\n */\n _setupSessionMetrics() {\n if (this._sessionMetricsInitialized) {\n return;\n }\n if (this._disableMetrics) {\n return;\n }\n if (this.isPreview()) {\n return;\n }\n if (typeof fetch === 'undefined') {\n return;\n }\n if (!this._data.properties.projectUuid) {\n return;\n }\n const baseUrl = 'https://api.gdevelop-app.com/analytics';\n this._playerId = this._makePlayerUuid();\n /**\n * The duration that is already sent to the service\n * (in milliseconds).\n **/\n let sentDuration = 0;\n /**\n * The duration that is not yet sent to the service to avoid flooding\n * (in milliseconds).\n **/\n let notYetSentDuration = 0;\n /**\n * The last time when duration has been counted\n * either in sendedDuration or notYetSentDuration.\n **/\n let lastSessionResumeTime = Date.now();\n const platform = this.getPlatformInfo();\n fetch(baseUrl + '/session', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n // It's important to ensure that the data sent here does not contain\n // any personal information from the player or that would allow to\n // precisely identify someone.\n body: JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n game: {\n name: this._data.properties.name || '',\n packageName: this._data.properties.packageName || '',\n version: this._data.properties.version || '',\n location: window.location.href,\n },\n platform: {\n isCordova: platform.isCordova,\n devicePlatform: platform.devicePlatform,\n navigatorPlatform: platform.navigatorPlatform,\n hasTouch: platform.hasTouch,\n },\n }),\n })\n .then((response) => {\n // Ensure the session is correctly created to avoid sending hits that will fail.\n if (!response.ok) {\n console.error('Error while creating the session', response);\n throw new Error('Error while creating the session');\n }\n return response;\n })\n .then((response) => response.text())\n .then((returnedSessionId) => {\n this._sessionId = returnedSessionId;\n })\n .catch(() => {});\n\n /* Ignore any error */\n const sendSessionHit = () => {\n if (!this._sessionId) {\n return;\n }\n\n const now = Date.now();\n notYetSentDuration += now - lastSessionResumeTime;\n lastSessionResumeTime = now;\n\n // Group repeated calls to sendSessionHit - which could\n // happen because of multiple event listeners being fired.\n if (notYetSentDuration < 5 * 1000) {\n return;\n }\n // The backend use seconds for duration.\n // The milliseconds will stay in notYetSentDuration.\n const toBeSentDuration = Math.floor(notYetSentDuration / 1000) * 1000;\n sentDuration += toBeSentDuration;\n notYetSentDuration -= toBeSentDuration;\n\n navigator.sendBeacon(\n baseUrl + '/session-hit',\n JSON.stringify({\n gameId: this._data.properties.projectUuid,\n playerId: this._playerId,\n sessionId: this._sessionId,\n duration: Math.floor(sentDuration / 1000),\n })\n );\n };\n if (typeof navigator !== 'undefined' && typeof document !== 'undefined') {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n } else {\n sendSessionHit();\n }\n });\n window.addEventListener('pagehide', sendSessionHit, false);\n // Cordova events\n window.addEventListener('pause', sendSessionHit, false);\n window.addEventListener(\n 'resume',\n () => {\n // Skip the duration the game was hidden.\n lastSessionResumeTime = Date.now();\n },\n false\n );\n\n // Detect Safari to work around Safari-specific bugs:\n // - https://bugs.webkit.org/show_bug.cgi?id=151610\n // - https://bugs.webkit.org/show_bug.cgi?id=151234\n // @ts-ignore\n const isSafari = typeof safari === 'object' && safari.pushNotification;\n const isElectron = /electron/i.test(navigator.userAgent);\n if (isSafari || isElectron) {\n window.addEventListener('beforeunload', () => {\n sendSessionHit();\n });\n }\n }\n this._sessionMetricsInitialized = true;\n this._sessionId = this._sessionId;\n }\n\n /**\n * Generate an anonymous unique identifier to differentiate\n * the player from others in the game metrics.\n */\n _makePlayerUuid(): string {\n try {\n const key = 'GDJS-internal-player-uuid';\n const existingPlayerUuid = localStorage.getItem(key);\n if (existingPlayerUuid) {\n return existingPlayerUuid;\n }\n const newPlayerUuid = gdjs.makeUuid();\n localStorage.setItem(key, newPlayerUuid);\n return newPlayerUuid;\n } catch (err) {\n return gdjs.makeUuid();\n }\n }\n\n getSessionId(): string | null {\n return this._sessionId;\n }\n\n getPlayerId(): string | null {\n return this._playerId;\n }\n\n /**\n * Called by the game renderer when the window containing the game\n * has changed size (this can result from a resize of the window,\n * but also other factors like a device orientation change on mobile).\n */\n onWindowInnerSizeChanged() {\n this._forceGameResolutionUpdate();\n }\n\n /**\n * Enlarge/reduce the width (or the height) of the game to fill the inner window.\n */\n _forceGameResolutionUpdate() {\n this.setGameResolutionSize(\n this._gameResolutionWidth,\n this._gameResolutionHeight\n );\n }\n\n /**\n * Start a profiler for the currently running scene.\n * @param onProfilerStopped Function to be called when the profiler is stopped. Will be passed the profiler as argument.\n */\n startCurrentSceneProfiler(\n onProfilerStopped: (oldProfiler: Profiler) => void\n ) {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return false;\n }\n currentScene.startProfiler(onProfilerStopped);\n return true;\n }\n\n /**\n * Stop the profiler for the currently running scene.\n */\n stopCurrentSceneProfiler() {\n this._throwIfDisposed();\n const currentScene = this._sceneStack.getCurrentScene();\n if (!currentScene) {\n return;\n }\n currentScene.stopProfiler();\n }\n\n /**\n * Return true if a scene was loaded, false otherwise (i.e: game not yet started).\n */\n wasFirstSceneLoaded(): boolean {\n return this._sceneStack.wasFirstSceneLoaded();\n }\n\n /**\n * Return the stack of {@link gdjs.RuntimeScene} being played.\n */\n getSceneStack(): gdjs.SceneStack {\n return this._sceneStack;\n }\n\n /**\n * Check if the game is running as a preview, launched from an editor.\n * @returns true if the current game is a preview.\n */\n isPreview(): boolean {\n return this._isPreview;\n }\n\n /**\n * Check if the game should call GDevelop development APIs or not.\n *\n * Unless you are contributing to GDevelop, avoid using this.\n */\n isUsingGDevelopDevelopmentEnvironment(): boolean {\n return this._options.environment === 'dev';\n }\n\n /**\n * Gets an extension property from the project data.\n * @param extensionName The extension name.\n * @param propertyName The property name.\n * @return The property value.\n */\n getExtensionProperty(\n extensionName: string,\n propertyName: string\n ): string | null {\n for (let property of this._data.properties.extensionProperties) {\n if (\n property.extension === extensionName &&\n property.property === propertyName\n ) {\n return property.value;\n }\n }\n return null;\n }\n\n /**\n * Resolves the name of an embedded resource.\n * @param mainResourceName The name of the resource containing the embedded resource.\n * @param embeddedResourceName The name of the embedded resource.\n * @return The resource name.\n */\n resolveEmbeddedResource(\n mainResourceName: string,\n embeddedResourceName: string\n ): string {\n const mapping = this._embeddedResourcesMappings.get(mainResourceName);\n return mapping && mapping[embeddedResourceName]\n ? mapping[embeddedResourceName]\n : embeddedResourceName;\n }\n\n /**\n * Returns the array of resources that are embedded to passed one.\n * @param resourceName The name of resource to find embedded resources of.\n * @returns The array of related resources names.\n */\n getEmbeddedResourcesNames(resourceName: string): string[] {\n return this._embeddedResourcesMappings.has(resourceName)\n ? Object.keys(this._embeddedResourcesMappings.get(resourceName)!)\n : [];\n }\n\n getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): GameNetworkSyncData | null {\n const syncData: GameNetworkSyncData = {\n var: this._variables.getNetworkSyncData(syncOptions),\n ss: this._sceneStack.getNetworkSyncData(syncOptions) || undefined,\n };\n\n const extensionsVariablesSyncData = {};\n this._variablesByExtensionName.forEach((variables, extensionName) => {\n const extensionVariablesSyncData = variables.getNetworkSyncData(\n syncOptions\n );\n // If there is no variables to sync, don't include the extension in the sync data.\n if (extensionVariablesSyncData.length) {\n extensionsVariablesSyncData[\n extensionName\n ] = extensionVariablesSyncData;\n }\n });\n syncData.extVar = extensionsVariablesSyncData;\n\n if (\n (!syncData.var || syncData.var.length === 0) &&\n !syncData.ss &&\n (!syncData.extVar || Object.keys(syncData.extVar).length === 0)\n ) {\n // Nothing to sync.\n return null;\n }\n\n return syncData;\n }\n\n updateFromNetworkSyncData(syncData: GameNetworkSyncData) {\n this._throwIfDisposed();\n if (syncData.var) {\n this._variables.updateFromNetworkSyncData(syncData.var);\n }\n if (syncData.ss) {\n this._sceneStack.updateFromNetworkSyncData(syncData.ss);\n }\n if (syncData.extVar) {\n for (const extensionName in syncData.extVar) {\n if (!syncData.extVar.hasOwnProperty(extensionName)) {\n continue;\n }\n const extensionVariablesData = syncData.extVar[extensionName];\n const extensionVariables = this.getVariablesForExtension(\n extensionName\n );\n if (extensionVariables) {\n extensionVariables.updateFromNetworkSyncData(\n extensionVariablesData\n );\n }\n }\n }\n }\n\n private _throwIfDisposed(): void {\n if (this._wasDisposed) {\n throw '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