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

less-openui5

Package Overview
Dependencies
Maintainers
5
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.10.0 to 0.11.0

lib/plugin/url-collector.js

20

CHANGELOG.md

@@ -5,4 +5,21 @@ # Changelog

A list of unreleased changes can be found [here](https://github.com/SAP/less-openui5/compare/v0.10.0...HEAD).
A list of unreleased changes can be found [here](https://github.com/SAP/less-openui5/compare/v0.11.0...HEAD).
<a name="v0.11.0"></a>
## [v0.11.0] - 2021-03-10
### Breaking Changes
- Only rewrite image paths for RTL-variant when files exist ([#162](https://github.com/SAP/less-openui5/issues/162)) [`88e7a74`](https://github.com/SAP/less-openui5/commit/88e7a7436fc7f197186c780a856bb9c6dff7c582)
### BREAKING CHANGE
This affects the output of the `rtl` (right-to-left) variant that is created by applying several mechanisms to create a mirrored variant of the CSS to be used in locales that use a right to left text direction.
One aspect is adopting urls which contain an `img` folder in the path.
Before this change, all urls have been changed to use a `img-RTL` folder instead. This allows mirrored images to be used, but it also requires an images to be available on that path even when the original image should be used (e.g. for a logo).
With this change:
- Urls are only adopted in case an `img-RTL` variant of that file exists
- Urls with a protocol (http/https/data/...) or starting with a slash (`/`) are not adopted anymore
<a name="v0.10.0"></a>

@@ -96,2 +113,3 @@ ## [v0.10.0] - 2021-01-29

[v0.11.0]: https://github.com/SAP/less-openui5/compare/v0.10.0...v0.11.0
[v0.10.0]: https://github.com/SAP/less-openui5/compare/v0.9.0...v0.10.0

@@ -98,0 +116,0 @@ [v0.9.0]: https://github.com/SAP/less-openui5/compare/v0.8.7...v0.9.0

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

const VariableCollectorPlugin = require("./plugin/variable-collector");
const UrlCollector = require("./plugin/url-collector");

@@ -216,3 +217,3 @@ // Workaround for a performance issue in the "css" parser module when used in combination

});
}).then(function(tree) {
}).then(async function(tree) {
const result = {};

@@ -227,6 +228,7 @@

const oVariableCollector = new VariableCollectorPlugin(options.compiler);
const oUrlCollector = new UrlCollector();
// render to css
result.css = tree.toCSS(Object.assign({}, options.compiler, {
plugins: [oImportCollector, oVariableCollector]
plugins: [oImportCollector, oVariableCollector, oUrlCollector]
}));

@@ -248,2 +250,18 @@

oRTL = new RTLPlugin();
const urls = oUrlCollector.getUrls();
const existingImgRtlUrls = (await Promise.all(
urls.map(async ({currentDirectory, relativeUrl}) => {
const relativeImgRtlUrl = RTLPlugin.getRtlImgUrl(relativeUrl);
if (relativeImgRtlUrl) {
const resolvedImgRtlUrl = path.posix.join(currentDirectory, relativeImgRtlUrl);
if (await that.fileUtils.findFile(resolvedImgRtlUrl, options.rootPaths)) {
return resolvedImgRtlUrl;
}
}
})
)).filter(Boolean);
oRTL.setExistingImgRtlPaths(existingImgRtlUrls);
}

@@ -250,0 +268,0 @@

55

lib/plugin/rtl.js
"use strict";
const less = require("../thirdparty/less");
const path = require("path");
const url = require("url");

@@ -205,7 +207,9 @@ const cssSizePattern = /(-?[.0-9]+)([a-z]*)/;

url: function(ruleNode) {
ruleNode.value.value.forEach(function(valueObject) {
ruleNode.value.value.forEach((valueObject) => {
if (valueObject.type === "Url") {
replaceUrl(valueObject);
this.replaceUrl(valueObject);
} else if (valueObject.type === "Expression") {
valueObject.value.forEach(replaceUrl);
valueObject.value.forEach((childValueObject) => {
this.replaceUrl(childValueObject);
});
}

@@ -570,10 +574,2 @@ });

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

@@ -593,2 +589,6 @@ return str.indexOf(suffix, str.length - suffix.length) !== -1;

/**
*
* @constructor
*/
const LessRtlPlugin = module.exports = function() {

@@ -598,2 +598,3 @@ /* eslint-disable new-cap */

/* eslint-enable new-cap */
this.resolvedImgRtlPaths = [];
};

@@ -618,3 +619,35 @@

return ruleNode;
},
replaceUrl: function(node) {
if (node.type !== "Url") {
return;
}
modifyOnce(node, "replaceUrl", (urlNode) => {
const imgPath = urlNode.value.value;
const parsedUrl = url.parse(imgPath);
if (parsedUrl.protocol || imgPath.startsWith("/")) {
// Ignore absolute urls
return;
}
const imgPathRTL = LessRtlPlugin.getRtlImgUrl(imgPath);
if (!imgPathRTL) {
return;
}
const resolvedUrl = path.posix.join(urlNode.currentFileInfo.currentDirectory, imgPathRTL);
if (this.existingImgRtlPaths.includes(resolvedUrl)) {
urlNode.value.value = imgPathRTL;
}
});
},
setExistingImgRtlPaths: function(existingImgRtlPaths) {
this.existingImgRtlPaths = existingImgRtlPaths;
}
};
LessRtlPlugin.getRtlImgUrl = function(url) {
if (urlPattern.test(url)) {
return url.replace(urlPattern, urlReplacement);
} else {
return null;
}
};
{
"name": "less-openui5",
"version": "0.10.0",
"version": "0.11.0",
"description": "Build OpenUI5 themes with Less.js",

@@ -90,9 +90,10 @@ "author": {

"devDependencies": {
"depcheck": "^1.3.1",
"eslint": "^6.8.0",
"depcheck": "^1.4.0",
"eslint": "^7.21.0",
"eslint-config-google": "^0.14.0",
"graceful-fs": "^4.2.4",
"mocha": "^7.2.0",
"nyc": "^15.1.0"
"graceful-fs": "^4.2.6",
"mocha": "^8.3.1",
"nyc": "^15.1.0",
"sinon": "^9.2.4"
}
}
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