@pixi/loaders
Advanced tools
Comparing version 5.2.4 to 5.3.0
/*! | ||
* @pixi/loaders - v5.2.4 | ||
* Compiled Sun, 03 May 2020 22:38:52 UTC | ||
* @pixi/loaders - v5.3.0 | ||
* Compiled Thu, 18 Jun 2020 23:27:40 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/loaders is licensed under the MIT License. | ||
*/ | ||
this.PIXI=this.PIXI||{};var _pixi_loaders=function(t,e,r){"use strict";var i=function(t,e){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},i=r.parser[e.strictMode?"strict":"loose"].exec(t),n={},s=14;s--;)n[r.key[s]]=i[s]||"";return n[r.q.name]={},n[r.key[12]].replace(r.q.parser,function(t,e,i){e&&(n[r.q.name][e]=i)}),n};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n,s,o=(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}();function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(e,r,n){void 0===r&&(r=!1),i(this,t),this._fn=e,this._once=r,this._thisArg=n,this._next=this._prev=this._owner=null}return r(t,[{key:"detach",value:function(){return null!==this._owner&&(this._owner.detach(this),!0)}}]),t}();function s(t,e){return t._head?(t._tail._next=e,e._prev=t._tail,t._tail=e):(t._head=e,t._tail=e),e._owner=t,e}var o=function(){function t(){i(this,t),this._head=this._tail=void 0}return r(t,[{key:"handlers",value:function(){var t=!(arguments.length<=0||void 0===arguments[0])&&arguments[0],e=this._head;if(t)return!!e;for(var r=[];e;)r.push(e),e=e._next;return r}},{key:"has",value:function(t){if(!(t instanceof n))throw new Error("MiniSignal#has(): First arg must be a MiniSignalBinding object.");return t._owner===this}},{key:"dispatch",value:function(){var t=arguments,e=this._head;if(!e)return!1;for(;e;)e._once&&this.detach(e),e._fn.apply(e._thisArg,t),e=e._next;return!0}},{key:"add",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if("function"!=typeof t)throw new Error("MiniSignal#add(): First arg must be a Function.");return s(this,new n(t,!1,e))}},{key:"once",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if("function"!=typeof t)throw new Error("MiniSignal#once(): First arg must be a Function.");return s(this,new n(t,!0,e))}},{key:"detach",value:function(t){if(!(t instanceof n))throw new Error("MiniSignal#detach(): First arg must be a MiniSignalBinding object.");return t._owner!==this?this:(t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t===this._head?(this._head=t._next,null===t._next&&(this._tail=null)):t===this._tail&&(this._tail=t._prev,this._tail._next=null),t._owner=null,this)}},{key:"detachAll",value:function(){var t=this._head;if(!t)return this;for(this._head=this._tail=null;t;)t._owner=null,t=t._next;return this}}]),t}();o.MiniSignalBinding=n,e.default=o,t.exports=e.default}(n={exports:{}},n.exports),n.exports),a=(s=o)&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s;function h(){}function u(t,e,r,i){var n=0,s=t.length;!function o(a){a||n===s?r&&r(a):i?setTimeout(function(){e(t[n++],o)},1):e(t[n++],o)}()}function d(t){return function(){if(null===t)throw new Error("Callback was already called.");var e=t;t=null,e.apply(this,arguments)}}function l(t,e){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=0,i={_tasks:[],concurrency:e,saturated:h,unsaturated:h,buffer:e/4,empty:h,drain:h,error:h,started:!1,paused:!1,push:function(t,e){n(t,!1,e)},kill:function(){r=0,i.drain=h,i.started=!1,i._tasks=[]},unshift:function(t,e){n(t,!0,e)},process:function(){for(;!i.paused&&r<i.concurrency&&i._tasks.length;){var e=i._tasks.shift();0===i._tasks.length&&i.empty(),(r+=1)===i.concurrency&&i.saturated(),t(e.data,d(s(e)))}},length:function(){return i._tasks.length},running:function(){return r},idle:function(){return i._tasks.length+r===0},pause:function(){!0!==i.paused&&(i.paused=!0)},resume:function(){if(!1!==i.paused){i.paused=!1;for(var t=1;t<=i.concurrency;t++)i.process()}}};function n(t,e,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(i.started=!0,null==t&&i.idle())setTimeout(function(){return i.drain()},1);else{var n={data:t,callback:"function"==typeof r?r:h};e?i._tasks.unshift(n):i._tasks.push(n),setTimeout(function(){return i.process()},1)}}function s(t){return function(){r-=1,t.callback.apply(t,arguments),null!=arguments[0]&&i.error(arguments[0],t.data),r<=i.concurrency-i.buffer&&i.unsaturated(),i.idle()&&i.drain(),i.process()}}return i}var c={};function _(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function f(t,e,r){return e&&_(t.prototype,e),r&&_(t,r),t}var p=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest),E=null;function g(){}var T=function(){function t(e,r,i){if("string"!=typeof e||"string"!=typeof r)throw new Error("Both name and url are required for constructing a resource.");i=i||{},this._flags=0,this._setFlag(t.STATUS_FLAGS.DATA_URL,0===r.indexOf("data:")),this.name=e,this.url=r,this.extension=this._getExtension(),this.data=null,this.crossOrigin=!0===i.crossOrigin?"anonymous":i.crossOrigin,this.timeout=i.timeout||0,this.loadType=i.loadType||this._determineLoadType(),this.xhrType=i.xhrType,this.metadata=i.metadata||{},this.error=null,this.xhr=null,this.children=[],this.type=t.TYPE.UNKNOWN,this.progressChunk=0,this._dequeue=g,this._onLoadBinding=null,this._elementTimer=0,this._boundComplete=this.complete.bind(this),this._boundOnError=this._onError.bind(this),this._boundOnProgress=this._onProgress.bind(this),this._boundOnTimeout=this._onTimeout.bind(this),this._boundXhrOnError=this._xhrOnError.bind(this),this._boundXhrOnTimeout=this._xhrOnTimeout.bind(this),this._boundXhrOnAbort=this._xhrOnAbort.bind(this),this._boundXhrOnLoad=this._xhrOnLoad.bind(this),this.onStart=new a,this.onProgress=new a,this.onComplete=new a,this.onAfterMiddleware=new a}t.setExtensionLoadType=function(e,r){m(t._loadTypeMap,e,r)},t.setExtensionXhrType=function(e,r){m(t._xhrTypeMap,e,r)};var e=t.prototype;return e.complete=function(){this._clearEvents(),this._finish()},e.abort=function(e){if(!this.error){if(this.error=new Error(e),this._clearEvents(),this.xhr)this.xhr.abort();else if(this.xdr)this.xdr.abort();else if(this.data)if(this.data.src)this.data.src=t.EMPTY_GIF;else for(;this.data.firstChild;)this.data.removeChild(this.data.firstChild);this._finish()}},e.load=function(e){var r=this;if(!this.isLoading)if(this.isComplete)e&&setTimeout(function(){return e(r)},1);else switch(e&&this.onComplete.once(e),this._setFlag(t.STATUS_FLAGS.LOADING,!0),this.onStart.dispatch(this),!1!==this.crossOrigin&&"string"==typeof this.crossOrigin||(this.crossOrigin=this._determineCrossOrigin(this.url)),this.loadType){case t.LOAD_TYPE.IMAGE:this.type=t.TYPE.IMAGE,this._loadElement("image");break;case t.LOAD_TYPE.AUDIO:this.type=t.TYPE.AUDIO,this._loadSourceElement("audio");break;case t.LOAD_TYPE.VIDEO:this.type=t.TYPE.VIDEO,this._loadSourceElement("video");break;case t.LOAD_TYPE.XHR:default:p&&this.crossOrigin?this._loadXdr():this._loadXhr()}},e._hasFlag=function(t){return 0!=(this._flags&t)},e._setFlag=function(t,e){this._flags=e?this._flags|t:this._flags&~t},e._clearEvents=function(){clearTimeout(this._elementTimer),this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("timeout",this._boundXhrOnTimeout,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null))},e._finish=function(){if(this.isComplete)throw new Error("Complete called again for an already completed resource.");this._setFlag(t.STATUS_FLAGS.COMPLETE,!0),this._setFlag(t.STATUS_FLAGS.LOADING,!1),this.onComplete.dispatch(this)},e._loadElement=function(t){this.metadata.loadElement?this.data=this.metadata.loadElement:"image"===t&&void 0!==window.Image?this.data=new Image:this.data=document.createElement(t),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))},e._loadSourceElement=function(t){if(this.metadata.loadElement?this.data=this.metadata.loadElement:"audio"===t&&void 0!==window.Audio?this.data=new Audio:this.data=document.createElement(t),null!==this.data){if(this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var e=this.metadata.mimeType,r=0;r<this.url.length;++r)this.data.appendChild(this._createSource(t,this.url[r],Array.isArray(e)?e[r]:e));else{var i=this.metadata.mimeType;this.data.appendChild(this._createSource(t,this.url,Array.isArray(i)?i[0]:i))}this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.data.addEventListener("canplaythrough",this._boundComplete,!1),this.data.load(),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))}else this.abort("Unsupported element: "+t)},e._loadXhr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var e=this.xhr=new XMLHttpRequest;e.open("GET",this.url,!0),e.timeout=this.timeout,this.xhrType===t.XHR_RESPONSE_TYPE.JSON||this.xhrType===t.XHR_RESPONSE_TYPE.DOCUMENT?e.responseType=t.XHR_RESPONSE_TYPE.TEXT:e.responseType=this.xhrType,e.addEventListener("error",this._boundXhrOnError,!1),e.addEventListener("timeout",this._boundXhrOnTimeout,!1),e.addEventListener("abort",this._boundXhrOnAbort,!1),e.addEventListener("progress",this._boundOnProgress,!1),e.addEventListener("load",this._boundXhrOnLoad,!1),e.send()},e._loadXdr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var t=this.xhr=new XDomainRequest;t.timeout=this.timeout||5e3,t.onerror=this._boundXhrOnError,t.ontimeout=this._boundXhrOnTimeout,t.onprogress=this._boundOnProgress,t.onload=this._boundXhrOnLoad,t.open("GET",this.url,!0),setTimeout(function(){return t.send()},1)},e._createSource=function(t,e,r){r||(r=t+"/"+this._getExtension(e));var i=document.createElement("source");return i.src=e,i.type=r,i},e._onError=function(t){this.abort("Failed to load element using: "+t.target.nodeName)},e._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(this,t.loaded/t.total)},e._onTimeout=function(){this.abort("Load timed out.")},e._xhrOnError=function(){var t=this.xhr;this.abort(O(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e._xhrOnTimeout=function(){var t=this.xhr;this.abort(O(t)+" Request timed out.")},e._xhrOnAbort=function(){var t=this.xhr;this.abort(O(t)+" Request was aborted by the user.")},e._xhrOnLoad=function(){var e=this.xhr,r="",i=void 0===e.status?200:e.status;if(""!==e.responseType&&"text"!==e.responseType&&void 0!==e.responseType||(r=e.responseText),0===i&&(r.length>0||e.responseType===t.XHR_RESPONSE_TYPE.BUFFER)?i=200:1223===i&&(i=204),2===(i/100|0)){if(this.xhrType===t.XHR_RESPONSE_TYPE.TEXT)this.data=r,this.type=t.TYPE.TEXT;else if(this.xhrType===t.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(r),this.type=t.TYPE.JSON}catch(t){return void this.abort("Error trying to parse loaded json: "+t)}else if(this.xhrType===t.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var n=new DOMParser;this.data=n.parseFromString(r,"text/xml")}else{var s=document.createElement("div");s.innerHTML=r,this.data=s}this.type=t.TYPE.XML}catch(t){return void this.abort("Error trying to parse loaded xml: "+t)}else this.data=e.response||r;this.complete()}else this.abort("["+e.status+"] "+e.statusText+": "+e.responseURL)},e._determineCrossOrigin=function(t,e){if(0===t.indexOf("data:"))return"";if(window.origin!==window.location.origin)return"anonymous";e=e||window.location,E||(E=document.createElement("a")),E.href=t;var r=!(t=i(E.href,{strictMode:!0})).port&&""===e.port||t.port===e.port,n=t.protocol?t.protocol+":":"";return t.host===e.hostname&&r&&n===e.protocol?"":"anonymous"},e._determineXhrType=function(){return t._xhrTypeMap[this.extension]||t.XHR_RESPONSE_TYPE.TEXT},e._determineLoadType=function(){return t._loadTypeMap[this.extension]||t.LOAD_TYPE.XHR},e._getExtension=function(){var t=this.url,e="";if(this.isDataUrl){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var i=t.indexOf("?"),n=t.indexOf("#"),s=Math.min(i>-1?i:t.length,n>-1?n:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},e._getMimeFromXhrType=function(e){switch(e){case t.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case t.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case t.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case t.XHR_RESPONSE_TYPE.JSON:return"application/json";case t.XHR_RESPONSE_TYPE.DEFAULT:case t.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},f(t,[{key:"isDataUrl",get:function(){return this._hasFlag(t.STATUS_FLAGS.DATA_URL)}},{key:"isComplete",get:function(){return this._hasFlag(t.STATUS_FLAGS.COMPLETE)}},{key:"isLoading",get:function(){return this._hasFlag(t.STATUS_FLAGS.LOADING)}}]),t}();function m(t,e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t[e]=r)}function O(t){return t.toString().replace("object ","")}T.STATUS_FLAGS={NONE:0,DATA_URL:1,COMPLETE:2,LOADING:4},T.TYPE={UNKNOWN:0,JSON:1,XML:2,IMAGE:3,AUDIO:4,VIDEO:5,TEXT:6},T.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4},T.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"},T._loadTypeMap={gif:T.LOAD_TYPE.IMAGE,png:T.LOAD_TYPE.IMAGE,bmp:T.LOAD_TYPE.IMAGE,jpg:T.LOAD_TYPE.IMAGE,jpeg:T.LOAD_TYPE.IMAGE,tif:T.LOAD_TYPE.IMAGE,tiff:T.LOAD_TYPE.IMAGE,webp:T.LOAD_TYPE.IMAGE,tga:T.LOAD_TYPE.IMAGE,svg:T.LOAD_TYPE.IMAGE,"svg+xml":T.LOAD_TYPE.IMAGE,mp3:T.LOAD_TYPE.AUDIO,ogg:T.LOAD_TYPE.AUDIO,wav:T.LOAD_TYPE.AUDIO,mp4:T.LOAD_TYPE.VIDEO,webm:T.LOAD_TYPE.VIDEO},T._xhrTypeMap={xhtml:T.XHR_RESPONSE_TYPE.DOCUMENT,html:T.XHR_RESPONSE_TYPE.DOCUMENT,htm:T.XHR_RESPONSE_TYPE.DOCUMENT,xml:T.XHR_RESPONSE_TYPE.DOCUMENT,tmx:T.XHR_RESPONSE_TYPE.DOCUMENT,svg:T.XHR_RESPONSE_TYPE.DOCUMENT,tsx:T.XHR_RESPONSE_TYPE.DOCUMENT,gif:T.XHR_RESPONSE_TYPE.BLOB,png:T.XHR_RESPONSE_TYPE.BLOB,bmp:T.XHR_RESPONSE_TYPE.BLOB,jpg:T.XHR_RESPONSE_TYPE.BLOB,jpeg:T.XHR_RESPONSE_TYPE.BLOB,tif:T.XHR_RESPONSE_TYPE.BLOB,tiff:T.XHR_RESPONSE_TYPE.BLOB,webp:T.XHR_RESPONSE_TYPE.BLOB,tga:T.XHR_RESPONSE_TYPE.BLOB,json:T.XHR_RESPONSE_TYPE.JSON,text:T.XHR_RESPONSE_TYPE.TEXT,txt:T.XHR_RESPONSE_TYPE.TEXT,ttf:T.XHR_RESPONSE_TYPE.BUFFER,otf:T.XHR_RESPONSE_TYPE.BUFFER},T.EMPTY_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var y=window.URL||window.webkitURL;var P={caching:function(t,e){var r=this;c[t.url]?(t.data=c[t.url],t.complete()):t.onComplete.once(function(){return c[r.url]=r.data}),e()},parsing:function(t,e){if(t.data){if(t.xhr&&t.xhrType===T.XHR_RESPONSE_TYPE.BLOB)if(window.Blob&&"string"!=typeof t.data){if(0===t.data.type.indexOf("image")){var r=y.createObjectURL(t.data);return t.blob=t.data,t.data=new Image,t.data.src=r,t.type=T.TYPE.IMAGE,void(t.data.onload=function(){y.revokeObjectURL(r),t.data.onload=null,e()})}}else{var i=t.xhr.getResponseHeader("content-type");if(i&&0===i.indexOf("image"))return t.data=new Image,t.data.src="data:"+i+";base64,"+function(t){for(var e="",r=0;r<t.length;){for(var i=[0,0,0],n=[0,0,0,0],s=0;s<i.length;++s)r<t.length?i[s]=255&t.charCodeAt(r++):i[s]=0;switch(n[0]=i[0]>>2,n[1]=(3&i[0])<<4|i[1]>>4,n[2]=(15&i[1])<<2|i[2]>>6,n[3]=63&i[2],r-(t.length-1)){case 2:n[3]=64,n[2]=64;break;case 1:n[3]=64}for(var o=0;o<n.length;++o)e+=v.charAt(n[o])}return e}(t.xhr.responseText),t.type=T.TYPE.IMAGE,void(t.data.onload=function(){t.data.onload=null,e()})}e()}else e()}},b=/(#[\w-]+)?$/,S=function(){function t(e,r){var i=this;void 0===e&&(e=""),void 0===r&&(r=10),this.baseUrl=e,this.progress=0,this.loading=!1,this.defaultQueryString="",this._beforeMiddleware=[],this._afterMiddleware=[],this._resourcesParsing=[],this._boundLoadResource=function(t,e){return i._loadResource(t,e)},this._queue=l(this._boundLoadResource,r),this._queue.pause(),this.resources={},this.onProgress=new a,this.onError=new a,this.onLoad=new a,this.onStart=new a,this.onComplete=new a;for(var n=0;n<t._defaultBeforeMiddleware.length;++n)this.pre(t._defaultBeforeMiddleware[n]);for(var s=0;s<t._defaultAfterMiddleware.length;++s)this.use(t._defaultAfterMiddleware[s])}var e=t.prototype;return e.add=function(t,e,r,i){if(Array.isArray(t)){for(var n=0;n<t.length;++n)this.add(t[n]);return this}if("object"==typeof t&&(i=e||t.callback||t.onComplete,r=t,e=t.url,t=t.name||t.key||t.url),"string"!=typeof e&&(i=r,r=e,e=t),"string"!=typeof e)throw new Error("No url passed to add resource to loader.");if("function"==typeof r&&(i=r,r=null),this.loading&&(!r||!r.parentResource))throw new Error("Cannot add resources while the loader is running.");if(this.resources[t])throw new Error('Resource named "'+t+'" already exists.');if(e=this._prepareUrl(e),this.resources[t]=new T(t,e,r),"function"==typeof i&&this.resources[t].onAfterMiddleware.once(i),this.loading){for(var s=r.parentResource,o=[],a=0;a<s.children.length;++a)s.children[a].isComplete||o.push(s.children[a]);var h=s.progressChunk*(o.length+1)/(o.length+2);s.children.push(this.resources[t]),s.progressChunk=h;for(var u=0;u<o.length;++u)o[u].progressChunk=h;this.resources[t].progressChunk=h}return this._queue.push(this.resources[t]),this},e.pre=function(t){return this._beforeMiddleware.push(t),this},e.use=function(t){return this._afterMiddleware.push(t),this},e.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.kill(),this._queue.pause(),this.resources){var e=this.resources[t];e._onLoadBinding&&e._onLoadBinding.detach(),e.isLoading&&e.abort()}return this.resources={},this},e.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue._tasks.length,r=0;r<this._queue._tasks.length;++r)this._queue._tasks[r].data.progressChunk=e;this._onStart(),this._queue.resume()}return this},e._prepareUrl=function(t){var e,r=i(t,{strictMode:!0});if(e=r.protocol||!r.path||0===t.indexOf("//")?t:this.baseUrl.length&&this.baseUrl.lastIndexOf("/")!==this.baseUrl.length-1&&"/"!==t.charAt(0)?this.baseUrl+"/"+t:this.baseUrl+t,this.defaultQueryString){var n=b.exec(e)[0];-1!==(e=e.substr(0,e.length-n.length)).indexOf("?")?e+="&"+this.defaultQueryString:e+="?"+this.defaultQueryString,e+=n}return e},e._loadResource=function(t,e){var r=this;t._dequeue=e,u(this._beforeMiddleware,function(e,i){e.call(r,t,function(){i(t.isComplete?{}:null)})},function(){t.isComplete?r._onLoad(t):(t._onLoadBinding=t.onComplete.once(r._onLoad,r),t.load())},!0)},e._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},e._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},e._onLoad=function(t){var e=this;t._onLoadBinding=null,this._resourcesParsing.push(t),t._dequeue(),u(this._afterMiddleware,function(r,i){r.call(e,t,i)},function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()},!0)},f(t,[{key:"concurrency",get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t}}]),t}();S._defaultBeforeMiddleware=[],S._defaultAfterMiddleware=[],S.pre=function(t){return S._defaultBeforeMiddleware.push(t),S},S.use=function(t){return S._defaultAfterMiddleware.push(t),S};var A=function(){};A.use=function(t,e){t.data&&t.type===T.TYPE.IMAGE&&(t.texture=r.Texture.fromLoader(t.data,t.url,t.name)),e()};var L=function(t){function r(i,n){var s=this;t.call(this,i,n),e.EventEmitter.call(this);for(var o=0;o<r._plugins.length;++o){var a=r._plugins[o],h=a.pre,u=a.use;h&&this.pre(h),u&&this.use(u)}this.onStart.add(function(t){return s.emit("start",t)}),this.onProgress.add(function(t,e){return s.emit("progress",t,e)}),this.onError.add(function(t,e,r){return s.emit("error",t,e,r)}),this.onLoad.add(function(t,e){return s.emit("load",t,e)}),this.onComplete.add(function(t,e){return s.emit("complete",t,e)}),this._protected=!1}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={shared:{configurable:!0}};return r.prototype.destroy=function(){this._protected||(this.removeAllListeners(),this.reset())},i.shared.get=function(){var t=r._shared;return t||((t=new r)._protected=!0,r._shared=t),t},Object.defineProperties(r,i),r}(S);Object.assign(L.prototype,e.EventEmitter.prototype),L._plugins=[],L.registerPlugin=function(t){return L._plugins.push(t),t.add&&t.add(),L},L.registerPlugin({use:P.parsing}),L.registerPlugin(A);var w=function(){};w.init=function(t){t=Object.assign({sharedLoader:!1},t),this.loader=t.sharedLoader?L.shared:new L},w.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)};var x=T;return t.AppLoaderPlugin=w,t.Loader=L,t.LoaderResource=x,t.TextureLoader=A,t}({},PIXI.utils,PIXI);Object.assign(this.PIXI,_pixi_loaders); | ||
this.PIXI=this.PIXI||{};var _pixi_loaders=function(t,e){"use strict";var r=function(t,e){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},n=r.parser[e.strictMode?"strict":"loose"].exec(t),i={},s=14;s--;)i[r.key[s]]=n[s]||"";return i[r.q.name]={},i[r.key[12]].replace(r.q.parser,function(t,e,n){e&&(i[r.q.name][e]=n)}),i};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n,i,s=(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(e,r,i){void 0===r&&(r=!1),n(this,t),this._fn=e,this._once=r,this._thisArg=i,this._next=this._prev=this._owner=null}return r(t,[{key:"detach",value:function(){return null!==this._owner&&(this._owner.detach(this),!0)}}]),t}();function s(t,e){return t._head?(t._tail._next=e,e._prev=t._tail,t._tail=e):(t._head=e,t._tail=e),e._owner=t,e}var o=function(){function t(){n(this,t),this._head=this._tail=void 0}return r(t,[{key:"handlers",value:function(){var t=!(arguments.length<=0||void 0===arguments[0])&&arguments[0],e=this._head;if(t)return!!e;for(var r=[];e;)r.push(e),e=e._next;return r}},{key:"has",value:function(t){if(!(t instanceof i))throw new Error("MiniSignal#has(): First arg must be a MiniSignalBinding object.");return t._owner===this}},{key:"dispatch",value:function(){var t=arguments,e=this._head;if(!e)return!1;for(;e;)e._once&&this.detach(e),e._fn.apply(e._thisArg,t),e=e._next;return!0}},{key:"add",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if("function"!=typeof t)throw new Error("MiniSignal#add(): First arg must be a Function.");return s(this,new i(t,!1,e))}},{key:"once",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if("function"!=typeof t)throw new Error("MiniSignal#once(): First arg must be a Function.");return s(this,new i(t,!0,e))}},{key:"detach",value:function(t){if(!(t instanceof i))throw new Error("MiniSignal#detach(): First arg must be a MiniSignalBinding object.");return t._owner!==this?this:(t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t===this._head?(this._head=t._next,null===t._next&&(this._tail=null)):t===this._tail&&(this._tail=t._prev,this._tail._next=null),t._owner=null,this)}},{key:"detachAll",value:function(){var t=this._head;if(!t)return this;for(this._head=this._tail=null;t;)t._owner=null,t=t._next;return this}}]),t}();o.MiniSignalBinding=i,e.default=o,t.exports=e.default}(n={exports:{}},n.exports),n.exports),o=(i=s)&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i;function a(){}function h(t,e,r,n){var i=0,s=t.length;!function o(a){a||i===s?r&&r(a):n?setTimeout(function(){e(t[i++],o)},1):e(t[i++],o)}()}function u(t){return function(){if(null===t)throw new Error("Callback was already called.");var e=t;t=null,e.apply(this,arguments)}}function d(t,e){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var r=0,n={_tasks:[],concurrency:e,saturated:a,unsaturated:a,buffer:e/4,empty:a,drain:a,error:a,started:!1,paused:!1,push:function(t,e){i(t,!1,e)},kill:function(){r=0,n.drain=a,n.started=!1,n._tasks=[]},unshift:function(t,e){i(t,!0,e)},process:function(){for(;!n.paused&&r<n.concurrency&&n._tasks.length;){var e=n._tasks.shift();0===n._tasks.length&&n.empty(),(r+=1)===n.concurrency&&n.saturated(),t(e.data,u(s(e)))}},length:function(){return n._tasks.length},running:function(){return r},idle:function(){return n._tasks.length+r===0},pause:function(){!0!==n.paused&&(n.paused=!0)},resume:function(){if(!1!==n.paused){n.paused=!1;for(var t=1;t<=n.concurrency;t++)n.process()}}};function i(t,e,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(n.started=!0,null==t&&n.idle())setTimeout(function(){return n.drain()},1);else{var i={data:t,callback:"function"==typeof r?r:a};e?n._tasks.unshift(i):n._tasks.push(i),setTimeout(function(){return n.process()},1)}}function s(t){return function(){r-=1,t.callback.apply(t,arguments),null!=arguments[0]&&n.error(arguments[0],t.data),r<=n.concurrency-n.buffer&&n.unsaturated(),n.idle()&&n.drain(),n.process()}}return n}var l={};function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _(t,e,r){return e&&c(t.prototype,e),r&&c(t,r),t}var f=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest),p=null;function E(){}var g=function(){function t(e,r,n){if("string"!=typeof e||"string"!=typeof r)throw new Error("Both name and url are required for constructing a resource.");n=n||{},this._flags=0,this._setFlag(t.STATUS_FLAGS.DATA_URL,0===r.indexOf("data:")),this.name=e,this.url=r,this.extension=this._getExtension(),this.data=null,this.crossOrigin=!0===n.crossOrigin?"anonymous":n.crossOrigin,this.timeout=n.timeout||0,this.loadType=n.loadType||this._determineLoadType(),this.xhrType=n.xhrType,this.metadata=n.metadata||{},this.error=null,this.xhr=null,this.children=[],this.type=t.TYPE.UNKNOWN,this.progressChunk=0,this._dequeue=E,this._onLoadBinding=null,this._elementTimer=0,this._boundComplete=this.complete.bind(this),this._boundOnError=this._onError.bind(this),this._boundOnProgress=this._onProgress.bind(this),this._boundOnTimeout=this._onTimeout.bind(this),this._boundXhrOnError=this._xhrOnError.bind(this),this._boundXhrOnTimeout=this._xhrOnTimeout.bind(this),this._boundXhrOnAbort=this._xhrOnAbort.bind(this),this._boundXhrOnLoad=this._xhrOnLoad.bind(this),this.onStart=new o,this.onProgress=new o,this.onComplete=new o,this.onAfterMiddleware=new o}t.setExtensionLoadType=function(e,r){T(t._loadTypeMap,e,r)},t.setExtensionXhrType=function(e,r){T(t._xhrTypeMap,e,r)};var e=t.prototype;return e.complete=function(){this._clearEvents(),this._finish()},e.abort=function(e){if(!this.error){if(this.error=new Error(e),this._clearEvents(),this.xhr)this.xhr.abort();else if(this.xdr)this.xdr.abort();else if(this.data)if(this.data.src)this.data.src=t.EMPTY_GIF;else for(;this.data.firstChild;)this.data.removeChild(this.data.firstChild);this._finish()}},e.load=function(e){var r=this;if(!this.isLoading)if(this.isComplete)e&&setTimeout(function(){return e(r)},1);else switch(e&&this.onComplete.once(e),this._setFlag(t.STATUS_FLAGS.LOADING,!0),this.onStart.dispatch(this),!1!==this.crossOrigin&&"string"==typeof this.crossOrigin||(this.crossOrigin=this._determineCrossOrigin(this.url)),this.loadType){case t.LOAD_TYPE.IMAGE:this.type=t.TYPE.IMAGE,this._loadElement("image");break;case t.LOAD_TYPE.AUDIO:this.type=t.TYPE.AUDIO,this._loadSourceElement("audio");break;case t.LOAD_TYPE.VIDEO:this.type=t.TYPE.VIDEO,this._loadSourceElement("video");break;case t.LOAD_TYPE.XHR:default:f&&this.crossOrigin?this._loadXdr():this._loadXhr()}},e._hasFlag=function(t){return 0!=(this._flags&t)},e._setFlag=function(t,e){this._flags=e?this._flags|t:this._flags&~t},e._clearEvents=function(){clearTimeout(this._elementTimer),this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("timeout",this._boundXhrOnTimeout,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null))},e._finish=function(){if(this.isComplete)throw new Error("Complete called again for an already completed resource.");this._setFlag(t.STATUS_FLAGS.COMPLETE,!0),this._setFlag(t.STATUS_FLAGS.LOADING,!1),this.onComplete.dispatch(this)},e._loadElement=function(t){this.metadata.loadElement?this.data=this.metadata.loadElement:"image"===t&&void 0!==window.Image?this.data=new Image:this.data=document.createElement(t),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))},e._loadSourceElement=function(t){if(this.metadata.loadElement?this.data=this.metadata.loadElement:"audio"===t&&void 0!==window.Audio?this.data=new Audio:this.data=document.createElement(t),null!==this.data){if(this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var e=this.metadata.mimeType,r=0;r<this.url.length;++r)this.data.appendChild(this._createSource(t,this.url[r],Array.isArray(e)?e[r]:e));else{var n=this.metadata.mimeType;this.data.appendChild(this._createSource(t,this.url,Array.isArray(n)?n[0]:n))}this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.data.addEventListener("canplaythrough",this._boundComplete,!1),this.data.load(),this.timeout&&(this._elementTimer=setTimeout(this._boundOnTimeout,this.timeout))}else this.abort("Unsupported element: "+t)},e._loadXhr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var e=this.xhr=new XMLHttpRequest;e.open("GET",this.url,!0),e.timeout=this.timeout,this.xhrType===t.XHR_RESPONSE_TYPE.JSON||this.xhrType===t.XHR_RESPONSE_TYPE.DOCUMENT?e.responseType=t.XHR_RESPONSE_TYPE.TEXT:e.responseType=this.xhrType,e.addEventListener("error",this._boundXhrOnError,!1),e.addEventListener("timeout",this._boundXhrOnTimeout,!1),e.addEventListener("abort",this._boundXhrOnAbort,!1),e.addEventListener("progress",this._boundOnProgress,!1),e.addEventListener("load",this._boundXhrOnLoad,!1),e.send()},e._loadXdr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var t=this.xhr=new XDomainRequest;t.timeout=this.timeout||5e3,t.onerror=this._boundXhrOnError,t.ontimeout=this._boundXhrOnTimeout,t.onprogress=this._boundOnProgress,t.onload=this._boundXhrOnLoad,t.open("GET",this.url,!0),setTimeout(function(){return t.send()},1)},e._createSource=function(t,e,r){r||(r=t+"/"+this._getExtension(e));var n=document.createElement("source");return n.src=e,n.type=r,n},e._onError=function(t){this.abort("Failed to load element using: "+t.target.nodeName)},e._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(this,t.loaded/t.total)},e._onTimeout=function(){this.abort("Load timed out.")},e._xhrOnError=function(){var t=this.xhr;this.abort(O(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e._xhrOnTimeout=function(){var t=this.xhr;this.abort(O(t)+" Request timed out.")},e._xhrOnAbort=function(){var t=this.xhr;this.abort(O(t)+" Request was aborted by the user.")},e._xhrOnLoad=function(){var e=this.xhr,r="",n=void 0===e.status?200:e.status;if(""!==e.responseType&&"text"!==e.responseType&&void 0!==e.responseType||(r=e.responseText),0===n&&(r.length>0||e.responseType===t.XHR_RESPONSE_TYPE.BUFFER)?n=200:1223===n&&(n=204),2===(n/100|0)){if(this.xhrType===t.XHR_RESPONSE_TYPE.TEXT)this.data=r,this.type=t.TYPE.TEXT;else if(this.xhrType===t.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(r),this.type=t.TYPE.JSON}catch(t){return void this.abort("Error trying to parse loaded json: "+t)}else if(this.xhrType===t.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var i=new DOMParser;this.data=i.parseFromString(r,"text/xml")}else{var s=document.createElement("div");s.innerHTML=r,this.data=s}this.type=t.TYPE.XML}catch(t){return void this.abort("Error trying to parse loaded xml: "+t)}else this.data=e.response||r;this.complete()}else this.abort("["+e.status+"] "+e.statusText+": "+e.responseURL)},e._determineCrossOrigin=function(t,e){if(0===t.indexOf("data:"))return"";if(window.origin!==window.location.origin)return"anonymous";e=e||window.location,p||(p=document.createElement("a")),p.href=t;var n=!(t=r(p.href,{strictMode:!0})).port&&""===e.port||t.port===e.port,i=t.protocol?t.protocol+":":"";return t.host===e.hostname&&n&&i===e.protocol?"":"anonymous"},e._determineXhrType=function(){return t._xhrTypeMap[this.extension]||t.XHR_RESPONSE_TYPE.TEXT},e._determineLoadType=function(){return t._loadTypeMap[this.extension]||t.LOAD_TYPE.XHR},e._getExtension=function(){var t=this.url,e="";if(this.isDataUrl){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),i=t.indexOf("#"),s=Math.min(n>-1?n:t.length,i>-1?i:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},e._getMimeFromXhrType=function(e){switch(e){case t.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case t.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case t.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case t.XHR_RESPONSE_TYPE.JSON:return"application/json";case t.XHR_RESPONSE_TYPE.DEFAULT:case t.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},_(t,[{key:"isDataUrl",get:function(){return this._hasFlag(t.STATUS_FLAGS.DATA_URL)}},{key:"isComplete",get:function(){return this._hasFlag(t.STATUS_FLAGS.COMPLETE)}},{key:"isLoading",get:function(){return this._hasFlag(t.STATUS_FLAGS.LOADING)}}]),t}();function T(t,e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t[e]=r)}function O(t){return t.toString().replace("object ","")}g.STATUS_FLAGS={NONE:0,DATA_URL:1,COMPLETE:2,LOADING:4},g.TYPE={UNKNOWN:0,JSON:1,XML:2,IMAGE:3,AUDIO:4,VIDEO:5,TEXT:6},g.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4},g.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"},g._loadTypeMap={gif:g.LOAD_TYPE.IMAGE,png:g.LOAD_TYPE.IMAGE,bmp:g.LOAD_TYPE.IMAGE,jpg:g.LOAD_TYPE.IMAGE,jpeg:g.LOAD_TYPE.IMAGE,tif:g.LOAD_TYPE.IMAGE,tiff:g.LOAD_TYPE.IMAGE,webp:g.LOAD_TYPE.IMAGE,tga:g.LOAD_TYPE.IMAGE,svg:g.LOAD_TYPE.IMAGE,"svg+xml":g.LOAD_TYPE.IMAGE,mp3:g.LOAD_TYPE.AUDIO,ogg:g.LOAD_TYPE.AUDIO,wav:g.LOAD_TYPE.AUDIO,mp4:g.LOAD_TYPE.VIDEO,webm:g.LOAD_TYPE.VIDEO},g._xhrTypeMap={xhtml:g.XHR_RESPONSE_TYPE.DOCUMENT,html:g.XHR_RESPONSE_TYPE.DOCUMENT,htm:g.XHR_RESPONSE_TYPE.DOCUMENT,xml:g.XHR_RESPONSE_TYPE.DOCUMENT,tmx:g.XHR_RESPONSE_TYPE.DOCUMENT,svg:g.XHR_RESPONSE_TYPE.DOCUMENT,tsx:g.XHR_RESPONSE_TYPE.DOCUMENT,gif:g.XHR_RESPONSE_TYPE.BLOB,png:g.XHR_RESPONSE_TYPE.BLOB,bmp:g.XHR_RESPONSE_TYPE.BLOB,jpg:g.XHR_RESPONSE_TYPE.BLOB,jpeg:g.XHR_RESPONSE_TYPE.BLOB,tif:g.XHR_RESPONSE_TYPE.BLOB,tiff:g.XHR_RESPONSE_TYPE.BLOB,webp:g.XHR_RESPONSE_TYPE.BLOB,tga:g.XHR_RESPONSE_TYPE.BLOB,json:g.XHR_RESPONSE_TYPE.JSON,text:g.XHR_RESPONSE_TYPE.TEXT,txt:g.XHR_RESPONSE_TYPE.TEXT,ttf:g.XHR_RESPONSE_TYPE.BUFFER,otf:g.XHR_RESPONSE_TYPE.BUFFER},g.EMPTY_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var y=window.URL||window.webkitURL;var v={caching:function(t,e){var r=this;l[t.url]?(t.data=l[t.url],t.complete()):t.onComplete.once(function(){return l[r.url]=r.data}),e()},parsing:function(t,e){if(t.data){if(t.xhr&&t.xhrType===g.XHR_RESPONSE_TYPE.BLOB)if(window.Blob&&"string"!=typeof t.data){if(0===t.data.type.indexOf("image")){var r=y.createObjectURL(t.data);return t.blob=t.data,t.data=new Image,t.data.src=r,t.type=g.TYPE.IMAGE,void(t.data.onload=function(){y.revokeObjectURL(r),t.data.onload=null,e()})}}else{var n=t.xhr.getResponseHeader("content-type");if(n&&0===n.indexOf("image"))return t.data=new Image,t.data.src="data:"+n+";base64,"+function(t){for(var e="",r=0;r<t.length;){for(var n=[0,0,0],i=[0,0,0,0],s=0;s<n.length;++s)r<t.length?n[s]=255&t.charCodeAt(r++):n[s]=0;switch(i[0]=n[0]>>2,i[1]=(3&n[0])<<4|n[1]>>4,i[2]=(15&n[1])<<2|n[2]>>6,i[3]=63&n[2],r-(t.length-1)){case 2:i[3]=64,i[2]=64;break;case 1:i[3]=64}for(var o=0;o<i.length;++o)e+=m.charAt(i[o])}return e}(t.xhr.responseText),t.type=g.TYPE.IMAGE,void(t.data.onload=function(){t.data.onload=null,e()})}e()}else e()}},P=/(#[\w-]+)?$/,b=function(){function t(e,r){var n=this;void 0===e&&(e=""),void 0===r&&(r=10),this.baseUrl=e,this.progress=0,this.loading=!1,this.defaultQueryString="",this._beforeMiddleware=[],this._afterMiddleware=[],this._resourcesParsing=[],this._boundLoadResource=function(t,e){return n._loadResource(t,e)},this._queue=d(this._boundLoadResource,r),this._queue.pause(),this.resources={},this.onProgress=new o,this.onError=new o,this.onLoad=new o,this.onStart=new o,this.onComplete=new o;for(var i=0;i<t._defaultBeforeMiddleware.length;++i)this.pre(t._defaultBeforeMiddleware[i]);for(var s=0;s<t._defaultAfterMiddleware.length;++s)this.use(t._defaultAfterMiddleware[s])}var e=t.prototype;return e.add=function(t,e,r,n){if(Array.isArray(t)){for(var i=0;i<t.length;++i)this.add(t[i]);return this}if("object"==typeof t&&(n=e||t.callback||t.onComplete,r=t,e=t.url,t=t.name||t.key||t.url),"string"!=typeof e&&(n=r,r=e,e=t),"string"!=typeof e)throw new Error("No url passed to add resource to loader.");if("function"==typeof r&&(n=r,r=null),this.loading&&(!r||!r.parentResource))throw new Error("Cannot add resources while the loader is running.");if(this.resources[t])throw new Error('Resource named "'+t+'" already exists.');if(e=this._prepareUrl(e),this.resources[t]=new g(t,e,r),"function"==typeof n&&this.resources[t].onAfterMiddleware.once(n),this.loading){for(var s=r.parentResource,o=[],a=0;a<s.children.length;++a)s.children[a].isComplete||o.push(s.children[a]);var h=s.progressChunk*(o.length+1)/(o.length+2);s.children.push(this.resources[t]),s.progressChunk=h;for(var u=0;u<o.length;++u)o[u].progressChunk=h;this.resources[t].progressChunk=h}return this._queue.push(this.resources[t]),this},e.pre=function(t){return this._beforeMiddleware.push(t),this},e.use=function(t){return this._afterMiddleware.push(t),this},e.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.kill(),this._queue.pause(),this.resources){var e=this.resources[t];e._onLoadBinding&&e._onLoadBinding.detach(),e.isLoading&&e.abort()}return this.resources={},this},e.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue._tasks.length,r=0;r<this._queue._tasks.length;++r)this._queue._tasks[r].data.progressChunk=e;this._onStart(),this._queue.resume()}return this},e._prepareUrl=function(t){var e,n=r(t,{strictMode:!0});if(e=n.protocol||!n.path||0===t.indexOf("//")?t:this.baseUrl.length&&this.baseUrl.lastIndexOf("/")!==this.baseUrl.length-1&&"/"!==t.charAt(0)?this.baseUrl+"/"+t:this.baseUrl+t,this.defaultQueryString){var i=P.exec(e)[0];-1!==(e=e.substr(0,e.length-i.length)).indexOf("?")?e+="&"+this.defaultQueryString:e+="?"+this.defaultQueryString,e+=i}return e},e._loadResource=function(t,e){var r=this;t._dequeue=e,h(this._beforeMiddleware,function(e,n){e.call(r,t,function(){n(t.isComplete?{}:null)})},function(){t.isComplete?r._onLoad(t):(t._onLoadBinding=t.onComplete.once(r._onLoad,r),t.load())},!0)},e._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},e._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},e._onLoad=function(t){var e=this;t._onLoadBinding=null,this._resourcesParsing.push(t),t._dequeue(),h(this._afterMiddleware,function(r,n){r.call(e,t,n)},function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()},!0)},_(t,[{key:"concurrency",get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t}}]),t}();b._defaultBeforeMiddleware=[],b._defaultAfterMiddleware=[],b.pre=function(t){return b._defaultBeforeMiddleware.push(t),b},b.use=function(t){return b._defaultAfterMiddleware.push(t),b};var S=g,A=function(t,e){return(A=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};var L=function(){function t(){}return t.use=function(t,r){t.data&&t.type===g.TYPE.IMAGE&&(t.texture=e.Texture.fromLoader(t.data,t.url,t.name)),r()},t}(),w=function(t){function e(r,n){for(var i=t.call(this,r,n)||this,s=0;s<e._plugins.length;++s){var o=e._plugins[s],a=o.pre,h=o.use;a&&i.pre(a),h&&i.use(h)}return i._protected=!1,i}return function(t,e){function r(){this.constructor=t}A(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.destroy=function(){this._protected||this.reset()},Object.defineProperty(e,"shared",{get:function(){var t=e._shared;return t||((t=new e)._protected=!0,e._shared=t),t},enumerable:!1,configurable:!0}),e.registerPlugin=function(t){return e._plugins.push(t),t.add&&t.add(),e},e._plugins=[],e}(b);w.registerPlugin({use:v.parsing}),w.registerPlugin(L);var x=function(){function t(){}return t.init=function(t){t=Object.assign({sharedLoader:!1},t),this.loader=t.sharedLoader?w.shared:new w},t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t}();return t.AppLoaderPlugin=x,t.Loader=w,t.LoaderResource=S,t.TextureLoader=L,t}({},PIXI);Object.assign(this.PIXI,_pixi_loaders); | ||
//# sourceMappingURL=loaders.min.js.map |
/*! | ||
* @pixi/loaders - v5.2.4 | ||
* Compiled Sun, 03 May 2020 22:38:52 UTC | ||
* @pixi/loaders - v5.3.0 | ||
* Compiled Thu, 18 Jun 2020 23:27:40 UTC | ||
* | ||
@@ -9,6 +9,43 @@ * @pixi/loaders is licensed under the MIT License. | ||
import { Resource, Loader as Loader$1, middleware } from 'resource-loader'; | ||
import { EventEmitter } from '@pixi/utils'; | ||
import { Texture } from '@pixi/core'; | ||
/** | ||
* Reference to **{@link https://github.com/englercj/resource-loader | ||
* resource-loader}**'s Resource class. | ||
* @see http://englercj.github.io/resource-loader/Resource.html | ||
* @class LoaderResource | ||
* @memberof PIXI | ||
*/ | ||
var LoaderResource = Resource; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
/** | ||
* Loader plugin for handling Texture resources. | ||
@@ -19,17 +56,20 @@ * @class | ||
*/ | ||
var TextureLoader = function TextureLoader () {}; | ||
TextureLoader.use = function use (resource, next) | ||
{ | ||
// create a new texture if the data is an Image object | ||
if (resource.data && resource.type === Resource.TYPE.IMAGE) | ||
{ | ||
resource.texture = Texture.fromLoader( | ||
resource.data, | ||
resource.url, | ||
resource.name | ||
); | ||
var TextureLoader = /** @class */ (function () { | ||
function TextureLoader() { | ||
} | ||
next(); | ||
}; | ||
/** | ||
* Called after a resource is loaded. | ||
* @see PIXI.Loader.loaderMiddleware | ||
* @param {PIXI.LoaderResource} resource | ||
* @param {function} next | ||
*/ | ||
TextureLoader.use = function (resource, next) { | ||
// create a new texture if the data is an Image object | ||
if (resource.data && resource.type === Resource.TYPE.IMAGE) { | ||
resource.texture = Texture.fromLoader(resource.data, resource.url, resource.name); | ||
} | ||
next(); | ||
}; | ||
return TextureLoader; | ||
}()); | ||
@@ -87,34 +127,16 @@ /** | ||
*/ | ||
var Loader = /*@__PURE__*/(function (ResourceLoader) { | ||
function Loader(baseUrl, concurrency) | ||
{ | ||
var this$1 = this; | ||
ResourceLoader.call(this, baseUrl, concurrency); | ||
EventEmitter.call(this); | ||
for (var i = 0; i < Loader._plugins.length; ++i) | ||
{ | ||
var Loader = /** @class */ (function (_super) { | ||
__extends(Loader, _super); | ||
function Loader(baseUrl, concurrency) { | ||
var _this = _super.call(this, baseUrl, concurrency) || this; | ||
for (var i = 0; i < Loader._plugins.length; ++i) { | ||
var plugin = Loader._plugins[i]; | ||
var pre = plugin.pre; | ||
var use = plugin.use; | ||
if (pre) | ||
{ | ||
this.pre(pre); | ||
var pre = plugin.pre, use = plugin.use; | ||
if (pre) { | ||
_this.pre(pre); | ||
} | ||
if (use) | ||
{ | ||
this.use(use); | ||
if (use) { | ||
_this.use(use); | ||
} | ||
} | ||
// Compat layer, translate the new v2 signals into old v1 events. | ||
this.onStart.add(function (l) { return this$1.emit('start', l); }); | ||
this.onProgress.add(function (l, r) { return this$1.emit('progress', l, r); }); | ||
this.onError.add(function (e, l, r) { return this$1.emit('error', e, l, r); }); | ||
this.onLoad.add(function (l, r) { return this$1.emit('load', l, r); }); | ||
this.onComplete.add(function (l, r) { return this$1.emit('complete', l, r); }); | ||
/** | ||
@@ -126,91 +148,68 @@ * If this loader cannot be destroyed. | ||
*/ | ||
this._protected = false; | ||
_this._protected = false; | ||
return _this; | ||
} | ||
if ( ResourceLoader ) Loader.__proto__ = ResourceLoader; | ||
Loader.prototype = Object.create( ResourceLoader && ResourceLoader.prototype ); | ||
Loader.prototype.constructor = Loader; | ||
var staticAccessors = { shared: { configurable: true } }; | ||
/** | ||
* Destroy the loader, removes references. | ||
* @private | ||
* @memberof PIXI.Loader# | ||
* @method destroy | ||
* @public | ||
*/ | ||
Loader.prototype.destroy = function destroy () | ||
{ | ||
if (!this._protected) | ||
{ | ||
this.removeAllListeners(); | ||
Loader.prototype.destroy = function () { | ||
if (!this._protected) { | ||
this.reset(); | ||
} | ||
}; | ||
Object.defineProperty(Loader, "shared", { | ||
/** | ||
* A premade instance of the loader that can be used to load resources. | ||
* @name shared | ||
* @type {PIXI.Loader} | ||
* @static | ||
* @memberof PIXI.Loader | ||
*/ | ||
get: function () { | ||
var shared = Loader._shared; | ||
if (!shared) { | ||
shared = new Loader(); | ||
shared._protected = true; | ||
Loader._shared = shared; | ||
} | ||
return shared; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* A premade instance of the loader that can be used to load resources. | ||
* @name shared | ||
* @type {PIXI.Loader} | ||
* Adds a Loader plugin for the global shared loader and all | ||
* new Loader instances created. | ||
* | ||
* @static | ||
* @method registerPlugin | ||
* @memberof PIXI.Loader | ||
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add | ||
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining | ||
*/ | ||
staticAccessors.shared.get = function () | ||
{ | ||
var shared = Loader._shared; | ||
if (!shared) | ||
{ | ||
shared = new Loader(); | ||
shared._protected = true; | ||
Loader._shared = shared; | ||
Loader.registerPlugin = function (plugin) { | ||
Loader._plugins.push(plugin); | ||
if (plugin.add) { | ||
plugin.add(); | ||
} | ||
return shared; | ||
return Loader; | ||
}; | ||
Object.defineProperties( Loader, staticAccessors ); | ||
/** | ||
* Collection of all installed `use` middleware for Loader. | ||
* | ||
* @static | ||
* @member {Array<PIXI.ILoaderPlugin>} _plugins | ||
* @memberof PIXI.Loader | ||
* @private | ||
*/ | ||
Loader._plugins = []; | ||
return Loader; | ||
}(Loader$1)); | ||
// Copy EE3 prototype (mixin) | ||
Object.assign(Loader.prototype, EventEmitter.prototype); | ||
/** | ||
* Collection of all installed `use` middleware for Loader. | ||
* | ||
* @static | ||
* @member {Array<PIXI.ILoaderPlugin>} _plugins | ||
* @memberof PIXI.Loader | ||
* @private | ||
*/ | ||
Loader._plugins = []; | ||
/** | ||
* Adds a Loader plugin for the global shared loader and all | ||
* new Loader instances created. | ||
* | ||
* @static | ||
* @method registerPlugin | ||
* @memberof PIXI.Loader | ||
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add | ||
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining | ||
*/ | ||
Loader.registerPlugin = function registerPlugin(plugin) | ||
{ | ||
Loader._plugins.push(plugin); | ||
if (plugin.add) | ||
{ | ||
plugin.add(); | ||
} | ||
return Loader; | ||
}; | ||
// parse any blob into more usable objects (e.g. Image) | ||
Loader.registerPlugin({ use: middleware.parsing }); | ||
// parse any Image objects into textures | ||
Loader.registerPlugin(TextureLoader); | ||
/** | ||
@@ -220,3 +219,3 @@ * Plugin to be installed for handling specific Loader resources. | ||
* @memberof PIXI | ||
* @typedef ILoaderPlugin | ||
* @typedef {object} ILoaderPlugin | ||
* @property {function} [add] - Function to call immediate after registering plugin. | ||
@@ -228,5 +227,27 @@ * @property {PIXI.Loader.loaderMiddleware} [pre] - Middleware function to run before load, the | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {object} ICallbackID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {function} ISignalCallback | ||
* @param {function} callback - Callback function | ||
* @param {object} [context] - Context | ||
* @returns {ICallbackID} - CallbackID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {function} ISignalDetach | ||
* @param {ICallbackID} id - CallbackID returned by `add`/`once` methods | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef ILoaderSignal | ||
* @property {ISignalCallback} add - Register callback | ||
* @property {ISignalCallback} once - Register oneshot callback | ||
* @property {ISignalDetach} detach - Detach specific callback by ID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @callback loaderMiddleware | ||
@@ -236,26 +257,26 @@ * @param {PIXI.LoaderResource} resource | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onStart | ||
* @description Dispatched when the loader begins to loading process. | ||
* @member {PIXI.Loader.ILoaderSignal} onStart | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onProgress | ||
* @description Dispatched once per loaded or errored resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onProgress | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onError | ||
* @description Dispatched once per errored resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onError | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onLoad | ||
* @description Dispatched once per loaded resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onLoad | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onComplete | ||
* @description Dispatched when completely loaded all resources. | ||
* @member {PIXI.Loader.ILoaderSignal} onComplete | ||
*/ | ||
@@ -273,42 +294,36 @@ | ||
*/ | ||
var AppLoaderPlugin = function AppLoaderPlugin () {}; | ||
AppLoaderPlugin.init = function init (options) | ||
{ | ||
options = Object.assign({ | ||
sharedLoader: false, | ||
}, options); | ||
var AppLoaderPlugin = /** @class */ (function () { | ||
function AppLoaderPlugin() { | ||
} | ||
/** | ||
* Loader instance to help with asset loading. | ||
* @name PIXI.Application#loader | ||
* @type {PIXI.Loader} | ||
* @readonly | ||
* Called on application constructor | ||
* @param {object} options | ||
* @private | ||
*/ | ||
this.loader = options.sharedLoader ? Loader.shared : new Loader(); | ||
}; | ||
AppLoaderPlugin.init = function (options) { | ||
options = Object.assign({ | ||
sharedLoader: false, | ||
}, options); | ||
/** | ||
* Loader instance to help with asset loading. | ||
* @name PIXI.Application#loader | ||
* @type {PIXI.Loader} | ||
* @readonly | ||
*/ | ||
this.loader = options.sharedLoader ? Loader.shared : new Loader(); | ||
}; | ||
/** | ||
* Called when application destroyed | ||
* @private | ||
*/ | ||
AppLoaderPlugin.destroy = function () { | ||
if (this.loader) { | ||
this.loader.destroy(); | ||
this.loader = null; | ||
} | ||
}; | ||
return AppLoaderPlugin; | ||
}()); | ||
/** | ||
* Called when application destroyed | ||
* @private | ||
*/ | ||
AppLoaderPlugin.destroy = function destroy () | ||
{ | ||
if (this.loader) | ||
{ | ||
this.loader.destroy(); | ||
this.loader = null; | ||
} | ||
}; | ||
/** | ||
* Reference to **{@link https://github.com/englercj/resource-loader | ||
* resource-loader}**'s Resource class. | ||
* @see http://englercj.github.io/resource-loader/Resource.html | ||
* @class LoaderResource | ||
* @memberof PIXI | ||
*/ | ||
var LoaderResource = Resource; | ||
export { AppLoaderPlugin, Loader, LoaderResource, TextureLoader }; | ||
//# sourceMappingURL=loaders.es.js.map |
/*! | ||
* @pixi/loaders - v5.2.4 | ||
* Compiled Sun, 03 May 2020 22:38:52 UTC | ||
* @pixi/loaders - v5.3.0 | ||
* Compiled Thu, 18 Jun 2020 23:27:40 UTC | ||
* | ||
@@ -13,6 +13,43 @@ * @pixi/loaders is licensed under the MIT License. | ||
var resourceLoader = require('resource-loader'); | ||
var utils = require('@pixi/utils'); | ||
var core = require('@pixi/core'); | ||
/** | ||
* Reference to **{@link https://github.com/englercj/resource-loader | ||
* resource-loader}**'s Resource class. | ||
* @see http://englercj.github.io/resource-loader/Resource.html | ||
* @class LoaderResource | ||
* @memberof PIXI | ||
*/ | ||
var LoaderResource = resourceLoader.Resource; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
var extendStatics = function(d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } }; | ||
return extendStatics(d, b); | ||
}; | ||
function __extends(d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
} | ||
/** | ||
* Loader plugin for handling Texture resources. | ||
@@ -23,17 +60,20 @@ * @class | ||
*/ | ||
var TextureLoader = function TextureLoader () {}; | ||
TextureLoader.use = function use (resource, next) | ||
{ | ||
// create a new texture if the data is an Image object | ||
if (resource.data && resource.type === resourceLoader.Resource.TYPE.IMAGE) | ||
{ | ||
resource.texture = core.Texture.fromLoader( | ||
resource.data, | ||
resource.url, | ||
resource.name | ||
); | ||
var TextureLoader = /** @class */ (function () { | ||
function TextureLoader() { | ||
} | ||
next(); | ||
}; | ||
/** | ||
* Called after a resource is loaded. | ||
* @see PIXI.Loader.loaderMiddleware | ||
* @param {PIXI.LoaderResource} resource | ||
* @param {function} next | ||
*/ | ||
TextureLoader.use = function (resource, next) { | ||
// create a new texture if the data is an Image object | ||
if (resource.data && resource.type === resourceLoader.Resource.TYPE.IMAGE) { | ||
resource.texture = core.Texture.fromLoader(resource.data, resource.url, resource.name); | ||
} | ||
next(); | ||
}; | ||
return TextureLoader; | ||
}()); | ||
@@ -91,34 +131,16 @@ /** | ||
*/ | ||
var Loader = /*@__PURE__*/(function (ResourceLoader) { | ||
function Loader(baseUrl, concurrency) | ||
{ | ||
var this$1 = this; | ||
ResourceLoader.call(this, baseUrl, concurrency); | ||
utils.EventEmitter.call(this); | ||
for (var i = 0; i < Loader._plugins.length; ++i) | ||
{ | ||
var Loader = /** @class */ (function (_super) { | ||
__extends(Loader, _super); | ||
function Loader(baseUrl, concurrency) { | ||
var _this = _super.call(this, baseUrl, concurrency) || this; | ||
for (var i = 0; i < Loader._plugins.length; ++i) { | ||
var plugin = Loader._plugins[i]; | ||
var pre = plugin.pre; | ||
var use = plugin.use; | ||
if (pre) | ||
{ | ||
this.pre(pre); | ||
var pre = plugin.pre, use = plugin.use; | ||
if (pre) { | ||
_this.pre(pre); | ||
} | ||
if (use) | ||
{ | ||
this.use(use); | ||
if (use) { | ||
_this.use(use); | ||
} | ||
} | ||
// Compat layer, translate the new v2 signals into old v1 events. | ||
this.onStart.add(function (l) { return this$1.emit('start', l); }); | ||
this.onProgress.add(function (l, r) { return this$1.emit('progress', l, r); }); | ||
this.onError.add(function (e, l, r) { return this$1.emit('error', e, l, r); }); | ||
this.onLoad.add(function (l, r) { return this$1.emit('load', l, r); }); | ||
this.onComplete.add(function (l, r) { return this$1.emit('complete', l, r); }); | ||
/** | ||
@@ -130,91 +152,68 @@ * If this loader cannot be destroyed. | ||
*/ | ||
this._protected = false; | ||
_this._protected = false; | ||
return _this; | ||
} | ||
if ( ResourceLoader ) Loader.__proto__ = ResourceLoader; | ||
Loader.prototype = Object.create( ResourceLoader && ResourceLoader.prototype ); | ||
Loader.prototype.constructor = Loader; | ||
var staticAccessors = { shared: { configurable: true } }; | ||
/** | ||
* Destroy the loader, removes references. | ||
* @private | ||
* @memberof PIXI.Loader# | ||
* @method destroy | ||
* @public | ||
*/ | ||
Loader.prototype.destroy = function destroy () | ||
{ | ||
if (!this._protected) | ||
{ | ||
this.removeAllListeners(); | ||
Loader.prototype.destroy = function () { | ||
if (!this._protected) { | ||
this.reset(); | ||
} | ||
}; | ||
Object.defineProperty(Loader, "shared", { | ||
/** | ||
* A premade instance of the loader that can be used to load resources. | ||
* @name shared | ||
* @type {PIXI.Loader} | ||
* @static | ||
* @memberof PIXI.Loader | ||
*/ | ||
get: function () { | ||
var shared = Loader._shared; | ||
if (!shared) { | ||
shared = new Loader(); | ||
shared._protected = true; | ||
Loader._shared = shared; | ||
} | ||
return shared; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* A premade instance of the loader that can be used to load resources. | ||
* @name shared | ||
* @type {PIXI.Loader} | ||
* Adds a Loader plugin for the global shared loader and all | ||
* new Loader instances created. | ||
* | ||
* @static | ||
* @method registerPlugin | ||
* @memberof PIXI.Loader | ||
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add | ||
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining | ||
*/ | ||
staticAccessors.shared.get = function () | ||
{ | ||
var shared = Loader._shared; | ||
if (!shared) | ||
{ | ||
shared = new Loader(); | ||
shared._protected = true; | ||
Loader._shared = shared; | ||
Loader.registerPlugin = function (plugin) { | ||
Loader._plugins.push(plugin); | ||
if (plugin.add) { | ||
plugin.add(); | ||
} | ||
return shared; | ||
return Loader; | ||
}; | ||
Object.defineProperties( Loader, staticAccessors ); | ||
/** | ||
* Collection of all installed `use` middleware for Loader. | ||
* | ||
* @static | ||
* @member {Array<PIXI.ILoaderPlugin>} _plugins | ||
* @memberof PIXI.Loader | ||
* @private | ||
*/ | ||
Loader._plugins = []; | ||
return Loader; | ||
}(resourceLoader.Loader)); | ||
// Copy EE3 prototype (mixin) | ||
Object.assign(Loader.prototype, utils.EventEmitter.prototype); | ||
/** | ||
* Collection of all installed `use` middleware for Loader. | ||
* | ||
* @static | ||
* @member {Array<PIXI.ILoaderPlugin>} _plugins | ||
* @memberof PIXI.Loader | ||
* @private | ||
*/ | ||
Loader._plugins = []; | ||
/** | ||
* Adds a Loader plugin for the global shared loader and all | ||
* new Loader instances created. | ||
* | ||
* @static | ||
* @method registerPlugin | ||
* @memberof PIXI.Loader | ||
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add | ||
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining | ||
*/ | ||
Loader.registerPlugin = function registerPlugin(plugin) | ||
{ | ||
Loader._plugins.push(plugin); | ||
if (plugin.add) | ||
{ | ||
plugin.add(); | ||
} | ||
return Loader; | ||
}; | ||
// parse any blob into more usable objects (e.g. Image) | ||
Loader.registerPlugin({ use: resourceLoader.middleware.parsing }); | ||
// parse any Image objects into textures | ||
Loader.registerPlugin(TextureLoader); | ||
/** | ||
@@ -224,3 +223,3 @@ * Plugin to be installed for handling specific Loader resources. | ||
* @memberof PIXI | ||
* @typedef ILoaderPlugin | ||
* @typedef {object} ILoaderPlugin | ||
* @property {function} [add] - Function to call immediate after registering plugin. | ||
@@ -232,5 +231,27 @@ * @property {PIXI.Loader.loaderMiddleware} [pre] - Middleware function to run before load, the | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {object} ICallbackID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {function} ISignalCallback | ||
* @param {function} callback - Callback function | ||
* @param {object} [context] - Context | ||
* @returns {ICallbackID} - CallbackID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef {function} ISignalDetach | ||
* @param {ICallbackID} id - CallbackID returned by `add`/`once` methods | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @typedef ILoaderSignal | ||
* @property {ISignalCallback} add - Register callback | ||
* @property {ISignalCallback} once - Register oneshot callback | ||
* @property {ISignalDetach} detach - Detach specific callback by ID | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader | ||
* @callback loaderMiddleware | ||
@@ -240,26 +261,26 @@ * @param {PIXI.LoaderResource} resource | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onStart | ||
* @description Dispatched when the loader begins to loading process. | ||
* @member {PIXI.Loader.ILoaderSignal} onStart | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onProgress | ||
* @description Dispatched once per loaded or errored resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onProgress | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onError | ||
* @description Dispatched once per errored resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onError | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onLoad | ||
* @description Dispatched once per loaded resource. | ||
* @member {PIXI.Loader.ILoaderSignal} onLoad | ||
*/ | ||
/** | ||
* @memberof PIXI.Loader# | ||
* @member {object} onComplete | ||
* @description Dispatched when completely loaded all resources. | ||
* @member {PIXI.Loader.ILoaderSignal} onComplete | ||
*/ | ||
@@ -277,41 +298,35 @@ | ||
*/ | ||
var AppLoaderPlugin = function AppLoaderPlugin () {}; | ||
AppLoaderPlugin.init = function init (options) | ||
{ | ||
options = Object.assign({ | ||
sharedLoader: false, | ||
}, options); | ||
var AppLoaderPlugin = /** @class */ (function () { | ||
function AppLoaderPlugin() { | ||
} | ||
/** | ||
* Loader instance to help with asset loading. | ||
* @name PIXI.Application#loader | ||
* @type {PIXI.Loader} | ||
* @readonly | ||
* Called on application constructor | ||
* @param {object} options | ||
* @private | ||
*/ | ||
this.loader = options.sharedLoader ? Loader.shared : new Loader(); | ||
}; | ||
AppLoaderPlugin.init = function (options) { | ||
options = Object.assign({ | ||
sharedLoader: false, | ||
}, options); | ||
/** | ||
* Loader instance to help with asset loading. | ||
* @name PIXI.Application#loader | ||
* @type {PIXI.Loader} | ||
* @readonly | ||
*/ | ||
this.loader = options.sharedLoader ? Loader.shared : new Loader(); | ||
}; | ||
/** | ||
* Called when application destroyed | ||
* @private | ||
*/ | ||
AppLoaderPlugin.destroy = function () { | ||
if (this.loader) { | ||
this.loader.destroy(); | ||
this.loader = null; | ||
} | ||
}; | ||
return AppLoaderPlugin; | ||
}()); | ||
/** | ||
* Called when application destroyed | ||
* @private | ||
*/ | ||
AppLoaderPlugin.destroy = function destroy () | ||
{ | ||
if (this.loader) | ||
{ | ||
this.loader.destroy(); | ||
this.loader = null; | ||
} | ||
}; | ||
/** | ||
* Reference to **{@link https://github.com/englercj/resource-loader | ||
* resource-loader}**'s Resource class. | ||
* @see http://englercj.github.io/resource-loader/Resource.html | ||
* @class LoaderResource | ||
* @memberof PIXI | ||
*/ | ||
var LoaderResource = resourceLoader.Resource; | ||
exports.AppLoaderPlugin = AppLoaderPlugin; | ||
@@ -318,0 +333,0 @@ exports.Loader = Loader; |
{ | ||
"name": "@pixi/loaders", | ||
"version": "5.2.4", | ||
"version": "5.3.0", | ||
"main": "lib/loaders.js", | ||
@@ -27,7 +27,10 @@ "module": "lib/loaders.es.js", | ||
"dependencies": { | ||
"@pixi/core": "5.2.4", | ||
"@pixi/utils": "5.2.4", | ||
"@pixi/core": "5.3.0", | ||
"@pixi/utils": "5.3.0", | ||
"resource-loader": "^3.0.1" | ||
}, | ||
"gitHead": "71c6b3b2061af4a4f3a95a265d46e933b8befc2c" | ||
"devDependencies": { | ||
"@pixi/utils": "5.2.1" | ||
}, | ||
"gitHead": "a9b7b32a9c0aeb3d9c42ef04b2c2a39be1cd0880" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
465284
3332
1
1
+ Added@pixi/constants@5.3.0(transitive)
+ Added@pixi/core@5.3.0(transitive)
+ Added@pixi/math@5.3.0(transitive)
+ Added@pixi/runner@5.3.0(transitive)
+ Added@pixi/settings@5.3.0(transitive)
+ Added@pixi/ticker@5.3.0(transitive)
+ Added@pixi/utils@5.3.0(transitive)
- Removed@pixi/constants@5.2.4(transitive)
- Removed@pixi/core@5.2.4(transitive)
- Removed@pixi/display@5.2.4(transitive)
- Removed@pixi/math@5.2.4(transitive)
- Removed@pixi/runner@5.2.4(transitive)
- Removed@pixi/settings@5.2.4(transitive)
- Removed@pixi/ticker@5.2.4(transitive)
- Removed@pixi/utils@5.2.4(transitive)
Updated@pixi/core@5.3.0
Updated@pixi/utils@5.3.0