wix-style-processor
Advanced tools
Comparing version 3.0.34 to 3.0.35
@@ -5,6 +5,3 @@ "use strict"; | ||
var wixStylesFontUtils_1 = require("./wixStylesFontUtils"); | ||
var pickBy = require("lodash/pickBy"); | ||
var omitBy = require("lodash/omitBy"); | ||
var forEach = require("lodash/forEach"); | ||
var isEqual = require("lodash/isEqual"); | ||
var _ = require("lodash"); | ||
var Stylis = require("stylis"); | ||
@@ -23,11 +20,11 @@ var processor_1 = require("./processor"); | ||
var isValidFontParam = function (fontParam) { return fontParam.family !== undefined; }; | ||
var colorStyles = omitBy(styleParams.colors || {}, function (v) { return isEqual(v, { value: 'rgba(1,2,3,1)' }) || isEqual(v, { rgba: 'rgba(1,2,3,1)' }); }); | ||
var fontStyles = pickBy(styleParams.fonts, isValidFontParam); | ||
var colorStyles = _.omitBy(styleParams.colors || {}, function (v) { return _.isEqual(v, { value: 'rgba(1,2,3,1)' }) || _.isEqual(v, { rgba: 'rgba(1,2,3,1)' }); }); | ||
var fontStyles = _.pickBy(styleParams.fonts, isValidFontParam); | ||
var numbers = styleParams.numbers || {}; | ||
var colors = wixStylesColorUtils_1.default.getFullColorStyles({ colorStyles: colorStyles, siteColors: siteColors }) || {}; | ||
var fonts = wixStylesFontUtils_1.default.getFullFontStyles({ fontStyles: fontStyles, siteTextPresets: siteTextPresets }) || {}; | ||
var strings = pickBy(styleParams.fonts, isStringHack); | ||
var strings = _.pickBy(styleParams.fonts, isStringHack); | ||
var tpaParams = { colors: colors, fonts: fonts, numbers: numbers, strings: strings }; | ||
if (!isRerender || !options.shouldUseCssVars) { | ||
forEach(domService.getAllStyleTags(), function (tagStyle) { | ||
_.forEach(domService.getAllStyleTags(), function (tagStyle) { | ||
var css = (tagStyle.originalTemplate || tagStyle.textContent); | ||
@@ -34,0 +31,0 @@ var stylis = new Stylis({ semicolon: false, compress: false, preserve: true }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var each = require("lodash/each"); | ||
var map = require("lodash/map"); | ||
var reduce = require("lodash/reduce"); | ||
var startsWith = require("lodash/startsWith"); | ||
var endsWith = require("lodash/endsWith"); | ||
var _ = require("lodash"); | ||
var Color = require("color"); | ||
@@ -23,3 +19,3 @@ var WixColorUtils = { | ||
// Basic template colors | ||
each(siteColors, function (_a) { | ||
_.each(siteColors, function (_a) { | ||
var reference = _a.reference, value = _a.value; | ||
@@ -37,7 +33,7 @@ returnValue[reference] = value; | ||
'color': function (key) { | ||
if (startsWith(key, '"') && endsWith(key, '"')) { | ||
if (_.startsWith(key, '"') && _.endsWith(key, '"')) { | ||
key = key.substr(1, key.length - 2); | ||
} | ||
key = key.replace(/\./g, '-'); | ||
if (startsWith(key, '--')) { | ||
if (_.startsWith(key, '--')) { | ||
key = key.substr(2, key.length - 2); | ||
@@ -50,3 +46,3 @@ } | ||
return values[key]; | ||
if (startsWith(key, 'color-')) | ||
if (_.startsWith(key, 'color-')) | ||
return values[key.substr(6)]; // support 'bbb' and 'color-bbb' for same variable | ||
@@ -71,3 +67,3 @@ })(); | ||
'join': function (params) { | ||
if (startsWith(params, '[') && endsWith(params, ']')) { | ||
if (_.startsWith(params, '[') && _.endsWith(params, ']')) { | ||
params = params.substr(1, params.length - 2); | ||
@@ -81,4 +77,4 @@ } | ||
} | ||
var arr = map(params.split(','), function (p) { return p.replace(/_<_/g, '(').replace(/_>_/g, ')').replace(/_\|_/g, ',').trim(); }); | ||
var ret = reduce(arr, function (acc, color) { | ||
var arr = _.map(params.split(','), function (p) { return p.replace(/_<_/g, '(').replace(/_>_/g, ')').replace(/_\|_/g, ',').trim(); }); | ||
var ret = _.reduce(arr, function (acc, color) { | ||
var c = new Color(fromDefaultString(color)); | ||
@@ -85,0 +81,0 @@ acc.red(acc.red() + c.red() * c.alpha()); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var each = require("lodash/each"); | ||
var extend = require("lodash/extend"); | ||
var includes = require("lodash/includes"); | ||
var omit = require("lodash/omit"); | ||
var isNumber = require("lodash/isNumber"); | ||
var _ = require("lodash"); | ||
var parseCssFont = require("parse-css-font"); | ||
@@ -15,7 +11,7 @@ var WixFontUtils = { | ||
var fixedFontStyles = {}; | ||
each(fontStyles, function (v, k) { return fixedFontStyles[k.replace(/\./g, '-')] = v; }); | ||
_.each(fontStyles, function (v, k) { return fixedFontStyles[k.replace(/\./g, '-')] = v; }); | ||
var parsedSiteTextPresets = {}; | ||
each(siteTextPresets, function (preset, key) { | ||
_.each(siteTextPresets, function (preset, key) { | ||
if (preset.displayName) { | ||
parsedSiteTextPresets[key] = extend({}, parseCssFont(preset.value), { | ||
parsedSiteTextPresets[key] = _.extend({}, parseCssFont(preset.value), { | ||
preset: key, | ||
@@ -27,3 +23,3 @@ editorKey: preset.editorKey, | ||
else { | ||
parsedSiteTextPresets[key] = extend({}, parseCssFont(preset.value), { | ||
parsedSiteTextPresets[key] = _.extend({}, parseCssFont(preset.value), { | ||
preset: key, | ||
@@ -35,5 +31,5 @@ editorKey: preset.editorKey | ||
var parsedFontStyles = {}; | ||
each(fixedFontStyles, function (value, key) { return parsedFontStyles[key] = parseWixStylesFont(value); }); | ||
_.each(fixedFontStyles, function (value, key) { return parsedFontStyles[key] = parseWixStylesFont(value); }); | ||
// Basic template colors | ||
each(parsedSiteTextPresets, function (preset, key) { return ret[key] = parsedFontStyles[key] || preset; }); | ||
_.each(parsedSiteTextPresets, function (preset, key) { return ret[key] = parsedFontStyles[key] || preset; }); | ||
// LIGHT/MEDIUM/STRONG | ||
@@ -44,5 +40,5 @@ ret['LIGHT'] = parseCssFont('12px HelveticaNeueW01-45Ligh'); | ||
ret = Object.assign(ret, parsedFontStyles); | ||
each(ret, function (font, key) { | ||
ret[key] = extend({}, font, { supports: { uppercase: true } }); | ||
if ((includes(font.family, 'snellroundhandw')) || (includes(font.family, 'niconne'))) { | ||
_.each(ret, function (font, key) { | ||
ret[key] = _.extend({}, font, { supports: { uppercase: true } }); | ||
if ((_.includes(font.family, 'snellroundhandw')) || (_.includes(font.family, 'niconne'))) { | ||
ret[key].supports.uppercase = false; | ||
@@ -62,3 +58,3 @@ } | ||
var preset = function (_default) { return values[_default]; }; | ||
var font = function (_default) { return extend({}, values[_default.template], omit(_default, 'template')); }; | ||
var font = function (_default) { return _.extend({}, values[_default.template], _.omit(_default, 'template')); }; | ||
var m = null; | ||
@@ -76,4 +72,4 @@ if (m = str.match(/fontPreset\((.*)\)$/)) { | ||
toFontCssValue: function (value) { | ||
var size = isNumber(value.size) ? value.size + 'px' : value.size; | ||
var lineHeight = isNumber(value.lineHeight) ? value.lineHeight + 'px' : value.lineHeight; | ||
var size = _.isNumber(value.size) ? value.size + 'px' : value.size; | ||
var lineHeight = _.isNumber(value.lineHeight) ? value.lineHeight + 'px' : value.lineHeight; | ||
return value.style + " " + value.variant + " " + value.weight + " " + size + "/" + lineHeight + " " + value.family.join(','); | ||
@@ -91,6 +87,6 @@ } | ||
var size = font.size || 'normal'; | ||
if (isNumber(size)) | ||
if (_.isNumber(size)) | ||
size = size + 'px'; | ||
var lineHeight = font.lineHeight || 'normal'; | ||
if (isNumber(lineHeight)) | ||
if (_.isNumber(lineHeight)) | ||
lineHeight = lineHeight + 'px'; | ||
@@ -97,0 +93,0 @@ value += size + '/' + lineHeight + ' '; |
@@ -5,3 +5,3 @@ { | ||
"description": "An alternative Wix Styles TPA processor", | ||
"version": "3.0.34", | ||
"version": "3.0.35", | ||
"author": { | ||
@@ -8,0 +8,0 @@ "name": "Eran Shabi", |
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 too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
7646322
50708
4