UNPKG

1.98 kBSource Map (JSON)View Raw
1{"version":3,"file":"autoDetectRenderer.js","sources":["../src/autoDetectRenderer.ts"],"sourcesContent":["import { extensions, ExtensionType } from '@pixi/extensions';\n\nimport type { ICanvas } from '@pixi/settings';\nimport type { IRenderer, IRendererOptions } from './IRenderer';\n\n/**\n * Renderer options supplied to `autoDetectRenderer`.\n * @memberof PIXI\n */\nexport interface IRendererOptionsAuto extends IRendererOptions\n{\n /**\n * Force CanvasRenderer even if WebGL is supported. Only available with **pixi.js-legacy**.\n * @default false\n */\n forceCanvas?: boolean;\n}\n\nexport interface IRendererConstructor<VIEW extends ICanvas = ICanvas>\n{\n test(options?: Partial<IRendererOptionsAuto>): boolean;\n new (options?: Partial<IRendererOptionsAuto>): IRenderer<VIEW>;\n}\n\n/**\n * Collection of installed Renderers.\n * @ignore\n */\nconst renderers: IRendererConstructor<ICanvas>[] = [];\n\nextensions.handleByList(ExtensionType.Renderer, renderers);\n\n/**\n * This helper function will automatically detect which renderer you should be using.\n * WebGL is the preferred renderer as it is a lot faster. If WebGL is not supported by\n * the browser then this function will return a canvas renderer.\n * @memberof PIXI\n * @function autoDetectRenderer\n * @param options - Options to use.\n */\nexport function autoDetectRenderer<VIEW extends ICanvas = ICanvas>(options?: Partial<IRendererOptionsAuto>): IRenderer<VIEW>\n{\n for (const RendererType of renderers)\n {\n if (RendererType.test(options))\n {\n return new RendererType(options) as IRenderer<VIEW>;\n }\n }\n\n throw new Error('Unable to auto-detect a suitable renderer.');\n}\n"],"names":["extensions","ExtensionType"],"mappings":";;AA4BA,MAAM,YAA6C,CAAA;AAEnDA,WAAW,WAAA,aAAaC,WAAAA,cAAc,UAAU,SAAS;AAUlD,SAAS,mBAAmD,SACnE;AACI,aAAW,gBAAgB;AAEnB,QAAA,aAAa,KAAK,OAAO;AAElB,aAAA,IAAI,aAAa,OAAO;AAIjC,QAAA,IAAI,MAAM,4CAA4C;AAChE;;"}
\No newline at end of file