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

cloudimage-responsive-utils

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudimage-responsive-utils - npm Package Compare versions

Comparing version 2.0.8 to 2.0.9

dist/utils/background.styles.js

18

dist/index.js

@@ -116,3 +116,9 @@ "use strict";

});
exports.CONSTANTS = exports.blurhash = void 0;
Object.defineProperty(exports, "determineContainerProps", {
enumerable: true,
get: function get() {
return _determineContainerProps.determineContainerProps;
}
});
exports.CONSTANTS = exports.blurhash = exports.backgroundStyles = exports.imgStyles = void 0;

@@ -155,2 +161,12 @@ var _isServer = require("./utils/is-server");

var _determineContainerProps = require("./utils/determine-container-props");
var _imgStyles = _interopRequireWildcard(require("./utils/img.styles"));
exports.imgStyles = _imgStyles;
var _backgroundStyles = _interopRequireWildcard(require("./utils/background.styles"));
exports.backgroundStyles = _backgroundStyles;
var _blurhash = _interopRequireWildcard(require("./libs/blur-hash"));

@@ -157,0 +173,0 @@

2

dist/libs/blur-hash/error.js

@@ -14,3 +14,3 @@ "use strict";

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

@@ -17,0 +17,0 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

@@ -18,3 +18,3 @@ "use strict";

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 _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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

@@ -51,3 +51,3 @@ 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; }

