@ui5/webcomponents-tools 0.0.0-0f0e49a22 → 0.0.0-10f3c0dc7
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 +2100 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -9
- package/assets-meta.js +14 -11
- package/bin/dev.js +10 -4
- package/bin/ui5nps.js +301 -0
- package/components-package/eslint.js +60 -30
- package/components-package/nps.js +125 -81
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -36
- package/components-package/vite.config.js +7 -11
- package/components-package/wdio.js +421 -401
- 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 +614 -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 +46 -34
- package/lib/create-illustrations/index.js +130 -45
- 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 +226 -0
- package/lib/css-processors/merge-light-dark.mjs +131 -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 +39 -0
- 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 +79 -64
- 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 -26
- 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/replace-global-core/index.js +0 -25
|
@@ -30,116 +30,129 @@ const globParent = require('glob-parent');
|
|
|
30
30
|
|
|
31
31
|
/* CODE */
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
33
|
+
const copyAndWatchFn = async (argv) => {
|
|
34
|
+
const args = argv.slice(2);
|
|
35
|
+
const options = {};
|
|
36
|
+
|
|
37
|
+
['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
|
|
38
|
+
const index = args.indexOf(`--${key}`);
|
|
39
|
+
if (index >= 0) {
|
|
40
|
+
options[key] = true;
|
|
41
|
+
args.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
45
|
+
// Default to silent mode unless verbose is enabled
|
|
46
|
+
if (process.env.UI5_VERBOSE !== "true") {
|
|
47
|
+
options.silent = true;
|
|
48
|
+
}
|
|
48
49
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
50
|
+
if (args.length < 2) {
|
|
51
|
+
console.error('Not enough arguments: copy-and-watch [options] <sources> <target>');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const findTarget = from => {
|
|
59
|
-
const parent = parents
|
|
60
|
-
.filter(p => from.indexOf(p) >= 0)
|
|
61
|
-
.sort()
|
|
62
|
-
.reverse()[0];
|
|
63
|
-
return path.join(target, path.relative(parent, from));
|
|
64
|
-
};
|
|
65
|
-
const createDirIfNotExist = to => {
|
|
66
|
-
'use strict';
|
|
67
|
-
|
|
68
|
-
const dirs = [];
|
|
69
|
-
let dir = path.dirname(to);
|
|
70
|
-
|
|
71
|
-
while (dir !== path.dirname(dir)) {
|
|
72
|
-
dirs.unshift(dir);
|
|
73
|
-
dir = path.dirname(dir);
|
|
55
|
+
if (options['skip-initial-copy'] && !options['watch']) {
|
|
56
|
+
console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied');
|
|
57
|
+
process.exit(1);
|
|
74
58
|
}
|
|
75
59
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
const target = args.pop();
|
|
61
|
+
const sources = args;
|
|
62
|
+
const parents = [...new Set(sources.map(globParent))];
|
|
63
|
+
|
|
64
|
+
const findTarget = from => {
|
|
65
|
+
const parent = parents
|
|
66
|
+
.filter(p => from.indexOf(p) >= 0)
|
|
67
|
+
.sort()
|
|
68
|
+
.reverse()[0];
|
|
69
|
+
return path.join(target, path.relative(parent, from));
|
|
70
|
+
};
|
|
71
|
+
const createDirIfNotExist = to => {
|
|
72
|
+
'use strict';
|
|
73
|
+
|
|
74
|
+
const dirs = [];
|
|
75
|
+
let dir = path.dirname(to);
|
|
76
|
+
|
|
77
|
+
while (dir !== path.dirname(dir)) {
|
|
78
|
+
dirs.unshift(dir);
|
|
79
|
+
dir = path.dirname(dir);
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
createDirIfNotExist(to);
|
|
85
|
-
const stats = fs.statSync(from);
|
|
86
|
-
if (stats.isDirectory()) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
fs.writeFileSync(to, fs.readFileSync(from));
|
|
90
|
-
options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
|
91
|
-
};
|
|
92
|
-
const remove = from => {
|
|
93
|
-
const to = findTarget(from);
|
|
94
|
-
fs.unlinkSync(to);
|
|
95
|
-
options.silent || console.log('[DELETE]'.yellow, to);
|
|
96
|
-
};
|
|
97
|
-
const rimraf = dir => {
|
|
98
|
-
if (fs.existsSync(dir)) {
|
|
99
|
-
fs.readdirSync(dir).forEach(entry => {
|
|
100
|
-
const entryPath = path.join(dir, entry);
|
|
101
|
-
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
102
|
-
rimraf(entryPath);
|
|
103
|
-
} else {
|
|
104
|
-
fs.unlinkSync(entryPath);
|
|
81
|
+
|
|
82
|
+
dirs.forEach(dir => {
|
|
83
|
+
if (!fs.existsSync(dir)) {
|
|
84
|
+
fs.mkdirSync(dir);
|
|
105
85
|
}
|
|
106
86
|
});
|
|
107
|
-
|
|
87
|
+
};
|
|
88
|
+
const copy = from => {
|
|
89
|
+
const to = findTarget(from);
|
|
90
|
+
createDirIfNotExist(to);
|
|
91
|
+
const stats = fs.statSync(from);
|
|
92
|
+
if (stats.isDirectory()) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
fs.writeFileSync(to, fs.readFileSync(from));
|
|
96
|
+
options.silent || console.log('[COPY]', from, 'to', to);
|
|
97
|
+
};
|
|
98
|
+
const remove = from => {
|
|
99
|
+
const to = findTarget(from);
|
|
100
|
+
fs.unlinkSync(to);
|
|
101
|
+
options.silent || console.log('[DELETE]', to);
|
|
102
|
+
};
|
|
103
|
+
const rimraf = dir => {
|
|
104
|
+
if (fs.existsSync(dir)) {
|
|
105
|
+
fs.readdirSync(dir).forEach(entry => {
|
|
106
|
+
const entryPath = path.join(dir, entry);
|
|
107
|
+
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
108
|
+
rimraf(entryPath);
|
|
109
|
+
} else {
|
|
110
|
+
fs.unlinkSync(entryPath);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
fs.rmdirSync(dir);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// clean
|
|
118
|
+
if (options.clean) {
|
|
119
|
+
rimraf(target);
|
|
108
120
|
}
|
|
109
|
-
};
|
|
110
121
|
|
|
111
|
-
//
|
|
112
|
-
if (options
|
|
113
|
-
|
|
114
|
-
}
|
|
122
|
+
// initial copy
|
|
123
|
+
if (!options['skip-initial-copy']) {
|
|
124
|
+
sources.forEach(s => glob.sync(s).forEach(copy));
|
|
125
|
+
}
|
|
115
126
|
|
|
116
|
-
//
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
// watch
|
|
128
|
+
if (options.watch) {
|
|
129
|
+
const chokidarOptions = {
|
|
130
|
+
ignoreInitial: true
|
|
131
|
+
};
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
if (options.safe) {
|
|
134
|
+
chokidarOptions.awaitWriteFinish = {
|
|
135
|
+
stabilityThreshold: 500,
|
|
136
|
+
pollInterval: 100
|
|
137
|
+
};
|
|
138
|
+
}
|
|
126
139
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
chokidar
|
|
141
|
+
.watch(sources, chokidarOptions)
|
|
142
|
+
.on('ready', () => sources.forEach(s => {
|
|
143
|
+
options.silent || console.log('[WATCH]', s);
|
|
144
|
+
}))
|
|
145
|
+
.on('add', copy)
|
|
146
|
+
.on('addDir', copy)
|
|
147
|
+
.on('change', copy)
|
|
148
|
+
.on('unlink', remove)
|
|
149
|
+
.on('unlinkDir', remove)
|
|
150
|
+
.on('error', e => console.log('[ERROR]', e));
|
|
132
151
|
}
|
|
152
|
+
}
|
|
133
153
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.on('ready', () => sources.forEach(s => {
|
|
137
|
-
options.silent || console.log('[WATCH]'.yellow, s);
|
|
138
|
-
}))
|
|
139
|
-
.on('add', copy)
|
|
140
|
-
.on('addDir', copy)
|
|
141
|
-
.on('change', copy)
|
|
142
|
-
.on('unlink', remove)
|
|
143
|
-
.on('unlinkDir', remove)
|
|
144
|
-
.on('error', e => console.log('[ERROR]'.red, e));
|
|
154
|
+
if (require.main === module) {
|
|
155
|
+
copyAndWatchFn(process.argv)
|
|
145
156
|
}
|
|
157
|
+
|
|
158
|
+
exports._ui5mainFn = copyAndWatchFn;
|
package/lib/copy-list/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const generate = async () => {
|
|
4
|
+
const generate = async (argv) => {
|
|
5
|
+
const fileList = argv[2];
|
|
6
|
+
const dest = argv[3];
|
|
7
|
+
const src = "@openui5/sap.ui.core/src/";
|
|
9
8
|
const filesToCopy = (await fs.readFile(fileList)).toString();
|
|
10
9
|
// console.log(filesToCopy);
|
|
11
10
|
|
|
@@ -14,15 +13,24 @@ const generate = async () => {
|
|
|
14
13
|
|
|
15
14
|
const trimFile = file => file.trim();
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
|
|
16
|
+
const promises = filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
|
|
17
|
+
const srcPath = require.resolve(path.join(src, moduleName), { paths: [process.cwd()] });
|
|
19
18
|
const destPath = path.join(dest, moduleName);
|
|
20
19
|
|
|
21
20
|
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
22
21
|
return fs.copyFile(srcPath, destPath);
|
|
23
22
|
});
|
|
23
|
+
|
|
24
|
+
return Promise.all(promises).then(() => {
|
|
25
|
+
if (process.env.UI5_VERBOSE === "true") {
|
|
26
|
+
console.log("Files copied.");
|
|
27
|
+
}
|
|
28
|
+
});
|
|
24
29
|
};
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
|
|
32
|
+
if (require.main === module) {
|
|
33
|
+
generate(process.argv)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports._ui5mainFn = generate;
|
|
@@ -1,114 +1,124 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const collectionVersion = process.argv[3];
|
|
6
|
-
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
|
7
|
-
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
|
8
|
-
|
|
9
|
-
const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
4
|
+
const iconTemplate = (name, pathData, ltr, viewBox, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
10
5
|
|
|
11
6
|
const name = "${name}";
|
|
12
7
|
const pathData = "${pathData}";
|
|
13
8
|
const ltr = ${ltr};
|
|
14
9
|
const accData = null;
|
|
10
|
+
const viewBox = "${viewBox}";
|
|
15
11
|
const collection = "${collection}";
|
|
16
12
|
const packageName = "${packageName}";
|
|
17
13
|
|
|
18
|
-
registerIcon(name, { pathData, ltr, collection, packageName });
|
|
14
|
+
registerIcon(name, { pathData, ltr, viewBox, collection, packageName });
|
|
19
15
|
|
|
20
16
|
export default "${collection}/${name}";
|
|
21
|
-
export { pathData, ltr, accData };`;
|
|
17
|
+
export { pathData, ltr, viewBox, accData };`;
|
|
22
18
|
|
|
23
19
|
|
|
24
|
-
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
25
|
-
import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
|
|
20
|
+
const iconAccTemplate = (name, pathData, ltr, viewBox, accData, collection, packageName, versioned) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
21
|
+
import { ${accData.key} } from "${versioned ? "../" : "./"}generated/i18n/i18n-defaults.js";
|
|
26
22
|
|
|
27
23
|
const name = "${name}";
|
|
28
24
|
const pathData = "${pathData}";
|
|
29
25
|
const ltr = ${ltr};
|
|
30
26
|
const accData = ${accData.key};
|
|
27
|
+
const viewBox = "${viewBox}";
|
|
31
28
|
const collection = "${collection}";
|
|
32
29
|
const packageName = "${packageName}";
|
|
33
30
|
|
|
34
|
-
registerIcon(name, { pathData, ltr, accData, collection, packageName });
|
|
31
|
+
registerIcon(name, { pathData, ltr, viewBox, accData, collection, packageName });
|
|
35
32
|
|
|
36
33
|
export default "${collection}/${name}";
|
|
37
|
-
export { pathData, ltr, accData };`;
|
|
34
|
+
export { pathData, ltr, viewBox, accData };`;
|
|
38
35
|
|
|
39
36
|
|
|
40
37
|
|
|
41
|
-
const collectionTemplate = (name, versions, fullName) => `import {
|
|
42
|
-
import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
|
|
38
|
+
const collectionTemplate = (name, versions, fullName) => `import { isLegacyThemeFamilyAsync } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
|
39
|
+
import { pathData as pathData${versions[0]}, ltr, viewBox, accData } from "./${versions[0]}/${name}.js";
|
|
43
40
|
import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
|
|
44
41
|
|
|
45
|
-
const
|
|
42
|
+
const getPathData = async() => {
|
|
43
|
+
return await isLegacyThemeFamilyAsync() ? pathDatav4 : pathDatav5;
|
|
44
|
+
};
|
|
46
45
|
|
|
47
46
|
export default "${fullName}";
|
|
48
|
-
export {
|
|
47
|
+
export { getPathData, ltr, viewBox, accData };`;
|
|
49
48
|
|
|
50
49
|
|
|
51
50
|
const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
|
|
52
51
|
declare const ltr: boolean;
|
|
52
|
+
declare const viewBox: string;
|
|
53
53
|
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
|
54
54
|
declare const _default: "${collection}/${name}";
|
|
55
55
|
|
|
56
56
|
export default _default;
|
|
57
|
-
export { pathData, ltr, accData };`
|
|
57
|
+
export { pathData, ltr, viewBox, accData };`
|
|
58
58
|
|
|
59
|
-
const collectionTypeDefinitionTemplate = (name, accData) => `declare const
|
|
59
|
+
const collectionTypeDefinitionTemplate = (name, accData) => `declare const getPathData: () => Promise<string>;
|
|
60
60
|
declare const ltr: boolean;
|
|
61
|
+
declare const viewBox: string;
|
|
61
62
|
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
|
62
63
|
declare const _default: "${name}";
|
|
63
64
|
|
|
64
65
|
export default _default;
|
|
65
|
-
export {
|
|
66
|
+
export { getPathData, ltr, viewBox, accData };`
|
|
66
67
|
|
|
67
68
|
|
|
68
|
-
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="
|
|
69
|
+
const svgTemplate = (pathData, viewBox) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}">
|
|
69
70
|
<path d="${pathData}"/>
|
|
70
71
|
</svg>`;
|
|
71
72
|
|
|
72
|
-
const createIcons = async (
|
|
73
|
+
const createIcons = async (argv) => {
|
|
74
|
+
const collectionName = argv[2] || "SAP-icons-v4";
|
|
75
|
+
const collectionVersion = argv[3];
|
|
76
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
|
77
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
|
73
78
|
await fs.mkdir(destDir, { recursive: true });
|
|
74
79
|
|
|
75
|
-
const json = JSON.parse(await fs.readFile(
|
|
80
|
+
const json = JSON.parse(await fs.readFile(srcFile));
|
|
76
81
|
|
|
77
82
|
const promises = [];
|
|
78
83
|
for (let name in json.data) {
|
|
79
84
|
const iconData = json.data[name];
|
|
80
85
|
const pathData = iconData.path;
|
|
81
86
|
const ltr = !!iconData.ltr;
|
|
87
|
+
const viewBox = iconData.viewBox || "0 0 512 512";
|
|
82
88
|
const acc = iconData.acc;
|
|
83
|
-
const packageName =
|
|
84
|
-
const collection =
|
|
89
|
+
const packageName = json.packageName;
|
|
90
|
+
const collection = json.collection;
|
|
91
|
+
const versioned = json.version;
|
|
85
92
|
|
|
86
|
-
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName) : iconTemplate(name, pathData, ltr, collection, packageName);
|
|
93
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, viewBox, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, viewBox, collection, packageName);
|
|
87
94
|
|
|
88
95
|
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
|
89
|
-
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
|
96
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData, viewBox)));
|
|
90
97
|
promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, collection)));
|
|
91
98
|
|
|
92
99
|
// For versioned icons collections, the script creates top level (unversioned) module that internally imports the versioned ones.
|
|
93
100
|
// For example, the top level "@ui5/ui5-webcomponents-icons/dist/accept.js" imports:
|
|
94
|
-
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
|
101
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
|
95
102
|
// - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
|
|
96
103
|
|
|
97
|
-
if (
|
|
104
|
+
if (versioned) {
|
|
98
105
|
// The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
|
|
99
106
|
// to add or not the collection name to the exported value:
|
|
100
107
|
// For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
|
|
101
108
|
// For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
|
|
102
109
|
const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
|
|
103
110
|
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
|
|
104
|
-
|
|
111
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
|
|
108
|
-
return Promise.all(promises)
|
|
115
|
+
return Promise.all(promises)
|
|
116
|
+
.then(() => {
|
|
117
|
+
console.log("Icons created.");
|
|
118
|
+
});
|
|
109
119
|
};
|
|
110
120
|
|
|
111
|
-
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4"
|
|
121
|
+
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
|
|
112
122
|
const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
|
|
113
123
|
const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
|
|
114
124
|
|
|
@@ -119,6 +129,8 @@ const CollectionVersionedToUnversionedMap = {
|
|
|
119
129
|
"business-suite-v2": "business-suite",
|
|
120
130
|
};
|
|
121
131
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
132
|
+
if (require.main === module) {
|
|
133
|
+
createIcons(process.argv)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports._ui5mainFn = createIcons;
|