@wix/motion-edm-autogen-p13n
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -14,4 +14,5 @@ "use strict"; | ||
const alignIfLegacyImage = image => { | ||
const _URL = new URL(image), | ||
protocol = _URL.protocol; | ||
const { | ||
protocol | ||
} = new URL(image); | ||
return protocol === WIX_LEGACY_IMAGE_PROTOCOL ? `wix:${image}` : image; | ||
@@ -24,12 +25,12 @@ }; | ||
const alignedImage = alignIfLegacyImage(image); | ||
const _URL2 = new URL(alignedImage), | ||
protocol = _URL2.protocol, | ||
hash = _URL2.hash, | ||
pathname = _URL2.pathname; | ||
const _querystring$parse = _querystring.default.parse(hash.replace(URL_HASH_PREFIX, '')), | ||
height = _querystring$parse.originHeight, | ||
width = _querystring$parse.originWidth; | ||
const _pathname$replace$spl = pathname.replace(WIX_IMAGE_PROTOCOL_SUFFIX, '').split('/'), | ||
id = _pathname$replace$spl[0], | ||
filename = _pathname$replace$spl[1]; | ||
const { | ||
protocol, | ||
hash, | ||
pathname | ||
} = new URL(alignedImage); | ||
const { | ||
originHeight: height, | ||
originWidth: width | ||
} = _querystring.default.parse(hash.replace(URL_HASH_PREFIX, '')); | ||
const [id, filename] = pathname.replace(WIX_IMAGE_PROTOCOL_SUFFIX, '').split('/'); | ||
if (protocol === WIX_IMAGE_PROTOCOL) { | ||
@@ -49,4 +50,3 @@ return { | ||
const computeImageFileName = image => { | ||
var _image$altText; | ||
const filename = (_image$altText = image.altText) != null ? _image$altText : DEFAULT_IMAGE_FILE_NAME; | ||
const filename = image.altText ?? DEFAULT_IMAGE_FILE_NAME; | ||
return encodeURIComponent(filename); | ||
@@ -53,0 +53,0 @@ }; |
@@ -10,5 +10,3 @@ "use strict"; | ||
const lowercaseAllButFirst = s => { | ||
const _s$split = s.split(' '), | ||
first = _s$split[0], | ||
rest = _s$split.slice(1); | ||
const [first, ...rest] = s.split(' '); | ||
return [first, ...rest.map(w => w.toLowerCase())].join(' '); | ||
@@ -15,0 +13,0 @@ }; |
@@ -9,3 +9,3 @@ "use strict"; | ||
var _wrap = require("./wrap"); | ||
const builtinCustomFunctions = { | ||
const builtinCustomFunctions = exports.builtinCustomFunctions = { | ||
image: { | ||
@@ -22,3 +22,2 @@ corvidToP13n: _image.corvidToP13n, | ||
}; | ||
exports.builtinCustomFunctions = builtinCustomFunctions; | ||
//# sourceMappingURL=index.js.map |
const wrapper = require('../index'); | ||
module.exports = { | ||
services: wrapper, | ||
requests: wrapper, | ||
responses: wrapper | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
module.exports = {services: wrapper, requests: wrapper, responses: wrapper}; |
const wrapper = require('../index'); | ||
module.exports = { | ||
services: wrapper, | ||
requests: wrapper, | ||
responses: wrapper | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
module.exports = {services: wrapper, requests: wrapper, responses: wrapper}; |
@@ -1,18 +0,13 @@ | ||
import { __assign } from "tslib"; | ||
import { pick, omitBy, isUndefined } from 'lodash'; | ||
var sharedFieldNames = ['city', 'subdivision', 'country', 'postalCode']; | ||
var sharedStreetAddressFieldNames = ['name', 'number', 'apt']; | ||
var p13nToCorvid = function (p13nAddress) { | ||
return p13nAddress | ||
? omitBy(__assign(__assign({ formatted: p13nAddress.formattedAddress, location: p13nAddress.geocode }, pick(p13nAddress, sharedFieldNames)), { streetAddress: p13nAddress.streetAddress && | ||
pick(p13nAddress.streetAddress, sharedStreetAddressFieldNames), addressLine1: p13nAddress.addressLine, addressLine2: p13nAddress.addressLine2 }), isUndefined) | ||
: undefined; | ||
}; | ||
var corvidToP13n = function (corvidAddress) { | ||
return corvidAddress | ||
? omitBy(__assign(__assign({ formattedAddress: corvidAddress.formatted, geocode: corvidAddress.location }, pick(corvidAddress, sharedFieldNames)), { streetAddress: corvidAddress.streetAddress && | ||
pick(corvidAddress.streetAddress, sharedStreetAddressFieldNames), addressLine: corvidAddress.addressLine1, addressLine2: corvidAddress.addressLine2 }), isUndefined) | ||
: undefined; | ||
}; | ||
const sharedFieldNames = ['city', 'subdivision', 'country', 'postalCode']; | ||
const sharedStreetAddressFieldNames = ['name', 'number', 'apt']; | ||
const p13nToCorvid = (p13nAddress) => p13nAddress | ||
? omitBy(Object.assign(Object.assign({ formatted: p13nAddress.formattedAddress, location: p13nAddress.geocode }, pick(p13nAddress, sharedFieldNames)), { streetAddress: p13nAddress.streetAddress && | ||
pick(p13nAddress.streetAddress, sharedStreetAddressFieldNames), addressLine1: p13nAddress.addressLine, addressLine2: p13nAddress.addressLine2 }), isUndefined) | ||
: undefined; | ||
const corvidToP13n = (corvidAddress) => corvidAddress | ||
? omitBy(Object.assign(Object.assign({ formattedAddress: corvidAddress.formatted, geocode: corvidAddress.location }, pick(corvidAddress, sharedFieldNames)), { streetAddress: corvidAddress.streetAddress && | ||
pick(corvidAddress.streetAddress, sharedStreetAddressFieldNames), addressLine: corvidAddress.addressLine1, addressLine2: corvidAddress.addressLine2 }), isUndefined) | ||
: undefined; | ||
export { p13nToCorvid, corvidToP13n }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,9 +0,3 @@ | ||
var coalesce = function () { | ||
var values = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
values[_i] = arguments[_i]; | ||
} | ||
return values.find(function (v) { return v !== undefined; }); | ||
}; | ||
const coalesce = (...values) => values.find((v) => v !== undefined); | ||
export { coalesce }; | ||
//# sourceMappingURL=coalesce.js.map |
import querystring from 'querystring'; | ||
import { toAltText } from './toAltText'; | ||
var WIX_IMAGE_PROTOCOL = 'wix:'; | ||
var WIX_LEGACY_IMAGE_PROTOCOL = 'image:'; | ||
var WIX_IMAGE_PROTOCOL_SUFFIX = 'image://v1/'; | ||
var URL_HASH_PREFIX = '#'; | ||
var DEFAULT_IMAGE_FILE_NAME = 'file'; | ||
var alignIfLegacyImage = function (image) { | ||
var protocol = new URL(image).protocol; | ||
return protocol === WIX_LEGACY_IMAGE_PROTOCOL ? "wix:".concat(image) : image; | ||
const WIX_IMAGE_PROTOCOL = 'wix:'; | ||
const WIX_LEGACY_IMAGE_PROTOCOL = 'image:'; | ||
const WIX_IMAGE_PROTOCOL_SUFFIX = 'image://v1/'; | ||
const URL_HASH_PREFIX = '#'; | ||
const DEFAULT_IMAGE_FILE_NAME = 'file'; | ||
const alignIfLegacyImage = (image) => { | ||
const { protocol } = new URL(image); | ||
return protocol === WIX_LEGACY_IMAGE_PROTOCOL ? `wix:${image}` : image; | ||
}; | ||
var corvidToP13n = function (image) { | ||
const corvidToP13n = (image) => { | ||
if (!image) { | ||
return undefined; | ||
} | ||
var alignedImage = alignIfLegacyImage(image); | ||
var _a = new URL(alignedImage), protocol = _a.protocol, hash = _a.hash, pathname = _a.pathname; | ||
var _b = querystring.parse(hash.replace(URL_HASH_PREFIX, '')), height = _b.originHeight, width = _b.originWidth; | ||
var _c = pathname | ||
const alignedImage = alignIfLegacyImage(image); | ||
const { protocol, hash, pathname } = new URL(alignedImage); | ||
const { originHeight: height, originWidth: width } = querystring.parse(hash.replace(URL_HASH_PREFIX, '')); | ||
const [id, filename] = pathname | ||
.replace(WIX_IMAGE_PROTOCOL_SUFFIX, '') | ||
.split('/'), id = _c[0], filename = _c[1]; | ||
.split('/'); | ||
if (protocol === WIX_IMAGE_PROTOCOL) { | ||
return { | ||
id: id, | ||
id, | ||
height: Number(height), | ||
@@ -32,8 +32,8 @@ width: Number(width), | ||
}; | ||
var computeImageFileName = function (image) { | ||
const computeImageFileName = (image) => { | ||
var _a; | ||
var filename = (_a = image.altText) !== null && _a !== void 0 ? _a : DEFAULT_IMAGE_FILE_NAME; | ||
const filename = (_a = image.altText) !== null && _a !== void 0 ? _a : DEFAULT_IMAGE_FILE_NAME; | ||
return encodeURIComponent(filename); | ||
}; | ||
var p13nToCorvid = function (image) { | ||
const p13nToCorvid = (image) => { | ||
if (!image) { | ||
@@ -43,3 +43,3 @@ return undefined; | ||
return image.id | ||
? "wix:image://v1/".concat(image.id, "/").concat(computeImageFileName(image), "#originWidth=").concat(image.width, "&originHeight=").concat(image.height) | ||
? `wix:image://v1/${image.id}/${computeImageFileName(image)}#originWidth=${image.width}&originHeight=${image.height}` | ||
: image === null || image === void 0 ? void 0 : image.url; | ||
@@ -46,0 +46,0 @@ }; |
@@ -1,14 +0,11 @@ | ||
import { __spreadArray } from "tslib"; | ||
import { startCase } from 'lodash'; | ||
var removeExtension = function (s) { return s.replace(/\.\S*$/, ''); }; | ||
var trimConsequentSpaces = function (s) { return s.replace(/\s+/g, ' '); }; | ||
var removeSpecialChars = function (s) { | ||
return s.replace(/[^a-zA-Z0-9]/g, ' '); | ||
const removeExtension = (s) => s.replace(/\.\S*$/, ''); | ||
const trimConsequentSpaces = (s) => s.replace(/\s+/g, ' '); | ||
const removeSpecialChars = (s) => s.replace(/[^a-zA-Z0-9]/g, ' '); | ||
const lowercaseAllButFirst = (s) => { | ||
const [first, ...rest] = s.split(' '); | ||
return [first, ...rest.map((w) => w.toLowerCase())].join(' '); | ||
}; | ||
var lowercaseAllButFirst = function (s) { | ||
var _a = s.split(' '), first = _a[0], rest = _a.slice(1); | ||
return __spreadArray([first], rest.map(function (w) { return w.toLowerCase(); }), true).join(' '); | ||
}; | ||
var toAltText = function (s) { | ||
var reducers = [ | ||
const toAltText = (s) => { | ||
const reducers = [ | ||
decodeURIComponent, | ||
@@ -21,5 +18,5 @@ removeExtension, | ||
]; | ||
return reducers.reduce(function (acc, fn) { return fn(acc); }, s); | ||
return reducers.reduce((acc, fn) => fn(acc), s); | ||
}; | ||
export { toAltText }; | ||
//# sourceMappingURL=toAltText.js.map |
@@ -5,3 +5,3 @@ import { corvidToP13n as corvidAddressToP13n, p13nToCorvid as p13nAddressToCorvid, } from './address'; | ||
import { wrap } from './wrap'; | ||
var builtinCustomFunctions = { | ||
const builtinCustomFunctions = { | ||
image: { corvidToP13n: corvidImageToP13n, p13nToCorvid: p13nImageToCorvid }, | ||
@@ -12,6 +12,6 @@ address: { | ||
}, | ||
wrap: wrap, | ||
coalesce: coalesce, | ||
wrap, | ||
coalesce, | ||
}; | ||
export { builtinCustomFunctions }; | ||
//# sourceMappingURL=index.js.map |
import { isNil } from 'lodash'; | ||
var wrap = function (value, wrapperPropertyName) { | ||
var _a; | ||
return isNil(value) ? undefined : (_a = {}, _a[wrapperPropertyName] = value, _a); | ||
}; | ||
const wrap = (value, wrapperPropertyName) => isNil(value) ? undefined : { [wrapperPropertyName]: value }; | ||
export { wrap }; | ||
//# sourceMappingURL=wrap.js.map |
{ | ||
"name": "@wix/motion-edm-autogen-p13n", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"main": "dist/cjs/index.js", | ||
@@ -29,3 +29,3 @@ "module": "dist/esm/index.js", | ||
"@wix/eslint-config-yoshi": "^6.63.2", | ||
"@wix/jest-yoshi-preset": "^5.162.14", | ||
"@wix/jest-yoshi-preset": "^6.83.1", | ||
"@wix/motion-edm-autogen-test-context": "~1.0.0", | ||
@@ -37,3 +37,3 @@ "@wix/motion-runtime-test-context": "~1.0.0", | ||
"@wix/wix-test-env": "^1.0.877", | ||
"@wix/yoshi-flow-library": "^5.162.14", | ||
"@wix/yoshi-flow-library": "^6.83.1", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
@@ -43,3 +43,3 @@ "husky": "~4.2.1", | ||
"prettier": "^2.7.1", | ||
"ts-jest": "^26.4.4", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "~10.7.0", | ||
@@ -50,3 +50,3 @@ "typescript": "~4.7.4" | ||
"@babel/runtime": "^7.0.0", | ||
"@wix/motion-edm-autogen-types": "1.0.11", | ||
"@wix/motion-edm-autogen-types": "1.0.12", | ||
"lodash": "~4.17.0" | ||
@@ -76,3 +76,3 @@ }, | ||
}, | ||
"falconPackageHash": "7ba8c0e53aabb3fe5f8aa1befd8a278c7425c5a91f9f3667641428a8" | ||
"falconPackageHash": "7210581db8afc23c5ac742cf1506611f07add053ff8c841c6d8849e3" | ||
} |
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 too big to display
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
4176448
50
100454
+ Added@wix/motion-edm-autogen-types@1.0.12(transitive)
- Removed@wix/motion-edm-autogen-types@1.0.11(transitive)