return [doNotReplaceURL ? '' : "https://".concat(token, ".").concat(domain, "/v7/"), src, src.indexOf('?') !== -1 ? '&' : '?', getQueryString({
params: _objectSpread(_objectSpread({}, config.params), params),
params: _objectSpread({}, config.params, {}, params),
width: width,

@@ -54,0 +54,0 @@ height: height,

@@ -12,3 +12,3 @@ "use strict";

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 _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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

@@ -15,0 +15,0 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }

@@ -26,3 +26,3 @@ "use strict";

var previewParams = _objectSpread(_objectSpread({}, params), {}, {
var previewParams = _objectSpread({}, params, {
ci_info: ''

@@ -38,3 +38,3 @@ });

config: config,
params: _objectSpread(_objectSpread({}, previewParams), lowQualitySize),
params: _objectSpread({}, previewParams, {}, lowQualitySize),
devicePixelRatio: devicePixelRatio

@@ -41,0 +41,0 @@ });

@@ -8,5 +8,11 @@ "use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var processParams = function processParams(params) {
var resultParams = {};
if (_typeof(params) === 'object') {
return params;
}
try {

@@ -13,0 +19,0 @@ resultParams = JSON.parse('{"' + decodeURI(params.replace(/&/g, "\",\"").replace(/=/g, "\":\"")) + '"}');

@@ -12,4 +12,2 @@ "use strict";

var _getHeight = require("../utils/get-height");
var _getImgSrc = require("../utils/get-img-src");

@@ -19,15 +17,7 @@

var _getRatio = require("../utils/get-ratio");
var _getWidth3 = require("../utils/get-width");
var _getSizeLimit = require("../utils/get-size-limit");
var _isLowQualityPreview = require("../utils/is-low-quality-preview");
var _isCrop = require("../utils/is-crop");
var _processParams = require("../utils/process-params");
var _constants = require("../constants");
var _determineContainerProps = require("../utils/determine-container-props");

@@ -44,3 +34,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

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 _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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

@@ -80,3 +70,3 @@ 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; }

var containerProps = determineContainerProps(_objectSpread({
var containerProps = (0, _determineContainerProps.determineContainerProps)(_objectSpread({
imgNode: imgNode,

@@ -106,2 +96,3 @@ config: config,

});
var operation = params.func || config.func;

@@ -118,2 +109,3 @@ if (preview) {

return _objectSpread({
imgProps: imgProps,
cloudimgURL: cloudimgURL,

@@ -123,3 +115,4 @@ previewCloudimgURL: previewCloudimgURL,

processed: true,
preview: preview
preview: preview,
operation: operation
}, containerProps);

@@ -146,79 +139,2 @@ };

};
};
var determineContainerProps = function determineContainerProps(props) {
var imgNode = props.imgNode,
_props$config = props.config,
config = _props$config === void 0 ? {} : _props$config,
imgNodeWidth = props.imgNodeWidth,
imgNodeHeight = props.imgNodeHeight,
imgNodeRatio = props.imgNodeRatio,
params = props.params,
size = props.size;
var ignoreNodeImgSize = config.ignoreNodeImgSize;
var ratio = null;
var crop = (0, _isCrop.isCrop)(params.func || config.params.func);
var exactSize = config.exactSize,
limitFactor = config.limitFactor;
var _getWidth = (0, _getWidth3.getWidth)({
imgNode: imgNode,
config: config,
exactSize: exactSize,
imgNodeWidth: imgNodeWidth,
params: _objectSpread(_objectSpread({}, config.params), params),
size: size
}),
_getWidth2 = _slicedToArray(_getWidth, 2),
width = _getWidth2[0],
isLimit = _getWidth2[1];
var height = (0, _getHeight.getHeight)({
imgNode: imgNode,
config: config,
exactSize: exactSize,
imgNodeHeight: imgNodeHeight,
imgNodeWidth: imgNodeWidth,
imgNodeRatio: imgNodeRatio,
params: _objectSpread(_objectSpread({}, config.params), params),
size: size,
width: width
});
ratio = (0, _getRatio.getRatio)({
imgNodeRatio: imgNodeRatio,
width: width,
height: height,
size: size,
config: config,
imgNodeWidth: imgNodeWidth,
imgNodeHeight: imgNodeHeight
});
var sizes = _constants.DEVICE_PIXEL_RATIO_LIST.map(function (dpr) {
var widthWithDPR, heightWithDRP;
widthWithDPR = width && width * dpr;
widthWithDPR = crop ? widthWithDPR : isLimit ? (0, _getSizeLimit.getSizeLimit)(widthWithDPR, exactSize, limitFactor) : widthWithDPR;
heightWithDRP = height && height * dpr;
if (!heightWithDRP && widthWithDPR && ratio) {
heightWithDRP = Math.floor(widthWithDPR / ratio);
}
if (!widthWithDPR && heightWithDRP && ratio) {
widthWithDPR = Math.floor(heightWithDRP * ratio);
}
return {
width: widthWithDPR,
height: heightWithDRP,
ratio: ratio
};
});
return {
sizes: sizes,
ratio: ratio,
width: width,
height: height
};
};
{
"name": "cloudimage-responsive-utils",
"version": "2.0.8",
"version": "2.0.9",
"description": "cloudimage responsive utils",
"main": "dist/index.js",
"scripts": {
"clean-dist": "shx rm -rf dist",
"clean-dist": "rm -rf dist",
"dist": "npm run clean-dist && babel src -d dist --copy-files"

@@ -36,5 +36,4 @@ },

"babel-preset-minify": "^0.5.0",
"cross-env": "^7.0.2",
"shx": "^0.3.2"
"cross-env": "^7.0.2"
}
}

@@ -22,2 +22,5 @@ ///*

export { convertToPX } from './utils/convert-to-px';
export { determineContainerProps } from './utils/determine-container-props';
export * as imgStyles from './utils/img.styles';
export * as backgroundStyles from './utils/background.styles';
//* libs

@@ -24,0 +27,0 @@ //* */

export const processParams = (params) => {
let resultParams = {};
if (typeof params === 'object') {
return params;
}
try {

@@ -5,0 +9,0 @@ resultParams = JSON.parse('{"' + decodeURI(params.replace(/&/g, "\",\"").replace(/=/g, "\":\"")) + '"}');

import { generateURL } from '../utils/generate-url';
import { getBreakpoint } from '../utils/get-breakpoint';
import { getHeight } from '../utils/get-height';
import { getImgSRC } from '../utils/get-img-src';
import { getPreviewSRC } from '../utils/get-preview-src';
import { getRatio } from '../utils/get-ratio';
import { getWidth } from '../utils/get-width';
import { getSizeLimit } from '../utils/get-size-limit';
import { isLowQualityPreview } from '../utils/is-low-quality-preview';
import { isCrop } from '../utils/is-crop';
import { processParams } from '../utils/process-params';
import { DEVICE_PIXEL_RATIO_LIST } from '../constants';
import { determineContainerProps } from '../utils/determine-container-props';

@@ -41,2 +36,3 @@

const cloudimgSRCSET = devicePixelRatioList.map(dpr => ({ dpr: dpr.toString(), url: generateURLbyDPR(dpr) }));
const operation = params.func || config.func;

@@ -48,2 +44,3 @@ if (preview) {

return {
imgProps,
cloudimgURL,

@@ -54,2 +51,3 @@ previewCloudimgURL,

preview,
operation,
...containerProps

@@ -69,52 +67,1 @@ };

const determineContainerProps = props => {
const { imgNode, config = {}, imgNodeWidth, imgNodeHeight, imgNodeRatio, params, size } = props;
const { ignoreNodeImgSize } = config;
let ratio = null;
const crop = isCrop(params.func || config.params.func);
const { exactSize, limitFactor } = config;
let [width, isLimit] = getWidth({
imgNode, config, exactSize, imgNodeWidth, params: { ...config.params, ...params }, size
});
let height = getHeight({
imgNode,
config,
exactSize,
imgNodeHeight,
imgNodeWidth,
imgNodeRatio,
params: { ...config.params, ...params },
size,
width
});
ratio = getRatio({ imgNodeRatio, width, height, size, config, imgNodeWidth, imgNodeHeight });
const sizes = DEVICE_PIXEL_RATIO_LIST.map(dpr => {
let widthWithDPR, heightWithDRP;
widthWithDPR = width && (width * dpr);
widthWithDPR = crop ?
widthWithDPR
:
isLimit ?
getSizeLimit(widthWithDPR, exactSize, limitFactor)
:
widthWithDPR;
heightWithDRP = height && (height * dpr);
if (!heightWithDRP && widthWithDPR && ratio) {
heightWithDRP = Math.floor(widthWithDPR / ratio);
}
if (!widthWithDPR && heightWithDRP && ratio) {
widthWithDPR = Math.floor(heightWithDRP * ratio);
}
return { width: widthWithDPR, height: heightWithDRP, ratio };
});
return { sizes, ratio, width, height };
};
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