@ui5/webcomponents-tools 1.10.4-rc.0 → 1.10.5
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,7 +3,15 @@
|
|
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.10.
|
6
|
+
## [1.10.5](https://github.com/SAP/ui5-webcomponents/compare/v1.10.4...v1.10.5) (2023-02-24)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.10.4](https://github.com/SAP/ui5-webcomponents/compare/v1.10.3...v1.10.4) (2023-02-15)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
17
|
|
@@ -120,9 +120,8 @@ 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",
|
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`,
|
126
125
|
preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
|
127
126
|
jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
|
128
127
|
cleanup: "rimraf jsdoc-dist/"
|
@@ -1,12 +1,9 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
|
-
const path = require("path");
|
3
2
|
// https://github.com/webcomponents/custom-elements-manifest/blob/main/schema.json
|
4
3
|
|
5
|
-
const inputDir = process.argv[2];
|
6
|
-
const outputDir = process.argv[3];
|
7
|
-
|
8
4
|
const camelToKebabMap = new Map();
|
9
5
|
const apiIndex = new Map();
|
6
|
+
const processedApiIndex = new Set();
|
10
7
|
const forbiddenAttributeTypes = ["object", "array"];
|
11
8
|
|
12
9
|
const camelToKebabCase = string => {
|
@@ -19,7 +16,7 @@ const camelToKebabCase = string => {
|
|
19
16
|
|
20
17
|
const generateJavaScriptExport = entity => {
|
21
18
|
return {
|
22
|
-
declaration: generateRefenrece(entity
|
19
|
+
declaration: generateRefenrece(entity),
|
23
20
|
deprecated: !!entity.deprecated,
|
24
21
|
kind: "js",
|
25
22
|
name: "default",
|
@@ -229,6 +226,8 @@ const generateSlots = slots => {
|
|
229
226
|
};
|
230
227
|
|
231
228
|
const generateCustomElementDeclaration = entity => {
|
229
|
+
entity = generateFullComponentApi(entity);
|
230
|
+
|
232
231
|
let generatedCustomElementDeclaration = {
|
233
232
|
deprecated: !!entity.deprecated,
|
234
233
|
customElement: true,
|
@@ -266,60 +265,107 @@ const generateCustomElementDeclaration = entity => {
|
|
266
265
|
}
|
267
266
|
|
268
267
|
if (entity.extends && entity.extends !== "HTMLElement") {
|
269
|
-
generatedCustomElementDeclaration.superclass = generateRefenrece(entity.extends);
|
268
|
+
generatedCustomElementDeclaration.superclass = generateRefenrece(apiIndex.get(entity.extends));
|
270
269
|
}
|
271
270
|
|
272
271
|
return generatedCustomElementDeclaration;
|
273
272
|
};
|
274
273
|
|
275
|
-
const generateRefenrece = (
|
274
|
+
const generateRefenrece = (entity) => {
|
276
275
|
let packageName;
|
277
|
-
let basename;
|
278
276
|
|
279
|
-
if (!
|
277
|
+
if (!entity.name) {
|
280
278
|
throw new Error("JSDoc error: entity not found in api.json.");
|
281
279
|
}
|
282
280
|
|
283
|
-
if (
|
284
|
-
basename = entityName.split(".").pop();
|
285
|
-
} else {
|
286
|
-
basename = entityName
|
287
|
-
}
|
288
|
-
|
289
|
-
if (entityName.includes("sap.ui.webc.main")) {
|
281
|
+
if (entity.name.includes("sap.ui.webc.main")) {
|
290
282
|
packageName = "@ui5/webcomponents";
|
291
|
-
} else if (
|
283
|
+
} else if (entity.name.includes("sap.ui.webc.fiori")) {
|
292
284
|
packageName = "@ui5/webcomponents-fiori";
|
293
|
-
} else if (
|
285
|
+
} else if (entity.name.includes("sap.ui.webc.base")) {
|
294
286
|
packageName = "@ui5/webcomponents-base";
|
295
287
|
}
|
296
288
|
|
297
289
|
return {
|
298
|
-
module: `${
|
299
|
-
name: `${basename}`,
|
290
|
+
module: `${entity.module}.js`,
|
291
|
+
name: `${entity.basename}`,
|
300
292
|
package: packageName,
|
301
293
|
};
|
302
294
|
};
|
303
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
|
+
|
304
327
|
const filterPublicApi = array => {
|
305
328
|
return (array || []).filter(el => el.visibility === "public");
|
306
329
|
};
|
307
330
|
|
308
331
|
const generate = async () => {
|
309
|
-
const
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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));
|
315
342
|
|
316
|
-
|
317
|
-
|
318
|
-
|
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;
|
319
353
|
}
|
320
|
-
});
|
321
354
|
|
322
|
-
|
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
|
+
}));
|
323
369
|
};
|
324
370
|
|
325
371
|
generate().then(() => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.10.
|
3
|
+
"version": "1.10.5",
|
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": "
|
75
|
+
"gitHead": "80761cf0065e72e98596c20c4136e4113d96386a"
|
76
76
|
}
|