Socket
Socket
Sign inDemoInstall

react-lazy-images

Package Overview
Dependencies
13
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0-rc.2 to 1.1.0-rc.3

2

dist/react-lazy-images.es.js

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

import e from"react";import r from"react-intersection-observer";import{unionize as t,ofType as n}from"unionize";var o=function(e,r){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};var a,i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function c(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&(t[n[o]]=e[n[o]])}return t}!function(e){e.NotAsked="NotAsked",e.Buffering="Buffering",e.Loading="Loading",e.LoadSuccess="LoadSuccess",e.LoadError="LoadError"}(a||(a={}));var u=t({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:n()}),s=t({ViewChanged:n(),BufferingEnded:{},LoadSuccess:{},LoadError:n()}),d=function(t){function n(e){var r=t.call(this,e)||this;return r.promiseCache={},r.initialState=u.NotAsked(),r.state=r.initialState,r.update=r.update.bind(r),r.reducer=r.reducer.bind(r),r}return function(e,r){function t(){this.constructor=e}o(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}(n,t),n.prototype.update=function(e){var r=this;this.setState(function(t,n){var o=r.reducer(e,t,n);return n.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:t,nextState:o})),o})},n.prototype.reducer=function(e,r,t){var n=this;return s.match(e,{ViewChanged:function(e){return!0===e.inView?t.src?u.match(r,{NotAsked:function(){if(t.debounceDurationMs){var e=l(p(t.debounceDurationMs));return e.promise.then(function(){return n.update(s.BufferingEnded())}).catch(function(e){}),n.promiseCache.buffering=e,u.Buffering()}var r=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=r,u.Loading()},default:function(){return r}}):u.LoadSuccess():u.match(r,{Buffering:function(){return n.promiseCache.buffering.cancel(),u.NotAsked()},default:function(){return r}})},BufferingEnded:function(){var e=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=e,u.Loading()},LoadSuccess:function(){return u.LoadSuccess()},LoadError:function(e){return u.LoadError(e)}})},n.prototype.render=function(){var t=this,n=this.props,o=n.children,a=n.loadEagerly,d=n.observerProps,f=c(n,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:f}):e.createElement(r,i({rootMargin:"50px 0px",threshold:.01},d,{onChange:function(e){return t.update(s.ViewChanged({inView:e}))}}),function(e){return o({imageState:t.state.tag,imageProps:f,ref:e.ref})})},n.displayName="LazyImageFull",n}(e.Component),f=function(e,r){var t=e.src,n=e.srcSet,o=e.alt,a=e.sizes;return void 0===r&&(r=!1),new Promise(function(e,i){var c=new Image;if(n&&(c.srcset=n),o&&(c.alt=o),a&&(c.sizes=a),c.src=t,r&&"decode"in c)return c.decode().then(function(r){return e(r)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},p=function(e){return new Promise(function(r){return setTimeout(r,e)})},l=function(e){var r=!1;return{promise:new Promise(function(t,n){e.then(function(e){return r?n({isCanceled:!0}):t(e)}),e.catch(function(e){return n(r?{isCanceled:!0}:e)})}),cancel:function(){r=!0}}},g=function(r){var t=r.actual,n=r.placeholder,o=r.loading,u=r.error,s=c(r,["actual","placeholder","loading","error"]);return e.createElement(d,i({},s),function(e){var r=e.imageProps,i=e.ref;switch(e.imageState){case a.NotAsked:return!!n&&n({imageProps:r,ref:i});case a.Loading:return o?o():!!n&&n({imageProps:r,ref:i});case a.LoadSuccess:return t({imageProps:r});case a.LoadError:return u?u():t({imageProps:r});case a.Buffering:return o?o():!!n&&n({imageProps:r,ref:i})}})};g.displayName="LazyImage";export{g as LazyImage,a as ImageState,d as LazyImageFull};
import e from"react";import t from"react-intersection-observer";import{unionize as r,ofType as n}from"unionize";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var a,i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r}!function(e){e.NotAsked="NotAsked",e.Buffering="Buffering",e.Loading="Loading",e.LoadSuccess="LoadSuccess",e.LoadError="LoadError"}(a||(a={}));var u=r({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:n()}),s=r({ViewChanged:n(),BufferingEnded:{},LoadSuccess:{},LoadError:n()}),d=function(e,t){return function(r){var n=l(e,t).then(function(e){return r.update(s.LoadSuccess({}))}).catch(function(e){return r.update(s.LoadError({msg:"Failed to load"}))});r.promiseCache.loading=n}},f=function(e){e.promiseCache.buffering.cancel()},p=function(r){function n(e){var t=r.call(this,e)||this;return t.promiseCache={},t.initialState=u.NotAsked(),t.state=t.initialState,t.update=t.update.bind(t),t}return function(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(n,r),n.reducer=function(e,t,r){return s.match(e,{ViewChanged:function(e){return!0===e.inView?r.src?u.match(t,{NotAsked:function(){return r.debounceDurationMs?{nextState:u.Buffering(),cmd:(e=r.debounceDurationMs,function(t){var r=m(g(e));r.promise.then(function(){return t.update(s.BufferingEnded())}).catch(function(e){}),t.promiseCache.buffering=r})}:{nextState:u.Loading(),cmd:d(r,r.experimentalDecode)};var e},default:function(){return{nextState:t}}}):{nextState:u.LoadSuccess()}:u.match(t,{Buffering:function(){return{nextState:u.NotAsked(),cmd:f}},default:function(){return{nextState:t}}})},BufferingEnded:function(){return{nextState:u.Loading(),cmd:d(r,r.experimentalDecode)}},LoadSuccess:function(){return{nextState:u.LoadSuccess()}},LoadError:function(e){return{nextState:u.LoadError(e)}}})},n.prototype.update=function(e){var t=this,r=n.reducer(e,this.state,this.props),o=r.nextState,a=r.cmd;this.props.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:this.state,nextState:o})),this.setState(o,function(){return a&&a(t)})},n.prototype.render=function(){var r=this,n=this.props,o=n.children,a=n.loadEagerly,d=n.observerProps,f=c(n,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:f}):e.createElement(t,i({rootMargin:"50px 0px",threshold:.01},d,{onChange:function(e){return r.update(s.ViewChanged({inView:e}))}}),function(e){return o({imageState:r.state.tag,imageProps:f,ref:e.ref})})},n.displayName="LazyImageFull",n}(e.Component),l=function(e,t){var r=e.src,n=e.srcSet,o=e.alt,a=e.sizes;return void 0===t&&(t=!1),new Promise(function(e,i){var c=new Image;if(n&&(c.srcset=n),o&&(c.alt=o),a&&(c.sizes=a),c.src=r,t&&"decode"in c)return c.decode().then(function(t){return e(t)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},g=function(e){return new Promise(function(t){return setTimeout(t,e)})},m=function(e){var t=!1;return{promise:new Promise(function(r,n){e.then(function(e){return t?n({isCanceled:!0}):r(e)}),e.catch(function(e){return n(t?{isCanceled:!0}:e)})}),cancel:function(){t=!0}}},h=function(t){var r=t.actual,n=t.placeholder,o=t.loading,u=t.error,s=c(t,["actual","placeholder","loading","error"]);return e.createElement(p,i({},s),function(e){var t=e.imageProps,i=e.ref;switch(e.imageState){case a.NotAsked:return!!n&&n({imageProps:t,ref:i});case a.Loading:return o?o():!!n&&n({imageProps:t,ref:i});case a.LoadSuccess:return r({imageProps:t});case a.LoadError:return u?u():r({imageProps:t});case a.Buffering:return o?o():!!n&&n({imageProps:t,ref:i})}})};h.displayName="LazyImage";export{h as LazyImage,a as ImageState,p as LazyImageFull};
//# sourceMappingURL=react-lazy-images.es.js.map

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

function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=e(require("react")),t=e(require("react-intersection-observer")),n=require("unionize"),o=function(e,r){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};var a,i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function c(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&(t[n[o]]=e[n[o]])}return t}(a=exports.ImageState||(exports.ImageState={})).NotAsked="NotAsked",a.Buffering="Buffering",a.Loading="Loading",a.LoadSuccess="LoadSuccess",a.LoadError="LoadError";var u=n.unionize({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:n.ofType()}),s=n.unionize({ViewChanged:n.ofType(),BufferingEnded:{},LoadSuccess:{},LoadError:n.ofType()}),d=function(e){function n(r){var t=e.call(this,r)||this;return t.promiseCache={},t.initialState=u.NotAsked(),t.state=t.initialState,t.update=t.update.bind(t),t.reducer=t.reducer.bind(t),t}return function(e,r){function t(){this.constructor=e}o(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}(n,e),n.prototype.update=function(e){var r=this;this.setState(function(t,n){var o=r.reducer(e,t,n);return n.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:t,nextState:o})),o})},n.prototype.reducer=function(e,r,t){var n=this;return s.match(e,{ViewChanged:function(e){return!0===e.inView?t.src?u.match(r,{NotAsked:function(){if(t.debounceDurationMs){var e=l(p(t.debounceDurationMs));return e.promise.then(function(){return n.update(s.BufferingEnded())}).catch(function(e){}),n.promiseCache.buffering=e,u.Buffering()}var r=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=r,u.Loading()},default:function(){return r}}):u.LoadSuccess():u.match(r,{Buffering:function(){return n.promiseCache.buffering.cancel(),u.NotAsked()},default:function(){return r}})},BufferingEnded:function(){var e=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=e,u.Loading()},LoadSuccess:function(){return u.LoadSuccess()},LoadError:function(e){return u.LoadError(e)}})},n.prototype.render=function(){var e=this,n=this.props,o=n.children,a=n.loadEagerly,d=n.observerProps,f=c(n,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:f}):r.createElement(t,i({rootMargin:"50px 0px",threshold:.01},d,{onChange:function(r){return e.update(s.ViewChanged({inView:r}))}}),function(r){return o({imageState:e.state.tag,imageProps:f,ref:r.ref})})},n.displayName="LazyImageFull",n}(r.Component),f=function(e,r){var t=e.src,n=e.srcSet,o=e.alt,a=e.sizes;return void 0===r&&(r=!1),new Promise(function(e,i){var c=new Image;if(n&&(c.srcset=n),o&&(c.alt=o),a&&(c.sizes=a),c.src=t,r&&"decode"in c)return c.decode().then(function(r){return e(r)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},p=function(e){return new Promise(function(r){return setTimeout(r,e)})},l=function(e){var r=!1;return{promise:new Promise(function(t,n){e.then(function(e){return r?n({isCanceled:!0}):t(e)}),e.catch(function(e){return n(r?{isCanceled:!0}:e)})}),cancel:function(){r=!0}}},g=function(e){var t=e.actual,n=e.placeholder,o=e.loading,a=e.error,u=c(e,["actual","placeholder","loading","error"]);return r.createElement(d,i({},u),function(e){var r=e.imageProps,i=e.ref;switch(e.imageState){case exports.ImageState.NotAsked:return!!n&&n({imageProps:r,ref:i});case exports.ImageState.Loading:return o?o():!!n&&n({imageProps:r,ref:i});case exports.ImageState.LoadSuccess:return t({imageProps:r});case exports.ImageState.LoadError:return a?a():t({imageProps:r});case exports.ImageState.Buffering:return o?o():!!n&&n({imageProps:r,ref:i})}})};g.displayName="LazyImage",exports.LazyImage=g,exports.LazyImageFull=d;
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("react")),r=e(require("react-intersection-observer")),n=require("unionize"),o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var a,i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r}(a=exports.ImageState||(exports.ImageState={})).NotAsked="NotAsked",a.Buffering="Buffering",a.Loading="Loading",a.LoadSuccess="LoadSuccess",a.LoadError="LoadError";var u=n.unionize({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:n.ofType()}),s=n.unionize({ViewChanged:n.ofType(),BufferingEnded:{},LoadSuccess:{},LoadError:n.ofType()}),f=function(e,t){return function(r){var n=g(e,t).then(function(e){return r.update(s.LoadSuccess({}))}).catch(function(e){return r.update(s.LoadError({msg:"Failed to load"}))});r.promiseCache.loading=n}},d=function(e){e.promiseCache.buffering.cancel()},p=function(e){function n(t){var r=e.call(this,t)||this;return r.promiseCache={},r.initialState=u.NotAsked(),r.state=r.initialState,r.update=r.update.bind(r),r}return function(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(n,e),n.reducer=function(e,t,r){return s.match(e,{ViewChanged:function(e){return!0===e.inView?r.src?u.match(t,{NotAsked:function(){return r.debounceDurationMs?{nextState:u.Buffering(),cmd:(e=r.debounceDurationMs,function(t){var r=m(l(e));r.promise.then(function(){return t.update(s.BufferingEnded())}).catch(function(e){}),t.promiseCache.buffering=r})}:{nextState:u.Loading(),cmd:f(r,r.experimentalDecode)};var e},default:function(){return{nextState:t}}}):{nextState:u.LoadSuccess()}:u.match(t,{Buffering:function(){return{nextState:u.NotAsked(),cmd:d}},default:function(){return{nextState:t}}})},BufferingEnded:function(){return{nextState:u.Loading(),cmd:f(r,r.experimentalDecode)}},LoadSuccess:function(){return{nextState:u.LoadSuccess()}},LoadError:function(e){return{nextState:u.LoadError(e)}}})},n.prototype.update=function(e){var t=this,r=n.reducer(e,this.state,this.props),o=r.nextState,a=r.cmd;this.props.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:this.state,nextState:o})),this.setState(o,function(){return a&&a(t)})},n.prototype.render=function(){var e=this,n=this.props,o=n.children,a=n.loadEagerly,f=n.observerProps,d=c(n,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:d}):t.createElement(r,i({rootMargin:"50px 0px",threshold:.01},f,{onChange:function(t){return e.update(s.ViewChanged({inView:t}))}}),function(t){return o({imageState:e.state.tag,imageProps:d,ref:t.ref})})},n.displayName="LazyImageFull",n}(t.Component),g=function(e,t){var r=e.src,n=e.srcSet,o=e.alt,a=e.sizes;return void 0===t&&(t=!1),new Promise(function(e,i){var c=new Image;if(n&&(c.srcset=n),o&&(c.alt=o),a&&(c.sizes=a),c.src=r,t&&"decode"in c)return c.decode().then(function(t){return e(t)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},l=function(e){return new Promise(function(t){return setTimeout(t,e)})},m=function(e){var t=!1;return{promise:new Promise(function(r,n){e.then(function(e){return t?n({isCanceled:!0}):r(e)}),e.catch(function(e){return n(t?{isCanceled:!0}:e)})}),cancel:function(){t=!0}}},h=function(e){var r=e.actual,n=e.placeholder,o=e.loading,a=e.error,u=c(e,["actual","placeholder","loading","error"]);return t.createElement(p,i({},u),function(e){var t=e.imageProps,i=e.ref;switch(e.imageState){case exports.ImageState.NotAsked:return!!n&&n({imageProps:t,ref:i});case exports.ImageState.Loading:return o?o():!!n&&n({imageProps:t,ref:i});case exports.ImageState.LoadSuccess:return r({imageProps:t});case exports.ImageState.LoadError:return a?a():r({imageProps:t});case exports.ImageState.Buffering:return o?o():!!n&&n({imageProps:t,ref:i})}})};h.displayName="LazyImage",exports.LazyImage=h,exports.LazyImageFull=p;
//# sourceMappingURL=react-lazy-images.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("react-intersection-observer"),require("unionize")):"function"==typeof define&&define.amd?define(["exports","react","react-intersection-observer","unionize"],r):r(e.reactLazyImages={},e.react,null,e.unionize)}(this,function(e,r,t,n){r=r&&r.hasOwnProperty("default")?r.default:r,t=t&&t.hasOwnProperty("default")?t.default:t;var o=function(e,r){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};var a,i=function(){return(i=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function c(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&(t[n[o]]=e[n[o]])}return t}(a=e.ImageState||(e.ImageState={})).NotAsked="NotAsked",a.Buffering="Buffering",a.Loading="Loading",a.LoadSuccess="LoadSuccess",a.LoadError="LoadError";var u=n.unionize({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:n.ofType()}),s=n.unionize({ViewChanged:n.ofType(),BufferingEnded:{},LoadSuccess:{},LoadError:n.ofType()}),d=function(e){function n(r){var t=e.call(this,r)||this;return t.promiseCache={},t.initialState=u.NotAsked(),t.state=t.initialState,t.update=t.update.bind(t),t.reducer=t.reducer.bind(t),t}return function(e,r){function t(){this.constructor=e}o(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}(n,e),n.prototype.update=function(e){var r=this;this.setState(function(t,n){var o=r.reducer(e,t,n);return n.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:t,nextState:o})),o})},n.prototype.reducer=function(e,r,t){var n=this;return s.match(e,{ViewChanged:function(e){return!0===e.inView?t.src?u.match(r,{NotAsked:function(){if(t.debounceDurationMs){var e=l(p(t.debounceDurationMs));return e.promise.then(function(){return n.update(s.BufferingEnded())}).catch(function(e){}),n.promiseCache.buffering=e,u.Buffering()}var r=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=r,u.Loading()},default:function(){return r}}):u.LoadSuccess():u.match(r,{Buffering:function(){return n.promiseCache.buffering.cancel(),u.NotAsked()},default:function(){return r}})},BufferingEnded:function(){var e=f({src:t.src,srcSet:t.srcSet,alt:t.alt,sizes:t.sizes},t.experimentalDecode).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});return n.promiseCache.loading=e,u.Loading()},LoadSuccess:function(){return u.LoadSuccess()},LoadError:function(e){return u.LoadError(e)}})},n.prototype.render=function(){var e=this,n=this.props,o=n.children,a=n.loadEagerly,d=n.observerProps,f=c(n,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:f}):r.createElement(t,i({rootMargin:"50px 0px",threshold:.01},d,{onChange:function(r){return e.update(s.ViewChanged({inView:r}))}}),function(r){return o({imageState:e.state.tag,imageProps:f,ref:r.ref})})},n.displayName="LazyImageFull",n}(r.Component),f=function(e,r){var t=e.src,n=e.srcSet,o=e.alt,a=e.sizes;return void 0===r&&(r=!1),new Promise(function(e,i){var c=new Image;if(n&&(c.srcset=n),o&&(c.alt=o),a&&(c.sizes=a),c.src=t,r&&"decode"in c)return c.decode().then(function(r){return e(r)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},p=function(e){return new Promise(function(r){return setTimeout(r,e)})},l=function(e){var r=!1;return{promise:new Promise(function(t,n){e.then(function(e){return r?n({isCanceled:!0}):t(e)}),e.catch(function(e){return n(r?{isCanceled:!0}:e)})}),cancel:function(){r=!0}}},g=function(t){var n=t.actual,o=t.placeholder,a=t.loading,u=t.error,s=c(t,["actual","placeholder","loading","error"]);return r.createElement(d,i({},s),function(r){var t=r.imageProps,i=r.ref;switch(r.imageState){case e.ImageState.NotAsked:return!!o&&o({imageProps:t,ref:i});case e.ImageState.Loading:return a?a():!!o&&o({imageProps:t,ref:i});case e.ImageState.LoadSuccess:return n({imageProps:t});case e.ImageState.LoadError:return u?u():n({imageProps:t});case e.ImageState.Buffering:return a?a():!!o&&o({imageProps:t,ref:i})}})};g.displayName="LazyImage",e.LazyImage=g,e.LazyImageFull=d});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-intersection-observer"),require("unionize")):"function"==typeof define&&define.amd?define(["exports","react","react-intersection-observer","unionize"],t):t(e.reactLazyImages={},e.react,null,e.unionize)}(this,function(e,t,n,r){t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n;var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var a,i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}return n}(a=e.ImageState||(e.ImageState={})).NotAsked="NotAsked",a.Buffering="Buffering",a.Loading="Loading",a.LoadSuccess="LoadSuccess",a.LoadError="LoadError";var u=r.unionize({NotAsked:{},Buffering:{},Loading:{},LoadSuccess:{},LoadError:r.ofType()}),s=r.unionize({ViewChanged:r.ofType(),BufferingEnded:{},LoadSuccess:{},LoadError:r.ofType()}),f=function(e,t){return function(n){var r=g(e,t).then(function(e){return n.update(s.LoadSuccess({}))}).catch(function(e){return n.update(s.LoadError({msg:"Failed to load"}))});n.promiseCache.loading=r}},d=function(e){e.promiseCache.buffering.cancel()},p=function(e){function r(t){var n=e.call(this,t)||this;return n.promiseCache={},n.initialState=u.NotAsked(),n.state=n.initialState,n.update=n.update.bind(n),n}return function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(r,e),r.reducer=function(e,t,n){return s.match(e,{ViewChanged:function(e){return!0===e.inView?n.src?u.match(t,{NotAsked:function(){return n.debounceDurationMs?{nextState:u.Buffering(),cmd:(e=n.debounceDurationMs,function(t){var n=m(l(e));n.promise.then(function(){return t.update(s.BufferingEnded())}).catch(function(e){}),t.promiseCache.buffering=n})}:{nextState:u.Loading(),cmd:f(n,n.experimentalDecode)};var e},default:function(){return{nextState:t}}}):{nextState:u.LoadSuccess()}:u.match(t,{Buffering:function(){return{nextState:u.NotAsked(),cmd:d}},default:function(){return{nextState:t}}})},BufferingEnded:function(){return{nextState:u.Loading(),cmd:f(n,n.experimentalDecode)}},LoadSuccess:function(){return{nextState:u.LoadSuccess()}},LoadError:function(e){return{nextState:u.LoadError(e)}}})},r.prototype.update=function(e){var t=this,n=r.reducer(e,this.state,this.props),o=n.nextState,a=n.cmd;this.props.debugActions&&("production"===process.env.NODE_ENV&&console.warn('You are running LazyImage with debugActions="true" in production. This might have performance implications.'),console.log({action:e,prevState:this.state,nextState:o})),this.setState(o,function(){return a&&a(t)})},r.prototype.render=function(){var e=this,r=this.props,o=r.children,a=r.loadEagerly,f=r.observerProps,d=c(r,["children","loadEagerly","observerProps","experimentalDecode","debounceDurationMs","debugActions"]);return a?o({imageState:u.LoadSuccess().tag,imageProps:d}):t.createElement(n,i({rootMargin:"50px 0px",threshold:.01},f,{onChange:function(t){return e.update(s.ViewChanged({inView:t}))}}),function(t){return o({imageState:e.state.tag,imageProps:d,ref:t.ref})})},r.displayName="LazyImageFull",r}(t.Component),g=function(e,t){var n=e.src,r=e.srcSet,o=e.alt,a=e.sizes;return void 0===t&&(t=!1),new Promise(function(e,i){var c=new Image;if(r&&(c.srcset=r),o&&(c.alt=o),a&&(c.sizes=a),c.src=n,t&&"decode"in c)return c.decode().then(function(t){return e(t)}).catch(function(e){return i(e)});c.onload=e,c.onerror=i})},l=function(e){return new Promise(function(t){return setTimeout(t,e)})},m=function(e){var t=!1;return{promise:new Promise(function(n,r){e.then(function(e){return t?r({isCanceled:!0}):n(e)}),e.catch(function(e){return r(t?{isCanceled:!0}:e)})}),cancel:function(){t=!0}}},h=function(n){var r=n.actual,o=n.placeholder,a=n.loading,u=n.error,s=c(n,["actual","placeholder","loading","error"]);return t.createElement(p,i({},s),function(t){var n=t.imageProps,i=t.ref;switch(t.imageState){case e.ImageState.NotAsked:return!!o&&o({imageProps:n,ref:i});case e.ImageState.Loading:return a?a():!!o&&o({imageProps:n,ref:i});case e.ImageState.LoadSuccess:return r({imageProps:n});case e.ImageState.LoadError:return u?u():r({imageProps:n});case e.ImageState.Buffering:return a?a():!!o&&o({imageProps:n,ref:i})}})};h.displayName="LazyImage",e.LazyImage=h,e.LazyImageFull=p});
//# sourceMappingURL=react-lazy-images.umd.js.map
{
"name": "react-lazy-images",
"description": "React utilities for lazy image loading",
"version": "1.1.0-rc.2",
"version": "1.1.0-rc.3",
"source": "src/index.tsx",

@@ -6,0 +6,0 @@ "module": "dist/react-lazy-images.es.js",

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc