react-cloudimage-responsive
Advanced tools
Comparing version 3.6.4 to 3.6.5
@@ -30,2 +30,6 @@ # Changelog | ||
------------- | ||
## 3.6.5 - 2023-04-18 | ||
### Fixed | ||
- Remove CVE vulnerabilities | ||
## 3.6.4 - 2022-08-04 | ||
@@ -32,0 +36,0 @@ ### Fixed |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,59 +8,39 @@ value: true | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var _cloudimageResponsiveUtils = require("cloudimage-responsive-utils"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["config", "cloudimgURL", "previewCloudimgURL", "className", "style", "children", "preview", "src", "onImgLoad", "innerRef"]; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function BackgroundInner(props) { | ||
var _props$config = props.config, | ||
config = _props$config === void 0 ? {} : _props$config, | ||
cloudimgURL = props.cloudimgURL, | ||
previewCloudimgURL = props.previewCloudimgURL, | ||
className = props.className, | ||
style = props.style, | ||
children = props.children, | ||
preview = props.preview, | ||
src = props.src, | ||
onImgLoad = props.onImgLoad, | ||
innerRef = props.innerRef, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
config = _props$config === void 0 ? {} : _props$config, | ||
cloudimgURL = props.cloudimgURL, | ||
previewCloudimgURL = props.previewCloudimgURL, | ||
className = props.className, | ||
style = props.style, | ||
children = props.children, | ||
preview = props.preview, | ||
src = props.src, | ||
onImgLoad = props.onImgLoad, | ||
innerRef = props.innerRef, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
var _useState = (0, _react.useState)(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
loaded = _useState2[0], | ||
setLoaded = _useState2[1]; | ||
var alt = otherProps.alt; | ||
var autoAlt = config.autoAlt, | ||
delay = config.delay; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
loaded = _useState2[0], | ||
setLoaded = _useState2[1]; | ||
var delay = config.delay; | ||
var _onImgLoad = function _onImgLoad(event) { | ||
setLoaded(true); | ||
if (typeof onImgLoad === 'function') { | ||
@@ -69,3 +50,2 @@ onImgLoad(event); | ||
}; | ||
var preLoadImg = function preLoadImg() { | ||
@@ -76,9 +56,2 @@ var img = new Image(); | ||
}; | ||
var getAlt = function getAlt(name) { | ||
if (!name) return; | ||
var index = name.indexOf('.'); | ||
return name.slice(0, index); | ||
}; | ||
var containerClassName = [className, 'cloudimage-background', loaded ? 'loaded' : 'loading'].join(' ').trim(); | ||
@@ -95,3 +68,2 @@ (0, _react.useEffect)(function () { | ||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, otherProps), {}, { | ||
alt: !alt && autoAlt ? getAlt(src) : alt, | ||
className: containerClassName, | ||
@@ -121,4 +93,3 @@ ref: innerRef, | ||
} | ||
var _default = BackgroundInner; | ||
exports["default"] = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,53 +8,33 @@ value: true | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var _cloudimageResponsiveUtils = require("cloudimage-responsive-utils"); | ||
var _reactLazyload = _interopRequireDefault(require("react-lazyload")); | ||
var _utils = require("./utils"); | ||
var _backgroundInner = _interopRequireDefault(require("./background-inner")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["className", "style", "lazyLoadConfig", "lazyLoading", "children", "innerRef", "doNotReplaceURL"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function BackgroundImg(props) { | ||
var _props$config = props.config, | ||
config = _props$config === void 0 ? {} : _props$config, | ||
onImgLoad = props.onImgLoad, | ||
src = props.src, | ||
defualtChildren = props.children; | ||
config = _props$config === void 0 ? {} : _props$config, | ||
onImgLoad = props.onImgLoad, | ||
src = props.src, | ||
defualtChildren = props.children; | ||
var _useState = (0, _react.useState)({}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
data = _useState2[0], | ||
setData = _useState2[1]; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
data = _useState2[0], | ||
setData = _useState2[1]; | ||
var bgNode = (0, _react.useRef)(); | ||
@@ -64,10 +45,8 @@ var server = (0, _react.useMemo)(function () { | ||
var height = data.height, | ||
cloudimgURL = data.cloudimgURL, | ||
previewCloudimgURL = data.previewCloudimgURL, | ||
preview = data.preview, | ||
processed = data.processed; | ||
cloudimgURL = data.cloudimgURL, | ||
previewCloudimgURL = data.previewCloudimgURL, | ||
preview = data.preview, | ||
processed = data.processed; | ||
var processBg = function processBg(update, windowScreenBecomesBigger) { | ||
var bgData = (0, _cloudimageResponsiveUtils.processReactNode)(props, bgNode.current, update, windowScreenBecomesBigger); | ||
if (bgData) { | ||
@@ -77,14 +56,12 @@ setData(bgData); | ||
}; | ||
var _getFilteredBgProps = (0, _utils.getFilteredBgProps)(props), | ||
className = _getFilteredBgProps.className, | ||
style = _getFilteredBgProps.style, | ||
lazyLoadConfig = _getFilteredBgProps.lazyLoadConfig, | ||
_getFilteredBgProps$l = _getFilteredBgProps.lazyLoading, | ||
lazyLoading = _getFilteredBgProps$l === void 0 ? config.lazyLoading : _getFilteredBgProps$l, | ||
children = _getFilteredBgProps.children, | ||
innerRef = _getFilteredBgProps.innerRef, | ||
doNotReplaceURL = _getFilteredBgProps.doNotReplaceURL, | ||
otherProps = _objectWithoutProperties(_getFilteredBgProps, _excluded); | ||
className = _getFilteredBgProps.className, | ||
style = _getFilteredBgProps.style, | ||
lazyLoadConfig = _getFilteredBgProps.lazyLoadConfig, | ||
_getFilteredBgProps$l = _getFilteredBgProps.lazyLoading, | ||
lazyLoading = _getFilteredBgProps$l === void 0 ? config.lazyLoading : _getFilteredBgProps$l, | ||
children = _getFilteredBgProps.children, | ||
innerRef = _getFilteredBgProps.innerRef, | ||
doNotReplaceURL = _getFilteredBgProps.doNotReplaceURL, | ||
otherProps = _objectWithoutProperties(_getFilteredBgProps, _excluded); | ||
(0, _react.useEffect)(function () { | ||
@@ -94,3 +71,2 @@ if (server) return; | ||
}, []); | ||
var containerProps = _objectSpread({ | ||
@@ -107,3 +83,2 @@ cloudimgURL: cloudimgURL, | ||
}, otherProps); | ||
if (server) { | ||
@@ -114,3 +89,2 @@ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { | ||
} | ||
if (!processed) { | ||
@@ -122,3 +96,2 @@ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { | ||
} | ||
return lazyLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLazyload["default"], _objectSpread(_objectSpread({ | ||
@@ -135,4 +108,3 @@ height: height, | ||
} | ||
var _default = BackgroundImg; | ||
exports["default"] = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -16,25 +14,16 @@ value: true | ||
exports["default"] = exports.Img = void 0; | ||
var _react = require("react"); | ||
var _img = _interopRequireDefault(require("../img")); | ||
var _background = _interopRequireDefault(require("../background")); | ||
var _provider = _interopRequireWildcard(require("../provider")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var Img = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) { | ||
@@ -41,0 +30,0 @@ var cloudImageContext = (0, _react.useContext)(_provider.CloudimageContext); |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var usePrevious = function usePrevious(value) { | ||
@@ -18,4 +16,3 @@ var ref = (0, _react.useRef)(); | ||
}; | ||
var _default = usePrevious; | ||
exports["default"] = _default; |
136
dist/img.js
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,68 +8,44 @@ value: true | ||
exports["default"] = void 0; | ||
var _react = require("react"); | ||
var _cloudimageResponsiveUtils = require("cloudimage-responsive-utils"); | ||
var _reactLazyload = _interopRequireDefault(require("react-lazyload")); | ||
var _utils = require("./utils"); | ||
var _usePrevious = _interopRequireDefault(require("./hooks/usePrevious")); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["alt", "className", "lazyLoadConfig", "preserveSize", "imgNodeWidth", "imgNodeHeight"], | ||
_excluded2 = ["innerRef", "onImgLoad", "disableAnimation", "doNotReplaceURL"]; | ||
_excluded2 = ["innerRef", "onImgLoad", "disableAnimation", "doNotReplaceURL", "config"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function Img(props) { | ||
var config = props.config, | ||
src = props.src, | ||
autoAlt = props.autoAlt, | ||
placeholderBackground = props.placeholderBackground; | ||
src = props.src, | ||
placeholderBackground = props.placeholderBackground; | ||
var _useState = (0, _react.useState)(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
loaded = _useState2[0], | ||
setLoaded = _useState2[1]; | ||
_useState2 = _slicedToArray(_useState, 2), | ||
loaded = _useState2[0], | ||
setLoaded = _useState2[1]; | ||
var _useState3 = (0, _react.useState)(false), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
previewLoaded = _useState4[0], | ||
setPreviewLoaded = _useState4[1]; | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
previewLoaded = _useState4[0], | ||
setPreviewLoaded = _useState4[1]; | ||
var _useState5 = (0, _react.useState)({}), | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
data = _useState6[0], | ||
setData = _useState6[1]; | ||
_useState6 = _slicedToArray(_useState5, 2), | ||
data = _useState6[0], | ||
setData = _useState6[1]; | ||
var _useState7 = (0, _react.useState)({}), | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
loadedImageDim = _useState8[0], | ||
setLoadedImageDim = _useState8[1]; | ||
_useState8 = _slicedToArray(_useState7, 2), | ||
loadedImageDim = _useState8[0], | ||
setLoadedImageDim = _useState8[1]; | ||
var imgNode = (0, _react.useRef)(); | ||
@@ -83,41 +60,37 @@ var previousProps = (0, _usePrevious["default"])({ | ||
var configLazyLoadingValue = config.lazyLoading, | ||
lazyLoadOffset = config.lazyLoadOffset, | ||
delay = config.delay, | ||
innerWidth = config.innerWidth; | ||
lazyLoadOffset = config.lazyLoadOffset, | ||
delay = config.delay, | ||
innerWidth = config.innerWidth; | ||
var _props$lazyLoading = props.lazyLoading, | ||
lazyLoading = _props$lazyLoading === void 0 ? configLazyLoadingValue : _props$lazyLoading; | ||
lazyLoading = _props$lazyLoading === void 0 ? configLazyLoadingValue : _props$lazyLoading; | ||
var ratio = data.ratio, | ||
operation = data.operation, | ||
preview = data.preview, | ||
previewCloudimgURL = data.previewCloudimgURL, | ||
cloudimgURL = data.cloudimgURL, | ||
cloudimgSRCSET = data.cloudimgSRCSET, | ||
height = data.height; | ||
operation = data.operation, | ||
preview = data.preview, | ||
previewCloudimgURL = data.previewCloudimgURL, | ||
cloudimgURL = data.cloudimgURL, | ||
cloudimgSRCSET = data.cloudimgSRCSET, | ||
height = data.height; | ||
var _getFilteredProps = (0, _utils.getFilteredProps)(props), | ||
alt = _getFilteredProps.alt, | ||
className = _getFilteredProps.className, | ||
lazyLoadConfig = _getFilteredProps.lazyLoadConfig, | ||
preserveSize = _getFilteredProps.preserveSize, | ||
imgNodeWidth = _getFilteredProps.imgNodeWidth, | ||
imgNodeHeight = _getFilteredProps.imgNodeHeight, | ||
otherProps = _objectWithoutProperties(_getFilteredProps, _excluded); | ||
alt = _getFilteredProps.alt, | ||
className = _getFilteredProps.className, | ||
lazyLoadConfig = _getFilteredProps.lazyLoadConfig, | ||
preserveSize = _getFilteredProps.preserveSize, | ||
imgNodeWidth = _getFilteredProps.imgNodeWidth, | ||
imgNodeHeight = _getFilteredProps.imgNodeHeight, | ||
otherProps = _objectWithoutProperties(_getFilteredProps, _excluded); | ||
var innerRef = otherProps.innerRef, | ||
onImgLoad = otherProps.onImgLoad, | ||
disableAnimation = otherProps.disableAnimation, | ||
doNotReplaceURL = otherProps.doNotReplaceURL, | ||
filteredProps = _objectWithoutProperties(otherProps, _excluded2); | ||
onImgLoad = otherProps.onImgLoad, | ||
disableAnimation = otherProps.disableAnimation, | ||
doNotReplaceURL = otherProps.doNotReplaceURL, | ||
_config = otherProps.config, | ||
filteredProps = _objectWithoutProperties(otherProps, _excluded2); | ||
var getcloudimgSRCSET = function getcloudimgSRCSET() { | ||
return cloudimgSRCSET.map(function (_ref) { | ||
var dpr = _ref.dpr, | ||
url = _ref.url; | ||
url = _ref.url; | ||
return "".concat(url, " ").concat(dpr, "x"); | ||
}).join(', '); | ||
}; | ||
var processImg = function processImg(update, windowScreenBecomesBigger) { | ||
var imageData = (0, _cloudimageResponsiveUtils.processReactNode)(props, imgNode.current, update, windowScreenBecomesBigger); | ||
if (imageData) { | ||
@@ -127,3 +100,2 @@ setData(imageData); | ||
}; | ||
var updateLoadedImageSize = function updateLoadedImageSize(image) { | ||
@@ -136,7 +108,5 @@ setLoadedImageDim({ | ||
}; | ||
var _onImgLoad = function _onImgLoad(event) { | ||
updateLoadedImageSize(event.target); | ||
setLoaded(true); | ||
if (typeof onImgLoad === 'function') { | ||
@@ -146,9 +116,2 @@ onImgLoad(event); | ||
}; | ||
var getAlt = function getAlt(name) { | ||
if (!name) return; | ||
var index = name.indexOf('.'); | ||
return name.slice(0, index); | ||
}; | ||
var onPreviewLoaded = function onPreviewLoaded(event) { | ||
@@ -160,3 +123,2 @@ if (previewLoaded) return; | ||
}; | ||
var pictureStyles = _cloudimageResponsiveUtils.imgStyles.picture({ | ||
@@ -172,3 +134,2 @@ preserveSize: preserveSize, | ||
}); | ||
var imageStyles = _cloudimageResponsiveUtils.imgStyles.image({ | ||
@@ -180,3 +141,2 @@ preserveSize: preserveSize, | ||
}); | ||
var pictureClassName = "".concat(className, " cloudimage-image ").concat(loaded ? 'loaded' : 'loading').trim(); | ||
@@ -187,3 +147,2 @@ (0, _react.useEffect)(function () { | ||
} | ||
if (typeof delay !== 'undefined' && !server) { | ||
@@ -199,7 +158,5 @@ setTimeout(function () { | ||
if (!previousProps) return; | ||
if (previousProps.innerWidth !== innerWidth) { | ||
processImg(true, innerWidth > previousProps.innerWidth); | ||
} | ||
if (src !== previousProps.src) { | ||
@@ -209,3 +166,3 @@ processImg(); | ||
}, [innerWidth, src]); | ||
var pictureAlt = !alt && autoAlt ? getAlt(src) : alt; | ||
var pictureAlt = alt || (0, _cloudimageResponsiveUtils.generateAlt)(src); | ||
var plainImage = /*#__PURE__*/(0, _jsxRuntime.jsx)("img", _objectSpread(_objectSpread(_objectSpread({}, filteredProps), {}, { | ||
@@ -234,3 +191,3 @@ ref: imgNode, | ||
src: previewCloudimgURL, | ||
alt: "low quality preview", | ||
alt: "low quality preview for ".concat(pictureAlt), | ||
onLoad: onPreviewLoaded | ||
@@ -264,4 +221,3 @@ }) | ||
} | ||
var _default = Img; | ||
exports["default"] = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -16,27 +14,17 @@ value: true | ||
exports["default"] = exports.Img = void 0; | ||
require("./polyfills"); | ||
var _react = require("react"); | ||
var _img = _interopRequireDefault(require("./img")); | ||
var _background = _interopRequireDefault(require("./background")); | ||
var _provider = _interopRequireWildcard(require("./provider")); | ||
require("./polyfills"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var Img = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) { | ||
@@ -43,0 +31,0 @@ var cloudImageContext = (0, _react.useContext)(_provider.CloudimageContext); |
"use strict"; | ||
require("core-js/features/array/find"); | ||
require("core-js/es/math/trunc"); | ||
require("core-js/features/array/for-each"); |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,29 +8,17 @@ value: true | ||
exports["default"] = exports.CloudimageContext = void 0; | ||
var _react = require("react"); | ||
var _throttleDebounce = require("throttle-debounce"); | ||
var _cloudimageResponsiveUtils = require("cloudimage-responsive-utils"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var CloudimageContext = /*#__PURE__*/(0, _react.createContext)({ | ||
@@ -39,84 +28,77 @@ cloudImageConfig: {} | ||
exports.CloudimageContext = CloudimageContext; | ||
function CloudimageProvider() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$config = _ref.config, | ||
config = _ref$config === void 0 ? {} : _ref$config, | ||
children = _ref.children; | ||
_ref$config = _ref.config, | ||
config = _ref$config === void 0 ? {} : _ref$config, | ||
children = _ref.children; | ||
var _config$token = config.token, | ||
token = _config$token === void 0 ? '' : _config$token, | ||
_config$domain = config.domain, | ||
domain = _config$domain === void 0 ? config.customDomain || 'cloudimg.io' : _config$domain, | ||
_config$customDomain = config.customDomain, | ||
customDomain = _config$customDomain === void 0 ? false : _config$customDomain, | ||
_config$lazyLoading = config.lazyLoading, | ||
lazyLoading = _config$lazyLoading === void 0 ? false : _config$lazyLoading, | ||
_config$lazyLoadOffse = config.lazyLoadOffset, | ||
lazyLoadOffset = _config$lazyLoadOffse === void 0 ? 100 : _config$lazyLoadOffse, | ||
_config$placeholderBa = config.placeholderBackground, | ||
placeholderBackground = _config$placeholderBa === void 0 ? '#f4f4f4' : _config$placeholderBa, | ||
baseUrl = config.baseUrl, | ||
baseURL = config.baseURL, | ||
_config$apiVersion = config.apiVersion, | ||
apiVersion = _config$apiVersion === void 0 ? 'v7' : _config$apiVersion, | ||
presets = config.presets, | ||
_config$ratio = config.ratio, | ||
ratio = _config$ratio === void 0 ? 1.5 : _config$ratio, | ||
_config$params = config.params, | ||
params = _config$params === void 0 ? 'org_if_sml=1' : _config$params, | ||
_config$imageSizeAttr = config.imageSizeAttributes, | ||
imageSizeAttributes = _config$imageSizeAttr === void 0 ? 'use' : _config$imageSizeAttr, | ||
_config$exactSize = config.exactSize, | ||
exactSize = _config$exactSize === void 0 ? false : _config$exactSize, | ||
_config$doNotReplaceU = config.doNotReplaceURL, | ||
doNotReplaceURL = _config$doNotReplaceU === void 0 ? false : _config$doNotReplaceU, | ||
_config$limitFactor = config.limitFactor, | ||
limitFactor = _config$limitFactor === void 0 ? 100 : _config$limitFactor, | ||
_config$devicePixelRa = config.devicePixelRatioList, | ||
devicePixelRatioList = _config$devicePixelRa === void 0 ? _cloudimageResponsiveUtils.CONSTANTS.DEVICE_PIXEL_RATIO_LIST : _config$devicePixelRa, | ||
_config$lowQualityPre = config.lowQualityPreview; | ||
_config$lowQualityPre = _config$lowQualityPre === void 0 ? {} : _config$lowQualityPre; | ||
var _config$lowQualityPre2 = _config$lowQualityPre.minImgWidth, | ||
minImgWidth = _config$lowQualityPre2 === void 0 ? 250 : _config$lowQualityPre2, | ||
_config$autoAlt = config.autoAlt, | ||
autoAlt = _config$autoAlt === void 0 ? false : _config$autoAlt; | ||
token = _config$token === void 0 ? '' : _config$token, | ||
_config$domain = config.domain, | ||
domain = _config$domain === void 0 ? config.customDomain || 'cloudimg.io' : _config$domain, | ||
_config$customDomain = config.customDomain, | ||
customDomain = _config$customDomain === void 0 ? false : _config$customDomain, | ||
_config$lazyLoading = config.lazyLoading, | ||
lazyLoading = _config$lazyLoading === void 0 ? false : _config$lazyLoading, | ||
_config$lazyLoadOffse = config.lazyLoadOffset, | ||
lazyLoadOffset = _config$lazyLoadOffse === void 0 ? 100 : _config$lazyLoadOffse, | ||
_config$placeholderBa = config.placeholderBackground, | ||
placeholderBackground = _config$placeholderBa === void 0 ? '#f4f4f4' : _config$placeholderBa, | ||
baseUrl = config.baseUrl, | ||
baseURL = config.baseURL, | ||
_config$apiVersion = config.apiVersion, | ||
apiVersion = _config$apiVersion === void 0 ? 'v7' : _config$apiVersion, | ||
presets = config.presets, | ||
_config$ratio = config.ratio, | ||
ratio = _config$ratio === void 0 ? 1.5 : _config$ratio, | ||
_config$params = config.params, | ||
params = _config$params === void 0 ? 'org_if_sml=1' : _config$params, | ||
_config$imageSizeAttr = config.imageSizeAttributes, | ||
imageSizeAttributes = _config$imageSizeAttr === void 0 ? 'use' : _config$imageSizeAttr, | ||
_config$exactSize = config.exactSize, | ||
exactSize = _config$exactSize === void 0 ? false : _config$exactSize, | ||
_config$doNotReplaceU = config.doNotReplaceURL, | ||
doNotReplaceURL = _config$doNotReplaceU === void 0 ? false : _config$doNotReplaceU, | ||
_config$limitFactor = config.limitFactor, | ||
limitFactor = _config$limitFactor === void 0 ? 100 : _config$limitFactor, | ||
_config$devicePixelRa = config.devicePixelRatioList, | ||
devicePixelRatioList = _config$devicePixelRa === void 0 ? _cloudimageResponsiveUtils.CONSTANTS.DEVICE_PIXEL_RATIO_LIST : _config$devicePixelRa, | ||
_config$lowQualityPre = config.lowQualityPreview, | ||
_config$lowQualityPre2 = _config$lowQualityPre === void 0 ? {} : _config$lowQualityPre, | ||
_config$lowQualityPre3 = _config$lowQualityPre2.minImgWidth, | ||
minImgWidth = _config$lowQualityPre3 === void 0 ? 250 : _config$lowQualityPre3; | ||
var _useState = (0, _react.useState)({ | ||
token: token, | ||
domain: domain, | ||
customDomain: customDomain, | ||
lazyLoading: lazyLoading, | ||
lazyLoadOffset: lazyLoadOffset, | ||
placeholderBackground: placeholderBackground, | ||
baseURL: baseUrl || baseURL, | ||
ratio: ratio, | ||
exactSize: exactSize, | ||
presets: presets || { | ||
xs: '(max-width: 575px)', | ||
// to 575 PHONE | ||
sm: '(min-width: 576px)', | ||
// 576 - 767 PHABLET | ||
md: '(min-width: 768px)', | ||
// 768 - 991 TABLET | ||
lg: '(min-width: 992px)', | ||
// 992 - 1199 SMALL_LAPTOP_SCREEN | ||
xl: '(min-width: 1200px)' // from 1200 USUALSCREEN | ||
token: token, | ||
domain: domain, | ||
customDomain: customDomain, | ||
lazyLoading: lazyLoading, | ||
lazyLoadOffset: lazyLoadOffset, | ||
placeholderBackground: placeholderBackground, | ||
baseURL: baseUrl || baseURL, | ||
ratio: ratio, | ||
exactSize: exactSize, | ||
presets: presets || { | ||
xs: '(max-width: 575px)', | ||
// to 575 PHONE | ||
sm: '(min-width: 576px)', | ||
// 576 - 767 PHABLET | ||
md: '(min-width: 768px)', | ||
// 768 - 991 TABLET | ||
lg: '(min-width: 992px)', | ||
// 992 - 1199 SMALL_LAPTOP_SCREEN | ||
xl: '(min-width: 1200px)' // from 1200 USUALSCREEN | ||
}, | ||
}, | ||
params: (0, _cloudimageResponsiveUtils.processParams)(params), | ||
apiVersion: apiVersion, | ||
innerWidth: typeof window !== 'undefined' ? window.innerWidth : null, | ||
previewQualityFactor: 10, | ||
doNotReplaceURL: doNotReplaceURL, | ||
devicePixelRatioList: devicePixelRatioList, | ||
limitFactor: limitFactor, | ||
minLowQualityWidth: minImgWidth, | ||
imageSizeAttributes: imageSizeAttributes, | ||
autoAlt: autoAlt | ||
}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
cloudImageConfig = _useState2[0], | ||
setCloudImageConfig = _useState2[1]; | ||
params: (0, _cloudimageResponsiveUtils.processParams)(params), | ||
apiVersion: apiVersion, | ||
innerWidth: typeof window !== 'undefined' ? window.innerWidth : null, | ||
previewQualityFactor: 10, | ||
doNotReplaceURL: doNotReplaceURL, | ||
devicePixelRatioList: devicePixelRatioList, | ||
limitFactor: limitFactor, | ||
minLowQualityWidth: minImgWidth, | ||
imageSizeAttributes: imageSizeAttributes | ||
}), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
cloudImageConfig = _useState2[0], | ||
setCloudImageConfig = _useState2[1]; | ||
var updateDimensions = (0, _throttleDebounce.debounce)(100, function () { | ||
@@ -131,3 +113,2 @@ setCloudImageConfig(_objectSpread(_objectSpread({}, cloudImageConfig), {}, { | ||
} | ||
return function () { | ||
@@ -146,4 +127,3 @@ window.removeEventListener('resize', updateDimensions); | ||
} | ||
var _default = CloudimageProvider; | ||
exports["default"] = _default; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,29 +9,24 @@ value: true | ||
var _excluded = ["config", "alt", "className", "src", "sizes", "width", "height", "params", "lazyLoading"], | ||
_excluded2 = ["config", "alt", "className", "src", "sizes", "width", "height", "params"]; | ||
_excluded2 = ["config", "alt", "className", "src", "sizes", "width", "height", "params"]; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var getFilteredProps = function getFilteredProps(_ref) { | ||
var _ref$config = _ref.config, | ||
config = _ref$config === void 0 ? {} : _ref$config, | ||
_ref$alt = _ref.alt, | ||
alt = _ref$alt === void 0 ? '' : _ref$alt, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? '' : _ref$className, | ||
src = _ref.src, | ||
sizes = _ref.sizes, | ||
width = _ref.width, | ||
height = _ref.height, | ||
params = _ref.params, | ||
lazyLoading = _ref.lazyLoading, | ||
otherProps = _objectWithoutProperties(_ref, _excluded); | ||
config = _ref$config === void 0 ? {} : _ref$config, | ||
_ref$alt = _ref.alt, | ||
alt = _ref$alt === void 0 ? '' : _ref$alt, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? '' : _ref$className, | ||
src = _ref.src, | ||
sizes = _ref.sizes, | ||
width = _ref.width, | ||
height = _ref.height, | ||
params = _ref.params, | ||
lazyLoading = _ref.lazyLoading, | ||
otherProps = _objectWithoutProperties(_ref, _excluded); | ||
return _objectSpread({ | ||
@@ -43,19 +39,16 @@ alt: alt, | ||
}; | ||
exports.getFilteredProps = getFilteredProps; | ||
var getFilteredBgProps = function getFilteredBgProps(_ref2) { | ||
var _ref2$config = _ref2.config, | ||
config = _ref2$config === void 0 ? {} : _ref2$config, | ||
_ref2$alt = _ref2.alt, | ||
alt = _ref2$alt === void 0 ? '' : _ref2$alt, | ||
_ref2$className = _ref2.className, | ||
className = _ref2$className === void 0 ? '' : _ref2$className, | ||
src = _ref2.src, | ||
sizes = _ref2.sizes, | ||
width = _ref2.width, | ||
height = _ref2.height, | ||
params = _ref2.params, | ||
otherProps = _objectWithoutProperties(_ref2, _excluded2); | ||
config = _ref2$config === void 0 ? {} : _ref2$config, | ||
_ref2$alt = _ref2.alt, | ||
alt = _ref2$alt === void 0 ? '' : _ref2$alt, | ||
_ref2$className = _ref2.className, | ||
className = _ref2$className === void 0 ? '' : _ref2$className, | ||
src = _ref2.src, | ||
sizes = _ref2.sizes, | ||
width = _ref2.width, | ||
height = _ref2.height, | ||
params = _ref2.params, | ||
otherProps = _objectWithoutProperties(_ref2, _excluded2); | ||
return _objectSpread({ | ||
@@ -66,3 +59,2 @@ alt: alt, | ||
}; | ||
exports.getFilteredBgProps = getFilteredBgProps; |
{ | ||
"name": "react-cloudimage-responsive", | ||
"version": "3.6.4", | ||
"version": "3.6.5", | ||
"main": "dist/index.js", | ||
@@ -43,5 +43,5 @@ "description": "Cloudimage Responsive will smartly resize, compress and accelerate images across the World in your site for all devices. The plugin supports lazy loading technique with fancy animation on image load.", | ||
"dependencies": { | ||
"cloudimage-responsive-utils": "^2.4.9", | ||
"cloudimage-responsive-utils": "^2.5.1", | ||
"core-js": "^3.15.2", | ||
"prop-types": "15.8.1", | ||
"core-js": "^3.15.2", | ||
"react-lazyload": "^3.2.0", | ||
@@ -52,3 +52,3 @@ "throttle-debounce": "^3.0.1" | ||
"@babel/cli": "^7.14.5", | ||
"@babel/core": "^7.14.6", | ||
"@babel/core": "^7.21.4", | ||
"@babel/plugin-proposal-class-properties": "^7.14.5", | ||
@@ -63,9 +63,8 @@ "@babel/plugin-proposal-decorators": "^7.14.5", | ||
"@babel/plugin-syntax-import-meta": "^7.0.0", | ||
"@babel/preset-env": "^7.14.7", | ||
"@babel/preset-env": "^7.21.4", | ||
"@babel/preset-react": "^7.14.5", | ||
"babel-loader": "^8.2.2", | ||
"css-loader": "^2.0.0", | ||
"babel-loader": "^9.1.2", | ||
"css-loader": "^6.7.3", | ||
"eslint": "^8.10.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-jsx-a11y": "^6.5.1", | ||
@@ -75,11 +74,11 @@ "eslint-plugin-react": "^7.29.3", | ||
"gh-pages": "^2.0.1", | ||
"html-webpack-plugin": "^3.2.0", | ||
"html-webpack-plugin": "^5.5.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-syntax-highlighter": "^10.2.0", | ||
"style-loader": "^0.23.1", | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.11.2" | ||
"react-syntax-highlighter": "^15.5.0", | ||
"style-loader": "^3.3.2", | ||
"webpack": "^5.79.0", | ||
"webpack-cli": "^5.0.1", | ||
"webpack-dev-server": "^4.13.3" | ||
} | ||
} |
@@ -20,2 +20,7 @@ [![Release](https://img.shields.io/github/v/release/scaleflex/react-cloudimage-responsive)](https://github.com/scaleflex/js-cloudimage-responsive/releases) | ||
</a> | ||
<!-- <a href="https://www.cloudimage.io/#gh-dark-mode-only"> | ||
<img | ||
alt="The Lounge" | ||
src="https://scaleflex.cloudimg.io/v7/cloudimage.io/cloudimage-logo-light.png?vh=b798ab&w=350"> | ||
</a> --> | ||
</p> | ||
@@ -69,2 +74,3 @@ | ||
* [Responsive plugins family](#plugin_family) | ||
* [Compatibility](#compatibility) | ||
* [Requirements](#requirements) | ||
@@ -95,9 +101,14 @@ * [Step 1: Installation](#installation) | ||
<details> | ||
<summary>Javascript</summary> | ||
<a href="https://github.com/scaleflex/js-cloudimage-responsive">Js Cloudimage Responsive (Low Quality Preview)</a><br/> | ||
<a href="https://github.com/scaleflex/js-cloudimage-responsive/blob/master/README-BLUR-HASH.md">Js Cloudimage Responsive (Blur-hash)</a><br/> | ||
<a href="https://github.com/scaleflex/js-cloudimage-responsive/blob/master/README-PLAIN.md">Js Cloudimage Responsive (Plain)</a> | ||
<summary>React</summary> | ||
<a href="https://github.com/scaleflex/react-cloudimage-responsive">React Cloudimage Responsive (Low Quality Preview)</a><br/> | ||
<a href="https://github.com/scaleflex/react-cloudimage-responsive-blur-hash">React Cloudimage Responsive (Blur-hash)</a><br/> | ||
<a href="https://github.com/scaleflex/react-cloudimage-responsive-plain">React Cloudimage Responsive (Plain)</a> | ||
</details> | ||
<details> | ||
<summary>Next.js</summary> | ||
<a href="https://github.com/scaleflex/next-cloudimage-responsive">Vue Cloudimage Responsive (Low Quality Preview)</a><br/> | ||
</details> | ||
<details> | ||
<summary>Vue.js</summary> | ||
@@ -114,2 +125,8 @@ <a href="https://github.com/scaleflex/vue-cloudimage-responsive">Vue Cloudimage Responsive (Low Quality Preview)</a><br/> | ||
## <a name="compatibility"></a> Compatibility | ||
| Version | React Version | | ||
|---------|--------------| | ||
| >3.6.3 | >=18.0.0 | | ||
| <=3.6.3 | <=17.x.x | | ||
## <a name="requirements"/> Requirements | ||
@@ -116,0 +133,0 @@ |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable import/no-nodejs-modules */ | ||
/* eslint-disable import/no-commonjs */ | ||
const path = require('path'); | ||
@@ -2,0 +4,0 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); |
Sorry, the diff of this file is not supported yet
79191
29
938
532