@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
@@ -5,61 +5,40 @@ const path = require("path");
5
5
  const inputDir = process.argv[2];
6
6
  const outputDir = process.argv[3];
7
7
 
8
- const camelToKebabMap = new Map();
9
- const apiIndex = new Map();
10
- const forbiddenAttributeTypes = ["object", "array"];
11
-
12
- const camelToKebabCase = string => {
13
- if (!camelToKebabMap.has(string)) {
14
- const result = string.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
15
- camelToKebabMap.set(string, result);
16
- }
17
- return camelToKebabMap.get(string);
18
- };
8
+ const moduleDeclarations = new Map();
19
9
 
20
10
  const generateJavaScriptExport = entity => {
21
11
  return {
22
- declaration: generateRefenrece(entity.name),
23
- deprecated: !!entity.deprecated,
12
+ declaration: {
13
+ name: entity.basename,
14
+ module: `dist/${entity.resource}`,
15
+ },
24
16
  kind: "js",
25
17
  name: "default",
26
18
  };
27
19
  };
28
20
 
29
21
  const generateCustomElementExport = entity => {
22
+ if (!entity.tagname) return;
23
+
30
24
  return {
31
25
  declaration: {
32
26
  name: entity.basename,
33
- module: `${entity.module}.js`,
27
+ module: `dist/${entity.resource}`,
34
28
  },
35
- deprecated: !!entity.deprecated,
36
29
  kind: "custom-element-definition",
37
- name: entity.tagname,
38
- };
39
- };
40
-
41
- const generateJavaScriptModule = entity => {
42
- return {
43
- kind: "javascript-module",
44
- path: `${entity.basename}.js`,
45
- declarations: [
46
- generateCustomElementDeclaration(entity),
47
- ],
48
- exports: [
49
- generateJavaScriptExport(entity),
50
- generateCustomElementExport(entity),
51
- ],
30
+ name: entity.basename,
52
31
  };
53
32
  };
54
33
 
