1 line
37 KiB
Plaintext
1 line
37 KiB
Plaintext
|
|
{"version":3,"file":"Assets.mjs","sources":["../src/Assets.ts"],"sourcesContent":["import { extensions, ExtensionType, utils } from '@pixi/core';\nimport { BackgroundLoader } from './BackgroundLoader';\nimport { Cache } from './cache/Cache';\nimport { Loader } from './loader/Loader';\nimport { loadTextures } from './loader/parsers';\nimport { Resolver } from './resolver/Resolver';\nimport { convertToList } from './utils/convertToList';\nimport { isSingleItem } from './utils/isSingleItem';\n\nimport type { FormatDetectionParser } from './detections';\nimport type { LoadTextureConfig } from './loader/parsers';\nimport type { BundleIdentifierOptions } from './resolver/Resolver';\nimport type {\n ArrayOr,\n AssetsBundle,\n AssetsManifest,\n AssetSrc,\n LoadParserName,\n ResolvedAsset,\n UnresolvedAsset\n} from './types';\n\nexport type ProgressCallback = (progress: number) => void;\n\n/**\n * Extensible preferences that can be used, for instance, when configuring loaders.\n * @since 7.2.0\n * @memberof PIXI\n */\nexport interface AssetsPreferences extends LoadTextureConfig, GlobalMixins.AssetsPreferences {}\n\n/**\n * Initialization options object for Asset Class.\n * @memberof PIXI\n */\nexport interface AssetInitOptions\n{\n // basic...\n /** a base path for any assets loaded */\n basePath?: string;\n\n /** a default URL parameter string to append to all assets loaded */\n defaultSearchParams?: string | Record<string, any>;\n\n /**\n * a manifest to tell the asset loader upfront what all your assets are\n * this can be the manifest object itself, or a URL to the manifest.\n */\n manifest?: string | AssetsManifest;\n /**\n * optional preferences for which textures preferences you have when resolving assets\n * for example you might set the resolution to 0.5 if the user is on a rubbish old phone\n * or you might set the resolution to 2 if the user is on a retina display\n */\n texturePreference?: {\n /** the resolution order you prefer, can be an array (priority order - first is prefered) or a single resolutions */\n resolution?: number | number[];\n /**\n * the formats you prefer, by default this will be:\n * ['avif', 'webp', 'png', 'jpg', 'jpeg', 'webm', 'mp4', 'm4v', 'ogv']\n */\n format?: ArrayOr<string>;\n };\n\n /**\n * If true, don't attempt to detect whether browser has preferred formats available.\n * May result in increased performance as it skips detection step.\n */\n skipDetections?: boolean;\n\n /** advanced - override how bundlesIds are generated */\n bundleIdentifier?: BundleIdentifierOptions;\n\n /** Optional loader preferences */\n preferences?: Partial<AssetsPreferences>;\n}\n\n/**\n * A one stop shop for all Pixi resource management!\n * Super modern and easy to use, with enough flexibility to customize and do what you need!\n * @memberof PIXI\n * @namespace Assets\n *\n * Only one Asset Class exists accessed via the Global Asset object.\n *\n * It has four main responsibilities:\n * 1. Allows users to map URLs to keys and resolve them according to the user's browser capabilities\n * 2. Loads the resources and transforms them into assets that developers understand.\n * 3. Caches the assets and provides a way to access them.\n * 4. Allow developers to unload assets and clear the cache.\n *\n * It also has a few advanced features:\n * 1. Allows developers to provide a manifest upfront of all assets and help manage them via 'bundles'.\n * 2. Allows users to background load assets. Shortening (or eliminating) load times and improving UX. With this feature,\n * in-game loading bars can be a thing of the past!\n *\n * ### Assets Loading\n *\n * Do not be afraid to load things multiple times - under the hood, it will NEVER load anything more than once.\n *\n * For example:\n *\n * ```js\n * import { Assets } from 'pixi.js';\n *\n * promise1 = Assets.load('bunny.png')\n * promise2 = Assets.load('bunny.png')\n *\n * // promise1 === promise2\n * ```\n *\n
|