@ui5/webcomponents-tools 0.0.0-d1315d658 → 0.0.0-d473b9686
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 +767 -0
- package/README.md +2 -1
- package/assets-meta.js +15 -10
- package/components-package/eslint.js +2 -0
- package/components-package/nps.js +51 -43
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -50
- package/components-package/wdio.js +414 -400
- package/icons-collection/nps.js +7 -5
- package/lib/amd-to-es6/index.js +102 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/custom-elements-manifest.config.mjs +501 -0
- package/lib/cem/event.mjs +131 -0
- package/lib/cem/schema-internal.json +1357 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +796 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +384 -0
- package/lib/cem/validate.js +70 -0
- package/lib/create-icons/index.js +8 -6
- package/lib/create-illustrations/index.js +51 -30
- package/lib/create-new-component/index.js +4 -11
- package/lib/create-new-component/tsFileContentTemplate.js +3 -12
- package/lib/css-processors/css-processor-component-styles.mjs +48 -0
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +79 -0
- package/lib/css-processors/scope-variables.mjs +49 -0
- package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/ssr-dom-shim-loader.js +26 -0
- package/lib/generate-js-imports/illustrations.js +78 -64
- package/lib/generate-json-imports/i18n.js +10 -37
- package/lib/generate-json-imports/themes.js +9 -31
- package/lib/i18n/defaults.js +1 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
- package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
- package/lib/scoping/get-all-tags.js +1 -1
- package/lib/scoping/lint-src.js +8 -7
- package/lib/scoping/scope-test-pages.js +2 -1
- package/package.json +11 -10
- package/components-package/wdio.sync.js +0 -368
- package/lib/create-new-component/jsFileContentTemplate.js +0 -73
- package/lib/esm-abs-to-rel/index.js +0 -58
- package/lib/generate-custom-elements-manifest/index.js +0 -327
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/configTypescript.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2468
- package/lib/jsdoc/preprocess.js +0 -146
- package/lib/jsdoc/template/publish.js +0 -4120
- package/lib/postcss-css-to-json/index.js +0 -47
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -14
- package/lib/replace-global-core/index.js +0 -25
@@ -1,13 +1,15 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
2
|
const path = require('path');
|
3
3
|
|
4
|
+
const isTypeScript = process.env.UI5_TS;
|
5
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
6
|
+
|
4
7
|
const generate = async () => {
|
5
8
|
|
6
9
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
7
10
|
|
8
11
|
const inputFolder = path.normalize(process.argv[2]);
|
9
|
-
const
|
10
|
-
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.js`);
|
12
|
+
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
|
11
13
|
|
12
14
|
// All languages present in the file system
|
13
15
|
const files = await fs.readdir(inputFolder);
|
@@ -16,50 +18,22 @@ const generate = async () => {
|
|
16
18
|
return matches ? matches[1] : undefined;
|
17
19
|
}).filter(key => !!key);
|
18
20
|
|
19
|
-
let
|
21
|
+
let contentDynamic;
|
20
22
|
|
21
23
|
// No i18n - just import dependencies, if any
|
22
24
|
if (languages.length === 0) {
|
23
|
-
contentStatic = "";
|
24
25
|
contentDynamic = "";
|
25
26
|
// There is i18n - generate the full file
|
26
27
|
} else {
|
27
28
|
// Keys for the array
|
28
|
-
const languagesKeysString = languages.map(key => `"${key}": _${key},`).join("\n\t");
|
29
29
|
const languagesKeysStringArray = languages.map(key => `"${key}",`).join("\n\t");
|
30
30
|
|
31
31
|
// Actual imports for json assets
|
32
|
-
const
|
33
|
-
|
34
|
-
// static imports
|
35
|
-
contentStatic = `import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
36
|
-
|
37
|
-
${assetsImportsString}
|
38
|
-
|
39
|
-
const bundleMap = {
|
40
|
-
${languagesKeysString}
|
41
|
-
};
|
42
|
-
|
43
|
-
const fetchMessageBundle = async (localeId) => {
|
44
|
-
if (typeof bundleMap[localeId] === "object") {
|
45
|
-
// inlined from build
|
46
|
-
throw new Error("[i18n] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs")
|
47
|
-
}
|
48
|
-
return (await fetch(bundleMap[localeId])).json()
|
49
|
-
}
|
50
|
-
|
51
|
-
const localeIds = [${languagesKeysStringArray}];
|
52
|
-
|
53
|
-
localeIds.forEach(localeId => {
|
54
|
-
registerI18nLoader("${packageName}", localeId, fetchMessageBundle);
|
55
|
-
});
|
56
|
-
`;
|
57
|
-
|
58
|
-
// Actual imports for json assets
|
59
|
-
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import("../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
32
|
+
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
60
33
|
|
61
34
|
// Resulting file content
|
62
|
-
contentDynamic =
|
35
|
+
contentDynamic = `// @ts-nocheck
|
36
|
+
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
63
37
|
|
64
38
|
const importMessageBundle = async (localeId) => {
|
65
39
|
switch (localeId) {
|
@@ -71,7 +45,7 @@ localeIds.forEach(localeId => {
|
|
71
45
|
const importAndCheck = async (localeId) => {
|
72
46
|
const data = await importMessageBundle(localeId);
|
73
47
|
if (typeof data === "string" && data.endsWith(".json")) {
|
74
|
-
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build
|
48
|
+
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
75
49
|
}
|
76
50
|
return data;
|
77
51
|
}
|
@@ -86,9 +60,8 @@ localeIds.forEach(localeId => {
|
|
86
60
|
|
87
61
|
}
|
88
62
|
|
89
|
-
await fs.mkdir(path.dirname(
|
63
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
90
64
|
return Promise.all([
|
91
|
-
fs.writeFile(outputFile, contentStatic),
|
92
65
|
fs.writeFile(outputFileDynamic, contentDynamic),
|
93
66
|
]);
|
94
67
|
}
|
@@ -2,10 +2,12 @@ const fs = require("fs").promises;
|
|
2
2
|
const path = require('path');
|
3
3
|
const assets = require("../../assets-meta.js");
|
4
4
|
|
5
|
+
const isTypeScript = process.env.UI5_TS;
|
6
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
7
|
+
|
5
8
|
const generate = async () => {
|
6
9
|
const inputFolder = path.normalize(process.argv[2]);
|
7
|
-
const
|
8
|
-
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.js`);
|
10
|
+
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
|
9
11
|
|
10
12
|
// All supported optional themes
|
11
13
|
const allThemes = assets.themes.all;
|
@@ -19,35 +21,12 @@ const generate = async () => {
|
|
19
21
|
|
20
22
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
21
23
|
|
22
|
-
const importLines = themesOnFileSystem.map(theme => `import ${theme} from "../assets/themes/${theme}/parameters-bundle.css.json";`).join("\n");
|
23
|
-
const themeUrlsByName = "{\n" + themesOnFileSystem.join(",\n") + "\n}";
|
24
24
|
const availableThemesArray = `[${themesOnFileSystem.map(theme => `"${theme}"`).join(", ")}]`;
|
25
|
-
const dynamicImportLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import("../assets/themes/${theme}/parameters-bundle.css.json")).default;`).join("\n");
|
26
|
-
|
27
|
-
|
28
|
-
// static imports file content
|
29
|
-
const contentStatic = `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
30
|
-
|
31
|
-
${importLines}
|
32
|
-
|
33
|
-
const themeUrlsByName = ${themeUrlsByName};
|
34
|
-
const isInlined = obj => typeof (obj) === "object";
|
35
|
-
|
36
|
-
const loadThemeProperties = async (themeName) => {
|
37
|
-
if (typeof themeUrlsByName[themeName] === "object") {
|
38
|
-
// inlined from build
|
39
|
-
throw new Error("[themes] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs");
|
40
|
-
}
|
41
|
-
return (await fetch(themeUrlsByName[themeName])).json();
|
42
|
-
};
|
43
|
-
|
44
|
-
${availableThemesArray}
|
45
|
-
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadThemeProperties));
|
46
|
-
`;
|
47
|
-
|
25
|
+
const dynamicImportLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json")).default;`).join("\n");
|
48
26
|
|
49
27
|
// dynamic imports file content
|
50
|
-
const contentDynamic =
|
28
|
+
const contentDynamic = `// @ts-nocheck
|
29
|
+
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
51
30
|
|
52
31
|
const loadThemeProperties = async (themeName) => {
|
53
32
|
switch (themeName) {
|
@@ -59,7 +38,7 @@ ${dynamicImportLines}
|
|
59
38
|
const loadAndCheck = async (themeName) => {
|
60
39
|
const data = await loadThemeProperties(themeName);
|
61
40
|
if (typeof data === "string" && data.endsWith(".json")) {
|
62
|
-
throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build
|
41
|
+
throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
63
42
|
}
|
64
43
|
return data;
|
65
44
|
};
|
@@ -68,9 +47,8 @@ ${availableThemesArray}
|
|
68
47
|
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadAndCheck));
|
69
48
|
`;
|
70
49
|
|
71
|
-
await fs.mkdir(path.dirname(
|
50
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
72
51
|
return Promise.all([
|
73
|
-
fs.writeFile(outputFile, contentStatic),
|
74
52
|
fs.writeFile(outputFileDynamic, contentDynamic)
|
75
53
|
]);
|
76
54
|
};
|
package/lib/i18n/defaults.js
CHANGED
@@ -31,7 +31,7 @@ const generate = async () => {
|
|
31
31
|
// (2) as the messagebundle.properties file is always written in English,
|
32
32
|
// it makes sense to consider the messagebundle.properties content only when the default language is "en".
|
33
33
|
if (defaultLanguage === "en") {
|
34
|
-
defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
|
34
|
+
defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
|
35
35
|
}
|
36
36
|
|
37
37
|
/*
|
@@ -154,22 +154,29 @@ module.exports = (options) => {
|
|
154
154
|
options.removeDuplicatedProperties ||
|
155
155
|
options.removeDuplicatedValues
|
156
156
|
) {
|
157
|
-
removeDupProperties(
|
158
|
-
|
159
|
-
|
160
|
-
);
|
157
|
+
// removeDupProperties(
|
158
|
+
// destination,
|
159
|
+
// options.removeDuplicatedValues,
|
160
|
+
// );
|
161
161
|
}
|
162
162
|
} else {
|
163
163
|
if (
|
164
164
|
options.removeDuplicatedProperties ||
|
165
165
|
options.removeDuplicatedValues
|
166
166
|
) {
|
167
|
-
removeDupProperties(rule, options.removeDuplicatedValues);
|
167
|
+
// removeDupProperties(rule, options.removeDuplicatedValues);
|
168
168
|
}
|
169
169
|
// add new selector to symbol table
|
170
170
|
map.set(selector, rule);
|
171
171
|
}
|
172
172
|
},
|
173
|
+
OnceExit(root) {
|
174
|
+
root.nodes.forEach(node => {
|
175
|
+
if (node.type === "rule") {
|
176
|
+
removeDupProperties(node, options.removeDuplicatedValues);
|
177
|
+
}
|
178
|
+
})
|
179
|
+
}
|
173
180
|
};
|
174
181
|
},
|
175
182
|
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { globby } from "globby";
|
2
|
+
import * as esbuild from 'esbuild'
|
3
|
+
import * as fs from "fs";
|
4
|
+
|
5
|
+
let customPlugin = {
|
6
|
+
name: 'ui5-tools',
|
7
|
+
setup(build) {
|
8
|
+
build.onLoad({ filter: /UI5Element.ts$/ }, async (args) => {
|
9
|
+
let text = await fs.promises.readFile(args.path, 'utf8');
|
10
|
+
text = text.replaceAll(/const DEV_MODE = true/g, "");
|
11
|
+
text = text.replaceAll(/if \(DEV_MODE\)/g, "if (false)");
|
12
|
+
return {
|
13
|
+
contents: text,
|
14
|
+
loader: 'ts',
|
15
|
+
}
|
16
|
+
})
|
17
|
+
},
|
18
|
+
}
|
19
|
+
|
20
|
+
const getConfig = async () => {
|
21
|
+
const config = {
|
22
|
+
entryPoints: await globby("src/**/*.ts"),
|
23
|
+
bundle: false,
|
24
|
+
minify: true,
|
25
|
+
sourcemap: true,
|
26
|
+
outdir: 'dist/prod',
|
27
|
+
outbase: 'src',
|
28
|
+
plugins: [
|
29
|
+
customPlugin,
|
30
|
+
]
|
31
|
+
};
|
32
|
+
return config;
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
const config = await getConfig();
|
37
|
+
const result = await esbuild.build(config);
|
@@ -10,7 +10,7 @@ const getTag = file => {
|
|
10
10
|
|
11
11
|
const getPackageTags = (packageDir) => {
|
12
12
|
const srcDir = path.join(packageDir, "src/");
|
13
|
-
return glob.sync(path.join(srcDir, "/**/*.
|
13
|
+
return glob.sync(path.join(srcDir, "/**/*.ts")).flatMap(file => {
|
14
14
|
const tag = getTag(file);
|
15
15
|
return [tag];
|
16
16
|
}).filter(item => !!item);
|
package/lib/scoping/lint-src.js
CHANGED
@@ -7,25 +7,26 @@ const tags = getAllTags(process.cwd());
|
|
7
7
|
|
8
8
|
const errors = [];
|
9
9
|
|
10
|
+
const removeComments = str => str.replaceAll(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
|
11
|
+
|
10
12
|
glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
|
11
|
-
let content = String(fs.readFileSync(file));
|
13
|
+
let content = removeComments(String(fs.readFileSync(file)));
|
12
14
|
tags.forEach(tag => {
|
13
15
|
if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
|
14
|
-
errors.push(
|
16
|
+
errors.push(`${tag} found in ${file}`);
|
15
17
|
}
|
16
18
|
});
|
17
19
|
});
|
18
20
|
|
19
|
-
glob.sync(path.join(process.cwd(), "src/**/*.
|
20
|
-
let content = String(fs.readFileSync(file));
|
21
|
+
glob.sync(path.join(process.cwd(), "src/**/*.ts")).forEach(file => {
|
22
|
+
let content = removeComments(String(fs.readFileSync(file)));
|
21
23
|
tags.forEach(tag => {
|
22
24
|
if (content.match(new RegExp(`querySelector[A-Za-z]*..${tag}`, "g"))) {
|
23
|
-
errors.push(`
|
25
|
+
errors.push(`querySelector for ${tag} found in ${file}`);
|
24
26
|
}
|
25
27
|
});
|
26
28
|
});
|
27
29
|
|
28
30
|
if (errors.length) {
|
29
|
-
errors.
|
30
|
-
throw new Error("Errors found.");
|
31
|
+
throw new Error(`Scoping-related errors found (f.e. used ui5-input instead of [ui5-input]): \n ${errors.join("\n")}`);
|
31
32
|
}
|
@@ -18,6 +18,7 @@ const replaceTagsHTML = content => {
|
|
18
18
|
|
19
19
|
// Replace tags in any content
|
20
20
|
const replaceTagsAny = content => {
|
21
|
+
console.log(tags.length);
|
21
22
|
tags.forEach(tag => {
|
22
23
|
content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
|
23
24
|
});
|
@@ -27,7 +28,7 @@ const replaceTagsAny = content => {
|
|
27
28
|
// Replace bundle names and HTML tag names in test pages
|
28
29
|
glob.sync(path.join(root, "/**/*.html")).forEach(file => {
|
29
30
|
let content = String(fs.readFileSync(file));
|
30
|
-
content = content.replace(
|
31
|
+
content = content.replace("%VITE_BUNDLE_PATH%", "%VITE_BUNDLE_PATH_SCOPED%");
|
31
32
|
content = replaceTagsHTML(content);
|
32
33
|
fs.writeFileSync(file, content);
|
33
34
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-d473b9686",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -21,22 +21,26 @@
|
|
21
21
|
"directory": "packages/tools"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"@
|
25
|
-
"@typescript-eslint/
|
24
|
+
"@custom-elements-manifest/analyzer": "^0.8.4",
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
26
|
+
"@typescript-eslint/parser": "^6.9.0",
|
26
27
|
"@wdio/cli": "^7.19.7",
|
27
28
|
"@wdio/dot-reporter": "^7.19.7",
|
28
29
|
"@wdio/local-runner": "^7.19.7",
|
29
30
|
"@wdio/mocha-framework": "^7.19.7",
|
30
31
|
"@wdio/spec-reporter": "^7.19.7",
|
31
32
|
"@wdio/static-server-service": "^7.19.5",
|
33
|
+
"ajv": "^8.12.0",
|
34
|
+
"cem-plugin-vs-code-custom-data-generator": "^1.4.2",
|
32
35
|
"chai": "^4.3.4",
|
33
36
|
"child_process": "^1.0.2",
|
34
37
|
"chokidar": "^3.5.1",
|
35
38
|
"chokidar-cli": "^3.0.0",
|
36
39
|
"command-line-args": "^5.1.1",
|
40
|
+
"comment-parser": "^1.4.0",
|
37
41
|
"concurrently": "^6.0.0",
|
38
42
|
"cross-env": "^7.0.3",
|
39
|
-
"
|
43
|
+
"custom-element-jet-brains-integration": "^1.4.4",
|
40
44
|
"escodegen": "^2.0.0",
|
41
45
|
"eslint": "^7.22.0",
|
42
46
|
"eslint-config-airbnb-base": "^14.2.1",
|
@@ -48,14 +52,11 @@
|
|
48
52
|
"globby": "^13.1.1",
|
49
53
|
"handlebars": "^4.7.7",
|
50
54
|
"is-port-reachable": "^3.1.0",
|
51
|
-
"jsdoc": "^3.6.6",
|
52
55
|
"json-beautify": "^1.1.1",
|
53
56
|
"mkdirp": "^1.0.4",
|
54
|
-
"modify-selectors": "^2.0.0",
|
55
57
|
"nps": "^5.10.0",
|
56
58
|
"postcss": "^8.4.5",
|
57
59
|
"postcss-cli": "^9.1.0",
|
58
|
-
"postcss-import": "^14.0.2",
|
59
60
|
"postcss-selector-parser": "^6.0.10",
|
60
61
|
"prompts": "^2.4.2",
|
61
62
|
"properties-reader": "^2.2.0",
|
@@ -63,9 +64,8 @@
|
|
63
64
|
"resolve": "^1.20.0",
|
64
65
|
"rimraf": "^3.0.2",
|
65
66
|
"slash": "3.0.0",
|
66
|
-
"vite": "^
|
67
|
-
"wdio-chromedriver-service": "^7.3.2"
|
68
|
-
"zx": "^7.2.3"
|
67
|
+
"vite": "^4.4.9",
|
68
|
+
"wdio-chromedriver-service": "^7.3.2"
|
69
69
|
},
|
70
70
|
"peerDependencies": {
|
71
71
|
"chromedriver": "*",
|
@@ -77,6 +77,7 @@
|
|
77
77
|
}
|
78
78
|
},
|
79
79
|
"devDependencies": {
|
80
|
+
"esbuild": "^0.19.9",
|
80
81
|
"yargs": "^17.5.1"
|
81
82
|
}
|
82
83
|
}
|