New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/loaders

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/loaders - npm Package Compare versions

Comparing version 5.0.0-alpha.3 to 5.0.0-rc

413

lib/loaders.es.js
/*!
* @pixi/loaders - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/loaders - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -13,3 +13,3 @@ * @pixi/loaders is licensed under the MIT License.

function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
}

@@ -51,2 +51,3 @@

var miniSignals = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, '__esModule', {

@@ -137,3 +138,2 @@ value: true

var arguments$1 = arguments;
var this$1 = this;

@@ -145,3 +145,3 @@ var node = this._head;

while (node) {
if (node._once) { this$1.detach(node); }
if (node._once) { this.detach(node); }
node._fn.apply(node._thisArg, arguments$1);

@@ -225,3 +225,5 @@ node = node._next;

var Resource_1 = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports.Resource = undefined;

@@ -242,3 +244,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }();

// tests is CORS is supported in XHR, if not we need to use XDR
// tests if CORS is supported in XHR, if not we need to use XDR
var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest()));

@@ -263,3 +265,3 @@ var tempAnchor = null;

var Resource$$1 = function () {
var Resource$$1 = exports.Resource = function () {
/**

@@ -296,2 +298,5 @@ * Sets the load type to be used for a specific extension.

* determine automatically.
* @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes
* longer than this time it is cancelled and the load is considered a failure. If this value is
* set to `0` then there is no explicit timeout.
* @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource

@@ -301,10 +306,3 @@ * be loaded?

* should the data being loaded be interpreted when using XHR?
* @param {object} [options.metadata] - Extra configuration for middleware and the Resource object.
* @param {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [options.metadata.loadElement=null] - The
* element to use for loading, instead of creating one.
* @param {boolean} [options.metadata.skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources to.
* @param {string|string[]} [options.metadata.mimeType] - The mime type to use for the source element of a video/audio
* elment. If the urls are an array, you can pass this as an array as well where each index is the mime type to
* use for the corresponding url index.
* @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object.
*/

@@ -325,2 +323,3 @@

*
* @private
* @member {number}

@@ -336,4 +335,4 @@ */

*
* @readonly
* @member {string}
* @readonly
*/

@@ -345,4 +344,4 @@ this.name = name;

*
* @readonly
* @member {string}
* @readonly
*/

@@ -354,4 +353,4 @@ this.url = url;

*
* @readonly
* @member {string}
* @readonly
*/

@@ -375,2 +374,11 @@ this.extension = this._getExtension();

/**
* A timeout in milliseconds for the load. If the load takes longer than this time
* it is cancelled and the load is considered a failure. If this value is set to `0`
* then there is no explicit timeout.
*
* @member {number}
*/
this.timeout = options.timeout || 0;
/**
* The method of loading to use for this resource.

@@ -395,8 +403,3 @@ *

*
* @member {object}
* @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The
* element to use for loading, instead of creating one.
* @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources
* to.
* @member {Resource.IMetadata}
*/

@@ -408,4 +411,4 @@ this.metadata = options.metadata || {};

*
* @readonly
* @member {Error}
* @readonly
*/

@@ -418,4 +421,4 @@ this.error = null;

*
* @readonly
* @member {XMLHttpRequest}
* @readonly
*/

@@ -427,4 +430,4 @@ this.xhr = null;

*
* @readonly
* @member {Resource[]}
* @readonly
*/

@@ -436,4 +439,4 @@ this.children = [];

*
* @readonly
* @member {Resource.TYPE}
* @readonly
*/

@@ -445,4 +448,4 @@ this.type = Resource$$1.TYPE.UNKNOWN;

*
* @readonly
* @member {number}
* @readonly
*/

@@ -469,2 +472,10 @@ this.progressChunk = 0;

/**
* The timer for element loads to check if they timeout.
*
* @private
* @member {number}
*/
this._elementTimer = 0;
/**
* The `complete` function bound to this resource's context.

@@ -493,7 +504,15 @@ *

/**
* The `_onTimeout` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundOnTimeout = this._onTimeout.bind(this);
// xhr callbacks
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._boundXdrOnTimeout = this._xdrOnTimeout.bind(this);

@@ -540,34 +559,46 @@ /**

this.onAfterMiddleware = new _miniSignals2.default();
}
/**
* When the resource starts to load.
*
* @memberof Resource
* @callback OnStartSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* When the resource starts to load.
*
* @memberof Resource
* @callback OnStartSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* When the resource reports loading progress.
*
* @memberof Resource
* @callback OnProgressSignal
* @param {Resource} resource - The resource that the event happened on.
* @param {number} percentage - The progress of the load in the range [0, 1].
*/
/**
* When the resource reports loading progress.
*
* @memberof Resource
* @callback OnProgressSignal
* @param {Resource} resource - The resource that the event happened on.
* @param {number} percentage - The progress of the load in the range [0, 1].
*/
/**
* When the resource finishes loading.
*
* @memberof Resource
* @callback OnCompleteSignal
* @param {Resource} resource - The resource that the event happened on.
*/
}
/**
* When the resource finishes loading.
*
* @memberof Resource
* @callback OnCompleteSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* @memberof Resource
* @typedef {object} IMetadata
* @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The
* element to use for loading, instead of creating one.
* @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources to.
* @property {string|string[]} [mimeType] - The mime type to use for the source element
* of a video/audio elment. If the urls are an array, you can pass this as an array as well
* where each index is the mime type to use for the corresponding url index.
*/
/**
* Stores whether or not this url is a data url.
*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -581,32 +612,4 @@

Resource$$1.prototype.complete = function complete() {
// TODO: Clean this up in a wrapper or something...gross....
if (this.data && this.data.removeEventListener) {
this.data.removeEventListener('error', this._boundOnError, false);
this.data.removeEventListener('load', this._boundComplete, false);
this.data.removeEventListener('progress', this._boundOnProgress, false);
this.data.removeEventListener('canplaythrough', this._boundComplete, false);
}
if (this.xhr) {
if (this.xhr.removeEventListener) {
this.xhr.removeEventListener('error', this._boundXhrOnError, false);
this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);
this.xhr.removeEventListener('progress', this._boundOnProgress, false);
this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);
} else {
this.xhr.onerror = null;
this.xhr.ontimeout = null;
this.xhr.onprogress = null;
this.xhr.onload = null;
}
}
if (this.isComplete) {
throw new Error('Complete called again for an already completed resource.');
}
this._setFlag(Resource$$1.STATUS_FLAGS.COMPLETE, true);
this._setFlag(Resource$$1.STATUS_FLAGS.LOADING, false);
this.onComplete.dispatch(this);
this._clearEvents();
this._finish();
};

@@ -622,4 +625,2 @@

Resource$$1.prototype.abort = function abort(message) {
var this$1 = this;
// abort can be called multiple times, ignore subsequent calls.

@@ -633,2 +634,5 @@ if (this.error) {

// clear events before calling aborts
this._clearEvents();
// abort the actual loading

@@ -647,3 +651,3 @@ if (this.xhr) {

while (this.data.firstChild) {
this$1.data.removeChild(this$1.data.firstChild);
this.data.removeChild(this.data.firstChild);
}

@@ -654,3 +658,3 @@ }

// done now.
this.complete();
this._finish();
};

@@ -661,3 +665,3 @@

*
* @param {function} [cb] - Optional callback to call once the resource is loaded.
* @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded.
*/

@@ -732,3 +736,3 @@

Resource$$1.prototype._hasFlag = function _hasFlag(flag) {
return !!(this._flags & flag);
return (this._flags & flag) !== 0;
};

@@ -750,2 +754,53 @@

/**
* Clears all the events from the underlying loading source.
*
* @private
*/
Resource$$1.prototype._clearEvents = function _clearEvents() {
clearTimeout(this._elementTimer);
if (this.data && this.data.removeEventListener) {
this.data.removeEventListener('error', this._boundOnError, false);
this.data.removeEventListener('load', this._boundComplete, false);
this.data.removeEventListener('progress', this._boundOnProgress, false);
this.data.removeEventListener('canplaythrough', this._boundComplete, false);
}
if (this.xhr) {
if (this.xhr.removeEventListener) {
this.xhr.removeEventListener('error', this._boundXhrOnError, false);
this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false);
this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);
this.xhr.removeEventListener('progress', this._boundOnProgress, false);
this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);
} else {
this.xhr.onerror = null;
this.xhr.ontimeout = null;
this.xhr.onprogress = null;
this.xhr.onload = null;
}
}
};
/**
* Finalizes the load.
*
* @private
*/
Resource$$1.prototype._finish = function _finish() {
if (this.isComplete) {
throw new Error('Complete called again for an already completed resource.');
}
this._setFlag(Resource$$1.STATUS_FLAGS.COMPLETE, true);
this._setFlag(Resource$$1.STATUS_FLAGS.LOADING, false);
this.onComplete.dispatch(this);
};
/**
* Loads this resources using an element that has a single source,

@@ -779,2 +834,6 @@ * like an HTMLImageElement.

this.data.addEventListener('progress', this._boundOnProgress, false);
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};

@@ -792,4 +851,2 @@

Resource$$1.prototype._loadSourceElement = function _loadSourceElement(type) {
var this$1 = this;
if (this.metadata.loadElement) {

@@ -809,2 +866,6 @@ this.data = this.metadata.loadElement;

if (this.crossOrigin) {
this.data.crossOrigin = this.crossOrigin;
}
if (!this.metadata.skipSource) {

@@ -818,3 +879,3 @@ // support for CocoonJS Canvas+ runtime, lacks document.createElement('source')

for (var i = 0; i < this.url.length; ++i) {
this$1.data.appendChild(this$1._createSource(type, this$1.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));
this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));
}

@@ -834,2 +895,6 @@ } else {

this.data.load();
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};

@@ -855,2 +920,4 @@

xhr.timeout = this.timeout;
// load json as text and parse it ourselves. We do this because some browsers

@@ -865,2 +932,3 @@ // *cough* safari *cough* can't deal with it.

xhr.addEventListener('error', this._boundXhrOnError, false);
xhr.addEventListener('timeout', this._boundXhrOnTimeout, false);
xhr.addEventListener('abort', this._boundXhrOnAbort, false);

@@ -886,3 +954,3 @@ xhr.addEventListener('progress', this._boundOnProgress, false);

var xdr = this.xhr = new XDomainRequest();
var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef

@@ -892,6 +960,6 @@ // XDomainRequest has a few quirks. Occasionally it will abort requests

// More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9
xdr.timeout = 5000;
xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9
xdr.onerror = this._boundXhrOnError;
xdr.ontimeout = this._boundXdrOnTimeout;
xdr.ontimeout = this._boundXhrOnTimeout;
xdr.onprogress = this._boundOnProgress;

@@ -948,3 +1016,3 @@ xdr.onload = this._boundXhrOnLoad;

/**
* Called if a load progress event fires for xhr/xdr.
* Called if a load progress event fires for an element or xhr/xdr.
*

@@ -963,6 +1031,16 @@ * @private

/**
* Called if a timeout event fires for an element.
*
* @private
*/
Resource$$1.prototype._onTimeout = function _onTimeout() {
this.abort('Load timed out.');
};
/**
* Called if an error event fires for xhr/xdr.
*
* @private
* @param {XMLHttpRequestErrorEvent|Event} event - Error event.
*/

@@ -978,23 +1056,25 @@

/**
* Called if an abort event fires for xhr.
* Called if an error event fires for xhr/xdr.
*
* @private
* @param {XMLHttpRequestAbortEvent} event - Abort Event
*/
Resource$$1.prototype._xhrOnAbort = function _xhrOnAbort() {
this.abort(reqType(this.xhr) + ' Request was aborted by the user.');
Resource$$1.prototype._xhrOnTimeout = function _xhrOnTimeout() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request timed out.');
};
/**
* Called if a timeout event fires for xdr.
* Called if an abort event fires for xhr/xdr.
*
* @private
* @param {Event} event - Timeout event.
*/
Resource$$1.prototype._xdrOnTimeout = function _xdrOnTimeout() {
this.abort(reqType(this.xhr) + ' Request timed out.');
Resource$$1.prototype._xhrOnAbort = function _xhrOnAbort() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request was aborted by the user.');
};

@@ -1102,2 +1182,9 @@

// A sandboxed iframe without the 'allow-same-origin' attribute will have a special
// origin designed not to match window.location.origin, and will always require
// crossOrigin requests regardless of whether the location matches.
if (window.origin !== window.location.origin) {
return 'anonymous';
}
// default is window.location

@@ -1210,3 +1297,2 @@ loc = loc || window.location;

return 'text/plain';
}

@@ -1225,4 +1311,4 @@ };

*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -1240,4 +1326,4 @@

*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -1264,3 +1350,2 @@

exports.default = Resource$$1;
Resource$$1.STATUS_FLAGS = {

@@ -1426,7 +1511,14 @@ NONE: 0,

// Backwards compat
{
module.exports.default = Resource$$1; // eslint-disable-line no-undef
}
});
unwrapExports(Resource_1);
var Resource_2 = Resource_1.Resource;
var b64 = createCommonjsModule(function (module, exports) {
exports.__esModule = true;

@@ -1436,2 +1528,8 @@ exports.encodeBinary = encodeBinary;

/**
* Encodes binary into base64.
*
* @param {string} input The input data to encode.
* @returns {string} The encoded base64 string
*/
function encodeBinary(input) {

@@ -1498,2 +1596,7 @@ var output = '';

// Backwards compat
{
module.exports.default = encodeBinary; // eslint-disable-line no-undef
}
});

@@ -1505,6 +1608,4 @@

var blob = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.blobMiddlewareFactory = blobMiddlewareFactory;

@@ -1514,10 +1615,4 @@

var _Resource2 = _interopRequireDefault(Resource_1);
var _b2 = _interopRequireDefault(b64);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Url = window.URL || window.webkitURL;

@@ -1535,3 +1630,3 @@

// if this was an XHR load of a blob
if (resource.xhr && resource.xhrType === _Resource2.default.XHR_RESPONSE_TYPE.BLOB) {
if (resource.xhr && resource.xhrType === Resource_1.Resource.XHR_RESPONSE_TYPE.BLOB) {
// if there is no blob support we probably got a binary string back

@@ -1544,5 +1639,5 @@ if (!window.Blob || typeof resource.data === 'string') {

resource.data = new Image();
resource.data.src = 'data:' + type + ';base64,' + _b2.default.encodeBinary(resource.xhr.responseText);
resource.data.src = 'data:' + type + ';base64,' + (0, b64.encodeBinary)(resource.xhr.responseText);
resource.type = _Resource2.default.TYPE.IMAGE;
resource.type = Resource_1.Resource.TYPE.IMAGE;

@@ -1562,27 +1657,21 @@ // wait until the image loads and then callback

else if (resource.data.type.indexOf('image') === 0) {
var _ret = function () {
var src = Url.createObjectURL(resource.data);
var src = Url.createObjectURL(resource.data);
resource.blob = resource.data;
resource.data = new Image();
resource.data.src = src;
resource.blob = resource.data;
resource.data = new Image();
resource.data.src = src;
resource.type = _Resource2.default.TYPE.IMAGE;
resource.type = Resource_1.Resource.TYPE.IMAGE;
// cleanup the no longer used blob after the image loads
// TODO: Is this correct? Will the image be invalid after revoking?
resource.data.onload = function () {
Url.revokeObjectURL(src);
resource.data.onload = null;
// cleanup the no longer used blob after the image loads
// TODO: Is this correct? Will the image be invalid after revoking?
resource.data.onload = function () {
Url.revokeObjectURL(src);
resource.data.onload = null;
next();
};
next();
};
// next will be called on load.
return {
v: void 0
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") { return _ret.v; }
// next will be called on load.
return;
}

@@ -1604,3 +1693,3 @@ }

* @memberof PIXI
* @extends PIXI.Loader~LoaderPlugin
* @implements PIXI.ILoaderPlugin
*/

@@ -1624,3 +1713,2 @@ var TextureLoader = function TextureLoader () {};

/**
*
* The new loader, extends Resource Loader by Chad Engler: https://github.com/englercj/resource-loader

@@ -1672,3 +1760,2 @@ *

* @class Loader
* @extends module:resource-loader.ResourceLoader
* @memberof PIXI

@@ -1678,3 +1765,3 @@ * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader.

*/
var Loader = (function (ResourceLoader$$1) {
var Loader = /*@__PURE__*/(function (ResourceLoader$$1) {
function Loader(baseUrl, concurrency)

@@ -1695,3 +1782,3 @@ {

{
this$1.pre(pre);
this.pre(pre);
}

@@ -1701,3 +1788,3 @@

{
this$1.use(use);
this.use(use);
}

@@ -1730,2 +1817,3 @@ }

* Destroy the loader, removes references.
* @private
*/

@@ -1774,3 +1862,3 @@ Loader.prototype.destroy = function destroy ()

* @static
* @member {Array<PIXI.Loader~LoaderPlugin>}
* @member {Array<PIXI.ILoaderPlugin>} _plugins
* @memberof PIXI.Loader

@@ -1788,3 +1876,3 @@ * @private

* @memberof PIXI.Loader
* @param {PIXI.Loader~LoaderPlugin} plugin - The plugin to add
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining

@@ -1812,7 +1900,9 @@ */

* Plugin to be installed for handling specific Loader resources.
* @typedef {object} PIXI.Loader~LoaderPlugin
* @property {function} [plugin.add] - Function to call immediate after registering plugin.
* @property {PIXI.Loader~loaderMiddleware} [plugin.pre] - Middleware function to run before load, the
*
* @memberof PIXI
* @typedef ILoaderPlugin
* @property {function} [add] - Function to call immediate after registering plugin.
* @property {PIXI.Loader.loaderMiddleware} [pre] - Middleware function to run before load, the
* arguments for this are `(resource, next)`
* @property {PIXI.Loader~loaderMiddleware} [plugin.use] - Middleware function to run after load, the
* @property {PIXI.Loader.loaderMiddleware} [use] - Middleware function to run after load, the
* arguments for this are `(resource, next)`

@@ -1822,3 +1912,4 @@ */

/**
* @callback PIXI.Loader~loaderMiddleware
* @memberof PIXI.Loader
* @callback loaderMiddleware
* @param {PIXI.LoaderResource} resource

@@ -1832,11 +1923,11 @@ * @param {function} next

* @example
* import {LoaderPlugin} from '@pixi/loaders';
* import {AppLoaderPlugin} from '@pixi/loaders';
* import {Application} from '@pixi/app';
* Application.registerPlugin(LoaderPlugin);
* Application.registerPlugin(AppLoaderPlugin);
* @class
* @memberof PIXI
*/
var LoaderPlugin = function LoaderPlugin () {};
var AppLoaderPlugin = function AppLoaderPlugin () {};
LoaderPlugin.init = function init (options)
AppLoaderPlugin.init = function init (options)
{

@@ -1860,3 +1951,3 @@ options = Object.assign({

*/
LoaderPlugin.destroy = function destroy ()
AppLoaderPlugin.destroy = function destroy ()
{

@@ -1879,3 +1970,3 @@ if (this.loader)

export { LoaderResource, Loader, TextureLoader, LoaderPlugin };
export { LoaderResource, Loader, TextureLoader, AppLoaderPlugin };
//# sourceMappingURL=loaders.es.js.map
/*!
* @pixi/loaders - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/loaders - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -20,3 +20,3 @@ * @pixi/loaders is licensed under the MIT License.

function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
}

@@ -58,2 +58,3 @@

var miniSignals = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, '__esModule', {

@@ -144,3 +145,2 @@ value: true

var arguments$1 = arguments;
var this$1 = this;

@@ -152,3 +152,3 @@ var node = this._head;

while (node) {
if (node._once) { this$1.detach(node); }
if (node._once) { this.detach(node); }
node._fn.apply(node._thisArg, arguments$1);

@@ -232,3 +232,5 @@ node = node._next;

var Resource_1 = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports.Resource = undefined;

@@ -249,3 +251,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) { defineProperties(Constructor.prototype, protoProps); } if (staticProps) { defineProperties(Constructor, staticProps); } return Constructor; }; }();

// tests is CORS is supported in XHR, if not we need to use XDR
// tests if CORS is supported in XHR, if not we need to use XDR
var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest()));

@@ -270,3 +272,3 @@ var tempAnchor = null;

var Resource$$1 = function () {
var Resource = exports.Resource = function () {
/**

@@ -279,4 +281,4 @@ * Sets the load type to be used for a specific extension.

*/
Resource$$1.setExtensionLoadType = function setExtensionLoadType(extname, loadType) {
setExtMap(Resource$$1._loadTypeMap, extname, loadType);
Resource.setExtensionLoadType = function setExtensionLoadType(extname, loadType) {
setExtMap(Resource._loadTypeMap, extname, loadType);
};

@@ -293,4 +295,4 @@

Resource$$1.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) {
setExtMap(Resource$$1._xhrTypeMap, extname, xhrType);
Resource.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) {
setExtMap(Resource._xhrTypeMap, extname, xhrType);
};

@@ -305,2 +307,5 @@

* determine automatically.
* @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes
* longer than this time it is cancelled and the load is considered a failure. If this value is
* set to `0` then there is no explicit timeout.
* @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource

@@ -310,15 +315,8 @@ * be loaded?

* should the data being loaded be interpreted when using XHR?
* @param {object} [options.metadata] - Extra configuration for middleware and the Resource object.
* @param {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [options.metadata.loadElement=null] - The
* element to use for loading, instead of creating one.
* @param {boolean} [options.metadata.skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources to.
* @param {string|string[]} [options.metadata.mimeType] - The mime type to use for the source element of a video/audio
* elment. If the urls are an array, you can pass this as an array as well where each index is the mime type to
* use for the corresponding url index.
* @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object.
*/
function Resource$$1(name, url, options) {
_classCallCheck(this, Resource$$1);
function Resource(name, url, options) {
_classCallCheck(this, Resource);

@@ -334,2 +332,3 @@ if (typeof name !== 'string' || typeof url !== 'string') {

*
* @private
* @member {number}

@@ -340,3 +339,3 @@ */

// set data url flag, needs to be set early for some _determineX checks to work.
this._setFlag(Resource$$1.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0);
this._setFlag(Resource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0);

@@ -346,4 +345,4 @@ /**

*
* @readonly
* @member {string}
* @readonly
*/

@@ -355,4 +354,4 @@ this.name = name;

*
* @readonly
* @member {string}
* @readonly
*/

@@ -364,4 +363,4 @@ this.url = url;

*
* @readonly
* @member {string}
* @readonly
*/

@@ -385,2 +384,11 @@ this.extension = this._getExtension();

/**
* A timeout in milliseconds for the load. If the load takes longer than this time
* it is cancelled and the load is considered a failure. If this value is set to `0`
* then there is no explicit timeout.
*
* @member {number}
*/
this.timeout = options.timeout || 0;
/**
* The method of loading to use for this resource.

@@ -405,8 +413,3 @@ *

*
* @member {object}
* @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The
* element to use for loading, instead of creating one.
* @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources
* to.
* @member {Resource.IMetadata}
*/

@@ -418,4 +421,4 @@ this.metadata = options.metadata || {};

*
* @readonly
* @member {Error}
* @readonly
*/

@@ -428,4 +431,4 @@ this.error = null;

*
* @readonly
* @member {XMLHttpRequest}
* @readonly
*/

@@ -437,4 +440,4 @@ this.xhr = null;

*
* @readonly
* @member {Resource[]}
* @readonly
*/

@@ -446,6 +449,6 @@ this.children = [];

*
* @readonly
* @member {Resource.TYPE}
* @readonly
*/
this.type = Resource$$1.TYPE.UNKNOWN;
this.type = Resource.TYPE.UNKNOWN;

@@ -455,4 +458,4 @@ /**

*
* @readonly
* @member {number}
* @readonly
*/

@@ -479,2 +482,10 @@ this.progressChunk = 0;

/**
* The timer for element loads to check if they timeout.
*
* @private
* @member {number}
*/
this._elementTimer = 0;
/**
* The `complete` function bound to this resource's context.

@@ -503,7 +514,15 @@ *

/**
* The `_onTimeout` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundOnTimeout = this._onTimeout.bind(this);
// xhr callbacks
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._boundXdrOnTimeout = this._xdrOnTimeout.bind(this);

@@ -550,34 +569,46 @@ /**

this.onAfterMiddleware = new _miniSignals2.default();
}
/**
* When the resource starts to load.
*
* @memberof Resource
* @callback OnStartSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* When the resource starts to load.
*
* @memberof Resource
* @callback OnStartSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* When the resource reports loading progress.
*
* @memberof Resource
* @callback OnProgressSignal
* @param {Resource} resource - The resource that the event happened on.
* @param {number} percentage - The progress of the load in the range [0, 1].
*/
/**
* When the resource reports loading progress.
*
* @memberof Resource
* @callback OnProgressSignal
* @param {Resource} resource - The resource that the event happened on.
* @param {number} percentage - The progress of the load in the range [0, 1].
*/
/**
* When the resource finishes loading.
*
* @memberof Resource
* @callback OnCompleteSignal
* @param {Resource} resource - The resource that the event happened on.
*/
}
/**
* When the resource finishes loading.
*
* @memberof Resource
* @callback OnCompleteSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* @memberof Resource
* @typedef {object} IMetadata
* @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The
* element to use for loading, instead of creating one.
* @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources to.
* @property {string|string[]} [mimeType] - The mime type to use for the source element
* of a video/audio elment. If the urls are an array, you can pass this as an array as well
* where each index is the mime type to use for the corresponding url index.
*/
/**
* Stores whether or not this url is a data url.
*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -590,33 +621,5 @@

*/
Resource$$1.prototype.complete = function complete() {
// TODO: Clean this up in a wrapper or something...gross....
if (this.data && this.data.removeEventListener) {
this.data.removeEventListener('error', this._boundOnError, false);
this.data.removeEventListener('load', this._boundComplete, false);
this.data.removeEventListener('progress', this._boundOnProgress, false);
this.data.removeEventListener('canplaythrough', this._boundComplete, false);
}
if (this.xhr) {
if (this.xhr.removeEventListener) {
this.xhr.removeEventListener('error', this._boundXhrOnError, false);
this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);
this.xhr.removeEventListener('progress', this._boundOnProgress, false);
this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);
} else {
this.xhr.onerror = null;
this.xhr.ontimeout = null;
this.xhr.onprogress = null;
this.xhr.onload = null;
}
}
if (this.isComplete) {
throw new Error('Complete called again for an already completed resource.');
}
this._setFlag(Resource$$1.STATUS_FLAGS.COMPLETE, true);
this._setFlag(Resource$$1.STATUS_FLAGS.LOADING, false);
this.onComplete.dispatch(this);
Resource.prototype.complete = function complete() {
this._clearEvents();
this._finish();
};

@@ -631,5 +634,3 @@

Resource$$1.prototype.abort = function abort(message) {
var this$1 = this;
Resource.prototype.abort = function abort(message) {
// abort can be called multiple times, ignore subsequent calls.

@@ -643,2 +644,5 @@ if (this.error) {

// clear events before calling aborts
this._clearEvents();
// abort the actual loading

@@ -652,3 +656,3 @@ if (this.xhr) {

if (this.data.src) {
this.data.src = Resource$$1.EMPTY_GIF;
this.data.src = Resource.EMPTY_GIF;
}

@@ -658,3 +662,3 @@ // multi-source

while (this.data.firstChild) {
this$1.data.removeChild(this$1.data.firstChild);
this.data.removeChild(this.data.firstChild);
}

@@ -665,3 +669,3 @@ }

// done now.
this.complete();
this._finish();
};

@@ -672,7 +676,7 @@

*
* @param {function} [cb] - Optional callback to call once the resource is loaded.
* @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded.
*/
Resource$$1.prototype.load = function load(cb) {
Resource.prototype.load = function load(cb) {
var _this = this;

@@ -696,3 +700,3 @@

this._setFlag(Resource$$1.STATUS_FLAGS.LOADING, true);
this._setFlag(Resource.STATUS_FLAGS.LOADING, true);

@@ -707,18 +711,18 @@ this.onStart.dispatch(this);

switch (this.loadType) {
case Resource$$1.LOAD_TYPE.IMAGE:
this.type = Resource$$1.TYPE.IMAGE;
case Resource.LOAD_TYPE.IMAGE:
this.type = Resource.TYPE.IMAGE;
this._loadElement('image');
break;
case Resource$$1.LOAD_TYPE.AUDIO:
this.type = Resource$$1.TYPE.AUDIO;
case Resource.LOAD_TYPE.AUDIO:
this.type = Resource.TYPE.AUDIO;
this._loadSourceElement('audio');
break;
case Resource$$1.LOAD_TYPE.VIDEO:
this.type = Resource$$1.TYPE.VIDEO;
case Resource.LOAD_TYPE.VIDEO:
this.type = Resource.TYPE.VIDEO;
this._loadSourceElement('video');
break;
case Resource$$1.LOAD_TYPE.XHR:
case Resource.LOAD_TYPE.XHR:
/* falls through */

@@ -744,4 +748,4 @@ default:

Resource$$1.prototype._hasFlag = function _hasFlag(flag) {
return !!(this._flags & flag);
Resource.prototype._hasFlag = function _hasFlag(flag) {
return (this._flags & flag) !== 0;
};

@@ -758,3 +762,3 @@

Resource$$1.prototype._setFlag = function _setFlag(flag, value) {
Resource.prototype._setFlag = function _setFlag(flag, value) {
this._flags = value ? this._flags | flag : this._flags & ~flag;

@@ -764,2 +768,53 @@ };

/**
* Clears all the events from the underlying loading source.
*
* @private
*/
Resource.prototype._clearEvents = function _clearEvents() {
clearTimeout(this._elementTimer);
if (this.data && this.data.removeEventListener) {
this.data.removeEventListener('error', this._boundOnError, false);
this.data.removeEventListener('load', this._boundComplete, false);
this.data.removeEventListener('progress', this._boundOnProgress, false);
this.data.removeEventListener('canplaythrough', this._boundComplete, false);
}
if (this.xhr) {
if (this.xhr.removeEventListener) {
this.xhr.removeEventListener('error', this._boundXhrOnError, false);
this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false);
this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);
this.xhr.removeEventListener('progress', this._boundOnProgress, false);
this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);
} else {
this.xhr.onerror = null;
this.xhr.ontimeout = null;
this.xhr.onprogress = null;
this.xhr.onload = null;
}
}
};
/**
* Finalizes the load.
*
* @private
*/
Resource.prototype._finish = function _finish() {
if (this.isComplete) {
throw new Error('Complete called again for an already completed resource.');
}
this._setFlag(Resource.STATUS_FLAGS.COMPLETE, true);
this._setFlag(Resource.STATUS_FLAGS.LOADING, false);
this.onComplete.dispatch(this);
};
/**
* Loads this resources using an element that has a single source,

@@ -773,3 +828,3 @@ * like an HTMLImageElement.

Resource$$1.prototype._loadElement = function _loadElement(type) {
Resource.prototype._loadElement = function _loadElement(type) {
if (this.metadata.loadElement) {

@@ -794,2 +849,6 @@ this.data = this.metadata.loadElement;

this.data.addEventListener('progress', this._boundOnProgress, false);
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};

@@ -806,5 +865,3 @@

Resource$$1.prototype._loadSourceElement = function _loadSourceElement(type) {
var this$1 = this;
Resource.prototype._loadSourceElement = function _loadSourceElement(type) {
if (this.metadata.loadElement) {

@@ -824,2 +881,6 @@ this.data = this.metadata.loadElement;

if (this.crossOrigin) {
this.data.crossOrigin = this.crossOrigin;
}
if (!this.metadata.skipSource) {

@@ -833,3 +894,3 @@ // support for CocoonJS Canvas+ runtime, lacks document.createElement('source')

for (var i = 0; i < this.url.length; ++i) {
this$1.data.appendChild(this$1._createSource(type, this$1.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));
this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));
}

@@ -849,2 +910,6 @@ } else {

this.data.load();
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};

@@ -859,3 +924,3 @@

Resource$$1.prototype._loadXhr = function _loadXhr() {
Resource.prototype._loadXhr = function _loadXhr() {
// if unset, determine the value

@@ -871,6 +936,8 @@ if (typeof this.xhrType !== 'string') {

xhr.timeout = this.timeout;
// load json as text and parse it ourselves. We do this because some browsers
// *cough* safari *cough* can't deal with it.
if (this.xhrType === Resource$$1.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT) {
xhr.responseType = Resource$$1.XHR_RESPONSE_TYPE.TEXT;
if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) {
xhr.responseType = Resource.XHR_RESPONSE_TYPE.TEXT;
} else {

@@ -881,2 +948,3 @@ xhr.responseType = this.xhrType;

xhr.addEventListener('error', this._boundXhrOnError, false);
xhr.addEventListener('timeout', this._boundXhrOnTimeout, false);
xhr.addEventListener('abort', this._boundXhrOnAbort, false);

@@ -896,3 +964,3 @@ xhr.addEventListener('progress', this._boundOnProgress, false);

Resource$$1.prototype._loadXdr = function _loadXdr() {
Resource.prototype._loadXdr = function _loadXdr() {
// if unset, determine the value

@@ -903,3 +971,3 @@ if (typeof this.xhrType !== 'string') {

var xdr = this.xhr = new XDomainRequest();
var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef

@@ -909,6 +977,6 @@ // XDomainRequest has a few quirks. Occasionally it will abort requests

// More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9
xdr.timeout = 5000;
xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9
xdr.onerror = this._boundXhrOnError;
xdr.ontimeout = this._boundXdrOnTimeout;
xdr.ontimeout = this._boundXhrOnTimeout;
xdr.onprogress = this._boundOnProgress;

@@ -939,3 +1007,3 @@ xdr.onload = this._boundXhrOnLoad;

Resource$$1.prototype._createSource = function _createSource(type, url, mime) {
Resource.prototype._createSource = function _createSource(type, url, mime) {
if (!mime) {

@@ -961,3 +1029,3 @@ mime = type + '/' + this._getExtension(url);

Resource$$1.prototype._onError = function _onError(event) {
Resource.prototype._onError = function _onError(event) {
this.abort('Failed to load element using: ' + event.target.nodeName);

@@ -967,3 +1035,3 @@ };

/**
* Called if a load progress event fires for xhr/xdr.
* Called if a load progress event fires for an element or xhr/xdr.
*

@@ -975,3 +1043,3 @@ * @private

Resource$$1.prototype._onProgress = function _onProgress(event) {
Resource.prototype._onProgress = function _onProgress(event) {
if (event && event.lengthComputable) {

@@ -983,10 +1051,20 @@ this.onProgress.dispatch(this, event.loaded / event.total);

/**
* Called if a timeout event fires for an element.
*
* @private
*/
Resource.prototype._onTimeout = function _onTimeout() {
this.abort('Load timed out.');
};
/**
* Called if an error event fires for xhr/xdr.
*
* @private
* @param {XMLHttpRequestErrorEvent|Event} event - Error event.
*/
Resource$$1.prototype._xhrOnError = function _xhrOnError() {
Resource.prototype._xhrOnError = function _xhrOnError() {
var xhr = this.xhr;

@@ -998,23 +1076,25 @@

/**
* Called if an abort event fires for xhr.
* Called if an error event fires for xhr/xdr.
*
* @private
* @param {XMLHttpRequestAbortEvent} event - Abort Event
*/
Resource$$1.prototype._xhrOnAbort = function _xhrOnAbort() {
this.abort(reqType(this.xhr) + ' Request was aborted by the user.');
Resource.prototype._xhrOnTimeout = function _xhrOnTimeout() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request timed out.');
};
/**
* Called if a timeout event fires for xdr.
* Called if an abort event fires for xhr/xdr.
*
* @private
* @param {Event} event - Timeout event.
*/
Resource$$1.prototype._xdrOnTimeout = function _xdrOnTimeout() {
this.abort(reqType(this.xhr) + ' Request timed out.');
Resource.prototype._xhrOnAbort = function _xhrOnAbort() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request was aborted by the user.');
};

@@ -1030,3 +1110,3 @@

Resource$$1.prototype._xhrOnLoad = function _xhrOnLoad() {
Resource.prototype._xhrOnLoad = function _xhrOnLoad() {
var xhr = this.xhr;

@@ -1043,3 +1123,3 @@ var text = '';

// If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request.
if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource$$1.XHR_RESPONSE_TYPE.BUFFER)) {
if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource.XHR_RESPONSE_TYPE.BUFFER)) {
status = STATUS_OK;

@@ -1056,11 +1136,11 @@ }

// if text, just return it
if (this.xhrType === Resource$$1.XHR_RESPONSE_TYPE.TEXT) {
if (this.xhrType === Resource.XHR_RESPONSE_TYPE.TEXT) {
this.data = text;
this.type = Resource$$1.TYPE.TEXT;
this.type = Resource.TYPE.TEXT;
}
// if json, parse into json object
else if (this.xhrType === Resource$$1.XHR_RESPONSE_TYPE.JSON) {
else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON) {
try {
this.data = JSON.parse(text);
this.type = Resource$$1.TYPE.JSON;
this.type = Resource.TYPE.JSON;
} catch (e) {

@@ -1073,3 +1153,3 @@ this.abort('Error trying to parse loaded json: ' + e);

// if xml, parse into an xml document or div element
else if (this.xhrType === Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT) {
else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) {
try {

@@ -1088,3 +1168,3 @@ if (window.DOMParser) {

this.type = Resource$$1.TYPE.XML;
this.type = Resource.TYPE.XML;
} catch (e) {

@@ -1121,3 +1201,3 @@ this.abort('Error trying to parse loaded xml: ' + e);

Resource$$1.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) {
Resource.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) {
// data: and javascript: urls are considered same-origin

@@ -1128,2 +1208,9 @@ if (url.indexOf('data:') === 0) {

// A sandboxed iframe without the 'allow-same-origin' attribute will have a special
// origin designed not to match window.location.origin, and will always require
// crossOrigin requests regardless of whether the location matches.
if (window.origin !== window.location.origin) {
return 'anonymous';
}
// default is window.location

@@ -1162,4 +1249,4 @@ loc = loc || window.location;

Resource$$1.prototype._determineXhrType = function _determineXhrType() {
return Resource$$1._xhrTypeMap[this.extension] || Resource$$1.XHR_RESPONSE_TYPE.TEXT;
Resource.prototype._determineXhrType = function _determineXhrType() {
return Resource._xhrTypeMap[this.extension] || Resource.XHR_RESPONSE_TYPE.TEXT;
};

@@ -1176,4 +1263,4 @@

Resource$$1.prototype._determineLoadType = function _determineLoadType() {
return Resource$$1._loadTypeMap[this.extension] || Resource$$1.LOAD_TYPE.XHR;
Resource.prototype._determineLoadType = function _determineLoadType() {
return Resource._loadTypeMap[this.extension] || Resource.LOAD_TYPE.XHR;
};

@@ -1189,3 +1276,3 @@

Resource$$1.prototype._getExtension = function _getExtension() {
Resource.prototype._getExtension = function _getExtension() {
var url = this.url;

@@ -1220,29 +1307,28 @@ var ext = '';

Resource$$1.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) {
Resource.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) {
switch (type) {
case Resource$$1.XHR_RESPONSE_TYPE.BUFFER:
case Resource.XHR_RESPONSE_TYPE.BUFFER:
return 'application/octet-binary';
case Resource$$1.XHR_RESPONSE_TYPE.BLOB:
case Resource.XHR_RESPONSE_TYPE.BLOB:
return 'application/blob';
case Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT:
case Resource.XHR_RESPONSE_TYPE.DOCUMENT:
return 'application/xml';
case Resource$$1.XHR_RESPONSE_TYPE.JSON:
case Resource.XHR_RESPONSE_TYPE.JSON:
return 'application/json';
case Resource$$1.XHR_RESPONSE_TYPE.DEFAULT:
case Resource$$1.XHR_RESPONSE_TYPE.TEXT:
case Resource.XHR_RESPONSE_TYPE.DEFAULT:
case Resource.XHR_RESPONSE_TYPE.TEXT:
/* falls through */
default:
return 'text/plain';
}
};
_createClass(Resource$$1, [{
_createClass(Resource, [{
key: 'isDataUrl',
get: function get() {
return this._hasFlag(Resource$$1.STATUS_FLAGS.DATA_URL);
return this._hasFlag(Resource.STATUS_FLAGS.DATA_URL);
}

@@ -1254,4 +1340,4 @@

*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -1262,3 +1348,3 @@

get: function get() {
return this._hasFlag(Resource$$1.STATUS_FLAGS.COMPLETE);
return this._hasFlag(Resource.STATUS_FLAGS.COMPLETE);
}

@@ -1270,4 +1356,4 @@

*
* @readonly
* @member {boolean}
* @readonly
*/

@@ -1278,7 +1364,7 @@

get: function get() {
return this._hasFlag(Resource$$1.STATUS_FLAGS.LOADING);
return this._hasFlag(Resource.STATUS_FLAGS.LOADING);
}
}]);
return Resource$$1;
return Resource;
}();

@@ -1295,4 +1381,3 @@

exports.default = Resource$$1;
Resource$$1.STATUS_FLAGS = {
Resource.STATUS_FLAGS = {
NONE: 0,

@@ -1311,3 +1396,3 @@ DATA_URL: 1 << 0,

*/
Resource$$1.TYPE = {
Resource.TYPE = {
UNKNOWN: 0,

@@ -1329,3 +1414,3 @@ JSON: 1,

*/
Resource$$1.LOAD_TYPE = {
Resource.LOAD_TYPE = {
/** Uses XMLHttpRequest to load the resource. */

@@ -1348,3 +1433,3 @@ XHR: 1,

*/
Resource$$1.XHR_RESPONSE_TYPE = {
Resource.XHR_RESPONSE_TYPE = {
/** string */

@@ -1364,34 +1449,34 @@ DEFAULT: 'text',

Resource$$1._loadTypeMap = {
Resource._loadTypeMap = {
// images
gif: Resource$$1.LOAD_TYPE.IMAGE,
png: Resource$$1.LOAD_TYPE.IMAGE,
bmp: Resource$$1.LOAD_TYPE.IMAGE,
jpg: Resource$$1.LOAD_TYPE.IMAGE,
jpeg: Resource$$1.LOAD_TYPE.IMAGE,
tif: Resource$$1.LOAD_TYPE.IMAGE,
tiff: Resource$$1.LOAD_TYPE.IMAGE,
webp: Resource$$1.LOAD_TYPE.IMAGE,
tga: Resource$$1.LOAD_TYPE.IMAGE,
svg: Resource$$1.LOAD_TYPE.IMAGE,
'svg+xml': Resource$$1.LOAD_TYPE.IMAGE, // for SVG data urls
gif: Resource.LOAD_TYPE.IMAGE,
png: Resource.LOAD_TYPE.IMAGE,
bmp: Resource.LOAD_TYPE.IMAGE,
jpg: Resource.LOAD_TYPE.IMAGE,
jpeg: Resource.LOAD_TYPE.IMAGE,
tif: Resource.LOAD_TYPE.IMAGE,
tiff: Resource.LOAD_TYPE.IMAGE,
webp: Resource.LOAD_TYPE.IMAGE,
tga: Resource.LOAD_TYPE.IMAGE,
svg: Resource.LOAD_TYPE.IMAGE,
'svg+xml': Resource.LOAD_TYPE.IMAGE, // for SVG data urls
// audio
mp3: Resource$$1.LOAD_TYPE.AUDIO,
ogg: Resource$$1.LOAD_TYPE.AUDIO,
wav: Resource$$1.LOAD_TYPE.AUDIO,
mp3: Resource.LOAD_TYPE.AUDIO,
ogg: Resource.LOAD_TYPE.AUDIO,
wav: Resource.LOAD_TYPE.AUDIO,
// videos
mp4: Resource$$1.LOAD_TYPE.VIDEO,
webm: Resource$$1.LOAD_TYPE.VIDEO
mp4: Resource.LOAD_TYPE.VIDEO,
webm: Resource.LOAD_TYPE.VIDEO
};
Resource$$1._xhrTypeMap = {
Resource._xhrTypeMap = {
// xml
xhtml: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
html: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
htm: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
xml: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
tmx: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
svg: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
xhtml: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
html: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
htm: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
xml: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
tmx: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
svg: Resource.XHR_RESPONSE_TYPE.DOCUMENT,

@@ -1401,29 +1486,29 @@ // This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component.

// this should probably be fine.
tsx: Resource$$1.XHR_RESPONSE_TYPE.DOCUMENT,
tsx: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
// images
gif: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
png: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
bmp: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
jpg: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
jpeg: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
tif: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
tiff: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
webp: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
tga: Resource$$1.XHR_RESPONSE_TYPE.BLOB,
gif: Resource.XHR_RESPONSE_TYPE.BLOB,
png: Resource.XHR_RESPONSE_TYPE.BLOB,
bmp: Resource.XHR_RESPONSE_TYPE.BLOB,
jpg: Resource.XHR_RESPONSE_TYPE.BLOB,
jpeg: Resource.XHR_RESPONSE_TYPE.BLOB,
tif: Resource.XHR_RESPONSE_TYPE.BLOB,
tiff: Resource.XHR_RESPONSE_TYPE.BLOB,
webp: Resource.XHR_RESPONSE_TYPE.BLOB,
tga: Resource.XHR_RESPONSE_TYPE.BLOB,
// json
json: Resource$$1.XHR_RESPONSE_TYPE.JSON,
json: Resource.XHR_RESPONSE_TYPE.JSON,
// text
text: Resource$$1.XHR_RESPONSE_TYPE.TEXT,
txt: Resource$$1.XHR_RESPONSE_TYPE.TEXT,
text: Resource.XHR_RESPONSE_TYPE.TEXT,
txt: Resource.XHR_RESPONSE_TYPE.TEXT,
// fonts
ttf: Resource$$1.XHR_RESPONSE_TYPE.BUFFER,
otf: Resource$$1.XHR_RESPONSE_TYPE.BUFFER
ttf: Resource.XHR_RESPONSE_TYPE.BUFFER,
otf: Resource.XHR_RESPONSE_TYPE.BUFFER
};
// We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif
Resource$$1.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
Resource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';

@@ -1462,7 +1547,14 @@ /**

// Backwards compat
{
module.exports.default = Resource; // eslint-disable-line no-undef
}
});
unwrapExports(Resource_1);
var Resource_2 = Resource_1.Resource;
var b64 = createCommonjsModule(function (module, exports) {
exports.__esModule = true;

@@ -1472,2 +1564,8 @@ exports.encodeBinary = encodeBinary;

/**
* Encodes binary into base64.
*
* @param {string} input The input data to encode.
* @returns {string} The encoded base64 string
*/
function encodeBinary(input) {

@@ -1534,2 +1632,7 @@ var output = '';

// Backwards compat
{
module.exports.default = encodeBinary; // eslint-disable-line no-undef
}
});

@@ -1541,6 +1644,4 @@

var blob = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.blobMiddlewareFactory = blobMiddlewareFactory;

@@ -1550,10 +1651,4 @@

var _Resource2 = _interopRequireDefault(Resource_1);
var _b2 = _interopRequireDefault(b64);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Url = window.URL || window.webkitURL;

@@ -1571,3 +1666,3 @@

// if this was an XHR load of a blob
if (resource.xhr && resource.xhrType === _Resource2.default.XHR_RESPONSE_TYPE.BLOB) {
if (resource.xhr && resource.xhrType === Resource_1.Resource.XHR_RESPONSE_TYPE.BLOB) {
// if there is no blob support we probably got a binary string back

@@ -1580,5 +1675,5 @@ if (!window.Blob || typeof resource.data === 'string') {

resource.data = new Image();
resource.data.src = 'data:' + type + ';base64,' + _b2.default.encodeBinary(resource.xhr.responseText);
resource.data.src = 'data:' + type + ';base64,' + (0, b64.encodeBinary)(resource.xhr.responseText);
resource.type = _Resource2.default.TYPE.IMAGE;
resource.type = Resource_1.Resource.TYPE.IMAGE;

@@ -1598,27 +1693,21 @@ // wait until the image loads and then callback

else if (resource.data.type.indexOf('image') === 0) {
var _ret = function () {
var src = Url.createObjectURL(resource.data);
var src = Url.createObjectURL(resource.data);
resource.blob = resource.data;
resource.data = new Image();
resource.data.src = src;
resource.blob = resource.data;
resource.data = new Image();
resource.data.src = src;
resource.type = _Resource2.default.TYPE.IMAGE;
resource.type = Resource_1.Resource.TYPE.IMAGE;
// cleanup the no longer used blob after the image loads
// TODO: Is this correct? Will the image be invalid after revoking?
resource.data.onload = function () {
Url.revokeObjectURL(src);
resource.data.onload = null;
// cleanup the no longer used blob after the image loads
// TODO: Is this correct? Will the image be invalid after revoking?
resource.data.onload = function () {
Url.revokeObjectURL(src);
resource.data.onload = null;
next();
};
next();
};
// next will be called on load.
return {
v: void 0
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") { return _ret.v; }
// next will be called on load.
return;
}

@@ -1640,3 +1729,3 @@ }

* @memberof PIXI
* @extends PIXI.Loader~LoaderPlugin
* @implements PIXI.ILoaderPlugin
*/

@@ -1660,3 +1749,2 @@ var TextureLoader = function TextureLoader () {};

/**
*
* The new loader, extends Resource Loader by Chad Engler: https://github.com/englercj/resource-loader

@@ -1708,3 +1796,2 @@ *

* @class Loader
* @extends module:resource-loader.ResourceLoader
* @memberof PIXI

@@ -1714,3 +1801,3 @@ * @param {string} [baseUrl=''] - The base url for all resources loaded by this loader.

*/
var Loader = (function (ResourceLoader$$1) {
var Loader = /*@__PURE__*/(function (ResourceLoader$$1) {
function Loader(baseUrl, concurrency)

@@ -1731,3 +1818,3 @@ {

{
this$1.pre(pre);
this.pre(pre);
}

@@ -1737,3 +1824,3 @@

{
this$1.use(use);
this.use(use);
}

@@ -1766,2 +1853,3 @@ }

* Destroy the loader, removes references.
* @private
*/

@@ -1810,3 +1898,3 @@ Loader.prototype.destroy = function destroy ()

* @static
* @member {Array<PIXI.Loader~LoaderPlugin>}
* @member {Array<PIXI.ILoaderPlugin>} _plugins
* @memberof PIXI.Loader

@@ -1824,3 +1912,3 @@ * @private

* @memberof PIXI.Loader
* @param {PIXI.Loader~LoaderPlugin} plugin - The plugin to add
* @param {PIXI.ILoaderPlugin} plugin - The plugin to add
* @return {PIXI.Loader} Reference to PIXI.Loader for chaining

@@ -1848,7 +1936,9 @@ */

* Plugin to be installed for handling specific Loader resources.
* @typedef {object} PIXI.Loader~LoaderPlugin
* @property {function} [plugin.add] - Function to call immediate after registering plugin.
* @property {PIXI.Loader~loaderMiddleware} [plugin.pre] - Middleware function to run before load, the
*
* @memberof PIXI
* @typedef ILoaderPlugin
* @property {function} [add] - Function to call immediate after registering plugin.
* @property {PIXI.Loader.loaderMiddleware} [pre] - Middleware function to run before load, the
* arguments for this are `(resource, next)`
* @property {PIXI.Loader~loaderMiddleware} [plugin.use] - Middleware function to run after load, the
* @property {PIXI.Loader.loaderMiddleware} [use] - Middleware function to run after load, the
* arguments for this are `(resource, next)`

@@ -1858,3 +1948,4 @@ */

/**
* @callback PIXI.Loader~loaderMiddleware
* @memberof PIXI.Loader
* @callback loaderMiddleware
* @param {PIXI.LoaderResource} resource

@@ -1868,11 +1959,11 @@ * @param {function} next

* @example
* import {LoaderPlugin} from '@pixi/loaders';
* import {AppLoaderPlugin} from '@pixi/loaders';
* import {Application} from '@pixi/app';
* Application.registerPlugin(LoaderPlugin);
* Application.registerPlugin(AppLoaderPlugin);
* @class
* @memberof PIXI
*/
var LoaderPlugin = function LoaderPlugin () {};
var AppLoaderPlugin = function AppLoaderPlugin () {};
LoaderPlugin.init = function init (options)
AppLoaderPlugin.init = function init (options)
{

@@ -1896,3 +1987,3 @@ options = Object.assign({

*/
LoaderPlugin.destroy = function destroy ()
AppLoaderPlugin.destroy = function destroy ()
{

@@ -1918,3 +2009,3 @@ if (this.loader)

exports.TextureLoader = TextureLoader;
exports.LoaderPlugin = LoaderPlugin;
exports.AppLoaderPlugin = AppLoaderPlugin;
//# sourceMappingURL=loaders.js.map
{
"name": "@pixi/loaders",
"version": "5.0.0-alpha.3",
"version": "5.0.0-rc",
"main": "lib/loaders.js",
"module": "lib/loaders.es.js",
"description": "Support for legacy browser JavaScript environments",
"description": "Load assets and resources",
"author": "Mat Groves",

@@ -28,10 +28,11 @@ "contributors": [

"dependencies": {
"@pixi/core": "^5.0.0-alpha.3",
"@pixi/utils": "^5.0.0-alpha.3",
"@pixi/core": "^5.0.0-rc",
"@pixi/utils": "^5.0.0-rc",
"eventemitter3": "^2.0.0",
"resource-loader": "^2.1.1"
"resource-loader": "^2.2.3"
},
"devDependencies": {
"floss": "^2.1.3"
}
"floss": "^2.1.5"
},
"gitHead": "9026a1bbca9a9d86b7a3b6d5eb4fa2c3145c2b85"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc