{"version":3,"file":"resource-loader.js","sources":["../node_modules/type-signals/dist/type-signals.esm.js","../src/load_strategies/AbstractLoadStrategy.ts","../src/utilities.ts","../src/resource_type.ts","../src/load_strategies/MediaElementLoadStrategy.ts","../src/load_strategies/AudioLoadStrategy.ts","../src/load_strategies/ImageLoadStrategy.ts","../src/load_strategies/VideoLoadStrategy.ts","../src/load_strategies/XhrLoadStrategy.ts","../node_modules/parse-uri/index.js","../src/async/AsyncQueue.ts","../src/Resource.ts","../src/async/eachSeries.ts","../src/Loader.ts","../src/bundle.ts"],"sourcesContent":["/*!\n * type-signals - v1.0.3\n * https://github.com/englercj/type-signals\n * Compiled Sun, 15 Sep 2019 20:21:49 UTC\n *\n * type-signals is licensed under the MIT license.\n * http://www.opensource.org/licenses/mit-license\n */\nvar SignalBinding = (function () {\r\n function SignalBinding(fn, once, thisArg) {\r\n if (once === void 0) { once = false; }\r\n this.next = null;\r\n this.prev = null;\r\n this.owner = null;\r\n this.fn = fn;\r\n this.once = once;\r\n this.thisArg = thisArg;\r\n }\r\n SignalBinding.prototype.detach = function () {\r\n if (this.owner === null)\r\n return false;\r\n this.owner.detach(this);\r\n return true;\r\n };\r\n SignalBinding.prototype.dispose = function () {\r\n this.detach();\r\n };\r\n return SignalBinding;\r\n}());\r\nvar Signal = (function () {\r\n function Signal() {\r\n this._head = null;\r\n this._tail = null;\r\n this._filter = null;\r\n }\r\n Signal.prototype.handlers = function () {\r\n var node = this._head;\r\n var handlers = [];\r\n while (node) {\r\n handlers.push(node);\r\n node = node.next;\r\n }\r\n return handlers;\r\n };\r\n Signal.prototype.hasAny = function () {\r\n return !!this._head;\r\n };\r\n Signal.prototype.has = function (node) {\r\n return node.owner === this;\r\n };\r\n Signal.prototype.dispatch = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var node = this._head;\r\n if (!node)\r\n return false;\r\n if (this._filter && !this._filter.apply(this, args))\r\n return false;\r\n while (node) {\r\n if (node.once)\r\n this.detach(node);\r\n node.fn.apply(node.thisArg, args);\r\n node = node.next;\r\n }\r\n return true;\r\n };\r\n Signal.prototype.add = function (fn, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return this._addMiniSignalBinding(new SignalBinding(fn, false, thisArg));\r\n };\r\n Signal.prototype.once = function (fn, thisArg) {\r\n if (thisArg === void 0) { thisArg = null; }\r\n return this._addMiniSignalBinding(new SignalBinding(fn, true, thisArg));\r\n };\r\n Signal.prototype.detach = function (node) {\r\n if (node.owner !== this)\r\n return this;\r\n if (node.prev)\r\n node.prev.next = node.next;\r\n if (node.next)\r\n node.next.prev = node.prev;\r\n if (node === this._head) {\r\n this._head = node.next;\r\n if (node.next === null) {\r\n this._tail = null;\r\n }\r\n }\r\n else if (node === this._tail) {\r\n this._tail = node.prev;\r\n if (this._tail)\r\n this._tail.next = null;\r\n }\r\n node.owner = null;\r\n return this;\r\n };\r\n Signal.prototype.detachAll = function () {\r\n var node = this._head;\r\n if (!node)\r\n return this;\r\n this._head = null;\r\n this._tail = null;\r\n while (node) {\r\n node.owner = null;\r\n node = node.next;\r\n }\r\n return this;\r\n };\r\n Signal.prototype.filter = function (filter) {\r\n this._filter = filter;\r\n };\r\n Signal.prototype.proxy = function () {\r\n var _this = this;\r\n var signals = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n signals[_i] = arguments[_i];\r\n }\r\n var fn = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return _this.dispatch.apply(_this, args);\r\n };\r\n for (var i = 0; i < signals.length; ++i) {\r\n signals[i].add(fn);\r\n }\r\n return this;\r\n };\r\n Signal.prototype._addMiniSignalBinding = function (node) {\r\n if (!this._head) {\r\n this._head = node;\r\n this._tail = node;\r\n }\r\n else {\r\n if (this._tail)\r\n this._tail.next = node;\r\n node.prev = this._tail;\r\n this._tail = node;\r\n }\r\n node.owner = this;\r\n return node;\r\n };\r\n return Signal;\r\n}());\n\nexport { Signal, SignalBinding };\n//# sourceMappingURL=type-signals.esm.js.map\n","import { Signal } from 'type-signals';\nimport { ResourceType } from '../resource_type';\n\nexport interface ILoadConfig\n{\n // The url for this resource, relative to the baseUrl of this loader.\n url: string;\n\n // A base url to use for just this resource load. This can be passed in\n // as the base url for a subresource if desired.\n baseUrl?: string;\n\n // String to use for crossOrigin properties on load elements.\n crossOrigin?: string;\n\n // The time to wait in milliseconds before considering the load a failure.\n timeout?: number;\n}\n\n/**\n * @category Type Aliases\n */\nexport namespace AbstractLoadStrategy\n{\n export type OnErrorSignal = (errMessage: string) => void;\n export type OnCompleteSignal = (type: ResourceType, data: any) => void;\n export type OnProgressSignal = (percent: number) => void;\n}\n\n/**\n * Base load strategy interface that all custom load strategies\n * are expected to inherit from and implement.\n * @preferred\n */\nexport abstract class AbstractLoadStrategy\n{\n /**\n * Dispatched when the resource fails to load.\n */\n readonly onError: Signal = new Signal();\n\n /**\n * Dispatched once this resource has loaded, if there was an error it will\n * be in the `error` property.\n */\n readonly onComplete: Signal = new Signal();\n\n /**\n * Dispatched each time progress of this resource load updates.\n * Not all resources types and loader systems can support this event\n * so sometimes it may not be available. If the resource\n * is being loaded on a modern browser, using XHR, and the remote server\n * properly sets Content-Length headers, then this will be available.\n */\n readonly onProgress: Signal = new Signal();\n\n constructor(readonly config: C)\n { }\n\n /**\n * Load the resource described by `config`.\n */\n abstract load(): void;\n\n /**\n * Abort the loading of the resource.\n */\n abstract abort(): void;\n}\n\nexport type AbstractLoadStrategyCtor =\n new (config: C) => AbstractLoadStrategy;\n","export type Overwrite = {\n [P in Exclude]: T1[P]\n} & T2;\n\n/**\n * Extracts the extension (sans '.') of the file being loaded by the resource.\n */\nexport function getExtension(url: string)\n{\n const isDataUrl = url.indexOf('data:') === 0;\n let ext = '';\n\n if (isDataUrl)\n {\n const slashIndex = url.indexOf('/');\n\n ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex));\n }\n else\n {\n const queryStart = url.indexOf('?');\n const hashStart = url.indexOf('#');\n const index = Math.min(\n queryStart > -1 ? queryStart : url.length,\n hashStart > -1 ? hashStart : url.length\n );\n\n url = url.substring(0, index);\n ext = url.substring(url.lastIndexOf('.') + 1);\n }\n\n return ext.toLowerCase();\n}\n\nexport function assertNever(x: never): never\n{\n throw new Error('Unexpected value. Should have been never.');\n}\n","/**\n * Describes the type of data the Resource holds.\n */\nexport enum ResourceType\n{\n /** The resource data type is unknown. */\n Unknown,\n /** The resource data is an ArrayBuffer. */\n Buffer,\n /** The resource data is a Blob. */\n Blob,\n /** The resource data is a parsed JSON Object. */\n Json,\n /** The resource data is a Document or
element representing parsed XML. */\n Xml,\n /** The resource data is an element. */\n Image,\n /** The resource data is an