@ui5/webcomponents-tools 0.0.0-ec448881d → 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 +86 -0
- package/README.md +5 -6
- package/bin/dev.js +1 -5
- package/components-package/eslint.js +28 -0
- package/components-package/nps.js +71 -42
- package/components-package/vite.config.js +12 -0
- package/components-package/wdio.js +28 -4
- package/components-package/wdio.sync.js +1 -1
- package/icons-collection/nps.js +2 -1
- package/lib/copy-list/index.js +2 -2
- package/lib/create-icons/index.js +21 -2
- package/lib/create-new-component/index.js +5 -5
- package/lib/dev-server/dev-server.js +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +53 -0
- package/lib/generate-custom-elements-manifest/index.js +373 -0
- package/lib/generate-js-imports/illustrations.js +72 -0
- package/lib/generate-json-imports/themes.js +3 -3
- package/lib/hbs2lit/src/compiler.js +8 -0
- package/lib/hbs2lit/src/litVisitor2.js +46 -8
- package/lib/i18n/defaults.js +9 -0
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +32 -0
- package/lib/jsdoc/preprocess.js +147 -0
- package/lib/jsdoc/template/publish.js +9 -1
- package/lib/postcss-css-to-esm/index.js +13 -1
- package/lib/postcss-css-to-json/index.js +12 -1
- package/lib/postcss-p/postcss-p.mjs +3 -0
- package/lib/scoping/get-all-tags.js +1 -8
- package/lib/scoping/scope-test-pages.js +1 -1
- package/lib/test-runner/test-runner.js +63 -0
- package/package.json +15 -16
- package/components-package/rollup-plugins/empty-module.js +0 -15
- package/components-package/rollup.js +0 -150
- package/lib/documentation/index.js +0 -168
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -42
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -39
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
@@ -0,0 +1,53 @@
|
|
1
|
+
let path = require("path");
|
2
|
+
|
3
|
+
const virtualIndexPlugin = async () => {
|
4
|
+
const { globby } = await import("globby");
|
5
|
+
const files = await globby(["test/pages/**/*.html", "packages/*/test/pages/**/*.html"]);
|
6
|
+
|
7
|
+
const pagesPerFolder = {};
|
8
|
+
files.forEach(file => {
|
9
|
+
let folder = pagesPerFolder[path.dirname(file)] = pagesPerFolder[path.dirname(file)] || [];
|
10
|
+
folder.push(path.basename(file));
|
11
|
+
});
|
12
|
+
|
13
|
+
const rollupInput = {};
|
14
|
+
|
15
|
+
files.forEach(file => {
|
16
|
+
rollupInput[file] = path.resolve(process.cwd(), file);
|
17
|
+
})
|
18
|
+
|
19
|
+
return {
|
20
|
+
name: 'virtual-index-html',
|
21
|
+
config() {
|
22
|
+
return {
|
23
|
+
build: {
|
24
|
+
rollupOptions: {
|
25
|
+
input: rollupInput
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
configureServer(server) {
|
31
|
+
server.middlewares.use((req, res, next) => {
|
32
|
+
if (req.url === "/") {
|
33
|
+
const folders = Object.keys(pagesPerFolder);
|
34
|
+
|
35
|
+
res.statusCode = 200;
|
36
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
37
|
+
res.end(`${folders.map(folder => {
|
38
|
+
const pages = pagesPerFolder[folder];
|
39
|
+
return `<h1>${folder}</h1>
|
40
|
+
${pages.map(page => {
|
41
|
+
return `<li><a href='${folder}/${page}'>${page}</a></li>`
|
42
|
+
}).join("")}
|
43
|
+
`
|
44
|
+
}).join("")}`);
|
45
|
+
} else {
|
46
|
+
next();
|
47
|
+
}
|
48
|
+
})
|
49
|
+
},
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
module.exports = virtualIndexPlugin;
|
@@ -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
|
+
});
|
@@ -39,7 +39,7 @@ const loadThemeProperties = async (themeName) => {
|
|
39
39
|
throw new Error("[themes] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs");
|
40
40
|
}
|
41
41
|
return (await fetch(themeUrlsByName[themeName])).json();
|
42
|
-
}
|
42
|
+
};
|
43
43
|
|
44
44
|
${availableThemesArray}
|
45
45
|
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadThemeProperties));
|
@@ -54,7 +54,7 @@ const loadThemeProperties = async (themeName) => {
|
|
54
54
|
${dynamicImportLines}
|
55
55
|
default: throw "unknown theme"
|
56
56
|
}
|
57
|
-
}
|
57
|
+
};
|
58
58
|
|
59
59
|
const loadAndCheck = async (themeName) => {
|
60
60
|
const data = await loadThemeProperties(themeName);
|
@@ -62,7 +62,7 @@ const loadAndCheck = async (themeName) => {
|
|
62
62
|
throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build or use 'import ".../Assets-static.js"'. Check the \"Assets\" documentation for more information.\`);
|
63
63
|
}
|
64
64
|
return data;
|
65
|
-
}
|
65
|
+
};
|
66
66
|
|
67
67
|
${availableThemesArray}
|
68
68
|
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadAndCheck));
|
@@ -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.
|
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.
|
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.
|
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
|
-
|
199
|
-
|
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
|
-
|
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
|
|
package/lib/i18n/defaults.js
CHANGED
@@ -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
|
+
}
|