Socket
Socket
Sign inDemoInstall

resource-loader

Package Overview
Dependencies
2
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-rc3 to 4.0.0-rc4

12

dist/index.d.ts

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

export { AbstractLoadStrategy } from './load_strategies/AbstractLoadStrategy';
export { AbstractLoadStrategy, ILoadConfig } from './load_strategies/AbstractLoadStrategy';
export { AudioLoadStrategy } from './load_strategies/AudioLoadStrategy';
export { ImageLoadStrategy } from './load_strategies/ImageLoadStrategy';
export { MediaElementLoadStrategy } from './load_strategies/MediaElementLoadStrategy';
export { ImageLoadStrategy, IImageLoadConfig } from './load_strategies/ImageLoadStrategy';
export { MediaElementLoadStrategy, IMediaElementLoadConfig } from './load_strategies/MediaElementLoadStrategy';
export { VideoLoadStrategy } from './load_strategies/VideoLoadStrategy';
export { XhrLoadStrategy } from './load_strategies/XhrLoadStrategy';
export { Loader } from './Loader';
export { Resource } from './Resource';
export { XhrLoadStrategy, XhrResponseType, IXhrLoadConfig } from './load_strategies/XhrLoadStrategy';
export { Loader, IAddOptions } from './Loader';
export { Resource, IResourceOptions } from './Resource';
export { ResourceType, ResourceState } from './resource_type';
import parseUri from 'parse-uri';
import { Signal } from 'type-signals';
import { Resource } from './Resource';
import { ILoadConfig } from './load_strategies/AbstractLoadStrategy';
import { Resource, IResourceOptions } from './Resource';
export declare namespace Loader {

@@ -15,3 +14,3 @@ type ResourceMap = Partial<Record<string, Resource>>;

}
export interface IAddOptions extends ILoadConfig {
export interface IAddOptions extends IResourceOptions {
[key: string]: any;

@@ -18,0 +17,0 @@ url: string;

/*!
* resource-loader - v4.0.0-rc3
* resource-loader - v4.0.0-rc4
* https://github.com/englercj/resource-loader
* Compiled Wed, 04 Dec 2019 03:21:51 UTC
* Compiled Sun, 08 Mar 2020 16:55:29 UTC
*

@@ -265,3 +265,2 @@ * resource-loader is licensed under the MIT license.

var useXdr = !!(window.XDomainRequest && !('withCredentials' in (new XMLHttpRequest())));
var XhrResponseType;
(function (XhrResponseType) {

@@ -274,3 +273,3 @@ XhrResponseType["Default"] = "text";

XhrResponseType["Text"] = "text";
})(XhrResponseType || (XhrResponseType = {}));
})(exports.XhrResponseType || (exports.XhrResponseType = {}));
function reqType(xhr) {

@@ -289,3 +288,3 @@ return xhr.toString().replace('object ', '');

_this._xhr = _this._createRequest();
_this._xhrType = XhrResponseType.Default;
_this._xhrType = exports.XhrResponseType.Default;
return _this;

@@ -300,3 +299,3 @@ }

var xhr = this._xhr;
this._xhrType = config.xhrType || XhrResponseType.Default;
this._xhrType = config.xhrType || exports.XhrResponseType.Default;
if (useXdr) {

@@ -315,4 +314,4 @@ xhr.timeout = config.timeout || 5000;

xhr.timeout = config.timeout;
if (config.xhrType === XhrResponseType.Json || config.xhrType === XhrResponseType.Document)
xhr.responseType = XhrResponseType.Text;
if (config.xhrType === exports.XhrResponseType.Json || config.xhrType === exports.XhrResponseType.Document)
xhr.responseType = exports.XhrResponseType.Text;
else

@@ -345,3 +344,3 @@ xhr.responseType = config.xhrType;

XhrLoadStrategy.prototype._determineXhrType = function (ext) {
return XhrLoadStrategy._xhrTypeMap[ext] || XhrResponseType.Default;
return XhrLoadStrategy._xhrTypeMap[ext] || exports.XhrResponseType.Default;
};

@@ -378,3 +377,3 @@ XhrLoadStrategy.prototype._clearEvents = function () {

}
if (status === 0 && (text.length > 0 || xhr.responseType === XhrResponseType.Buffer)) {
if (status === 0 && (text.length > 0 || xhr.responseType === exports.XhrResponseType.Buffer)) {
status = 200;

@@ -391,16 +390,16 @@ }

switch (this._xhrType) {
case XhrResponseType.Buffer:
case exports.XhrResponseType.Buffer:
this._complete(exports.ResourceType.Buffer, xhr.response);
break;
case XhrResponseType.Blob:
case exports.XhrResponseType.Blob:
this._complete(exports.ResourceType.Blob, xhr.response);
break;
case XhrResponseType.Document:
case exports.XhrResponseType.Document:
this._parseDocument(text);
break;
case XhrResponseType.Json:
case exports.XhrResponseType.Json:
this._parseJson(text);
break;
case XhrResponseType.Default:
case XhrResponseType.Text:
case exports.XhrResponseType.Default:
case exports.XhrResponseType.Text:
this._complete(exports.ResourceType.Text, text);

@@ -462,25 +461,25 @@ break;

};
XhrLoadStrategy.ResponseType = XhrResponseType;
XhrLoadStrategy.ResponseType = exports.XhrResponseType;
XhrLoadStrategy._xhrTypeMap = {
xhtml: XhrResponseType.Document,
html: XhrResponseType.Document,
htm: XhrResponseType.Document,
xml: XhrResponseType.Document,
tmx: XhrResponseType.Document,
svg: XhrResponseType.Document,
tsx: XhrResponseType.Document,
gif: XhrResponseType.Blob,
png: XhrResponseType.Blob,
bmp: XhrResponseType.Blob,
jpg: XhrResponseType.Blob,
jpeg: XhrResponseType.Blob,
tif: XhrResponseType.Blob,
tiff: XhrResponseType.Blob,
webp: XhrResponseType.Blob,
tga: XhrResponseType.Blob,
json: XhrResponseType.Json,
text: XhrResponseType.Text,
txt: XhrResponseType.Text,
ttf: XhrResponseType.Buffer,
otf: XhrResponseType.Buffer,
xhtml: exports.XhrResponseType.Document,
html: exports.XhrResponseType.Document,
htm: exports.XhrResponseType.Document,
xml: exports.XhrResponseType.Document,
tmx: exports.XhrResponseType.Document,
svg: exports.XhrResponseType.Document,
tsx: exports.XhrResponseType.Document,
gif: exports.XhrResponseType.Blob,
png: exports.XhrResponseType.Blob,
bmp: exports.XhrResponseType.Blob,
jpg: exports.XhrResponseType.Blob,
jpeg: exports.XhrResponseType.Blob,
tif: exports.XhrResponseType.Blob,
tiff: exports.XhrResponseType.Blob,
webp: exports.XhrResponseType.Blob,
tga: exports.XhrResponseType.Blob,
json: exports.XhrResponseType.Json,
text: exports.XhrResponseType.Text,
txt: exports.XhrResponseType.Text,
ttf: exports.XhrResponseType.Buffer,
otf: exports.XhrResponseType.Buffer,
};

@@ -630,2 +629,3 @@ return XhrLoadStrategy;

this.name = name;
this.metadata = options.metadata;
if (typeof options.crossOrigin !== 'string')

@@ -659,2 +659,7 @@ options.crossOrigin = this._determineCrossOrigin(options.url);

};
Object.defineProperty(Resource.prototype, "strategy", {
get: function () { return this._strategy; },
enumerable: true,
configurable: true
});
Object.defineProperty(Resource.prototype, "url", {

@@ -661,0 +666,0 @@ get: function () { return this._strategy.config.url; },

/*!
* resource-loader - v4.0.0-rc3
* resource-loader - v4.0.0-rc4
* https://github.com/englercj/resource-loader
* Compiled Wed, 04 Dec 2019 03:21:51 UTC
* Compiled Sun, 08 Mar 2020 16:55:29 UTC
*

@@ -617,2 +617,3 @@ * resource-loader is licensed under the MIT license.

this.name = name;
this.metadata = options.metadata;
if (typeof options.crossOrigin !== 'string')

@@ -646,2 +647,7 @@ options.crossOrigin = this._determineCrossOrigin(options.url);

};
Object.defineProperty(Resource.prototype, "strategy", {
get: function () { return this._strategy; },
enumerable: true,
configurable: true
});
Object.defineProperty(Resource.prototype, "url", {

@@ -965,3 +971,3 @@ get: function () { return this._strategy.config.url; },

export { AbstractLoadStrategy, AudioLoadStrategy, ImageLoadStrategy, Loader, MediaElementLoadStrategy, Resource, ResourceState, ResourceType, VideoLoadStrategy, XhrLoadStrategy };
export { AbstractLoadStrategy, AudioLoadStrategy, ImageLoadStrategy, Loader, MediaElementLoadStrategy, Resource, ResourceState, ResourceType, VideoLoadStrategy, XhrLoadStrategy, XhrResponseType };
//# sourceMappingURL=resource-loader.esm.js.map
/*!
* resource-loader - v4.0.0-rc3
* resource-loader - v4.0.0-rc4
* https://github.com/englercj/resource-loader
* Compiled Wed, 04 Dec 2019 03:21:51 UTC
* Compiled Sun, 08 Mar 2020 16:55:29 UTC
*

@@ -793,2 +793,3 @@ * resource-loader is licensed under the MIT license.

this.name = name;
this.metadata = options.metadata;
if (typeof options.crossOrigin !== 'string')

@@ -822,2 +823,7 @@ options.crossOrigin = this._determineCrossOrigin(options.url);

};
Object.defineProperty(Resource.prototype, "strategy", {
get: function () { return this._strategy; },
enumerable: true,
configurable: true
});
Object.defineProperty(Resource.prototype, "url", {

@@ -824,0 +830,0 @@ get: function () { return this._strategy.config.url; },

/*!
* resource-loader - v4.0.0-rc3
* resource-loader - v4.0.0-rc4
* https://github.com/englercj/resource-loader
* Compiled Wed, 04 Dec 2019 03:21:51 UTC
* Compiled Sun, 08 Mar 2020 16:55:29 UTC
*

@@ -9,3 +9,3 @@ * resource-loader is licensed under the MIT license.

*/
var Loader=function(){"use strict";var t,e,r=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),n=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addMiniSignalBinding(new r(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addMiniSignalBinding(new r(t,!0,e))},t.prototype.detach=function(t){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&&(this._tail.next=null)),t.owner=null,this)},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addMiniSignalBinding=function(t){return this._head?(this._tail&&(this._tail.next=t),t.prev=this._tail,this._tail=t):(this._head=t,this._tail=t),t.owner=this,t},t}(),o=function(t){this.config=t,this.onError=new n,this.onComplete=new n,this.onProgress=new n},i=function(t,e){return(i=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)};function s(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function u(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,o++)n[o]=i[s];return n}function a(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),i=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,i)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function h(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(t||(t={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(e||(e={}));var l,p=function(e){function r(t,r){var n=e.call(this,t)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return s(r,e),r.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+a(n));var i=document.createElement("source");i.src=n,i.type=o,this._element.appendChild(i)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},r.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},r.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},r.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(){this._clearEvents();var e=t.Unknown;switch(this.elementType){case"audio":e=t.Audio;break;case"video":e=t.Video;break;default:h(this.elementType)}this.onComplete.dispatch(e,this._element)},r.prototype._onLoad=function(){this._complete()},r.prototype._onError=function(){this._error(this.elementType+" failed to load.")},r.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},r}(o),c=function(t){function e(e){return t.call(this,e,"audio")||this}return s(e,t),e}(p),d=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t._boundOnLoad=t._onLoad.bind(t),t._boundOnError=t._onError.bind(t),t._boundOnTimeout=t._onTimeout.bind(t),t._element=t._createElement(),t._elementTimer=0,t}return s(r,e),r.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},r.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},r.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},r.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(t.Image,this._element)},r.prototype._onLoad=function(){this._complete()},r.prototype._onError=function(){this._error("Image failed to load.")},r.prototype._onTimeout=function(){this._error("Image load timed out.")},r}(o),f=function(t){function e(e){return t.call(this,e,"video")||this}return s(e,t),e}(p),_=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function m(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}(l||(l={}));var y=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t._boundOnLoad=t._onLoad.bind(t),t._boundOnAbort=t._onAbort.bind(t),t._boundOnError=t._onError.bind(t),t._boundOnTimeout=t._onTimeout.bind(t),t._boundOnProgress=t._onProgress.bind(t),t._xhr=t._createRequest(),t._xhrType=l.Default,t}return s(r,e),r.prototype.load=function(){var t=this.config,e=a(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||l.Default,_?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===l.Json||t.xhrType===l.Document?r.responseType=l.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},r.prototype.abort=function(){_?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},r.prototype._createRequest=function(){return _?new window.XDomainRequest:new XMLHttpRequest},r.prototype._determineXhrType=function(t){return r._xhrTypeMap[t]||l.Default},r.prototype._clearEvents=function(){_?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},r.prototype._onLoad=function(){var e=this._xhr,r="",n=void 0===e.status?200:e.status;if(void 0!==e.responseType&&""!==e.responseType&&"text"!==e.responseType||(r=e.responseText),0===n&&(r.length>0||e.responseType===l.Buffer)?n=200:1223===n&&(n=204),200===100*Math.floor(n/100))switch(this._xhrType){case l.Buffer:this._complete(t.Buffer,e.response);break;case l.Blob:this._complete(t.Blob,e.response);break;case l.Document:this._parseDocument(r);break;case l.Json:this._parseJson(r);break;case l.Default:case l.Text:this._complete(t.Text,r);break;default:h(this._xhrType)}else this._error("["+e.status+"] "+e.statusText+": "+e.responseURL)},r.prototype._parseDocument=function(e){try{if(window.DOMParser){var r=(new DOMParser).parseFromString(e,"text/xml");this._complete(t.Xml,r)}else{var n=document.createElement("div");n.innerHTML=e,this._complete(t.Xml,n)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},r.prototype._parseJson=function(e){try{var r=JSON.parse(e);this._complete(t.Json,r)}catch(t){this._error("Error trying to parse loaded json: "+t)}},r.prototype._onAbort=function(){var t=this._xhr;this._error(m(t)+" Request was aborted by the user.")},r.prototype._onError=function(){var t=this._xhr;this._error(m(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},r.prototype._onTimeout=function(){var t=this._xhr;this._error(m(t)+" Request timed out.")},r.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},r.setExtensionXhrType=function(t,e){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(r._xhrTypeMap[t]=e)},r.ResponseType=l,r._xhrTypeMap={xhtml:l.Document,html:l.Document,htm:l.Document,xml:l.Document,tmx:l.Document,svg:l.Document,tsx:l.Document,gif:l.Blob,png:l.Blob,bmp:l.Blob,jpg:l.Blob,jpeg:l.Blob,tif:l.Blob,tiff:l.Blob,webp:l.Blob,tga:l.Blob,json:l.Json,text:l.Text,txt:l.Text,ttf:l.Buffer,otf:l.Buffer},r}(o),g=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),o={},i=14;i--;)o[r.key[i]]=n[i]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o};function b(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var v=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new n,this.onUnsaturated=new n,this.onEmpty=new n,this.onDrain=new n,this.onError=new n,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,b(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,u([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),w=function(){function r(o,i){if(this.children=[],this.onStart=new n,this.onProgress=new n,this.onComplete=new n,this.onAfterMiddleware=new n,this.data=null,this.type=t.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=e.NotStarted,this.name=o,"string"!=typeof i.crossOrigin&&(i.crossOrigin=this._determineCrossOrigin(i.url)),i.strategy&&"function"!=typeof i.strategy)this._strategy=i.strategy,this._strategy.config=i;else{var s=i.strategy;s||(s=r._loadStrategyMap[a(i.url)]),s||(s=r._defaultLoadStrategy),this._strategy=new s(i)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return r.setDefaultLoadStrategy=function(t){r._defaultLoadStrategy=t},r.setLoadStrategy=function(t,e){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(r._loadStrategyMap[t]=e)},Object.defineProperty(r.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isLoading",{get:function(){return this._state===e.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isComplete",{get:function(){return this._state===e.Complete},enumerable:!0,configurable:!0}),r.prototype.abort=function(){this._strategy.abort()},r.prototype.load=function(){this._state=e.Loading,this.onStart.dispatch(this),this._strategy.load()},r.prototype._error=function(t){this._state=e.Complete,this.error=t,this.onComplete.dispatch(this)},r.prototype._complete=function(t,r){this._state=e.Complete,this.type=t,this.data=r,this.onComplete.dispatch(this)},r.prototype._progress=function(t){this.onProgress.dispatch(this,t)},r.prototype._determineCrossOrigin=function(t,e){if(void 0===e&&(e=window.location),0===t.indexOf("data:")||0===t.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";r._tempAnchor||(r._tempAnchor=document.createElement("a")),r._tempAnchor.href=t;var n=g(r._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===e.port||n.port===e.port,i=n.protocol?n.protocol+":":"";return n.host===e.hostname&&o&&i===e.protocol?"":"anonymous"},r._tempAnchor=null,r._defaultLoadStrategy=y,r._loadStrategyMap={gif:d,png:d,bmp:d,jpg:d,jpeg:d,tif:d,tiff:d,webp:d,tga:d,svg:d,"svg+xml":d,mp3:c,ogg:c,wav:c,mp4:f,webm:f,mov:f},r}();function E(t,e,r,n){void 0===n&&(n=!1);var o=0,i=t.length;!function s(u){u||o===i?r&&r(u):n?setTimeout((function(){return e(t[o++],s)}),1):e(t[o++],s)}()}var x=/(#[\w-]+)?$/,T=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new n,this.onLoad=new n,this.onStart=new n,this.onComplete=new n,this.onProgress=new n,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new v(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",i=this._baseUrl,s={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,i=t.baseUrl||i,s=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!s.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,i),s.url=n;var u=new w(o,s);if(this.resources[o]=u,"function"==typeof s.onComplete&&u.onAfterMiddleware.once(s.onComplete),this.loading){var a=s.parentResource,h=[];for(r=0;r<a.children.length;++r)a.children[r].isComplete||h.push(a.children[r]);var l=a.progressChunk*(h.length+1)/(h.length+2);a.children.push(u),a.progressChunk=l;for(r=0;r<h.length;++r)h[r].progressChunk=l;u.progressChunk=l}return this._queue.push(u),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.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.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=g(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=g(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=x.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),E(this._middleware,(function(r,n){r.fn.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.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}();return Object.defineProperties(T,{AbstractLoadStrategy:{get:function(){return o}},AudioLoadStrategy:{get:function(){return c}},ImageLoadStrategy:{get:function(){return d}},MediaElementLoadStrategy:{get:function(){return p}},VideoLoadStrategy:{get:function(){return f}},XhrLoadStrategy:{get:function(){return y}},Resource:{get:function(){return w}},ResourceType:{get:function(){return t}},ResourceState:{get:function(){return e}},async:{get:function(){return{AsyncQueue:v,eachSeries:E}}},getExtension:{get:function(){return a}}}),T}();
var Loader=function(){"use strict";var t,e,r=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),n=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addMiniSignalBinding(new r(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addMiniSignalBinding(new r(t,!0,e))},t.prototype.detach=function(t){return t.owner!==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&&(this._tail.next=null)),t.owner=null),this},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addMiniSignalBinding=function(t){return this._head?(this._tail&&(this._tail.next=t),t.prev=this._tail,this._tail=t):(this._head=t,this._tail=t),t.owner=this,t},t}(),o=function(t){this.config=t,this.onError=new n,this.onComplete=new n,this.onProgress=new n},i=function(t,e){return(i=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)};function s(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function a(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}function u(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),i=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,i)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function h(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(t||(t={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(e||(e={}));var l,p=function(e){function r(t,r){var n=e.call(this,t)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return s(r,e),r.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+u(n));var i=document.createElement("source");i.src=n,i.type=o,this._element.appendChild(i)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},r.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},r.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},r.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(){this._clearEvents();var e=t.Unknown;switch(this.elementType){case"audio":e=t.Audio;break;case"video":e=t.Video;break;default:h(this.elementType)}this.onComplete.dispatch(e,this._element)},r.prototype._onLoad=function(){this._complete()},r.prototype._onError=function(){this._error(this.elementType+" failed to load.")},r.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},r}(o),c=function(t){function e(e){return t.call(this,e,"audio")||this}return s(e,t),e}(p),d=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t._boundOnLoad=t._onLoad.bind(t),t._boundOnError=t._onError.bind(t),t._boundOnTimeout=t._onTimeout.bind(t),t._element=t._createElement(),t._elementTimer=0,t}return s(r,e),r.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},r.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},r.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},r.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(t.Image,this._element)},r.prototype._onLoad=function(){this._complete()},r.prototype._onError=function(){this._error("Image failed to load.")},r.prototype._onTimeout=function(){this._error("Image load timed out.")},r}(o),f=function(t){function e(e){return t.call(this,e,"video")||this}return s(e,t),e}(p),_=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function m(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}(l||(l={}));var y=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t._boundOnLoad=t._onLoad.bind(t),t._boundOnAbort=t._onAbort.bind(t),t._boundOnError=t._onError.bind(t),t._boundOnTimeout=t._onTimeout.bind(t),t._boundOnProgress=t._onProgress.bind(t),t._xhr=t._createRequest(),t._xhrType=l.Default,t}return s(r,e),r.prototype.load=function(){var t=this.config,e=u(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||l.Default,_?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===l.Json||t.xhrType===l.Document?r.responseType=l.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},r.prototype.abort=function(){_?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},r.prototype._createRequest=function(){return _?new window.XDomainRequest:new XMLHttpRequest},r.prototype._determineXhrType=function(t){return r._xhrTypeMap[t]||l.Default},r.prototype._clearEvents=function(){_?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},r.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},r.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},r.prototype._onLoad=function(){var e=this._xhr,r="",n=void 0===e.status?200:e.status;if(void 0!==e.responseType&&""!==e.responseType&&"text"!==e.responseType||(r=e.responseText),0===n&&(r.length>0||e.responseType===l.Buffer)?n=200:1223===n&&(n=204),200===100*Math.floor(n/100))switch(this._xhrType){case l.Buffer:this._complete(t.Buffer,e.response);break;case l.Blob:this._complete(t.Blob,e.response);break;case l.Document:this._parseDocument(r);break;case l.Json:this._parseJson(r);break;case l.Default:case l.Text:this._complete(t.Text,r);break;default:h(this._xhrType)}else this._error("["+e.status+"] "+e.statusText+": "+e.responseURL)},r.prototype._parseDocument=function(e){try{if(window.DOMParser){var r=(new DOMParser).parseFromString(e,"text/xml");this._complete(t.Xml,r)}else{var n=document.createElement("div");n.innerHTML=e,this._complete(t.Xml,n)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},r.prototype._parseJson=function(e){try{var r=JSON.parse(e);this._complete(t.Json,r)}catch(t){this._error("Error trying to parse loaded json: "+t)}},r.prototype._onAbort=function(){var t=this._xhr;this._error(m(t)+" Request was aborted by the user.")},r.prototype._onError=function(){var t=this._xhr;this._error(m(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},r.prototype._onTimeout=function(){var t=this._xhr;this._error(m(t)+" Request timed out.")},r.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},r.setExtensionXhrType=function(t,e){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(r._xhrTypeMap[t]=e)},r.ResponseType=l,r._xhrTypeMap={xhtml:l.Document,html:l.Document,htm:l.Document,xml:l.Document,tmx:l.Document,svg:l.Document,tsx:l.Document,gif:l.Blob,png:l.Blob,bmp:l.Blob,jpg:l.Blob,jpeg:l.Blob,tif:l.Blob,tiff:l.Blob,webp:l.Blob,tga:l.Blob,json:l.Json,text:l.Text,txt:l.Text,ttf:l.Buffer,otf:l.Buffer},r}(o),g=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),o={},i=14;i--;)o[r.key[i]]=n[i]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o};function b(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var v=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new n,this.onUnsaturated=new n,this.onEmpty=new n,this.onDrain=new n,this.onError=new n,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,b(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,a([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),w=function(){function r(o,i){if(this.children=[],this.onStart=new n,this.onProgress=new n,this.onComplete=new n,this.onAfterMiddleware=new n,this.data=null,this.type=t.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=e.NotStarted,this.name=o,this.metadata=i.metadata,"string"!=typeof i.crossOrigin&&(i.crossOrigin=this._determineCrossOrigin(i.url)),i.strategy&&"function"!=typeof i.strategy)this._strategy=i.strategy,this._strategy.config=i;else{var s=i.strategy;s||(s=r._loadStrategyMap[u(i.url)]),s||(s=r._defaultLoadStrategy),this._strategy=new s(i)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return r.setDefaultLoadStrategy=function(t){r._defaultLoadStrategy=t},r.setLoadStrategy=function(t,e){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(r._loadStrategyMap[t]=e)},Object.defineProperty(r.prototype,"strategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isLoading",{get:function(){return this._state===e.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isComplete",{get:function(){return this._state===e.Complete},enumerable:!0,configurable:!0}),r.prototype.abort=function(){this._strategy.abort()},r.prototype.load=function(){this._state=e.Loading,this.onStart.dispatch(this),this._strategy.load()},r.prototype._error=function(t){this._state=e.Complete,this.error=t,this.onComplete.dispatch(this)},r.prototype._complete=function(t,r){this._state=e.Complete,this.type=t,this.data=r,this.onComplete.dispatch(this)},r.prototype._progress=function(t){this.onProgress.dispatch(this,t)},r.prototype._determineCrossOrigin=function(t,e){if(void 0===e&&(e=window.location),0===t.indexOf("data:")||0===t.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";r._tempAnchor||(r._tempAnchor=document.createElement("a")),r._tempAnchor.href=t;var n=g(r._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===e.port||n.port===e.port,i=n.protocol?n.protocol+":":"";return n.host===e.hostname&&o&&i===e.protocol?"":"anonymous"},r._tempAnchor=null,r._defaultLoadStrategy=y,r._loadStrategyMap={gif:d,png:d,bmp:d,jpg:d,jpeg:d,tif:d,tiff:d,webp:d,tga:d,svg:d,"svg+xml":d,mp3:c,ogg:c,wav:c,mp4:f,webm:f,mov:f},r}();function E(t,e,r,n){void 0===n&&(n=!1);var o=0,i=t.length;!function s(a){a||o===i?r&&r(a):n?setTimeout((function(){return e(t[o++],s)}),1):e(t[o++],s)}()}var x=/(#[\w-]+)?$/,T=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new n,this.onLoad=new n,this.onStart=new n,this.onComplete=new n,this.onProgress=new n,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new v(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",i=this._baseUrl,s={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,i=t.baseUrl||i,s=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!s.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,i),s.url=n;var a=new w(o,s);if(this.resources[o]=a,"function"==typeof s.onComplete&&a.onAfterMiddleware.once(s.onComplete),this.loading){var u=s.parentResource,h=[];for(r=0;r<u.children.length;++r)u.children[r].isComplete||h.push(u.children[r]);var l=u.progressChunk*(h.length+1)/(h.length+2);u.children.push(a),u.progressChunk=l;for(r=0;r<h.length;++r)h[r].progressChunk=l;a.progressChunk=l}return this._queue.push(a),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.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.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=g(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=g(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=x.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),E(this._middleware,(function(r,n){r.fn.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.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}();return Object.defineProperties(T,{AbstractLoadStrategy:{get:function(){return o}},AudioLoadStrategy:{get:function(){return c}},ImageLoadStrategy:{get:function(){return d}},MediaElementLoadStrategy:{get:function(){return p}},VideoLoadStrategy:{get:function(){return f}},XhrLoadStrategy:{get:function(){return y}},Resource:{get:function(){return w}},ResourceType:{get:function(){return t}},ResourceState:{get:function(){return e}},async:{get:function(){return{AsyncQueue:v,eachSeries:E}}},getExtension:{get:function(){return u}}}),T}();
//# sourceMappingURL=resource-loader.min.js.map

@@ -6,2 +6,3 @@ import { Signal, SignalBinding } from 'type-signals';

strategy?: AbstractLoadStrategy | AbstractLoadStrategyCtor;
metadata?: any;
}

@@ -27,2 +28,3 @@ export declare namespace Resource {

data: any;
metadata: any;
type: ResourceType;

@@ -36,2 +38,3 @@ error: string;

constructor(name: string, options: IResourceOptions);
get strategy(): AbstractLoadStrategy;
get url(): string;

@@ -38,0 +41,0 @@ get isLoading(): boolean;

{
"name": "resource-loader",
"version": "4.0.0-rc3",
"version": "4.0.0-rc4",
"main": "./dist/resource-loader.cjs.js",

@@ -48,25 +48,25 @@ "module": "./dist/resource-loader.esm.js",

"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"chai": "^4.2.0",
"gh-pages": "^2.1.1",
"gh-pages": "^2.2.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^1.2.0",
"karma-firefox-launcher": "^1.3.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-sinon-chai": "^2.0.2",
"mkdirp": "^0.5.1",
"mocha": "^6.2.2",
"mkdirp": "^1.0.3",
"mocha": "^7.1.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.0",
"rollup": "^1.27.6",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-typescript2": "^0.25.2",
"sinon": "^7.5.0",
"sinon-chai": "^3.3.0",
"tslib": "^1.10.0",
"typedoc": "^0.15.3",
"typescript": "^3.7.2"
"rimraf": "^3.0.2",
"rollup": "^1.32.1",
"rollup-plugin-terser": "^5.2.0",
"rollup-plugin-typescript2": "^0.26.0",
"sinon": "^9.0.0",
"sinon-chai": "^3.5.0",
"tslib": "^1.11.1",
"typedoc": "^0.16.11",
"typescript": "^3.8.3"
}
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc