@ui5/webcomponents-tools 1.16.0 → 1.17.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/assets-meta.js +9 -6
- package/components-package/nps.js +3 -3
- package/components-package/postcss.components.js +6 -3
- package/components-package/postcss.themes.js +5 -25
- package/lib/create-illustrations/index.js +14 -0
- package/lib/generate-js-imports/illustrations.js +75 -64
- package/lib/postcss-css-to-esm/index.js +1 -1
- package/lib/postcss-css-to-json/index.js +1 -1
- package/lib/postcss-scope-vars/index.js +24 -0
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,28 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.17.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v1.17.0-rc.0...v1.17.0-rc.1) (2023-08-17)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **framework:** scope css variables per runtime and version ([#7449](https://github.com/SAP/ui5-webcomponents/issues/7449)) ([d3f6c2e](https://github.com/SAP/ui5-webcomponents/commit/d3f6c2efba9cfda389ea4d700a375f75b3e2996b))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# [1.17.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0...v1.17.0-rc.0) (2023-08-10)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* **ui5-illustrated-message:** support collection based illustration loading ([#7318](https://github.com/SAP/ui5-webcomponents/issues/7318)) ([6b52dbd](https://github.com/SAP/ui5-webcomponents/commit/6b52dbd157a3c8198e41c84157e3d9ae89e3386e))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
6
28
|
# [1.16.0](https://github.com/SAP/ui5-webcomponents/compare/v1.16.0-rc.4...v1.16.0) (2023-08-03)
|
7
29
|
|
8
30
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
package/assets-meta.js
CHANGED
@@ -9,12 +9,15 @@ const assetsMeta = {
|
|
9
9
|
"sap_belize_hcw",
|
10
10
|
"sap_fiori_3_hcb",
|
11
11
|
"sap_fiori_3_hcw",
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
"sap_horizon",
|
13
|
+
"sap_horizon_dark",
|
14
|
+
"sap_horizon_hcb",
|
15
|
+
"sap_horizon_hcw",
|
16
|
+
"sap_horizon_exp",
|
17
|
+
"sap_horizon_dark_exp",
|
18
|
+
"sap_horizon_hcb_exp",
|
19
|
+
"sap_horizon_hcw_exp",
|
20
|
+
],
|
18
21
|
},
|
19
22
|
"languages": {
|
20
23
|
"default": "en",
|
@@ -8,12 +8,12 @@ const getScripts = (options) => {
|
|
8
8
|
|
9
9
|
// The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
|
10
10
|
const illustrationsData = options.illustrationsData || [];
|
11
|
-
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
|
11
|
+
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`);
|
12
12
|
const createIllustrationsJSImportsScript = illustrations.join(" && ");
|
13
13
|
|
14
14
|
// The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
15
|
-
|
16
|
-
|
15
|
+
const createIllustrationsLoadersScript = illustrationsData.map(illustrations => `node ${LIB}/generate-js-imports/illustrations.js ${illustrations.destinationPath} ${illustrations.dynamicImports.outputFile} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.prefix || '\"\"'} ${illustrations.dynamicImports.filterOut.join(" ")}`).join(" && ");
|
16
|
+
|
17
17
|
const tsOption = options.typescript;
|
18
18
|
const tsCommand = tsOption ? "tsc" : "";
|
19
19
|
const tsWatchCommand = tsOption ? "tsc --watch" : "";
|
@@ -1,9 +1,11 @@
|
|
1
1
|
const postcssImport = require('postcss-import');
|
2
2
|
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
3
|
+
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
3
4
|
const cssnano = require('cssnano');
|
4
|
-
const fs = require("fs")
|
5
|
+
const fs = require("fs")
|
5
6
|
|
6
|
-
|
7
|
+
|
8
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
7
9
|
|
8
10
|
module.exports = {
|
9
11
|
plugins: [
|
@@ -16,6 +18,7 @@ module.exports = {
|
|
16
18
|
},
|
17
19
|
]
|
18
20
|
}),
|
19
|
-
|
21
|
+
postcssScopeVars({version: packageJSON.version}),
|
22
|
+
postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName: packageJSON.name }),
|
20
23
|
]
|
21
24
|
}
|
@@ -2,15 +2,17 @@ const postcssImport = require('postcss-import');
|
|
2
2
|
const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
|
3
3
|
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
4
|
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
|
+
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
5
6
|
const cssnano = require('cssnano');
|
6
|
-
const modifySelectors = require("modify-selectors");
|
7
7
|
const fs = require("fs");
|
8
8
|
|
9
|
-
|
10
|
-
const
|
9
|
+
|
10
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
11
|
+
const packageName = packageJSON.name;
|
11
12
|
|
12
13
|
module.exports = {
|
13
14
|
plugins: [
|
15
|
+
postcssScopeVars({version: packageJSON.version}),
|
14
16
|
postcssImport(),
|
15
17
|
combineSelectors({
|
16
18
|
removeDuplicatedProperties: true
|
@@ -22,28 +24,6 @@ module.exports = {
|
|
22
24
|
},
|
23
25
|
]
|
24
26
|
},),
|
25
|
-
modifySelectors({
|
26
|
-
enable: true,
|
27
|
-
suffix: [
|
28
|
-
{
|
29
|
-
match: '*',
|
30
|
-
with: '[_ui5host]', // Add suffix to each selector in the file (:root => :root [_ui5host])
|
31
|
-
},
|
32
|
-
],
|
33
|
-
}),
|
34
|
-
modifySelectors({
|
35
|
-
enable: true,
|
36
|
-
modify: [
|
37
|
-
{
|
38
|
-
match: (selector) => {
|
39
|
-
return selectors.some($ => selector.startsWith($));
|
40
|
-
},
|
41
|
-
with: (selector) => {
|
42
|
-
return `${selector.replace(" ", "")}, ${selector}`;
|
43
|
-
},
|
44
|
-
},
|
45
|
-
]
|
46
|
-
}),
|
47
27
|
postcssCSStoJSON({ toReplace: 'src', packageName }),
|
48
28
|
postcssCSStoESM({ toReplace: 'src', packageName }),
|
49
29
|
]
|
@@ -57,10 +57,20 @@ const generate = async () => {
|
|
57
57
|
const illustrationsPrefix = process.argv[4];
|
58
58
|
const illustrationSet = process.argv[5];
|
59
59
|
const destPath = process.argv[6];
|
60
|
+
const collection = process.argv[7];
|
60
61
|
const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
|
61
62
|
// collect each illustration name because each one should have Sample.js file
|
62
63
|
const fileNames = new Set();
|
63
64
|
|
65
|
+
try {
|
66
|
+
await fs.access(srcPath);
|
67
|
+
} catch (error) {
|
68
|
+
console.log(`The path ${srcPath} does not exist.`);
|
69
|
+
return Promise.resolve(null);
|
70
|
+
}
|
71
|
+
|
72
|
+
console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
|
73
|
+
|
64
74
|
const svgImportTemplate = svgContent => {
|
65
75
|
return `export default \`${svgContent}\`;`
|
66
76
|
};
|
@@ -95,6 +105,7 @@ import {
|
|
95
105
|
|
96
106
|
const name = "${illustrationName}";
|
97
107
|
const set = "${illustrationSet}";
|
108
|
+
const collection = "${collection}";
|
98
109
|
const title = IM_TITLE_${illustrationNameUpperCase};
|
99
110
|
const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};
|
100
111
|
|
@@ -105,6 +116,7 @@ registerIllustration(name, {
|
|
105
116
|
title,
|
106
117
|
subtitle,
|
107
118
|
set,
|
119
|
+
collection,
|
108
120
|
});
|
109
121
|
|
110
122
|
export {
|
@@ -119,12 +131,14 @@ import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
|
119
131
|
|
120
132
|
const name = "${illustrationName}";
|
121
133
|
const set = "${illustrationSet}";
|
134
|
+
const collection = "${collection}";
|
122
135
|
|
123
136
|
registerIllustration(name, {
|
124
137
|
dialogSvg,
|
125
138
|
sceneSvg,
|
126
139
|
spotSvg,
|
127
140
|
set,
|
141
|
+
collection,
|
128
142
|
});
|
129
143
|
|
130
144
|
export {
|
@@ -1,72 +1,83 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
|
-
const path = require(
|
3
|
-
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
default: throw new Error("[Illustrations] Illustration not found: " + illustrationName);
|
50
|
-
}
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const generateDynamicImportLines = (fileNames, location, exclusionPatterns = []) => {
|
5
|
+
return fileNames
|
6
|
+
.filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
|
7
|
+
.map((fileName) => {
|
8
|
+
const illustrationPath = `${location}/${fileName.replace(".js", "")}`;
|
9
|
+
return `\t\tcase "${fileName.replace('.js', '')}": return (await import("${illustrationPath}.js")).default;`;
|
10
|
+
})
|
11
|
+
.join("\n");
|
12
|
+
};
|
13
|
+
|
14
|
+
const generateAvailableIllustrationsArray = (fileNames, exclusionPatterns = []) => {
|
15
|
+
return JSON.stringify(
|
16
|
+
fileNames
|
17
|
+
.filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
|
18
|
+
.map((fileName) => fileName.replace(".js", ""))
|
19
|
+
);
|
20
|
+
};
|
21
|
+
|
22
|
+
const generateDynamicImportsFileContent = (dynamicImports, availableIllustrations, collection, prefix = "") => {
|
23
|
+
return `import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
24
|
+
|
25
|
+
export const loadIllustration = async (illustrationName) => {
|
26
|
+
const collectionAndPrefix = "${collection}/${prefix}";
|
27
|
+
const cleanIllustrationName = illustrationName.startsWith(collectionAndPrefix) ? illustrationName.replace(collectionAndPrefix, "") : illustrationName;
|
28
|
+
switch (cleanIllustrationName) {
|
29
|
+
${dynamicImports}
|
30
|
+
default:
|
31
|
+
throw new Error("[Illustrations] Illustration not found: " + illustrationName);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
const loadAndCheck = async (illustrationName) => {
|
36
|
+
const data = await loadIllustration(illustrationName);
|
37
|
+
return data;
|
38
|
+
};
|
39
|
+
|
40
|
+
${availableIllustrations}.forEach((illustrationName) =>
|
41
|
+
registerIllustrationLoader(\`${collection}/${prefix}\${illustrationName}\`, loadAndCheck)
|
42
|
+
);
|
43
|
+
`;
|
44
|
+
};
|
45
|
+
|
46
|
+
const getMatchingFiles = async (folder, pattern) => {
|
47
|
+
const dir = await fs.readdir(folder);
|
48
|
+
return dir.filter((fileName) => fileName.match(pattern));
|
51
49
|
};
|
52
|
-
const loadAndCheck = async (illustrationName) => {
|
53
|
-
const data = await loadIllustration(illustrationName);
|
54
|
-
return data;
|
55
|
-
}
|
56
50
|
|
51
|
+
const generateIllustrations = async (config) => {
|
52
|
+
const { inputFolder, outputFile, collection, location, prefix, filterOut } = config;
|
53
|
+
|
54
|
+
const normalizedInputFolder = path.normalize(inputFolder);
|
55
|
+
const normalizedOutputFile = path.normalize(outputFile);
|
56
|
+
|
57
|
+
const illustrations = await getMatchingFiles(normalizedInputFolder, /^.*\.js$/);
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
const dynamicImports = generateDynamicImportLines(illustrations, location, filterOut);
|
60
|
+
const availableIllustrations = generateAvailableIllustrationsArray(illustrations, filterOut);
|
61
|
+
|
62
|
+
const contentDynamic = generateDynamicImportsFileContent(dynamicImports, availableIllustrations, collection, prefix);
|
63
|
+
|
64
|
+
await fs.mkdir(path.dirname(normalizedOutputFile), { recursive: true });
|
65
|
+
await fs.writeFile(normalizedOutputFile, contentDynamic);
|
66
|
+
|
67
|
+
console.log(`Generated ${normalizedOutputFile}`);
|
68
|
+
};
|
61
69
|
|
62
|
-
|
63
|
-
|
70
|
+
// Parse configuration from command-line arguments
|
71
|
+
const config = {
|
72
|
+
inputFolder: process.argv[2],
|
73
|
+
outputFile: process.argv[3],
|
74
|
+
collection: process.argv[4],
|
75
|
+
location: process.argv[5],
|
76
|
+
prefix: process.argv[6],
|
77
|
+
filterOut: process.argv.slice(7),
|
64
78
|
};
|
65
79
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
.catch(err => {
|
70
|
-
console.error(err);
|
71
|
-
process.exit(1);
|
80
|
+
// Run the generation process
|
81
|
+
generateIllustrations(config).catch((error) => {
|
82
|
+
console.error("Error generating illustrations:", error);
|
72
83
|
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
const name = "postcss-scope-vars";
|
2
|
+
|
3
|
+
module.exports = (options) => {
|
4
|
+
const versionStr = "v" + options?.version?.replaceAll(".", "-");
|
5
|
+
return {
|
6
|
+
postcssPlugin: name,
|
7
|
+
prepare() {
|
8
|
+
return {
|
9
|
+
Declaration: (declaration) => {
|
10
|
+
if (declaration.__ui5_replaced) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
// add version after ui5
|
14
|
+
const expr = /(--_?ui5)([^\,\:\)\s]+)/g
|
15
|
+
declaration.prop = declaration.prop.replaceAll(expr, `$1-${versionStr}$2`)
|
16
|
+
declaration.value = declaration.value.replaceAll(expr, `$1-${versionStr}$2`)
|
17
|
+
declaration.__ui5_replaced = true;
|
18
|
+
},
|
19
|
+
};
|
20
|
+
},
|
21
|
+
};
|
22
|
+
};
|
23
|
+
|
24
|
+
module.exports.postcss = true;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.17.0-rc.1",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -51,7 +51,6 @@
|
|
51
51
|
"jsdoc": "^3.6.6",
|
52
52
|
"json-beautify": "^1.1.1",
|
53
53
|
"mkdirp": "^1.0.4",
|
54
|
-
"modify-selectors": "^2.0.0",
|
55
54
|
"nps": "^5.10.0",
|
56
55
|
"postcss": "^8.4.5",
|
57
56
|
"postcss-cli": "^9.1.0",
|
@@ -79,5 +78,5 @@
|
|
79
78
|
"devDependencies": {
|
80
79
|
"yargs": "^17.5.1"
|
81
80
|
},
|
82
|
-
"gitHead": "
|
81
|
+
"gitHead": "6ab07172a4a1566c3c598ea1db8dae9b26b4d64e"
|
83
82
|
}
|