@ui5/webcomponents-tools 1.10.3 → 1.11.0-rc.0

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 CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.11.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.4-rc.0...v1.11.0-rc.0) (2023-02-02)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-tools
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.10.4-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.3...v1.10.4-rc.0) (2023-01-26)
15
+
16
+ **Note:** Version bump only for package @ui5/webcomponents-tools
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.10.3](https://github.com/SAP/ui5-webcomponents/compare/v1.10.2...v1.10.3) (2023-01-25)
7
23
 
8
24
  **Note:** Version bump only for package @ui5/webcomponents-tools
@@ -42,17 +42,17 @@ const getScripts = (options) => {
42
42
  }
43
43
 
44
44
  const scripts = {
45
- clean: 'rimraf jsdoc-dist && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
45
+ clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
46
46
  lint: `eslint . ${eslintConfig}`,
47
47
  lintfix: `eslint . ${eslintConfig}`,
48
48
  prepare: {
49
- default: "nps clean prepare.all generateAPI",
50
- all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps typescript" "nps build.illustrations"',
49
+ default: "nps clean prepare.all typescript generateAPI",
50
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
51
51
  styleRelated: "nps build.styles build.jsonImports build.jsImports",
52
52
  },
53
53
  typescript: tsCommand,
54
54
  build: {
55
- default: "nps lint prepare build.bundle",
55
+ default: "nps prepare lint build.bundle",
56
56
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
57
57
  styles: {
58
58
  default: "nps build.styles.themes build.styles.components",
@@ -61,7 +61,7 @@ const getScripts = (options) => {
61
61
  },
62
62
  i18n: {
63
63
  default: "nps build.i18n.defaultsjs build.i18n.json",
64
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
64
+ defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
65
65
  json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
66
66
  },
67
67
  jsonImports: {
@@ -120,8 +120,9 @@ const getScripts = (options) => {
120
120
  bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
121
121
  },
122
122
  generateAPI: {
123
- default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup",
123
+ default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest",
124
124
  prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
125
+ prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
125
126
  preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
126
127
  jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
127
128
  cleanup: "rimraf jsdoc-dist/"
@@ -43,13 +43,13 @@ const getScripts = (options) => {
43
43
  const copyAssetsCmd = copyIconAssetsCommand(options);
44
44
 
45
45
  const scripts = {
46
- clean: "rimraf dist",
46
+ clean: "rimraf dist && rimraf src/generated",
47
47
  copy: copyAssetsCmd,
48
48
  build: {
49
- default: `nps clean typescript copy build.i18n build.icons build.jsonImports`,
49
+ default: `nps clean copy build.i18n typescript build.icons build.jsonImports`,
50
50
  i18n: {
51
51
  default: "nps build.i18n.defaultsjs build.i18n.json",
52
- defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
52
+ defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
53
53
  json: `mkdirp dist/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
54
54
  },
55
55
  jsonImports: {
@@ -1,9 +1,12 @@
1
1
  const fs = require("fs").promises;
2
+ const path = require("path");
2
3
  // https://github.com/webcomponents/custom-elements-manifest/blob/main/schema.json
3
4
 
5
+ const inputDir = process.argv[2];
6
+ const outputDir = process.argv[3];
7
+
4
8
  const camelToKebabMap = new Map();
5
9
  const apiIndex = new Map();
6
- const processedApiIndex = new Set();
7
10
  const forbiddenAttributeTypes = ["object", "array"];
8
11
 
9
12
  const camelToKebabCase = string => {
@@ -16,7 +19,7 @@ const camelToKebabCase = string => {
16
19
 
17
20
  const generateJavaScriptExport = entity => {
18
21
  return {
19
- declaration: generateRefenrece(entity),
22
+ declaration: generateRefenrece(entity.name),
20
23
  deprecated: !!entity.deprecated,
21
24
  kind: "js",
22
25
  name: "default",
@@ -226,8 +229,6 @@ const generateSlots = slots => {
226
229
  };
227
230
 
228
231
  const generateCustomElementDeclaration = entity => {
229
- entity = generateFullComponentApi(entity);
230
-
231
232
  let generatedCustomElementDeclaration = {
232
233
  deprecated: !!entity.deprecated,
233
234
  customElement: true,
@@ -265,107 +266,60 @@ const generateCustomElementDeclaration = entity => {
265
266
  }
266
267
 
267
268
  if (entity.extends && entity.extends !== "HTMLElement") {
268
- generatedCustomElementDeclaration.superclass = generateRefenrece(apiIndex.get(entity.extends));
269
+ generatedCustomElementDeclaration.superclass = generateRefenrece(entity.extends);
269
270
  }
270
271
 
271
272
  return generatedCustomElementDeclaration;
272
273
  };
273
274
 
274
- const generateRefenrece = (entity) => {
275
+ const generateRefenrece = (entityName) => {
275
276
  let packageName;
277
+ let basename;
276
278
 
277
- if (!entity.name) {
279
+ if (!entityName) {
278
280
  throw new Error("JSDoc error: entity not found in api.json.");
279
281
  }
280
282
 
281
- if (entity.name.includes("sap.ui.webc.main")) {
283
+ if (entityName.includes(".")) {
284
+ basename = entityName.split(".").pop();
285
+ } else {
286
+ basename = entityName
287
+ }
288
+
289
+ if (entityName.includes("sap.ui.webc.main")) {
282
290
  packageName = "@ui5/webcomponents";
283
- } else if (entity.name.includes("sap.ui.webc.fiori")) {
291
+ } else if (entityName.includes("sap.ui.webc.fiori")) {
284
292
  packageName = "@ui5/webcomponents-fiori";
285
- } else if (entity.name.includes("sap.ui.webc.base")) {
293
+ } else if (entityName.includes("sap.ui.webc.base")) {
286
294
  packageName = "@ui5/webcomponents-base";
287
295
  }
288
296
 
289
297
  return {
290
- module: `${entity.module}.js`,
291
- name: `${entity.basename}`,
298
+ module: `${basename}.js`,
299
+ name: `${basename}`,
292
300
  package: packageName,
293
301
  };
294
302
  };
295
303
 
296
- const generateFullComponentApi = entity => {
297
- const componentProps = ["properties", "slots", "events", "methods"];
298
- let parent = apiIndex.get(entity.extends);
299
-
300
- if (!parent) {
301
- processedApiIndex.add(entity.name);
302
-
303
- return entity;
304
- }
305
-
306
- parent = processedApiIndex.has(entity.extends) ? apiIndex.get(entity.extends) : generateFullComponentApi(parent);
307
-
308
- componentProps.forEach(prop => {
309
- if (parent[prop] && parent[prop].length) {
310
- if (entity[prop] && entity[prop].length) {
311
- const uniqueParentState = parent[prop].filter(pSlot => {
312
- return !entity[prop].some(eSlot => eSlot.name === pSlot.name);
313
- });
314
-
315
- entity[prop] = entity[prop].concat(uniqueParentState);
316
- } else {
317
- entity[prop] = [...parent[prop]];
318
- }
319
- }
320
- });
321
-
322
- processedApiIndex.add(entity.name);
323
-
324
- return entity;
325
- };
326
-
327
304
  const filterPublicApi = array => {
328
305
  return (array || []).filter(el => el.visibility === "public");
329
306
  };
330
307
 
331
308
  const generate = async () => {
332
- const apiFilesPaths = [
333
- require.resolve("@ui5/webcomponents-base/dist/api.json"),
334
- require.resolve("@ui5/webcomponents/dist/api.json"),
335
- require.resolve("@ui5/webcomponents-fiori/dist/api.json"),
336
- ];
337
-
338
- let apiFiles = new Map();
339
-
340
- await Promise.all(apiFilesPaths.map(async (apiFilePath) => {
341
- const file = JSON.parse(await fs.readFile(apiFilePath));
342
-
343
- apiFiles.set(apiFilePath, file);
344
-
345
- file.symbols.forEach(symbol => {
346
- apiIndex.set(symbol.name, symbol);
347
- });
348
- }));
309
+ const file = JSON.parse(await fs.readFile(path.join(inputDir, "api.json")));
310
+ let customElementsManifest = {
311
+ schemaVersion: "1.0.0",
312
+ readme: "",
313
+ modules: [],
314
+ };
349
315
 
350
- await Promise.all(apiFilesPaths.map(async (apiFilePath) => {
351
- if (apiFilePath.includes("base")) {
352
- return;
316
+ file.symbols.forEach(entity => {
317
+ if (entity.tagname) {
318
+ customElementsManifest.modules.push(generateJavaScriptModule(entity));
353
319
  }
320
+ });
354
321
 
355
- let customElementsManifest = {
356
- schemaVersion: "1.0.0",
357
- readme: "",
358
- modules: [],
359
- };
360
-
361
- apiFiles.get(apiFilePath).symbols.forEach(entity => {
362
- if (entity.tagname) {
363
- customElementsManifest.modules.push(generateJavaScriptModule(entity));
364
- }
365
- });
366
-
367
- await fs.writeFile(apiFilePath.replace("api.json", "custom-elements.json"), JSON.stringify(customElementsManifest));
368
- }));
322
+ await fs.writeFile(path.join(outputDir, "custom-elements.json"), JSON.stringify(customElementsManifest));
369
323
  };
370
324
 
371
325
  generate().then(() => {
@@ -8,7 +8,7 @@ const generate = async () => {
8
8
 
9
9
  const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
10
10
  const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
11
- const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.js`);
11
+ const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.ts`);
12
12
 
13
13
  if (!messageBundle || !outputFile) {
14
14
  return;
@@ -45,7 +45,7 @@ const generate = async () => {
45
45
  let effectiveValue = defaultLanguageValue || value;
46
46
  effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
47
47
 
48
- return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
48
+ return `const ${key}: I18nText = {key: "${key}", defaultText: "${effectiveValue}"};`;
49
49
  };
50
50
 
51
51
  /*
@@ -62,7 +62,8 @@ const generate = async () => {
62
62
  const textKeys = Object.keys(properties);
63
63
  const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
64
64
 
65
- return `${texts}
65
+ return `import { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";
66
+ ${texts}
66
67
  export {${textKeys.join()}};`;
67
68
  };
68
69
 
@@ -4,15 +4,17 @@ const mkdirp = require('mkdirp');
4
4
  const assets = require("../../assets-meta.js");
5
5
 
6
6
  const DEFAULT_THEME = assets.themes.default;
7
+ const requiredImports = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";";
7
8
 
8
9
  const getDefaultThemeCode = packageName => {
9
10
  return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
11
+ ${requiredImports}
10
12
 
11
13
  import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
12
14
  import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
13
15
 
14
- registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
15
- registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
16
+ registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", async () => defaultThemeBase);
17
+ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", async () => defaultTheme);
16
18
  `;
17
19
  };
18
20
 
@@ -33,12 +35,12 @@ module.exports = function (opts) {
33
35
  let css = root.toString();
34
36
  css = proccessCSS(css);
35
37
 
36
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
38
+ const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/src/generated/").replace(`\\${opts.toReplace}\\`, "\\src\\generated\\");
37
39
  mkdirp.sync(path.dirname(targetFile));
38
40
 
39
- const filePath = `${targetFile}.js`;
40
- const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
41
-
41
+ const filePath = `${targetFile}.ts`;
42
+ const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : requiredImports;
43
+
42
44
  // it seems slower to read the old content, but writing the same content with no real changes
43
45
  // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
44
46
  let oldContent = "";
@@ -47,7 +49,11 @@ module.exports = function (opts) {
47
49
  } catch (e) {
48
50
  // file not found
49
51
  }
50
- const content = `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
52
+
53
+ const content = `${defaultTheme}
54
+ const styleData: StyleData = {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
55
+ export default styleData;
56
+ `;
51
57
  if (content !== oldContent) {
52
58
  fs.writeFileSync(filePath, content);
53
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "1.10.3",
3
+ "version": "1.11.0-rc.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -72,5 +72,5 @@
72
72
  "devDependencies": {
73
73
  "yargs": "^17.5.1"
74
74
  },
75
- "gitHead": "78222ac6ff90e19163d924b84ef405d39943e98d"
75
+ "gitHead": "6464abd79265425ce65232ebeee53cf6585e6ec6"
76
76
  }