UNPKG

1.6 kBSource Map (JSON)View Raw
1{"version":3,"file":"CanvasResource.js","sources":["../../../src/textures/resources/CanvasResource.ts"],"sourcesContent":["import { BaseImageResource } from './BaseImageResource';\n\nimport type { ICanvas } from '@pixi/settings';\n\n/**\n * Resource type for HTMLCanvasElement and OffscreenCanvas.\n * @memberof PIXI\n */\nexport class CanvasResource extends BaseImageResource\n{\n /**\n * @param source - Canvas element to use\n */\n // eslint-disable-next-line @typescript-eslint/no-useless-constructor\n constructor(source: ICanvas)\n {\n super(source);\n }\n\n /**\n * Used to auto-detect the type of resource.\n * @param {*} source - The source object\n * @returns {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas\n */\n static test(source: unknown): source is OffscreenCanvas | HTMLCanvasElement\n {\n const { OffscreenCanvas } = globalThis;\n\n // Check for browsers that don't yet support OffscreenCanvas\n if (OffscreenCanvas && source instanceof OffscreenCanvas)\n {\n return true;\n }\n\n return globalThis.HTMLCanvasElement && source instanceof HTMLCanvasElement;\n }\n}\n"],"names":["BaseImageResource"],"mappings":";;;;;;AAQO,MAAM,uBAAuBA,mCACpC,CAAA;AAAA,EAKI,YAAY,MACZ,EAAA;AACI,IAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AAAA,GAChB;AAAA,EAOA,OAAO,KAAK,MACZ,EAAA;AACI,IAAA,MAAM,EAAE,eAAoB,EAAA,GAAA,UAAA,CAAA;AAG5B,IAAI,IAAA,eAAA,IAAmB,kBAAkB,eACzC,EAAA;AACI,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAO,OAAA,UAAA,CAAW,qBAAqB,MAAkB,YAAA,iBAAA,CAAA;AAAA,GAC7D;AACJ;;;;"}
\No newline at end of file