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

@wix/image-kit

Package Overview
Dependencies
Maintainers
17
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/image-kit - npm Package Compare versions

Comparing version 1.26.0 to 1.27.0

78

dist/cjs/api/max/api.js

@@ -6,17 +6,9 @@ "use strict";

exports.getPlaceholder = getPlaceholder;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
var _imageServiceUtils = require("../../helpers/imageServiceUtils");
var _attributes = require("../../engines/attributes");
var _transform = require("../transform");
var _uri = require("../uri");
var _srcset = require("../srcset");
var _imagePlaceholderUtils = require("../../helpers/imagePlaceholderUtils");
const PLACEHOLDER_IMG_CSS_OVERRIDES = {

@@ -26,2 +18,3 @@ width: '100%',

};
/**

@@ -38,3 +31,2 @@ * returns image _placeholder_ transform uri and the

*/
function getPlaceholder(fittingType, src, target, options = {}) {

@@ -44,9 +36,8 @@ if (!(0, _imageServiceUtils.isValidRequest)(fittingType, src, target)) {

}
const _options$autoEncode = options.autoEncode,
autoEncode = _options$autoEncode === void 0 ? true : _options$autoEncode,
isSEOBot = options.isSEOBot,
shouldLoadHQImage = options.shouldLoadHQImage;
const {
autoEncode = true,
isSEOBot,
shouldLoadHQImage
} = options;
const canTransformImage = (0, _imageServiceUtils.isImageTransformApplicable)(src.id);
if (!canTransformImage || shouldLoadHQImage) {

@@ -57,14 +48,18 @@ /* Either:

*/
return getData(fittingType, src, target, { ...options,
return getData(fittingType, src, target, {
...options,
autoEncode,
useSrcset: canTransformImage
});
} // If there aren't dimensions, we make them up
}
const newTarget = { ...target,
// If there aren't dimensions, we make them up
const newTarget = {
...target,
...(0, _imagePlaceholderUtils.validateTargetDimensions)(src, target)
};
const alignment = newTarget.alignment,
htmlTag = newTarget.htmlTag;
const {
alignment,
htmlTag
} = newTarget;
const isFakeTile = (0, _imagePlaceholderUtils.getIsFakeTile)(fittingType, src, newTarget);

@@ -75,4 +70,6 @@ const scaledDimensions = (0, _imagePlaceholderUtils.getScaledDimensions)(fittingType, src, newTarget, isSEOBot);

const overrideCSS = (0, _imagePlaceholderUtils.getCSSOverrides)(fittingType, src, target, alignment);
const _getData = getData(convertedFittingType, src, { ...scaledDimensions,
const {
uri
} = getData(convertedFittingType, src, {
...scaledDimensions,
alignment,

@@ -85,13 +82,11 @@ htmlTag

} : {}
}),
uri = _getData.uri;
const _getData2 = getData(fittingType, src, { ...newTarget,
});
const {
attr = {},
css
} = getData(fittingType, src, {
...newTarget,
alignment,
htmlTag
}, {}),
_getData2$attr = _getData2.attr,
attr = _getData2$attr === void 0 ? {} : _getData2$attr,
css = _getData2.css;
}, {});
css.img = css.img || {};

@@ -108,2 +103,3 @@ css.container = css.container || {};

}
/**

@@ -120,19 +116,17 @@ * returns image transform uri and the

*/
function getData(fittingType, src, target, options) {
let data = {}; // check if valid request
let data = {};
// check if valid request
if ((0, _imageServiceUtils.isValidRequest)(fittingType, src, target)) {
// handle site BG legacy fitting types if needed
const targetObj = (0, _transform.getTarget)(fittingType, src, target); // parse request and create working OBJ
const targetObj = (0, _transform.getTarget)(fittingType, src, target);
// parse request and create working OBJ
const transformObj = (0, _transform.getTransform)(fittingType, src, targetObj, options);
data.uri = (0, _uri.getURI)(fittingType, src, targetObj, options, transformObj);
if (options != null && options.useSrcset) {
data.srcset = (0, _srcset.getSrcset)(fittingType, src, targetObj, options, data);
} // set the CSS or the SVG property
}
// set the CSS or the SVG property
Object.assign(data, (0, _attributes.getAttributes)(transformObj, targetObj), {

@@ -144,7 +138,7 @@ transformed: transformObj.transformed

data = _imageServiceConstants.emptyData;
} // return data to be used in html
}
// return data to be used in html
return data;
}
//# sourceMappingURL=api.js.map

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

exports.sdk = exports.STATIC_MEDIA_URL = void 0;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
exports.alignTypes = _imageServiceConstants.alignTypes;

@@ -24,16 +22,9 @@ exports.fittingTypes = _imageServiceConstants.fittingTypes;

exports.upscaleMethods = _imageServiceConstants.upscaleMethods;
var _populateFeatureSupport = require("../../helpers/populateFeatureSupport");
exports.populateGlobalFeatureSupport = _populateFeatureSupport.populateGlobalFeatureSupport;
var _api = require("./api");
exports.getData = _api.getData;
exports.getPlaceholder = _api.getPlaceholder;
var _sdk = require("../../sdk");
var _types = require("../../types");
Object.keys(_types).forEach(function (key) {

@@ -40,0 +31,0 @@ if (key === "default" || key === "__esModule") return;

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

exports.getSrcset = getSrcset;
var _uri = require("./uri");
function getSrcset(fittingType, src, target, options, data) {
const dpr = target.pixelAspectRatio || 1;
return {
dpr: [`${dpr === 1 ? data.uri : (0, _uri.getURI)(fittingType, src, { ...target,
dpr: [`${dpr === 1 ? data.uri : (0, _uri.getURI)(fittingType, src, {
...target,
pixelAspectRatio: 1
}, options)} 1x`, `${dpr === 2 ? data.uri : (0, _uri.getURI)(fittingType, src, { ...target,
}, options)} 1x`, `${dpr === 2 ? data.uri : (0, _uri.getURI)(fittingType, src, {
...target,
pixelAspectRatio: 2

@@ -16,0 +16,0 @@ }, options)} 2x`]

@@ -6,13 +6,7 @@ "use strict";

exports.getTransform = getTransform;
var _imageServiceUtils = require("../helpers/imageServiceUtils");
var _browserFeatureSupport = require("../helpers/browserFeatureSupport");
var _imageTransformParts = require("../helpers/imageTransformParts");
var _imageTransformOptions = require("../helpers/imageTransformOptions");
var _imageServiceConstants = require("../helpers/imageServiceConstants");
/**

@@ -30,3 +24,2 @@ * returns image transform data

const _isSEOBot = (0, _imageServiceUtils.isSEOBot)(options);
const fileType = (0, _imageServiceUtils.getFileType)(src.id);

@@ -65,3 +58,2 @@ const fileName = (0, _imageServiceUtils.getFileName)(src.id, src.name);

};
if (canTransformImage) {

@@ -71,5 +63,5 @@ (0, _imageTransformParts.setTransformParts)(transformsObj, src, target);

}
return transformsObj;
}
/**

@@ -85,11 +77,9 @@ * returns target data

*/
function getTarget(fittingType, src, target) {
const targetObj = { ...target
const targetObj = {
...target
};
const _isMobile = (0, _browserFeatureSupport.isMobile)();
const _isMobile = (0, _browserFeatureSupport.isMobile)(); // handle site BG legacy fitting types (desktop & mobile)
// handle site BG legacy fitting types (desktop & mobile)
switch (fittingType) {

@@ -103,9 +93,8 @@ case _imageServiceConstants.fittingTypes.LEGACY_BG_FIT_AND_TILE:

targetObj.width = Math.min(maxBGSiteLegacyWidth, src.width);
targetObj.height = Math.min(maxBGSiteLegacyHeight, Math.round(targetObj.width / (src.width / src.height))); // for legacy types force htmlTag='bg' and devicePixelRatio=1
targetObj.height = Math.min(maxBGSiteLegacyHeight, Math.round(targetObj.width / (src.width / src.height)));
// for legacy types force htmlTag='bg' and devicePixelRatio=1
targetObj.pixelAspectRatio = 1;
}
return targetObj;
}
//# sourceMappingURL=transform.js.map

@@ -5,9 +5,5 @@ "use strict";

exports.getURI = getURI;
var _imageServiceUtils = require("../helpers/imageServiceUtils");
var _transforms = require("../engines/transforms");
var _transform = require("./transform");
/**

@@ -27,9 +23,9 @@ * returns image transform uri

if ((0, _imageServiceUtils.isImageTransformApplicable)(src.id)) {
transformObj = transformObj || (0, _transform.getTransform)(fittingType, src, target, options); // set the uri property
transformObj = transformObj || (0, _transform.getTransform)(fittingType, src, target, options);
// set the uri property
return (0, _transforms.getImageURI)(transformObj);
}
return src.id;
}
//# sourceMappingURL=uri.js.map

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

exports.getData = getData;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
exports.fittingTypes = _imageServiceConstants.fittingTypes;

@@ -13,13 +11,7 @@ exports.alignTypes = _imageServiceConstants.alignTypes;

exports.upscaleMethods = _imageServiceConstants.upscaleMethods;
var _imageServiceUtils = require("../../helpers/imageServiceUtils");
var _populateFeatureSupport = require("../../helpers/populateFeatureSupport");
exports.populateGlobalFeatureSupport = _populateFeatureSupport.populateGlobalFeatureSupport;
var _transform = require("../transform");
var _uri = require("../uri");
/**

@@ -39,4 +31,4 @@ * returns image transform uri

// handle site BG legacy fitting types
const targetObj = (0, _transform.getTarget)(fittingType, src, target); // parse request and create working OBJ
const targetObj = (0, _transform.getTarget)(fittingType, src, target);
// parse request and create working OBJ
const transformObj = (0, _transform.getTransform)(fittingType, src, targetObj, options);

@@ -47,3 +39,2 @@ return {

}
return {

@@ -50,0 +41,0 @@ uri: ''

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

exports.getAttributes = getAttributes;
var _imageServiceConstants = require("../helpers/imageServiceConstants");
var _backgroundAttributes = require("./attributes/backgroundAttributes");
var _imgAttributes = require("./attributes/imgAttributes");
var _SVGAttributes = require("./attributes/SVGAttributes");
/**

@@ -24,3 +19,2 @@ * get CSS or SVG attributes to be used in the browser

let attributesGetter;
if (target.htmlTag === _imageServiceConstants.htmlTag.BG) {

@@ -33,5 +27,4 @@ attributesGetter = _backgroundAttributes.get;

}
return attributesGetter(transformsObj, target);
}
//# sourceMappingURL=attributes.js.map

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

exports.get = getCSS;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
/**

@@ -22,5 +20,10 @@ * returns BG tag CSS data

};
const css = attributes.css;
const fittingType = transformsObj.fittingType; // set fitting
const {
css
} = attributes;
const {
fittingType
} = transformsObj;
// set fitting
switch (fittingType) {

@@ -33,3 +36,2 @@ case _imageServiceConstants.fittingTypes.ORIGINAL_SIZE:

break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FIT:

@@ -40,3 +42,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_SCALE_TO_FIT:

break;
case _imageServiceConstants.fittingTypes.STRETCH:

@@ -46,3 +47,2 @@ css.container.backgroundSize = '100% 100%';

break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FILL:

@@ -53,3 +53,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_SCALE_TO_FILL:

break;
case _imageServiceConstants.fittingTypes.TILE_HORIZONTAL:

@@ -60,3 +59,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_TILE_HORIZONTAL:

break;
case _imageServiceConstants.fittingTypes.TILE_VERTICAL:

@@ -67,3 +65,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_TILE_VERTICAL:

break;
case _imageServiceConstants.fittingTypes.TILE:

@@ -74,3 +71,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_TILE:

break;
case _imageServiceConstants.fittingTypes.LEGACY_STRIP_FIT_AND_TILE:

@@ -80,3 +76,2 @@ css.container.backgroundSize = 'contain';

break;
case _imageServiceConstants.fittingTypes.FIT_AND_TILE:

@@ -86,4 +81,4 @@ css.container.backgroundSize = 'auto';

break;
// Legacy old editor bg types.
case _imageServiceConstants.fittingTypes.LEGACY_BG_FIT_AND_TILE:

@@ -93,3 +88,2 @@ css.container.backgroundSize = 'auto';

break;
case _imageServiceConstants.fittingTypes.LEGACY_BG_FIT_AND_TILE_HORIZONTAL:

@@ -99,3 +93,2 @@ css.container.backgroundSize = 'auto';

break;
case _imageServiceConstants.fittingTypes.LEGACY_BG_FIT_AND_TILE_VERTICAL:

@@ -105,3 +98,2 @@ css.container.backgroundSize = 'auto';

break;
case _imageServiceConstants.fittingTypes.LEGACY_BG_NORMAL:

@@ -111,55 +103,38 @@ css.container.backgroundSize = 'auto';

break;
} // set alignment
}
// set alignment
switch (target.alignment) {
case _imageServiceConstants.alignTypes.CENTER:
css.container.backgroundPosition = 'center center'; // 50% 50%
break;
case _imageServiceConstants.alignTypes.LEFT:
css.container.backgroundPosition = 'left center'; // 0% 50%
break;
case _imageServiceConstants.alignTypes.RIGHT:
css.container.backgroundPosition = 'right center'; // 100% 50%
break;
case _imageServiceConstants.alignTypes.TOP:
css.container.backgroundPosition = 'center top'; // 50% 0%
break;
case _imageServiceConstants.alignTypes.BOTTOM:
css.container.backgroundPosition = 'center bottom'; // 50% 100%
break;
case _imageServiceConstants.alignTypes.TOP_RIGHT:
css.container.backgroundPosition = 'right top'; // 100% 0%
break;
case _imageServiceConstants.alignTypes.TOP_LEFT:
css.container.backgroundPosition = 'left top'; // 0% 0%
break;
case _imageServiceConstants.alignTypes.BOTTOM_RIGHT:
css.container.backgroundPosition = 'right bottom'; // 100% 100%
break;
case _imageServiceConstants.alignTypes.BOTTOM_LEFT:
css.container.backgroundPosition = 'left bottom'; // 0% 100%
break;
} // return background CSS
}
// return background CSS
return attributes;
}
//# sourceMappingURL=backgroundAttributes.js.map

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

exports.get = getCSS;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
/**

@@ -57,3 +55,2 @@ * align type to position

}
const alignTypeToPositionStr = {

@@ -77,2 +74,3 @@ [_imageServiceConstants.alignTypes.CENTER]: 'center',

};
/**

@@ -85,3 +83,2 @@ * returns image tag CSS data

*/
function getCSS(transformsObj, target) {

@@ -94,7 +91,10 @@ const attributes = {

};
const css = attributes.css;
const fittingType = transformsObj.fittingType;
const {
css
} = attributes;
const {
fittingType
} = transformsObj;
const alignType = target.alignment;
css.container.position = 'relative';
switch (fittingType) {

@@ -110,5 +110,3 @@ case _imageServiceConstants.fittingTypes.ORIGINAL_SIZE:

}
break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FIT:

@@ -125,3 +123,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_FIT_WIDTH:

// target width and height were modified in transform.js
case _imageServiceConstants.fittingTypes.LEGACY_BG_NORMAL:

@@ -133,3 +130,2 @@ css.img.width = '100%';

break;
case _imageServiceConstants.fittingTypes.STRETCH:

@@ -140,3 +136,2 @@ css.img.width = target.width;

break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FILL:

@@ -147,5 +142,5 @@ css.img.width = target.width;

break;
} // set alignment in a private case where the image src is smaller than the image container,
}
// set alignment in a private case where the image src is smaller than the image container,
if (typeof css.img.width === 'number' && typeof css.img.height === 'number' && (css.img.width !== target.width || css.img.height !== target.height)) {

@@ -156,5 +151,4 @@ const verticalMiddle = Math.round((target.height - css.img.height) / 2);

}
return attributes;
}
//# sourceMappingURL=imgAttributes.js.map

@@ -5,9 +5,5 @@ "use strict";

exports.get = getSvgAttr;
var _imageServiceConstants = require("../../helpers/imageServiceConstants");
var _imageServiceUtils = require("../../helpers/imageServiceUtils");
/* eslint-disable indent */
/**

@@ -30,13 +26,19 @@ * get CSS or SVG attributes to be used in the browser

};
const css = attributes.css,
attr = attributes.attr;
const fittingType = transformsObj.fittingType;
const {
css,
attr
} = attributes;
const {
fittingType
} = transformsObj;
const alignType = target.alignment;
const _transformsObj$src = transformsObj.src,
sourceWidth = _transformsObj$src.width,
sourceHeight = _transformsObj$src.height;
const {
width: sourceWidth,
height: sourceHeight
} = transformsObj.src;
let imageScale;
css.container.position = 'relative'; // populate SVG attributes object
css.container.position = 'relative';
// populate SVG attributes object
// eslint-disable-line indent
switch (fittingType) {

@@ -53,6 +55,4 @@ case _imageServiceConstants.fittingTypes.ORIGINAL_SIZE:

}
attr.img.preserveAspectRatio = 'xMidYMid slice';
break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FIT:

@@ -67,3 +67,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_FIT_WIDTH:

break;
case _imageServiceConstants.fittingTypes.STRETCH:

@@ -77,3 +76,2 @@ attr.img.width = target.width;

break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FILL:

@@ -88,3 +86,2 @@ if (!(0, _imageServiceUtils.isImageTransformApplicable)(transformsObj.src.id)) {

}
attr.img.x = 0;

@@ -95,5 +92,5 @@ attr.img.y = 0;

break;
} // set alignment for cases where the requested src is smaller or bigger than the target element,
}
// set alignment for cases where the requested src is smaller or bigger than the target element,
if (typeof attr.img.width === 'number' && typeof attr.img.height === 'number' && (attr.img.width !== target.width || attr.img.height !== target.height)) {

@@ -105,3 +102,2 @@ // x and y to use in svg <pattern> element

let bottom;
if (fittingType === _imageServiceConstants.fittingTypes.TILE) {

@@ -114,6 +110,4 @@ right = target.width % attr.img.width;

}
const center = Math.round(right / 2);
const middle = Math.round(bottom / 2);
switch (alignType) {

@@ -124,3 +118,2 @@ case _imageServiceConstants.alignTypes.TOP_LEFT:

break;
case _imageServiceConstants.alignTypes.TOP:

@@ -130,3 +123,2 @@ x = center;

break;
case _imageServiceConstants.alignTypes.TOP_RIGHT:

@@ -136,3 +128,2 @@ x = right;

break;
case _imageServiceConstants.alignTypes.LEFT:

@@ -142,3 +133,2 @@ x = 0;

break;
case _imageServiceConstants.alignTypes.CENTER:

@@ -148,3 +138,2 @@ x = center;

break;
case _imageServiceConstants.alignTypes.RIGHT:

@@ -154,3 +143,2 @@ x = right;

break;
case _imageServiceConstants.alignTypes.BOTTOM_LEFT:

@@ -160,3 +148,2 @@ x = 0;

break;
case _imageServiceConstants.alignTypes.BOTTOM:

@@ -166,3 +153,2 @@ x = center;

break;
case _imageServiceConstants.alignTypes.BOTTOM_RIGHT:

@@ -173,11 +159,10 @@ x = right;

}
attr.img.x = x;
attr.img.y = y;
}
attr.container.width = target.width;
attr.container.height = target.height;
attr.container.viewBox = [0, 0, target.width, target.height].join(' '); // return attributes object
attr.container.viewBox = [0, 0, target.width, target.height].join(' ');
// return attributes object
return attributes;

@@ -184,0 +169,0 @@ }

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

exports.getImageURI = getImageURI;
var _utils = require("../helpers/utils");
var _imageServiceConstants = require("../helpers/imageServiceConstants");
// transform templates

@@ -15,9 +12,12 @@ const fitTemplate = (0, _utils.template)`fit/w_${'width'},h_${'height'}`;

const fillFocalTemplate = (0, _utils.template)`fill/w_${'width'},h_${'height'},fp_${'focalPointX'}_${'focalPointY'}`;
const cropTemplate = (0, _utils.template)`crop/x_${'x'},y_${'y'},w_${'width'},h_${'height'}`; // legacy templates
const cropTemplate = (0, _utils.template)`crop/x_${'x'},y_${'y'},w_${'width'},h_${'height'}`;
// legacy templates
const legacyCropTemplate = (0, _utils.template)`crop/w_${'width'},h_${'height'},al_${'alignment'}`;
const legacyFillTemplate = (0, _utils.template)`fill/w_${'width'},h_${'height'},al_${'alignment'}`; // upscale template
const legacyFillTemplate = (0, _utils.template)`fill/w_${'width'},h_${'height'},al_${'alignment'}`;
const upscaleTemplate = (0, _utils.template)`,lg_${'upscaleMethodValue'}`; // options templates
// upscale template
const upscaleTemplate = (0, _utils.template)`,lg_${'upscaleMethodValue'}`;
// options templates
const qualityTemplate = (0, _utils.template)`,q_${'quality'}`;

@@ -35,2 +35,3 @@ const unSharpMaskTemplate = (0, _utils.template)`,usm_${'radius'}_${'amount'}_${'threshold'}`;

const autoEncodeTemplate = (0, _utils.template)`,enc_auto`;
/**

@@ -42,7 +43,7 @@ * returns image transform uri

*/
function getImageURI(transformsObj) {
// construct image transforms
const transformsObjStrArr = []; // construct transform
const transformsObjStrArr = [];
// construct transform
transformsObj.parts.forEach(transformPart => {

@@ -53,44 +54,31 @@ switch (transformPart.transformType) {

break;
case _imageServiceConstants.transformTypes.LEGACY_CROP:
transformsObjStrArr.push(legacyCropTemplate(transformPart));
break;
case _imageServiceConstants.transformTypes.LEGACY_FILL:
let legacyFillStr = legacyFillTemplate(transformPart);
if (transformPart.upscale) {
legacyFillStr += upscaleTemplate(transformPart);
}
transformsObjStrArr.push(legacyFillStr);
break;
case _imageServiceConstants.transformTypes.FIT:
let fitStr = fitTemplate(transformPart);
if (transformPart.upscale) {
fitStr += upscaleTemplate(transformPart);
}
transformsObjStrArr.push(fitStr);
break;
case _imageServiceConstants.transformTypes.FILL:
let fillStr = fillTemplate(transformPart);
if (transformPart.upscale) {
fillStr += upscaleTemplate(transformPart);
}
transformsObjStrArr.push(fillStr);
break;
case _imageServiceConstants.transformTypes.FILL_FOCAL:
let fillFocalStr = fillFocalTemplate(transformPart);
if (transformPart.upscale) {
fillFocalStr += upscaleTemplate(transformPart);
}
transformsObjStrArr.push(fillFocalStr);

@@ -100,37 +88,33 @@ break;

});
let transformsStr = transformsObjStrArr.join('/'); // construct transform options
let transformsStr = transformsObjStrArr.join('/');
// construct transform options
// quality
if (transformsObj.quality) {
transformsStr += qualityTemplate(transformsObj);
} // un-sharp mask
}
// un-sharp mask
if (transformsObj.unsharpMask) {
transformsStr += unSharpMaskTemplate(transformsObj.unsharpMask);
} // progressive
}
// progressive
if (!transformsObj.progressive) {
transformsStr += nonProgressiveTemplate(transformsObj);
} // watermark
}
// watermark
if (transformsObj.watermark) {
transformsStr += watermarkTemplate(transformsObj);
} // filters
}
// filters
if (transformsObj.filters) {
transformsStr += Object.keys(transformsObj.filters).map(filterName => filterTemplatesMap[filterName](transformsObj.filters)).join('');
} // auto encode
}
// auto encode
if (transformsObj.autoEncode && transformsObj.fileType !== _imageServiceConstants.fileType.GIF) {
transformsStr += autoEncodeTemplate(transformsObj);
} // image url string
}
// image url string
return `${transformsObj.src.id}/${_imageServiceConstants.API_VERSION}/${transformsStr}/${transformsObj.fileName}.${transformsObj.preferredExtension}`;
}
//# sourceMappingURL=transforms.js.map

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

exports.isMobile = isMobile;
var _imageServiceFeatureSupportObject = require("./imageServiceFeatureSupportObject");
/**

@@ -10,0 +8,0 @@ * get a browser detection if running on mobile device

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

exports.validateTargetDimensions = validateTargetDimensions;
var _imageServiceConstants = require("./imageServiceConstants");
var _imageServiceUtils = require("./imageServiceUtils");
const ALIGN_TYPE_TO_POSITION = {

@@ -33,3 +30,2 @@ [_imageServiceConstants.alignTypes.CENTER]: '50% 50%',

const NON_SCALING_FITTING_TYPES = [_imageServiceConstants.fittingTypes.LEGACY_ORIGINAL_SIZE, _imageServiceConstants.fittingTypes.ORIGINAL_SIZE, _imageServiceConstants.fittingTypes.LEGACY_BG_NORMAL];
function getIsFakeTile(fittingType, src, {

@@ -49,4 +45,2 @@ width: targetWidth,

*/
function getScaledDimensions(fittingType, src, {

@@ -62,3 +56,2 @@ width,

}
const isScalable = !NON_SCALING_FITTING_TYPES.includes(fittingType);

@@ -70,7 +63,4 @@ const isFakeTile = getIsFakeTile(fittingType, src, {

const isTile = !isFakeTile && TILE_FITTING_TYPES.includes(fittingType);
const _width = isTile ? src.width : width;
const _height = isTile ? src.height : height;
const scaleFactor = isScalable ? getScaleFactorByWidth(_width, (0, _imageServiceUtils.isPNG)(src.id)) : 1;

@@ -82,2 +72,3 @@ return {

}
/**

@@ -89,4 +80,2 @@ *

*/
function getConvertedFitting(fittingType, isFakeTile) {

@@ -97,2 +86,3 @@ const isTile = TILE_FITTING_TYPES.includes(fittingType) && !isFakeTile;

}
/**

@@ -105,4 +95,2 @@ *

*/
function validateTargetDimensions(src, {

@@ -114,3 +102,2 @@ width,

const _width = width || Math.min(980, src.width);
const heightRatio = _width / src.width;

@@ -122,3 +109,2 @@ return {

}
return {

@@ -129,2 +115,3 @@ width,

}
/**

@@ -136,4 +123,2 @@ *

*/
function getScaleFactorByWidth(width, isHighQuality) {

@@ -147,5 +132,5 @@ if (width > 900) {

}
return 1;
}
/**

@@ -158,4 +143,2 @@ *

*/
function getBlurValue(width, fittingType, isSEOBot) {

@@ -165,13 +148,11 @@ if (isSEOBot) {

}
if (TILE_FITTING_TYPES.includes(fittingType)) {
return 1;
}
if (width > 200) {
return 2;
}
return 3;
}
/**

@@ -185,4 +166,2 @@ *

*/
function getCSSOverrides(fittingType, src, target, alignment = 'center') {

@@ -193,7 +172,5 @@ const returnValue = {

};
if (fittingType === _imageServiceConstants.fittingTypes.SCALE_TO_FILL) {
const alignTypeFromFocalPoint = src.focalPoint && convertFocalPointToAlignType(src.focalPoint);
const alignType = alignTypeFromFocalPoint || alignment;
if (src.focalPoint && !alignTypeFromFocalPoint) {

@@ -221,5 +198,5 @@ returnValue.img = {

}
return returnValue;
}
/**

@@ -231,4 +208,2 @@ * Try to convert focal point value to 9 grid alignment value

*/
function convertFocalPointToAlignType(focalPoint) {

@@ -238,2 +213,3 @@ const position = `${focalPoint.x}% ${focalPoint.y}%`;

}
/**

@@ -246,16 +222,18 @@ *

*/
function convertFillFocalToPosition(src, target, focalPoint) {
const sW = src.width,
sH = src.height;
const tW = target.width,
tH = target.height;
const fpX = focalPoint.x,
fpY = focalPoint.y;
const {
width: sW,
height: sH
} = src;
const {
width: tW,
height: tH
} = target;
const {
x: fpX,
y: fpY
} = focalPoint;
if (!tW || !tH) {
return `${fpX}% ${fpY}%`;
}
const fillScaleFactor = Math.max(tW / sW, tH / sH);

@@ -262,0 +240,0 @@ const imgScaledW = sW * fillScaleFactor;

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

exports.upscaleMethodsValues = exports.upscaleMethods = exports.transformTypes = exports.supportedExtensions = exports.imageScaleDefaults = exports.imageQuality = exports.imageFilters = exports.htmlTag = exports.fittingTypes = exports.fileType = exports.emptyData = exports.defaultUSM = exports.alignTypesMap = exports.alignTypes = exports.SUPER_UPSCALE_MODELS = exports.SAFE_TRANSFORMED_AREA = exports.MOBILE_MAX_BG_SITE_LEGACY_WIDTH = exports.MOBILE_MAX_BG_SITE_LEGACY_HEIGHT = exports.MAX_DEVICE_PIXEL_RATIO = exports.DSKTP_MAX_BG_SITE_LEGACY_WIDTH = exports.DSKTP_MAX_BG_SITE_LEGACY_HEIGHT = exports.API_VERSION = exports.ALIGN_TYPE_TO_FOCAL_POINT = void 0;
/**

@@ -11,12 +10,12 @@ * image service api version

const API_VERSION = 'v1';
/**
the maximum retina factor
*/
exports.API_VERSION = API_VERSION;
const MAX_DEVICE_PIXEL_RATIO = 2;
/**
site BG legacy max width x height
*/
exports.MAX_DEVICE_PIXEL_RATIO = MAX_DEVICE_PIXEL_RATIO;

@@ -30,2 +29,3 @@ const DSKTP_MAX_BG_SITE_LEGACY_WIDTH = 1920;

const MOBILE_MAX_BG_SITE_LEGACY_HEIGHT = 1000;
/**

@@ -36,3 +36,2 @@ * Enum string values of requested image fitting types

*/
exports.MOBILE_MAX_BG_SITE_LEGACY_HEIGHT = MOBILE_MAX_BG_SITE_LEGACY_HEIGHT;

@@ -64,6 +63,6 @@ const fittingTypes = {

};
/**
* Enum string values of image transform types as passed to the image service api
*/
exports.fittingTypes = fittingTypes;

@@ -78,2 +77,3 @@ const transformTypes = {

};
/**

@@ -83,3 +83,2 @@ * Enum string values of requested image align types

*/
exports.transformTypes = transformTypes;

@@ -97,6 +96,6 @@ const alignTypes = {

};
/**
* Enum 9Grid alignment to focal point
*/
exports.alignTypes = alignTypes;

@@ -141,6 +140,6 @@ const ALIGN_TYPE_TO_FOCAL_POINT = {

};
/**
* Enum string values of image align types as passed to the image service
*/
exports.ALIGN_TYPE_TO_FOCAL_POINT = ALIGN_TYPE_TO_FOCAL_POINT;

@@ -158,2 +157,3 @@ const alignTypesMap = {

};
/**

@@ -163,3 +163,2 @@ * Enum string values of html tag used to construct the css or svg attributes

*/
exports.alignTypesMap = alignTypesMap;

@@ -171,2 +170,3 @@ const htmlTag = {

};
/**

@@ -176,3 +176,2 @@ * Enum string values of upscale method

*/
exports.htmlTag = htmlTag;

@@ -184,2 +183,3 @@ const upscaleMethods = {

};
/**

@@ -189,3 +189,2 @@ * api values of upscale method

*/
exports.upscaleMethods = upscaleMethods;

@@ -196,2 +195,3 @@ const upscaleMethodsValues = {

};
/**

@@ -201,3 +201,2 @@ * default unsharp mask values

*/
exports.upscaleMethodsValues = upscaleMethodsValues;

@@ -209,6 +208,6 @@ const defaultUSM = {

};
/**
* default empty data
*/
exports.defaultUSM = defaultUSM;

@@ -231,2 +230,3 @@ const emptyData = {

const SAFE_TRANSFORMED_AREA = MAX_TRANSFORMED_IMAGE_WIDTH * MAX_TRANSFORMED_IMAGE_HEIGHT;
/**

@@ -236,9 +236,8 @@ * super res machine learning upscale factor models -

*/
exports.SAFE_TRANSFORMED_AREA = SAFE_TRANSFORMED_AREA;
const SUPER_UPSCALE_MODELS = [1.5, 2, 4];
/**
* image qualities
*/
exports.SUPER_UPSCALE_MODELS = SUPER_UPSCALE_MODELS;

@@ -267,2 +266,3 @@ const imageScaleDefaults = {

};
/**

@@ -272,3 +272,2 @@ * image quality

*/
exports.imageScaleDefaults = imageScaleDefaults;

@@ -281,2 +280,3 @@ const imageQuality = {

};
/**

@@ -286,3 +286,2 @@ * image filters

*/
exports.imageQuality = imageQuality;

@@ -289,0 +288,0 @@ const imageFilters = {

@@ -11,14 +11,10 @@ "use strict";

};
const getFeature = function (feature) {
return globalFeaturesSupportObj[feature];
};
exports.getFeature = getFeature;
const setFeature = function (feature, value) {
globalFeaturesSupportObj[feature] = value;
};
exports.setFeature = setFeature;
//# sourceMappingURL=imageServiceFeatureSupportObject.js.map

@@ -25,9 +25,7 @@ "use strict";

exports.roundToFixed = roundToFixed;
var _imageServiceConstants = require("./imageServiceConstants");
var _utils = require("./utils");
const SUPPORTED_IMAGE_EXTENSIONS = [_imageServiceConstants.fileType.PNG, _imageServiceConstants.fileType.JPEG, _imageServiceConstants.fileType.JPG, _imageServiceConstants.fileType.JPE, _imageServiceConstants.fileType.WIX_ICO_MP, _imageServiceConstants.fileType.WIX_MP];
const JPG_EXTENSIONS = [_imageServiceConstants.fileType.JPEG, _imageServiceConstants.fileType.JPG, _imageServiceConstants.fileType.JPE];
/**

@@ -39,6 +37,6 @@ * checks if image type is supported

*/
function isImageTypeSupported(uri) {
return SUPPORTED_IMAGE_EXTENSIONS.includes(getFileExtension(uri));
}
/**

@@ -52,7 +50,6 @@ * check request integrity

*/
function isValidRequest(fittingType, src, target) {
return target && src && !isUrlEmptyOrNone(src.id) && Object.values(_imageServiceConstants.fittingTypes).includes(fittingType);
}
/**

@@ -64,7 +61,6 @@ * check if image transform is supported for source image

*/
function isImageTransformApplicable(uri) {
return isImageTypeSupported(uri) && !isExternalUrl(uri);
}
/**

@@ -76,7 +72,6 @@ * returns true if image is of JPG type

*/
function isJPG(uri) {
return JPG_EXTENSIONS.includes(getFileExtension(uri));
}
/**

@@ -88,7 +83,6 @@ * returns true if image is of PNG type

*/
function isPNG(uri) {
return getFileExtension(uri) === _imageServiceConstants.fileType.PNG;
}
/**

@@ -100,7 +94,6 @@ * returns true if image is of webP type

*/
function isWEBP(uri) {
return getFileExtension(uri) === _imageServiceConstants.fileType.WEBP;
}
/**

@@ -112,7 +105,6 @@ * returns true if the url starts with http, https, // or data

*/
function isExternalUrl(url) {
return /(^https?)|(^data)|(^\/\/)/.test(url);
}
/**

@@ -124,7 +116,6 @@ * returns true if the url empty or none string

*/
function isUrlEmptyOrNone(url) {
return !url || !url.trim() || url.toLowerCase() === 'none';
}
/**

@@ -136,15 +127,12 @@ * returns search bot true or false as indicated in options

*/
function isSEOBot(options) {
var _options$isSEOBot;
return (options == null ? void 0 : options.isSEOBot) ?? false;
}
return (_options$isSEOBot = options == null ? void 0 : options.isSEOBot) != null ? _options$isSEOBot : false;
} // https://jira.wixpress.com/browse/WEED-12667
// https://jira.wixpress.com/browse/WEED-12667
// const illegalChars = ['/', '\\', '#', '^', '?', '{', '}', '<', '>', '|', '`', '“', ':', '"'].map(encodeURIComponent)
const ILLEGAL_CHARS = ['/', '\\', '?', '<', '>', '|', '“', ':', '"'].map(encodeURIComponent);
const URL_SAFE_ILLEGAL_CHARS = ['\\.', '\\*'];
const ILLEGAL_CHARS_REPLACEMENT = '_';
/**

@@ -157,20 +145,18 @@ * returns source image file name (no extension)

*/
function getFileName(uri, name) {
const beforeLeadingSlashRegexp = /\/(.*?)$/;
const fileExtensionRegexp = /\.([^.]*)$/;
const illegalCharsRegex = new RegExp(`(${ILLEGAL_CHARS.concat(URL_SAFE_ILLEGAL_CHARS).join('|')})`, 'g'); // if name is a non empty string, remove only supported extension if exists and url encode the string
const illegalCharsRegex = new RegExp(`(${ILLEGAL_CHARS.concat(URL_SAFE_ILLEGAL_CHARS).join('|')})`, 'g');
// if name is a non empty string, remove only supported extension if exists and url encode the string
if (name && name.length) {
let fileName = name;
const extension = name.match(fileExtensionRegexp);
if (extension && SUPPORTED_IMAGE_EXTENSIONS.includes(extension[1])) {
fileName = name.replace(fileExtensionRegexp, '');
}
return encodeURIComponent(fileName).replace(illegalCharsRegex, ILLEGAL_CHARS_REPLACEMENT);
} // else, trim any preceding media structure from the uri string (like "media/" etc.) and remove extension
}
// else, trim any preceding media structure from the uri string (like "media/" etc.) and remove extension
const trimmed = uri.match(beforeLeadingSlashRegexp);

@@ -180,2 +166,3 @@ const fileName = trimmed ? trimmed[1] : uri;

}
/**

@@ -187,4 +174,2 @@ * returns source image file name (no extension)

*/
function getFileType(uri) {

@@ -198,5 +183,5 @@ if (isJPG(uri)) {

}
return _imageServiceConstants.fileType.UNRECOGNIZED;
}
/**

@@ -208,4 +193,2 @@ * returns source image file extension

*/
function getFileExtension(uri) {

@@ -215,2 +198,3 @@ const splitURI = /[.]([^.]+)$/.exec(uri);

}
/**

@@ -225,7 +209,6 @@ * returns scale factor needed if FIT fitting

*/
function getFitScaleFactor(sWidth, sHeight, dWidth, dHeight) {
return Math.min(dWidth / sWidth, dHeight / sHeight);
}
/**

@@ -240,7 +223,6 @@ * returns scale factor needed if FILL fitting

*/
function getFillScaleFactor(sWidth, sHeight, dWidth, dHeight) {
return Math.max(dWidth / sWidth, dHeight / sHeight);
}
/**

@@ -256,7 +238,4 @@ * returns scale factor source target

*/
function getScaleFactor(sWidth, sHeight, dWidth, dHeight, transformType) {
let scaleFactor;
if (transformType === _imageServiceConstants.transformTypes.FILL) {

@@ -269,5 +248,5 @@ scaleFactor = getFillScaleFactor(sWidth, sHeight, dWidth, dHeight);

}
return scaleFactor;
}
/**

@@ -282,26 +261,23 @@ * get calculated scale factor , width and height while considering wixmp image transform dimension limits

*/
function getSafeTransformData(sWidth, sHeight, dWidth, dHeight, transformType) {
let scaleFactor; // defaults for FILL transform type
let scaleFactor;
// defaults for FILL transform type
let width = dWidth;
let height = dHeight; // calculate safe image transformed area
let height = dHeight;
// calculate safe image transformed area
scaleFactor = getScaleFactor(sWidth, sHeight, dWidth, dHeight, transformType);
if (transformType === _imageServiceConstants.transformTypes.FIT) {
width = sWidth * scaleFactor;
height = sHeight * scaleFactor;
} // adjust target width & height & scaleFactor
}
// adjust target width & height & scaleFactor
if (width && height && width * height > _imageServiceConstants.SAFE_TRANSFORMED_AREA) {
const dimensionScaleFactor = Math.sqrt(_imageServiceConstants.SAFE_TRANSFORMED_AREA / (width * height));
width *= dimensionScaleFactor;
height *= dimensionScaleFactor; // get the new scale factor
height *= dimensionScaleFactor;
// get the new scale factor
scaleFactor = getScaleFactor(sWidth, sHeight, width, height, transformType);
}
return {

@@ -313,2 +289,3 @@ scaleFactor,

}
/**

@@ -325,17 +302,18 @@ * returns the destination rectangle

*/
function getTransformData(sWidth, sHeight, transformType, target, dpr, upscaleMethod) {
// use target dimension is src not provided
sWidth = sWidth || target.width;
sHeight = sHeight || target.height; // adjust image transform values considering server side transform limitations and performance
sHeight = sHeight || target.height;
const _getSafeTransformData = getSafeTransformData(sWidth, sHeight, target.width * dpr, target.height * dpr, transformType),
scaleFactor = _getSafeTransformData.scaleFactor,
width = _getSafeTransformData.width,
height = _getSafeTransformData.height; // adjust image transform values to optimizing upsacle quality and payload
// adjust image transform values considering server side transform limitations and performance
const {
scaleFactor,
width,
height
} = getSafeTransformData(sWidth, sHeight, target.width * dpr, target.height * dpr, transformType);
// adjust image transform values to optimizing upsacle quality and payload
return getOptimizedTransformData(sWidth, sHeight, width, height, upscaleMethod, scaleFactor, transformType);
}
/**

@@ -348,6 +326,6 @@ * converts 9 grid alignment to Focal point position

function getFocalPointFrom9GridAlignment(alignment = _imageServiceConstants.alignTypes.CENTER) {
return _imageServiceConstants.ALIGN_TYPE_TO_FOCAL_POINT[alignment];
}
/**

@@ -363,9 +341,8 @@ * returns overlapping rectangle where sRect

*/
function getAlignedRect(sRect, dRect, sFP, alignment) {
const fp = getFocalPoint(sFP) || getFocalPointFrom9GridAlignment(alignment);
const x = Math.max(0, Math.min(sRect.width - dRect.width, fp.x * sRect.width - dRect.width / 2));
const y = Math.max(0, Math.min(sRect.height - dRect.height, fp.y * sRect.height - dRect.height / 2)); // rect
const y = Math.max(0, Math.min(sRect.height - dRect.height, fp.y * sRect.height - dRect.height / 2));
// rect
return {

@@ -378,2 +355,3 @@ x,

}
/**

@@ -386,9 +364,8 @@ * returns overlapping rectangle between sRect and dRect

*/
function getOverlappingRect(sRect, dRect) {
const width = Math.max(0, Math.min(sRect.width, dRect.x + dRect.width) - Math.max(0, dRect.x));
const height = Math.max(0, Math.min(sRect.height, dRect.y + dRect.height) - Math.max(0, dRect.y));
const isValidRect = width && height && (sRect.width !== width || sRect.height !== height); // return overlapping sRect/dRect rectangle(x, y, width, height)
const isValidRect = width && height && (sRect.width !== width || sRect.height !== height);
// return overlapping sRect/dRect rectangle(x, y, width, height)
return isValidRect ? {

@@ -401,2 +378,3 @@ x: Math.max(0, dRect.x),

}
/**

@@ -408,7 +386,6 @@ * returns pixel aspect ratio value

*/
function getDevicePixelRatio(target) {
return Math.min(target.pixelAspectRatio || 1, _imageServiceConstants.MAX_DEVICE_PIXEL_RATIO);
}
/**

@@ -420,7 +397,6 @@ * returns target alignment value

*/
function getAlignment(target) {
return target.alignment && _imageServiceConstants.alignTypesMap[target.alignment] || _imageServiceConstants.alignTypesMap[_imageServiceConstants.alignTypes.CENTER];
}
/**

@@ -430,7 +406,4 @@ * returns the focal point value, if no focal point passed use alignment

*/
function getFocalPoint(focalPoint) {
let fp;
if (focalPoint && typeof focalPoint.x === 'number' && !isNaN(focalPoint.x) && typeof focalPoint.y === 'number' && !isNaN(focalPoint.y)) {

@@ -442,5 +415,5 @@ fp = {

}
return fp;
}
/**

@@ -453,7 +426,6 @@ * returns preferred image quality value

*/
function getPreferredImageQuality(imageWidth, imageHeight) {
return _imageServiceConstants.imageScaleDefaults[getImageQualityKey(imageWidth, imageHeight)].quality;
}
/**

@@ -465,4 +437,2 @@ * returns the scale descriptor of CLASSIC upscale method

*/
function getClassicScaleData(sWidth, sHeight) {

@@ -476,2 +446,3 @@ const imageKey = getImageQualityKey(sWidth, sHeight);

}
/**

@@ -483,4 +454,2 @@ * returns the scale descriptor of AUTO upscale method

*/
function getAutoScaleData(sWidth, sHeight) {

@@ -494,2 +463,3 @@ const imageKey = getImageQualityKey(sWidth, sHeight);

}
/**

@@ -500,4 +470,2 @@ * returns the scale descriptor of SUPER upscale method

*/
function getSuperScaleData(scaleFactor) {

@@ -510,2 +478,3 @@ return {

}
/**

@@ -520,4 +489,2 @@ * returns upscale descriptor object

*/
function getOptimizedScaleData(sWidth, sHeight, scaleFactor, upscaleMethod) {

@@ -528,7 +495,8 @@ if (upscaleMethod === 'auto') {

return getSuperScaleData(scaleFactor);
} // assuming 'classic' method
}
// assuming 'classic' method
return getClassicScaleData(sWidth, sHeight);
}
/**

@@ -546,13 +514,10 @@ * returns optimized upscale data, considering requested upscale method , optimize upscale for best quality and bandwidth

*/
function getOptimizedTransformData(sWidth, sHeight, tWidth, tHeight, upscaleMethod, scaleFactor, transformType) {
const _getOptimizedScaleDat = getOptimizedScaleData(sWidth, sHeight, scaleFactor, upscaleMethod),
optimizedScaleFactor = _getOptimizedScaleDat.optimizedScaleFactor,
upscaleMethodValue = _getOptimizedScaleDat.upscaleMethodValue,
forceUSM = _getOptimizedScaleDat.forceUSM;
const {
optimizedScaleFactor,
upscaleMethodValue,
forceUSM
} = getOptimizedScaleData(sWidth, sHeight, scaleFactor, upscaleMethod);
let width = tWidth;
let height = tHeight;
if (scaleFactor <= optimizedScaleFactor) {

@@ -568,5 +533,4 @@ // target upscale within limits or downscale

};
} // limited upscale
}
// limited upscale
switch (transformType) {

@@ -577,3 +541,2 @@ case _imageServiceConstants.transformTypes.FILL:

break;
case _imageServiceConstants.transformTypes.FIT:

@@ -583,8 +546,6 @@ width = sWidth * optimizedScaleFactor;

break;
default:
break;
} // adjust transform values
}
// adjust transform values
return {

@@ -599,2 +560,3 @@ width,

}
/**

@@ -607,7 +569,4 @@ * returns image quality key

*/
function getImageQualityKey(imageWidth, imageHeight) {
const size = imageWidth * imageHeight;
if (size > _imageServiceConstants.imageScaleDefaults[_imageServiceConstants.imageQuality.HIGH].size) {

@@ -620,5 +579,5 @@ return _imageServiceConstants.imageQuality.HIGH;

}
return _imageServiceConstants.imageQuality.TINY;
}
/**

@@ -633,4 +592,2 @@ * return the actual rounded dimension of a scaled rectangle

*/
function getDimension(sWidth, sHeight, tWidth, tHeight, transformType) {

@@ -643,2 +600,3 @@ const scaleFactor = getScaleFactor(sWidth, sHeight, tWidth, tHeight, transformType);

}
/**

@@ -651,4 +609,2 @@ * rounds number n digit precision and converts to string

*/
function roundToFixed(value, precision) {

@@ -658,2 +614,3 @@ const truncatePrecision = Math.pow(10, precision || 0);

}
/**

@@ -664,4 +621,2 @@ * get normalize scale method

*/
function getUpscaleString(options) {

@@ -671,5 +626,4 @@ if (!options || !options.upscaleMethod) {

}
return _imageServiceConstants.upscaleMethods[options.upscaleMethod.toUpperCase()] || _imageServiceConstants.upscaleMethods.AUTO;
}
//# sourceMappingURL=imageServiceUtils.js.map

@@ -5,9 +5,5 @@ "use strict";

exports.setTransformOptions = setTransformOptions;
var _utils = require("./utils");
var _imageServiceUtils = require("./imageServiceUtils");
var _imageServiceConstants = require("./imageServiceConstants");
/**

@@ -19,14 +15,13 @@ * returns image filters part of the image transform uri

function setTransformOptions(transformsObj, options) {
var _options$autoEncode;
options = options || {}; // options - general
options = options || {};
// options - general
transformsObj.quality = getQuality(transformsObj, options);
transformsObj.progressive = getProgressive(options);
transformsObj.watermark = getWatermark(options);
transformsObj.autoEncode = (_options$autoEncode = options.autoEncode) != null ? _options$autoEncode : true; // options - filters & adjustments
transformsObj.autoEncode = options.autoEncode ?? true;
// options - filters & adjustments
transformsObj.unsharpMask = getUnsharpMask(transformsObj, options);
transformsObj.filters = getFilters(options);
}
/**

@@ -37,7 +32,6 @@ *

*/
function getWatermark(options) {
return options.watermark;
}
/**

@@ -49,7 +43,6 @@ * returns progressive if required

*/
function getProgressive(options) {
return options.progressive !== false;
}
/**

@@ -62,4 +55,2 @@ * returns image filters part of the image transform uri

*/
function getQuality(transformsObj, options) {

@@ -69,15 +60,14 @@ const isPNG = transformsObj.fileType === _imageServiceConstants.fileType.PNG;

const isQualitySupported = isJPG || isPNG;
if (isQualitySupported) {
const transformData = (0, _utils.last)(transformsObj.parts);
const defaultQuality = (0, _imageServiceUtils.getPreferredImageQuality)(transformData.width, transformData.height);
let quality = options.quality && options.quality >= 5 && options.quality <= 90 ? options.quality : defaultQuality; // increase quality by 5 for webp images
let quality = options.quality && options.quality >= 5 && options.quality <= 90 ? options.quality : defaultQuality;
// increase quality by 5 for webp images
quality = isPNG ? quality + 5 : quality;
return quality;
} // quality not supported
}
// quality not supported
return 0;
}
/**

@@ -89,34 +79,33 @@ * returns the desired transformed image filters

*/
function getFilters(options) {
const filterOptions = options.filters || {};
const filters = {}; // contrast
const filters = {};
// contrast
if (isValidImageFilter(filterOptions[_imageServiceConstants.imageFilters.CONTRAST], -100, 100)) {
filters[_imageServiceConstants.imageFilters.CONTRAST] = filterOptions[_imageServiceConstants.imageFilters.CONTRAST];
} // brightness
}
// brightness
if (isValidImageFilter(filterOptions[_imageServiceConstants.imageFilters.BRIGHTNESS], -100, 100)) {
filters[_imageServiceConstants.imageFilters.BRIGHTNESS] = filterOptions[_imageServiceConstants.imageFilters.BRIGHTNESS];
} // saturation
}
// saturation
if (isValidImageFilter(filterOptions[_imageServiceConstants.imageFilters.SATURATION], -100, 100)) {
filters[_imageServiceConstants.imageFilters.SATURATION] = filterOptions[_imageServiceConstants.imageFilters.SATURATION];
} // hue
}
// hue
if (isValidImageFilter(filterOptions[_imageServiceConstants.imageFilters.HUE], -180, 180)) {
filters[_imageServiceConstants.imageFilters.HUE] = filterOptions[_imageServiceConstants.imageFilters.HUE];
} // blur
}
// blur
if (isValidImageFilter(filterOptions[_imageServiceConstants.imageFilters.BLUR], 0, 100)) {
filters[_imageServiceConstants.imageFilters.BLUR] = filterOptions[_imageServiceConstants.imageFilters.BLUR];
}
return filters;
}
/**

@@ -130,4 +119,2 @@ * indicates if requested filter value is valid

*/
function isValidImageFilter(filterValue, minValue, maxValue) {

@@ -137,2 +124,3 @@ // check if filter name and filter values range valid

}
/**

@@ -145,4 +133,2 @@ * returns the desired transformed image unSharpMask values

*/
function getUnsharpMask(transformsObj, options) {

@@ -152,3 +138,2 @@ // If options.unsharpMask is a valid value, use it

var _options$unsharpMask, _options$unsharpMask2, _options$unsharpMask3;
// If we got usm, change values to have trailing zeros (.00), else return undefined

@@ -159,9 +144,10 @@ return {

threshold: (0, _imageServiceUtils.roundToFixed)((_options$unsharpMask3 = options.unsharpMask) == null ? void 0 : _options$unsharpMask3.threshold, 2)
}; // if options.unsharpMask is not all zeros and not valid and usm should be used, use default
};
// if options.unsharpMask is not all zeros and not valid and usm should be used, use default
} else if (!isZeroUSM(options.unsharpMask) && isUSMNeeded(transformsObj)) {
return _imageServiceConstants.defaultUSM;
}
return;
}
/**

@@ -173,4 +159,2 @@ * indicates if usm is needed

*/
function isUSMNeeded(transformsObj) {

@@ -182,6 +166,8 @@ // ---------------------------------------------------------------------------------------

const transformPart = (0, _utils.last)(transformsObj.parts);
const upscale = transformPart.scaleFactor >= 1; // return if usm is needed
const upscale = transformPart.scaleFactor >= 1;
// return if usm is needed
return !upscale || transformPart.forceUSM;
}
/**

@@ -193,4 +179,2 @@ * indicates if all usm values are presented and in range

*/
function isUSMValid(usm) {

@@ -200,6 +184,8 @@ usm = usm || {};

const amount = typeof usm.amount === 'number' && !isNaN(usm.amount) && usm.amount >= 0 && usm.amount <= 10;
const threshold = typeof usm.threshold === 'number' && !isNaN(usm.threshold) && usm.threshold >= 0 && usm.threshold <= 255; // return is a valid USM data
const threshold = typeof usm.threshold === 'number' && !isNaN(usm.threshold) && usm.threshold >= 0 && usm.threshold <= 255;
// return is a valid USM data
return radius && amount && threshold;
}
/**

@@ -211,4 +197,2 @@ * indicates if all usm values are presented and are zero. an explicit request to not apply usm

*/
function isZeroUSM(usm) {

@@ -215,0 +199,0 @@ usm = usm || {};

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

exports.setTransformParts = setTransformParts;
var _imageServiceConstants = require("./imageServiceConstants");
var _imageServiceUtils = require("./imageServiceUtils");
/**

@@ -18,8 +15,8 @@ * request analysis, returns parsed transforms object

function setTransformParts(transformsObj, src, target) {
let rect; // crop source image if needed
let rect;
// crop source image if needed
// set crop part and adjust source dimensions
if (src.crop) {
rect = (0, _imageServiceUtils.getOverlappingRect)(src, src.crop);
if (rect) {

@@ -31,5 +28,5 @@ transformsObj.src.width = rect.width;

}
} // set additional transform part
}
// set additional transform part
switch (transformsObj.fittingType) {

@@ -48,3 +45,2 @@ case _imageServiceConstants.fittingTypes.SCALE_TO_FIT:

break;
case _imageServiceConstants.fittingTypes.SCALE_TO_FILL:

@@ -54,3 +50,2 @@ // fill

break;
case _imageServiceConstants.fittingTypes.STRETCH:

@@ -60,3 +55,2 @@ // stretch

break;
case _imageServiceConstants.fittingTypes.TILE_HORIZONTAL:

@@ -70,6 +64,6 @@ case _imageServiceConstants.fittingTypes.TILE_VERTICAL:

rect = (0, _imageServiceUtils.getAlignedRect)(transformsObj.src, target, transformsObj.focalPoint, target.alignment);
if (transformsObj.src.isCropped) {
Object.assign(transformsObj.parts[0], rect); // update source width & height accordingly
Object.assign(transformsObj.parts[0], rect);
// update source width & height accordingly
transformsObj.src.width = rect.width;

@@ -80,4 +74,4 @@ transformsObj.src.height = rect.height;

}
break;
break;
// ---------------------------------------------------------------------------------------

@@ -87,3 +81,2 @@ // handles a legacy bug on bgImageStrip, background html tag

// ---------------------------------------------------------------------------------------
case _imageServiceConstants.fittingTypes.LEGACY_STRIP_TILE_HORIZONTAL:

@@ -97,3 +90,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_TILE_VERTICAL:

break;
case _imageServiceConstants.fittingTypes.LEGACY_STRIP_SCALE_TO_FIT:

@@ -104,3 +96,2 @@ case _imageServiceConstants.fittingTypes.LEGACY_STRIP_FIT_AND_TILE:

break;
case _imageServiceConstants.fittingTypes.LEGACY_STRIP_SCALE_TO_FILL:

@@ -112,2 +103,3 @@ // legacy fill

}
/**

@@ -120,9 +112,8 @@ * returns fit part of the image transform uri

*/
function getFitPart(transformsObj, target) {
// calculate the transformed image size needed
const transformedData = (0, _imageServiceUtils.getTransformData)(transformsObj.src.width, transformsObj.src.height, _imageServiceConstants.transformTypes.FIT, target, transformsObj.devicePixelRatio, transformsObj.upscaleMethod);
const transformType = _imageServiceConstants.transformTypes.FILL; // return fit transform data
const transformType = _imageServiceConstants.transformTypes.FILL;
// return fit transform data
return {

@@ -140,2 +131,3 @@ transformType,

}
/**

@@ -148,4 +140,2 @@ * returns fill part of the image transform uri

*/
function getFillPart(transformsObj, target) {

@@ -170,2 +160,3 @@ // calculate the transformed image size needed

}
/**

@@ -178,14 +169,15 @@ * returns fill part of the image transform uri

*/
function getStretchPart(transformsObj, target) {
// stretch data
const scaleFactor = (0, _imageServiceUtils.getScaleFactor)(transformsObj.src.width, transformsObj.src.height, target.width, target.height, _imageServiceConstants.transformTypes.FILL);
const clonedTarget = { ...target
const clonedTarget = {
...target
};
clonedTarget.width = transformsObj.src.width * scaleFactor;
clonedTarget.height = transformsObj.src.height * scaleFactor; // return stretch part
clonedTarget.height = transformsObj.src.height * scaleFactor;
// return stretch part
return getFitPart(transformsObj, clonedTarget);
}
/**

@@ -197,4 +189,2 @@ * returns crop part of the image transform uri

*/
function getCropPart(rect) {

@@ -212,3 +202,5 @@ return {

};
} // ---------------------------------------------------------------------------------------
}
// ---------------------------------------------------------------------------------------
// handles a legacy bug on bgImageStrip, background html tag

@@ -224,4 +216,2 @@ // component Full Width Strip stored incorrect image source width and height

*/
function getLegacyFitPart(target) {

@@ -238,2 +228,3 @@ return {

}
/**

@@ -245,4 +236,2 @@ * returns fill part of the image transform uri

*/
function getLegacyFillPart(target) {

@@ -260,2 +249,3 @@ return {

}
/**

@@ -267,4 +257,2 @@ * returns legacy crop part of the image transform uri

*/
function getLegacyCropPart(target) {

@@ -271,0 +259,0 @@ return {

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

exports.populateGlobalFeatureSupport = populateGlobalFeatureSupport;
var _imageServiceFeatureSupportObject = require("./imageServiceFeatureSupportObject");
/**

@@ -15,4 +13,4 @@ * Populate the global feature support object with browser specific values

const isSmallScreen = window.matchMedia && window.matchMedia('(max-width: 767px)').matches;
const isMobileAgent = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); // set is mobile
const isMobileAgent = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
// set is mobile
(0, _imageServiceFeatureSupportObject.setFeature)('isMobile', isSmallScreen && isMobileAgent);

@@ -19,0 +17,0 @@ }

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

exports.template = template;
/**

@@ -14,2 +13,3 @@ * Simple templates.

*/
function template(strings, ...keys) {

@@ -26,2 +26,3 @@ return function (...values) {

}
/**

@@ -32,4 +33,2 @@ * Get the last element in an array

*/
function last(array) {

@@ -36,0 +35,0 @@ return array[array.length - 1];

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

exports.wixStaticWithMedia = exports.wixStatic = void 0;
var _index = require("../api/uri/index");
exports.populateGlobalFeatureSupport = _index.populateGlobalFeatureSupport;
var _imageServiceConstants = require("../helpers/imageServiceConstants");
const wixStatic = 'https://static.wixstatic.com/';

@@ -22,5 +18,3 @@ exports.wixStatic = wixStatic;

const devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
const getWixStaticURL = uri => HAS_MEDIA_PREFIX_RE.test(uri) ? `${wixStatic}${uri}` : `${wixStaticWithMedia}${uri}`;
const getURL = (uri, options) => {

@@ -30,3 +24,2 @@ const baseHostURL = options && options.baseHostURL;

};
function getScaleToFitImageURL(relativeUrl, sourceWidth, sourceHeight, targetWidth, targetHeight, options) {

@@ -47,3 +40,2 @@ const data = (0, _index.getData)(_imageServiceConstants.fittingTypes.SCALE_TO_FIT, {

}
function getScaleToFillImageURL(relativeUrl, sourceWidth, sourceHeight, targetWidth, targetHeight, options) {

@@ -68,3 +60,2 @@ const data = (0, _index.getData)(_imageServiceConstants.fittingTypes.SCALE_TO_FILL, {

}
function getCropImageURL(relativeUrl, sourceWidth, sourceHeight, cropX, cropY, cropWidth, cropHeight, targetWidth, targetHeight, options) {

@@ -71,0 +62,0 @@ const data = (0, _index.getData)(_imageServiceConstants.fittingTypes.SCALE_TO_FILL, {

"use strict";
exports.__esModule = true;
var _api = require("./api");
exports.getScaleToFitImageURL = _api.getScaleToFitImageURL;

@@ -8,0 +6,0 @@ exports.getScaleToFillImageURL = _api.getScaleToFillImageURL;

{
"name": "@wix/image-kit",
"description": "Standard library for generating canonical URL's for optimally consuming images at Wix",
"version": "1.26.0",
"version": "1.27.0",
"license": "MIT",

@@ -44,4 +44,4 @@ "author": {

"@types/node": "^16.0.0",
"@wix/jest-yoshi-preset": "^6.0.0",
"@wix/yoshi-flow-library": "^6.0.0",
"@wix/jest-yoshi-preset": "^6.50.4",
"@wix/yoshi-flow-library": "^6.50.4",
"husky": "~4.2.1",

@@ -68,3 +68,3 @@ "jsdom": "^19.0.0",

},
"falconPackageHash": "2eecd1abaa2635f1ec100308012effb97b6308eaa54b34310a3b8775"
"falconPackageHash": "26ba9e7596ec706036dca1576d5edbad9f989261eb21a6aaafabf69b"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc