{"version":3,"file":"Application.mjs","sources":["../src/Application.ts"],"sourcesContent":["import { autoDetectRenderer, extensions, ExtensionType } from '@pixi/core';\nimport { Container } from '@pixi/display';\n\nimport type { ICanvas, IRenderer, IRendererOptionsAuto, Rectangle } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\n\n/**\n * Any plugin that's usable for Application should contain these methods.\n * @memberof PIXI\n */\nexport interface IApplicationPlugin\n{\n /**\n * Called when Application is constructed, scoped to Application instance.\n * Passes in `options` as the only argument, which are Application constructor options.\n * @param {object} options - Application options.\n */\n init(options: Partial): void;\n /** Called when destroying Application, scoped to Application instance. */\n destroy(): void;\n}\n\n/**\n * Application options supplied to constructor.\n * @memberof PIXI\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IApplicationOptions extends IRendererOptionsAuto, GlobalMixins.IApplicationOptions {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface Application extends GlobalMixins.Application {}\n\n/**\n * Convenience class to create a new PixiJS application.\n *\n * This class automatically creates the renderer, ticker and root container.\n * @example\n * import { Application, Sprite } from 'pixi.js';\n *\n * // Create the application\n * const app = new Application();\n *\n * // Add the view to the DOM\n * document.body.appendChild(app.view);\n *\n * // ex, add display objects\n * app.stage.addChild(Sprite.from('something.png'));\n * @class\n * @memberof PIXI\n */\nexport class Application\n{\n /** Collection of installed plugins. */\n static _plugins: IApplicationPlugin[] = [];\n\n /**\n * The root display container that's rendered.\n * @member {PIXI.Container}\n */\n public stage: Container = new Container();\n\n /**\n * WebGL renderer if available, otherwise CanvasRenderer.\n * @member {PIXI.Renderer|PIXI.CanvasRenderer}\n */\n public renderer: IRenderer;\n\n /**\n * @param options - The optional application and renderer parameters.\n */\n constructor(options?: Partial)\n {\n // The default options\n options = Object.assign({\n forceCanvas: false,\n }, options);\n\n this.renderer = autoDetectRenderer(options);\n\n // install plugins here\n Application._plugins.forEach((plugin) =>\n {\n plugin.init.call(this, options);\n });\n }\n\n /** Render the current stage. */\n public render(): void\n {\n this.renderer.render(this.stage);\n }\n\n /**\n * Reference to the renderer's canvas element.\n * @member {PIXI.ICanvas}\n * @readonly\n */\n get view(): VIEW\n {\n return this.renderer?.view;\n }\n\n /**\n * Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.\n * @member {PIXI.Rectangle}\n * @readonly\n */\n get screen(): Rectangle\n {\n return this.renderer?.screen;\n }\n\n /**\n * Destroy and don't use after this.\n * @param {boolean} [removeView=false] - Automatically remove canvas from DOM.\n * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options\n * have been set to that value\n * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy\n * method called as well. 'stageOptions' will be passed on to those calls.\n * @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set\n * to true. Should it destroy the texture of the child sprite\n * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set\n * to true. Should it destroy the base texture of the child sprite\n */\n public destroy(removeView?: boolean, stageOptions?: IDestroyOptions | boolean): void\n {\n // Destroy plugins in the opposite order\n // which they were constructed\n const plugins = Application._plugins.slice(0);\n\n plugins.reverse();\n plugins.forEach((plugin) =>\n {\n plugin.destroy.call(this);\n });\n\n this.stage.destroy(stageOptions);\n this.stage = null;\n\n this.renderer.destroy(removeView);\n this.renderer = null;\n }\n}\n\nextensions.handleByList(ExtensionType.Application, Application._plugins);\n"],"names":["_Application"],"mappings":";;AAkDO,MAAM,eAAN,MAAMA,cACb;AAAA;AAAA;AAAA;AAAA,EAmBI,YAAY,SACZ;AAZO,SAAA,QAAmB,IAAI,aAc1B,UAAU,OAAO,OAAO;AAAA,MACpB,aAAa;AAAA,IACd,GAAA,OAAO,GAEV,KAAK,WAAW,mBAAyB,OAAO,GAGhDA,cAAY,SAAS,QAAQ,CAAC,WAC9B;AACW,aAAA,KAAK,KAAK,MAAM,OAAO;AAAA,IAAA,CACjC;AAAA,EACL;AAAA;AAAA,EAGO,SACP;AACS,SAAA,SAAS,OAAO,KAAK,KAAK;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,OACJ;AACI,WAAO,KAAK,UAAU;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,SACJ;AACI,WAAO,KAAK,UAAU;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcO,QAAQ,YAAsB,cACrC;AAGI,UAAM,UAAUA,cAAY,SAAS,MAAM,CAAC;AAE5C,YAAQ,QAAQ,GAChB,QAAQ,QAAQ,CAAC,WACjB;AACW,aAAA,QAAQ,KAAK,IAAI;AAAA,IAAA,CAC3B,GAED,KAAK,MAAM,QAAQ,YAAY,GAC/B,KAAK,QAAQ,MAEb,KAAK,SAAS,QAAQ,UAAU,GAChC,KAAK,WAAW;AAAA,EACpB;AACJ;AA5Fa,aAGF,WAAiC,CAAA;AAHrC,IAAM,cAAN;AA8FP,WAAW,aAAa,cAAc,aAAa,YAAY,QAAQ;"}