@ui5/webcomponents-tools 0.0.0-e818f286e → 0.0.0-ee3bbe46b

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,62 @@
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.9.1](https://github.com/SAP/ui5-webcomponents/compare/v1.9.0...v1.9.1) (2022-11-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **framework:** fix paths for generating illustration imports in nps ([#5997](https://github.com/SAP/ui5-webcomponents/issues/5997)) ([e932f7d](https://github.com/SAP/ui5-webcomponents/commit/e932f7d069ebf10f73219bff7154558b7b0d849e))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.9.0](https://github.com/SAP/ui5-webcomponents/compare/v1.8.0...v1.9.0) (2022-10-31)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **framework:** fix contexts management in hbs-2-lit compiler ([#5958](https://github.com/SAP/ui5-webcomponents/issues/5958)) ([94d1619](https://github.com/SAP/ui5-webcomponents/commit/94d16199ed7dc79b21d99a0637533e93af54c90a)), closes [#4701](https://github.com/SAP/ui5-webcomponents/issues/4701)
23
+
24
+
25
+ ### Features
26
+
27
+ * **framework:** fetch illustrations on demand ([#5927](https://github.com/SAP/ui5-webcomponents/issues/5927)) ([f8e1033](https://github.com/SAP/ui5-webcomponents/commit/f8e1033643626261dcad8a38f65c325ba9aff99f))
28
+ * **framework:** generate custom elements manifest ([#5964](https://github.com/SAP/ui5-webcomponents/issues/5964)) ([0d62770](https://github.com/SAP/ui5-webcomponents/commit/0d62770cace54fd9aef73d9632dd06d8a83680e9))
29
+
30
+
31
+
32
+
33
+
34
+ # [1.8.0](https://github.com/SAP/ui5-webcomponents/compare/v1.7.1...v1.8.0) (2022-10-03)
35
+
36
+
37
+ ### Features
38
+
39
+ * **icons:** create type-definitions for icon imports ([#5753](https://github.com/SAP/ui5-webcomponents/issues/5753)) ([2de4a04](https://github.com/SAP/ui5-webcomponents/commit/2de4a045f56e2f166d3e846ff11e6f9d76e98009)), closes [#5747](https://github.com/SAP/ui5-webcomponents/issues/5747) [#5335](https://github.com/SAP/ui5-webcomponents/issues/5335)
40
+ * **main:** add support for custom SVG icons ([#5865](https://github.com/SAP/ui5-webcomponents/issues/5865)) ([d8b7200](https://github.com/SAP/ui5-webcomponents/commit/d8b7200f30c16d94b7f15ddbdf9808d8efbaa38c))
41
+
42
+
43
+
44
+
45
+
46
+ ## [1.7.1](https://github.com/SAP/ui5-webcomponents/compare/v1.7.0...v1.7.1) (2022-09-08)
47
+
48
+ **Note:** Version bump only for package @ui5/webcomponents-tools
49
+
50
+
51
+
52
+
53
+
54
+ # [1.7.0](https://github.com/SAP/ui5-webcomponents/compare/v1.6.0...v1.7.0) (2022-09-02)
55
+
56
+ **Note:** Version bump only for package @ui5/webcomponents-tools
57
+
58
+
59
+
60
+
61
+
6
62
  # [1.6.0](https://github.com/SAP/ui5-webcomponents/compare/v1.5.0...v1.6.0) (2022-07-25)
7
63
 
8
64
 
@@ -5,6 +5,34 @@ module.exports = {
5
5
  },
6
6
  "root": true,
7
7
  "extends": "airbnb-base",
8
+ overrides: [{
9
+ files: ["*.ts"],
10
+ parser: "@typescript-eslint/parser",
11
+ plugins: ["@typescript-eslint"],
12
+ extends: [
13
+ "plugin:@typescript-eslint/recommended",
14
+ "plugin:@typescript-eslint/recommended-requiring-type-checking"
15
+ ],
16
+ parserOptions: {
17
+ "project": ["./tsconfig.json", "./packages/*/tsconfig.json"],
18
+ },
19
+ /**
20
+ * Typescript Rules
21
+ */
22
+ rules: {
23
+ "no-shadow": "off",
24
+ "@typescript-eslint/no-shadow": ["error"],
25
+ "@typescript-eslint/no-unsafe-member-access": "off",
26
+ "@typescript-eslint/no-floating-promises": "off",
27
+ "@typescript-eslint/no-explicit-any": "off",
28
+ "@typescript-eslint/no-unsafe-assignment": "off",
29
+ "@typescript-eslint/ban-ts-comment": "off",
30
+ "@typescript-eslint/no-unsafe-call": "off",
31
+ "@typescript-eslint/no-non-null-assertion": "off",
32
+ "@typescript-eslint/no-empty-function": "off",
33
+ "lines-between-class-members": "off",
34
+ }
35
+ }],
8
36
  "parserOptions": {
9
37
  "ecmaVersion": 2018,
10
38
  "sourceType": "module"
@@ -1,13 +1,21 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
+ const resolve = require("resolve");
3
4
  const LIB = path.join(__dirname, `../lib/`);
4
-
5
+ const preprocessJSDocScript = resolve.sync("@ui5/webcomponents-tools/lib/jsdoc/preprocess.js");
5
6
 
6
7
  const getScripts = (options) => {
7
8
 
8
- let illustrations = options.illustrationsData || [];
9
- illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
10
- let illustrationsScript = illustrations.join(" && ");
9
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
10
+ const illustrationsData = options.illustrationsData || [];
11
+ illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
12
+ const createIllustrationsJSImportsScript = illustrations.join(" && ");
13
+
14
+ // The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
15
+ const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
16
+ const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
17
+ const tsCommand = options.typescript ? "tsc" : "";
18
+ const tsWatchCommand = options.typescript ? "tsc --watch" : "";
11
19
 
12
20
  let viteConfig;
13
21
  if (fs.existsSync("config/vite.config.js")) {
@@ -32,16 +40,17 @@ const getScripts = (options) => {
32
40
  // no custom configuration - use default from tools project
33
41
  eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
34
42
  }
35
-
43
+
36
44
  const scripts = {
37
- clean: 'rimraf dist && rimraf .port && nps "scope.testPages.clean"',
45
+ clean: 'rimraf jsdoc-dist && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
38
46
  lint: `eslint . ${eslintConfig}`,
39
47
  lintfix: `eslint . ${eslintConfig}`,
40
48
  prepare: {
41
- default: "nps clean prepare.all",
42
- all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.api" "nps build.illustrations"',
43
- styleRelated: "nps build.styles build.jsonImports",
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"',
51
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
44
52
  },
53
+ typescript: tsCommand,
45
54
  build: {
46
55
  default: "nps lint prepare build.bundle",
47
56
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
@@ -60,9 +69,12 @@ const getScripts = (options) => {
60
69
  themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
61
70
  i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
62
71
  },
72
+ jsImports: {
73
+ default: "mkdirp dist/generated/js-imports && nps build.jsImports.illustrationsLoaders",
74
+ illustrationsLoaders: createIllustrationsLoadersScript,
75
+ },
63
76
  bundle: `vite build ${viteConfig}`,
64
- api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
65
- illustrations: illustrationsScript
77
+ illustrations: createIllustrationsJSImportsScript,
66
78
  },
67
79
  copy: {
68
80
  default: "nps copy.src copy.props",
@@ -70,9 +82,10 @@ const getScripts = (options) => {
70
82
  props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
71
83
  },
72
84
  watch: {
73
- default: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.styles" "nps watch.i18n" "nps watch.props"',
85
+ default: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"',
74
86
  devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
75
87
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
88
+ typescript: tsWatchCommand,
76
89
  props: 'nps "copy.props --watch --safe --skip-initial-copy"',
77
90
  bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
78
91
  styles: {
@@ -85,7 +98,7 @@ const getScripts = (options) => {
85
98
  },
86
99
  },
87
100
  templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
88
- api: 'chokidar "test/**/*.sample.html" -c "nps build.api"',
101
+ api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
89
102
  i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
90
103
  },
91
104
  start: "nps prepare watch.devServer",
@@ -105,7 +118,14 @@ const getScripts = (options) => {
105
118
  watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
106
119
  watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
107
120
  bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
108
- }
121
+ },
122
+ generateAPI: {
123
+ default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup",
124
+ prepare: `copy-and-watch "dist/**/*.js" jsdoc-dist/`,
125
+ preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
126
+ jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
127
+ cleanup: "rimraf jsdoc-dist/"
128
+ },
109
129
  };
110
130
 
111
131
  return scripts;
@@ -217,6 +217,12 @@ exports.config = {
217
217
  }, this, className);
218
218
  }, true);
219
219
 
220
+ await browser.addCommand("hasAttribute", async function(attrName) {
221
+ return browser.executeAsync((elem, attrName, done) => {
222
+ done(elem.hasAttribute(attrName));
223
+ }, this, attrName);
224
+ }, true);
225
+
220
226
  await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
221
227
  return browser.executeAsync(async (selector, done) => {
222
228
  const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
@@ -238,6 +244,7 @@ exports.config = {
238
244
  "$",
239
245
  "$$",
240
246
  "getAttribute",
247
+ "hasAttribute", // custom
241
248
  "getCSSProperty",
242
249
  "getHTML",
243
250
  "getProperty",
@@ -46,7 +46,7 @@ const getScripts = (options) => {
46
46
  clean: "rimraf dist",
47
47
  copy: copyAssetsCmd,
48
48
  build: {
49
- default: `nps clean copy build.i18n build.icons build.jsonImports`,
49
+ default: `nps clean typescript copy build.i18n build.icons build.jsonImports`,
50
50
  i18n: {
51
51
  default: "nps build.i18n.defaultsjs build.i18n.json",
52
52
  defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
@@ -58,6 +58,7 @@ const getScripts = (options) => {
58
58
  },
59
59
  icons: createJSImportsCmd,
60
60
  },
61
+ typescript: "tsc",
61
62
  };
62
63
 
63
64
  return scripts;
@@ -3,7 +3,7 @@ const path = require("path");
3
3
 
4
4
  const fileList = process.argv[2];
5
5
  const dest = process.argv[3];
6
- const src = "../../node_modules/@openui5/sap.ui.core/src/";
6
+ const src = "@openui5/sap.ui.core/src/";
7
7
 
8
8
  const generate = async () => {
9
9
  const filesToCopy = (await fs.readFile(fileList)).toString();
@@ -15,7 +15,7 @@ const generate = async () => {
15
15
  const trimFile = file => file.trim();
16
16
 
17
17
  return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
18
- const srcPath = path.join(src, moduleName);
18
+ const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
19
19
  const destPath = path.join(dest, moduleName);
20
20
 
21
21
  await fs.mkdir(path.dirname(destPath), { recursive: true });
@@ -17,7 +17,7 @@ const packageName = "${packageName}";
17
17
 
18
18
  registerIcon(name, { pathData, ltr, collection, packageName });
19
19
 
20
- export default "${name}";
20
+ export default "${collection}/${name}";
21
21
  export { pathData, ltr, accData };`;
22
22
 
23
23
 
@@ -33,7 +33,7 @@ const packageName = "${packageName}";
33
33
 
34
34
  registerIcon(name, { pathData, ltr, accData, collection, packageName });
35
35
 
36
- export default "${name}";
36
+ export default "${collection}/${name}";
37
37
  export { pathData, ltr, accData };`;
38
38
 
39
39
 
@@ -48,6 +48,23 @@ export default "${name}";
48
48
  export { pathData, ltr, accData };`;
49
49
 
50
50
 
51
+ const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
52
+ declare const ltr: boolean;
53
+ declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
54
+ declare const _default: "${collection}/${name}";
55
+
56
+ export default _default;
57
+ export { pathData, ltr, accData };`
58
+
59
+ const collectionTypeDefinitionTemplate = (name, accData) => `declare const pathData: string;
60
+ declare const ltr: boolean;
61
+ declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
62
+ declare const _default: "${name}";
63
+
64
+ export default _default;
65
+ export { pathData, ltr, accData };`
66
+
67
+
51
68
  const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
52
69
  <path d="${pathData}"/>
53
70
  </svg>`;
@@ -68,9 +85,11 @@ const createIcons = async (file) => {
68
85
 
69
86
  promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
70
87
  promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
88
+ promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, json.collection)));
71
89
 
72
90
  if (json.version) {
73
91
  promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name)));
92
+ promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(name, acc)));
74
93
  }
75
94
  }
76
95
 
@@ -13,13 +13,13 @@ import ${componentName}Css from "./generated/themes/${componentName}.css.js";
13
13
  */
14
14
  const metadata = {
15
15
  tag: "${tagName}",
16
- properties: /** @lends sap.ui.webcomponents.${library}.${componentName}.prototype */ {
16
+ properties: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
17
17
  //
18
18
  },
19
- slots: /** @lends sap.ui.webcomponents.${library}.${componentName}.prototype */ {
19
+ slots: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
20
20
  //
21
21
  },
22
- events: /** @lends sap.ui.webcomponents.${library}.${componentName}.prototype */ {
22
+ events: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
23
23
  //
24
24
  },
25
25
  };
@@ -39,8 +39,8 @@ const metadata = {
39
39
  *
40
40
  * @constructor
41
41
  * @author SAP SE
42
- * @alias sap.ui.webcomponents.${library}.${componentName}
43
- * @extends UI5Element
42
+ * @alias sap.ui.webc.${library}.${componentName}
43
+ * @extends sap.ui.webc.base.UI5Element
44
44
  * @tagname ${tagName}
45
45
  * @public
46
46
  */
@@ -33,6 +33,7 @@ const virtualIndexPlugin = async () => {
33
33
  const folders = Object.keys(pagesPerFolder);
34
34
 
35
35
  res.statusCode = 200;
36
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
36
37
  res.end(`${folders.map(folder => {
37
38
  const pages = pagesPerFolder[folder];
38
39
  return `<h1>${folder}</h1>
@@ -0,0 +1,373 @@
1
+ const fs = require("fs").promises;
2
+ // https://github.com/webcomponents/custom-elements-manifest/blob/main/schema.json
3
+
4
+ const camelToKebabMap = new Map();
5
+ const apiIndex = new Map();
6
+ const processedApiIndex = new Set();
7
+ const forbiddenAttributeTypes = ["object", "array"];
8
+
9
+ const camelToKebabCase = string => {
10
+ if (!camelToKebabMap.has(string)) {
11
+ const result = string.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
12
+ camelToKebabMap.set(string, result);
13
+ }
14
+ return camelToKebabMap.get(string);
15
+ };
16
+
17
+ const generateJavaScriptExport = entity => {
18
+ return {
19
+ declaration: generateRefenrece(entity),
20
+ deprecated: !!entity.deprecated,
21
+ kind: "js",
22
+ name: "default",
23
+ };
24
+ };
25
+
26
+ const generateCustomElementExport = entity => {
27
+ return {
28
+ declaration: {
29
+ name: entity.basename,
30
+ module: `${entity.module}.js`,
31
+ },
32
+ deprecated: !!entity.deprecated,
33
+ kind: "custom-element-definition",
34
+ name: entity.tagname,
35
+ };
36
+ };
37
+
38
+ const generateJavaScriptModule = entity => {
39
+ return {
40
+ kind: "javascript-module",
41
+ path: `${entity.basename}.js`,
42
+ declarations: [
43
+ generateCustomElementDeclaration(entity),
44
+ ],
45
+ exports: [
46
+ generateJavaScriptExport(entity),
47
+ generateCustomElementExport(entity),
48
+ ],
49
+ };
50
+ };
51
+
52
+ const generateSingleClassField = classField => {
53
+ let generatedClassField = {
54
+ deprecated: !!classField.deprecated,
55
+ kind: "field",
56
+ name: classField.name,
57
+ privacy: classField.visibility,
58
+ static: !!classField.static,
59
+ type: generateType(classField.type),
60
+ };
61
+
62
+ if (classField.defaultValue) {
63
+ generatedClassField.default = classField.defaultValue;
64
+ }
65
+
66
+ if (classField.description) {
67
+ generatedClassField.description = classField.description;
68
+ }
69
+
70
+ return generatedClassField;
71
+ };
72
+
73
+ const generateSingleParameter = parameter => {
74
+ let generatedParameter = {
75
+ deprecated: !!parameter.deprecated,
76
+ name: parameter.name,
77
+ type: generateType(parameter.type),
78
+ };
79
+
80
+ if (parameter.description) {
81
+ generatedParameter.description = parameter.description;
82
+ }
83
+
84
+ if (parameter.optional) {
85
+ generatedParameter.optional = parameter.optional;
86
+ }
87
+
88
+ return generatedParameter;
89
+ };
90
+
91
+ const generateParameters = (parameters) => {
92
+ return parameters.reduce((newParametersArray, parameter) => {
93
+ newParametersArray.push(generateSingleParameter(parameter));
94
+
95
+ return newParametersArray;
96
+ }, []);
97
+ };
98
+
99
+ const generateSingleClassMethod = classMethod => {
100
+ let generatedClassMethod = {
101
+ deprecated: !!classMethod.deprecated,
102
+ kind: "method",
103
+ name: classMethod.name,
104
+ privacy: classMethod.visibility,
105
+ static: classMethod.static,
106
+ };
107
+
108
+ if (classMethod.description) {
109
+ generatedClassMethod.description = classMethod.description;
110
+ }
111
+
112
+ if (classMethod.parameters && classMethod.parameters.length) {
113
+ generatedClassMethod.parameters = generateParameters(classMethod.parameters);
114
+ }
115
+
116
+ if (classMethod.returnValue) {
117
+ generatedClassMethod.return = {
118
+ type: generateType(classMethod.returnValue.type),
119
+ };
120
+
121
+ if (classMethod.returnValue.description) {
122
+ generatedClassMethod.return.description = classMethod.returnValue.type;
123
+ }
124
+ }
125
+
126
+ return generatedClassMethod;
127
+ };
128
+
129
+ const generateClassFields = classFields => {
130
+ return classFields.reduce((newClassFieldsArray, classField) => {
131
+ newClassFieldsArray.push(generateSingleClassField(classField));
132
+
133
+ return newClassFieldsArray;
134
+ }, []);
135
+ };
136
+
137
+ const generateClassMethods = classMethods => {
138
+ return classMethods.reduce((newClassMethodsArray, classMethod) => {
139
+ newClassMethodsArray.push(generateSingleClassMethod(classMethod));
140
+
141
+ return newClassMethodsArray;
142
+ }, []);
143
+ };
144
+
145
+ const generateMembers = (classFields, classMethods) => {
146
+ return [...generateClassFields(classFields), ...generateClassMethods(classMethods)];
147
+ };
148
+
149
+ const generateType = type => {
150
+ const dataType = apiIndex.get(type);
151
+
152
+ return {
153
+ text: dataType && dataType.name.includes(".types.") ?
154
+ filterPublicApi(dataType.properties)
155
+ .map(prop => `"${prop.name}"`)
156
+ .join(" | ") : type,
157
+ };
158
+ };
159
+
160
+ const generateSingleAttribute = attribute => {
161
+ let generatedAttribute = {
162
+ default: attribute.defaultValue,
163
+ deprecated: !!attribute.deprecated,
164
+ fieldName: attribute.name,
165
+ name: camelToKebabCase(attribute.name),
166
+ type: generateType(attribute.type),
167
+ };
168
+
169
+ if (attribute.description) {
170
+ generatedAttribute.description = attribute.description;
171
+ }
172
+
173
+ return generatedAttribute;
174
+ };
175
+
176
+ const generateAttributes = attributes => {
177
+ attributes = attributes.reduce((newAttributesArray, attribute) => {
178
+ newAttributesArray.push(generateSingleAttribute(attribute));
179
+
180
+ return newAttributesArray;
181
+ }, []);
182
+
183
+ return attributes;
184
+ };
185
+
186
+ const generateSingleEvent = event => {
187
+ let generatedEvent = {
188
+ deprecated: !!event.deprecated,
189
+ name: event.name,
190
+ type: event.native === "true" ? "NativeEvent" : "CustomEvent",
191
+ };
192
+
193
+ if (event.description) {
194
+ generatedEvent.description = event.description;
195
+ }
196
+
197
+ return generatedEvent;
198
+ };
199
+
200
+ const generateEvents = events => {
201
+ events = events.reduce((newEventsArray, event) => {
202
+ newEventsArray.push(generateSingleEvent(event));
203
+
204
+ return newEventsArray;
205
+ }, []);
206
+
207
+ return events;
208
+ };
209
+
210
+ const generateSingleSlot = slot => {
211
+ return {
212
+ deprecated: !!slot.deprecated,
213
+ description: slot.description,
214
+ name: slot.name,
215
+ };
216
+ };
217
+
218
+ const generateSlots = slots => {
219
+ slots = slots.reduce((newSlotsArray, event) => {
220
+ newSlotsArray.push(generateSingleSlot(event));
221
+
222
+ return newSlotsArray;
223
+ }, []);
224
+
225
+ return slots;
226
+ };
227
+
228
+ const generateCustomElementDeclaration = entity => {
229
+ entity = generateFullComponentApi(entity);
230
+
231
+ let generatedCustomElementDeclaration = {
232
+ deprecated: !!entity.deprecated,
233
+ customElement: true,
234
+ kind: entity.basename,
235
+ name: entity.basename,
236
+ tagName: entity.tagname,
237
+ };
238
+
239
+ const slots = filterPublicApi(entity.slots);
240
+ const events = filterPublicApi(entity.events);
241
+ const classFields = filterPublicApi(entity.properties);
242
+ const classMethods = filterPublicApi(entity.methods);
243
+ const attributes = classFields.filter(property => {
244
+ return property.noattribute !== "true" && property.readonly !== "true" && !forbiddenAttributeTypes.includes(property.type.toLowerCase());
245
+ });
246
+
247
+ if (slots.length) {
248
+ generatedCustomElementDeclaration.slots = generateSlots(slots);
249
+ }
250
+
251
+ if (events.length) {
252
+ generatedCustomElementDeclaration.events = generateEvents(events);
253
+ }
254
+
255
+ if (attributes.length) {
256
+ generatedCustomElementDeclaration.attributes = generateAttributes(attributes);
257
+ }
258
+
259
+ if (entity.description) {
260
+ generatedCustomElementDeclaration.description = entity.description;
261
+ }
262
+
263
+ if (classFields.length || classMethods.length) {
264
+ generatedCustomElementDeclaration.members = generateMembers(classFields, classMethods);
265
+ }
266
+
267
+ if (entity.extends && entity.extends !== "HTMLElement") {
268
+ generatedCustomElementDeclaration.superclass = generateRefenrece(apiIndex.get(entity.extends));
269
+ }
270
+
271
+ return generatedCustomElementDeclaration;
272
+ };
273
+
274
+ const generateRefenrece = (entity) => {
275
+ let packageName;
276
+
277
+ if (!entity.name) {
278
+ throw new Error("JSDoc error: entity not found in api.json.");
279
+ }
280
+
281
+ if (entity.name.includes("sap.ui.webc.main")) {
282
+ packageName = "@ui5/webcomponents";
283
+ } else if (entity.name.includes("sap.ui.webc.fiori")) {
284
+ packageName = "@ui5/webcomponents-fiori";
285
+ } else if (entity.name.includes("sap.ui.webc.base")) {
286
+ packageName = "@ui5/webcomponents-base";
287
+ }
288
+
289
+ return {
290
+ module: `${entity.module}.js`,
291
+ name: `${entity.basename}`,
292
+ package: packageName,
293
+ };
294
+ };
295
+
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
+ const filterPublicApi = array => {
328
+ return (array || []).filter(el => el.visibility === "public");
329
+ };
330
+
331
+ 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
+ }));
349
+
350
+ await Promise.all(apiFilesPaths.map(async (apiFilePath) => {
351
+ if (apiFilePath.includes("base")) {
352
+ return;
353
+ }
354
+
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
+ }));
369
+ };
370
+
371
+ generate().then(() => {
372
+ console.log("Custom elements manifest generated.");
373
+ });
@@ -0,0 +1,72 @@
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
+ }
51
+ };
52
+ const loadAndCheck = async (illustrationName) => {
53
+ const data = await loadIllustration(illustrationName);
54
+ return data;
55
+ }
56
+
57
+
58
+ ${fioriAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));
59
+ ${tntAvailableIllustrationsArray}.forEach(illustrationName => registerIllustrationLoader(illustrationName, loadAndCheck));`;
60
+
61
+
62
+ await fs.mkdir(path.dirname(outputFile), { recursive: true });
63
+ return Promise.all([fs.writeFile(outputFile, contentDynamic)]);
64
+ };
65
+
66
+ generate().then(() => {
67
+ console.log("Generated Illustrations.js");
68
+ })
69
+ .catch(err => {
70
+ console.error(err);
71
+ process.exit(1);
72
+ });
@@ -17,6 +17,14 @@ const hbs2lit = async (file) => {
17
17
 
18
18
  sPreprocessed = removeWhiteSpaces(sPreprocessed);
19
19
 
20
+ // icons hack
21
+ if (sPreprocessed.startsWith("<g ") || sPreprocessed.startsWith("<g>")) {
22
+ return `
23
+ let block0 = () => {
24
+ return svg\`${sPreprocessed}\`
25
+ }`;
26
+ }
27
+
20
28
  const ast = Handlebars.parse(sPreprocessed);
21
29
 
22
30
  const pv = new PartialsVisitor();
@@ -34,7 +34,7 @@ function HTMLLitVisitor(debug) {
34
34
  this.blocks = {};
35
35
  this.result = "";
36
36
  this.mainBlock = "";
37
- this.blockPath = "context";
37
+ this.blockLevel = 0;
38
38
  this.blockParameters = ["context", "tags", "suffix"];
39
39
  this.paths = []; //contains all normalized relative paths
40
40
  this.debug = debug;
@@ -57,7 +57,6 @@ HTMLLitVisitor.prototype.Program = function(program) {
57
57
  this.blocks[this.prevKey()] += this.currentKey() + "(" + this.blockParameters.join(", ") + ")";
58
58
  } else {
59
59
  this.mainBlock = this.currentKey();
60
- this.paths.push(this.blockPath);
61
60
  }
62
61
 
63
62
  this.blocks[this.currentKey()] += "html`";
@@ -173,7 +172,7 @@ function visitEachBlock(block) {
173
172
 
174
173
  this.blocks[this.currentKey()] += "${ repeat(" + normalizePath.call(this, block.params[0].original) + ", (item, index) => item._id || index, (item, index) => ";
175
174
  this.paths.push(normalizePath.call(this, block.params[0].original));
176
- this.blockPath = "item";
175
+ this.blockLevel++;
177
176
 
178
177
  if (this.blockParameters.indexOf("item") === -1) {
179
178
  bParamAdded = true;
@@ -185,8 +184,7 @@ function visitEachBlock(block) {
185
184
  this.blockParameters.shift("item");
186
185
  this.blockParameters.shift("index");
187
186
  }
188
- this.blockPath = "context";
189
-
187
+ this.blockLevel--;
190
188
  this.blocks[this.currentKey()] += ") }";
191
189
  }
192
190
 
@@ -195,12 +193,52 @@ function normalizePath(sPath) {
195
193
 
196
194
  //read carefully - https://github.com/wycats/handlebars.js/issues/1028
197
195
  //kpdecker commented on May 20, 2015
198
- if (result.indexOf("../") === 0) {
199
- let absolutePath = replaceAll(this.paths[this.paths.length - 1], ".", "/") + "/" + result;
196
+
197
+ if (result.indexOf("@root") === 0) {
198
+ // Trying to access root context via the HBS "@root" variable.
199
+ // Example: {{@root.property}} compiles to "context.property" - called from anywhere within the template.
200
+ result = result.replace("@root", "context");
201
+
202
+ } else if (result.indexOf("../") === 0) {
203
+ let absolutePath;
204
+ const levelsUp = (result.match(/..\//g) || []).length;
205
+
206
+ if (this.blockLevel <= levelsUp) {
207
+ // Trying to access root context from nested loops.
208
+ // Example: {{../../property}} compiles to "context.property" - when currently in a nested level loop.
209
+ // Example: {{../../../property}} compile to "context.property" - when requested levels are not present. fallback to root context.
210
+ absolutePath = `context.${replaceAll(result,"../", "")}`;
211
+ } else {
212
+ // Trying to access upper context (one-level-up) and based on the current lelev, that could be "context" or "item".
213
+ // Example: {{../property}} compiles to "context.property" - when called in a top level loop.
214
+ // Example: {{../property}} compiles to "item.property" - when called in a nested level loop.
215
+ // TODO: the second example, although correctly generated to "item.property", "item" will point to the current object within the nested loop,
216
+ // not the upper level loop as intended. So accessing the upper loop from nested loop is currently not working.
217
+ absolutePath = replaceAll(this.paths[this.paths.length - 1 - levelsUp], ".", "/") + "/" + result;
218
+ }
219
+
200
220
  result = replaceAll(path.normalize(absolutePath), path.sep, ".");
221
+
201
222
  } else {
202
- result = result ? replaceAll(this.blockPath + "/" + result, "/", ".") : this.blockPath;
223
+ // When neither "@root", nor "../" are used, use the following contexts:
224
+ // - use "context" - for the top level of execution, e.g "this.blockLevel = 0".
225
+ // - use "item" - for any nested level, e.g "this.blockLevel > 0".
226
+ // Example:
227
+ //
228
+ // {{text}} -> compiles to "context.text"
229
+ // {{#each items}}
230
+ // Item text: {{text}}</div> -> compiles to "item.text"
231
+ // {{#each words}}
232
+ // Word text: {{text}}</div> -> compiles to "item.text"
233
+ // {{/each}}
234
+ // Item text: {{text}}</div> -> compiles to "item.text"
235
+ // {{/each}}
236
+ // {{text}} -> compiles to "context.text"
237
+
238
+ const blockPath = this.blockLevel > 0 ? "item" : "context";
239
+ result = result ? replaceAll(blockPath + "/" + result, "/", ".") : blockPath;
203
240
  }
241
+
204
242
  return result;
205
243
  }
206
244
 
@@ -22,6 +22,15 @@ const generate = async () => {
22
22
  } catch (e) {
23
23
  }
24
24
 
25
+ // Merge messagebundle.properties and messagebundle_en.properties files to generate the default texts.
26
+ // Note:
27
+ // (1) at DEV time, it's intuituve to work with the source bundle file - the messagebundle.properties,
28
+ // and see the changes there take effect.
29
+ // (2) as the messagebundle.properties file is always written in English,
30
+ // it makes sense to consider the messagebundle.properties content only when the default language is "en".
31
+ if (defaultLanguage === "en") {
32
+ defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
33
+ }
25
34
 
26
35
  /*
27
36
  * Returns the single text object to enable single export.
@@ -0,0 +1,29 @@
1
+ {
2
+ "source": {
3
+ "include": "jsdoc-dist",
4
+ "excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
5
+ },
6
+ "opts" : {
7
+ "recurse": true,
8
+ "template" : "template",
9
+ "destination": ""
10
+ },
11
+ "plugins": [
12
+ "./plugin.js"
13
+ ],
14
+ "templates" : {
15
+ "ui5" : {
16
+ "variants": [
17
+ "apijson"
18
+ ],
19
+ "version": "1.62",
20
+ "apiJsonFolder": "",
21
+ "apiJsonFile": "dist/api.json",
22
+ "includeSettingsInConstructor": false
23
+ }
24
+ },
25
+ "tags": {
26
+ "allowUnknownTags": true,
27
+ "dictionaries": ["jsdoc"]
28
+ }
29
+ }
@@ -34,6 +34,10 @@
34
34
  * native
35
35
  *
36
36
  * noattribute
37
+ *
38
+ * formEvents
39
+ *
40
+ * formProperty
37
41
  *
38
42
  * allowPreventDefault
39
43
  *
@@ -2108,6 +2112,34 @@ exports.defineTags = function(dictionary) {
2108
2112
  doclet.noattribute = true;
2109
2113
  }
2110
2114
  });
2115
+
2116
+ dictionary.defineTag('formEvents', {
2117
+ mustHaveValue: false,
2118
+ onTagged: function(doclet, tag) {
2119
+ if (tag.value) {
2120
+ doclet.formEvents = doclet.formEvents || [];
2121
+ tag.value.split(" ").forEach(function($) {
2122
+ if ( doclet.formEvents.indexOf($) < 0 ) {
2123
+ doclet.formEvents.push($);
2124
+ }
2125
+ });
2126
+ }
2127
+ }
2128
+ });
2129
+
2130
+ dictionary.defineTag('formProperty', {
2131
+ mustHaveValue: false,
2132
+ onTagged: function(doclet, tag) {
2133
+ doclet.formProperty = true;
2134
+ }
2135
+ });
2136
+
2137
+ dictionary.defineTag('formAssociated', {
2138
+ mustHaveValue: false,
2139
+ onTagged: function(doclet, tag) {
2140
+ doclet.formAssociated = doclet.formAssociated || true;
2141
+ }
2142
+ });
2111
2143
  };
2112
2144
 
2113
2145
  exports.handlers = {
@@ -0,0 +1,147 @@
1
+ const process = require("process");
2
+ const path = require("path");
3
+ const fs = require("fs/promises");
4
+
5
+ const inputDir = process.argv[2];
6
+ const sourceDir = process.argv[3];
7
+
8
+ const preprocessTypes = async () => {
9
+ try {
10
+ const { globby } = await import("globby");
11
+ const fileNames = await globby(inputDir + "**/types/*.js");
12
+
13
+ return Promise.all(fileNames.map(processTypeFile));
14
+ } catch(e) {
15
+ console.log("JSDoc types preprocess failed: ", e);
16
+ }
17
+ };
18
+
19
+ const processTypeFile = async (fileName) => {
20
+ let fileContent = `${await fs.readFile(fileName)}`;
21
+
22
+ const re = new RegExp(`(\\/\\*\\*\\s*\\n([^\\*]|(\\*(?!\\/)))*\\*\\/)\\s+[\\w\\d]+\\[\\"([\\w\\d]+)\\"\\]\\s*=\\s*\\"([\\w\\d]+)\\";`, "gm")
23
+ let matches = [...fileContent.matchAll(re)];
24
+
25
+ // Get all type values
26
+ const typeData = matches.map(match => {
27
+ return {
28
+ comment: match[1],
29
+ key: match[4],
30
+ value: match[5],
31
+ };
32
+ });
33
+ if (typeData.length === 0) {
34
+ return;
35
+ }
36
+
37
+ const typeName = path.parse(fileName).name;
38
+
39
+ matches = fileContent.match(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\//gm);
40
+ const comment = matches[0];
41
+
42
+ const propsCode = typeData.map(item => {
43
+ return `${item.comment}\n get ${item.key}() { return "${item.value}"; }`;
44
+ }).join("\n");
45
+
46
+ const newClassCode = `
47
+ ${comment}
48
+ class ${typeName} {
49
+ ${propsCode}
50
+ };
51
+
52
+ export default ${typeName};`;
53
+
54
+ fileContent = newClassCode;
55
+
56
+ return fs.writeFile(fileName, fileContent);
57
+ };
58
+
59
+ const preprocessComponents = async () => {
60
+ if (!sourceDir) {
61
+ return; // if the second param was not passed, there are no components
62
+ }
63
+
64
+ try {
65
+ const { globby } = await import("globby");
66
+ const fileNames = await globby(sourceDir + "/*.ts");
67
+
68
+ return Promise.all(fileNames.map(processComponentFile));
69
+ } catch(e) {
70
+ console.log("JSDoc components preprocess failed: ", e);
71
+ }
72
+ };
73
+
74
+ const isClass = text => {
75
+ return text.includes("@abstract") || text.includes("@class");
76
+ };
77
+
78
+ const isAnnotationComment = (comment, fileContent) => {
79
+ const index = fileContent.indexOf(comment);
80
+ return fileContent.substr(index + comment.length).trim().charAt(0) === "@";
81
+ }
82
+
83
+ const processComponentFile = async (fileName) => {
84
+ // source file (src/*.ts)
85
+ let tsFileContent = `${await fs.readFile(fileName)}`;
86
+
87
+ // Skip all non-component files
88
+ if (!isClass(tsFileContent)) {
89
+ return;
90
+ }
91
+
92
+ // Gather all JSDocs from the original .ts file
93
+ const allJSDocsRegExp = new RegExp(`\\/\\*\\*(.|\\n)+?\\s+\\*\\/`, "gm");
94
+ let allJSDocs = [...tsFileContent.matchAll(allJSDocsRegExp)];
95
+ allJSDocs = allJSDocs.map(match => match[0]); // all /** ..... */ comments
96
+
97
+ // Find where the class is defined in the original file
98
+ const tsClassDefinitionRegExp = new RegExp(`^class [\\w\\d_]+`, "gm");
99
+ let tsClassDefinitionMatch = tsFileContent.match(tsClassDefinitionRegExp);
100
+ if (!tsClassDefinitionMatch) {
101
+ return; // no class defined in this .ts file
102
+ }
103
+ const tsClassDefinition = tsClassDefinitionMatch[0];
104
+ const tsClassDefinitionIndex = tsFileContent.indexOf(tsClassDefinition);
105
+
106
+ // Gather all JSDocs that are before the class definition (except for the @class one)
107
+ const JSDocsToAppend = [];
108
+ allJSDocs.forEach(JSDoc => {
109
+ if (!isClass(JSDoc) && (tsFileContent.indexOf(JSDoc) < tsClassDefinitionIndex || isAnnotationComment(JSDoc, tsFileContent))) {
110
+ JSDocsToAppend.push(JSDoc);
111
+ }
112
+ });
113
+
114
+
115
+
116
+ // destination file (jsdoc-dist/*.js)
117
+ const destFileName = fileName.replace(sourceDir, inputDir).replace(/\.ts$/, ".js");
118
+ let jsFileContent = `${await fs.readFile(destFileName)}`;
119
+
120
+ const classDefinitionRegExp = new RegExp(`let.*? = class`, "gm");
121
+ let classDefinitionMatch = jsFileContent.match(classDefinitionRegExp);
122
+ if (!classDefinitionMatch) {
123
+ return; // not a file, generated by typescript, nothing to do here
124
+ }
125
+
126
+ const classDefinition = classDefinitionMatch[0];
127
+ const classDefinitionIndex = jsFileContent.indexOf(classDefinition); // classDefinitionIndex is the position in the file where the class is defined
128
+
129
+ // All comments before the class definition, except for the @class comment, must be removed
130
+ allJSDocs.forEach(JSDoc => {
131
+ if (!isClass(JSDoc) && jsFileContent.indexOf(JSDoc) < classDefinitionIndex) {
132
+ jsFileContent = jsFileContent.replace(JSDoc, "");
133
+ }
134
+ });
135
+
136
+ // Put all other comments at the end of the file
137
+ jsFileContent = jsFileContent + "\n\n" + JSDocsToAppend.join("\n\n");
138
+ return fs.writeFile(destFileName, jsFileContent);
139
+ };
140
+
141
+ Promise.all([
142
+ preprocessTypes(),
143
+ preprocessComponents(),
144
+ ]).then(() => {
145
+ console.log("JSDoc preprocess ready.");
146
+ });
147
+
@@ -2820,6 +2820,14 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2820
2820
  attrib("since", extractVersion(member.since));
2821
2821
  }
2822
2822
 
2823
+ if ( member.formEvents ) {
2824
+ attrib("formEvents", member.formEvents);
2825
+ }
2826
+
2827
+ if ( member.formEvents ) {
2828
+ attrib("formProperty", member.formProperty);
2829
+ }
2830
+
2823
2831
  var type = listTypes(member.type);
2824
2832
  attrib("type", type);
2825
2833
 
@@ -3865,7 +3873,7 @@ function createAPIJS(symbols, filename) {
3865
3873
 
3866
3874
  var output = [];
3867
3875
 
3868
- var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
3876
+ var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|formEvents|formProperty|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
3869
3877
 
3870
3878
  function isNoKeyword($) { return !rkeywords.test($.name); }
3871
3879
 
@@ -8,18 +8,11 @@ const getTag = file => {
8
8
  return matches ? matches[1] : undefined;
9
9
  };
10
10
 
11
- const getAltTag = file => {
12
- const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
13
- const matches = fileContent.match(/\baltTag\b:\s*\"(.*?)\"/);
14
- return matches ? matches[1] : undefined;
15
- };
16
-
17
11
  const getPackageTags = (packageDir) => {
18
12
  const srcDir = path.join(packageDir, "src/");
19
13
  return glob.sync(path.join(srcDir, "/**/*.js")).flatMap(file => {
20
14
  const tag = getTag(file);
21
- const altTag = getAltTag(file);
22
- return [tag, altTag];
15
+ return [tag];
23
16
  }).filter(item => !!item);
24
17
  };
25
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-e818f286e",
3
+ "version": "0.0.0-ee3bbe46b",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,6 +21,8 @@
21
21
  "directory": "packages/tools"
22
22
  },
23
23
  "dependencies": {
24
+ "@typescript-eslint/eslint-plugin": "^5.42.1",
25
+ "@typescript-eslint/parser": "^5.42.1",
24
26
  "@wdio/cli": "^7.19.7",
25
27
  "@wdio/devtools-service": "^7.19.7",
26
28
  "@wdio/dot-reporter": "^7.19.7",