55
34
  const generateSingleClassField = classField => {
56
35
  let generatedClassField = {
57
- deprecated: !!classField.deprecated,
58
36
  kind: "field",
59
37
  name: classField.name,
60
- privacy: classField.visibility,
61
- static: !!classField.static,
62
38
  type: generateType(classField.type),
39
+ privacy: classField.visibility,
40
+ deprecated: !!classField.deprecated || undefined,
41
+ static: !!classField.static || undefined,
63
42
  };
64
43
 
65
44
  if (classField.defaultValue) {
@@ -75,7 +54,7 @@ const generateSingleClassField = classField => {
75
54
 
76
55
  const generateSingleParameter = parameter => {
77
56
  let generatedParameter = {
78
- deprecated: !!parameter.deprecated,
57
+ deprecated: !!parameter.deprecated || undefined,
79
58
  name: parameter.name,
80
59
  type: generateType(parameter.type),
81
60
  };
@@ -86,6 +65,7 @@ const generateSingleParameter = parameter => {
86
65
 
87
66
  if (parameter.optional) {
88
67
  generatedParameter.optional = parameter.optional;
68
+ generatedParameter.default = parameter.defaultValue;
89
69
  }
90
70
 
91
71
  return generatedParameter;
@@ -101,7 +81,7 @@ const generateParameters = (parameters) => {
101
81
 
102
82
  const generateSingleClassMethod = classMethod => {
103
83
  let generatedClassMethod = {
104
- deprecated: !!classMethod.deprecated,
84
+ deprecated: !!classMethod.deprecated || undefined,
105
85
  kind: "method",
106
86
  name: classMethod.name,
107
87
  privacy: classMethod.visibility,
@@ -122,7 +102,7 @@ const generateSingleClassMethod = classMethod => {
122
102
  };
123
103
 
124
104
  if (classMethod.returnValue.description) {
125
- generatedClassMethod.return.description = classMethod.returnValue.type;
105
+ generatedClassMethod.return.description = classMethod.returnValue.description;
126
106
  }
127
107
  }
128
108
 
@@ -150,47 +130,16 @@ const generateMembers = (classFields, classMethods) => {
150
130
  };
151
131
 
152
132
  const generateType = type => {
153
- const dataType = apiIndex.get(type);
154
-
155
133
  return {
156
- text: dataType && dataType.name.includes(".types.") ?
157
- filterPublicApi(dataType.properties)
158
- .map(prop => `"${prop.name}"`)
159
- .join(" | ") : type,
160
- };
161
- };
162
-
163
- const generateSingleAttribute = attribute => {
164
- let generatedAttribute = {
165
- default: attribute.defaultValue,
166
- deprecated: !!attribute.deprecated,
167
- fieldName: attribute.name,
168
- name: camelToKebabCase(attribute.name),
169
- type: generateType(attribute.type),
134
+ text: type,
170
135
  };
171
-
172
- if (attribute.description) {
173
- generatedAttribute.description = attribute.description;
174
- }
175
-
176
- return generatedAttribute;
177
- };
178
-
179
- const generateAttributes = attributes => {
180
- attributes = attributes.reduce((newAttributesArray, attribute) => {
181
- newAttributesArray.push(generateSingleAttribute(attribute));
182
-
183
- return newAttributesArray;
184
- }, []);
185
-
186
- return attributes;
187
136
  };
188
137
 
189
138
  const generateSingleEvent = event => {
190
139
  let generatedEvent = {
191
- deprecated: !!event.deprecated,
140
+ deprecated: !!event.deprecated || undefined,
192
141
  name: event.name,
193
- type: event.native === "true" ? "NativeEvent" : "CustomEvent",
142
+ type: generateType(event.native === "true" ? "NativeEvent" : "CustomEvent")
194
143
  };
195
144
 
196
145
  if (event.description) {
@@ -212,7 +161,7 @@ const generateEvents = events => {
212
161
 
213
162
  const generateSingleSlot = slot => {
214
163
  return {
215
- deprecated: !!slot.deprecated,
164
+ deprecated: !!slot.deprecated || undefined,
216
165
  description: slot.description,
217
166
  name: slot.name,
218
167
  };
@@ -230,9 +179,9 @@ const generateSlots = slots => {
230
179
 
231
180
  const generateCustomElementDeclaration = entity => {
232
181
  let generatedCustomElementDeclaration = {
233
- deprecated: !!entity.deprecated,
182
+ deprecated: !!entity.deprecated || undefined,
234
183
  customElement: true,
235
- kind: entity.basename,
184
+ kind: entity.kind,
236
185
  name: entity.basename,
237
186
  tagName: entity.tagname,
238
187
  };
@@ -241,9 +190,6 @@ const generateCustomElementDeclaration = entity => {
241
190
  const events = filterPublicApi(entity.events);
242
191
  const classFields = filterPublicApi(entity.properties);
243
192
  const classMethods = filterPublicApi(entity.methods);
244
- const attributes = classFields.filter(property => {
245
- return property.noattribute !== "true" && property.readonly !== "true" && !forbiddenAttributeTypes.includes(property.type.toLowerCase());
246
- });
247
193
 
248
194
  if (slots.length) {
249
195
  generatedCustomElementDeclaration.slots = generateSlots(slots);
@@ -253,10 +199,6 @@ const generateCustomElementDeclaration = entity => {
253
199
  generatedCustomElementDeclaration.events = generateEvents(events);
254
200
  }
255
201
 
256
- if (attributes.length) {
257
- generatedCustomElementDeclaration.attributes = generateAttributes(attributes);
258
- }
259
-
260
202
  if (entity.description) {
261
203
  generatedCustomElementDeclaration.description = entity.description;
262
204
  }
@@ -273,31 +215,8 @@ const generateCustomElementDeclaration = entity => {
273
215
  };
274
216
 
275
217
  const generateRefenrece = (entityName) => {
276
- let packageName;
277
- let basename;
278
-
279
- if (!entityName) {
280
- throw new Error("JSDoc error: entity not found in api.json.");
281
- }
282
-
283
- if (entityName.includes(".")) {
284
- basename = entityName.split(".").pop();
285
- } else {
286
- basename = entityName
287
- }
288
-
289
- if (entityName.includes("sap.ui.webc.main")) {
290
- packageName = "@ui5/webcomponents";
291
- } else if (entityName.includes("sap.ui.webc.fiori")) {
292
- packageName = "@ui5/webcomponents-fiori";
293
- } else if (entityName.includes("sap.ui.webc.base")) {
294
- packageName = "@ui5/webcomponents-base";
295
- }
296
-
297
218
  return {
298
- module: `${basename}.js`,
299
- name: `${basename}`,
300
- package: packageName,
219
+ name: entityName,
301
220
  };
302
221
  };
303
222
 
@@ -313,12 +232,37 @@ const generate = async () => {
313
232
  modules: [],
314
233
  };
315
234
 
316
- file.symbols.forEach(entity => {
317
- if (entity.tagname) {
318
- customElementsManifest.modules.push(generateJavaScriptModule(entity));
235
+ filterPublicApi(file.symbols).forEach(entity => {
236
+ let declaration = moduleDeclarations.get(entity.resource);
237
+
238
+ if (!declaration) {
239
+ moduleDeclarations.set(entity.resource, {
240
+ declarations: [],
241
+ exports: [],
242
+ });
243
+ declaration = moduleDeclarations.get(entity.resource);
244
+ }
245
+
246
+ if (entity.kind === "class" && entity.tagname) {
247
+ declaration.declarations.push(generateCustomElementDeclaration(entity));
248
+ declaration.exports.push(generateJavaScriptExport(entity));
249
+ declaration.exports.push(generateCustomElementExport(entity));
250
+ } else if (entity.kind === "class" && entity.static) {
251
+ declaration.exports.push(generateJavaScriptExport(entity));
319
252
  }
320
253
  });
321
254
 
255
+ [...moduleDeclarations.keys()].forEach(key => {
256
+ let declaration = moduleDeclarations.get(key);
257
+
258
+ customElementsManifest.modules.push({
259
+ kind: "javascript-module",
260
+ path: `dist/${key}`,
261
+ declarations: declaration.declarations,
262
+ exports: declaration.exports
263
+ })
264
+ })
265
+
322
266
  await fs.writeFile(path.join(outputDir, "custom-elements.json"), JSON.stringify(customElementsManifest));
323
267
  };
324
268
 
@@ -1,72 +1,86 @@
1
1
  const fs = require("fs").promises;
2
- const path = require('path');
3
-
4
- const generate = async () => {
5
- const fioriInputFolder = path.normalize(process.argv[2]);
6
- const tntInputFolder = path.normalize(process.argv[3]);
7
- const outputFile = path.normalize(`${process.argv[4]}/Illustrations.js`);
8
-
9
- const dir = await fs.readdir(fioriInputFolder);
10
- const fioriIllustrationsOnFileSystem = dir.map(illustrationName => {
11
- const fioriMatches = illustrationName.match(/.*\.js$/);
12
- return fioriMatches ? illustrationName : undefined;
13
- }).filter(key => !!key);
14
-
15
- const tntDir = await fs.readdir(tntInputFolder);
16
- const tntIllustrationsOnFileSystem = tntDir.map(illustrationName => {
17
- const tntMatches = illustrationName.match(/.*\.js$/);
18
- return tntMatches ? illustrationName : undefined;
19
- }).filter(key => !!key);
20
-
21
- // dynamic imports for Fiori illustrations
22
- const fioriAvailableIllustrationsArray = `[${fioriIllustrationsOnFileSystem.filter(
23
- // skipping the items starting with sapIllus-Dialog, sapIllus-Scene, sapIllus-Spot since they are included in the illustration's js file
24
- line => !line.startsWith("sapIllus-Dialog") && !line.startsWith("sapIllus-Scene") && !line.startsWith("sapIllus-Spot") && !line.startsWith("AllIllustrations")).map(illustrationName => `"${illustrationName.replace('.js', '')}"`).join(", ")}]`;
25
-
26
- const fioriDynamicImportLines = fioriIllustrationsOnFileSystem.map(illustrationName =>
27
- `\t\tcase "${illustrationName.replace('.js', '')}": return (await import("../../illustrations/${illustrationName}")).default;`).filter(
28
- // skipping the items starting with sapIllus-Dialog, sapIllus-Scene, sapIllus-Spot since they are included in the illustration's js file
29
- line => !line.startsWith("\t\tcase \"sapIllus-Dialog") && !line.startsWith("\t\tcase \"sapIllus-Scene") && !line.startsWith("\t\tcase \"sapIllus-Spot") && !line.startsWith("\t\tcase \"AllIllustrations")).join("\n");
30
-
31
- // dynamic imports for Tnt illustrations
32
- const tntAvailableIllustrationsArray = `[${tntIllustrationsOnFileSystem.filter(
33
- // skipping the items starting with tnt-Dialog, tnt-Scene, tnt-Spot since they are included in the illustration's js file
34
- line => !line.startsWith("tnt-Dialog") && !line.startsWith("tnt-Scene") && !line.startsWith("tnt-Spot")).map(illustrationName => `"Tnt${illustrationName.replace('.js', '')}"`).join(", ")}]`;
35
-
36
- const tntDynamicImportLines = tntIllustrationsOnFileSystem.map(illustrationName =>
37
- `\t\tcase "Tnt${illustrationName.replace('.js', '')}": return (await import("../../illustrations/tnt/${illustrationName}")).default;`).filter(
38
- // skipping the items starting with tnt-Dialog, tnt-Scene, tnt-Spot since they are included in the illustration's js file
39
- line => !line.startsWith("\t\tcase \"Tnttnt-Dialog") && !line.startsWith("\t\tcase \"Tnttnt-Scene") && !line.startsWith("\t\tcase \"Tnttnt-Spot")).join("\n");
40
-
41
-
42
- // dynamic imports file content
43
- const contentDynamic = `import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
44
-
45
- const loadIllustration = async (illustrationName) => {
46
- switch (illustrationName) {
47
- ${fioriDynamicImportLines}
48
- ${tntDynamicImportLines}
49
- default: throw new Error("[Illustrations] Illustration not found: " + illustrationName);
50
- }
2
+ const path = require("path");
3
+
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(".js", "");
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");
14
+ };
15
+
16
+ const generateAvailableIllustrationsArray = (fileNames, exclusionPatterns = []) => {
17
+ return JSON.stringify(
18
+ fileNames
19
+ .filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
20
+ .map((fileName) => fileName.replace(".js", ""))
21
+ );
22
+ };
23
+
24
+ const generateDynamicImportsFileContent = (dynamicImports, availableIllustrations, collection, set, prefix = "") => {
25
+ return `// @ts-nocheck
26
+ import { registerIllustrationLoader } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
27
+
28
+ export const loadIllustration = async (illustrationName) => {
29
+ const collectionAndPrefix = "${set}/${collection}/${prefix}";
30
+ const cleanIllustrationName = illustrationName.startsWith(collectionAndPrefix) ? illustrationName.replace(collectionAndPrefix, "") : illustrationName;
31
+ switch (cleanIllustrationName) {
32
+ ${dynamicImports}
33
+ default:
34
+ throw new Error("[Illustrations] Illustration not found: " + illustrationName);
35
+ }
36
+ };
37
+
38
+ const loadAndCheck = async (illustrationName) => {
39
+ const data = await loadIllustration(illustrationName);
40
+ return data;
41
+ };
42
+
43
+ ${availableIllustrations}.forEach((illustrationName) =>
44
+ registerIllustrationLoader(\`${set}/${collection}/${prefix}\${illustrationName}\`, loadAndCheck)
45
+ );
46
+ `;
47
+ };
48
+
49
+ const getMatchingFiles = async (folder, pattern) => {
50
+ const dir = await fs.readdir(folder);
51
+ return dir.filter((fileName) => fileName.match(pattern));
51
52
  };
52
- const loadAndCheck = async (illustrationName) => {
53
- const data = await loadIllustration(illustrationName);
54
- return data;
55
- }
56
53
 
54
+ const generateIllustrations = async (config) => {
55
+ const { inputFolder, outputFile, collection, location, prefix, filterOut, set } = config;
56
+
57
+ const normalizedInputFolder = path.normalize(inputFolder);
58
+ const normalizedOutputFile = path.normalize(outputFile);
59
+
60
+ const illustrations = await getMatchingFiles(normalizedInputFolder, /^.*\.js$/);
57
61
 
58
- ${fioriAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));
59
- ${tntAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));`;
60
-
62
+ const dynamicImports = await generateDynamicImportLines(illustrations, location, filterOut);
63
+ const availableIllustrations = generateAvailableIllustrationsArray(illustrations, filterOut);
64
+
65
+ const contentDynamic = generateDynamicImportsFileContent(dynamicImports, availableIllustrations, collection, set, prefix);
66
+
67
+ await fs.mkdir(path.dirname(normalizedOutputFile), { recursive: true });
68
+ await fs.writeFile(normalizedOutputFile, contentDynamic);
69
+
70
+ console.log(`Generated ${normalizedOutputFile}`);
71
+ };
61
72
 
62
- await fs.mkdir(path.dirname(outputFile), { recursive: true });
63
- return Promise.all([fs.writeFile(outputFile, contentDynamic)]);
73
+ // Parse configuration from command-line arguments
74
+ const config = {
75
+ inputFolder: process.argv[2],
76
+ outputFile: process.argv[3],
77
+ set: process.argv[4],
78
+ collection: process.argv[5],
79
+ location: process.argv[6],
80
+ filterOut: process.argv.slice[7],
64
81
  };
65
82
 
66
- generate().then(() => {
67
- console.log("Generated Illustrations.js");
68
- })
69
- .catch(err => {
70
- console.error(err);
71
- process.exit(1);
83
+ // Run the generation process
84
+ generateIllustrations(config).catch((error) => {
85
+ console.error("Error generating illustrations:", error);
72
86
  });
@@ -1,13 +1,16 @@
1
1
  const fs = require("fs").promises;
2
2
  const path = require('path');
3
3
 
4
+ const isTypeScript = process.env.UI5_TS;
5
+ const ext = isTypeScript ? 'ts' : 'js';
6
+
4
7
  const generate = async () => {
5
8
 
6
9
  const packageName = JSON.parse(await fs.readFile("package.json")).name;
7
10
 
8
11
  const inputFolder = path.normalize(process.argv[2]);
9
- const outputFile = path.normalize(`${process.argv[3]}/i18n-static.js`);
10
- const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.js`);
12
+ const outputFile = path.normalize(`${process.argv[3]}/i18n-static.${ext}`);
13
+ const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
11
14
 
12
15
  // All languages present in the file system
13
16
  const files = await fs.readdir(inputFolder);
@@ -32,7 +35,8 @@ const generate = async () => {
32
35
  const assetsImportsString = languages.map(key => `import _${key} from "../assets/i18n/messagebundle_${key}.json";`).join("\n");
33
36
 
34
37
  // static imports
35
- contentStatic = `import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
38
+ contentStatic = `// @ts-nocheck
39
+ import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
36
40
 
37
41
  ${assetsImportsString}
38
42
 
@@ -56,10 +60,11 @@ localeIds.forEach(localeId => {
56
60
  `;
57
61
 
58
62
  // Actual imports for json assets
59
- const dynamicImportsString = languages.map(key => ` case "${key}": return (await import("../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
63
+ const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
60
64
 
61
65
  // Resulting file content
62
- contentDynamic = `import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
66
+ contentDynamic = `// @ts-nocheck
67
+ import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
63
68
 
64
69
  const importMessageBundle = async (localeId) => {
65
70
  switch (localeId) {
@@ -2,10 +2,13 @@ const fs = require("fs").promises;
2
2
  const path = require('path');
3
3
  const assets = require("../../assets-meta.js");
4
4
 
5
+ const isTypeScript = process.env.UI5_TS;
6
+ const ext = isTypeScript ? 'ts' : 'js';
7
+
5
8
  const generate = async () => {
6
9
  const inputFolder = path.normalize(process.argv[2]);
7
- const outputFile = path.normalize(`${process.argv[3]}/Themes-static.js`);
8
- const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.js`);
10
+ const outputFile = path.normalize(`${process.argv[3]}/Themes-static.${ext}`);
11
+ const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
9
12
 
10
13
  // All supported optional themes
11
14
  const allThemes = assets.themes.all;
@@ -22,11 +25,12 @@ const generate = async () => {
22
25
  const importLines = themesOnFileSystem.map(theme => `import ${theme} from "../assets/themes/${theme}/parameters-bundle.css.json";`).join("\n");
23
26
  const themeUrlsByName = "{\n" + themesOnFileSystem.join(",\n") + "\n}";
24
27
  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");
28
+ 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");
26
29
 
27
30
 
28
31
  // static imports file content
29
- const contentStatic = `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
32
+ const contentStatic = `// @ts-nocheck
33
+ import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
30
34
 
31
35
  ${importLines}
32
36
 
@@ -47,7 +51,8 @@ ${availableThemesArray}
47
51
 
48
52
 
49
53
  // dynamic imports file content
50
- const contentDynamic = `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
54
+ const contentDynamic = `// @ts-nocheck
55
+ import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
51
56
 
52
57
  const loadThemeProperties = async (themeName) => {
53
58
  switch (themeName) {
@@ -12,15 +12,17 @@ const removeWhiteSpaces = (source) => {
12
12
  .replace(/}}\s+{{/g, "}}{{"); // Remove whitespace between }} and {{
13
13
  };
14
14
 
15
- const hbs2lit = async (file) => {
15
+ const hbs2lit = async (file, componentName) => {
16
16
  let sPreprocessed = await includesReplacer.replace(file);
17
17
 
18
18
  sPreprocessed = removeWhiteSpaces(sPreprocessed);
19
19
 
20
+ const blockSignature = process.env.UI5_TS ? `this: ${componentName}` : ""
21
+
20
22
  // icons hack
21
23
  if (sPreprocessed.startsWith("<g ") || sPreprocessed.startsWith("<g>")) {
22
24
  return `
23
- let block0 = () => {
25
+ function block0 (${blockSignature}) {
24
26
  return svg\`${sPreprocessed}\`
25
27
  }`;
26
28
  }
@@ -28,7 +30,7 @@ const hbs2lit = async (file) => {
28
30
  const ast = Handlebars.parse(sPreprocessed);
29
31
 
30
32
  const pv = new PartialsVisitor();
31
- const lv = new HTMLLitVisitor();
33
+ const lv = new HTMLLitVisitor(componentName);
32
34
 
33
35
  let result = "";
34
36
 
@@ -41,10 +43,11 @@ const hbs2lit = async (file) => {
41
43
  let block = lv.blocks[key];
42
44
 
43
45
  if (block.match(/scopeTag/)) {
44
- const matches = block.match(/^(.*?)( => )(.*?);$/);
45
- const scopedCode = matches[3];
46
+ // const matches = block.match(/^(.*?)( => )(.*?);$/);
47
+ const matches = block.match(/^(function .*? \{ return )(.*?);\}$/);
48
+ const scopedCode = matches[2];
46
49
  const normalCode = scopedCode.replace(/\${scopeTag\("/g, "").replace(/", tags, suffix\)}/g, "");
47
- block = `${matches[1]}${matches[2]}suffix ? ${scopedCode} : ${normalCode};`;
50
+ block = `${matches[1]}suffix ? ${scopedCode} : ${normalCode};}`;
48
51
  }
49
52
 
50
53
  result += block + "\n";