async-preloader
Advanced tools
Comparing version 4.5.0 to 4.6.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var LoaderKey,tslib_1=require("tslib"),FontFaceObserver=require("fontfaceobserver-es");!function(e){e.Json="Json",e.ArrayBuffer="ArrayBuffer",e.Blob="Blob",e.FormData="FormData",e.Text="Text",e.Image="Image",e.Video="Video",e.Audio="Audio",e.Xml="Xml",e.Font="Font"}(LoaderKey||(LoaderKey={}));var isSafari=navigator&&-1<navigator.userAgent.indexOf("Safari"),AsyncPreloader=function(){function o(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=LoaderKey.Text,this.loadItems=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(n){return tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return t=o.getFileExtension(n.src),[4,this["load"+(n.loader||o.getLoaderKey(t))](n)];case 1:return r=e.sent(),this.items.set(n.id||n.src,r),[2,r]}})})},this.loadManifest=function(n,i){return void 0===i&&(i="items"),tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:n})];case 1:return t=e.sent(),r=o.getProp(t,i),[4,this.loadItems(r)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:(i=new Image,[4,new Promise(function(t,r){i.addEventListener("load",function e(){i.removeEventListener("load",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)}),i.src=URL.createObjectURL(n)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:(i=document.createElement("video"),[4,new Promise(function(t,r){i.addEventListener("canplaythrough",function e(){i.removeEventListener("canplaythrough",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)});try{if(isSafari)throw"";i.srcObject=n}catch(e){i.src=URL.createObjectURL(n)}i.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:((i=document.createElement("audio")).autoplay=!1,i.preload="auto",[4,new Promise(function(t,r){i.addEventListener("canplaythrough",function e(){i.removeEventListener("canplaythrough",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)});try{if(isSafari)throw"";i.srcObject=n}catch(e){i.src=URL.createObjectURL(n)}i.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(n){return tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return n.mimeType||(t=o.getFileExtension(n.src),n=tslib_1.__assign({},n,{mimeType:o.getMimeType(LoaderKey.Xml,t)})),[4,o.fetchItem(n)];case 1:return[4,e.sent().text()];case 2:return r=e.sent(),[2,o.domParser.parseFromString(r,n.mimeType)]}})})},this.loadFont=function(r){return tslib_1.__awaiter(e,void 0,void 0,function(){var t;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return t=r.id,[4,new FontFaceObserver(t,r.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return o.fetchItem=function(e){return fetch(e.src,e.options||{})},o.getProp=function(e,t){var r=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return r.length?o.getProp(e[r.shift()],r):e},o.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},o.getLoaderKey=function(t){var e=Array.from(o.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:LoaderKey.Text},o.getMimeType=function(e,t){var r=o.loaders.get(e);return r.mimeType[t]||r.defaultMimeType},o.loaders=(new Map).set(LoaderKey.Text,{extensions:["txt"]}).set(LoaderKey.Json,{extensions:["json"]}).set(LoaderKey.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(LoaderKey.Video,{extensions:["webm","ogg","mp4"]}).set(LoaderKey.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(LoaderKey.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"application/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"xml"}).set(LoaderKey.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),o.domParser=new DOMParser,o}(),AsyncPreloaderInstance=new AsyncPreloader;exports.AsyncPreloader=AsyncPreloader,exports.default=AsyncPreloaderInstance; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var LoaderKey,tslib_1=require("tslib"),FontFaceObserver=require("fontfaceobserver-es");!function(e){e.Json="Json",e.ArrayBuffer="ArrayBuffer",e.Blob="Blob",e.FormData="FormData",e.Text="Text",e.Image="Image",e.Video="Video",e.Audio="Audio",e.Xml="Xml",e.Font="Font"}(LoaderKey||(LoaderKey={}));var isSafari=navigator&&-1<navigator.userAgent.indexOf("Safari"),AsyncPreloader=function(){function o(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=LoaderKey.Text,this.loadItems=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(n){return tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return t=o.getFileExtension(n.src),[4,this["load"+(n.loader||o.getLoaderKey(t))](n)];case 1:return r=e.sent(),this.items.set(n.id||n.src,r),[2,r]}})})},this.loadManifest=function(n,i){return void 0===i&&(i="items"),tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:n})];case 1:return t=e.sent(),r=o.getProp(t,i),[4,this.loadItems(r)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:(i=new Image,[4,new Promise(function(t,r){i.addEventListener("load",function e(){i.removeEventListener("load",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)}),i.src=URL.createObjectURL(n)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:(i=document.createElement("video"),[4,new Promise(function(t,r){i.addEventListener("canplaythrough",function e(){i.removeEventListener("canplaythrough",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)});try{if(isSafari)throw"";i.srcObject=n}catch(e){i.src=URL.createObjectURL(n)}i.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return tslib_1.__awaiter(e,void 0,void 0,function(){var n,i;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return[4,o.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return n=e.sent(),t.body?[2,n]:((i=document.createElement("audio")).autoplay=!1,i.preload="auto",[4,new Promise(function(t,r){i.addEventListener("canplaythrough",function e(){i.removeEventListener("canplaythrough",e),t(i)}),i.addEventListener("error",function e(){i.removeEventListener("error",e),r(i)});try{if(isSafari)throw"";i.srcObject=n}catch(e){i.src=URL.createObjectURL(n)}i.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(n){return tslib_1.__awaiter(e,void 0,void 0,function(){var t,r;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return n.mimeType||(t=o.getFileExtension(n.src),n=tslib_1.__assign({},n,{mimeType:o.getMimeType(LoaderKey.Xml,t)})),[4,o.fetchItem(n)];case 1:return[4,e.sent().text()];case 2:return r=e.sent(),[2,o.domParser.parseFromString(r,n.mimeType)]}})})},this.loadFont=function(r){return tslib_1.__awaiter(e,void 0,void 0,function(){var t;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return t=r.id,[4,new FontFaceObserver(t,r.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return o.fetchItem=function(e){return fetch(e.src,e.options||{})},o.getProp=function(e,t){var r=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return r.length?o.getProp(e[r.shift()],r):e},o.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},o.getLoaderKey=function(t){var e=Array.from(o.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:LoaderKey.Text},o.getMimeType=function(e,t){var r=o.loaders.get(e);return r.mimeType[t]||r.defaultMimeType},o.loaders=(new Map).set(LoaderKey.Text,{extensions:["txt"]}).set(LoaderKey.Json,{extensions:["json"]}).set(LoaderKey.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(LoaderKey.Video,{extensions:["webm","ogg","mp4"]}).set(LoaderKey.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(LoaderKey.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"text/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"text/xml"}).set(LoaderKey.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),o.domParser=new DOMParser,o}(),AsyncPreloaderInstance=new AsyncPreloader;exports.AsyncPreloader=AsyncPreloader,exports.default=AsyncPreloaderInstance; |
@@ -463,7 +463,7 @@ import { __awaiter, __generator, __assign } from 'tslib'; | ||
mimeType: { | ||
xml: "application/xml", | ||
xml: "text/xml", | ||
svg: "image/svg+xml", | ||
html: "text/html" | ||
}, | ||
defaultMimeType: "xml" | ||
defaultMimeType: "text/xml" | ||
}) | ||
@@ -470,0 +470,0 @@ .set(LoaderKey.Font, { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("fontfaceobserver-es")):"function"==typeof define&&define.amd?define(["exports","tslib","fontfaceobserver-es"],t):t((e=e||self).AsyncPreloader={},e.tslib,e.FontFaceObserver)}(this,function(e,s,r){"use strict";var o,t;(t=o||(o={})).Json="Json",t.ArrayBuffer="ArrayBuffer",t.Blob="Blob",t.FormData="FormData",t.Text="Text",t.Image="Image",t.Video="Video",t.Audio="Audio",t.Xml="Xml",t.Font="Font";var a=navigator&&-1<navigator.userAgent.indexOf("Safari"),n=function(){function i(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=o.Text,this.loadItems=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return t=i.getFileExtension(r.src),[4,this["load"+(r.loader||i.getLoaderKey(t))](r)];case 1:return n=e.sent(),this.items.set(r.id||r.src,n),[2,n]}})})},this.loadManifest=function(r,o){return void 0===o&&(o="items"),s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:r})];case 1:return t=e.sent(),n=i.getProp(t,o),[4,this.loadItems(n)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=new Image,[4,new Promise(function(t,n){o.addEventListener("load",function e(){o.removeEventListener("load",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)}),o.src=URL.createObjectURL(r)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=document.createElement("video"),[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{if(a)throw"";o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:((o=document.createElement("audio")).autoplay=!1,o.preload="auto",[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{if(a)throw"";o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return r.mimeType||(t=i.getFileExtension(r.src),r=s.__assign({},r,{mimeType:i.getMimeType(o.Xml,t)})),[4,i.fetchItem(r)];case 1:return[4,e.sent().text()];case 2:return n=e.sent(),[2,i.domParser.parseFromString(n,r.mimeType)]}})})},this.loadFont=function(n){return s.__awaiter(e,void 0,void 0,function(){var t;return s.__generator(this,function(e){switch(e.label){case 0:return t=n.id,[4,new r(t,n.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return i.fetchItem=function(e){return fetch(e.src,e.options||{})},i.getProp=function(e,t){var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?i.getProp(e[n.shift()],n):e},i.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},i.getLoaderKey=function(t){var e=Array.from(i.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:o.Text},i.getMimeType=function(e,t){var n=i.loaders.get(e);return n.mimeType[t]||n.defaultMimeType},i.loaders=(new Map).set(o.Text,{extensions:["txt"]}).set(o.Json,{extensions:["json"]}).set(o.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(o.Video,{extensions:["webm","ogg","mp4"]}).set(o.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(o.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"application/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"xml"}).set(o.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),i.domParser=new DOMParser,i}(),i=new n;e.AsyncPreloader=n,e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("fontfaceobserver-es")):"function"==typeof define&&define.amd?define(["exports","tslib","fontfaceobserver-es"],t):t((e=e||self).AsyncPreloader={},e.tslib,e.FontFaceObserver)}(this,function(e,s,r){"use strict";var o,t;(t=o||(o={})).Json="Json",t.ArrayBuffer="ArrayBuffer",t.Blob="Blob",t.FormData="FormData",t.Text="Text",t.Image="Image",t.Video="Video",t.Audio="Audio",t.Xml="Xml",t.Font="Font";var a=navigator&&-1<navigator.userAgent.indexOf("Safari"),n=function(){function i(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=o.Text,this.loadItems=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return t=i.getFileExtension(r.src),[4,this["load"+(r.loader||i.getLoaderKey(t))](r)];case 1:return n=e.sent(),this.items.set(r.id||r.src,n),[2,n]}})})},this.loadManifest=function(r,o){return void 0===o&&(o="items"),s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:r})];case 1:return t=e.sent(),n=i.getProp(t,o),[4,this.loadItems(n)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=new Image,[4,new Promise(function(t,n){o.addEventListener("load",function e(){o.removeEventListener("load",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)}),o.src=URL.createObjectURL(r)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=document.createElement("video"),[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{if(a)throw"";o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:((o=document.createElement("audio")).autoplay=!1,o.preload="auto",[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{if(a)throw"";o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return r.mimeType||(t=i.getFileExtension(r.src),r=s.__assign({},r,{mimeType:i.getMimeType(o.Xml,t)})),[4,i.fetchItem(r)];case 1:return[4,e.sent().text()];case 2:return n=e.sent(),[2,i.domParser.parseFromString(n,r.mimeType)]}})})},this.loadFont=function(n){return s.__awaiter(e,void 0,void 0,function(){var t;return s.__generator(this,function(e){switch(e.label){case 0:return t=n.id,[4,new r(t,n.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return i.fetchItem=function(e){return fetch(e.src,e.options||{})},i.getProp=function(e,t){var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?i.getProp(e[n.shift()],n):e},i.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},i.getLoaderKey=function(t){var e=Array.from(i.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:o.Text},i.getMimeType=function(e,t){var n=i.loaders.get(e);return n.mimeType[t]||n.defaultMimeType},i.loaders=(new Map).set(o.Text,{extensions:["txt"]}).set(o.Json,{extensions:["json"]}).set(o.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(o.Video,{extensions:["webm","ogg","mp4"]}).set(o.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(o.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"text/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"text/xml"}).set(o.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),i.domParser=new DOMParser,i}(),i=new n;e.AsyncPreloader=n,e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "async-preloader", | ||
"version": "4.5.0", | ||
"version": "4.6.0", | ||
"description": "Assets preloader using ES2017 async/await and fetch.", | ||
@@ -65,17 +65,17 @@ "main": "lib/async-preloader.cjs.js", | ||
"devDependencies": { | ||
"@types/jest": "^24.0.0", | ||
"@types/node": "^11.9.0", | ||
"jest": "^23.6.0", | ||
"jsdom": "^13.1.0", | ||
"jsdom": "^14.0.0", | ||
"jest": "^24.5.0", | ||
"@types/jest": "^24.0.11", | ||
"@types/node": "^11.11.3", | ||
"node-fetch": "^2.3.0", | ||
"prettier": "^1.15.3", | ||
"rollup": "^1.1.1", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-typescript2": "^0.19.2", | ||
"rollup-plugin-uglify": "^6.0.1", | ||
"prettier": "^1.16.4", | ||
"rollup": "^1.6.0", | ||
"rollup-plugin-commonjs": "^9.2.1", | ||
"rollup-plugin-node-resolve": "^4.0.1", | ||
"rollup-plugin-typescript2": "^0.20.1", | ||
"rollup-plugin-uglify": "^6.0.2", | ||
"ts-jest": "^24.0.0", | ||
"tslint": "^5.12.1", | ||
"tslint": "^5.14.0", | ||
"typedoc": "^0.14.2", | ||
"typescript": "^3.2.4", | ||
"typescript": "^3.3.3333", | ||
"xmldom": "^0.1.27" | ||
@@ -82,0 +82,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59211
9
4