@wix/image-kit
Advanced tools
Comparing version 1.56.0 to 1.57.0
@@ -31,6 +31,13 @@ import { emptyData } from '../../helpers/imageServiceConstants'; | ||
*/ | ||
return getData(fittingType, src, target, Object.assign(Object.assign({}, options), { autoEncode, useSrcset: canTransformImage })); | ||
return getData(fittingType, src, target, { | ||
...options, | ||
autoEncode, | ||
useSrcset: canTransformImage, | ||
}); | ||
} | ||
// If there aren't dimensions, we make them up | ||
const newTarget = Object.assign(Object.assign({}, target), validateTargetDimensions(src, target)); | ||
const newTarget = { | ||
...target, | ||
...validateTargetDimensions(src, target), | ||
}; | ||
const { alignment, htmlTag } = newTarget; | ||
@@ -42,4 +49,7 @@ const isFakeTile = getIsFakeTile(fittingType, src, newTarget); | ||
const overrideCSS = getCSSOverrides(fittingType, src, target, alignment); | ||
const { uri } = getData(convertedFittingType, src, Object.assign(Object.assign({}, scaledDimensions), { alignment, | ||
htmlTag }), { | ||
const { uri } = getData(convertedFittingType, src, { | ||
...scaledDimensions, | ||
alignment, | ||
htmlTag, | ||
}, { | ||
autoEncode, | ||
@@ -50,4 +60,7 @@ filters: blur ? { blur } : {}, | ||
}); | ||
const { attr = {}, css } = getData(fittingType, src, Object.assign(Object.assign({}, newTarget), { alignment, | ||
htmlTag }), {}); | ||
const { attr = {}, css } = getData(fittingType, src, { | ||
...newTarget, | ||
alignment, | ||
htmlTag, | ||
}, {}); | ||
css.img = css.img || {}; | ||
@@ -79,3 +92,3 @@ css.container = css.container || {}; | ||
data.uri = getURI(fittingType, src, targetObj, options, transformObj); | ||
if (options === null || options === void 0 ? void 0 : options.useSrcset) { | ||
if (options?.useSrcset) { | ||
data.srcset = getSrcset(fittingType, src, targetObj, options, data); | ||
@@ -82,0 +95,0 @@ } |
@@ -8,6 +8,12 @@ import { getURI } from './uri'; | ||
? data.uri | ||
: getURI(fittingType, src, Object.assign(Object.assign({}, target), { pixelAspectRatio: 1 }), options)} 1x`, | ||
: getURI(fittingType, src, { | ||
...target, | ||
pixelAspectRatio: 1, | ||
}, options)} 1x`, | ||
`${dpr === 2 | ||
? data.uri | ||
: getURI(fittingType, src, Object.assign(Object.assign({}, target), { pixelAspectRatio: 2 }), options)} 2x`, | ||
: getURI(fittingType, src, { | ||
...target, | ||
pixelAspectRatio: 2, | ||
}, options)} 2x`, | ||
], | ||
@@ -14,0 +20,0 @@ }; |
@@ -23,3 +23,3 @@ import { isSEOBot, getFileType, getFileName, getFileExtension, getDevicePixelRatio, getUpscaleString, isImageTransformApplicable, } from '../helpers/imageServiceUtils'; | ||
const preferredExtension = fileExtension; | ||
const canTransformImage = isImageTransformApplicable(src.id, options === null || options === void 0 ? void 0 : options.hasAnimation, options === null || options === void 0 ? void 0 : options.allowWEBPTransform); | ||
const canTransformImage = isImageTransformApplicable(src.id, options?.hasAnimation, options?.allowWEBPTransform); | ||
const transformsObj = { | ||
@@ -69,3 +69,3 @@ fileName, | ||
function getTarget(fittingType, src, target) { | ||
const targetObj = Object.assign({}, target); | ||
const targetObj = { ...target }; | ||
const _isMobile = isMobile(); | ||
@@ -72,0 +72,0 @@ // handle site BG legacy fitting types (desktop & mobile) |
@@ -1,2 +0,1 @@ | ||
import { __rest } from "tslib"; | ||
import { isImageTransformApplicable, isWEBP } from '../helpers/imageServiceUtils'; | ||
@@ -18,8 +17,8 @@ import { getImageURI } from '../engines/transforms'; | ||
// check if image transformation is applicable (e.g. .gif, .wix_mp) | ||
if (isImageTransformApplicable(src.id, options === null || options === void 0 ? void 0 : options.hasAnimation, options === null || options === void 0 ? void 0 : options.allowWEBPTransform)) { | ||
if (isImageTransformApplicable(src.id, options?.hasAnimation, options?.allowWEBPTransform)) { | ||
if (isWEBP(src.id)) { | ||
// exclude alignment, focalPoint and crop from webp transformation in order not to break webp images before transformation was enabled | ||
const { alignment } = target, transformTarget = __rest(target, ["alignment"]); | ||
const { alignment, ...transformTarget } = target; | ||
src.focalPoint = { x: undefined, y: undefined }; | ||
src === null || src === void 0 ? true : delete src.crop; | ||
delete src?.crop; | ||
transformObj = getTransform(fittingType, src, transformTarget, options); | ||
@@ -26,0 +25,0 @@ } |
@@ -106,4 +106,3 @@ import { alignTypes, alignTypesMap, fileType, fittingTypes, imageQuality, imageScaleDefaults, transformTypes, upscaleMethods, upscaleMethodsValues, ALIGN_TYPE_TO_FOCAL_POINT, MAX_DEVICE_PIXEL_RATIO, SUPER_UPSCALE_MODELS, SAFE_TRANSFORMED_AREA, } from './imageServiceConstants'; | ||
function isSEOBot(options) { | ||
var _a; | ||
return (_a = options === null || options === void 0 ? void 0 : options.isSEOBot) !== null && _a !== void 0 ? _a : false; | ||
return options?.isSEOBot ?? false; | ||
} | ||
@@ -110,0 +109,0 @@ // https://jira.wixpress.com/browse/WEED-12667 |
@@ -10,3 +10,2 @@ import { last } from './utils'; | ||
function setTransformOptions(transformsObj, options) { | ||
var _a; | ||
options = options || {}; | ||
@@ -17,3 +16,3 @@ // options - general | ||
transformsObj.watermark = getWatermark(options); | ||
transformsObj.autoEncode = (_a = options.autoEncode) !== null && _a !== void 0 ? _a : true; | ||
transformsObj.autoEncode = options.autoEncode ?? true; | ||
// options - filters & adjustments | ||
@@ -120,3 +119,2 @@ transformsObj.unsharpMask = getUnsharpMask(transformsObj, options); | ||
function getUnsharpMask(transformsObj, options) { | ||
var _a, _b, _c; | ||
// If options.unsharpMask is a valid value, use it | ||
@@ -126,5 +124,5 @@ if (isUSMValid(options.unsharpMask)) { | ||
return { | ||
radius: roundToFixed((_a = options.unsharpMask) === null || _a === void 0 ? void 0 : _a.radius, 2), | ||
amount: roundToFixed((_b = options.unsharpMask) === null || _b === void 0 ? void 0 : _b.amount, 2), | ||
threshold: roundToFixed((_c = options.unsharpMask) === null || _c === void 0 ? void 0 : _c.threshold, 2), | ||
radius: roundToFixed(options.unsharpMask?.radius, 2), | ||
amount: roundToFixed(options.unsharpMask?.amount, 2), | ||
threshold: roundToFixed(options.unsharpMask?.threshold, 2), | ||
}; | ||
@@ -131,0 +129,0 @@ // if options.unsharpMask is not all zeros and not valid and usm should be used, use default |
@@ -150,3 +150,3 @@ import { fittingTypes, transformTypes, alignTypesMap, } from './imageServiceConstants'; | ||
const scaleFactor = getScaleFactor(transformsObj.src.width, transformsObj.src.height, target.width, target.height, transformTypes.FILL); | ||
const clonedTarget = Object.assign({}, target); | ||
const clonedTarget = { ...target }; | ||
clonedTarget.width = transformsObj.src.width * scaleFactor; | ||
@@ -153,0 +153,0 @@ clonedTarget.height = transformsObj.src.height * scaleFactor; |
{ | ||
"name": "@wix/image-kit", | ||
"description": "Standard library for generating canonical URL's for optimally consuming images at Wix", | ||
"version": "1.56.0", | ||
"version": "1.57.0", | ||
"license": "MIT", | ||
@@ -44,4 +44,4 @@ "author": { | ||
"@types/node": "^16.18.83", | ||
"@wix/jest-yoshi-preset": "^6.88.1", | ||
"@wix/yoshi-flow-library": "^6.88.1", | ||
"@wix/jest-yoshi-preset": "^6.89.0", | ||
"@wix/yoshi-flow-library": "^6.89.0", | ||
"husky": "~4.2.1", | ||
@@ -68,3 +68,3 @@ "jsdom": "^19.0.0", | ||
}, | ||
"falconPackageHash": "dbccb6a154af087da4e963df8cfb06a94c2736dd0083430cf4200fd6" | ||
"falconPackageHash": "20ffe9836ebfcb460de04e18cde70e7959b742ea0199f290074c2619" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5626
548994