@ui5/webcomponents-tools 0.0.0-f651a470c → 0.0.0-f6676abdd
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 +1346 -0
- package/README.md +3 -5
- package/assets-meta.js +11 -10
- package/components-package/cypress/support/commands.js +66 -0
- package/components-package/cypress/support/component-index.html +17 -0
- package/components-package/cypress/support/component.d.ts +22 -0
- package/components-package/cypress/support/component.js +46 -0
- package/components-package/cypress/support/cypress-ct-preact.js +11 -0
- package/components-package/cypress.config.js +33 -0
- package/components-package/eslint.js +94 -28
- package/components-package/nps.js +58 -47
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -26
- package/components-package/vite.config.js +7 -11
- package/components-package/wdio.js +415 -393
- package/icons-collection/nps.js +9 -7
- 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 +544 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/schema-internal.json +1413 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +423 -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/{tsFileContentTemplate.js → Component.js} +15 -25
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +35 -73
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +74 -0
- package/lib/css-processors/scope-variables.mjs +49 -0
- package/lib/css-processors/shared.mjs +56 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
- package/lib/dev-server/virtual-index-html-plugin.js +24 -20
- package/lib/generate-js-imports/illustrations.js +78 -64
- package/lib/generate-json-imports/i18n.js +45 -61
- package/lib/generate-json-imports/themes.js +16 -33
- package/lib/hbs2lit/src/compiler.js +9 -6
- package/lib/hbs2lit/src/litVisitor2.js +42 -17
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
- package/lib/hbs2ui5/index.js +23 -6
- package/lib/i18n/defaults.js +3 -2
- 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 +10 -3
- package/lib/scoping/lint-src.js +8 -7
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +2 -2
- package/package.json +25 -13
- package/tsconfig.json +18 -0
- package/types/index.d.ts +1 -0
- package/components-package/wdio.sync.js +0 -360
- package/lib/create-new-component/jsFileContentTemplate.js +0 -77
- 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-esm/index.js +0 -90
- 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
package/icons-collection/nps.js
CHANGED
@@ -21,7 +21,7 @@ const copyIconAssetsCommand = (options) => {
|
|
21
21
|
return {
|
22
22
|
default: "nps copy.json-imports copy.icon-collection",
|
23
23
|
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
24
|
-
"icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json"
|
24
|
+
"icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" src/generated/assets/`,
|
25
25
|
}
|
26
26
|
}
|
27
27
|
|
@@ -32,7 +32,7 @@ const copyIconAssetsCommand = (options) => {
|
|
32
32
|
|
33
33
|
options.versions.forEach((v) => {
|
34
34
|
command.default += ` copy.icon-collection${v}`;
|
35
|
-
command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json"
|
35
|
+
command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
|
36
36
|
});
|
37
37
|
|
38
38
|
return command;
|
@@ -41,22 +41,24 @@ const copyIconAssetsCommand = (options) => {
|
|
41
41
|
const getScripts = (options) => {
|
42
42
|
const createJSImportsCmd = createIconImportsCommand(options);
|
43
43
|
const copyAssetsCmd = copyIconAssetsCommand(options);
|
44
|
-
const tsCommand = options.
|
45
|
-
const tsCrossEnv = options.
|
44
|
+
const tsCommand = !options.legacy ? "tsc --build" : "";
|
45
|
+
const tsCrossEnv = !options.legacy ? "cross-env UI5_TS=true" : "";
|
46
46
|
|
47
47
|
const scripts = {
|
48
48
|
clean: "rimraf dist && rimraf src/generated",
|
49
49
|
copy: copyAssetsCmd,
|
50
|
+
generate: `${tsCrossEnv} nps clean copy build.i18n build.icons build.jsonImports copyjson`,
|
51
|
+
copyjson: "copy-and-watch \"src/generated/**/*.json\" dist/generated/",
|
50
52
|
build: {
|
51
53
|
default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
|
52
54
|
i18n: {
|
53
55
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
54
56
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
55
|
-
json: `mkdirp
|
57
|
+
json: `mkdirp src/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
|
56
58
|
},
|
57
59
|
jsonImports: {
|
58
|
-
default: "mkdirp
|
59
|
-
i18n: `node "${LIB}/generate-json-imports/i18n.js"
|
60
|
+
default: "mkdirp src/generated/json-imports && nps build.jsonImports.i18n",
|
61
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
|
60
62
|
},
|
61
63
|
icons: createJSImportsCmd,
|
62
64
|
},
|
@@ -0,0 +1,102 @@
|
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
const basePath = process.argv[2];
|
4
|
+
const babelCore = require("@babel/core");
|
5
|
+
const babelParser = require("@babel/parser");
|
6
|
+
const babelGenerator = require("@babel/generator").default;
|
7
|
+
const replaceAsync = require('replace-in-file');
|
8
|
+
|
9
|
+
const convertSAPUIDefineToDefine = async (filePath) => {
|
10
|
+
return replaceAsync({
|
11
|
+
files: filePath,
|
12
|
+
processor: (input) => {
|
13
|
+
return input.replace("sap.ui.define", "define").replace(", /* bExport= */ false", "").replace(", /* bExport= */ true", "");
|
14
|
+
}
|
15
|
+
})
|
16
|
+
}
|
17
|
+
|
18
|
+
const convertAmdToEs6 = async (code) => {
|
19
|
+
return (await babelCore.transformAsync(code, {
|
20
|
+
plugins: [['babel-plugin-amd-to-esm', {}]]
|
21
|
+
})).code;
|
22
|
+
}
|
23
|
+
|
24
|
+
const convertAbsImportsToRelative = (filePath, code) => {
|
25
|
+
let changed = false;
|
26
|
+
// console.log("File processing started: ", srcPath);
|
27
|
+
|
28
|
+
if (code.includes("import(")) {
|
29
|
+
// esprima can't parse this, but it's from the project files
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
34
|
+
const importer = filePath.replace(basePath, "");
|
35
|
+
const importerDir = path.dirname(importer);
|
36
|
+
// console.log("Importer -> ", importer);
|
37
|
+
|
38
|
+
tree?.program?.body?.forEach(node => {
|
39
|
+
if (node.type === "ImportDeclaration") {
|
40
|
+
let importee = node.source.value;
|
41
|
+
// console.log(importee);
|
42
|
+
if (importee.startsWith(".")) {
|
43
|
+
// add .js extension if missing
|
44
|
+
if (!importee.endsWith(".js")) {
|
45
|
+
node.source.value += ".js"
|
46
|
+
changed = true;
|
47
|
+
}
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
let importeeDir = path.dirname(importee);
|
51
|
+
let importeeFile = path.basename(importee);
|
52
|
+
let relativePath = path.relative(importerDir, importeeDir);
|
53
|
+
if (relativePath.length === 0) {
|
54
|
+
relativePath = "."
|
55
|
+
}
|
56
|
+
if (!relativePath.startsWith(".")) {
|
57
|
+
relativePath = "./" + relativePath;
|
58
|
+
}
|
59
|
+
|
60
|
+
relativePath = relativePath.replace(/\\/g, "/"); // the browser expects unix paths
|
61
|
+
let relativeImport = `${relativePath}/${importeeFile}.js`;
|
62
|
+
// console.log(importee + " --> " + relativeImport);
|
63
|
+
node.source.value = relativeImport;
|
64
|
+
changed = true;
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
return changed ? babelGenerator(tree).code : code;
|
69
|
+
}
|
70
|
+
|
71
|
+
const replaceGlobalCoreUsage = (filePath, code) => {
|
72
|
+
if (!filePath.includes("Configuration")) {
|
73
|
+
const replaced = code.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
74
|
+
return code !== replaced ? `import Core from 'sap/ui/core/Core';${replaced}` : code;
|
75
|
+
}
|
76
|
+
|
77
|
+
return code;
|
78
|
+
};
|
79
|
+
|
80
|
+
const transformAmdToES6Module = async (filePath) => {
|
81
|
+
await convertSAPUIDefineToDefine(filePath);
|
82
|
+
|
83
|
+
let code = (await fs.readFile(filePath)).toString();
|
84
|
+
|
85
|
+
code = await convertAmdToEs6(code);
|
86
|
+
|
87
|
+
code = replaceGlobalCoreUsage(filePath, code);
|
88
|
+
|
89
|
+
code = convertAbsImportsToRelative(filePath, code);
|
90
|
+
|
91
|
+
return fs.writeFile(filePath, code);
|
92
|
+
}
|
93
|
+
|
94
|
+
const transformAmdToES6Modules = async () => {
|
95
|
+
const { globby } = await import("globby");
|
96
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
97
|
+
return Promise.all(fileNames.map(transformAmdToES6Module).filter(x => !!x));
|
98
|
+
};
|
99
|
+
|
100
|
+
transformAmdToES6Modules().then(() => {
|
101
|
+
console.log("Success: all amd modules are transformed to es6!");
|
102
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
const basePath = process.argv[2];
|
4
|
+
const babelCore = require("@babel/core");
|
5
|
+
const babelParser = require("@babel/parser");
|
6
|
+
const babelGenerator = require("@babel/generator").default;
|
7
|
+
const walk = require("estree-walk");
|
8
|
+
|
9
|
+
const checkHasRequire = (filePath, code) => {
|
10
|
+
code = code.replace(/sap\.ui\.require/g, "unhandledRequire");
|
11
|
+
|
12
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
13
|
+
walk(tree, {
|
14
|
+
CallExpression: function (node) {
|
15
|
+
if (node.type === "CallExpression" && node?.callee?.name === "unhandledRequire") {
|
16
|
+
throw new Error(`sap.ui.require found in ${filePath}`);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
}
|
21
|
+
|
22
|
+
const checkFile = async (filePath) => {
|
23
|
+
let code = (await fs.readFile(filePath)).toString();
|
24
|
+
checkHasRequire(filePath, code);
|
25
|
+
}
|
26
|
+
|
27
|
+
const checkAll = async () => {
|
28
|
+
const { globby } = await import("globby");
|
29
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
30
|
+
return Promise.all(fileNames.map(checkFile).filter(x => !!x));
|
31
|
+
};
|
32
|
+
|
33
|
+
checkAll();
|