@ui5/webcomponents-tools 0.0.0-934b4df24 → 0.0.0-a3eca7ade
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 +139 -0
- package/README.md +1 -1
- package/assets-meta.js +14 -1
- package/bin/dev.js +16 -1
- package/components-package/nps.js +65 -26
- package/components-package/postcss.themes.js +5 -2
- package/components-package/rollup-plugins/empty-module.js +15 -0
- package/components-package/rollup.js +155 -50
- package/components-package/wdio.js +100 -28
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +53 -9
- package/lib/copy-and-watch/index.js +6 -4
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +40 -22
- package/lib/create-illustrations/index.js +150 -0
- package/lib/create-new-component/index.js +16 -4
- package/lib/documentation/index.js +42 -20
- package/lib/documentation/templates/api-properties-section.js +3 -1
- package/lib/documentation/templates/template.js +2 -1
- package/lib/esm-abs-to-rel/index.js +54 -0
- package/lib/generate-json-imports/i18n.js +58 -20
- package/lib/generate-json-imports/themes.js +53 -13
- package/lib/hash/config.js +10 -0
- package/lib/hash/generate.js +19 -0
- package/lib/hash/upToDate.js +31 -0
- package/lib/hbs2lit/index.js +2 -4
- package/lib/hbs2lit/src/compiler.js +7 -11
- package/lib/hbs2lit/src/includesReplacer.js +20 -9
- package/lib/hbs2lit/src/litVisitor2.js +43 -7
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
- package/lib/hbs2ui5/index.js +26 -20
- package/lib/i18n/toJSON.js +1 -1
- package/lib/jsdoc/config.json +1 -1
- package/lib/jsdoc/plugin.js +33 -4
- package/lib/jsdoc/template/publish.js +24 -4
- package/lib/polyfill-placeholder/index.js +5 -0
- package/lib/postcss-css-to-esm/index.js +19 -16
- package/lib/postcss-css-to-json/index.js +20 -11
- package/lib/postcss-new-files/index.js +36 -0
- package/lib/replace-global-core/index.js +20 -0
- package/lib/scoping/get-all-tags.js +44 -0
- package/lib/scoping/lint-src.js +31 -0
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +40 -0
- package/lib/serve/index.js +46 -0
- package/{components-package → lib/serve}/serve.json +0 -0
- package/package-lock.json +48 -0
- package/package.json +53 -53
- package/bin/init-ui5-package.js +0 -3
- package/lib/init-package/index.js +0 -115
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.es5.js +0 -25
- package/lib/init-package/resources/bundle.esm.js +0 -34
- package/lib/init-package/resources/config/.eslintrc.js +0 -1
- package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
- package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
- package/lib/init-package/resources/config/rollup.config.js +0 -1
- package/lib/init-package/resources/config/wdio.conf.js +0 -1
- package/lib/init-package/resources/package-scripts.js +0 -11
- package/lib/init-package/resources/src/Assets.js +0 -5
- package/lib/init-package/resources/src/Demo.hbs +0 -1
- package/lib/init-package/resources/src/Demo.js +0 -56
- package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
- package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
- package/lib/init-package/resources/src/themes/Demo.css +0 -11
- package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -51
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -1,20 +1,31 @@
|
|
1
1
|
const path = require("path");
|
2
|
-
const
|
2
|
+
const fs = require("fs");
|
3
3
|
|
4
|
-
function replaceIncludes(
|
5
|
-
const
|
6
|
-
|
4
|
+
function replaceIncludes(file) {
|
5
|
+
const filePath = path.dirname(file);
|
6
|
+
let fileContent = fs.readFileSync(file, "utf-8");
|
7
|
+
|
8
|
+
const inclRegex = /{{>\s*include\s*["'](.+?)["']}}/g;
|
7
9
|
let match;
|
8
10
|
|
9
|
-
while((match = inclRegex.exec(
|
11
|
+
while((match = inclRegex.exec(fileContent)) !== null) {
|
10
12
|
inclRegex.lastIndex = 0;
|
11
|
-
|
12
|
-
|
13
|
+
|
14
|
+
let targetFile = match[1];
|
15
|
+
if (targetFile.startsWith(".")) {
|
16
|
+
// Relative path, f.e. {{>include "./Popup.hbs"}} or {{>include "../partials/Header.hbs"}}
|
17
|
+
targetFile = path.join(filePath, targetFile);
|
18
|
+
} else {
|
19
|
+
// Node module path, f.e. {{>include "@ui5/webcomponents/src/Popup.hbs"}}
|
20
|
+
targetFile = require.resolve(targetFile);
|
21
|
+
}
|
22
|
+
|
23
|
+
fileContent = fileContent.replace(match[0], replaceIncludes(targetFile));
|
13
24
|
}
|
14
25
|
|
15
|
-
return
|
26
|
+
return fileContent;
|
16
27
|
}
|
17
28
|
|
18
29
|
module.exports = {
|
19
30
|
replace: replaceIncludes
|
20
|
-
};
|
31
|
+
};
|
@@ -5,9 +5,29 @@ const Visitor = Handlebars.Visitor;
|
|
5
5
|
// skip ifDefined for event handlers and boolean attrs
|
6
6
|
let skipIfDefined = false;
|
7
7
|
|
8
|
+
// when true => an HTML node value, when false => an attribute value
|
9
|
+
let isNodeValue = false;
|
10
|
+
|
11
|
+
// when true => the current attribute is "style"
|
12
|
+
let isStyleAttribute = false;
|
13
|
+
|
8
14
|
// matches event handlers @click= and boolean attrs ?disabled=
|
9
15
|
const dynamicAttributeRgx = /\s(\?|@)([a-zA-Z|-]+)="?\s*$/;
|
10
16
|
|
17
|
+
if (!String.prototype.replaceAll) {
|
18
|
+
String.prototype.replaceAll = function(str, newStr){
|
19
|
+
|
20
|
+
// If a regex pattern
|
21
|
+
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
22
|
+
return this.replace(str, newStr);
|
23
|
+
}
|
24
|
+
|
25
|
+
// If a string
|
26
|
+
return this.replace(new RegExp(str, 'g'), newStr);
|
27
|
+
|
28
|
+
};
|
29
|
+
}
|
30
|
+
|
11
31
|
function HTMLLitVisitor(debug) {
|
12
32
|
this.blockCounter = 0;
|
13
33
|
this.keys = [];
|
@@ -15,7 +35,7 @@ function HTMLLitVisitor(debug) {
|
|
15
35
|
this.result = "";
|
16
36
|
this.mainBlock = "";
|
17
37
|
this.blockPath = "context";
|
18
|
-
this.blockParameters = ["context"];
|
38
|
+
this.blockParameters = ["context", "tags", "suffix"];
|
19
39
|
this.paths = []; //contains all normalized relative paths
|
20
40
|
this.debug = debug;
|
21
41
|
if (this.debug) {
|
@@ -31,7 +51,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
|
|
31
51
|
this.keys.push(key);
|
32
52
|
this.debug && this.blockByNumber.push(key);
|
33
53
|
|
34
|
-
this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") =>
|
54
|
+
this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => ";
|
35
55
|
|
36
56
|
if (this.keys.length > 1) { //it's a nested block
|
37
57
|
this.blocks[this.prevKey()] += this.currentKey() + "(" + this.blockParameters.join(", ") + ")";
|
@@ -42,7 +62,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
|
|
42
62
|
|
43
63
|
this.blocks[this.currentKey()] += "html`";
|
44
64
|
Visitor.prototype.Program.call(this, program);
|
45
|
-
this.blocks[this.currentKey()] += "`;
|
65
|
+
this.blocks[this.currentKey()] += "`;";
|
46
66
|
|
47
67
|
this.keys.pop(key);
|
48
68
|
};
|
@@ -51,9 +71,24 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
|
|
51
71
|
Visitor.prototype.ContentStatement.call(this, content);
|
52
72
|
// let content = content.orgiinal; // attribute="__ attribute = "__ attribute ="__
|
53
73
|
|
54
|
-
|
74
|
+
let contentStatement = content.original;
|
55
75
|
skipIfDefined = !!dynamicAttributeRgx.exec(contentStatement);
|
56
76
|
|
77
|
+
const closingIndex = contentStatement.lastIndexOf(">");
|
78
|
+
const openingIndex = contentStatement.lastIndexOf("<");
|
79
|
+
if (closingIndex !== -1 || openingIndex !== -1) { // Only change isNodeValue whenever < or > is found in the content statement
|
80
|
+
isNodeValue = closingIndex > openingIndex;
|
81
|
+
}
|
82
|
+
|
83
|
+
isStyleAttribute = !isNodeValue && contentStatement.match(/style *= *["']? *$/);
|
84
|
+
|
85
|
+
if (!isStyleAttribute && contentStatement.match(/style=/)) {
|
86
|
+
console.log("WARNING: style hard-coded", contentStatement);
|
87
|
+
}
|
88
|
+
|
89
|
+
// Scope custom element tags
|
90
|
+
contentStatement = contentStatement.replaceAll(/(<\/?\s*)([a-zA-Z0-9_]+-[a-zA-Z0-9_-]+)/g, "$1\${scopeTag(\"$2\", tags, suffix)}");
|
91
|
+
|
57
92
|
this.blocks[this.currentKey()] += contentStatement;
|
58
93
|
};
|
59
94
|
|
@@ -65,13 +100,14 @@ HTMLLitVisitor.prototype.MustacheStatement = function(mustache) {
|
|
65
100
|
} else {
|
66
101
|
const path = normalizePath.call(this, mustache.path.original);
|
67
102
|
const hasCalculatingClasses = path.includes("context.classes");
|
68
|
-
const hasStylesCalculation = path.includes("context.styles");
|
69
103
|
|
70
104
|
let parsedCode = "";
|
71
105
|
|
72
|
-
if (
|
106
|
+
if (isNodeValue && !mustache.escaped) {
|
107
|
+
parsedCode = `\${unsafeHTML(${path})}`;
|
108
|
+
} else if (hasCalculatingClasses) {
|
73
109
|
parsedCode = `\${classMap(${path})}`;
|
74
|
-
} else if (
|
110
|
+
} else if (isStyleAttribute) {
|
75
111
|
parsedCode = `\${styleMap(${path})}`;
|
76
112
|
} else if (skipIfDefined){
|
77
113
|
parsedCode = `\${${path}}`;
|
@@ -46,8 +46,8 @@ function getSVGMatches(template) {
|
|
46
46
|
|
47
47
|
function getSVGBlock(input, blockCounter) {
|
48
48
|
return {
|
49
|
-
usage: `\${blockSVG${blockCounter}(context)}`,
|
50
|
-
definition: `\nconst blockSVG${blockCounter} = (context) =>
|
49
|
+
usage: `\${blockSVG${blockCounter}(context, tags, suffix)}`,
|
50
|
+
definition: `\nconst blockSVG${blockCounter} = (context, tags, suffix) => svg\`${input}\`;`,
|
51
51
|
};
|
52
52
|
}
|
53
53
|
|
@@ -55,7 +55,7 @@ function replaceInternalBlocks(template, svgContent) {
|
|
55
55
|
const internalBlocks = svgContent.match(blockrx) || [];
|
56
56
|
|
57
57
|
internalBlocks.forEach(blockName => {
|
58
|
-
const rx = new RegExp(`const ${blockName}.*(html\`)
|
58
|
+
const rx = new RegExp(`const ${blockName}.*(html\`).*;`);
|
59
59
|
template = template.replace(rx, (match, p1) => {
|
60
60
|
return match.replace(p1, "svg\`");
|
61
61
|
});
|
@@ -1,10 +1,10 @@
|
|
1
1
|
const buildRenderer = (controlName, litTemplate) => {
|
2
|
-
return
|
3
|
-
|
4
|
-
|
5
|
-
import { html, svg, repeat, classMap, styleMap } from '@ui5/webcomponents-base/dist/renderer/LitRenderer.js';
|
2
|
+
return `/* eslint no-unused-vars: 0 */
|
3
|
+
import { html, svg, repeat, classMap, styleMap, ifDefined, unsafeHTML, scopeTag } from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
4
|
+
|
6
5
|
${litTemplate}
|
7
|
-
|
6
|
+
|
7
|
+
export default block0;`;
|
8
8
|
};
|
9
9
|
|
10
10
|
module.exports = {
|
package/lib/hbs2ui5/index.js
CHANGED
@@ -3,6 +3,8 @@ const getopts = require('getopts');
|
|
3
3
|
const hbs2lit = require('../hbs2lit');
|
4
4
|
const path = require('path');
|
5
5
|
const litRenderer = require('./RenderTemplates/LitRenderer');
|
6
|
+
const recursiveReadDir = require("recursive-readdir");
|
7
|
+
const mkdirp = require('mkdirp');
|
6
8
|
|
7
9
|
const args = getopts(process.argv.slice(2), {
|
8
10
|
alias: {
|
@@ -18,32 +20,34 @@ const args = getopts(process.argv.slice(2), {
|
|
18
20
|
|
19
21
|
const onError = (place) => {
|
20
22
|
console.log(`A problem occoured when reading ${place}. Please recheck passed parameters.`);
|
21
|
-
}
|
23
|
+
};
|
24
|
+
|
22
25
|
const isHandlebars = (fileName) => fileName.indexOf('.hbs') !== -1;
|
23
|
-
const parseFile = (filePath, inputDir, outputDir) => {
|
24
|
-
fs.readFile(filePath, 'utf-8', (err, content) => {
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
const processFile = (file, outputDir) => {
|
28
|
+
const litCode = hbs2lit(file);
|
29
|
+
const absoluteOutputDir = composeAbsoluteOutputDir(file, outputDir);
|
30
|
+
const componentNameMatcher = /(\w+)(\.hbs)/gim;
|
31
|
+
const componentName = componentNameMatcher.exec(file)[1];
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
compiledTemplatesPath: outputDir
|
33
|
-
}).then((litCode) => {
|
34
|
-
const componentNameMatcher = /(\w+)(\.hbs)/gim;
|
35
|
-
const componentName = componentNameMatcher.exec(filePath)[1];
|
33
|
+
writeRenderers(absoluteOutputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
|
34
|
+
};
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
const composeAbsoluteOutputDir = (file, outputDir) => {
|
37
|
+
// (1) Extract the dir structure from the source file path - "src/lvl1/lvl2/MyCompBadge.hbs"
|
38
|
+
// - remove the filename - "src/lvl1/lvl2"
|
39
|
+
// - remove the leading dir - "lvl1/lvl2"
|
40
|
+
const fileDir = file.split(path.sep).slice(1, -1).join(path.sep);
|
41
|
+
|
42
|
+
// (2) Compose full output dir - "dist/generated/templates/lvl1/lvl2"
|
43
|
+
return `${outputDir}${path.sep}${fileDir}`;
|
44
|
+
};
|
41
45
|
|
42
46
|
const wrapDirectory = (directory, outputDir) => {
|
43
47
|
directory = path.normalize(directory);
|
44
48
|
outputDir = path.normalize(outputDir);
|
45
49
|
|
46
|
-
|
50
|
+
recursiveReadDir(directory, (err, files) => {
|
47
51
|
|
48
52
|
if (err) {
|
49
53
|
onError('directory');
|
@@ -51,9 +55,7 @@ const wrapDirectory = (directory, outputDir) => {
|
|
51
55
|
|
52
56
|
files.forEach(fileName => {
|
53
57
|
if (isHandlebars(fileName)) {
|
54
|
-
|
55
|
-
// could be refactored a bit
|
56
|
-
parseFile(directory + fileName, directory, outputDir);
|
58
|
+
processFile(fileName, outputDir);
|
57
59
|
}
|
58
60
|
});
|
59
61
|
})
|
@@ -61,6 +63,10 @@ const wrapDirectory = (directory, outputDir) => {
|
|
61
63
|
|
62
64
|
const writeRenderers = (outputDir, controlName, fileContent) => {
|
63
65
|
try {
|
66
|
+
if (!fs.existsSync(outputDir)) {
|
67
|
+
mkdirp.sync(outputDir);
|
68
|
+
}
|
69
|
+
|
64
70
|
const compiledFilePath = `${outputDir}${path.sep}${controlName}Template.lit.js`;
|
65
71
|
|
66
72
|
// strip DOS line endings because the break the source maps
|
package/lib/i18n/toJSON.js
CHANGED
@@ -30,7 +30,7 @@ const messagesJSONDist = path.normalize(`${process.argv[3]}`);
|
|
30
30
|
const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
|
31
31
|
|
32
32
|
fs.writeFileSync(outputFile, JSON.stringify(properties));
|
33
|
-
console.log(`[i18n]: "${filename}.json" has been generated!`);
|
33
|
+
// console.log(`[i18n]: "${filename}.json" has been generated!`);
|
34
34
|
};
|
35
35
|
|
36
36
|
mkdirp.sync(messagesJSONDist);
|
package/lib/jsdoc/config.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"source": {
|
3
3
|
"include": "src",
|
4
|
-
"excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js"
|
4
|
+
"excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
|
5
5
|
},
|
6
6
|
"opts" : {
|
7
7
|
"recurse": true,
|
package/lib/jsdoc/plugin.js
CHANGED
@@ -29,7 +29,13 @@
|
|
29
29
|
*
|
30
30
|
* appenddocs
|
31
31
|
*
|
32
|
-
*
|
32
|
+
* tagname
|
33
|
+
*
|
34
|
+
* native
|
35
|
+
*
|
36
|
+
* noattribute
|
37
|
+
*
|
38
|
+
* allowPreventDefault
|
33
39
|
*
|
34
40
|
* It furthermore listens to the following JSDoc3 events to implement additional functionality
|
35
41
|
*
|
@@ -2060,9 +2066,11 @@ exports.defineTags = function(dictionary) {
|
|
2060
2066
|
});
|
2061
2067
|
|
2062
2068
|
dictionary.defineTag('slot', {
|
2063
|
-
mustNotHaveValue: true,
|
2064
2069
|
onTagged: function(doclet, tag) {
|
2065
2070
|
doclet.slot = true;
|
2071
|
+
if (tag.value) {
|
2072
|
+
doclet.propertyName = tag.value;
|
2073
|
+
}
|
2066
2074
|
}
|
2067
2075
|
});
|
2068
2076
|
|
@@ -2073,10 +2081,31 @@ exports.defineTags = function(dictionary) {
|
|
2073
2081
|
}
|
2074
2082
|
});
|
2075
2083
|
|
2076
|
-
dictionary.defineTag('
|
2084
|
+
dictionary.defineTag('tagname', {
|
2077
2085
|
mustHaveValue: true,
|
2078
2086
|
onTagged: function(doclet, tag) {
|
2079
|
-
doclet.
|
2087
|
+
doclet.tagname = tag.value;
|
2088
|
+
}
|
2089
|
+
});
|
2090
|
+
|
2091
|
+
dictionary.defineTag('allowPreventDefault', {
|
2092
|
+
mustHaveValue: false,
|
2093
|
+
onTagged: function(doclet, tag) {
|
2094
|
+
doclet.allowPreventDefault = true;
|
2095
|
+
}
|
2096
|
+
});
|
2097
|
+
|
2098
|
+
dictionary.defineTag('native', {
|
2099
|
+
mustHaveValue: false,
|
2100
|
+
onTagged: function(doclet, tag) {
|
2101
|
+
doclet.native = true;
|
2102
|
+
}
|
2103
|
+
});
|
2104
|
+
|
2105
|
+
dictionary.defineTag('noattribute', {
|
2106
|
+
mustHaveValue: false,
|
2107
|
+
onTagged: function(doclet, tag) {
|
2108
|
+
doclet.noattribute = true;
|
2080
2109
|
}
|
2081
2110
|
});
|
2082
2111
|
};
|
@@ -2651,8 +2651,8 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2651
2651
|
|
2652
2652
|
attrib("name", symbol.longname);
|
2653
2653
|
attrib("basename", symbol.name);
|
2654
|
-
if (symbol.
|
2655
|
-
attrib("
|
2654
|
+
if (symbol.tagname) {
|
2655
|
+
attrib("tagname", symbol.tagname);
|
2656
2656
|
}
|
2657
2657
|
if (symbol.appenddocs) {
|
2658
2658
|
attrib("appenddocs", symbol.appenddocs);
|
@@ -2804,6 +2804,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2804
2804
|
attrib("export", undefined, '', true);
|
2805
2805
|
}
|
2806
2806
|
|
2807
|
+
if (member.noattribute) {
|
2808
|
+
attrib("noattribute", true);
|
2809
|
+
}
|
2810
|
+
|
2807
2811
|
if (member.readonly) {
|
2808
2812
|
attrib("readonly", member.readonly, null);
|
2809
2813
|
}
|
@@ -2815,7 +2819,14 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2815
2819
|
if ( member.since ) {
|
2816
2820
|
attrib("since", extractVersion(member.since));
|
2817
2821
|
}
|
2818
|
-
|
2822
|
+
|
2823
|
+
var type = listTypes(member.type);
|
2824
|
+
attrib("type", type);
|
2825
|
+
|
2826
|
+
if ((type === "object" || type === "Object") && visibility(member) === "public") {
|
2827
|
+
attrib("noattribute", true);
|
2828
|
+
}
|
2829
|
+
|
2819
2830
|
tag("description", normalizeWS(member.description), true);
|
2820
2831
|
if (member.defaultvalue) {
|
2821
2832
|
attrib("defaultValue", member.defaultvalue);
|
@@ -2838,6 +2849,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2838
2849
|
if (member.slot) {
|
2839
2850
|
tag("property");
|
2840
2851
|
attrib("name", member.name);
|
2852
|
+
if (member.propertyName) {
|
2853
|
+
attrib("propertyName", member.propertyName);
|
2854
|
+
}
|
2841
2855
|
if (member.__ui5.module && member.__ui5.module !== symbol.__ui5.module) {
|
2842
2856
|
attrib("module", member.__ui5.module);
|
2843
2857
|
attrib("export", undefined, '', true);
|
@@ -2879,6 +2893,12 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2879
2893
|
attrib("module", member.__ui5.module);
|
2880
2894
|
attrib("export", undefined, '', true);
|
2881
2895
|
}
|
2896
|
+
if (member.allowPreventDefault) {
|
2897
|
+
attrib("allowPreventDefault", true);
|
2898
|
+
}
|
2899
|
+
if (member.native) {
|
2900
|
+
attrib("native", true);
|
2901
|
+
}
|
2882
2902
|
attrib("visibility", visibility(member), 'public');
|
2883
2903
|
if ( member.scope === 'static' ) {
|
2884
2904
|
attrib("static", true, false, /* raw = */true);
|
@@ -3845,7 +3865,7 @@ function createAPIJS(symbols, filename) {
|
|
3845
3865
|
|
3846
3866
|
var output = [];
|
3847
3867
|
|
3848
|
-
var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
|
3868
|
+
var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
|
3849
3869
|
|
3850
3870
|
function isNoKeyword($) { return !rkeywords.test($.name); }
|
3851
3871
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
@@ -7,13 +6,13 @@ const assets = require("../../assets-meta.js");
|
|
7
6
|
const DEFAULT_THEME = assets.themes.default;
|
8
7
|
|
9
8
|
const getDefaultThemeCode = packageName => {
|
10
|
-
return `import {
|
9
|
+
return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
11
10
|
|
12
|
-
import defaultThemeBase from "@ui5/webcomponents-
|
11
|
+
import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
|
13
12
|
import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
|
15
|
+
registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
|
17
16
|
`;
|
18
17
|
};
|
19
18
|
|
@@ -25,18 +24,22 @@ const proccessCSS = css => {
|
|
25
24
|
return JSON.stringify(css);
|
26
25
|
}
|
27
26
|
|
28
|
-
module.exports =
|
27
|
+
module.exports = function (opts) {
|
29
28
|
opts = opts || {};
|
30
29
|
|
31
|
-
return
|
32
|
-
|
33
|
-
|
30
|
+
return {
|
31
|
+
postcssPlugin: 'postcss-css-to-esm',
|
32
|
+
Once (root) {
|
33
|
+
let css = root.toString();
|
34
|
+
css = proccessCSS(css);
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
|
37
|
+
mkdirp.sync(path.dirname(targetFile));
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
39
|
+
const filePath = `${targetFile}.js`;
|
40
|
+
const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
|
41
|
+
fs.writeFileSync(filePath, `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
};
|
45
|
+
module.exports.postcss = true;
|
@@ -1,4 +1,3 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
@@ -11,17 +10,27 @@ const proccessCSS = css => {
|
|
11
10
|
return css;
|
12
11
|
}
|
13
12
|
|
14
|
-
module.exports =
|
13
|
+
module.exports = function (opts) {
|
15
14
|
opts = opts || {};
|
16
15
|
|
17
|
-
return
|
18
|
-
|
19
|
-
|
16
|
+
return {
|
17
|
+
postcssPlugin: 'postcss-css-to-json',
|
18
|
+
Once (root) {
|
19
|
+
let css = root.toString();
|
20
|
+
css = proccessCSS(css);
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
|
23
|
+
mkdirp.sync(path.dirname(targetFile));
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
const filePath = `${targetFile}.json`;
|
26
|
+
const data = {
|
27
|
+
packageName: opts.packageName,
|
28
|
+
fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
|
29
|
+
content: css
|
30
|
+
};
|
31
|
+
fs.writeFileSync(filePath, JSON.stringify({_: data}));
|
32
|
+
}
|
33
|
+
};
|
34
|
+
};
|
35
|
+
|
36
|
+
module.exports.postcss = true;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
const chokidar = require("chokidar");
|
2
|
+
const commandLineArgs = require("command-line-args");
|
3
|
+
const { exec } = require("child_process");
|
4
|
+
|
5
|
+
const options = commandLineArgs([
|
6
|
+
{ name: "srcFiles", type: String },
|
7
|
+
]);
|
8
|
+
|
9
|
+
const runPostcss = path => {
|
10
|
+
let command = `postcss ${path} --config config/postcss.components --base src --dir dist/css/`;
|
11
|
+
console.log(`Executing: ${command}`);
|
12
|
+
exec(command, (err, stdout, stderr) => {
|
13
|
+
if (err) {
|
14
|
+
console.log(`Could not run postcss for ${path}. Error: ${err}`);
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
command = `${command} -w`;
|
19
|
+
console.log(`Executing: ${command}`);
|
20
|
+
exec(command, (err, stdout, stderr) => {
|
21
|
+
if (err) {
|
22
|
+
console.log(`Could not run postcss in watch mode for ${path}. Error: ${err}`);
|
23
|
+
}
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
let ready = false; // Do nothing until the ready event has been fired (we don't want to recompile all files initially)
|
28
|
+
const watcher = chokidar.watch(options.srcFiles);
|
29
|
+
watcher.on("ready", () => {
|
30
|
+
ready = true; // Initial scan is over -> waiting for new files
|
31
|
+
});
|
32
|
+
watcher.on("add", path => {
|
33
|
+
if (ready) {
|
34
|
+
runPostcss(path);
|
35
|
+
}
|
36
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const glob = require("glob");
|
3
|
+
|
4
|
+
const basePath = process.argv[2];
|
5
|
+
|
6
|
+
const replaceGlobalCoreUsage = (srcPath) => {
|
7
|
+
|
8
|
+
const original = fs.readFileSync(srcPath).toString();
|
9
|
+
let replaced = original.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
10
|
+
|
11
|
+
if (original !== replaced) {
|
12
|
+
replaced = `import Core from 'sap/ui/core/Core';
|
13
|
+
${replaced}`;
|
14
|
+
fs.writeFileSync(srcPath, replaced);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
|
18
|
+
const fileNames = glob.sync(basePath + "**/*.js");
|
19
|
+
fileNames.forEach(replaceGlobalCoreUsage);
|
20
|
+
console.log("Success: Replaced global core usage in:", basePath);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const glob = require("glob");
|
4
|
+
|
5
|
+
const getTag = file => {
|
6
|
+
const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
|
7
|
+
const matches = fileContent.match(/\btag\b:\s*\"(.*?)\"/);
|
8
|
+
return matches ? matches[1] : undefined;
|
9
|
+
};
|
10
|
+
|
11
|
+
const getAltTag = file => {
|
12
|
+
const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
|
13
|
+
const matches = fileContent.match(/\baltTag\b:\s*\"(.*?)\"/);
|
14
|
+
return matches ? matches[1] : undefined;
|
15
|
+
};
|
16
|
+
|
17
|
+
const getPackageTags = (packageDir) => {
|
18
|
+
const srcDir = path.join(packageDir, "src/");
|
19
|
+
return glob.sync(path.join(srcDir, "/**/*.js")).flatMap(file => {
|
20
|
+
const tag = getTag(file);
|
21
|
+
const altTag = getAltTag(file);
|
22
|
+
return [tag, altTag];
|
23
|
+
}).filter(item => !!item);
|
24
|
+
};
|
25
|
+
|
26
|
+
const isComponentsPackage = (packageFileContent) => {
|
27
|
+
return packageFileContent.ui5 && packageFileContent.ui5.webComponentsPackage;
|
28
|
+
};
|
29
|
+
|
30
|
+
const getDepComponentPackages = packageDir => {
|
31
|
+
const packageFile = path.join(packageDir, "package.json");
|
32
|
+
const packageFileContent = JSON.parse(fs.readFileSync(packageFile));
|
33
|
+
if (!isComponentsPackage(packageFileContent)) {
|
34
|
+
return [];
|
35
|
+
}
|
36
|
+
|
37
|
+
return Object.keys(packageFileContent.dependencies || {}).map(dep => path.dirname(require.resolve(path.join(dep, "package.json"))));
|
38
|
+
};
|
39
|
+
|
40
|
+
const getAllTags = (packageDir) => {
|
41
|
+
return getPackageTags(packageDir).concat(getDepComponentPackages(packageDir).flatMap(getPackageTags));
|
42
|
+
};
|
43
|
+
|
44
|
+
module.exports = getAllTags;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const glob = require("glob");
|
4
|
+
const getAllTags = require("./get-all-tags.js");
|
5
|
+
|
6
|
+
const tags = getAllTags(process.cwd());
|
7
|
+
|
8
|
+
const errors = [];
|
9
|
+
|
10
|
+
glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
|
11
|
+
let content = String(fs.readFileSync(file));
|
12
|
+
tags.forEach(tag => {
|
13
|
+
if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
|
14
|
+
errors.push(`Warning! ${tag} found in ${file}`);
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
glob.sync(path.join(process.cwd(), "src/**/*.js")).forEach(file => {
|
20
|
+
let content = String(fs.readFileSync(file));
|
21
|
+
tags.forEach(tag => {
|
22
|
+
if (content.match(new RegExp(`querySelector[A-Za-z]*..${tag}`, "g"))) {
|
23
|
+
errors.push(`Warning! querySelector for ${tag} found in ${file}`);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
if (errors.length) {
|
29
|
+
errors.forEach(error => console.log(error));
|
30
|
+
throw new Error("Errors found.");
|
31
|
+
}
|