@ui5/webcomponents-tools 0.0.0-b0b835975 → 0.0.0-b3a4f8020
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 +1791 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -9
- package/assets-meta.js +7 -9
- package/bin/dev.js +10 -4
- package/bin/ui5nps.js +301 -0
- package/components-package/eslint.js +59 -29
- package/components-package/nps.js +114 -82
- package/components-package/postcss.components.js +1 -24
- package/components-package/postcss.themes.js +1 -30
- package/components-package/vite.config.js +7 -11
- package/components-package/wdio.js +421 -400
- package/icons-collection/nps.js +31 -20
- package/lib/amd-to-es6/index.js +109 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +16 -0
- package/lib/cem/custom-elements-manifest.config.mjs +582 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/merge.mjs +220 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +1462 -0
- package/lib/cem/schema.json +1138 -0
- package/lib/cem/types-internal.d.ts +838 -0
- package/lib/cem/types.d.ts +766 -0
- package/lib/cem/utils.mjs +433 -0
- package/lib/cem/validate.js +81 -0
- package/lib/chokidar/chokidar.js +28 -0
- package/lib/copy-and-watch/index.js +110 -97
- package/lib/copy-list/index.js +18 -10
- package/lib/create-icons/index.js +32 -25
- package/lib/create-illustrations/index.js +86 -51
- package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +15 -21
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +16 -22
- package/lib/css-processors/css-processor-components.mjs +103 -0
- package/lib/css-processors/css-processor-themes.mjs +122 -0
- package/lib/css-processors/postcss-plugin.mjs +153 -0
- package/lib/css-processors/scope-variables.mjs +74 -0
- package/lib/css-processors/shared.mjs +47 -0
- package/lib/dev-server/custom-hot-update-plugin.js +4 -4
- package/lib/dev-server/{dev-server.js → dev-server.mjs} +26 -14
- package/lib/dev-server/virtual-index-html-plugin.js +24 -20
- package/lib/eslint/eslint.js +44 -0
- package/lib/generate-js-imports/illustrations.js +57 -53
- package/lib/generate-json-imports/i18n.js +63 -68
- package/lib/generate-json-imports/themes.js +38 -43
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +12 -7
- package/lib/hbs2ui5/index.js +3 -3
- package/lib/i18n/defaults.js +17 -9
- package/lib/i18n/toJSON.js +40 -12
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -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 +56 -48
- package/lib/vite-bundler/vite-bundler.mjs +35 -0
- package/package.json +29 -24
- package/tsconfig.json +18 -0
- 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-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/postcss-scope-vars/index.js +0 -24
- package/lib/replace-global-core/index.js +0 -25
|
@@ -3,15 +3,15 @@ const fs = require("fs");
|
|
|
3
3
|
/**
|
|
4
4
|
* A change is observed on MacOS since 13.5, where the build generates a large amount
|
|
5
5
|
* of JSON file that spotlight search has to index, as they are considered new files.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* Starting the vitejs dev server reads all of these files and this triggers the indexing.
|
|
8
8
|
* The indexing has a side effect of changing some file metadata (can be checked with `mdls <path_to_file>`).
|
|
9
9
|
* This metadata change is changing the ctime of the file, but not the mtime. This can be checked with `stat -x <path_to_file>
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* Essentially only metadata is changed, not content. This should not cause a page refresh,
|
|
12
12
|
* but chokidar reports this change and vite refreshes the page.
|
|
13
13
|
* The indexing is running with a 10 second interval, so for roughtly 20 minutes vite is refreshing the page every 10 seconds
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* This plugin checks if the file causing the refresh is a generated json file (dist/*.json) and if ctime is changed after mtime
|
|
16
16
|
* In that case, returing an empty array tells vitejs that a custom update will be made by the plugin,
|
|
17
17
|
* which is in effect ignoring the page refresh.
|
|
@@ -22,7 +22,7 @@ const customHotUpdate = async () => {
|
|
|
22
22
|
name: 'custom-hot-update',
|
|
23
23
|
handleHotUpdate(ctx) {
|
|
24
24
|
// custom check for generated json files
|
|
25
|
-
if (ctx.file.
|
|
25
|
+
if (ctx.file.endsWith(".json")) {
|
|
26
26
|
const stat = fs.statSync(ctx.file);
|
|
27
27
|
|
|
28
28
|
// metadata change only
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import { createServer } from 'vite';
|
|
3
|
+
import yargs from 'yargs';
|
|
4
|
+
import { hideBin } from 'yargs/helpers';
|
|
5
|
+
import { pathToFileURL } from "url";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
.alias("c", "config")
|
|
8
|
-
.argv;
|
|
9
|
-
|
|
10
|
-
const startVite = async (port) => {
|
|
7
|
+
const startVite = async (config, port) => {
|
|
11
8
|
const server = await createServer({
|
|
12
|
-
configFile:
|
|
9
|
+
configFile: config,
|
|
13
10
|
server: {
|
|
14
11
|
port: port,
|
|
15
12
|
strictPort: true,
|
|
@@ -28,7 +25,7 @@ const rmPortFile = async () => {
|
|
|
28
25
|
// exit handler must be sync
|
|
29
26
|
try {
|
|
30
27
|
await fs.rm(".dev-server-port");
|
|
31
|
-
} catch (e) {}
|
|
28
|
+
} catch (e) { }
|
|
32
29
|
process.exit();
|
|
33
30
|
}
|
|
34
31
|
|
|
@@ -36,7 +33,11 @@ const rmPortFile = async () => {
|
|
|
36
33
|
process.on(eventType, rmPortFile);
|
|
37
34
|
});
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
async function start(outArgv) {
|
|
37
|
+
const argv = yargs(hideBin(outArgv))
|
|
38
|
+
.alias("c", "config")
|
|
39
|
+
.argv;
|
|
40
|
+
|
|
40
41
|
let retries = 10;
|
|
41
42
|
let port = 8080;
|
|
42
43
|
while (retries--) {
|
|
@@ -44,7 +45,7 @@ const rmPortFile = async () => {
|
|
|
44
45
|
await fs.writeFile(".dev-server-port", `${port}`);
|
|
45
46
|
try {
|
|
46
47
|
// execSync(command, {stdio: 'pipe'});
|
|
47
|
-
const server = await startVite(port);
|
|
48
|
+
const server = await startVite(argv.config ?? "", port);
|
|
48
49
|
if (server) {
|
|
49
50
|
// server started, don't try other ports
|
|
50
51
|
break;
|
|
@@ -63,4 +64,15 @@ const rmPortFile = async () => {
|
|
|
63
64
|
// no error normal exit
|
|
64
65
|
// process.exit();
|
|
65
66
|
}
|
|
66
|
-
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const filePath = process.argv[1];
|
|
70
|
+
const fileUrl = pathToFileURL(filePath).href;
|
|
71
|
+
|
|
72
|
+
if (import.meta.url === fileUrl) {
|
|
73
|
+
start(process.argv)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default {
|
|
77
|
+
_ui5mainFn: start
|
|
78
|
+
}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
const virtualIndexPlugin =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
|
|
9
|
-
folder.push(path.basename(file));
|
|
10
|
-
});
|
|
1
|
+
const virtualIndexPlugin = () => {
|
|
2
|
+
return {
|
|
3
|
+
name: 'virtual-index-html',
|
|
4
|
+
async config() {
|
|
5
|
+
const path = (await import("path")).default;
|
|
6
|
+
const globby = (await import("globby")).globby;
|
|
7
|
+
const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
const rollupInput = {};
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
files.forEach(file => {
|
|
12
|
+
rollupInput[file] = path.resolve(process.cwd(), file);
|
|
13
|
+
});
|
|
17
14
|
|
|
18
|
-
return {
|
|
19
|
-
name: 'virtual-index-html',
|
|
20
|
-
config() {
|
|
21
15
|
return {
|
|
22
16
|
build: {
|
|
23
17
|
rollupOptions: {
|
|
@@ -26,7 +20,17 @@ const virtualIndexPlugin = async () => {
|
|
|
26
20
|
}
|
|
27
21
|
}
|
|
28
22
|
},
|
|
29
|
-
configureServer(server) {
|
|
23
|
+
async configureServer(server) {
|
|
24
|
+
const path = (await import("path")).default;
|
|
25
|
+
const globby = (await import("globby")).globby;
|
|
26
|
+
const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
|
|
27
|
+
|
|
28
|
+
const pagesPerFolder = {};
|
|
29
|
+
files.forEach(file => {
|
|
30
|
+
let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
|
|
31
|
+
folder.push(path.basename(file));
|
|
32
|
+
});
|
|
33
|
+
|
|
30
34
|
server.middlewares.use((req, res, next) => {
|
|
31
35
|
if (req.url === "/") {
|
|
32
36
|
const folders = Object.keys(pagesPerFolder);
|
|
@@ -37,8 +41,8 @@ const virtualIndexPlugin = async () => {
|
|
|
37
41
|
const pages = pagesPerFolder[folder];
|
|
38
42
|
return `<h1>${folder}</h1>
|
|
39
43
|
${pages.map(page => {
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
return `<li><a href='${folder}/${page}'>${page}</a></li>`
|
|
45
|
+
}).join("")}
|
|
42
46
|
`
|
|
43
47
|
}).join("")}`);
|
|
44
48
|
} else {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const { ESLint: ESLint7 } = require("eslint"); // isolated v7
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const main = async argv => {
|
|
6
|
+
let eslintConfig;
|
|
7
|
+
if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
|
|
8
|
+
// preferred way of custom configuration in root project folder
|
|
9
|
+
eslintConfig = null;
|
|
10
|
+
} else {
|
|
11
|
+
// no custom configuration - use default from tools project
|
|
12
|
+
eslintConfig = require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const packageDir = path.dirname(require.resolve("@ui5/webcomponents-tools/package.json"));
|
|
16
|
+
const eslint = new ESLint7({
|
|
17
|
+
overrideConfigFile: eslintConfig,
|
|
18
|
+
fix: argv.includes("--fix"),
|
|
19
|
+
resolvePluginsRelativeTo: packageDir,
|
|
20
|
+
});
|
|
21
|
+
console.log("Running ESLint v7...");
|
|
22
|
+
|
|
23
|
+
// Lint files
|
|
24
|
+
const results = await eslint.lintFiles(["."]);
|
|
25
|
+
|
|
26
|
+
// Format results
|
|
27
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
28
|
+
const resultText = formatter.format(results);
|
|
29
|
+
|
|
30
|
+
// Output results
|
|
31
|
+
console.log(resultText);
|
|
32
|
+
|
|
33
|
+
// Exit with error code if there are errors
|
|
34
|
+
const hasErrors = results.some(result => result.errorCount > 0);
|
|
35
|
+
if (hasErrors) {
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (require.main === module) {
|
|
41
|
+
main(process.argv)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports._ui5mainFn = main;
|
|
@@ -1,83 +1,87 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const generateDynamicImportLines = (fileNames, location, exclusionPatterns = []) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const generateDynamicImportLines = async (fileNames, location, exclusionPatterns = []) => {
|
|
5
|
+
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
|
6
|
+
return fileNames
|
|
7
|
+
.filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
|
|
8
|
+
.map((fileName) => {
|
|
9
|
+
const illustrationName = fileName.replace(".svg", "");
|
|
10
|
+
const illustrationPath = `${location}/${illustrationName}`;
|
|
11
|
+
return `\t\tcase "${fileName.replace('.js', '')}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${illustrationName.toLowerCase()}" */ "${illustrationPath}.js")).default;`;
|
|
12
|
+
})
|
|
13
|
+
.join("\n");
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
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";
|
|
16
|
+
const generateDynamicImportsFileContent = (dynamicImports, availableIllustrations, collection, set, prefix = "") => {
|
|
17
|
+
return `// @ts-nocheck
|
|
18
|
+
import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
|
24
19
|
|
|
25
20
|
export const loadIllustration = async (illustrationName) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const collectionAndPrefix = "${set}/${collection}/${prefix}";
|
|
22
|
+
const cleanIllustrationName = illustrationName.startsWith(collectionAndPrefix) ? illustrationName.replace(collectionAndPrefix, "") : illustrationName;
|
|
23
|
+
switch (cleanIllustrationName) {
|
|
29
24
|
${dynamicImports}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
default:
|
|
26
|
+
throw new Error("[Illustrations] Illustration not found: " + illustrationName);
|
|
27
|
+
}
|
|
33
28
|
};
|
|
34
29
|
|
|
35
30
|
const loadAndCheck = async (illustrationName) => {
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const data = await loadIllustration(illustrationName);
|
|
32
|
+
return data;
|
|
38
33
|
};
|
|
39
34
|
|
|
40
35
|
${availableIllustrations}.forEach((illustrationName) =>
|
|
41
|
-
|
|
36
|
+
registerIllustrationLoader(\`${set}/${collection}/${prefix}\${illustrationName}\`, loadAndCheck)
|
|
42
37
|
);
|
|
43
38
|
`;
|
|
44
39
|
};
|
|
45
40
|
|
|
46
41
|
const getMatchingFiles = async (folder, pattern) => {
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
const dir = await fs.readdir(folder);
|
|
43
|
+
return dir.filter((fileName) => fileName.match(pattern));
|
|
49
44
|
};
|
|
50
45
|
|
|
51
|
-
const generateIllustrations = async (
|
|
52
|
-
|
|
46
|
+
const generateIllustrations = async (argv) => {
|
|
47
|
+
const config = {
|
|
48
|
+
inputFolder: argv[2],
|
|
49
|
+
outputFile: argv[3],
|
|
50
|
+
set: argv[4],
|
|
51
|
+
collection: argv[5],
|
|
52
|
+
location: argv[6],
|
|
53
|
+
filterOut: argv[7].slice().split(","),
|
|
54
|
+
};
|
|
53
55
|
|
|
54
|
-
const normalizedInputFolder = path.normalize(inputFolder);
|
|
55
|
-
const normalizedOutputFile = path.normalize(outputFile);
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const { inputFolder, outputFile, collection, location, prefix, filterOut, set } = config;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const normalizedInputFolder = path.normalize(inputFolder);
|
|
60
|
+
const normalizedOutputFile = path.normalize(outputFile);
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
const svgFiles = await getMatchingFiles(normalizedInputFolder, /\.svg$/);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const illustrations = [
|
|
65
|
+
...new Set(
|
|
66
|
+
svgFiles
|
|
67
|
+
.filter(name => !name.includes("sapIllus-Patterns"))
|
|
68
|
+
.map(name => name.split("-").pop().replace(".svg", ""))
|
|
69
|
+
),
|
|
70
|
+
];
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
const dynamicImports = await generateDynamicImportLines(illustrations, location, filterOut);
|
|
73
|
+
const contentDynamic = generateDynamicImportsFileContent(dynamicImports, JSON.stringify(illustrations), collection, set, prefix);
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
prefix: process.argv[6],
|
|
77
|
-
filterOut: process.argv.slice(7),
|
|
75
|
+
await fs.mkdir(path.dirname(normalizedOutputFile), { recursive: true });
|
|
76
|
+
await fs.writeFile(normalizedOutputFile, contentDynamic);
|
|
77
|
+
|
|
78
|
+
if (process.env.UI5_VERBOSE === "true") {
|
|
79
|
+
console.log("Generated illustration imports.");
|
|
80
|
+
}
|
|
78
81
|
};
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
generateIllustrations(
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
if (require.main === module) {
|
|
84
|
+
generateIllustrations(process.argv)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports._ui5mainFn = generateIllustrations;
|
|
@@ -1,98 +1,93 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const isTypeScript = process.env.UI5_TS;
|
|
5
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const getContent = function(caseLines, languagesKeysStringArray, packageName) {
|
|
9
|
+
return `// @ts-nocheck
|
|
10
|
+
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
|
11
|
+
|
|
12
|
+
const importMessageBundle = async (localeId) => {
|
|
13
|
+
switch (localeId) {
|
|
14
|
+
${caseLines}
|
|
15
|
+
default: throw "unknown locale"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const importAndCheck = async (localeId) => {
|
|
20
|
+
const data = await importMessageBundle(localeId);
|
|
21
|
+
if (typeof data === "string" && data.endsWith(".json")) {
|
|
22
|
+
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.\`);
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const localeIds = [${languagesKeysStringArray}];
|
|
28
|
+
|
|
29
|
+
localeIds.forEach(localeId => {
|
|
30
|
+
registerI18nLoader(${ packageName.split("").map(c => `"${c}"`).join (" + ") }, localeId, importAndCheck);
|
|
31
|
+
});
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const generate = async (argv) => {
|
|
5
36
|
|
|
6
37
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
|
7
38
|
|
|
8
|
-
const inputFolder = path.normalize(
|
|
9
|
-
const
|
|
10
|
-
const
|
|
39
|
+
const inputFolder = path.normalize(argv[2]);
|
|
40
|
+
const outputFileDynamic = path.normalize(`${argv[3]}/i18n.${ext}`);
|
|
41
|
+
const outputFileFetchMetaResolve = path.normalize(`${argv[3]}/i18n-fetch.${ext}`);
|
|
42
|
+
const outputFileDynamicImportJSONImport = path.normalize(`${argv[3]}/i18n-node.${ext}`);
|
|
11
43
|
|
|
12
|
-
// All languages present in the file system
|
|
44
|
+
// All languages present in the file system
|
|
13
45
|
const files = await fs.readdir(inputFolder);
|
|
14
46
|
const languages = files.map(file => {
|
|
15
|
-
const matches = file.match(/messagebundle_(.+?).
|
|
47
|
+
const matches = file.match(/messagebundle_(.+?).properties$/);
|
|
16
48
|
return matches ? matches[1] : undefined;
|
|
17
49
|
}).filter(key => !!key);
|
|
18
50
|
|
|
19
|
-
let
|
|
51
|
+
let contentDynamic;
|
|
52
|
+
let contentFetchMetaResolve;
|
|
53
|
+
let contentDynamicImportJSONAttr;
|
|
20
54
|
|
|
21
|
-
// No i18n - just import dependencies, if any
|
|
55
|
+
// No i18n - just import dependencies, if any
|
|
22
56
|
if (languages.length === 0) {
|
|
23
|
-
contentStatic = "";
|
|
24
57
|
contentDynamic = "";
|
|
25
|
-
|
|
58
|
+
contentFetchMetaResolve = "";
|
|
59
|
+
contentDynamicImportJSONAttr = "";
|
|
60
|
+
// There is i18n - generate the full file
|
|
26
61
|
} else {
|
|
27
62
|
// Keys for the array
|
|
28
|
-
const languagesKeysString = languages.map(key => `"${key}": _${key},`).join("\n\t");
|
|
29
63
|
const languagesKeysStringArray = languages.map(key => `"${key}",`).join("\n\t");
|
|
30
64
|
|
|
31
65
|
// Actual imports for json assets
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
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");
|
|
66
|
+
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
|
67
|
+
const fetchMetaResolveString = languages.map(key => ` case "${key}": return (await fetch(new URL("../assets/i18n/messagebundle_${key}.json", import.meta.url))).json();`).join("\n");
|
|
68
|
+
const dynamicImportJSONAttrString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json", {with: { type: 'json'}})).default;`).join("\n");
|
|
60
69
|
|
|
61
70
|
// Resulting file content
|
|
62
|
-
contentDynamic = `import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
|
63
71
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
default: throw "unknown locale"
|
|
68
|
-
}
|
|
72
|
+
contentDynamic = getContent(dynamicImportsString, languagesKeysStringArray, packageName);
|
|
73
|
+
contentFetchMetaResolve = getContent(fetchMetaResolveString, languagesKeysStringArray, packageName);
|
|
74
|
+
contentDynamicImportJSONAttr = getContent(dynamicImportJSONAttrString, languagesKeysStringArray, packageName);
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
|
78
|
+
return Promise.all([
|
|
79
|
+
fs.writeFile(outputFileDynamic, contentDynamic),
|
|
80
|
+
fs.writeFile(outputFileFetchMetaResolve, contentFetchMetaResolve),
|
|
81
|
+
fs.writeFile(outputFileDynamicImportJSONImport, contentDynamicImportJSONAttr),
|
|
82
|
+
]).then(() => {
|
|
83
|
+
if (process.env.UI5_VERBOSE === "true") {
|
|
84
|
+
console.log("Generated i18n JSON imports.");
|
|
75
85
|
}
|
|
76
|
-
return data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const localeIds = [${languagesKeysStringArray}];
|
|
80
|
-
|
|
81
|
-
localeIds.forEach(localeId => {
|
|
82
|
-
registerI18nLoader("${packageName}", localeId, importAndCheck);
|
|
83
86
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
fs.writeFile(outputFile, contentStatic),
|
|
92
|
-
fs.writeFile(outputFileDynamic, contentDynamic),
|
|
93
|
-
]);
|
|
89
|
+
if (require.main === module) {
|
|
90
|
+
generate(process.argv)
|
|
94
91
|
}
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
console.log("Generated i18n JSON imports.");
|
|
98
|
-
});
|
|
93
|
+
exports._ui5mainFn = generate;
|
|
@@ -2,15 +2,21 @@ const fs = require("fs").promises;
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const assets = require("../../assets-meta.js");
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const outputFile = path.normalize(`${process.argv[3]}/Themes-static.js`);
|
|
8
|
-
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.js`);
|
|
5
|
+
const isTypeScript = process.env.UI5_TS;
|
|
6
|
+
const ext = isTypeScript ? 'ts' : 'js';
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
const CSS_VARIABLES_TARGET = process.env.CSS_VARIABLES_TARGET === "host";
|
|
9
|
+
|
|
10
|
+
const generate = async (argv) => {
|
|
11
|
+
const inputFolder = path.normalize(argv[2]);
|
|
12
|
+
const outputFileDynamic = path.normalize(`${argv[3]}/Themes.${ext}`);
|
|
13
|
+
const outputFileDynamicImportJSONAttr = path.normalize(`${argv[3]}/Themes-node.${ext}`);
|
|
14
|
+
const outputFileFetchMetaResolve = path.normalize(`${argv[3]}/Themes-fetch.${ext}`);
|
|
15
|
+
|
|
16
|
+
// All supported optional themes
|
|
11
17
|
const allThemes = assets.themes.all;
|
|
12
18
|
|
|
13
|
-
// All themes present in the file system
|
|
19
|
+
// All themes present in the file system
|
|
14
20
|
const dirs = await fs.readdir(inputFolder);
|
|
15
21
|
const themesOnFileSystem = dirs.map(dir => {
|
|
16
22
|
const matches = dir.match(/sap_.*$/);
|
|
@@ -19,39 +25,19 @@ const generate = async () => {
|
|
|
19
25
|
|
|
20
26
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
|
21
27
|
|
|
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
28
|
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
|
-
|
|
29
|
+
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");
|
|
30
|
+
const dynamicImportJSONAttrLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json", {with: { type: 'json'}})).default;`).join("\n");
|
|
31
|
+
const fetchMetaResolveLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await fetch(new URL("../assets/themes/${theme}/parameters-bundle.css.json", import.meta.url))).json();`).join("\n");
|
|
48
32
|
|
|
49
|
-
// dynamic imports file content
|
|
50
|
-
const contentDynamic =
|
|
33
|
+
// dynamic imports file content
|
|
34
|
+
const contentDynamic = function (lines) {
|
|
35
|
+
return `// @ts-nocheck
|
|
36
|
+
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
|
51
37
|
|
|
52
38
|
const loadThemeProperties = async (themeName) => {
|
|
53
39
|
switch (themeName) {
|
|
54
|
-
${
|
|
40
|
+
${lines}
|
|
55
41
|
default: throw "unknown theme"
|
|
56
42
|
}
|
|
57
43
|
};
|
|
@@ -59,22 +45,31 @@ ${dynamicImportLines}
|
|
|
59
45
|
const loadAndCheck = async (themeName) => {
|
|
60
46
|
const data = await loadThemeProperties(themeName);
|
|
61
47
|
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
|
|
48
|
+
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
49
|
}
|
|
64
50
|
return data;
|
|
65
51
|
};
|
|
66
52
|
|
|
67
53
|
${availableThemesArray}
|
|
68
|
-
.forEach(themeName => registerThemePropertiesLoader("${
|
|
54
|
+
.forEach(themeName => registerThemePropertiesLoader(${packageName.split("").map(c => `"${c}"`).join(" + ")}, themeName, loadAndCheck${CSS_VARIABLES_TARGET ? ', "host"' : ''}));
|
|
69
55
|
`;
|
|
56
|
+
}
|
|
70
57
|
|
|
71
|
-
await fs.mkdir(path.dirname(
|
|
58
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
|
72
59
|
return Promise.all([
|
|
73
|
-
fs.writeFile(
|
|
74
|
-
fs.writeFile(
|
|
75
|
-
|
|
60
|
+
fs.writeFile(outputFileDynamic, contentDynamic(dynamicImportLines)),
|
|
61
|
+
fs.writeFile(outputFileDynamicImportJSONAttr, contentDynamic(dynamicImportJSONAttrLines)),
|
|
62
|
+
fs.writeFile(outputFileFetchMetaResolve, contentDynamic(fetchMetaResolveLines)),
|
|
63
|
+
]).
|
|
64
|
+
then(() => {
|
|
65
|
+
if (process.env.UI5_VERBOSE === "true") {
|
|
66
|
+
console.log("Generated themes JSON imports.");
|
|
67
|
+
}
|
|
68
|
+
})
|
|
76
69
|
};
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
71
|
+
if (require.main === module) {
|
|
72
|
+
generate(process.argv)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
exports._ui5mainFn = generate;
|