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

less-openui5

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less-openui5 - npm Package Compare versions

Comparing version 0.5.4 to 0.6.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

# 0.6.0 (2018-09-10)
### Breaking changes
- Drop unsupported Node.js versions. Now requires >= 6 [#45](https://github.com/SAP/less-openui5/pull/45)
### Fixes
- Again, fix inline theme parameters encoding for '#' [#48](https://github.com/SAP/less-openui5/pull/48)
### All changes
[`0.5.4...0.6.0`](https://github.com/SAP/less-openui5/compare/0.5.4...0.6.0)
# 0.5.4 (2018-07-04)

@@ -2,0 +14,0 @@

47

lib/diff.js

@@ -15,10 +15,9 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";
// Regular expression to match type of property in order to check whether
// it possibly contains color values.
var rProperties = /(color|background|border|text|outline)(?!\-(width|radius|offset|style|align|overflow|transform))(\-(color|shadow|image))?/;
let rProperties = /(color|background|border|text|outline)(?!-(width|radius|offset|style|align|overflow|transform))(-(color|shadow|image))?/;
function selectorEquals(s1, s2) {
// Make sure there is the same number of select parts

@@ -30,3 +29,3 @@ if (s1.length !== s2.length) {

// Check if all the parts are the same strings
for (var i = 0; i < s1.length; i++) {
for (let i = 0; i < s1.length; i++) {
if (s1[i] !== s2[i]) {

@@ -60,9 +59,9 @@ return false;

Diffing.prototype.diffRules = function(oBaseRules, oCompareRules) {
var aDiffRules = [];
var iBaseNode, iCompareNode;
let aDiffRules = [];
let iBaseNode; let iCompareNode;
for (iBaseNode = 0, iCompareNode = 0; iBaseNode < oBaseRules.length; iBaseNode++, iCompareNode++) {
var oBaseNode = oBaseRules[iBaseNode];
var oCompareNode = oCompareRules[iCompareNode];
var oDiffNode = null;
let oBaseNode = oBaseRules[iBaseNode];
let oCompareNode = oCompareRules[iCompareNode];
let oDiffNode = null;

@@ -77,4 +76,4 @@ // Add all different compare nodes to stack and check for next one

if (oBaseNode.type === "comment") {
var sBaseComment = oBaseNode.comment;
var sCompareComment = oCompareNode.comment;
let sBaseComment = oBaseNode.comment;
let sCompareComment = oCompareNode.comment;

@@ -87,3 +86,2 @@ if (sBaseComment !== sCompareComment) {

if (oBaseNode.type === "rule") {
// Add all rules with different selector to stack and check for next one

@@ -96,15 +94,12 @@ while (!selectorEquals(oBaseNode.selectors, oCompareNode.selectors)) {

var aBaseDeclarations = oBaseNode.declarations;
var aCompareDeclarations = oCompareNode.declarations;
for (var j = 0; j < aBaseDeclarations.length; j++) {
var oBaseDeclaration = aBaseDeclarations[j];
var oCompareDeclaration = aCompareDeclarations[j];
let aBaseDeclarations = oBaseNode.declarations;
let aCompareDeclarations = oCompareNode.declarations;
for (let j = 0; j < aBaseDeclarations.length; j++) {
let oBaseDeclaration = aBaseDeclarations[j];
let oCompareDeclaration = aCompareDeclarations[j];
if (oBaseDeclaration.type === "declaration") {
// TODO: Also check for different node and add to stack???
if (oBaseDeclaration.type === oCompareDeclaration.type) {
if (oBaseDeclaration.property === oCompareDeclaration.property) {
// Always add color properties to diff to prevent unexpected CSS overrides

@@ -114,3 +109,2 @@ // due to selectors with more importance

|| oCompareDeclaration.property.match(rProperties)) {
// Add compared rule to diff

@@ -123,3 +117,2 @@ if (!oDiffNode) {

}
}

@@ -129,7 +122,5 @@ }

}
} else if (oBaseNode.type === "media") {
let aMediaDiffRules = this.diffRules(oBaseNode.rules, oCompareNode.rules);
var aMediaDiffRules = this.diffRules(oBaseNode.rules, oCompareNode.rules);
if (aMediaDiffRules.length > 0) {

@@ -139,3 +130,2 @@ oDiffNode = oCompareNode;

}
}

@@ -146,3 +136,2 @@

}
}

@@ -159,4 +148,4 @@

Diffing.prototype.run = function() {
var oBaseRules = this.oBase.stylesheet.rules;
var oCompareRules = this.oCompare.stylesheet.rules;
let oBaseRules = this.oBase.stylesheet.rules;
let oCompareRules = this.oCompare.stylesheet.rules;

@@ -163,0 +152,0 @@ this.oDiff.stylesheet.rules = this.diffRules(oBaseRules, oCompareRules);

@@ -15,9 +15,9 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";
var path = require('path');
let path = require("path");
module.exports = function(fs) {
if (!fs) {
fs = require('fs');
fs = require("fs");
}

@@ -29,3 +29,3 @@

// No rejection here as it is ok if the file was not found
resolve(stat ? { path: filePath, stat: stat } : null);
resolve(stat ? {path: filePath, stat: stat} : null);
});

@@ -46,3 +46,3 @@ });

).then(function(results) {
for (var i = 0; i < results.length; i++) {
for (let i = 0; i < results.length; i++) {
if (results[i] !== null) {

@@ -68,3 +68,3 @@ return results[i];

fs.readFile(fileInfo.path, {
encoding: 'utf8'
encoding: "utf8"
}, function(fileErr, content) {

@@ -71,0 +71,0 @@ if (fileErr) {

@@ -15,19 +15,19 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";
var path = require('path');
var assign = require('object-assign');
var clone = require('clone');
var css = require('css');
let path = require("path");
let assign = require("object-assign");
let clone = require("clone");
let css = require("css");
var createParser = require('./less/parser');
var diff = require('./diff');
var scope = require('./scope');
let createParser = require("./less/parser");
let diff = require("./diff");
let scope = require("./scope");
var fileUtilsFactory = require('./fileUtils');
let fileUtilsFactory = require("./fileUtils");
// Plugins
var RTLPlugin = require('./plugin/rtl');
var ImportCollectorPlugin = require('./plugin/import-collector');
var VariableCollectorPlugin = require('./plugin/variable-collector');
let RTLPlugin = require("./plugin/rtl");
let ImportCollectorPlugin = require("./plugin/import-collector");
let VariableCollectorPlugin = require("./plugin/variable-collector");

@@ -42,7 +42,7 @@ // Workaround for a performance issue in the "css" parser module when used in combination

function cleanupStringPrototype() {
var customGetters = {}, customProps = {}, s = "", key;
let customGetters = {}; let customProps = {}; let s = ""; let key;
for (key in s) {
if (!s.hasOwnProperty(key)) {
var getter = String.prototype.__lookupGetter__(key);
let getter = String.prototype.__lookupGetter__(key);
if (typeof getter === "function") {

@@ -69,6 +69,7 @@ customGetters[key] = getter;

if (customProps.hasOwnProperty(key)) {
// eslint-disable-next-line no-extend-native
String.prototype[key] = customProps[key];
}
}
}
};
}

@@ -84,3 +85,3 @@

var Builder = function(options) {
let Builder = function(options) {
this.themeCacheMapping = {};

@@ -101,7 +102,7 @@ this.customFs = options ? options.fs : null;

this.themeCacheMapping = {};
}
};
Builder.prototype.cacheTheme = function(result) {
var that = this;
var rootpath;
let that = this;
let rootpath;

@@ -124,11 +125,10 @@ // Theme can only be cached if list of imports is available

});
};
Builder.prototype.build = function(options) {
var that = this;
let that = this;
// Stores mapping between "virtual" paths (used within LESS) and real filesystem paths.
// Only relevant when using the "rootPaths" option.
var mFileMappings = {};
let mFileMappings = {};

@@ -153,11 +153,10 @@ // Assign default options

function fileHandler(file, currentFileInfo, handleDataAndCallCallback, callback) {
let pathname = path.posix.join(currentFileInfo.currentDirectory, file);
var pathname = path.posix.join(currentFileInfo.currentDirectory, file);
that.fileUtils.readFile(pathname, options.rootPaths).then(function(result) {
if (!result) {
// eslint-disable-next-line no-console
console.log("File not found");
callback({ type: 'File', message: "'" + file + "' wasn't found" })
callback({type: "File", message: "'" + file + "' wasn't found"});
} else {
try {

@@ -170,8 +169,9 @@ // Save import mapping to calculate full import paths later on

} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
callback(e);
}
}
}, function(err) {
// eslint-disable-next-line no-console
console.log(err);

@@ -183,4 +183,4 @@ callback(err);

function compile(config) {
var parserOptions = clone(options.parser);
var rootpath;
let parserOptions = clone(options.parser);
let rootpath;

@@ -194,6 +194,6 @@ if (config.path) {

// Keep filename for later usage (see ImportCollectorPlugin) as less modifies the parserOptions.filename
var filename = parserOptions.filename;
let filename = parserOptions.filename;
// Only use custom file handler when "rootPaths" or custom "fs" are used
var fnFileHandler;
let fnFileHandler;
if ((options.rootPaths && options.rootPaths.length > 0) || that.customFs) {

@@ -204,5 +204,4 @@ fnFileHandler = fileHandler;

return new Promise(function(resolve, reject) {
var parser = createParser(parserOptions, fnFileHandler);
let parser = createParser(parserOptions, fnFileHandler);
parser.parse(config.content, function(err, tree) {
if (err) {

@@ -215,16 +214,15 @@ reject(err);

}).then(function(tree) {
let result = {};
var result = {};
result.tree = tree;
// plugins to collect imported files and variable values
var oImportCollector = new ImportCollectorPlugin({
let oImportCollector = new ImportCollectorPlugin({
importMappings: mFileMappings[filename]
});
var oVariableCollector = new VariableCollectorPlugin(options.compiler);
let oVariableCollector = new VariableCollectorPlugin(options.compiler);
// render to css
result.css = tree.toCSS(assign(options.compiler, {
plugins: [ oImportCollector, oVariableCollector ]
plugins: [oImportCollector, oVariableCollector]
}));

@@ -244,3 +242,3 @@

result.cssRtl = tree.toCSS(assign(options.compiler, {
plugins: [ new RTLPlugin() ]
plugins: [new RTLPlugin()]
}));

@@ -254,3 +252,2 @@ }

return result;
});

@@ -262,16 +259,14 @@ }

if (typeof options.library === "object" && typeof options.library.name === "string") {
var parameters = JSON.stringify(result.variables);
let parameters = JSON.stringify(result.variables);
// escape all chars that could cause problems with css parsers using URI-Encoding (% + HEX-Code)
var escapedChars = "%{}()'\"\\";
for (var i = 0; i < escapedChars.length; i++) {
var char = escapedChars.charAt(i);
var hex = char.charCodeAt(0).toString(16).toUpperCase();
parameters = parameters.replace(new RegExp("\\" + char, "g"), "%" + hex);
}
// properly escape the parameters to be part of a data-uri
// + escaping single quote (') as it is used to surround the data-uri: url('...')
const escapedParameters = encodeURIComponent(parameters).replace(/'/g, function(char) {
return escape(char);
});
var parameterStyleRule =
"\n/* Inline theming parameters */\n#sap-ui-theme-" +
// embed parameter variables as plain-text string into css
const parameterStyleRule = "\n/* Inline theming parameters */\n#sap-ui-theme-" +
options.library.name.replace(/\./g, "\\.") +
" { background-image: url('data:text/plain;utf-8," + parameters + "'); }\n";
"{background-image:url('data:text/plain;utf-8," + escapedParameters + "')}\n";

@@ -289,8 +284,8 @@ // embed parameter variables as plain-text string into css

function getScopeVariables(options) {
var sScopeName = options.scopeName;
var oVariablesBase = options.baseVariables;
var oVariablesEmbedded = options.embeddedVariables;
var oVariablesDiff = {};
let sScopeName = options.scopeName;
let oVariablesBase = options.baseVariables;
let oVariablesEmbedded = options.embeddedVariables;
let oVariablesDiff = {};
for (var sKey in oVariablesEmbedded) {
for (let sKey in oVariablesEmbedded) {
if (sKey in oVariablesBase) {

@@ -304,3 +299,3 @@ if (oVariablesBase[sKey] != oVariablesEmbedded[sKey]) {

// Merge variables
var oVariables = {};
let oVariables = {};
oVariables["default"] = oVariablesBase;

@@ -324,21 +319,20 @@ oVariables["scopes"] = {};

}).then(function(results) {
var sScopeName = scopeOptions.selector;
let sScopeName = scopeOptions.selector;
function applyScope(embeddedCompareCss, embeddedCss, bRtl) {
let restoreStringPrototype = cleanupStringPrototype();
var restoreStringPrototype = cleanupStringPrototype();
// Create diff object between embeddedCompare and embedded
var oBase = css.parse(embeddedCompareCss);
var oEmbedded = css.parse(embeddedCss);
let oBase = css.parse(embeddedCompareCss);
let oEmbedded = css.parse(embeddedCss);
restoreStringPrototype();
var oDiff = diff(oBase, oEmbedded);
let oDiff = diff(oBase, oEmbedded);
// Create scope
var sScopeSelector = '.' + sScopeName;
var oScope = scope(oDiff.diff, sScopeSelector);
let sScopeSelector = "." + sScopeName;
let oScope = scope(oDiff.diff, sScopeSelector);
var oCssScopeRoot;
let oCssScopeRoot;

@@ -355,3 +349,3 @@ if (oDiff.stack) {

// The stack gets appended to the embeddedFile only
var sAppend = css.stringify(oScope, {
let sAppend = css.stringify(oScope, {
compress: options.compiler && options.compiler.compress === true

@@ -367,3 +361,2 @@ });

return sAppend + "\n";
}

@@ -388,11 +381,11 @@

var concatImports = function(aImportsBase, aImportsEmbedded) {
var aConcats = aImportsBase.concat(aImportsEmbedded);
let concatImports = function(aImportsBase, aImportsEmbedded) {
let aConcats = aImportsBase.concat(aImportsEmbedded);
return aConcats.filter(function(sImport, sIndex) {
return aConcats.indexOf(sImport) == sIndex;
})
});
};
if (scopeOptions.baseFilePath !== options.lessInputPath) {
if (scopeOptions.baseFilePath !== options.lessInputPath) {
results.embeddedCompare.imports = concatImports(results.embedded.imports, results.embeddedCompare.imports);

@@ -405,3 +398,2 @@ } else {

return results.embeddedCompare;
});

@@ -413,6 +405,5 @@ }

return that.fileUtils.readFile(dotThemingInputPath, options.rootPaths).then(function(result) {
let dotTheming;
let dotThemingFilePath;
var dotTheming;
var dotThemingFilePath;
if (result) {

@@ -424,25 +415,23 @@ dotTheming = JSON.parse(result.content);

if (dotTheming && dotTheming.mCssScopes) {
// Currently only the "library" target is supported
var cssScope = dotTheming.mCssScopes["library"];
let cssScope = dotTheming.mCssScopes["library"];
if (cssScope) {
let aScopes = cssScope.aScopes;
let oScopeConfig = aScopes[0]; // Currenlty only one scope is supported
var aScopes = cssScope.aScopes;
var oScopeConfig = aScopes[0]; // Currenlty only one scope is supported
let sBaseFile = dotThemingFileToPath(cssScope.sBaseFile);
let sEmbeddedCompareFile = dotThemingFileToPath(oScopeConfig.sEmbeddedCompareFile);
let sEmbeddedFile = dotThemingFileToPath(oScopeConfig.sEmbeddedFile);
var sBaseFile = dotThemingFileToPath(cssScope.sBaseFile || cssScopeTarget);
var sEmbeddedCompareFile = dotThemingFileToPath(oScopeConfig.sEmbeddedCompareFile);
var sEmbeddedFile = dotThemingFileToPath(oScopeConfig.sEmbeddedFile);
// Currently, only support the use case when "sBaseFile" equals "sEmbeddedCompareFile"
if (sBaseFile !== sEmbeddedCompareFile) {
throw new Error("Unsupported content in \"" + dotThemingInputPath + "\": " +
"\"sBaseFile\" (\"" + (cssScope.sBaseFile || cssScopeTarget) + "\") must be identical with " +
"\"sBaseFile\" (\"" + cssScope.sBaseFile + "\") must be identical with " +
"\"sEmbeddedCompareFile\" (\"" + oScopeConfig.sEmbeddedCompareFile + "\")");
}
var baseFilePath = path.posix.join(themeDir, sBaseFile) + '.source.less';
var embeddedCompareFilePath = path.posix.join(themeDir, sEmbeddedCompareFile) + '.source.less';
var embeddedFilePath = path.posix.join(themeDir, sEmbeddedFile) + '.source.less';
let baseFilePath = path.posix.join(themeDir, sBaseFile) + ".source.less";
let embeddedCompareFilePath = path.posix.join(themeDir, sEmbeddedCompareFile) + ".source.less";
let embeddedFilePath = path.posix.join(themeDir, sEmbeddedFile) + ".source.less";

@@ -476,16 +465,16 @@ // 1. Compile base + embedded files (both default + RTL variants)

if (options.lessInput) {
return compile({
content: options.lessInput
}).then(addInlineParameters).then(that.cacheTheme.bind(that));
} else {
// TODO: refactor
// eslint-disable-next-line no-var
var themeDir = path.posix.dirname(options.lessInputPath);
// Always use the sap/ui/core library to lookup .theming files
var coreThemeDir;
let coreThemeDir;
if (options.library && typeof options.library.name === "string") {
var libraryNamespace = options.library.name.replace(/\./g, "/");
coreThemeDir = themeDir.replace(libraryNamespace, "sap/ui/core");
let libraryNamespace = options.library.name.replace(/\./g, "/");
coreThemeDir = themeDir.replace(libraryNamespace, "sap/ui/core");
} else {

@@ -495,6 +484,5 @@ coreThemeDir = themeDir.replace(/^.*\/themes\//, "/sap/ui/core/themes/");

var dotThemingInputPath = path.posix.join(coreThemeDir, '.theming');
let dotThemingInputPath = path.posix.join(coreThemeDir, ".theming");
return that.fileUtils.findFile(options.lessInputPath, options.rootPaths).then(function(fileInfo) {
if (!fileInfo) {

@@ -505,3 +493,3 @@ throw new Error("`lessInputPath` " + options.lessInputPath + " could not be found.");

// check theme has been already cached
var themeCache;
let themeCache;
if (fileInfo.path) {

@@ -511,3 +499,3 @@ themeCache = that.getThemeCache(fileInfo.path);

var scopeOptions = options.scope;
let scopeOptions = options.scope;

@@ -522,3 +510,3 @@ // Compile theme if not cached or RTL is requested and missing in cache

return that.fileUtils.statFiles(themeCache.result.imports).then(function(newStats) {
for (var i = 0; i < newStats.length; i++) {
for (let i = 0; i < newStats.length; i++) {
// check if .theming and less files have changed since last less compilation

@@ -525,0 +513,0 @@ if (!newStats[i] || newStats[i].stat.mtime.getTime() !== themeCache.stats[i].stat.mtime.getTime()) {

@@ -1,2 +0,2 @@

/*!
/* !
* LESS - Leaner CSS v1.6.3

@@ -15,22 +15,23 @@ * http://lesscss.org

'use strict';
"use strict";
module.exports = function createFileLoader(fileHandler) {
return function fileLoader(file, currentFileInfo, callback, env) {
/* BEGIN MODIFICATION */
// Removed unused variables "dirname, data"
var pathname,
newFileInfo = {
relativeUrls: env.relativeUrls,
entryPath: currentFileInfo.entryPath,
rootpath: currentFileInfo.rootpath,
rootFilename: currentFileInfo.rootFilename
};
let pathname;
let newFileInfo = {
relativeUrls: env.relativeUrls,
entryPath: currentFileInfo.entryPath,
rootpath: currentFileInfo.rootpath,
rootFilename: currentFileInfo.rootFilename
};
/* END MODIFICATION */
function handleDataAndCallCallback(data) {
var j = file.lastIndexOf('/');
let j = file.lastIndexOf("/");

@@ -46,5 +47,6 @@ // Pass on an updated rootpath if path of imported file is relative and file

if (newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
var relativeSubDirectory = file.slice(0, j+1);
let relativeSubDirectory = file.slice(0, j+1);
newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file
}
// eslint-disable-next-line no-useless-escape
newFileInfo.currentDirectory = pathname.replace(/[^\\\/]*$/, "");

@@ -67,4 +69,3 @@ newFileInfo.filename = pathname;

/* END MODIFICATION */
};
};

@@ -1,2 +0,2 @@

/*!
/* !
* LESS - Leaner CSS v1.6.3

@@ -15,14 +15,14 @@ * http://lesscss.org

/* eslint-disable consistent-this, new-cap */
'use strict';
/* eslint-disable consistent-this, new-cap, no-invalid-this */
"use strict";
var less = require('less');
var tree = less.tree;
let less = require("less");
let tree = less.tree;
module.exports = function createImportsPushFunction(env, fileLoader, parserFactory) {
return function importsPush(path, currentFileInfo, importOptions, callback) {
var parserImports = this;
let parserImports = this;
this.queue.push(path);
var fileParsedFunc = function (e, root, fullPath) {
let fileParsedFunc = function(e, root, fullPath) {
parserImports.queue.splice(parserImports.queue.indexOf(path), 1); // Remove the path from the queue

@@ -33,9 +33,11 @@

// Replaced "rootFilename" with "env.filename"
var importedPreviously = fullPath in parserImports.files || fullPath === env.filename;
let importedPreviously = fullPath in parserImports.files || fullPath === env.filename;
/* END MODIFICATION */
parserImports.files[fullPath] = root; // Store the root
parserImports.files[fullPath] = root; // Store the root
if (e && !parserImports.error) { parserImports.error = e; }
if (e && !parserImports.error) {
parserImports.error = e;
}

@@ -48,3 +50,2 @@ callback(e, root, importedPreviously, fullPath);

} else {
/* BEGIN MODIFICATION */

@@ -54,8 +55,9 @@

fileLoader(path, currentFileInfo, function(e, contents, fullPath, newFileInfo) {
/* END MODIFICATION */
if (e) {fileParsedFunc(e); return;}
if (e) {
fileParsedFunc(e); return;
}
var newEnv = new tree.parseEnv(env);
let newEnv = new tree.parseEnv(env);

@@ -73,8 +75,6 @@ newEnv.currentFileInfo = newFileInfo;

} else {
/* BEGIN MODIFICATION */
// Create custom parser when resolving imports
parserFactory(newEnv, fileLoader).parse(contents, function (e, root) {
parserFactory(newEnv, fileLoader).parse(contents, function(e, root) {
/* END MODIFICATION */

@@ -81,0 +81,0 @@

@@ -16,7 +16,7 @@ // Copyright 2018 SAP SE.

/* eslint-disable new-cap */
'use strict';
"use strict";
var less = require('less');
var createFileLoader = require('./fileLoader');
var createImportsPushFunction = require('./importsPush');
let less = require("less");
let createFileLoader = require("./fileLoader");
let createImportsPushFunction = require("./importsPush");

@@ -29,3 +29,3 @@ function parserFactory(env, fileLoader) {

var parser = new less.Parser(env);
let parser = new less.Parser(env);

@@ -46,5 +46,4 @@ if (fileLoader) {

module.exports = function createParser(env, fileHandler) {
// Create fileLoader function if a fileHandler is provided
var fileLoader;
let fileLoader;
if (fileHandler) {

@@ -51,0 +50,0 @@ fileLoader = createFileLoader(fileHandler);

@@ -15,10 +15,10 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";
var less = require('less');
let less = require("less");
var ImportCollector = module.exports = function(options) {
/*eslint-disable new-cap */
let ImportCollector = module.exports = function(options) {
/* eslint-disable new-cap */
this.oVisitor = new less.tree.visitor(this);
/*eslint-enable new-cap */
/* eslint-enable new-cap */

@@ -32,3 +32,3 @@ this.aImports = [];

isPreEvalVisitor: true,
run: function (root) {
run: function(root) {
this.oVisitor.visit(root);

@@ -38,3 +38,3 @@ },

if (importNode.importedFilename) {
var fullImportPath = this.mImportMappings[importNode.importedFilename];
let fullImportPath = this.mImportMappings[importNode.importedFilename];
if (fullImportPath) {

@@ -41,0 +41,0 @@ this.aImports.push(fullImportPath);

@@ -15,17 +15,17 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";
var less = require('less');
let less = require("less");
var cssSizePattern = /(-?[\.0-9]+)([a-z]*)/;
var percentagePattern = /^\s*(-?[\.0-9]+)%\s*$/;
let cssSizePattern = /(-?[.0-9]+)([a-z]*)/;
let percentagePattern = /^\s*(-?[.0-9]+)%\s*$/;
var urlPattern = /('?"?([^\)]*\/)?)img\/([^\)]*)/;
var urlReplacement = '$1img-RTL/$3';
let urlPattern = /('?"?([^)]*\/)?)img\/([^)]*)/;
let urlReplacement = "$1img-RTL/$3";
var swapLeftRightPattern = /(\bright\b|\bleft\b)/g;
let swapLeftRightPattern = /(\bright\b|\bleft\b)/g;
var converterFunctions = {
let converterFunctions = {
modifyAttributeName: function(ruleNode, replacement) {
modifyOnce(ruleNode, 'modifyAttributeName', function(node) {
modifyOnce(ruleNode, "modifyAttributeName", function(node) {
node.name = replacement;

@@ -36,5 +36,5 @@ });

ruleNode.value.value.forEach(function(valueObject) {
var newParts;
if (valueObject.type === 'Anonymous') {
var parts = splitBySpace(valueObject.value);
let newParts;
if (valueObject.type === "Anonymous") {
let parts = splitBySpace(valueObject.value);
if (parts.length === 4) {

@@ -44,9 +44,9 @@ newParts = parts.slice(0);

newParts[3] = parts[1];
valueObject.value = newParts.join(' ');
valueObject.value = newParts.join(" ");
}
} else if (valueObject.type === 'Expression') {
var nodeCount = 0;
var rightValueIndex = null, leftValueIndex = null;
for (var i = 0; i < valueObject.value.length; i++) {
if (valueObject.value[i].type === 'Comment') {
} else if (valueObject.type === "Expression") {
let nodeCount = 0;
let rightValueIndex = null; let leftValueIndex = null;
for (let i = 0; i < valueObject.value.length; i++) {
if (valueObject.value[i].type === "Comment") {
continue;

@@ -71,3 +71,2 @@ }

}
}

@@ -78,11 +77,11 @@ });

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Anonymous') {
var parts = splitBySpace(valueObject.value);
valueObject.value = mirrorBorderRadius(parts).join(' ');
} else if (valueObject.type === 'Expression') {
var newParts = [];
var currentParts = [];
for (var i = 0; i < valueObject.value.length; i++) {
var part = valueObject.value[i];
if (part.type === 'Anonymous' && part.value === '/') {
if (valueObject.type === "Anonymous") {
let parts = splitBySpace(valueObject.value);
valueObject.value = mirrorBorderRadius(parts).join(" ");
} else if (valueObject.type === "Expression") {
let newParts = [];
let currentParts = [];
for (let i = 0; i < valueObject.value.length; i++) {
let part = valueObject.value[i];
if (part.type === "Anonymous" && part.value === "/") {
newParts = newParts.concat(mirrorBorderRadius(currentParts), part);

@@ -103,11 +102,10 @@ currentParts = [];

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression') {
for (var i = 0; i < valueObject.value.length; i++) {
var part = valueObject.value[i];
if (valueObject.type === "Expression") {
for (let i = 0; i < valueObject.value.length; i++) {
let part = valueObject.value[i];
// first Dimension is the horizontal position value
if (part.type === 'Dimension') {
if (part.type === "Dimension") {
// mirror percentage dimensions
if (part.unit.is('%')) {
if (part.unit.is("%")) {
mirrorPercentageDimensionNode(part);

@@ -120,6 +118,6 @@ }

// check if first Keyword value (horizontal background posistion) is no percentage value
if (part.type === 'Keyword' &&
(part.value === 'left' ||
part.value === 'right' ||
part.value === 'center')) {
if (part.type === "Keyword" &&
(part.value === "left" ||
part.value === "right" ||
part.value === "center")) {
break;

@@ -129,6 +127,5 @@ }

// also break if there is a / which splits up posistion and size definitions
if (part.type === 'Anonymous' && part.value === '/') {
if (part.type === "Anonymous" && part.value === "/") {
break;
}
}

@@ -140,27 +137,27 @@ }

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression' && valueObject.value.length >= 1) {
var potentialPercentageObject = valueObject.value.filter(function(node) {
if (valueObject.type === "Expression" && valueObject.value.length >= 1) {
let potentialPercentageObject = valueObject.value.filter(function(node) {
// get first node except comments
return node.type !== 'Comment';
return node.type !== "Comment";
})[0];
if (potentialPercentageObject &&
potentialPercentageObject.type === 'Dimension' &&
potentialPercentageObject.unit.is('%')) {
potentialPercentageObject.type === "Dimension" &&
potentialPercentageObject.unit.is("%")) {
mirrorPercentageDimensionNode(potentialPercentageObject);
}
} else if (valueObject.type === 'Anonymous') {
} else if (valueObject.type === "Anonymous") {
valueObject.value = splitByComma(valueObject.value).map(function(value) {
var valueParts = splitBySpace(value);
var match = valueParts[0].match(percentagePattern);
let valueParts = splitBySpace(value);
let match = valueParts[0].match(percentagePattern);
if (match) {
var parsedValue = (match[0].indexOf('.') > -1)
let parsedValue = (match[0].indexOf(".") > -1)
? parseFloat(match[0])
: parseInt(match[0], 10);
valueParts[0] = (100 - parsedValue) + '%';
return valueParts.join(' ');
valueParts[0] = (100 - parsedValue) + "%";
return valueParts.join(" ");
} else {
return value;
}
}).join(',');
} else if (valueObject.type === 'Dimension' && valueObject.unit.is('%')) {
}).join(",");
} else if (valueObject.type === "Dimension" && valueObject.unit.is("%")) {
mirrorPercentageDimensionNode(valueObject);

@@ -172,14 +169,14 @@ }

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression' && valueObject.value.length >= 1) {
var potentialPercentageObject = valueObject.value[0];
if (potentialPercentageObject.type === 'Dimension' &&
potentialPercentageObject.unit.is('%')) {
if (valueObject.type === "Expression" && valueObject.value.length >= 1) {
let potentialPercentageObject = valueObject.value[0];
if (potentialPercentageObject.type === "Dimension" &&
potentialPercentageObject.unit.is("%")) {
mirrorPercentageDimensionNode(potentialPercentageObject);
}
} else if (valueObject.type === 'Anonymous') {
var valueParts = splitBySpace(valueObject.value);
var match = valueParts[0].match(percentagePattern);
} else if (valueObject.type === "Anonymous") {
let valueParts = splitBySpace(valueObject.value);
let match = valueParts[0].match(percentagePattern);
if (match) {
valueParts[0] = (100 - parseInt(match[0], 10)) + '%';
valueObject.value = valueParts.join(' ');
valueParts[0] = (100 - parseInt(match[0], 10)) + "%";
valueObject.value = valueParts.join(" ");
}

@@ -191,3 +188,3 @@ }

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression') {
if (valueObject.type === "Expression") {
valueObject.value.forEach(processTransformNode);

@@ -201,3 +198,3 @@ } else {

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression') {
if (valueObject.type === "Expression") {
valueObject.value.forEach(processCursorNode);

@@ -211,6 +208,5 @@ } else {

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression') {
for (var i = 0; i < valueObject.value.length; i++) {
if (valueObject.value[i].type === 'Dimension') {
if (valueObject.type === "Expression") {
for (let i = 0; i < valueObject.value.length; i++) {
if (valueObject.value[i].type === "Dimension") {
negate(valueObject.value[i]);

@@ -220,8 +216,7 @@ break;

}
} else if (valueObject.type === 'Anonymous') {
modifyOnce(valueObject, 'shadow', function(node) {
} else if (valueObject.type === "Anonymous") {
modifyOnce(valueObject, "shadow", function(node) {
node.value = splitByComma(node.value).map(function(part) {
return mirrorShadow(part);
}).join(',');
}).join(",");
});

@@ -236,5 +231,5 @@ }

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Url') {
if (valueObject.type === "Url") {
replaceUrl(valueObject);
} else if (valueObject.type === 'Expression') {
} else if (valueObject.type === "Expression") {
valueObject.value.forEach(replaceUrl);

@@ -246,3 +241,3 @@ }

ruleNode.value.value.forEach(function(valueObject) {
if (valueObject.type === 'Expression') {
if (valueObject.type === "Expression") {
valueObject.value.forEach(processGradientCallNode);

@@ -256,121 +251,121 @@ } else {

var converterMapping = {
let converterMapping = {
modifyAttributeName: {
'left': 'right',
'right': 'left',
'border-left': 'border-right',
'border-right': 'border-left',
'border-left-color': 'border-right-color',
'border-right-color': 'border-left-color',
'border-left-style': 'border-right-style',
'border-right-style': 'border-left-style',
'border-left-width': 'border-right-width',
'border-right-width': 'border-left-width',
'margin-left': 'margin-right',
'margin-right': 'margin-left',
'padding-left': 'padding-right',
'padding-right': 'padding-left',
'border-bottom-left-radius': 'border-bottom-right-radius',
'border-bottom-right-radius': 'border-bottom-left-radius',
'border-top-left-radius': 'border-top-right-radius',
'border-top-right-radius': 'border-top-left-radius',
'nav-left': 'nav-right',
'nav-right': 'nav-left',
'-moz-border-radius-topright': '-moz-border-radius-topleft',
'-moz-border-radius-topleft': '-moz-border-radius-topright',
'-webkit-border-top-right-radius': '-webkit-border-top-left-radius',
'-webkit-border-top-left-radius': '-webkit-border-top-right-radius',
'-moz-border-radius-bottomright': '-moz-border-radius-bottomleft',
'-moz-border-radius-bottomleft': '-moz-border-radius-bottomright',
'-webkit-border-bottom-right-radius': '-webkit-border-bottom-left-radius',
'-webkit-border-bottom-left-radius': '-webkit-border-bottom-right-radius'
"left": "right",
"right": "left",
"border-left": "border-right",
"border-right": "border-left",
"border-left-color": "border-right-color",
"border-right-color": "border-left-color",
"border-left-style": "border-right-style",
"border-right-style": "border-left-style",
"border-left-width": "border-right-width",
"border-right-width": "border-left-width",
"margin-left": "margin-right",
"margin-right": "margin-left",
"padding-left": "padding-right",
"padding-right": "padding-left",
"border-bottom-left-radius": "border-bottom-right-radius",
"border-bottom-right-radius": "border-bottom-left-radius",
"border-top-left-radius": "border-top-right-radius",
"border-top-right-radius": "border-top-left-radius",
"nav-left": "nav-right",
"nav-right": "nav-left",
"-moz-border-radius-topright": "-moz-border-radius-topleft",
"-moz-border-radius-topleft": "-moz-border-radius-topright",
"-webkit-border-top-right-radius": "-webkit-border-top-left-radius",
"-webkit-border-top-left-radius": "-webkit-border-top-right-radius",
"-moz-border-radius-bottomright": "-moz-border-radius-bottomleft",
"-moz-border-radius-bottomleft": "-moz-border-radius-bottomright",
"-webkit-border-bottom-right-radius": "-webkit-border-bottom-left-radius",
"-webkit-border-bottom-left-radius": "-webkit-border-bottom-right-radius"
},
shuffle4Values: {
'border-style': true,
'border-color': true,
'border-width': true,
'margin': true,
'padding': true,
'border-image-outset': true,
'border-image-width': true
"border-style": true,
"border-color": true,
"border-width": true,
"margin": true,
"padding": true,
"border-image-outset": true,
"border-image-width": true
},
borderRadius: {
'border-radius': true,
'-moz-border-radius': true,
'-webkit-border-radius': true
"border-radius": true,
"-moz-border-radius": true,
"-webkit-border-radius": true
},
background: {
'background': true
"background": true
},
multiPosition: {
'background-position': true
"background-position": true
},
singlePosition: {
'object-position': true,
'perspective-origin': true,
'-moz-perspective-origin': true,
'-webkit-perspective-origin': true,
'transform-origin': true,
'-moz-transform-origin': true,
'-ms-transform-origin': true,
'-webkit-transform-origin': true
"object-position": true,
"perspective-origin": true,
"-moz-perspective-origin": true,
"-webkit-perspective-origin": true,
"transform-origin": true,
"-moz-transform-origin": true,
"-ms-transform-origin": true,
"-webkit-transform-origin": true
},
transform: {
'transform': true,
'-ms-transform': true,
'-moz-transform': true,
'-webkit-transform': true
"transform": true,
"-ms-transform": true,
"-moz-transform": true,
"-webkit-transform": true
},
cursor: {
'cursor': true
"cursor": true
},
shadow: {
'box-shadow': true,
'-moz-box-shadow': true,
'-webkit-box-shadow': true,
'text-shadow': true
"box-shadow": true,
"-moz-box-shadow": true,
"-webkit-box-shadow": true,
"text-shadow": true
},
swapLeftRightValue: {
'background': true,
'background-position': true,
'background-image': true,
'-ms-background-position-x': true,
'break-after': true,
'break-before': true,
'clear': true,
'object-position': true,
'float': true,
'page-break-after': true,
'page-break-before': true,
'perspective-origin': true,
'ruby-align': true,
"background": true,
"background-position": true,
"background-image": true,
"-ms-background-position-x": true,
"break-after": true,
"break-before": true,
"clear": true,
"object-position": true,
"float": true,
"page-break-after": true,
"page-break-before": true,
"perspective-origin": true,
"ruby-align": true,
// "text-align" is not mirrored because "start" and "end" are available to support RTL! IE does not support those and shall receive special CSS rules
'transform-origin': true,
'-moz-transform-origin': true,
'-ms-transform-origin': true,
'-webkit-transform-origin': true
"transform-origin": true,
"-moz-transform-origin": true,
"-ms-transform-origin": true,
"-webkit-transform-origin": true
},
url: {
'background': true,
'background-image': true,
'content': true,
'cursor': true,
'icon': true,
'list-style-image': true
"background": true,
"background-image": true,
"content": true,
"cursor": true,
"icon": true,
"list-style-image": true
},
gradient: {
'background': true,
'background-image': true
"background": true,
"background-image": true
}

@@ -380,47 +375,47 @@

var transformMapping = {
let transformMapping = {
negateFirst: {
'translate': true,
'translate3d': true,
'rotate': true,
'rotatey': true,
'rotateY': true,
'rotatez': true,
'rotateZ': true,
'skewX': true,
'skewx': true,
'skewY': true,
'skewy': true
"translate": true,
"translate3d": true,
"rotate": true,
"rotatey": true,
"rotateY": true,
"rotatez": true,
"rotateZ": true,
"skewX": true,
"skewx": true,
"skewY": true,
"skewy": true
},
negateTwo: {
'skew': true
"skew": true
},
negateSecondNumber: {
'rotate3d': true
"rotate3d": true
}
};
var cursorMapping = {
'e-resize': 'w-resize',
'w-resize': 'e-resize',
'ne-resize': 'nw-resize',
'nw-resize': 'ne-resize',
'se-resize': 'sw-resize',
'sw-resize': 'se-resize',
'nesw-resize': 'nwse-resize',
'nwse-resize': 'nesw-resize'
let cursorMapping = {
"e-resize": "w-resize",
"w-resize": "e-resize",
"ne-resize": "nw-resize",
"nw-resize": "ne-resize",
"se-resize": "sw-resize",
"sw-resize": "se-resize",
"nesw-resize": "nwse-resize",
"nwse-resize": "nesw-resize"
};
function swapLeftRight(valueObject) {
if (valueObject.type === 'Anonymous' || valueObject.type === 'Keyword') {
modifyOnce(valueObject, 'swapLeftRight', function(node) {
if (valueObject.type === "Anonymous" || valueObject.type === "Keyword") {
modifyOnce(valueObject, "swapLeftRight", function(node) {
node.value = node.value.replace(swapLeftRightPattern, function(match, p1, offset, string) {
return p1 === 'left' ? 'right' : 'left';
return p1 === "left" ? "right" : "left";
});
});
} else if (valueObject.type === 'Expression') {
} else if (valueObject.type === "Expression") {
valueObject.value.forEach(swapLeftRight);
} else if (valueObject.type === 'Call') {
} else if (valueObject.type === "Call") {
valueObject.args.forEach(swapLeftRight);

@@ -431,12 +426,12 @@ }

function splitByComma(value) {
var lastStart = 0;
var inParentheses = false;
var parts = [];
for (var i = 0; i < value.length; i++) {
var character = value[i];
if (character === '(') {
let lastStart = 0;
let inParentheses = false;
let parts = [];
for (let i = 0; i < value.length; i++) {
let character = value[i];
if (character === "(") {
inParentheses = true;
} else if (character === ')') {
} else if (character === ")") {
inParentheses = false;
} else if (character === ',') {
} else if (character === ",") {
if (!inParentheses) {

@@ -459,6 +454,6 @@ parts.push(value.substring(lastStart, i));

function mirrorBorderRadius(parts) {
var result = parts.slice(0);
var valueIndices = [], commentIndices = [];
var length = parts.filter(function(part, i) {
if (part.type !== 'Comment') {
let result = parts.slice(0);
let valueIndices = []; let commentIndices = [];
let length = parts.filter(function(part, i) {
if (part.type !== "Comment") {
valueIndices.push(i);

@@ -483,3 +478,2 @@ return true;

result.splice(valueIndices[2] + 1, 0, parts[valueIndices[2]]);
} else if (length === 4) {

@@ -497,4 +491,4 @@ // 1 2 3 4 -> 2 1 4 3

function negate(node) {
if (node.type === 'Dimension') {
modifyOnce(node, 'negate', function(negateNode) {
if (node.type === "Dimension") {
modifyOnce(node, "negate", function(negateNode) {
negateNode.value = -negateNode.value;

@@ -506,7 +500,7 @@ });

function processTransformNode(node) {
if (node.type !== 'Call') {
if (node.type !== "Call") {
return;
}
var name = node.name;
let name = node.name;
if (transformMapping.negateFirst[name]) {

@@ -525,10 +519,10 @@ negate(node.args[0]);

function mirrorShadow(value) {
var parts = splitBySpace(value);
var offsetXIndex = (parts[0] === 'inset' && parts.length > 1) ? 1 : 0;
var offsetX = parts[offsetXIndex];
var match = offsetX.match(cssSizePattern);
let parts = splitBySpace(value);
let offsetXIndex = (parts[0] === "inset" && parts.length > 1) ? 1 : 0;
let offsetX = parts[offsetXIndex];
let match = offsetX.match(cssSizePattern);
if (match) {
var offsetXValue = match[1];
var negated;
if (offsetXValue.indexOf('.') > -1) {
let offsetXValue = match[1];
let negated;
if (offsetXValue.indexOf(".") > -1) {
negated = -parseFloat(offsetXValue);

@@ -541,8 +535,8 @@ } else {

return parts.join(' ');
return parts.join(" ");
}
function mirrorPercentageDimensionNode(node) {
if (node.type === 'Dimension' && node.unit.is('%')) {
modifyOnce(node, 'mirrorPercentageDimensionNode', function(mirrorNode) {
if (node.type === "Dimension" && node.unit.is("%")) {
modifyOnce(node, "mirrorPercentageDimensionNode", function(mirrorNode) {
mirrorNode.value = 100 - mirrorNode.value;

@@ -554,10 +548,8 @@ });

function processGradientCallNode(node) {
if (node.type === 'Call' &&
endsWith(node.name, 'linear-gradient') &&
if (node.type === "Call" &&
endsWith(node.name, "linear-gradient") &&
node.args.length >= 1) {
var firstPart = node.args[0];
if (firstPart.type === 'Dimension') {
if (firstPart.unit.is('%')) {
let firstPart = node.args[0];
if (firstPart.type === "Dimension") {
if (firstPart.unit.is("%")) {
mirrorPercentageDimensionNode(firstPart);

@@ -567,7 +559,6 @@ }

mirrorLinearGradientAngle(firstPart);
} else if (firstPart.type === "Expression") {
let firstSubPart = firstPart.value[0];
} else if (firstPart.type === 'Expression') {
var firstSubPart = firstPart.value[0];
if (firstSubPart.type === 'Dimension' && firstSubPart.unit.is('%')) {
if (firstSubPart.type === "Dimension" && firstSubPart.unit.is("%")) {
mirrorPercentageDimensionNode(firstSubPart);

@@ -582,17 +573,17 @@ }

function mirrorLinearGradientAngle(node) {
if (node.type !== 'Dimension') {
if (node.type !== "Dimension") {
return;
}
modifyOnce(node, 'mirrorLinearGradientAngle', function(mirrorNode) {
modifyOnce(node, "mirrorLinearGradientAngle", function(mirrorNode) {
switch (mirrorNode.unit.toString()) {
case 'deg':
case "deg":
mirrorNode.value = 180 - mirrorNode.value;
break;
case 'grad':
case "grad":
mirrorNode.value = 200 - mirrorNode.value;
break;
case 'rad':
case "rad":
mirrorNode.value = Math.round((Math.PI - mirrorNode.value) * 100) / 100;
break;
case 'turn':
case "turn":
mirrorNode.value = Math.round((0.5 - mirrorNode.value) * 100) / 100;

@@ -607,6 +598,6 @@ break;

function processCursorNode(node) {
if (node.type === 'Keyword') {
var replacement = cursorMapping[node.value];
if (node.type === "Keyword") {
let replacement = cursorMapping[node.value];
if (replacement) {
modifyOnce(node, 'cursor', function(cursorNode) {
modifyOnce(node, "cursor", function(cursorNode) {
cursorNode.value = replacement;

@@ -619,4 +610,4 @@ });

function replaceUrl(node) {
if (node.type === 'Url') {
modifyOnce(node, 'replaceUrl', function(urlNode) {
if (node.type === "Url") {
modifyOnce(node, "replaceUrl", function(urlNode) {
urlNode.value.value = urlNode.value.value.replace(urlPattern, urlReplacement);

@@ -641,6 +632,6 @@ });

var LessRtlPlugin = module.exports = function() {
/*eslint-disable new-cap */
let LessRtlPlugin = module.exports = function() {
/* eslint-disable new-cap */
this.oVisitor = new less.tree.visitor(this);
/*eslint-enable new-cap */
/* eslint-enable new-cap */
};

@@ -651,10 +642,12 @@

isPreEvalVisitor: false,
run: function (root) {
run: function(root) {
return this.oVisitor.visit(root);
},
visitRule: function(ruleNode, visitArgs) {
for (var converter in converterMapping) {
var mappingValue = converterMapping[converter][ruleNode.name];
if (mappingValue) {
converterFunctions[converter].call(this, ruleNode, mappingValue);
for (let converter in converterMapping) {
if (converterMapping.hasOwnProperty(converter)) {
let mappingValue = converterMapping[converter][ruleNode.name];
if (mappingValue) {
converterFunctions[converter].call(this, ruleNode, mappingValue);
}
}

@@ -661,0 +654,0 @@ }

@@ -15,75 +15,75 @@ // Copyright 2018 SAP SE.

'use strict';
var path = require('path');
var less = require('less');
"use strict";
let path = require("path");
let less = require("less");
var VariableCollector = module.exports = function(env) {
/*eslint-disable new-cap */
this.oVisitor = new less.tree.visitor(this);
/*eslint-enable new-cap */
this.env = env;
this.mVariables = {};
this.mGlobalVariables = {};
this.mVarFile = {};
let VariableCollector = module.exports = function(env) {
/* eslint-disable new-cap */
this.oVisitor = new less.tree.visitor(this);
/* eslint-enable new-cap */
this.env = env;
this.mVariables = {};
this.mGlobalVariables = {};
this.mVarFile = {};
};
VariableCollector.prototype = {
isPreVisitor: true,
run: function (root) {
this.mGlobalVariables = root.variables();
return this.oVisitor.visit(root);
},
isPreVisitor: true,
run: function(root) {
this.mGlobalVariables = root.variables();
return this.oVisitor.visit(root);
},
visitRule: function(node) {
if (!node.variable) {
return;
}
if (!this.mGlobalVariables[node.name]) {
// Ignoring local variable
return;
}
try {
var value = node.value.toCSS(this.env);
this.mVariables[node.name.substr(1)] = {
value: value,
filename: node.currentFileInfo.filename,
rootFilename: node.currentFileInfo.rootFilename
};
} catch (err) {
// Errors might occur within mixins.
// But as we only collect global variables, this doesn't matter...
}
},
visitRule: function(node) {
if (!node.variable) {
return;
}
if (!this.mGlobalVariables[node.name]) {
// Ignoring local variable
return;
}
try {
let value = node.value.toCSS(this.env);
this.mVariables[node.name.substr(1)] = {
value: value,
filename: node.currentFileInfo.filename,
rootFilename: node.currentFileInfo.rootFilename
};
} catch (err) {
// Errors might occur within mixins.
// But as we only collect global variables, this doesn't matter...
}
},
getVariables: function(aImports) {
var mVariables = {};
getVariables: function(aImports) {
let mVariables = {};
for (var name in this.mVariables) {
if (this.mVariables.hasOwnProperty(name)) {
var oVar = this.mVariables[name];
var dirname = path.posix.dirname(oVar.filename);
var baseFileName = path.posix.basename(oVar.rootFilename); // usually library.source.less
var libraryBaseFile = path.posix.normalize(path.posix.join(dirname, baseFileName));
for (let name in this.mVariables) {
if (this.mVariables.hasOwnProperty(name)) {
let oVar = this.mVariables[name];
let dirname = path.posix.dirname(oVar.filename);
let baseFileName = path.posix.basename(oVar.rootFilename); // usually library.source.less
let libraryBaseFile = path.posix.normalize(path.posix.join(dirname, baseFileName));
// Only add variable if the corresponding library "base file" has been imported
if (aImports.indexOf(libraryBaseFile) > -1 || libraryBaseFile === oVar.rootFilename) {
mVariables[name] = oVar.value;
}
}
}
// Only add variable if the corresponding library "base file" has been imported
if (aImports.indexOf(libraryBaseFile) > -1 || libraryBaseFile === oVar.rootFilename) {
mVariables[name] = oVar.value;
}
}
}
return mVariables;
},
return mVariables;
},
getAllVariables: function(aImports) {
var mVariables = {};
for (var name in this.mVariables) {
if (this.mVariables.hasOwnProperty(name)) {
var oVar = this.mVariables[name];
mVariables[name] = oVar.value;
}
}
return mVariables;
}
getAllVariables: function(aImports) {
let mVariables = {};
for (let name in this.mVariables) {
if (this.mVariables.hasOwnProperty(name)) {
let oVar = this.mVariables[name];
mVariables[name] = oVar.value;
}
}
return mVariables;
}
};

@@ -15,3 +15,3 @@ // Copyright 2018 SAP SE.

'use strict';
"use strict";

@@ -23,8 +23,7 @@ /**

*/
var rRegex = /(html[^\s]*|body[^\s]*)/;
let rRegex = /(html[^\s]*|body[^\s]*)/;
var rPoint = /(^\s?\.{1}\w*)/;
let rPoint = /(^\s?\.{1}\w*)/;
function handleScoping(sSelector, sScopeName) {
/**

@@ -34,9 +33,9 @@ * Match the selector to regex, by splitting into two array elements,

*/
var aCaptureGroups = sSelector.split(rRegex);
let aCaptureGroups = sSelector.split(rRegex);
var aSelectors = [];
var sSelector1, sSelector2;
let aSelectors = [];
let sSelector1; let sSelector2;
// filter empty strings and undefined objects
var aMatch = aCaptureGroups.filter(function(n) {
let aMatch = aCaptureGroups.filter(function(n) {
return !!n;

@@ -53,3 +52,3 @@ });

sSelector2 = aMatch[0] + " " + sScopeName +
aMatch[1].replace(/\s/, '');
aMatch[1].replace(/\s/, "");
} else {

@@ -90,17 +89,14 @@ // no match, selector is a dom element

Scoping.prototype.scopeRules = function(oRules) {
for (let iNode = 0; iNode < oRules.length; iNode++) {
let oNode = oRules[iNode];
for (var iNode = 0; iNode < oRules.length; iNode++) {
var oNode = oRules[iNode];
if (oNode.type === "rule") {
let aNewSelectors = [];
var aNewSelectors = [];
for (let i = 0; i < oNode.selectors.length; i++) {
let sSelector = oNode.selectors[i];
let sSelector2;
for (var i = 0; i < oNode.selectors.length; i++) {
var sSelector = oNode.selectors[i];
var sSelector2;
if (!(sSelector.match(/.sapContrast/))) {
var aScopedSelectors = handleScoping(sSelector, this.sScopeName);
let aScopedSelectors = handleScoping(sSelector, this.sScopeName);
sSelector = (aScopedSelectors[0] ? aScopedSelectors[0] : sSelector);

@@ -114,3 +110,2 @@ sSelector2 = (aScopedSelectors[1] ? aScopedSelectors[1] : null);

}
}

@@ -121,3 +116,2 @@

}
} else if (oNode.type === "media") {

@@ -127,3 +121,2 @@ this.scopeRules(oNode.rules);

}
};

@@ -142,11 +135,9 @@

module.exports.scopeCssRoot = function scopeCssRoot(oRules, sScopeName) {
for (let iNode = 0; iNode < oRules.length; iNode++) {
let oNode = oRules[iNode];
for (var iNode = 0; iNode < oRules.length; iNode++) {
var oNode = oRules[iNode];
if (oNode.type === "rule") {
for (let i = 0; i < oNode.selectors.length; i++) {
let sSelector = oNode.selectors[i];
for (var i = 0; i < oNode.selectors.length; i++) {
var sSelector = oNode.selectors[i];
if (sSelector.match(/#CSS_SCOPE_ROOT\b/)) {

@@ -159,3 +150,2 @@ oNode.selectors[i] = "." + sScopeName;

}
}

@@ -162,0 +152,0 @@ }

{
"name": "less-openui5",
"version": "0.5.4",
"version": "0.6.0",
"description": "Build OpenUI5 themes with Less.js",

@@ -16,2 +16,6 @@ "scripts": {

},
"files": [
"CONTRIBUTING.md",
"lib/**"
],
"keywords": [

@@ -26,3 +30,3 @@ "less",

"engines": {
"node": ">= 0.12.0"
"node": ">= 6"
},

@@ -36,7 +40,7 @@ "dependencies": {

"devDependencies": {
"clean-css": "^3.4.23",
"eslint": "^1.10.3",
"eslint": "^5.5.0",
"eslint-config-google": "^0.10.0",
"graceful-fs": "^4.1.11",
"mocha": "^3.2.0"
"mocha": "^5.2.0"
}
}
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