@loaders.gl/images
Advanced tools
Comparing version 2.0.0-beta.4 to 2.0.0-beta.5
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return o}));const i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},a=i.global||i.self||i.window,o="object"!=typeof r||"[object process]"!==String(r)||r.browser,u=void 0!==r&&r.version&&r.version.match(/v([0-9]*)/);u&&parseFloat(u[1])}).call(this,n(1),n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const r=n(4),i="undefined"==typeof window?t:window;i.loaders=i.loaders||{},e.exports=Object.assign(i.loaders,r)}).call(this,n(1))},function(e,t){var n,r,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var c,s=[],f=!1,g=-1;function d(){f&&c&&(f=!1,c.length?s=c.concat(s):g=-1,s.length&&m())}function m(){if(!f){var e=u(d);f=!0;for(var t=s.length;t;){for(c=s,s=[];++g<t;)c&&c[g].run();g=-1,t=s.length}c=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function l(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new l(e,t)),1!==s.length||f||u(m)},l.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";function r(e,t){if(!e)throw new Error(t)}n.r(t);var i=n(0);const a="undefined"!=typeof ImageBitmap,o=void 0!==typeof Image,u=Boolean(i.a._parseImageNode);function c(e){switch(e){case"imagebitmap":return a;case"html":return o;case"ndarray":return u;default:throw new Error(`Unknown image format ${e}`)}}function s(){if(c("ndarray"))return"ndarray";if(c("html"))return"html";if(c("imagebitmap"))return"imagebitmap";if(!i.b)throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");return r(!1)}const f=!1,g=!0,d=new Map([["image/png",{test:m,getSize:function(e){return{width:e.getUint32(16,f),height:e.getUint32(20,f)}}}],["image/jpeg",{test:w,getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,f))return null;const{tableMarkers:t,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const i=e.getUint16(r,f);if(n.has(i))return{height:e.getUint16(r+5,f),width:e.getUint16(r+7,f)};if(!t.has(i))return null;r+=2,r+=e.getUint16(r,f)}return null}}],["image/gif",{test:l,getSize:function(e){return{width:e.getUint16(6,g),height:e.getUint16(8,g)}}}],["image/bmp",{test:p,getSize:function(e){return{width:e.getUint32(18,g),height:e.getUint32(22,g)}}}]]);function m(e){return e.byteLength>=24&&2303741511===e.getUint32(0,f)}function l(e){return e.byteLength>=10&&1195984440===e.getUint32(0,f)}function p(e){return e.byteLength>=2&&16973===e.getUint16(0,f)}function w(e){return e.byteLength>=3&&65496===e.getUint16(0,f)&&255===e.getUint8(2,f)}const h=`Invalid MIME type. Supported MIME types are: ${Array.from(d.keys()).join(", ")}`;function y(e,t){if(t){const{test:n}=I(t);return n(x(e))}return Boolean(b(e))}function b(e){const t=x(e);for(const[e,{test:n}]of d.entries())if(n(t))return e;return null}function v(e,t=null){t=t||b(e);const{getSize:n}=I(t),r=n(x(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}function I(e){const t=d.get(e);if(!t)throw new Error(h);return t}function x(e){if((e=e.buffer||e)instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}async function T(e,t){const n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((t,r)=>{try{n.onload=()=>t(n),n.onerror=t=>r(new Error(`Could not load image ${e}: ${t}`))}catch(e){r(e)}})}async function j(e,t){const n=(new TextDecoder).decode(e),r=`data:image/svg+xml;base64,${btoa(n)}`;return await T(r,t)}async function L(e,t,n){"image"in t&&(t={...t,image:{}});const{url:a}=n||{};if(a&&/\.svg((\?|#).*)?$/.test(a))return console.warn("@loaders.gl/images: SVG parsing needs to be fixed for 2.0"),await j(e,t);switch(function(e={}){const t=(e.image||{}).type||"auto";switch(t){case"imagebitmap":case"html":case"ndarray":if(!c(t))throw new Error(`Requested image type ${t} not available in current environment`);return t;case"auto":return s();default:throw new Error(`Unknown image format ${t}`)}}(t)){case"imagebitmap":return await function(e,t){const n=new Blob([new Uint8Array(e)]),r=t&&t.imagebitmap;return r?createImageBitmap(n):createImageBitmap(n,r)}(e,t);case"html":return await async function(e,t){const n=new Blob([e],{type:"image/jpeg"}),r=self.URL||self.webkitURL,i=r.createObjectURL(n);try{return await T(i,t)}finally{r.revokeObjectURL(i)}}(e,t);case"ndarray":return await function(e,t){r(i.a._parseImageNode);const n=b(e);return i.a._parseImageNode(e,n,t)}(e,t);default:return r(!1)}}var U={name:"Images",version:"2.0.0-beta.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vndmicrosofticon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:L,test:e=>{const t=new DataView(e);return w(t)||p(t)||l(t)||m(t)},options:{images:{format:"auto",decodeHTML:!0}}};var E={name:"Images",extensions:["jpeg"],encode:function(e,t){if(i.a._encodeImageNode)return i.a._encodeImageNode(e,t);if(e instanceof HTMLCanvasElement){return e.toDataURL(t)}r(e instanceof Image,"getImageData accepts image or canvas");const n=document.createElement("canvas");n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0);const a=n.toDataURL(t||"png").replace(/^data:image\/(png|jpg);base64,/,"");return Promise.resolve(a)},DEFAULT_OPTIONS:{type:"png"}};function M(e){return Boolean(_(e))}function S(e){const t=_(e);if(!t)throw new Error("Not an image");return t}function B(e){switch(S(e)){case"imagebitmap":case"ndarray":return{width:e.width,height:e.height};case"html":return{width:e.naturalWidth,height:e.naturalHeight};default:return r(!1)}}function P(e){switch(S(e)){case"imagebitmap":case"html":const t=document.createElement("canvas").getContext("2d");return t.drawImage(e,0,0),t.getImageData(0,0,e.width,e.height).data;case"ndarray":return e.data;default:return r(!1)}}function _(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"html":e&&"object"==typeof e&&e.data&&e.width&&e.height?"ndarray":Array.isArray(e)?"ndarray":null}function D(e,t,n){let i=e;"function"==typeof e&&(i=e({...t,...n})),r("string"==typeof i);const{baseUrl:a}=t;return a&&(i="/"===a[a.length-1]?`${a}${i}`:`${a}/${i}`),i}const O=e=>e&&"object"==typeof e;async function $(e,t,n){if(Array.isArray(e))return await async function(e,t,n={}){const r=e.map(e=>$(e,t,n));return await Promise.all(r)}(e,t,n);if(O(e))return await async function(e,t,n){const r=[],i={};for(const a in e){const o=$(e[a],t,n).then(e=>{i[a]=e});r.push(o)}return await Promise.all(r),i}(e,t,n);const r=e;return await t(r,n)}async function k(e,t,n){return await async function(e,t,n={}){return await $(e,t,n)}(e,e=>A(e,t,n))}async function A(e,t,n){const r=await fetch(e,n.fetch),i=await r.arrayBuffer();return await t(i,n)}async function V(e,t={}){const n=await N(e,t);return await k(n,L,t)}async function N(e,t,n={}){const i=t&&t.image&&t.image.mipLevels||0;return 0!==i?await async function(e,t,n,i){const a=[];if("auto"===t){const r=D(e,n,{...i,lod:0}),o=await A(r,L,n),{width:u,height:c}=B(o);t=function({width:e,height:t}){return 1+Math.floor(Math.log2(Math.max(e,t)))}({width:u,height:c}),a.push(r)}r(t>0);for(let r=a.length;r<t;++r){const t=D(e,n,{...i,lod:r});a.push(t)}return a}(e,i,t,n):D(e,t,n)}async function z(e,t,n={}){const r=await async function(e,t,n={}){const r=[];for(let i=0;i<e;i++){const e=N(t,n,{index:i});r.push(e)}return await Promise.all(r)}(e,t,n);return await k(r,L,n)}const G=[{face:34069,direction:"right",axis:"x",sign:"positive"},{face:34070,direction:"left",axis:"x",sign:"negative"},{face:34071,direction:"top",axis:"y",sign:"positive"},{face:34072,direction:"bottom",axis:"y",sign:"negative"},{face:34073,direction:"front",axis:"z",sign:"positive"},{face:34074,direction:"back",axis:"z",sign:"negative"}];async function R(e,t={}){const n=await async function(e,t){const n={},r=[];let i=0;for(const a in G){const o=N(e,t,{...G[i],index:i++}).then(e=>{n[a]=e});r.push(o)}return await Promise.all(r),n}(e,t);return await k(n,L,t)}const C={id:"jpeg",category:"image",name:"JPEG",version:"2.0.0-beta.4",extensions:["jpg","jpeg"],mimeType:"image/jpeg",test:e=>w(new DataView(e)),parse:L,options:{}},F={id:"png",category:"image",name:"PNG",version:"2.0.0-beta.4",extensions:["png"],mimeType:"image/png",test:e=>m(new DataView(e)),parse:L,options:{}},H={id:"gif",category:"image",name:"GIF",version:"2.0.0-beta.4",extensions:["gif"],mimeType:"image/gif",test:e=>l(new DataView(e)),parse:L,options:{}},J={id:"bmp",category:"image",name:"BMP",version:"2.0.0-beta.4",extensions:["gif"],mimeType:"image/gif",test:e=>p(new DataView(e)),parse:L,options:{}},W={id:"svg",name:"SVG",version:"2.0.0-beta.4",extensions:["svg"],mimeType:"image/svg+xml",parse:j},q=[C,F,H,J,W];n.d(t,"ImageLoader",(function(){return U})),n.d(t,"ImageWriter",(function(){return E})),n.d(t,"isImageTypeSupported",(function(){return c})),n.d(t,"getSupportedImageType",(function(){return s})),n.d(t,"isImage",(function(){return M})),n.d(t,"getImageType",(function(){return S})),n.d(t,"getImageSize",(function(){return B})),n.d(t,"getImageData",(function(){return P})),n.d(t,"isBinaryImage",(function(){return y})),n.d(t,"getBinaryImageMIMEType",(function(){return b})),n.d(t,"getBinaryImageSize",(function(){return v})),n.d(t,"loadImage",(function(){return V})),n.d(t,"loadImageArray",(function(){return z})),n.d(t,"loadImageCube",(function(){return R})),n.d(t,"_JPEGLoader",(function(){return C})),n.d(t,"_PNGLoader",(function(){return F})),n.d(t,"_GIFLoader",(function(){return H})),n.d(t,"_BMPLoader",(function(){return J})),n.d(t,"_SVGLoader",(function(){return W})),n.d(t,"_ImageLoaders",(function(){return q})),n.d(t,"HTMLImageLoader",(function(){return U}))}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return o}));const i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},a=i.global||i.self||i.window,o="object"!=typeof r||"[object process]"!==String(r)||r.browser,u=void 0!==r&&r.version&&r.version.match(/v([0-9]*)/);u&&parseFloat(u[1])}).call(this,n(1),n(3))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const r=n(4),i="undefined"==typeof window?t:window;i.loaders=i.loaders||{},e.exports=Object.assign(i.loaders,r)}).call(this,n(1))},function(e,t){var n,r,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var c,s=[],f=!1,g=-1;function d(){f&&c&&(f=!1,c.length?s=c.concat(s):g=-1,s.length&&m())}function m(){if(!f){var e=u(d);f=!0;for(var t=s.length;t;){for(c=s,s=[];++g<t;)c&&c[g].run();g=-1,t=s.length}c=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function l(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];s.push(new l(e,t)),1!==s.length||f||u(m)},l.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";function r(e,t){if(!e)throw new Error(t)}n.r(t);var i=n(0);const a="undefined"!=typeof ImageBitmap,o=void 0!==typeof Image,u=Boolean(i.a._parseImageNode);function c(e){switch(e){case"imagebitmap":return a;case"html":return o;case"ndarray":return u;default:throw new Error(`Unknown image format ${e}`)}}function s(){if(c("ndarray"))return"ndarray";if(c("html"))return"html";if(c("imagebitmap"))return"imagebitmap";if(!i.b)throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");return r(!1)}const f=!1,g=!0,d=new Map([["image/png",{test:m,getSize:function(e){return{width:e.getUint32(16,f),height:e.getUint32(20,f)}}}],["image/jpeg",{test:w,getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,f))return null;const{tableMarkers:t,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const i=e.getUint16(r,f);if(n.has(i))return{height:e.getUint16(r+5,f),width:e.getUint16(r+7,f)};if(!t.has(i))return null;r+=2,r+=e.getUint16(r,f)}return null}}],["image/gif",{test:l,getSize:function(e){return{width:e.getUint16(6,g),height:e.getUint16(8,g)}}}],["image/bmp",{test:p,getSize:function(e){return{width:e.getUint32(18,g),height:e.getUint32(22,g)}}}]]);function m(e){return e.byteLength>=24&&2303741511===e.getUint32(0,f)}function l(e){return e.byteLength>=10&&1195984440===e.getUint32(0,f)}function p(e){return e.byteLength>=2&&16973===e.getUint16(0,f)}function w(e){return e.byteLength>=3&&65496===e.getUint16(0,f)&&255===e.getUint8(2,f)}const h=`Invalid MIME type. Supported MIME types are: ${Array.from(d.keys()).join(", ")}`;function y(e,t){if(t){const{test:n}=I(t);return n(x(e))}return Boolean(b(e))}function b(e){const t=x(e);for(const[e,{test:n}]of d.entries())if(n(t))return e;return null}function v(e,t=null){t=t||b(e);const{getSize:n}=I(t),r=n(x(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}function I(e){const t=d.get(e);if(!t)throw new Error(h);return t}function x(e){if((e=e.buffer||e)instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}async function T(e,t){const n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((t,r)=>{try{n.onload=()=>t(n),n.onerror=t=>r(new Error(`Could not load image ${e}: ${t}`))}catch(e){r(e)}})}async function j(e,t){const n=(new TextDecoder).decode(e),r=`data:image/svg+xml;base64,${btoa(n)}`;return await T(r,t)}async function L(e,t,n){"image"in t&&(t={...t,image:{}});const{url:a}=n||{};if(a&&/\.svg((\?|#).*)?$/.test(a))return console.warn("@loaders.gl/images: SVG parsing needs to be fixed for 2.0"),await j(e,t);switch(function(e={}){const t=(e.image||{}).type||"auto";switch(t){case"imagebitmap":case"html":case"ndarray":if(!c(t))throw new Error(`Requested image type ${t} not available in current environment`);return t;case"auto":return s();default:throw new Error(`Unknown image format ${t}`)}}(t)){case"imagebitmap":return await function(e,t){const n=new Blob([new Uint8Array(e)]),r=t&&t.imagebitmap;return r?createImageBitmap(n):createImageBitmap(n,r)}(e,t);case"html":return await async function(e,t){const n=new Blob([e],{type:"image/jpeg"}),r=self.URL||self.webkitURL,i=r.createObjectURL(n);try{return await T(i,t)}finally{r.revokeObjectURL(i)}}(e,t);case"ndarray":return await function(e,t){r(i.a._parseImageNode);const n=b(e);return i.a._parseImageNode(e,n,t)}(e,t);default:return r(!1)}}var U={name:"Images",version:"2.0.0-beta.5",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vndmicrosofticon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:L,test:e=>{const t=new DataView(e);return w(t)||p(t)||l(t)||m(t)},options:{images:{format:"auto",decodeHTML:!0}}};var E={name:"Images",extensions:["jpeg"],encode:function(e,t){if(i.a._encodeImageNode)return i.a._encodeImageNode(e,t);if(e instanceof HTMLCanvasElement){return e.toDataURL(t)}r(e instanceof Image,"getImageData accepts image or canvas");const n=document.createElement("canvas");n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0);const a=n.toDataURL(t||"png").replace(/^data:image\/(png|jpg);base64,/,"");return Promise.resolve(a)},DEFAULT_OPTIONS:{type:"png"}};function M(e){return Boolean(_(e))}function S(e){const t=_(e);if(!t)throw new Error("Not an image");return t}function B(e){switch(S(e)){case"imagebitmap":case"ndarray":return{width:e.width,height:e.height};case"html":return{width:e.naturalWidth,height:e.naturalHeight};default:return r(!1)}}function P(e){switch(S(e)){case"imagebitmap":case"html":const t=document.createElement("canvas").getContext("2d");return t.drawImage(e,0,0),t.getImageData(0,0,e.width,e.height).data;case"ndarray":return e.data;default:return r(!1)}}function _(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"html":e&&"object"==typeof e&&e.data&&e.width&&e.height?"ndarray":Array.isArray(e)?"ndarray":null}function D(e,t,n){let i=e;"function"==typeof e&&(i=e({...t,...n})),r("string"==typeof i);const{baseUrl:a}=t;return a&&(i="/"===a[a.length-1]?`${a}${i}`:`${a}/${i}`),i}const O=e=>e&&"object"==typeof e;async function $(e,t,n){if(Array.isArray(e))return await async function(e,t,n={}){const r=e.map(e=>$(e,t,n));return await Promise.all(r)}(e,t,n);if(O(e))return await async function(e,t,n){const r=[],i={};for(const a in e){const o=$(e[a],t,n).then(e=>{i[a]=e});r.push(o)}return await Promise.all(r),i}(e,t,n);const r=e;return await t(r,n)}async function k(e,t,n){return await async function(e,t,n={}){return await $(e,t,n)}(e,e=>A(e,t,n))}async function A(e,t,n){const r=await fetch(e,n.fetch),i=await r.arrayBuffer();return await t(i,n)}async function V(e,t={}){const n=await N(e,t);return await k(n,L,t)}async function N(e,t,n={}){const i=t&&t.image&&t.image.mipLevels||0;return 0!==i?await async function(e,t,n,i){const a=[];if("auto"===t){const r=D(e,n,{...i,lod:0}),o=await A(r,L,n),{width:u,height:c}=B(o);t=function({width:e,height:t}){return 1+Math.floor(Math.log2(Math.max(e,t)))}({width:u,height:c}),a.push(r)}r(t>0);for(let r=a.length;r<t;++r){const t=D(e,n,{...i,lod:r});a.push(t)}return a}(e,i,t,n):D(e,t,n)}async function z(e,t,n={}){const r=await async function(e,t,n={}){const r=[];for(let i=0;i<e;i++){const e=N(t,n,{index:i});r.push(e)}return await Promise.all(r)}(e,t,n);return await k(r,L,n)}const G=[{face:34069,direction:"right",axis:"x",sign:"positive"},{face:34070,direction:"left",axis:"x",sign:"negative"},{face:34071,direction:"top",axis:"y",sign:"positive"},{face:34072,direction:"bottom",axis:"y",sign:"negative"},{face:34073,direction:"front",axis:"z",sign:"positive"},{face:34074,direction:"back",axis:"z",sign:"negative"}];async function R(e,t={}){const n=await async function(e,t){const n={},r=[];let i=0;for(const a in G){const o=N(e,t,{...G[i],index:i++}).then(e=>{n[a]=e});r.push(o)}return await Promise.all(r),n}(e,t);return await k(n,L,t)}const C={id:"jpeg",category:"image",name:"JPEG",version:"2.0.0-beta.5",extensions:["jpg","jpeg"],mimeType:"image/jpeg",test:e=>w(new DataView(e)),parse:L,options:{}},F={id:"png",category:"image",name:"PNG",version:"2.0.0-beta.5",extensions:["png"],mimeType:"image/png",test:e=>m(new DataView(e)),parse:L,options:{}},H={id:"gif",category:"image",name:"GIF",version:"2.0.0-beta.5",extensions:["gif"],mimeType:"image/gif",test:e=>l(new DataView(e)),parse:L,options:{}},J={id:"bmp",category:"image",name:"BMP",version:"2.0.0-beta.5",extensions:["gif"],mimeType:"image/gif",test:e=>p(new DataView(e)),parse:L,options:{}},W={id:"svg",name:"SVG",version:"2.0.0-beta.5",extensions:["svg"],mimeType:"image/svg+xml",parse:j},q=[C,F,H,J,W];n.d(t,"ImageLoader",(function(){return U})),n.d(t,"ImageWriter",(function(){return E})),n.d(t,"isImageTypeSupported",(function(){return c})),n.d(t,"getSupportedImageType",(function(){return s})),n.d(t,"isImage",(function(){return M})),n.d(t,"getImageType",(function(){return S})),n.d(t,"getImageSize",(function(){return B})),n.d(t,"getImageData",(function(){return P})),n.d(t,"isBinaryImage",(function(){return y})),n.d(t,"getBinaryImageMIMEType",(function(){return b})),n.d(t,"getBinaryImageSize",(function(){return v})),n.d(t,"loadImage",(function(){return V})),n.d(t,"loadImageArray",(function(){return z})),n.d(t,"loadImageCube",(function(){return R})),n.d(t,"_JPEGLoader",(function(){return C})),n.d(t,"_PNGLoader",(function(){return F})),n.d(t,"_GIFLoader",(function(){return H})),n.d(t,"_BMPLoader",(function(){return J})),n.d(t,"_SVGLoader",(function(){return W})),n.d(t,"_ImageLoaders",(function(){return q})),n.d(t,"HTMLImageLoader",(function(){return U}))}])})); |
@@ -14,3 +14,3 @@ "use strict"; | ||
var VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
var VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
var EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg']; | ||
@@ -17,0 +17,0 @@ var MIME_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp', 'image/vndmicrosofticon', 'image/svg+xml']; |
@@ -16,3 +16,3 @@ "use strict"; | ||
var VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
var VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
var JPEGLoader = { | ||
@@ -19,0 +19,0 @@ id: 'jpeg', |
import parseImage from './lib/parsers/parse-image'; | ||
import { isPng, isGif, isBmp, isJpeg } from './lib/binary-image-api/binary-image-parsers'; | ||
const VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
const VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
const EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg']; | ||
@@ -5,0 +5,0 @@ const MIME_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp', 'image/vndmicrosofticon', 'image/svg+xml']; |
import parseImage from './lib/parsers/parse-image'; | ||
import parseSVG from './lib/parsers/parse-svg'; | ||
import { isPng, isGif, isBmp, isJpeg } from './lib/binary-image-api/binary-image-parsers'; | ||
const VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
const VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
export const JPEGLoader = { | ||
@@ -6,0 +6,0 @@ id: 'jpeg', |
import parseImage from './lib/parsers/parse-image'; | ||
import { isPng, isGif, isBmp, isJpeg } from './lib/binary-image-api/binary-image-parsers'; | ||
var VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
var VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
var EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg']; | ||
@@ -5,0 +5,0 @@ var MIME_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp', 'image/vndmicrosofticon', 'image/svg+xml']; |
import parseImage from './lib/parsers/parse-image'; | ||
import parseSVG from './lib/parsers/parse-svg'; | ||
import { isPng, isGif, isBmp, isJpeg } from './lib/binary-image-api/binary-image-parsers'; | ||
var VERSION = typeof "2.0.0-beta.4" !== 'undefined' ? "2.0.0-beta.4" : 'latest'; | ||
var VERSION = typeof "2.0.0-beta.5" !== 'undefined' ? "2.0.0-beta.5" : 'latest'; | ||
export var JPEGLoader = { | ||
@@ -6,0 +6,0 @@ id: 'jpeg', |
{ | ||
"name": "@loaders.gl/images", | ||
"version": "2.0.0-beta.4", | ||
"version": "2.0.0-beta.5", | ||
"description": "Framework-independent loaders and writers for images (PNG, JPG, ...)", | ||
@@ -35,3 +35,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "d650d84afabb0c87ef084df6bd0f17f3b179d239" | ||
"gitHead": "138f85535a81e14b201ab89b818122c440f1e35e" | ||
} |
Sorry, the diff of this file is too big to display
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
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