@ui5/webcomponents-tools 0.0.0-fc993d8cd → 0.0.0-fca1107e7

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +623 -0
  2. package/README.md +2 -1
  3. package/assets-meta.js +15 -7
  4. package/components-package/eslint.js +2 -0
  5. package/components-package/nps.js +41 -32
  6. package/components-package/postcss.components.js +1 -21
  7. package/components-package/postcss.themes.js +1 -26
  8. package/components-package/wdio.js +15 -3
  9. package/components-package/wdio.sync.js +9 -1
  10. package/icons-collection/nps.js +8 -6
  11. package/lib/amd-to-es6/index.js +102 -0
  12. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  13. package/lib/cem/custom-elements-manifest.config.mjs +501 -0
  14. package/lib/cem/event.mjs +131 -0
  15. package/lib/cem/schema-internal.json +1357 -0
  16. package/lib/cem/schema.json +1098 -0
  17. package/lib/cem/types-internal.d.ts +796 -0
  18. package/lib/cem/types.d.ts +736 -0
  19. package/lib/cem/utils.mjs +384 -0
  20. package/lib/cem/validate.js +70 -0
  21. package/lib/create-illustrations/index.js +51 -30
  22. package/lib/create-new-component/index.js +28 -58
  23. package/lib/create-new-component/jsFileContentTemplate.js +1 -5
  24. package/lib/create-new-component/tsFileContentTemplate.js +3 -16
  25. package/lib/css-processors/css-processor-component-styles.mjs +47 -0
  26. package/lib/css-processors/css-processor-components.mjs +77 -0
  27. package/lib/css-processors/css-processor-themes.mjs +79 -0
  28. package/lib/css-processors/scope-variables.mjs +49 -0
  29. package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
  30. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  31. package/lib/generate-custom-elements-manifest/index.js +51 -107
  32. package/lib/generate-js-imports/illustrations.js +78 -64
  33. package/lib/generate-json-imports/i18n.js +10 -5
  34. package/lib/generate-json-imports/themes.js +10 -5
  35. package/lib/hbs2lit/src/compiler.js +9 -6
  36. package/lib/hbs2lit/src/litVisitor2.js +42 -17
  37. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  38. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
  39. package/lib/hbs2ui5/index.js +21 -4
  40. package/lib/i18n/toJSON.js +1 -1
  41. package/lib/jsdoc/preprocess.js +3 -3
  42. package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
  43. package/lib/scoping/get-all-tags.js +1 -1
  44. package/lib/scoping/scope-test-pages.js +2 -1
  45. package/lib/test-runner/test-runner.js +2 -2
  46. package/package.json +13 -10
  47. package/lib/esm-abs-to-rel/index.js +0 -58
  48. package/lib/postcss-css-to-json/index.js +0 -47
  49. package/lib/postcss-new-files/index.js +0 -36
  50. package/lib/postcss-p/postcss-p.mjs +0 -14
  51. package/lib/replace-global-core/index.js +0 -25
@@ -0,0 +1,384 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ let documentationErrors = new Map();
5
+
6
+ const getDeprecatedStatus = (jsdocComment) => {
7
+ const deprecatedTag = findTag(jsdocComment, "deprecated");
8
+ return deprecatedTag?.name
9
+ ? deprecatedTag.description
10
+ ? `${deprecatedTag.name} ${deprecatedTag.description}`
11
+ : deprecatedTag.name
12
+ : deprecatedTag
13
+ ? true
14
+ : undefined;
15
+ };
16
+
17
+ const toKebabCase = str => {
18
+ return str.replaceAll(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase())
19
+ }
20
+
21
+ const normalizeDescription = (description) => {
22
+ return typeof description === 'string' ? description.replaceAll(/^-\s+|^(\n)+|(\n)+$/g, ""): description;
23
+ }
24
+
25
+ const getTypeRefs = (ts, node, member) => {
26
+ const extractTypeRefs = (type) => {
27
+ if (type?.kind === ts.SyntaxKind.TypeReference) {
28
+ return type.typeArguments?.length
29
+ ? type.typeArguments.map((typeRef) => typeRef.typeName?.text)
30
+ : [type.typeName?.text];
31
+ } else if (type?.kind === ts.SyntaxKind.ArrayType) {
32
+ return [type.elementType?.typeName?.text];
33
+ } else if (type?.kind === ts.SyntaxKind.UnionType) {
34
+ return type.types
35
+ .map((type) => extractTypeRefs(type))
36
+ .flat(1);
37
+ } else if (type?.kind === ts.SyntaxKind.TemplateLiteralType) {
38
+ if (member?.type) {
39
+ member.type.text = member.type.text.replaceAll?.(/`|\${|}/g, "");
40
+ }
41
+
42
+ return type.templateSpans?.length
43
+ ? type.templateSpans.map((typeRef) => typeRef.type?.typeName?.text)
44
+ : [type.typeName?.text];
45
+ }
46
+ };
47
+
48
+ let typeRefs = extractTypeRefs(node.type) || node?.typeArguments?.map(n => extractTypeRefs(n)).flat(2);
49
+
50
+ if (typeRefs) {
51
+ typeRefs = typeRefs.filter((e) => !!e);
52
+ }
53
+
54
+ return typeRefs?.length ? typeRefs : undefined;
55
+ };
56
+
57
+ const getSinceStatus = (jsdocComment) => {
58
+ const sinceTag = findTag(jsdocComment, "since");
59
+ return sinceTag
60
+ ? sinceTag.description
61
+ ? `${sinceTag.name} ${sinceTag.description}`
62
+ : sinceTag.name
63
+ : undefined;
64
+ };
65
+
66
+ const getPrivacyStatus = (jsdocComment) => {
67
+ const privacyTag = findTag(jsdocComment, ["public", "private", "protected"]);
68
+ return privacyTag?.tag || "private";
69
+ };
70
+
71
+ const findPackageName = (ts, sourceFile, typeName) => {
72
+ const localStatements = [
73
+ ts.SyntaxKind.EnumDeclaration,
74
+ ts.SyntaxKind.InterfaceDeclaration,
75
+ ts.SyntaxKind.ClassDeclaration,
76
+ ts.SyntaxKind.TypeAliasDeclaration,
77
+ ];
78
+
79
+ const isLocalDeclared = sourceFile.statements.some(
80
+ (statement) =>
81
+ localStatements.includes(statement.kind) && statement?.name?.text === typeName
82
+ );
83
+
84
+ if (isLocalDeclared) {
85
+ return packageJSON?.name;
86
+ } else {
87
+ const importStatements = sourceFile.statements?.filter(
88
+ (statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
89
+ );
90
+ const currentModuleSpecifier = importStatements.find((statement) => {
91
+ if (statement.importClause?.name?.text === typeName) {
92
+ return true;
93
+ }
94
+
95
+ return statement.importClause?.namedBindings?.elements?.some(
96
+ (element) => element.name?.text === typeName
97
+ );
98
+ })?.moduleSpecifier;
99
+
100
+ if (currentModuleSpecifier?.text?.startsWith(".")) {
101
+ return packageJSON?.name;
102
+ } else {
103
+ return Object.keys(packageJSON?.dependencies || {}).find(
104
+ (dependency) =>
105
+ currentModuleSpecifier?.text?.startsWith(`${dependency}/`)
106
+ );
107
+ }
108
+ }
109
+ };
110
+
111
+ const findImportPath = (ts, sourceFile, typeName, modulePath) => {
112
+ const localStatements = [
113
+ ts.SyntaxKind.EnumDeclaration,
114
+ ts.SyntaxKind.InterfaceDeclaration,
115
+ ts.SyntaxKind.ClassDeclaration,
116
+ ts.SyntaxKind.TypeAliasDeclaration,
117
+ ];
118
+
119
+ const isLocalDeclared = sourceFile.statements.some(
120
+ (statement) =>
121
+ localStatements.includes(statement.kind) && statement?.name?.text === typeName
122
+ );
123
+
124
+ if (isLocalDeclared) {
125
+ return (
126
+ modulePath?.replace("src", "dist")?.replace(".ts", ".js") || undefined
127
+ );
128
+ } else {
129
+ const importStatements = sourceFile.statements?.filter(
130
+ (statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
131
+ );
132
+ const currentModuleSpecifier = importStatements.find((statement) => {
133
+ if (statement.importClause?.name?.text === typeName) {
134
+ return true;
135
+ }
136
+
137
+ return statement.importClause?.namedBindings?.elements?.some(
138
+ (element) => element.name?.text === typeName
139
+ );
140
+ })?.moduleSpecifier;
141
+
142
+ if (currentModuleSpecifier?.text?.startsWith(".")) {
143
+ return (
144
+ path.join(path.dirname(modulePath), currentModuleSpecifier.text)
145
+ ?.replace("src", "dist")?.replace(".ts", ".js") || undefined
146
+ );
147
+ } else {
148
+ const packageName = Object.keys(packageJSON?.dependencies || {}).find(
149
+ (dependency) =>
150
+ currentModuleSpecifier?.text?.startsWith(dependency)
151
+ );
152
+ return currentModuleSpecifier?.text
153
+ ?.replace(`${packageName}/`, "") || undefined;
154
+ }
155
+ }
156
+ };
157
+
158
+
159
+ const isClass = text => {
160
+ return text.includes("@abstract") || text.includes("@class") || text.includes("@constructor");
161
+ };
162
+
163
+ const normalizeTagType = (type) => {
164
+ return type?.trim();
165
+ }
166
+
167
+ const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
168
+
169
+ const getReference = (ts, type, classNode, modulePath) => {
170
+ let sourceFile = classNode.parent;
171
+
172
+ while (sourceFile && sourceFile.kind !== ts.SyntaxKind.SourceFile) {
173
+ sourceFile = sourceFile.parent;
174
+ }
175
+
176
+ const typeName =
177
+ typeof type === "string"
178
+ ? normalizeTagType(type)
179
+ : type.class?.expression?.text ||
180
+ type.typeExpression?.type?.getText() ||
181
+ type.typeExpression?.type?.elementType?.typeName?.text;
182
+ const packageName = findPackageName(ts, sourceFile, typeName);
183
+ const importPath = findImportPath(
184
+ ts,
185
+ sourceFile,
186
+ typeName,
187
+ modulePath
188
+ )?.replace(`${packageName}/`, "");
189
+
190
+ return packageName && {
191
+ name: typeName,
192
+ package: packageName,
193
+ module: importPath,
194
+ };
195
+ };
196
+
197
+ const getType = (type) => {
198
+ const typeName = typeof type === "string" ? normalizeTagType(type) : type?.type;
199
+
200
+ const multiple =
201
+ typeName?.endsWith("[]") || typeName?.startsWith("Array<");
202
+ const name = multiple
203
+ ? typeName?.replace("[]", "")?.replace("Array<", "")?.replace(">", "")
204
+ : typeName;
205
+
206
+ return typeName ? { typeName: multiple ? `Array<${name}>` : typeName, name, multiple } : undefined;
207
+ };
208
+
209
+ const commonTags = ["public", "protected", "private", "since", "deprecated"];
210
+
211
+ const allowedTags = {
212
+ field: [...commonTags, "formEvents", "formProperty", "default"],
213
+ slot: [...commonTags, "default"],
214
+ event: [...commonTags, "param", "allowPreventDefault", "native"],
215
+ eventParam: [...commonTags],
216
+ method: [...commonTags, "param", "returns", "override"],
217
+ class: [...commonTags, "constructor", "class", "abstract", "implements", "extends", "slot", "csspart"],
218
+ enum: [...commonTags],
219
+ enumMember: [...commonTags],
220
+ interface: [...commonTags],
221
+ };
222
+ allowedTags.getter = [...allowedTags.field, "override"]
223
+
224
+ const tagMatchCallback = (tag, tagName) => {
225
+ const currentTagName = tag.tag;
226
+
227
+ return typeof tagName === "string"
228
+ ? currentTagName === tagName
229
+ : tagName.includes(currentTagName);
230
+ };
231
+
232
+ const findDecorator = (node, decoratorName) => {
233
+ return node?.decorators?.find(
234
+ (decorator) =>
235
+ decorator?.expression?.expression?.text === decoratorName
236
+ );
237
+ };
238
+
239
+ const findAllDecorators = (node, decoratorName) => {
240
+ return (
241
+ node?.decorators?.filter(
242
+ (decorator) =>
243
+ decorator?.expression?.expression?.text === decoratorName
244
+ ) || []
245
+ );
246
+ };
247
+
248
+ const hasTag = (jsDoc, tagName) => {
249
+ if (!jsDoc) {
250
+ return;
251
+ }
252
+
253
+ return jsDoc?.tags?.some((tag) => tagMatchCallback(tag, tagName));
254
+ };
255
+
256
+ const findTag = (jsDoc, tagName) => {
257
+ if (!jsDoc) {
258
+ return;
259
+ }
260
+
261
+ return jsDoc?.tags?.find((tag) => tagMatchCallback(tag, tagName));
262
+ };
263
+
264
+ const findAllTags = (jsDoc, tagName) => {
265
+ if (!jsDoc) {
266
+ return [];
267
+ }
268
+
269
+ const foundTags = jsDoc?.tags?.filter((tag) => tagMatchCallback(tag, tagName));
270
+
271
+ return foundTags || [];
272
+ };
273
+
274
+ const validateJSDocTag = (tag) => {
275
+ const booleanTags = ["private", "protected", "public", "abstract", "allowPreventDefault", "native", "formProperty", "constructor", "override"];
276
+ let tagName = tag.tag;
277
+
278
+ if (booleanTags.includes(tag.tag)) {
279
+ tagName = "boolean";
280
+ }
281
+
282
+ switch (tagName) {
283
+ case "boolean":
284
+ return !tag.name && !tag.type && !tag.description;
285
+ case "deprecated":
286
+ return !tag.type;
287
+ case "extends":
288
+ return !tag.type && tag.name && !tag.description;
289
+ case "implements":
290
+ return tag.type && !tag.name && !tag.description;
291
+ case "slot":
292
+ return tag.type && tag.name && tag.description;
293
+ case "csspart":
294
+ return !tag.type && tag.name && tag.description;
295
+ case "since":
296
+ return !tag.type && tag.name;
297
+ case "returns":
298
+ return !tag.type && tag.name;
299
+ case "default":
300
+ return !tag.type && !tag.description;
301
+ case "class":
302
+ return !tag.type;
303
+ case "param":
304
+ return !tag.type && tag.name;
305
+ case "eventparam":
306
+ return tag.type && tag.name;
307
+ case "formEvents":
308
+ return !tag.type && tag.name;
309
+ default:
310
+ return false;
311
+ }
312
+ };
313
+
314
+ const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
315
+ return !!jsdocComment?.tags?.every((tag) => {
316
+ let isValid = false
317
+
318
+ if (fieldType === "event" && tag?.tag === "param") {
319
+ isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag({...tag, tag: "eventparam"});
320
+ } else {
321
+ isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag(tag);
322
+ }
323
+
324
+ if (!isValid) {
325
+ logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
326
+ }
327
+
328
+ return !!isValid;
329
+ });
330
+ };
331
+
332
+ const logDocumentationError = (modulePath, message) => {
333
+ let moduleErrors = documentationErrors.get(modulePath);
334
+
335
+ if (!moduleErrors) {
336
+ documentationErrors.set(modulePath, []);
337
+ moduleErrors = documentationErrors.get(modulePath);
338
+ }
339
+
340
+ moduleErrors.push(message);
341
+ }
342
+
343
+ const displayDocumentationErrors = () => {
344
+ let errorsCount = 0;
345
+ [...documentationErrors.keys()].forEach(modulePath => {
346
+ const moduleErrors = documentationErrors.get(modulePath);
347
+
348
+ console.log(`=== ERROR: ${moduleErrors.length > 1 ? `${moduleErrors.length} problems` : "Problem"} found in file: ${modulePath}:`)
349
+ moduleErrors.forEach(moduleError => {
350
+ errorsCount++;
351
+ console.log(`\t- ${moduleError}`)
352
+ })
353
+ })
354
+
355
+ if(errorsCount) {
356
+ throw new Error(`Found ${errorsCount} errors in the description of the public API.`);
357
+ }
358
+ }
359
+
360
+ const formatArrays = (typeText) => {
361
+ return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
362
+ }
363
+
364
+ export {
365
+ getPrivacyStatus,
366
+ getSinceStatus,
367
+ getDeprecatedStatus,
368
+ getType,
369
+ getReference,
370
+ validateJSDocComment,
371
+ findDecorator,
372
+ findAllDecorators,
373
+ hasTag,
374
+ findTag,
375
+ findAllTags,
376
+ getTypeRefs,
377
+ normalizeDescription,
378
+ formatArrays,
379
+ isClass,
380
+ normalizeTagType,
381
+ displayDocumentationErrors,
382
+ logDocumentationError,
383
+ toKebabCase
384
+ };
@@ -0,0 +1,70 @@
1
+ const fs = require('fs');
2
+ const Ajv = require('ajv');
3
+ const path = require('path');
4
+ const yargs = require('yargs/yargs')
5
+ const { hideBin } = require('yargs/helpers')
6
+ const argv = yargs(hideBin(process.argv))
7
+ .argv;
8
+
9
+ // Load your JSON schema
10
+ const extenalSchema = require('./schema.json');
11
+ const internalSchema = require('./schema-internal.json');
12
+
13
+ // Load your JSON data from the input file
14
+ const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
15
+ const customManifest = fs.readFileSync(inputFilePath, 'utf8');
16
+ const inputDataInternal = JSON.parse(customManifest);
17
+
18
+ inputDataInternal.modules.forEach(moduleDoc => {
19
+ moduleDoc.exports = moduleDoc.exports.
20
+ filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
21
+ })
22
+
23
+ const clearProps = (data) => {
24
+ if (Array.isArray(data)) {
25
+ for (let i = 0; i < data.length; i++) {
26
+ if (typeof data[i] === "object") {
27
+ if (["enum", "interface"].includes(data[i].kind)) {
28
+ data.splice(i, 1);
29
+ i--;
30
+ } else {
31
+ clearProps(data[i]);
32
+ }
33
+ }
34
+ }
35
+ } else if (typeof data === "object") {
36
+ Object.keys(data).forEach(prop => {
37
+ if (prop.startsWith("_ui5")) {
38
+ delete data[prop];
39
+ } else if (typeof data[prop] === "object") {
40
+ clearProps(data[prop]);
41
+ }
42
+ });
43
+ }
44
+
45
+ return data;
46
+ }
47
+
48
+ const ajv = new Ajv({ allowUnionTypes: true, allError: true })
49
+ let validate = ajv.compile(internalSchema)
50
+
51
+ // Validate the JSON data against the schema
52
+ if (argv.dev) {
53
+ if (validate(inputDataInternal)) {
54
+ console.log('Internal custom element manifest is validated successfully');
55
+ } else {
56
+ throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
57
+ }
58
+ }
59
+
60
+ const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
61
+ validate = ajv.compile(extenalSchema)
62
+
63
+ // Validate the JSON data against the schema
64
+ if (validate(inputDataExternal)) {
65
+ console.log('Custom element manifest is validated successfully');
66
+ fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
67
+ fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
68
+ } else if (argv.dev) {
69
+ throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
70
+ }
@@ -57,18 +57,36 @@ const generate = async () => {
57
57
  const illustrationsPrefix = process.argv[4];
58
58
  const illustrationSet = process.argv[5];
59
59
  const destPath = process.argv[6];
60
+ const collection = process.argv[7];
60
61
  const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
61
- // collect each illustration name because each one should have Sample.js file
62
+ // collect each illustration name because each one should have Sample.js file
62
63
  const fileNames = new Set();
63
64
 
65
+ let dotIllustrationNames = [];
66
+
67
+ try {
68
+ await fs.access(srcPath);
69
+ } catch (error) {
70
+ console.log(`The path ${srcPath} does not exist.`);
71
+ return Promise.resolve(null);
72
+ }
73
+
74
+ console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
75
+
64
76
  const svgImportTemplate = svgContent => {
65
77
  return `export default \`${svgContent}\`;`
66
78
  };
67
79
  const svgToJs = async fileName => {
68
- const svg = await fs.readFile(path.join(srcPath, fileName), {encoding: "utf-8"});
80
+ const svg = await fs.readFile(path.join(srcPath, fileName), { encoding: "utf-8" });
69
81
  const fileContent = svgImportTemplate(svg);
82
+ const fileNameSplitArr = fileName.split('-');
70
83
  fileName = fileName.replace(/\.svg$/, ".js");
71
84
 
85
+ if (fileNameSplitArr[1] === 'Dot') {
86
+ // we keep the Dot illustration names to import them later. If no Dot is present, Spot will be used
87
+ dotIllustrationNames.push(fileNameSplitArr[2].split('.')[0]);
88
+ }
89
+
72
90
  return fs.writeFile(path.join(destPath, fileName), fileContent);
73
91
  };
74
92
  const illustrationImportTemplate = illustrationName => {
@@ -83,55 +101,54 @@ const generate = async () => {
83
101
  }
84
102
 
85
103
  const illustrationNameUpperCase = illustrationNameForTranslation.toUpperCase();
104
+ // If no Dot is present, Spot will be imported as Dot
105
+ const hasDot = dotIllustrationNames.indexOf(illustrationName) !== -1 ? 'Dot' : 'Spot';
86
106
 
87
- return defaultText ? `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
107
+ return `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
88
108
  import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
89
109
  import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
90
110
  import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
91
- import {
111
+ import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${
112
+ defaultText ? `import {
92
113
  IM_TITLE_${illustrationNameUpperCase},
93
114
  IM_SUBTITLE_${illustrationNameUpperCase},
94
- } from "../generated/i18n/i18n-defaults.js";
115
+ } from "../generated/i18n/i18n-defaults.js";` : ``}
95
116
 
96
117
  const name = "${illustrationName}";
97
118
  const set = "${illustrationSet}";
119
+ const collection = "${collection}";${defaultText ? `
98
120
  const title = IM_TITLE_${illustrationNameUpperCase};
99
- const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};
121
+ const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};` : ``}
100
122
 
101
123
  registerIllustration(name, {
102
124
  dialogSvg,
103
125
  sceneSvg,
104
126
  spotSvg,
127
+ dotSvg,${defaultText ? `
105
128
  title,
106
- subtitle,
129
+ subtitle,` : ``}
107
130
  set,
131
+ collection,
108
132
  });
109
133
 
134
+ export default "${illustrationSet === "fiori" ? "" : `${illustrationSet}/`}${illustrationName}";
110
135
  export {
111
136
  dialogSvg,
112
137
  sceneSvg,
113
138
  spotSvg,
114
- };` :
115
- `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
116
- import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
117
- import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
118
- import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
119
-
120
- const name = "${illustrationName}";
121
- const set = "${illustrationSet}";
139
+ dotSvg,
140
+ };`
141
+ };
122
142
 
123
- registerIllustration(name, {
124
- dialogSvg,
125
- sceneSvg,
126
- spotSvg,
127
- set,
128
- });
143
+ const illustrationTypeDefinition = illustrationName => {
144
+ return `declare const dialogSvg: string;
145
+ declare const sceneSvg: string;
146
+ declare const spotSvg: string;
147
+ declare const dotSvg: string;
148
+ declare const _default: "${illustrationSet === "fiori" ? "" : `${illustrationSet}/`}${illustrationName}";
129
149
 
130
- export {
131
- dialogSvg,
132
- sceneSvg,
133
- spotSvg,
134
- };`
150
+ export default _default;
151
+ export { dialogSvg, sceneSvg, spotSvg, dotSvg };`
135
152
  };
136
153
 
137
154
  await fs.mkdir(destPath, { recursive: true });
@@ -149,11 +166,15 @@ export {
149
166
  }
150
167
  });
151
168
 
152
- for (let illustrationName of fileNames) {
153
- promises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
154
- }
169
+ return Promise.all(promises).then(() => {
170
+ const nestedPromises = [];
171
+ for (let illustrationName of fileNames) {
172
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
173
+ nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
174
+ }
155
175
 
156
- return Promise.all(promises);
176
+ return Promise.all(nestedPromises);
177
+ });
157
178
  };
158
179
 
159
180
  generate().then(() => {