{"version":3,"file":"adapter.mjs","sources":["../src/adapter.ts"],"sourcesContent":["import type { ICanvas } from './ICanvas';\nimport type { ICanvasRenderingContext2D } from './ICanvasRenderingContext2D';\n\n/**\n * This interface describes all the DOM dependent calls that Pixi makes throughout its codebase.\n * Implementations of this interface can be used to make sure Pixi will work in any environment,\n * such as browser, Web Workers, and Node.js.\n * @memberof PIXI\n */\nexport interface IAdapter\n{\n    /** Returns a canvas object that can be used to create a webgl context. */\n    createCanvas: (width?: number, height?: number) => ICanvas;\n    /** Returns a 2D rendering context. */\n    getCanvasRenderingContext2D: () => { prototype: ICanvasRenderingContext2D; };\n    /** Returns a WebGL rendering context. */\n    getWebGLRenderingContext: () => typeof WebGLRenderingContext;\n    /** Returns a partial implementation of the browsers window.navigator */\n    getNavigator: () => { userAgent: string };\n    /** Returns the current base URL For browser environments this is either the document.baseURI or window.location.href */\n    getBaseUrl: () => string;\n    getFontFaceSet: () => FontFaceSet | null;\n    fetch: (url: RequestInfo, options?: RequestInit) => Promise<Response>;\n    parseXML: (xml: string) => Document;\n}\n\nexport const BrowserAdapter = {\n    /**\n     * Creates a canvas element of the given size.\n     * This canvas is created using the browser's native canvas element.\n     * @param width - width of the canvas\n     * @param height - height of the canvas\n     */\n    createCanvas: (width: number, height: number): HTMLCanvasElement =>\n    {\n        const canvas = document.createElement('canvas');\n\n        canvas.width = width;\n        canvas.height = height;\n\n        return canvas;\n    },\n    getCanvasRenderingContext2D: () => CanvasRenderingContext2D,\n    getWebGLRenderingContext: () => WebGLRenderingContext,\n    getNavigator: () => navigator,\n    getBaseUrl: () => (document.baseURI ?? window.location.href),\n    getFontFaceSet: () => document.fonts,\n    fetch: (url: RequestInfo, options?: RequestInit) => fetch(url, options),\n    parseXML: (xml: string) =>\n    {\n        const parser = new DOMParser();\n\n        return parser.parseFromString(xml, 'text/xml');\n    },\n} as IAdapter;\n"],"names":[],"mappings":"AA0BO,MAAM,cAAiB,GAAA;AAAA,EAO1B,YAAA,EAAc,CAAC,KAAA,EAAe,MAC9B,KAAA;AACI,IAAM,MAAA,MAAA,GAAS,QAAS,CAAA,aAAA,CAAc,QAAQ,CAAA,CAAA;AAE9C,IAAA,MAAA,CAAO,KAAQ,GAAA,KAAA,CAAA;AACf,IAAA,MAAA,CAAO,MAAS,GAAA,MAAA,CAAA;AAEhB,IAAO,OAAA,MAAA,CAAA;AAAA,GACX;AAAA,EACA,6BAA6B,MAAM,wBAAA;AAAA,EACnC,0BAA0B,MAAM,qBAAA;AAAA,EAChC,cAAc,MAAM,SAAA;AAAA,EACpB,UAAY,EAAA,MAAO,QAAS,CAAA,OAAA,IAAW,OAAO,QAAS,CAAA,IAAA;AAAA,EACvD,cAAA,EAAgB,MAAM,QAAS,CAAA,KAAA;AAAA,EAC/B,OAAO,CAAC,GAAA,EAAkB,OAA0B,KAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAAA,EACtE,QAAA,EAAU,CAAC,GACX,KAAA;AACI,IAAM,MAAA,MAAA,GAAS,IAAI,SAAU,EAAA,CAAA;AAE7B,IAAO,OAAA,MAAA,CAAO,eAAgB,CAAA,GAAA,EAAK,UAAU,CAAA,CAAA;AAAA,GACjD;AACJ;;;;"}