Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/assets

Package Overview
Dependencies
Maintainers
3
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/assets - npm Package Compare versions

Comparing version 6.5.3 to 7.0.0-alpha

34

dist/cjs/assets.min.js

@@ -1,9 +0,33 @@

/*!
* @pixi/assets - v6.5.3
* Compiled Fri, 09 Sep 2022 13:55:20 UTC
"use strict";/*!
* @pixi/assets - v7.0.0-alpha
* Compiled Fri, 09 Sep 2022 16:09:18 UTC
*
* @pixi/assets is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@pixi/core"),t=require("@pixi/spritesheet"),r=require("@pixi/utils"),n=require("@pixi/settings"),s=require("@pixi/basis"),i=require("@pixi/text-bitmap"),o=require("@pixi/compressed-textures"),a=require("@pixi/constants"),u=function(){return u=Object.assign||function(e){for(var t,r=arguments,n=1,s=arguments.length;n<s;n++)for(var i in t=r[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},u.apply(this,arguments)};function c(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(s=2&i[0]?n.return:i[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;switch(n=0,s&&(i=[2&i[0],s.value]),i[0]){case 0:case 1:s=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(s=o.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){o.label=i[1];break}if(6===i[0]&&o.label<s[1]){o.label=s[1],s=i;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(i);break}s[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var h=function(){function e(e,t){void 0===t&&(t=!1),this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}return e.prototype.add=function(e){var t=this;e.forEach((function(e){t._assetList.push(e)})),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()},e.prototype._next=function(){return c(this,void 0,Promise,(function(){var e,t,r;return l(this,(function(n){switch(n.label){case 0:if(!this._assetList.length||!this._isActive)return[3,2];for(this._isLoading=!0,e=[],t=Math.min(this._assetList.length,this._maxConcurrent),r=0;r<t;r++)e.push(this._assetList.pop());return[4,this._loader.load(e)];case 1:n.sent(),this._isLoading=!1,this._next(),n.label=2;case 2:return[2]}}))}))},Object.defineProperty(e.prototype,"active",{get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())},enumerable:!1,configurable:!0}),e}(),f=function(e,t){return Array.isArray(e)||(e=[e]),t?e.map((function(e){return"string"==typeof e?t(e):e})):e};function p(e,t,r,n,s){for(var i=t[r],o=0;o<i.length;o++){var a=i[o];r<t.length-1?p(e.replace(n[r],a),t,r+1,n,s):s.push(e.replace(n[r],a))}}function A(e){var t=e.match(/\{(.*?)\}/g),r=[];if(t){var n=[];t.forEach((function(e){var t=e.substring(1,e.length-1).split(",");n.push(t)})),p(e,n,0,t,r)}else r.push(e);return r}var d=function(e){return!Array.isArray(e)},v=new(function(){function t(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}return t.prototype.reset=function(){this._cacheMap.clear(),this._cache.clear()},t.prototype.has=function(e){return this._cache.has(e)},t.prototype.get=function(e){return this._cache.get(e)},t.prototype.set=function(t,r){for(var n,s=this,i=f(t),o=0;o<this.parsers.length;o++){var a=this.parsers[o];if(a.test(r)){n=a.getCacheableAssets(i,r);break}}n||(n={},i.forEach((function(e){n[e]=r})));var u=Object.keys(n),c={cacheKeys:u,keys:i};if(i.forEach((function(e){s._cacheMap.set(e,c)})),u.forEach((function(e){s._cache.has(e)&&s._cache.get(e),s._cache.set(e,n[e])})),r instanceof e.Texture){var l=r;i.forEach((function(t){l.baseTexture!==e.Texture.EMPTY.baseTexture&&e.BaseTexture.addToCache(l.baseTexture,t),e.Texture.addToCache(l,t)}))}},t.prototype.remove=function(e){var t=this;if(this._cacheMap.get(e),this._cacheMap.has(e)){var r=this._cacheMap.get(e);r.cacheKeys.forEach((function(e){t._cache.delete(e)})),r.keys.forEach((function(e){t._cacheMap.delete(e)}))}},Object.defineProperty(t.prototype,"parsers",{get:function(){return this._parsers},enumerable:!1,configurable:!0}),t}());function m(e,t,n){var s={};if(e.forEach((function(e){s[e]=t})),Object.keys(t.textures).forEach((function(e){s[e]=t.textures[e]})),!n){var i=r.path.dirname(e[0]);t.linkedSheets.forEach((function(e,r){var n=m([i+"/"+t.data.meta.related_multi_packs[r]],e,!0);Object.assign(s,n)}))}return s}var g={extension:e.ExtensionType.CacheParser,test:function(e){return e instanceof t.Spritesheet},getCacheableAssets:function(e,t){return m(e,t,!1)}},b={extension:e.ExtensionType.CacheParser,test:function(t){return Array.isArray(t)&&t.every((function(t){return t instanceof e.Texture}))},getCacheableAssets:function(e,t){var r={};return e.forEach((function(e){t.forEach((function(t,n){r[e+(0===n?"":n+1)]=t}))})),r}};function x(){for(var e=arguments,t=this,r=[],n=0;n<arguments.length;n++)r[n]=e[n];return function(e){return c(t,void 0,void 0,(function(){return l(this,(function(t){return e.unshift.apply(e,r),[2,e]}))}))}}function y(){for(var e=arguments,t=this,r=[],n=0;n<arguments.length;n++)r[n]=e[n];return function(e){return c(t,void 0,void 0,(function(){var t,n,s,i;return l(this,(function(o){for(t=0,n=r;t<n.length;t++)s=n[t],-1!==(i=e.indexOf(s))&&e.splice(i,1);return[2,e]}))}))}}var _,P,E={extension:e.ExtensionType.DetectionParser,test:function(){return c(void 0,void 0,Promise,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return globalThis.createImageBitmap?("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",[4,n.settings.ADAPTER.fetch("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=").then((function(e){return e.blob()}))]):[2,!1];case 1:return e=t.sent(),[2,createImageBitmap(e).then((function(){return!0}),(function(){return!1}))]}}))}))},add:x("avif"),remove:y("avif")};function B(){P={s3tc:_.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:_.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:_.getExtension("WEBGL_compressed_texture_etc"),etc1:_.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:_.getExtension("WEBGL_compressed_texture_pvrtc")||_.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:_.getExtension("WEBGL_compressed_texture_atc"),astc:_.getExtension("WEBGL_compressed_texture_astc")}}var w={extension:e.ExtensionType.DetectionParser,test:function(){return c(void 0,void 0,Promise,(function(){var e,t;return l(this,(function(r){return e=n.settings.ADAPTER.createCanvas(),(t=e.getContext("webgl"))?(_=t,[2,!0]):[2,!1]}))}))},add:function(e){return c(void 0,void 0,Promise,(function(){var t,r;return l(this,(function(n){for(r in P||B(),t=[],P)P[r]&&t.push(r);return e.unshift.apply(e,t),[2,e]}))}))},remove:function(e){return c(void 0,void 0,Promise,(function(){return l(this,(function(t){return P||B(),[2,e.filter((function(e){return!(e in P)}))]}))}))}},T={extension:e.ExtensionType.DetectionParser,test:function(){return c(void 0,void 0,Promise,(function(){return l(this,(function(e){return[2,!(!s.BasisParser.basisBinding||!s.BasisParser.TranscoderWorker.wasmSource)]}))}))},add:x("basis"),remove:y("basis")},L={extension:e.ExtensionType.DetectionParser,test:function(){return c(void 0,void 0,Promise,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return globalThis.createImageBitmap?("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",[4,n.settings.ADAPTER.fetch("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=").then((function(e){return e.blob()}))]):[2,!1];case 1:return e=t.sent(),[2,createImageBitmap(e).then((function(){return!0}),(function(){return!1}))]}}))}))},add:x("webp"),remove:y("webp")},k=[".xml",".fnt"],O={extension:e.ExtensionType.LoadParser,test:function(e){return k.includes(r.path.extname(e))},testParse:function(e){return c(this,void 0,Promise,(function(){return l(this,(function(t){return[2,i.TextFormat.test(e)||i.XMLStringFormat.test(e)]}))}))},parse:function(e,t,n){return c(this,void 0,Promise,(function(){var s,o,a,u,c,h,f,p,A;return l(this,(function(l){switch(l.label){case 0:for(s=i.TextFormat.test(e)?i.TextFormat.parse(e):i.XMLStringFormat.parse(e),o=t.src,a=s.page,u=[],c=0;c<a.length;++c)h=a[c].file,f=r.path.join(r.path.dirname(o),h),u.push(f);return[4,n.load(u)];case 1:return p=l.sent(),A=u.map((function(e){return p[e]})),[2,i.BitmapFont.install(s,A,!0)]}}))}))},load:function(e,t){return c(this,void 0,Promise,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,n.settings.ADAPTER.fetch(e)];case 1:return[2,t.sent().text()]}}))}))},unload:function(e){e.destroy()}},M={extension:e.ExtensionType.LoadParser,test:function(e){return r.path.extname(e).includes(".json")},load:function(e){return c(this,void 0,Promise,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,n.settings.ADAPTER.fetch(e)];case 1:return[4,t.sent().json()];case 2:return[2,t.sent()]}}))}))}},R={extension:e.ExtensionType.LoadParser,testParse:function(e,t){return c(this,void 0,Promise,(function(){return l(this,(function(n){return[2,r.path.extname(t.src).includes(".json")&&!!e.frames]}))}))},parse:function(e,n,s){var i,o;return c(this,void 0,Promise,(function(){var a,u,c,h,f,p,A,d,v,m,g,b;return l(this,(function(l){switch(l.label){case 0:return(a=r.path.dirname(n.src))&&a.lastIndexOf("/")!==a.length-1&&(a+="/"),u=a+e.meta.image,[4,s.load([u])];case 1:return c=l.sent(),h=c[u],[4,(f=new t.Spritesheet(h.baseTexture,e,n.src)).parse()];case 2:if(l.sent(),p=null===(i=null==e?void 0:e.meta)||void 0===i?void 0:i.related_multi_packs,!Array.isArray(p))return[3,4];for(A=[],d=0,v=p;d<v.length;d++)"string"==typeof(m=v[d])&&(g=a+m,(null===(o=n.data)||void 0===o?void 0:o.ignoreMultiPack)||A.push(s.load({src:g,data:{ignoreMultiPack:!0}})));return[4,Promise.all(A)];case 3:b=l.sent(),f.linkedSheets=b,b.forEach((function(e){e.linkedSheets=[f].concat(f.linkedSheets.filter((function(t){return t!==e})))})),l.label=4;case 4:return[2,f]}}))}))},unload:function(e){e.destroy(!0)}},j={extension:e.ExtensionType.LoadParser,test:function(e){return r.path.extname(e).includes(".txt")},load:function(e){return c(this,void 0,Promise,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,n.settings.ADAPTER.fetch(e)];case 1:return[4,t.sent().text()];case 2:return[2,t.sent()]}}))}))}},F=["normal","bold","100","200","300","400","500","600","700","800","900"],I=["woff","woff2","ttf","otf"];function W(e){var t=r.path.extname(e);return r.path.basename(e,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map((function(e){return e.charAt(0).toUpperCase()+e.slice(1)})).join(" ")}var C={extension:e.ExtensionType.LoadParser,test:function(e){var t=e.split("?")[0].split(".").pop();return I.includes(t)},load:function(e,t){var r,n,s,i,o,a;return c(this,void 0,Promise,(function(){var c,h,f,p,A,d,v;return l(this,(function(l){switch(l.label){case 0:if(!window.navigator.onLine)throw new Error("[loadWebFont] Cannot load font - navigator is offline");if(!("FontFace"in window))return[3,5];c=[],h=null!==(n=null===(r=t.data)||void 0===r?void 0:r.family)&&void 0!==n?n:W(e),f=null!==(o=null===(i=null===(s=t.data)||void 0===s?void 0:s.weights)||void 0===i?void 0:i.filter((function(e){return F.includes(e)})))&&void 0!==o?o:["normal"],p=null!==(a=t.data)&&void 0!==a?a:{},A=0,l.label=1;case 1:return A<f.length?(d=f[A],[4,(v=new FontFace(h,"url("+e+")",u(u({},p),{weight:d}))).load()]):[3,4];case 2:l.sent(),document.fonts.add(v),c.push(v),l.label=3;case 3:return A++,[3,1];case 4:return[2,1===c.length?c[0]:c];case 5:return[2,null]}}))}))},unload:function(e){(Array.isArray(e)?e:[e]).forEach((function(e){return document.fonts.delete(e)}))}};function D(e,t){var n=e.split("?")[0],s=r.path.extname(n).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function G(t,r,n){var s=new e.Texture(t);return s.baseTexture.on("dispose",(function(){delete r.promiseCache[n]})),s}var S,U,H={extension:e.ExtensionType.LoadParser,test:function(e){return D(e,".basis")},load:function(t,r,i){return c(this,void 0,Promise,(function(){var c,h,f,p,A;return l(this,(function(l){switch(l.label){case 0:return[4,s.TranscoderWorker.onTranscoderInitialized];case 1:return l.sent(),[4,n.settings.ADAPTER.fetch(t)];case 2:return[4,l.sent().arrayBuffer()];case 3:return c=l.sent(),[4,s.BasisParser.transcode(c)];case 4:return h=l.sent(),f=s.BASIS_FORMAT_TO_TYPE[h.basisFormat],p=h.basisFormat!==s.BASIS_FORMATS.cTFRGBA32?a.FORMATS.RGB:a.FORMATS.RGBA,[2,1===(A=h.map((function(n){return G(new e.BaseTexture(n,u({mipmap:n instanceof o.CompressedTextureResource&&n.levels>1?a.MIPMAP_MODES.ON_MANUAL:a.MIPMAP_MODES.OFF,alphaMode:a.ALPHA_MODES.NO_PREMULTIPLIED_ALPHA,type:f,format:p},r.data)),i,t)}))).length?A[0]:A]}}))}))},unload:function(e){Array.isArray(e)?e.forEach((function(e){return e.destroy(!0)})):e.destroy(!0)}},Q={extension:e.ExtensionType.LoadParser,test:function(e){return D(e,".dds")},load:function(t,s,i){return c(this,void 0,Promise,(function(){var c,h,f;return l(this,(function(l){switch(l.label){case 0:return[4,n.settings.ADAPTER.fetch(t)];case 1:return[4,l.sent().arrayBuffer()];case 2:return c=l.sent(),h=o.parseDDS(c),[2,1===(f=h.map((function(n){return G(new e.BaseTexture(n,u({mipmap:a.MIPMAP_MODES.OFF,alphaMode:a.ALPHA_MODES.NO_PREMULTIPLIED_ALPHA,resolution:r.getResolutionOfUrl(t)},s.data)),i,t)}))).length?f[0]:f]}}))}))},unload:function(e){Array.isArray(e)?e.forEach((function(e){return e.destroy(!0)})):e.destroy(!0)}},X={extension:e.ExtensionType.LoadParser,test:function(e){return D(e,".ktx")},load:function(t,s,i){return c(this,void 0,Promise,(function(){var c,h,f,p,A,d,v,m;return l(this,(function(l){switch(l.label){case 0:return[4,n.settings.ADAPTER.fetch(t)];case 1:return[4,l.sent().arrayBuffer()];case 2:return c=l.sent(),h=o.parseKTX(t,c),f=h.compressed,p=h.uncompressed,A=h.kvData,d=null!=f?f:p,v=u({mipmap:a.MIPMAP_MODES.OFF,alphaMode:a.ALPHA_MODES.NO_PREMULTIPLIED_ALPHA,resolution:r.getResolutionOfUrl(t)},s.data),[2,1===(m=d.map((function(r){d===p&&Object.assign(v,{type:r.type,format:r.format});var n=new e.BaseTexture(r,v);return n.ktxKeyValueData=A,G(n,i,t)}))).length?m[0]:m]}}))}))},unload:function(e){Array.isArray(e)?e.forEach((function(e){return e.destroy(!0)})):e.destroy(!0)}},N=0,Y="\n self.onmessage = function(event) {\n\n async function loadImageBitmap(url)\n {\n const response = await fetch(url);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap;\n }\n\n loadImageBitmap(event.data.data[0]).then(imageBitmap => {\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id,\n }, [imageBitmap]);\n }).catch(error => {\n self.postMessage({\n data: null,\n uuid: event.data.uuid,\n id: event.data.id,\n });\n });\n }",z=new(function(){function e(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}return e.prototype.loadImageBitmap=function(e){return this._run("loadImageBitmap",[e])},e.prototype._initWorkers=function(){return c(this,void 0,void 0,(function(){return l(this,(function(e){return this._initialized||(this._initialized=!0),[2]}))}))},e.prototype.getWorker=function(){var e=this;void 0===S&&(S=navigator.hardwareConcurrency||4);var t=this.workerPool.pop();return!t&&this._createdWorkers<S&&(U||(U=URL.createObjectURL(new Blob([Y],{type:"application/javascript"}))),this._createdWorkers++,(t=new Worker(U)).addEventListener("message",(function(t){e.complete(t.data),e.returnWorker(t.target),e.next()}))),t},e.prototype.returnWorker=function(e){this.workerPool.push(e)},e.prototype.complete=function(e){var t=e.data;this.resolveHash[e.uuid](t),this.resolveHash[e.uuid]=null},e.prototype._run=function(e,t){var r=this;this._initWorkers();var n=new Promise((function(n){r.queue.push({id:e,arguments:t,resolve:n})}));return this.next(),n},e.prototype.next=function(){if(this.queue.length){var e=this.getWorker();if(e){var t=this.queue.pop(),r=t.id;this.resolveHash[N]=t.resolve,e.postMessage({data:t.arguments,uuid:N++,id:r})}}},e}()),q=[".jpg",".png",".jpeg",".avif",".webp"];function K(e){return c(this,void 0,Promise,(function(){var t;return l(this,(function(r){switch(r.label){case 0:return[4,n.settings.ADAPTER.fetch(e)];case 1:return[4,r.sent().blob()];case 2:return t=r.sent(),[4,createImageBitmap(t)];case 3:return[2,r.sent()]}}))}))}var Z={extension:e.ExtensionType.LoadParser,config:{preferWorkers:!0},test:function(e){for(var t=!1,r=0;r<q.length;r++)if(0===e.indexOf("data:image/"+q[r].slice(1))){t=!0;break}return t||D(e,q)},load:function(t,n,s){return c(this,void 0,Promise,(function(){var i,o,a;return l(this,(function(c){switch(c.label){case 0:return i=null,window.createImageBitmap?this.config.preferWorkers?[4,z.loadImageBitmap(t)]:[3,2]:[3,5];case 1:return o=c.sent(),[3,4];case 2:return[4,K(t)];case 3:o=c.sent(),c.label=4;case 4:return i=o,[3,7];case 5:return[4,new Promise((function(e){(i=new Image).crossOrigin="anonymous",i.src=t,i.complete?e(i):i.onload=function(){e(i)}}))];case 6:i=c.sent(),c.label=7;case 7:return(a=new e.BaseTexture(i,u({resolution:r.getResolutionOfUrl(t)},n.data))).resource.src=t,[2,G(a,s,t)]}}))}))},unload:function(e){e.destroy(!0)}},V={extension:e.ExtensionType.LoadParser,test:function(e){return r.path.extname(e).includes(".svg")},testParse:function(t){return c(this,void 0,Promise,(function(){return l(this,(function(r){return[2,e.SVGResource.test(t)]}))}))},parse:function(t,n,s){var i,o,a;return c(this,void 0,Promise,(function(){var c,h,f;return l(this,(function(l){switch(l.label){case 0:return c=new e.SVGResource(t,null===(i=null==n?void 0:n.data)||void 0===i?void 0:i.resourceOptions),(h=new e.BaseTexture(c,u({resolution:r.getResolutionOfUrl(t)},null==n?void 0:n.data))).resource.src=t,f=G(h,s,t),(null===(a=null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.resourceOptions)||void 0===a?void 0:a.autoLoad)?[3,2]:[4,c.load()];case 1:l.sent(),l.label=2;case 2:return[2,f]}}))}))},load:function(e,t){return c(this,void 0,Promise,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,n.settings.ADAPTER.fetch(e)];case 1:return[2,t.sent().text()]}}))}))},unload:Z.unload},J=function(){function e(){this._parsers=[],this.promiseCache={}}return e.prototype.reset=function(){this.promiseCache={}},e.prototype._getLoadPromiseAndParser=function(e,t){var r=this,n={promise:null,parser:null};return n.promise=c(r,void 0,void 0,(function(){var r,s,i,o,a,u;return l(this,(function(c){switch(c.label){case 0:r=null,s=0,c.label=1;case 1:return s<this.parsers.length?(i=this.parsers[s]).load&&(null===(a=i.test)||void 0===a?void 0:a.call(i,e,t,this))?[4,i.load(e,t,this)]:[3,3]:[3,4];case 2:return r=c.sent(),n.parser=i,[3,4];case 3:return s++,[3,1];case 4:if(!n.parser)return[2,null];s=0,c.label=5;case 5:return s<this.parsers.length?(i=this.parsers[s]).parse?(o=i.parse)?[4,null===(u=i.testParse)||void 0===u?void 0:u.call(i,r,t,this)]:[3,7]:[3,9]:[3,10];case 6:o=c.sent(),c.label=7;case 7:return o?[4,i.parse(r,t,this)]:[3,9];case 8:r=c.sent()||r,n.parser=i,c.label=9;case 9:return s++,[3,5];case 10:return[2,r]}}))})),n},e.prototype.load=function(e,t){return c(this,void 0,Promise,(function(){var n,s,i,o,a,u,h=this;return l(this,(function(p){switch(p.label){case 0:return n=0,s={},i=d(e),o=f(e,(function(e){return{src:e}})),a=o.length,u=o.map((function(e){return c(h,void 0,void 0,(function(){var i,o,u,c;return l(this,(function(l){switch(l.label){case 0:if(i=r.path.toAbsolute(e.src),s[e.src])return[3,4];l.label=1;case 1:return l.trys.push([1,3,,4]),this.promiseCache[i]||(this.promiseCache[i]=this._getLoadPromiseAndParser(i,e)),o=s,u=e.src,[4,this.promiseCache[i].promise];case 2:return o[u]=l.sent(),t&&t(++n/a),[3,4];case 3:throw c=l.sent(),delete this.promiseCache[i],delete s[e.src],new Error("[Loader.load] Failed to load "+i+".\n"+c);case 4:return[2]}}))}))})),[4,Promise.all(u)];case 1:return p.sent(),[2,i?s[o[0].src]:s]}}))}))},e.prototype.unload=function(e){return c(this,void 0,Promise,(function(){var t,n,s=this;return l(this,(function(i){switch(i.label){case 0:return t=f(e,(function(e){return{src:e}})),n=t.map((function(e){return c(s,void 0,void 0,(function(){var t,n,s,i,o;return l(this,(function(a){switch(a.label){case 0:return t=r.path.toAbsolute(e.src),(n=this.promiseCache[t])?[4,n.promise]:[3,2];case 1:s=a.sent(),null===(o=null===(i=n.parser)||void 0===i?void 0:i.unload)||void 0===o||o.call(i,s,e,this),delete this.promiseCache[t],a.label=2;case 2:return[2]}}))}))})),[4,Promise.all(n)];case 1:return i.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"parsers",{get:function(){return this._parsers},enumerable:!1,configurable:!0}),e}(),$=["jpg","png","jpeg","avif","webp"],ee={extension:e.ExtensionType.ResolveParser,test:function(e){var t=e.split("?")[0].split("."),r=t.pop(),n=t.pop();return"json"===r&&$.includes(n)},parse:function(e){var t,r,s=e.split(".");return{resolution:parseFloat(null!==(r=null===(t=n.settings.RETINA_PREFIX.exec(e))||void 0===t?void 0:t[1])&&void 0!==r?r:"1"),format:s[s.length-2],src:e}}},te={extension:e.ExtensionType.ResolveParser,test:Z.test,parse:function(e){var t,r;return{resolution:parseFloat(null!==(r=null===(t=n.settings.RETINA_PREFIX.exec(e))||void 0===t?void 0:t[1])&&void 0!==r?r:"1"),format:e.split(".").pop(),src:e}}},re={extension:e.ExtensionType.ResolveParser,test:function(e){var t=e.split("?")[0].split(".").pop();return["basis","ktx","dds"].includes(t)},parse:function(e){var t,r,s,i;if("ktx"===e.split("?")[0].split(".").pop()){var o=[".s3tc.ktx",".s3tc_sRGB.ktx",".etc.ktx",".etc1.ktx",".pvrt.ktx",".atc.ktx",".astc.ktx"];if(o.some((function(t){return e.endsWith(t)})))return{resolution:parseFloat(null!==(r=null===(t=n.settings.RETINA_PREFIX.exec(e))||void 0===t?void 0:t[1])&&void 0!==r?r:"1"),format:o.find((function(t){return e.endsWith(t)})),src:e}}return{resolution:parseFloat(null!==(i=null===(s=n.settings.RETINA_PREFIX.exec(e))||void 0===s?void 0:s[1])&&void 0!==i?i:"1"),format:e.split(".").pop(),src:e}}},ne=function(){function e(){this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}return e.prototype.prefer=function(){for(var e=arguments,t=this,r=[],n=0;n<arguments.length;n++)r[n]=e[n];r.forEach((function(e){t._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))})),this._resolverHash={}},Object.defineProperty(e.prototype,"basePath",{get:function(){return this._basePath},set:function(e){this._basePath=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootPath",{get:function(){return this._rootPath},set:function(e){this._rootPath=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parsers",{get:function(){return this._parsers},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this._preferredOrder=[],this._resolverHash={},this._assetMap={},this._rootPath=null,this._basePath=null,this._manifest=null},e.prototype.addManifest=function(e){var t=this;this._manifest,this._manifest=e,e.bundles.forEach((function(e){t.addBundle(e.name,e.assets)}))},e.prototype.addBundle=function(e,t){var r=this,n=[];Array.isArray(t)?t.forEach((function(e){"string"==typeof e.name?n.push(e.name):n.push.apply(n,e.name),r.add(e.name,e.srcs)})):Object.keys(t).forEach((function(e){n.push(e),r.add(e,t[e])})),this._bundles[e]=n},e.prototype.add=function(e,t,n){var s=this,i=f(e);i.forEach((function(e){s._assetMap[e]})),Array.isArray(t)||(t="string"==typeof t?A(t):[t]);var o=t.map((function(e){var t,o=e;if("string"==typeof e){for(var a=!1,u=0;u<s._parsers.length;u++){var c=s._parsers[u];if(c.test(e)){o=c.parse(e),a=!0;break}}a||(o={src:e})}return o.format||(o.format=o.src.split(".").pop()),o.alias||(o.alias=i),(s._basePath||s._rootPath)&&(o.src=r.path.toAbsolute(o.src,s._basePath,s._rootPath)),o.data=null!==(t=o.data)&&void 0!==t?t:n,o}));i.forEach((function(e){s._assetMap[e]=o}))},e.prototype.resolveBundle=function(e){var t=this,r=d(e);e=f(e);var n={};return e.forEach((function(e){var r=t._bundles[e];r&&(n[e]=t.resolve(r))})),r?n[e[0]]:n},e.prototype.resolveUrl=function(e){var t=this.resolve(e);if("string"!=typeof e){var r={};for(var n in t)r[n]=t[n].src;return r}return t.src},e.prototype.resolve=function(e){var t=this,n=d(e);e=f(e);var s={};return e.forEach((function(e){var n;if(!t._resolverHash[e])if(t._assetMap[e]){var i=t._assetMap[e],o=t._getPreferredOrder(i),a=i[0];null==o||o.priority.forEach((function(e){o.params[e].forEach((function(t){var r=i.filter((function(r){return!!r[e]&&r[e]===t}));r.length&&(i=r)}))})),t._resolverHash[e]=null!==(n=i[0])&&void 0!==n?n:a}else{var u=e;(t._basePath||t._rootPath)&&(u=r.path.toAbsolute(u,t._basePath,t._rootPath)),t._resolverHash[e]={src:u}}s[e]=t._resolverHash[e]})),n?s[e[0]]:s},e.prototype._getPreferredOrder=function(e){for(var t=function(t){var n=e[0],s=r._preferredOrder.find((function(e){return e.params.format.includes(n.format)}));if(s)return{value:s}},r=this,n=0;n<e.length;n++){var s=t();if("object"==typeof s)return s.value}return this._preferredOrder[0]},e}(),se=function(){function e(){this._detections=[],this._initialized=!1,this.resolver=new ne,this.loader=new J,this.cache=v,this._backgroundLoader=new h(this.loader),this._backgroundLoader.active=!0,this.reset()}return e.prototype.init=function(e){var t,r,n,s;return void 0===e&&(e={}),c(this,void 0,Promise,(function(){var i,o,a,u,c,h,f,p,A,d;return l(this,(function(l){switch(l.label){case 0:return this._initialized?[2]:(this._initialized=!0,e.basePath&&(this.resolver.basePath=e.basePath),e.manifest?"string"!=typeof(i=e.manifest)?[3,2]:[4,this.load(i)]:[3,3]);case 1:i=l.sent(),l.label=2;case 2:this.resolver.addManifest(i),l.label=3;case 3:if(o=null!==(r=null===(t=e.texturePreference)||void 0===t?void 0:t.resolution)&&void 0!==r?r:1,a="number"==typeof o?[o]:o,!(null===(n=e.texturePreference)||void 0===n?void 0:n.format))return[3,9];c=null===(s=e.texturePreference)||void 0===s?void 0:s.format,u="string"==typeof c?[c]:c,h=0,f=this._detections,l.label=4;case 4:return h<f.length?[4,(d=f[h]).test()]:[3,8];case 5:return l.sent()?[3,7]:[4,d.remove(u)];case 6:u=l.sent(),l.label=7;case 7:return h++,[3,4];case 8:return[3,14];case 9:u=["png","jpg","jpeg"],p=0,A=this._detections,l.label=10;case 10:return p<A.length?[4,(d=A[p]).test()]:[3,14];case 11:return l.sent()?[4,d.add(u)]:[3,13];case 12:u=l.sent(),l.label=13;case 13:return p++,[3,10];case 14:return this.resolver.prefer({params:{format:u,resolution:a}}),[2]}}))}))},e.prototype.add=function(e,t,r){this.resolver.add(e,t,r)},e.prototype.load=function(e,t){return c(this,void 0,Promise,(function(){var r,n,s,i,o=this;return l(this,(function(a){switch(a.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:a.sent(),a.label=2;case 2:return r=d(e),n=f(e).map((function(e){return"string"!=typeof e?(o.resolver.add(e.src,e),e.src):e})),s=this.resolver.resolve(n),[4,this._mapLoadToResolve(s,t)];case 3:return i=a.sent(),[2,r?i[n[0]]:i]}}))}))},e.prototype.addBundle=function(e,t){this.resolver.addBundle(e,t)},e.prototype.loadBundle=function(e,t){return c(this,void 0,Promise,(function(){var r,n,s,i,o,a,u,c,h=this;return l(this,(function(l){switch(l.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:l.sent(),l.label=2;case 2:return r=!1,"string"==typeof e&&(r=!0,e=[e]),n=this.resolver.resolveBundle(e),s={},i=Object.keys(n),o=0,a=0,u=function(){null==t||t(++o/a)},c=i.map((function(e){var t=n[e];return a+=Object.keys(t).length,h._mapLoadToResolve(t,u).then((function(t){s[e]=t}))})),[4,Promise.all(c)];case 3:return l.sent(),[2,r?s[e[0]]:s]}}))}))},e.prototype.backgroundLoad=function(e){return c(this,void 0,Promise,(function(){var t;return l(this,(function(r){switch(r.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:r.sent(),r.label=2;case 2:return"string"==typeof e&&(e=[e]),t=this.resolver.resolve(e),this._backgroundLoader.add(Object.values(t)),[2]}}))}))},e.prototype.backgroundLoadBundle=function(e){return c(this,void 0,Promise,(function(){var t,r=this;return l(this,(function(n){switch(n.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:n.sent(),n.label=2;case 2:return"string"==typeof e&&(e=[e]),t=this.resolver.resolveBundle(e),Object.values(t).forEach((function(e){r._backgroundLoader.add(Object.values(e))})),[2]}}))}))},e.prototype.reset=function(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1},e.prototype.get=function(e){if("string"==typeof e)return v.get(e);for(var t={},r=0;r<e.length;r++)t[r]=v.get(e[r]);return t},e.prototype._mapLoadToResolve=function(e,t){return c(this,void 0,Promise,(function(){var r,n,s,i;return l(this,(function(o){switch(o.label){case 0:return r=Object.values(e),n=Object.keys(e),this._backgroundLoader.active=!1,[4,this.loader.load(r,t)];case 1:return s=o.sent(),this._backgroundLoader.active=!0,i={},r.forEach((function(e,t){var r=s[e.src],o=[e.src];e.alias&&o.push.apply(o,e.alias),i[n[t]]=r,v.set(o,r)})),[2,i]}}))}))},e.prototype.unload=function(e){return c(this,void 0,Promise,(function(){var t,r;return l(this,(function(n){switch(n.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:n.sent(),n.label=2;case 2:return t=f(e).map((function(e){return"string"!=typeof e?e.src:e})),r=this.resolver.resolve(t),[4,this._unloadFromResolved(r)];case 3:return n.sent(),[2]}}))}))},e.prototype.unloadBundle=function(e){return c(this,void 0,Promise,(function(){var t,r,n=this;return l(this,(function(s){switch(s.label){case 0:return this._initialized?[3,2]:[4,this.init()];case 1:s.sent(),s.label=2;case 2:return e=f(e),t=this.resolver.resolveBundle(e),r=Object.keys(t).map((function(e){return n._unloadFromResolved(t[e])})),[4,Promise.all(r)];case 3:return s.sent(),[2]}}))}))},e.prototype._unloadFromResolved=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(r){switch(r.label){case 0:return(t=Object.values(e)).forEach((function(e){v.remove(e.src)})),[4,this.loader.unload(t)];case 1:return r.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"detections",{get:function(){return this._detections},enumerable:!1,configurable:!0}),e}(),ie=new se;e.extensions.handleByList(e.ExtensionType.LoadParser,ie.loader.parsers).handleByList(e.ExtensionType.ResolveParser,ie.resolver.parsers).handleByList(e.ExtensionType.CacheParser,ie.cache.parsers).handleByList(e.ExtensionType.DetectionParser,ie.detections),e.extensions.add(Z,V,j,M,R,O,C,g,b,te,ee,L,E),exports.Assets=ie,exports.AssetsClass=se,exports.Cache=v,exports.addFormats=x,exports.cacheSpritesheet=g,exports.cacheTextureArray=b,exports.convertToList=f,exports.createStringVariations=A,exports.detectAvif=E,exports.detectBasis=T,exports.detectCompressedTextures=w,exports.detectWebp=L,exports.getFontFamilyName=W,exports.isSingleItem=d,exports.loadBasis=H,exports.loadBitmapFont=O,exports.loadDDS=Q,exports.loadImageBitmap=K,exports.loadJson=M,exports.loadKTX=X,exports.loadSVG=V,exports.loadSpritesheet=R,exports.loadTextures=Z,exports.loadTxt=j,exports.loadWebFont=C,exports.removeFormats=y,exports.resolveCompressedTextureUrl=re,exports.resolveSpriteSheetUrl=ee,exports.resolveTextureUrl=te;
*/Object.defineProperty(exports,"__esModule",{value:!0});var n=require("@pixi/core");class U{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(t=>{this._assetList.push(t)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;s<t;s++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}}const u=(a,e)=>(Array.isArray(a)||(a=[a]),e?a.map(t=>typeof t=="string"?e(t):t):a);function E(a,e,t,s,r){const i=e[t];for(let o=0;o<i.length;o++){const c=i[o];t<e.length-1?E(a.replace(s[t],c),e,t+1,s,r):r.push(a.replace(s[t],c))}}function L(a){const e=/\{(.*?)\}/g,t=a.match(e),s=[];if(t){const r=[];t.forEach(i=>{const o=i.substring(1,i.length-1).split(",");r.push(o)}),E(a,r,0,t,s)}else s.push(a);return s}const g=a=>!Array.isArray(a);class Q{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){return this._cache.get(e)}set(e,t){const s=u(e);let r;for(let c=0;c<this.parsers.length;c++){const h=this.parsers[c];if(h.test(t)){r=h.getCacheableAssets(s,t);break}}r||(r={},s.forEach(c=>{r[c]=t}));const i=Object.keys(r),o={cacheKeys:i,keys:s};if(s.forEach(c=>{this._cacheMap.set(c,o)}),i.forEach(c=>{this._cache.has(c)&&this._cache.get(c),this._cache.set(c,r[c])}),t instanceof n.Texture){const c=t;s.forEach(h=>{c.baseTexture!==n.Texture.EMPTY.baseTexture&&n.BaseTexture.addToCache(c.baseTexture,h),n.Texture.addToCache(c,h)})}}remove(e){if(this._cacheMap.get(e),!this._cacheMap.has(e))return;const t=this._cacheMap.get(e);t.cacheKeys.forEach(s=>{this._cache.delete(s)}),t.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const f=new Q;class V{constructor(){this._parsers=[],this.promiseCache={}}reset(){this.promiseCache={}}_getLoadPromiseAndParser(e,t){const s={promise:null,parser:null};return s.promise=(async()=>{let r=null;for(let i=0;i<this.parsers.length;i++){const o=this.parsers[i];if(o.load&&o.test?.(e,t,this)){r=await o.load(e,t,this),s.parser=o;break}}if(!s.parser)return null;for(let i=0;i<this.parsers.length;i++){const o=this.parsers[i];o.parse&&o.parse&&await o.testParse?.(r,t,this)&&(r=await o.parse(r,t,this)||r,s.parser=o)}return r})(),s}async load(e,t){let s=0;const r={},i=g(e),o=u(e,l=>({src:l})),c=o.length,h=o.map(async l=>{const d=n.utils.path.toAbsolute(l.src);if(!r[l.src])try{this.promiseCache[d]||(this.promiseCache[d]=this._getLoadPromiseAndParser(d,l)),r[l.src]=await this.promiseCache[d].promise,t&&t(++s/c)}catch(A){throw delete this.promiseCache[d],delete r[l.src],new Error(`[Loader.load] Failed to load ${d}.
${A}`)}});return await Promise.all(h),i?r[o[0].src]:r}async unload(e){const t=u(e,s=>({src:s})).map(async s=>{const r=n.utils.path.toAbsolute(s.src),i=this.promiseCache[r];if(i){const o=await i.promise;i.parser?.unload?.(o,s,this),delete this.promiseCache[r]}});await Promise.all(t)}get parsers(){return this._parsers}}class N{constructor(){this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this._preferredOrder=[],this._resolverHash={},this._assetMap={},this._rootPath=null,this._basePath=null,this._manifest=null}addManifest(e){this._manifest,this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const s=[];Array.isArray(t)?t.forEach(r=>{typeof r.name=="string"?s.push(r.name):s.push(...r.name),this.add(r.name,r.srcs)}):Object.keys(t).forEach(r=>{s.push(r),this.add(r,t[r])}),this._bundles[e]=s}add(e,t,s){const r=u(e);r.forEach(o=>{this._assetMap[o]}),Array.isArray(t)||(typeof t=="string"?t=L(t):t=[t]);const i=t.map(o=>{let c=o;if(typeof o=="string"){let h=!1;for(let l=0;l<this._parsers.length;l++){const d=this._parsers[l];if(d.test(o)){c=d.parse(o),h=!0;break}}h||(c={src:o})}return c.format||(c.format=c.src.split(".").pop()),c.alias||(c.alias=r),(this._basePath||this._rootPath)&&(c.src=n.utils.path.toAbsolute(c.src,this._basePath,this._rootPath)),c.data=c.data??s,c});r.forEach(o=>{this._assetMap[o]=i})}resolveBundle(e){const t=g(e);e=u(e);const s={};return e.forEach(r=>{const i=this._bundles[r];i&&(s[r]=this.resolve(i))}),t?s[e[0]]:s}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const s={};for(const r in t)s[r]=t[r].src;return s}return t.src}resolve(e){const t=g(e);e=u(e);const s={};return e.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let i=this._assetMap[r];const o=this._getPreferredOrder(i),c=i[0];o?.priority.forEach(h=>{o.params[h].forEach(l=>{const d=i.filter(A=>A[h]?A[h]===l:!1);d.length&&(i=d)})}),this._resolverHash[r]=i[0]??c}else{let i=r;(this._basePath||this._rootPath)&&(i=n.utils.path.toAbsolute(i,this._basePath,this._rootPath)),this._resolverHash[r]={src:i}}s[r]=this._resolverHash[r]}),t?s[e[0]]:s}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const s=e[0],r=this._preferredOrder.find(i=>i.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}}class T{constructor(){this._detections=[],this._initialized=!1,this.resolver=new N,this.loader=new V,this.cache=f,this._backgroundLoader=new U(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized)return;if(this._initialized=!0,e.basePath&&(this.resolver.basePath=e.basePath),e.manifest){let i=e.manifest;typeof i=="string"&&(i=await this.load(i)),this.resolver.addManifest(i)}const t=e.texturePreference?.resolution??1,s=typeof t=="number"?[t]:t;let r=[];if(e.texturePreference?.format){const i=e.texturePreference?.format;r=typeof i=="string"?[i]:i;for(const o of this._detections)await o.test()||(r=await o.remove(r))}else for(const i of this._detections)await i.test()&&(r=await i.add(r));this.resolver.prefer({params:{format:r,resolution:s}})}add(e,t,s){this.resolver.add(e,t,s)}async load(e,t){this._initialized||await this.init();const s=g(e),r=u(e).map(c=>typeof c!="string"?(this.resolver.add(c.src,c),c.src):c),i=this.resolver.resolve(r),o=await this._mapLoadToResolve(i,t);return s?o[r[0]]:o}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let s=!1;typeof e=="string"&&(s=!0,e=[e]);const r=this.resolver.resolveBundle(e),i={},o=Object.keys(r);let c=0,h=0;const l=()=>{t?.(++c/h)},d=o.map(A=>{const B=r[A];return h+=Object.keys(B).length,this._mapLoadToResolve(B,l).then(z=>{i[A]=z})});return await Promise.all(d),s?i[e[0]]:i}async backgroundLoad(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e=="string"&&(e=[e]);const t=this.resolver.resolveBundle(e);Object.values(t).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e=="string")return f.get(e);const t={};for(let s=0;s<e.length;s++)t[s]=f.get(e[s]);return t}async _mapLoadToResolve(e,t){const s=Object.values(e),r=Object.keys(e);this._backgroundLoader.active=!1;const i=await this.loader.load(s,t);this._backgroundLoader.active=!0;const o={};return s.forEach((c,h)=>{const l=i[c.src],d=[c.src];c.alias&&d.push(...c.alias),o[r[h]]=l,f.set(d,l)}),o}async unload(e){this._initialized||await this.init();const t=u(e).map(r=>typeof r!="string"?r.src:r),s=this.resolver.resolve(t);await this._unloadFromResolved(s)}async unloadBundle(e){this._initialized||await this.init(),e=u(e);const t=this.resolver.resolveBundle(e),s=Object.keys(t).map(r=>this._unloadFromResolved(t[r]));await Promise.all(s)}async _unloadFromResolved(e){const t=Object.values(e);t.forEach(s=>{f.remove(s.src)}),await this.loader.unload(t)}get detections(){return this._detections}}const m=new T;n.extensions.handleByList(n.ExtensionType.LoadParser,m.loader.parsers).handleByList(n.ExtensionType.ResolveParser,m.resolver.parsers).handleByList(n.ExtensionType.CacheParser,m.cache.parsers).handleByList(n.ExtensionType.DetectionParser,m.detections);const k={extension:n.ExtensionType.CacheParser,test:a=>Array.isArray(a)&&a.every(e=>e instanceof n.Texture),getCacheableAssets:(a,e)=>{const t={};return a.forEach(s=>{e.forEach((r,i)=>{t[s+(i===0?"":i+1)]=r})}),t}};n.extensions.add(k);var p=(a=>(a[a.Low=0]="Low",a[a.Normal=1]="Normal",a[a.High=2]="High",a))(p||{});const C={extension:{type:n.ExtensionType.LoadParser,priority:p.Low},test(a){return n.utils.path.extname(a).includes(".json")},async load(a){return await(await n.settings.ADAPTER.fetch(a)).json()}};n.extensions.add(C);const j={extension:{type:n.ExtensionType.LoadParser,priority:p.Low},test(a){return n.utils.path.extname(a).includes(".txt")},async load(a){return await(await n.settings.ADAPTER.fetch(a)).text()}};n.extensions.add(j);const S=["normal","bold","100","200","300","400","500","600","700","800","900"],Y=["woff","woff2","ttf","otf"];function O(a){const e=n.utils.path.extname(a);return n.utils.path.basename(a,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const R={extension:{type:n.ExtensionType.LoadParser,priority:p.Low},test(a){const e=a.split("?")[0].split(".").pop();return Y.includes(e)},async load(a,e){if(!window.navigator.onLine)throw new Error("[loadWebFont] Cannot load font - navigator is offline");if("FontFace"in window){const t=[],s=e.data?.family??O(a),r=e.data?.weights?.filter(o=>S.includes(o))??["normal"],i=e.data??{};for(let o=0;o<r.length;o++){const c=r[o],h=new FontFace(s,`url(${a})`,{...i,weight:c});await h.load(),document.fonts.add(h),t.push(h)}return t.length===1?t[0]:t}return null},unload(a){(Array.isArray(a)?a:[a]).forEach(e=>document.fonts.delete(e))}};n.extensions.add(R);let F=0,w;const $={id:"loadImageBitmap",code:`
self.onmessage = function(event) {
async function loadImageBitmap(url)
{
const response = await fetch(url);
const imageBlob = await response.blob();
const imageBitmap = await createImageBitmap(imageBlob);
return imageBitmap;
}
loadImageBitmap(event.data.data[0]).then(imageBitmap => {
self.postMessage({
data: imageBitmap,
uuid: event.data.uuid,
id: event.data.id,
}, [imageBitmap]);
}).catch(error => {
self.postMessage({
data: null,
uuid: event.data.uuid,
id: event.data.id,
});
});
}`};let b;class X{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}loadImageBitmap(e){return this._run("loadImageBitmap",[e])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){w===void 0&&(w=navigator.hardwareConcurrency||4);let e=this.workerPool.pop();return!e&&this._createdWorkers<w&&(b||(b=URL.createObjectURL(new Blob([$.code],{type:"application/javascript"}))),this._createdWorkers++,e=new Worker(b),e.addEventListener("message",t=>{this.complete(t.data),this.returnWorker(t.target),this.next()})),e}returnWorker(e){this.workerPool.push(e)}complete(e){const t=e.data;this.resolveHash[e.uuid](t),this.resolveHash[e.uuid]=null}_run(e,t){this._initWorkers();const s=new Promise(r=>{this.queue.push({id:e,arguments:t,resolve:r})});return this.next(),s}next(){if(!this.queue.length)return;const e=this.getWorker();if(!e)return;const t=this.queue.pop(),s=t.id;this.resolveHash[F]=t.resolve,e.postMessage({data:t.arguments,uuid:F++,id:s})}}const Z=new X;function I(a,e){const t=a.split("?")[0],s=n.utils.path.extname(t).toLowerCase();return Array.isArray(e)?e.includes(s.toLowerCase()):s.toLowerCase()===e}function x(a,e,t){const s=new n.Texture(a);return s.baseTexture.on("dispose",()=>{delete e.promiseCache[t]}),s}const P=[".jpg",".png",".jpeg",".avif",".webp"];async function M(a){const e=await(await n.settings.ADAPTER.fetch(a)).blob();return await createImageBitmap(e)}const _={extension:{type:n.ExtensionType.LoadParser,priority:p.High},config:{preferWorkers:!0},test(a){let e=!1;for(let t=0;t<P.length;t++)if(a.indexOf(`data:image/${P[t].slice(1)}`)===0){e=!0;break}return e||I(a,P)},async load(a,e,t){let s=null;window.createImageBitmap?s=this.config.preferWorkers?await Z.loadImageBitmap(a):await M(a):s=await new Promise(i=>{s=new Image,s.crossOrigin="anonymous",s.src=a,s.complete?i(s):s.onload=()=>{i(s)}});const r=new n.BaseTexture(s,{resolution:n.utils.getResolutionOfUrl(a),...e.data});return r.resource.src=a,x(r,t,a)},unload(a){a.destroy(!0)}};n.extensions.add(_);const q={extension:{type:n.ExtensionType.LoadParser,priority:p.High},test(a){return n.utils.path.extname(a).includes(".svg")},async testParse(a){return n.SVGResource.test(a)},async parse(a,e,t){const s=new n.SVGResource(a,e?.data?.resourceOptions),r=new n.BaseTexture(s,{resolution:n.utils.getResolutionOfUrl(a),...e?.data});r.resource.src=a;const i=x(r,t,a);return e?.data?.resourceOptions?.autoLoad||await s.load(),i},async load(a,e){return(await n.settings.ADAPTER.fetch(a)).text()},unload:_.unload},W={extension:n.ExtensionType.ResolveParser,test:_.test,parse:a=>({resolution:parseFloat(n.settings.RETINA_PREFIX.exec(a)?.[1]??"1"),format:a.split(".").pop(),src:a})};n.extensions.add(W);function y(...a){return async e=>(e.push(...a),e)}function v(...a){return async e=>{for(const t of a){const s=e.indexOf(t);s!==-1&&e.splice(s,1)}return e}}const D={extension:{type:n.ExtensionType.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const a="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",e=await n.settings.ADAPTER.fetch(a).then(t=>t.blob());return createImageBitmap(e).then(()=>!0,()=>!1)},add:y("avif"),remove:v("avif")};n.extensions.add(D);const H={extension:{type:n.ExtensionType.DetectionParser,priority:0},test:async()=>{if(!globalThis.createImageBitmap)return!1;const a="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=",e=await n.settings.ADAPTER.fetch(a).then(t=>t.blob());return createImageBitmap(e).then(()=>!0,()=>!1)},add:y("webp"),remove:v("webp")};n.extensions.add(H);const G={extension:{type:n.ExtensionType.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:y("png","jpg","jpeg"),remove:v("png","jpg","jpeg")};n.extensions.add(G),exports.Assets=m,exports.AssetsClass=T,exports.Cache=f,exports.LoaderParserPriority=p,exports.addFormats=y,exports.cacheTextureArray=k,exports.checkExtension=I,exports.convertToList=u,exports.createStringVariations=L,exports.createTexture=x,exports.detectAvif=D,exports.detectDefaults=G,exports.detectWebp=H,exports.getFontFamilyName=O,exports.isSingleItem=g,exports.loadImageBitmap=M,exports.loadJson=C,exports.loadSVG=q,exports.loadTextures=_,exports.loadTxt=j,exports.loadWebFont=R,exports.removeFormats=v,exports.resolveTextureUrl=W;
//# sourceMappingURL=assets.min.js.map

53

index.d.ts
/// <reference types="css-font-loading-module" />
import { BitmapFont } from '@pixi/text-bitmap';
import type { BaseTexture } from '@pixi/core';
import type { ExtensionMetadata } from '@pixi/core';
import type { IBaseTextureOptions } from '@pixi/core';
import { Resource } from '@pixi/core';
import { Spritesheet } from '@pixi/spritesheet';
import { Texture } from '@pixi/core';

@@ -546,6 +545,6 @@

export declare const cacheSpritesheet: CacheParser<Spritesheet>;
export declare const cacheTextureArray: CacheParser<Texture[]>;
export declare function checkExtension(url: string, extension: string | string[]): boolean;
export declare const convertToList: <T>(input: string | T | (string | T)[], transform?: (input: string) => T) => T[];

@@ -562,8 +561,8 @@

export declare function createTexture(base: BaseTexture, loader: Loader, url: string): Texture<Resource>;
export declare const detectAvif: FormatDetectionParser;
export declare const detectBasis: FormatDetectionParser;
export declare const detectDefaults: FormatDetectionParser;
export declare const detectCompressedTextures: FormatDetectionParser;
export declare const detectWebp: FormatDetectionParser;

@@ -596,11 +595,2 @@

/** Load BASIS textures! */
export declare const loadBasis: LoaderParser<Texture<Resource> | Texture<Resource>[], IBaseTextureOptions<any>>;
/** simple loader plugin for loading in bitmap fonts! */
export declare const loadBitmapFont: LoaderParser<string | BitmapFont, any>;
/** Load our DDS textures! */
export declare const loadDDS: LoaderParser;
/**

@@ -723,2 +713,16 @@ * The Loader is responsible for loading all assets, such as images, spritesheets, audio files, etc.

/**
* The extension priority for loader parsers.
* Helpful when managing multiple parsers that share the same extension
* test. The higher priority parsers will be checked first.
*/
export declare enum LoaderParserPriority {
/** Generic parsers: txt, json, webfonts */
Low = 0,
/** PixiJS assets with generic extensions: spritesheets, bitmapfonts */
Normal = 1,
/** Specific texture types: svg, png, ktx, dds, basis */
High = 2
}
export declare type LoadFontData = {

@@ -746,13 +750,2 @@ family: string;

/** Loads KTX textures! */
export declare const loadKTX: LoaderParser<Texture<Resource> | Texture<Resource>[], IBaseTextureOptions<any>>;
/**
* Loader plugin that parses sprite sheets!
* once the JSON has been loaded this checks to see if the JSON is spritesheet data.
* If it is, we load the spritesheets image and parse the data into PIXI.Spritesheet
* All textures in the sprite sheet are then added to the cache
*/
export declare const loadSpritesheet: LoaderParser<any, any>;
/** Loads SVG's into Textures */

@@ -776,3 +769,3 @@ export declare const loadSVG: LoaderParser<string | Texture<Resource>, IBaseTextureOptions<any>>;

/**
* A prefer order lets the resolver know which assets to prefere depending on the various parameters passed to it.
* A prefer order lets the resolver know which assets to prefer depending on the various parameters passed to it.
* @memberof PIXI

@@ -807,4 +800,2 @@ */

export declare const resolveCompressedTextureUrl: ResolveURLParser;
/**

@@ -1077,4 +1068,2 @@ * A class that is responsible for resolving mapping asset URLs to keys.

export declare const resolveSpriteSheetUrl: ResolveURLParser;
export declare const resolveTextureUrl: ResolveURLParser;

@@ -1081,0 +1070,0 @@

{
"name": "@pixi/assets",
"version": "6.5.3",
"version": "7.0.0-alpha",
"description": "Asset manager for PixiJS, loading resolving and Cacheing",

@@ -16,3 +16,2 @@ "keywords": [

"module": "dist/esm/assets.mjs",
"bundle": "dist/browser/assets.js",
"types": "index.d.ts",

@@ -48,13 +47,6 @@ "exports": {

},
"peerDependencies": {
"@pixi/basis": "6.5.3",
"@pixi/compressed-textures": "6.5.3",
"@pixi/constants": "6.5.3",
"@pixi/core": "6.5.3",
"@pixi/settings": "6.5.3",
"@pixi/spritesheet": "6.5.3",
"@pixi/text-bitmap": "6.5.3",
"@pixi/utils": "6.5.3"
},
"gitHead": "28e6b2841a65837a5e2873a3d5a9c27cabbe795a"
"pixiRequirements": [
"@pixi/core"
],
"gitHead": "da993226df64b804a9c00ed9ee4d011191467b8a"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc