Files
nothoughts/node_modules/pixi.js/lib/environment/adapter.mjs.map
2025-08-04 18:57:35 +02:00

1 line
4.1 KiB
Plaintext

{"version":3,"file":"adapter.mjs","sources":["../../src/environment/adapter.ts"],"sourcesContent":["import { BrowserAdapter } from '../environment-browser/BrowserAdapter';\n\nimport type { ICanvas } from './canvas/ICanvas';\nimport type { ICanvasRenderingContext2D } from './canvas/ICanvasRenderingContext2D';\n\n/**\n * PixiJS supports multiple environments including browsers, Web Workers, and Node.js.\n * The environment is auto-detected by default using the {@link environment.autoDetectEnvironment} function.\n *\n * The {@link environment.Adapter} interface provides a way to abstract away the differences between\n * these environments. PixiJS uses the {@link environment.BrowserAdapter} by default.\n *\n * However you can manually set the environment using the {@link environment.DOMAdapter} singleton, for example to\n * use Pixi within a WebWorker.\n * ```js\n * import { DOMAdapter, WebWorkerAdapter } from 'pixi.js';\n *\n * // WebWorkerAdapter is an implementation of the Adapter interface\n * DOMAdapter.set(WebWorkerAdapter);\n *\n * // use the adapter to create a canvas (in this case an OffscreenCanvas)\n * DOMAdapter.get().createCanvas(800, 600);\n * ```\n * @namespace environment\n */\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 environment\n */\nexport interface Adapter\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, gpu: GPU | null };\n /** Returns the current base URL For browser environments this is either the document.baseURI or window.location.href */\n getBaseUrl: () => string;\n /** Return the font face set if available */\n getFontFaceSet: () => FontFaceSet | null;\n /** Returns a Response object that has been fetched from the given URL. */\n fetch: (url: RequestInfo, options?: RequestInit) => Promise<Response>;\n /** Returns Document object that has been parsed from the given XML string. */\n parseXML: (xml: string) => Document;\n}\n\nlet currentAdapter: Adapter = BrowserAdapter;\n\n/**\n * The DOMAdapter is a singleton that allows PixiJS to perform DOM operations, such as creating a canvas.\n * This allows PixiJS to be used in any environment, such as a web browser, Web Worker, or Node.js.\n * It uses the {@link environment.Adapter} interface to abstract away the differences between these environments\n * and uses the {@link environment.BrowserAdapter} by default.\n *\n * It has two methods: `get():Adapter` and `set(adapter: Adapter)`.\n *\n * Defaults to the {@link environment.BrowserAdapter}.\n * @example\n * import { DOMAdapter, WebWorkerAdapter } from 'pixi.js';\n *\n * // WebWorkerAdapter is an implementation of the Adapter interface\n * DOMAdapter.set(WebWorkerAdapter);\n *\n * // use the adapter to create a canvas (in this case an OffscreenCanvas)\n * DOMAdapter.get().createCanvas(800, 600);\n * @memberof environment\n */\nexport const DOMAdapter = {\n /**\n * Returns the current adapter.\n * @returns {environment.Adapter} The current adapter.\n */\n get(): Adapter\n {\n return currentAdapter;\n },\n /**\n * Sets the current adapter.\n * @param adapter - The new adapter.\n */\n set(adapter: Adapter): void\n {\n currentAdapter = adapter;\n },\n};\n"],"names":[],"mappings":";;;AAoDA,IAAI,cAA0B,GAAA,cAAA,CAAA;AAqBvB,MAAM,UAAa,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,GACA,GAAA;AACI,IAAO,OAAA,cAAA,CAAA;AAAA,GACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,OACJ,EAAA;AACI,IAAiB,cAAA,GAAA,OAAA,CAAA;AAAA,GACrB;AACJ;;;;"}