UNPKG

2.08 kBSource Map (JSON)View Raw
1{"version":3,"file":"autoDetectRenderer.mjs","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":[],"mappings":";;AA4BA,MAAM,YAA6C,EAAC,CAAA;AAEpD,UAAW,CAAA,YAAA,CAAa,aAAc,CAAA,QAAA,EAAU,SAAS,CAAA,CAAA;AAUlD,SAAA,kBAAA,CAA4D,OACnE,EAAA;AACI,EAAA,KAAA,MAAW,gBAAgB,SAC3B,EAAA;AACI,IAAI,IAAA,YAAA,CAAa,IAAK,CAAA,OAAO,CAC7B,EAAA;AACI,MAAO,OAAA,IAAI,aAAa,OAAO,CAAA,CAAA;AAAA,KACnC;AAAA,GACJ;AAEA,EAAM,MAAA,IAAI,MAAM,4CAA4C,CAAA,CAAA;AAChE;;;;"}
\No newline at end of file