@ui5/webcomponents-tools 1.24.0 → 2.0.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.
@@ -1,271 +0,0 @@
1
- const fs = require("fs").promises;
2
- const path = require("path");
3
- // https://github.com/webcomponents/custom-elements-manifest/blob/main/schema.json
4
-
5
- const inputDir = process.argv[2];
6
- const outputDir = process.argv[3];
7
-
8
- const moduleDeclarations = new Map();
9
-
10
- const generateJavaScriptExport = entity => {
11
- return {
12
- declaration: {
13
- name: entity.basename,
14
- module: `dist/${entity.resource}`,
15
- },
16
- kind: "js",
17
- name: "default",
18
- };
19
- };
20
-
21
- const generateCustomElementExport = entity => {
22
- if (!entity.tagname) return;
23
-
24
- return {
25
- declaration: {
26
- name: entity.basename,
27
- module: `dist/${entity.resource}`,
28
- },
29
- kind: "custom-element-definition",
30
- name: entity.basename,
31
- };
32
- };
33
-
34
- const generateSingleClassField = classField => {
35
- let generatedClassField = {
36
- kind: "field",
37
- name: classField.name,
38
- type: generateType(classField.type),
39
- privacy: classField.visibility,
40
- deprecated: !!classField.deprecated || undefined,
41
- static: !!classField.static || undefined,
42
- };
43
-
44
- if (classField.defaultValue) {
45
- generatedClassField.default = classField.defaultValue;
46
- }
47
-
48
- if (classField.description) {
49
- generatedClassField.description = classField.description;
50
- }
51
-
52
- return generatedClassField;
53
- };
54
-
55
- const generateSingleParameter = parameter => {
56
- let generatedParameter = {
57
- deprecated: !!parameter.deprecated || undefined,
58
- name: parameter.name,
59
- type: generateType(parameter.type),
60
- };
61
-
62
- if (parameter.description) {
63
- generatedParameter.description = parameter.description;
64
- }
65
-
66
- if (parameter.optional) {
67
- generatedParameter.optional = parameter.optional;
68
- generatedParameter.default = parameter.defaultValue;
69
- }
70
-
71
- return generatedParameter;
72
- };
73
-
74
- const generateParameters = (parameters) => {
75
- return parameters.reduce((newParametersArray, parameter) => {
76
- newParametersArray.push(generateSingleParameter(parameter));
77
-
78
- return newParametersArray;
79
- }, []);
80
- };
81
-
82
- const generateSingleClassMethod = classMethod => {
83
- let generatedClassMethod = {
84
- deprecated: !!classMethod.deprecated || undefined,
85
- kind: "method",
86
- name: classMethod.name,
87
- privacy: classMethod.visibility,
88
- static: classMethod.static,
89
- };
90
-
91
- if (classMethod.description) {
92
- generatedClassMethod.description = classMethod.description;
93
- }
94
-
95
- if (classMethod.parameters && classMethod.parameters.length) {
96
- generatedClassMethod.parameters = generateParameters(classMethod.parameters);
97
- }
98
-
99
- if (classMethod.returnValue) {
100
- generatedClassMethod.return = {
101
- type: generateType(classMethod.returnValue.type),
102
- };
103
-
104
- if (classMethod.returnValue.description) {
105
- generatedClassMethod.return.description = classMethod.returnValue.description;
106
- }
107
- }
108
-
109
- return generatedClassMethod;
110
- };
111
-
112
- const generateClassFields = classFields => {
113
- return classFields.reduce((newClassFieldsArray, classField) => {
114
- newClassFieldsArray.push(generateSingleClassField(classField));
115
-
116
- return newClassFieldsArray;
117
- }, []);
118
- };
119
-
120
- const generateClassMethods = classMethods => {
121
- return classMethods.reduce((newClassMethodsArray, classMethod) => {
122
- newClassMethodsArray.push(generateSingleClassMethod(classMethod));
123
-
124
- return newClassMethodsArray;
125
- }, []);
126
- };
127
-
128
- const generateMembers = (classFields, classMethods) => {
129
- return [...generateClassFields(classFields), ...generateClassMethods(classMethods)];
130
- };
131
-
132
- const generateType = type => {
133
- return {
134
- text: type,
135
- };
136
- };
137
-
138
- const generateSingleEvent = event => {
139
- let generatedEvent = {
140
- deprecated: !!event.deprecated || undefined,
141
- name: event.name,
142
- type: generateType(event.native === "true" ? "NativeEvent" : "CustomEvent")
143
- };
144
-
145
- if (event.description) {
146
- generatedEvent.description = event.description;
147
- }
148
-
149
- return generatedEvent;
150
- };
151
-
152
- const generateEvents = events => {
153
- events = events.reduce((newEventsArray, event) => {
154
- newEventsArray.push(generateSingleEvent(event));
155
-
156
- return newEventsArray;
157
- }, []);
158
-
159
- return events;
160
- };
161
-
162
- const generateSingleSlot = slot => {
163
- return {
164
- deprecated: !!slot.deprecated || undefined,
165
- description: slot.description,
166
- name: slot.name,
167
- };
168
- };
169
-
170
- const generateSlots = slots => {
171
- slots = slots.reduce((newSlotsArray, event) => {
172
- newSlotsArray.push(generateSingleSlot(event));
173
-
174
- return newSlotsArray;
175
- }, []);
176
-
177
- return slots;
178
- };
179
-
180
- const generateCustomElementDeclaration = entity => {
181
- let generatedCustomElementDeclaration = {
182
- deprecated: !!entity.deprecated || undefined,
183
- customElement: true,
184
- kind: entity.kind,
185
- name: entity.basename,
186
- tagName: entity.tagname,
187
- };
188
-
189
- const slots = filterPublicApi(entity.slots);
190
- const events = filterPublicApi(entity.events);
191
- const classFields = filterPublicApi(entity.properties);
192
- const classMethods = filterPublicApi(entity.methods);
193
-
194
- if (slots.length) {
195
- generatedCustomElementDeclaration.slots = generateSlots(slots);
196
- }
197
-
198
- if (events.length) {
199
- generatedCustomElementDeclaration.events = generateEvents(events);
200
- }
201
-
202
- if (entity.description) {
203
- generatedCustomElementDeclaration.description = entity.description;
204
- }
205
-
206
- if (classFields.length || classMethods.length) {
207
- generatedCustomElementDeclaration.members = generateMembers(classFields, classMethods);
208
- }
209
-
210
- if (entity.extends && entity.extends !== "HTMLElement") {
211
- generatedCustomElementDeclaration.superclass = generateRefenrece(entity.extends);
212
- }
213
-
214
- return generatedCustomElementDeclaration;
215
- };
216
-
217
- const generateRefenrece = (entityName) => {
218
- return {
219
- name: entityName,
220
- };
221
- };
222
-
223
- const filterPublicApi = array => {
224
- return (array || []).filter(el => el.visibility === "public");
225
- };
226
-
227
- const generate = async () => {
228
- const file = JSON.parse(await fs.readFile(path.join(inputDir, "api.json")));
229
- let customElementsManifest = {
230
- schemaVersion: "1.0.0",
231
- readme: "",
232
- modules: [],
233
- };
234
-
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));
252
- }
253
- });
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
-
266
- await fs.writeFile(path.join(outputDir, "custom-elements.json"), JSON.stringify(customElementsManifest));
267
- };
268
-
269
- generate().then(() => {
270
- console.log("Custom elements manifest generated.");
271
- });
@@ -1,29 +0,0 @@
1
- {
2
- "source": {
3
- "include": "src",
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
- }
@@ -1,29 +0,0 @@
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
- }