Socket
Socket
Sign inDemoInstall

wix-style-processor

Package Overview
Dependencies
17
Maintainers
1
Versions
188
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.122 to 3.0.123

2

dist/src/external-types.d.ts

@@ -7,3 +7,3 @@ declare var expect: Function;

Wix: any;
CSS: {supports: Function}
CSS: { supports: Function };
styleProcessor?: any;

@@ -10,0 +10,0 @@ changeStyles?: any;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// murmurhash2 via https://gist.github.com/raycmorgan/588423
Object.defineProperty(exports, "__esModule", { value: true });
/* tslint:disable */
function hash(str) {

@@ -5,0 +6,0 @@ return murmur2(str, str.length).toString(36);

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

var defaultReplacers_1 = require("./defaultReplacers");
/* tslint:disable:no-invalid-this */
exports.default = {
styleUpdater: null,
plugins: new plugins_1.Plugins(),
init: function (options, domServiceOverride) {
init: function (options, domService) {
var _this = this;
if (options === void 0) { options = {}; }
if (domServiceOverride === void 0) { domServiceOverride = domService_1.default; }
var wixService = wixService_1.default(window.Wix);
if (domService === void 0) { domService = domService_1.default; }
var wixService = new wixService_1.WixService(window.Wix);
Object.keys(defaultPlugins_1.defaultPlugins)

@@ -24,6 +25,6 @@ .forEach(function (funcName) { return _this.plugins.addCssFunction(funcName, defaultPlugins_1.defaultPlugins[funcName]); });

defaultOptions.plugins = this.plugins;
defaultOptions.shouldUseCssVars = domService_1.default.isCssVarsSupported() && (wixService.isEditorMode() || wixService.isPreviewMode());
defaultOptions.shouldUseCssVars = domService.isCssVarsSupported() && (wixService.isEditorMode() || wixService.isPreviewMode());
defaultOptions.shouldApplyCSSFunctions = !wixService.shouldRunAsStandalone();
options = Object.assign({}, defaultOptions, options);
this.styleUpdater = styleUpdater_1.default(wixService, domServiceOverride, options);
this.styleUpdater = styleUpdater_1.StyleUpdaterFactory(wixService, domService, options);
if (wixService.isEditorMode() || wixService.isPreviewMode()) {

@@ -30,0 +31,0 @@ wixService.listenToStyleParamsChange(function () { return _this.styleUpdater.update(true); });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var paramsRegex = /,(?![^(]*(?:\)|}))/g;
var Plugins = /** @class */ (function () {

@@ -27,3 +28,3 @@ function Plugins() {

funcName: groups[1],
args: groups[2]
args: groups[2].split(paramsRegex)
};

@@ -39,3 +40,3 @@ }

exports.Plugins = Plugins;
function wrapWithValueProvider(fn) {
function wrapWithValueProvider(fnToWrap) {
return function () {

@@ -46,5 +47,5 @@ var args = [];

}
return function (tpaParams) { return fn.apply(void 0, args.map(function (fn) { return fn(tpaParams); }).concat([tpaParams])); };
return function (tpaParams) { return fnToWrap.apply(void 0, args.map(function (fn) { return fn(tpaParams); }).concat([tpaParams])); };
};
}
//# sourceMappingURL=plugins.js.map

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

var hash_1 = require("./hash");
var paramsRegex = /,(?![^(]*(?:\)|}))/g;
function processor(_a, _b) {

@@ -25,6 +24,6 @@ var part = _a.part, customSyntaxHelper = _a.customSyntaxHelper, tpaParams = _a.tpaParams, cacheMap = _a.cacheMap;

function executeFunction(value, plugins, customSyntaxHelper) {
var functionSignature;
if (functionSignature = plugins.getFunctionSignature(value)) {
return (_a = plugins.cssFunctions)[functionSignature.funcName].apply(_a, functionSignature.args.split(paramsRegex)
.map(function (v) { return executeFunction(v.trim(), plugins, customSyntaxHelper); }));
var functionSignature = plugins.getFunctionSignature(value);
if (functionSignature) {
return (_a = plugins.cssFunctions)[functionSignature.funcName].apply(_a, functionSignature.args
.map(function (arg) { return executeFunction(arg.trim(), plugins, customSyntaxHelper); }));
}

@@ -31,0 +30,0 @@ else {

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

var utils_1 = require("./utils");
exports.default = (function (wixService, domService, options) {
function StyleUpdaterFactory(wixService, domService, options) {
var cacheMap = {};

@@ -37,5 +37,6 @@ return {

if (options.shouldUseCssVars) {
var varMap = Object.keys(cacheMap).reduce(function (varMap, key) {
varMap[key] = cacheMap[key](tpaParams);
return varMap;
var varMap = Object.keys(cacheMap)
.reduce(function (acc, key) {
acc[key] = cacheMap[key](tpaParams);
return acc;
}, {});

@@ -45,2 +46,3 @@ domService.updateCssVars(varMap);

}).catch(function (err) {
//tslint:disable-next-line
console.error('Failed updating styles:', err);

@@ -51,3 +53,4 @@ throw err;

};
});
}
exports.StyleUpdaterFactory = StyleUpdaterFactory;
function escapeRegExp(str) {

@@ -60,3 +63,3 @@ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');

stylis.use(function (context, declaration) {
if (context == 1) {
if (context === 1) {
var _a = utils_1.splitDeclaration(declaration), key = _a.key, value = _a.value;

@@ -82,7 +85,7 @@ var pluginResult = replacer(key, value);

/* post-process */
return customSyntaxHelper.customSyntaxStrs.reduce(function (content, part) {
return customSyntaxHelper.customSyntaxStrs.reduce(function (processedContent, part) {
var newValue = processor_1.processor({
part: part, customSyntaxHelper: customSyntaxHelper, tpaParams: tpaParams, cacheMap: cacheMap
}, options);
return content.replace(new RegExp(escapeRegExp(part), 'g'), newValue);
return processedContent.replace(new RegExp(escapeRegExp(part), 'g'), newValue);
}, content);

@@ -89,0 +92,0 @@ }

@@ -19,4 +19,4 @@ "use strict";

exports.isJsonLike = isJsonLike;
function parseJson(value) {
return value.slice(1, -1)
function parseJson(strValue) {
return strValue.slice(1, -1)
.split(',')

@@ -23,0 +23,0 @@ .reduce(function (json, current) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (function (Wix) { return ({
getStyleParams: function () {
var WixService = /** @class */ (function () {
function WixService(Wix) {
this.Wix = Wix;
}
WixService.prototype.getStyleParams = function () {
return this.shouldRunAsStandalone() ?
Promise.resolve([{}, {}, {}]) :
Promise.all([
getSiteColors(Wix),
getSiteTextPresets(Wix),
getStyleParams(Wix)
promisfy(this.Wix.Styles.getSiteColors),
promisfy(this.Wix.Styles.getSiteTextPresets),
promisfy(this.Wix.Styles.getStyleParams)
]);
},
listenToStyleParamsChange: function (cb) {
Wix.addEventListener(Wix.Events.STYLE_PARAMS_CHANGE, cb);
},
listenToSettingsUpdated: function (cb) {
Wix.addEventListener(Wix.Events.SETTINGS_UPDATED, cb);
},
isEditorMode: function () {
return Wix.Utils.getViewMode() === 'editor';
},
isPreviewMode: function () {
return Wix.Utils.getViewMode() === 'preview';
},
shouldRunAsStandalone: function () {
};
WixService.prototype.listenToStyleParamsChange = function (cb) {
this.Wix.addEventListener(this.Wix.Events.STYLE_PARAMS_CHANGE, cb);
};
WixService.prototype.listenToSettingsUpdated = function (cb) {
this.Wix.addEventListener(this.Wix.Events.SETTINGS_UPDATED, cb);
};
WixService.prototype.isEditorMode = function () {
return this.Wix.Utils.getViewMode() === 'editor';
};
WixService.prototype.isPreviewMode = function () {
return this.Wix.Utils.getViewMode() === 'preview';
};
WixService.prototype.isStandaloneMode = function () {
return this.Wix.Utils.getViewMode() === 'standalone';
};
WixService.prototype.shouldRunAsStandalone = function () {
return this.isStandaloneMode() || this.withoutStyleCapabilites();
},
withoutStyleCapabilites: function () {
return !Wix.Styles;
},
isStandaloneMode: function () {
return Wix.Utils.getViewMode() === 'standalone';
}
}); });
function getSiteColors(Wix) {
return new Promise(function (resolve, reject) { return Wix.Styles.getSiteColors(function (res) { return res ? resolve(res) : reject({}); }); });
};
WixService.prototype.withoutStyleCapabilites = function () {
return !this.Wix.Styles;
};
return WixService;
}());
exports.WixService = WixService;
function promisfy(fn) {
return new Promise(function (resolve, reject) { return fn(function (res) { return res ? resolve(res) : reject({}); }); });
}
function getSiteTextPresets(Wix) {
return new Promise(function (resolve, reject) { return Wix.Styles.getSiteTextPresets(function (res) { return res ? resolve(res) : reject({}); }); });
}
function getStyleParams(Wix) {
return new Promise(function (resolve, reject) { return Wix.Styles.getStyleParams(function (res) { return res ? resolve(res) : reject({}); }); });
}
//# sourceMappingURL=wixService.js.map

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

var size = font.size || 'normal';
if (utils_1.isNumber(size))
if (utils_1.isNumber(size)) {
size = size + 'px';
}
var lineHeight = font.lineHeight || 'normal';
if (utils_1.isNumber(lineHeight))
if (utils_1.isNumber(lineHeight)) {
lineHeight = lineHeight + 'px';
}
value += size + '/' + lineHeight + ' ';

@@ -79,0 +81,0 @@ value += font.cssFontFamily || font.family;

@@ -5,3 +5,3 @@ {

"description": "An alternative Wix Styles TPA processor",
"version": "3.0.122",
"version": "3.0.123",
"author": {

@@ -18,9 +18,9 @@ "name": "Eran Shabi",

"scripts": {
"start": "haste start --entry-point=./test/mock/start-fake-server.js",
"start": "yoshi start --entry-point=./test/mock/start-fake-server.js",
"build": ":",
"pretest": "haste lint && haste build",
"test:unit": "haste test --mocha",
"test:e2e": "haste test --protractor",
"pretest": "yoshi lint && yoshi build",
"test:unit": "yoshi test --mocha",
"test:e2e": "yoshi test --protractor",
"test": "npm run test:unit && npm run test:e2e",
"release": "haste release"
"release": "yoshi release"
},

@@ -46,3 +46,3 @@ "dependencies": {

"velocity": "^0.7.2",
"haste-preset-yoshi": "latest"
"yoshi": "^2.6.1"
},

@@ -61,6 +61,3 @@ "yoshi": {

"registry": "https://registry.npmjs.org/"
},
"haste": {
"preset": "yoshi"
}
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc