Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/images

Package Overview
Dependencies
Maintainers
9
Versions
329
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/images - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

2

dist/dist.min.js

@@ -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,"b",(function(){return i})),n.d(t,"a",(function(){return o}));const i="object"!=typeof e||"[object process]"!==String(e)||e.browser,a={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==r&&r,document:"undefined"!=typeof document&&document},o=a.global||a.self||a.window,u=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/);u&&parseFloat(u[1])}).call(this,n(3),n(1))},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)]);return createImageBitmap(n)}(e);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",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(B(e))}function S(e){const t=B(e);if(!t)throw new Error("Not an image");return t}function P(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 _(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 B(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}=P(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",extensions:["jpg","jpeg"],mimeType:"image/jpeg",test:e=>w(new DataView(e)),parse:L,options:{}},F={id:"png",category:"image",name:"PNG",extensions:["png"],mimeType:"image/png",test:e=>m(new DataView(e)),parse:L,options:{}},H={id:"gif",category:"image",name:"GIF",extensions:["gif"],mimeType:"image/gif",test:e=>l(new DataView(e)),parse:L,options:{}},J={id:"bmp",category:"image",name:"BMP",extensions:["gif"],mimeType:"image/gif",test:e=>p(new DataView(e)),parse:L,options:{}},W={id:"svg",name:"SVG",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 P})),n.d(t,"getImageData",(function(){return _})),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&&l())}function l(){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 m(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 m(e,t)),1!==s.length||f||u(l)},m.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:l,getSize:function(e){return{width:e.getUint32(16,f),height:e.getUint32(20,f)}}}],["image/jpeg",{test:h,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:m,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 l(e){return e.byteLength>=24&&2303741511===e.getUint32(0,f)}function m(e){return e.byteLength>=10&&1195984440===e.getUint32(0,f)}function p(e){return e.byteLength>=2&&16973===e.getUint16(0,f)}function h(e){return e.byteLength>=3&&65496===e.getUint16(0,f)&&255===e.getUint8(2,f)}const w=`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(w);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-alpha.3",extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:L,test:e=>{const t=new DataView(e);return h(t)||p(t)||m(t)||l(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-alpha.3",extensions:["jpg","jpeg"],mimeType:"image/jpeg",test:e=>h(new DataView(e)),parse:L,options:{}},F={id:"png",category:"image",name:"PNG",version:"2.0.0-alpha.3",extensions:["png"],mimeType:"image/png",test:e=>l(new DataView(e)),parse:L,options:{}},H={id:"gif",category:"image",name:"GIF",version:"2.0.0-alpha.3",extensions:["gif"],mimeType:"image/gif",test:e=>m(new DataView(e)),parse:L,options:{}},J={id:"bmp",category:"image",name:"BMP",version:"2.0.0-alpha.3",extensions:["gif"],mimeType:"image/gif",test:e=>p(new DataView(e)),parse:L,options:{}},W={id:"svg",name:"SVG",version:"2.0.0-alpha.3",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,5 +14,7 @@ "use strict";

var VERSION = typeof "2.0.0-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
var EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg'];
var ImageLoader = {
name: 'Images',
version: VERSION,
extensions: EXTENSIONS,

@@ -19,0 +21,0 @@ parse: _parseImage["default"],

@@ -16,2 +16,3 @@ "use strict";

var VERSION = typeof "2.0.0-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
var JPEGLoader = {

@@ -21,2 +22,3 @@ id: 'jpeg',

name: 'JPEG',
version: VERSION,
extensions: ['jpg', 'jpeg'],

@@ -35,2 +37,3 @@ mimeType: 'image/jpeg',

name: 'PNG',
version: VERSION,
extensions: ['png'],

@@ -49,2 +52,3 @@ mimeType: 'image/png',

name: 'GIF',
version: VERSION,
extensions: ['gif'],

@@ -63,2 +67,3 @@ mimeType: 'image/gif',

name: 'BMP',
version: VERSION,
extensions: ['gif'],

@@ -76,2 +81,3 @@ mimeType: 'image/gif',

name: 'SVG',
version: VERSION,
extensions: ['svg'],

@@ -78,0 +84,0 @@ mimeType: 'image/svg+xml',

@@ -10,4 +10,5 @@ "use strict";

var blob = new Blob([new Uint8Array(arrayBuffer)]);
return createImageBitmap(blob);
var imagebitmapOptions = options && options.imagebitmap;
return imagebitmapOptions ? createImageBitmap(blob) : createImageBitmap(blob, imagebitmapOptions);
}
//# sourceMappingURL=parse-to-image-bitmap.js.map

@@ -8,8 +8,6 @@ "use strict";

});
exports.nodeVersion = exports.document = exports.global = exports.window = exports.self = exports.isBrowser = void 0;
exports.nodeVersion = exports.isWorker = exports.isBrowser = exports.document = exports.global = exports.window = exports.self = void 0;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var isBrowser = (typeof process === "undefined" ? "undefined" : (0, _typeof2["default"])(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
exports.isBrowser = isBrowser;
var globals = {

@@ -29,2 +27,6 @@ self: typeof self !== 'undefined' && self,

exports.document = document_;
var isBrowser = (typeof process === "undefined" ? "undefined" : (0, _typeof2["default"])(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
exports.isBrowser = isBrowser;
var isWorker = typeof importScripts === 'function';
exports.isWorker = isWorker;
var matches = typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/);

@@ -31,0 +33,0 @@ var nodeVersion = matches && parseFloat(matches[1]) || 0;

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-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
const EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg'];
const ImageLoader = {
name: 'Images',
version: VERSION,
extensions: EXTENSIONS,

@@ -7,0 +9,0 @@ parse: parseImage,

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-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
export const JPEGLoader = {

@@ -8,2 +9,3 @@ id: 'jpeg',

name: 'JPEG',
version: VERSION,
extensions: ['jpg', 'jpeg'],

@@ -19,2 +21,3 @@ mimeType: 'image/jpeg',

name: 'PNG',
version: VERSION,
extensions: ['png'],

@@ -30,2 +33,3 @@ mimeType: 'image/png',

name: 'GIF',
version: VERSION,
extensions: ['gif'],

@@ -41,2 +45,3 @@ mimeType: 'image/gif',

name: 'BMP',
version: VERSION,
extensions: ['gif'],

@@ -51,2 +56,3 @@ mimeType: 'image/gif',

name: 'SVG',
version: VERSION,
extensions: ['svg'],

@@ -53,0 +59,0 @@ mimeType: 'image/svg+xml',

export default function parseToImageBitmap(arrayBuffer, options) {
const blob = new Blob([new Uint8Array(arrayBuffer)]);
return createImageBitmap(blob);
const imagebitmapOptions = options && options.imagebitmap;
return imagebitmapOptions ? createImageBitmap(blob) : createImageBitmap(blob, imagebitmapOptions);
}
//# sourceMappingURL=parse-to-image-bitmap.js.map

@@ -1,2 +0,1 @@

const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
const globals = {

@@ -12,5 +11,7 @@ self: typeof self !== 'undefined' && self,

const document_ = globals.document || {};
export { isBrowser, self_ as self, window_ as window, global_ as global, document_ as document };
export { self_ as self, window_ as window, global_ as global, document_ as document };
export const isBrowser = typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
export const isWorker = typeof importScripts === 'function';
const matches = typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/);
export const nodeVersion = matches && parseFloat(matches[1]) || 0;
//# sourceMappingURL=globals.js.map
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-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
var EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg'];
var ImageLoader = {
name: 'Images',
version: VERSION,
extensions: EXTENSIONS,

@@ -7,0 +9,0 @@ parse: parseImage,

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-alpha.3" !== 'undefined' ? "2.0.0-alpha.3" : 'latest';
export var JPEGLoader = {

@@ -8,2 +9,3 @@ id: 'jpeg',

name: 'JPEG',
version: VERSION,
extensions: ['jpg', 'jpeg'],

@@ -21,2 +23,3 @@ mimeType: 'image/jpeg',

name: 'PNG',
version: VERSION,
extensions: ['png'],

@@ -34,2 +37,3 @@ mimeType: 'image/png',

name: 'GIF',
version: VERSION,
extensions: ['gif'],

@@ -47,2 +51,3 @@ mimeType: 'image/gif',

name: 'BMP',
version: VERSION,
extensions: ['gif'],

@@ -59,2 +64,3 @@ mimeType: 'image/gif',

name: 'SVG',
version: VERSION,
extensions: ['svg'],

@@ -61,0 +67,0 @@ mimeType: 'image/svg+xml',

export default function parseToImageBitmap(arrayBuffer, options) {
var blob = new Blob([new Uint8Array(arrayBuffer)]);
return createImageBitmap(blob);
var imagebitmapOptions = options && options.imagebitmap;
return imagebitmapOptions ? createImageBitmap(blob) : createImageBitmap(blob, imagebitmapOptions);
}
//# sourceMappingURL=parse-to-image-bitmap.js.map
import _typeof from "@babel/runtime/helpers/esm/typeof";
var isBrowser = (typeof process === "undefined" ? "undefined" : _typeof(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
var globals = {

@@ -13,5 +12,7 @@ self: typeof self !== 'undefined' && self,

var document_ = globals.document || {};
export { isBrowser, self_ as self, window_ as window, global_ as global, document_ as document };
export { self_ as self, window_ as window, global_ as global, document_ as document };
export var isBrowser = (typeof process === "undefined" ? "undefined" : _typeof(process)) !== 'object' || String(process) !== '[object process]' || process.browser;
export var isWorker = typeof importScripts === 'function';
var matches = typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/);
export var nodeVersion = matches && parseFloat(matches[1]) || 0;
//# sourceMappingURL=globals.js.map
{
"name": "@loaders.gl/images",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Framework-independent loaders and writers for images (PNG, JPG, ...)",

@@ -35,3 +35,3 @@ "license": "MIT",

},
"gitHead": "1bc3e4e6522a2a337f972799f63682464500a313"
"gitHead": "fc28707733ea13de169330a6acd003956e9dbcfa"
}

@@ -0,5 +1,7 @@

/* global __VERSION__ */ // __VERSION__ is injected by babel-plugin-version-inline
import parseImage from './lib/parsers/parse-image';
import {isPng, isGif, isBmp, isJpeg} from './lib/binary-image-api/binary-image-parsers';
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
const EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'svg'];

@@ -10,2 +12,3 @@

name: 'Images',
version: VERSION,
extensions: EXTENSIONS,

@@ -22,2 +25,3 @@ parse: parseImage,

}
// imagebitmap: {}
}

@@ -24,0 +28,0 @@ };

@@ -0,6 +1,8 @@

/* global __VERSION__ */ // __VERSION__ is injected by babel-plugin-version-inline
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 __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
export const JPEGLoader = {

@@ -10,2 +12,3 @@ id: 'jpeg',

name: 'JPEG',
version: VERSION,
extensions: ['jpg', 'jpeg'],

@@ -23,2 +26,3 @@ mimeType: 'image/jpeg',

name: 'PNG',
version: VERSION,
extensions: ['png'],

@@ -36,2 +40,3 @@ mimeType: 'image/png',

name: 'GIF',
version: VERSION,
extensions: ['gif'],

@@ -48,2 +53,3 @@ mimeType: 'image/gif',

name: 'BMP',
version: VERSION,
extensions: ['gif'],

@@ -59,2 +65,3 @@ mimeType: 'image/gif',

name: 'SVG',
version: VERSION,
extensions: ['svg'],

@@ -61,0 +68,0 @@ mimeType: 'image/svg+xml',

@@ -10,3 +10,4 @@ /* global Blob, createImageBitmap */

const blob = new Blob([new Uint8Array(arrayBuffer)]); // MIME type not needed...
return createImageBitmap(blob);
const imagebitmapOptions = options && options.imagebitmap;
return imagebitmapOptions ? createImageBitmap(blob) : createImageBitmap(blob, imagebitmapOptions);
}

@@ -25,7 +25,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

/* eslint-disable no-restricted-globals */
/* global process, window, global, document */
const isBrowser =
typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
/* global self, window, global, document */
/* global process, window, global, document, self, importScripts */
const globals = {

@@ -43,7 +39,12 @@ self: typeof self !== 'undefined' && self,

export {isBrowser, self_ as self, window_ as window, global_ as global, document_ as document};
export {self_ as self, window_ as window, global_ as global, document_ as document};
// Extract node version
export const isBrowser =
typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
export const isWorker = typeof importScripts === 'function';
// Extract node major version
const matches =
typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/);
export const nodeVersion = (matches && parseFloat(matches[1])) || 0;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc