@ui5/webcomponents-tools 0.0.0-38861c872 → 0.0.0-38f83ffef
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 +1121 -0
- package/README.md +2 -5
- package/assets-meta.js +3 -11
- package/components-package/eslint.js +59 -31
- package/components-package/nps.js +48 -26
- package/components-package/vite.config.js +7 -11
- package/components-package/wdio.js +415 -405
- package/icons-collection/nps.js +2 -2
- package/lib/amd-to-es6/index.js +102 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/custom-elements-manifest.config.mjs +129 -55
- package/lib/cem/event.mjs +75 -21
- package/lib/cem/schema-internal.json +71 -0
- package/lib/cem/types-internal.d.ts +564 -785
- package/lib/cem/types.d.ts +520 -655
- package/lib/cem/utils.mjs +115 -47
- package/lib/cem/validate.js +41 -37
- package/lib/create-icons/index.js +13 -10
- package/lib/create-illustrations/index.js +44 -9
- package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +13 -10
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +14 -22
- package/lib/css-processors/css-processor-components.mjs +3 -2
- package/lib/css-processors/css-processor-themes.mjs +2 -7
- package/lib/css-processors/scope-variables.mjs +3 -0
- package/lib/css-processors/shared.mjs +2 -22
- package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
- package/lib/dev-server/virtual-index-html-plugin.js +24 -20
- package/lib/generate-json-imports/i18n.js +46 -62
- package/lib/generate-json-imports/themes.js +13 -32
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +12 -7
- package/lib/hbs2ui5/index.js +3 -3
- package/lib/i18n/defaults.js +3 -2
- package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
- package/lib/scoping/get-all-tags.js +9 -2
- package/lib/scoping/lint-src.js +8 -7
- package/package.json +11 -8
- package/tsconfig.json +18 -0
- package/components-package/wdio.sync.js +0 -368
- package/lib/create-new-component/jsFileContentTemplate.js +0 -73
- package/lib/esm-abs-to-rel/index.js +0 -61
- package/lib/generate-custom-elements-manifest/index.js +0 -327
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/configTypescript.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2468
- package/lib/jsdoc/preprocess.js +0 -146
- package/lib/jsdoc/template/publish.js +0 -4120
- package/lib/replace-global-core/index.js +0 -25
package/lib/cem/utils.mjs
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
import fs from "fs";
|
2
2
|
import path from "path";
|
3
3
|
|
4
|
-
let
|
4
|
+
let documentationErrors = new Map();
|
5
|
+
|
6
|
+
const packageRegex = /^((@([a-z0-9._-]+)\/)?([a-z0-9._-]+))/;
|
5
7
|
|
6
8
|
const getDeprecatedStatus = (jsdocComment) => {
|
7
9
|
const deprecatedTag = findTag(jsdocComment, "deprecated");
|
@@ -14,22 +16,39 @@ const getDeprecatedStatus = (jsdocComment) => {
|
|
14
16
|
: undefined;
|
15
17
|
};
|
16
18
|
|
19
|
+
const getExperimentalStatus = (jsdocComment) => {
|
20
|
+
const experimentalTag = findTag(jsdocComment, "experimental");
|
21
|
+
return experimentalTag?.name
|
22
|
+
? experimentalTag.description
|
23
|
+
? `${experimentalTag.name} ${experimentalTag.description}`
|
24
|
+
: experimentalTag.name
|
25
|
+
: experimentalTag
|
26
|
+
? true
|
27
|
+
: undefined;
|
28
|
+
};
|
29
|
+
|
30
|
+
const toKebabCase = str => {
|
31
|
+
return str.replaceAll(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase())
|
32
|
+
}
|
33
|
+
|
17
34
|
const normalizeDescription = (description) => {
|
18
|
-
|
35
|
+
return typeof description === 'string' ? description.replaceAll(/^-\s+|^(\n)+|(\n)+$/g, "") : description;
|
19
36
|
}
|
20
37
|
|
21
|
-
const getTypeRefs = (ts,
|
38
|
+
const getTypeRefs = (ts, node, member) => {
|
22
39
|
const extractTypeRefs = (type) => {
|
23
40
|
if (type?.kind === ts.SyntaxKind.TypeReference) {
|
24
41
|
return type.typeArguments?.length
|
25
42
|
? type.typeArguments.map((typeRef) => typeRef.typeName?.text)
|
26
43
|
: [type.typeName?.text];
|
44
|
+
} else if (type?.kind === ts.SyntaxKind.ArrayType) {
|
45
|
+
return [type.elementType?.typeName?.text];
|
27
46
|
} else if (type?.kind === ts.SyntaxKind.UnionType) {
|
28
47
|
return type.types
|
29
48
|
.map((type) => extractTypeRefs(type))
|
30
49
|
.flat(1);
|
31
50
|
} else if (type?.kind === ts.SyntaxKind.TemplateLiteralType) {
|
32
|
-
if (member
|
51
|
+
if (member?.type) {
|
33
52
|
member.type.text = member.type.text.replaceAll?.(/`|\${|}/g, "");
|
34
53
|
}
|
35
54
|
|
@@ -39,7 +58,7 @@ const getTypeRefs = (ts, classNodeMember, member) => {
|
|
39
58
|
}
|
40
59
|
};
|
41
60
|
|
42
|
-
let typeRefs = extractTypeRefs(
|
61
|
+
let typeRefs = extractTypeRefs(node.type) || node?.typeArguments?.map(n => extractTypeRefs(n)).flat(2);
|
43
62
|
|
44
63
|
if (typeRefs) {
|
45
64
|
typeRefs = typeRefs.filter((e) => !!e);
|
@@ -62,7 +81,7 @@ const getPrivacyStatus = (jsdocComment) => {
|
|
62
81
|
return privacyTag?.tag || "private";
|
63
82
|
};
|
64
83
|
|
65
|
-
const findPackageName = (ts, sourceFile, typeName
|
84
|
+
const findPackageName = (ts, sourceFile, typeName) => {
|
66
85
|
const localStatements = [
|
67
86
|
ts.SyntaxKind.EnumDeclaration,
|
68
87
|
ts.SyntaxKind.InterfaceDeclaration,
|
@@ -94,15 +113,27 @@ const findPackageName = (ts, sourceFile, typeName, packageJSON) => {
|
|
94
113
|
if (currentModuleSpecifier?.text?.startsWith(".")) {
|
95
114
|
return packageJSON?.name;
|
96
115
|
} else {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
116
|
+
// my-package/test
|
117
|
+
// my-package
|
118
|
+
// @scope/my-package
|
119
|
+
// my.package
|
120
|
+
// _mypackage
|
121
|
+
// mypackage-
|
122
|
+
// scope/my-package/test
|
123
|
+
// @scope/my-package/test
|
124
|
+
const match = currentModuleSpecifier?.text.match(packageRegex);
|
125
|
+
let packageName;
|
126
|
+
|
127
|
+
if (match) {
|
128
|
+
packageName = match[1];
|
129
|
+
}
|
130
|
+
|
131
|
+
return packageName || undefined;
|
101
132
|
}
|
102
133
|
}
|
103
134
|
};
|
104
135
|
|
105
|
-
const findImportPath = (ts, sourceFile, typeName,
|
136
|
+
const findImportPath = (ts, sourceFile, typeName, modulePath) => {
|
106
137
|
const localStatements = [
|
107
138
|
ts.SyntaxKind.EnumDeclaration,
|
108
139
|
ts.SyntaxKind.InterfaceDeclaration,
|
@@ -139,25 +170,28 @@ const findImportPath = (ts, sourceFile, typeName, packageJSON, modulePath) => {
|
|
139
170
|
?.replace("src", "dist")?.replace(".ts", ".js") || undefined
|
140
171
|
);
|
141
172
|
} else {
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
173
|
+
let packageName = currentModuleSpecifier?.text?.replace(packageRegex, "") || undefined;
|
174
|
+
|
175
|
+
if (packageName?.startsWith("/")) {
|
176
|
+
packageName = packageName.replace("/", "");
|
177
|
+
}
|
178
|
+
|
179
|
+
return packageName;
|
148
180
|
}
|
149
181
|
}
|
150
182
|
};
|
151
183
|
|
152
184
|
|
153
185
|
const isClass = text => {
|
154
|
-
|
186
|
+
return text.includes("@abstract") || text.includes("@class") || text.includes("@constructor");
|
155
187
|
};
|
156
188
|
|
157
189
|
const normalizeTagType = (type) => {
|
158
|
-
|
190
|
+
return type?.trim();
|
159
191
|
}
|
160
192
|
|
193
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
|
194
|
+
|
161
195
|
const getReference = (ts, type, classNode, modulePath) => {
|
162
196
|
let sourceFile = classNode.parent;
|
163
197
|
|
@@ -165,22 +199,19 @@ const getReference = (ts, type, classNode, modulePath) => {
|
|
165
199
|
sourceFile = sourceFile.parent;
|
166
200
|
}
|
167
201
|
|
168
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
|
169
|
-
|
170
202
|
const typeName =
|
171
203
|
typeof type === "string"
|
172
204
|
? normalizeTagType(type)
|
173
205
|
: type.class?.expression?.text ||
|
174
206
|
type.typeExpression?.type?.getText() ||
|
175
207
|
type.typeExpression?.type?.elementType?.typeName?.text;
|
176
|
-
const packageName = findPackageName(ts, sourceFile, typeName
|
208
|
+
const packageName = findPackageName(ts, sourceFile, typeName);
|
177
209
|
const importPath = findImportPath(
|
178
210
|
ts,
|
179
211
|
sourceFile,
|
180
212
|
typeName,
|
181
|
-
packageJSON,
|
182
213
|
modulePath
|
183
|
-
);
|
214
|
+
)?.replace(`${packageName}/`, "");
|
184
215
|
|
185
216
|
return packageName && {
|
186
217
|
name: typeName,
|
@@ -206,13 +237,13 @@ const commonTags = ["public", "protected", "private", "since", "deprecated"];
|
|
206
237
|
const allowedTags = {
|
207
238
|
field: [...commonTags, "formEvents", "formProperty", "default"],
|
208
239
|
slot: [...commonTags, "default"],
|
209
|
-
event: [...commonTags, "param", "
|
240
|
+
event: [...commonTags, "param", "native", "allowPreventDefault"],
|
210
241
|
eventParam: [...commonTags],
|
211
242
|
method: [...commonTags, "param", "returns", "override"],
|
212
|
-
class: [...commonTags, "constructor", "class", "abstract", "implements", "extends", "slot", "csspart"],
|
213
|
-
enum: [...commonTags],
|
214
|
-
enumMember: [...commonTags],
|
215
|
-
interface: [...commonTags],
|
243
|
+
class: [...commonTags, "constructor", "class", "abstract", "experimental", "implements", "extends", "slot", "csspart"],
|
244
|
+
enum: [...commonTags, "experimental",],
|
245
|
+
enumMember: [...commonTags, "experimental",],
|
246
|
+
interface: [...commonTags, "experimental",],
|
216
247
|
};
|
217
248
|
allowedTags.getter = [...allowedTags.field, "override"]
|
218
249
|
|
@@ -225,19 +256,29 @@ const tagMatchCallback = (tag, tagName) => {
|
|
225
256
|
};
|
226
257
|
|
227
258
|
const findDecorator = (node, decoratorName) => {
|
228
|
-
return node?.decorators?.find(
|
259
|
+
return (node?.modifiers || node?.decorators)?.find(
|
229
260
|
(decorator) =>
|
230
261
|
decorator?.expression?.expression?.text === decoratorName
|
231
262
|
);
|
232
263
|
};
|
233
264
|
|
234
265
|
const findAllDecorators = (node, decoratorName) => {
|
235
|
-
|
236
|
-
node?.decorators?.filter(
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
266
|
+
if (typeof decoratorName === "string") {
|
267
|
+
return (node?.modifiers || node?.decorators)?.filter(decorator => decorator?.expression?.expression?.text === decoratorName) || [];
|
268
|
+
}
|
269
|
+
|
270
|
+
if (Array.isArray(decoratorName)) {
|
271
|
+
return (node?.modifiers || node?.decorators)?.filter(decorator => {
|
272
|
+
if (decorator?.expression?.expression?.text) {
|
273
|
+
return decoratorName.includes(decorator.expression.expression.text);
|
274
|
+
}
|
275
|
+
|
276
|
+
return false;
|
277
|
+
}
|
278
|
+
) || [];
|
279
|
+
}
|
280
|
+
|
281
|
+
return [];
|
241
282
|
};
|
242
283
|
|
243
284
|
const hasTag = (jsDoc, tagName) => {
|
@@ -267,7 +308,7 @@ const findAllTags = (jsDoc, tagName) => {
|
|
267
308
|
};
|
268
309
|
|
269
310
|
const validateJSDocTag = (tag) => {
|
270
|
-
const booleanTags = ["private", "protected", "public", "abstract", "
|
311
|
+
const booleanTags = ["private", "protected", "public", "abstract", "native", "allowPreventDefault", "formProperty", "constructor", "override"];
|
271
312
|
let tagName = tag.tag;
|
272
313
|
|
273
314
|
if (booleanTags.includes(tag.tag)) {
|
@@ -279,6 +320,8 @@ const validateJSDocTag = (tag) => {
|
|
279
320
|
return !tag.name && !tag.type && !tag.description;
|
280
321
|
case "deprecated":
|
281
322
|
return !tag.type;
|
323
|
+
case "experimental":
|
324
|
+
return !tag.type;
|
282
325
|
case "extends":
|
283
326
|
return !tag.type && tag.name && !tag.description;
|
284
327
|
case "implements":
|
@@ -311,33 +354,56 @@ const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
|
|
311
354
|
let isValid = false
|
312
355
|
|
313
356
|
if (fieldType === "event" && tag?.tag === "param") {
|
314
|
-
isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag({...tag, tag: "eventparam"});
|
357
|
+
isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag({ ...tag, tag: "eventparam" });
|
315
358
|
} else {
|
316
359
|
isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag(tag);
|
317
360
|
}
|
318
361
|
|
319
362
|
if (!isValid) {
|
320
|
-
|
321
|
-
`=== ERROR: Problem found with ${node}'s JSDoc comment in ${moduleDoc.path}: \n\t- @${tag.tag} tag is being used wrong or it's not part of ${fieldType} JSDoc tags`
|
322
|
-
);
|
363
|
+
logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
|
323
364
|
}
|
324
365
|
|
325
366
|
return !!isValid;
|
326
367
|
});
|
327
368
|
};
|
328
369
|
|
329
|
-
const
|
330
|
-
|
331
|
-
|
370
|
+
const logDocumentationError = (modulePath, message) => {
|
371
|
+
let moduleErrors = documentationErrors.get(modulePath);
|
372
|
+
|
373
|
+
if (!moduleErrors) {
|
374
|
+
documentationErrors.set(modulePath, []);
|
375
|
+
moduleErrors = documentationErrors.get(modulePath);
|
376
|
+
}
|
377
|
+
|
378
|
+
moduleErrors.push(message);
|
379
|
+
}
|
380
|
+
|
381
|
+
const displayDocumentationErrors = () => {
|
382
|
+
let errorsCount = 0;
|
383
|
+
[...documentationErrors.keys()].forEach(modulePath => {
|
384
|
+
const moduleErrors = documentationErrors.get(modulePath);
|
385
|
+
|
386
|
+
console.log(`=== ERROR: ${moduleErrors.length > 1 ? `${moduleErrors.length} problems` : "Problem"} found in file: ${modulePath}:`)
|
387
|
+
moduleErrors.forEach(moduleError => {
|
388
|
+
errorsCount++;
|
389
|
+
console.log(`\t- ${moduleError}`)
|
390
|
+
})
|
391
|
+
})
|
392
|
+
|
393
|
+
if (errorsCount) {
|
394
|
+
throw new Error(`Found ${errorsCount} errors in the description of the public API.`);
|
395
|
+
}
|
396
|
+
}
|
332
397
|
|
333
398
|
const formatArrays = (typeText) => {
|
334
|
-
|
399
|
+
return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
|
335
400
|
}
|
336
401
|
|
337
402
|
export {
|
338
403
|
getPrivacyStatus,
|
339
404
|
getSinceStatus,
|
340
405
|
getDeprecatedStatus,
|
406
|
+
getExperimentalStatus,
|
341
407
|
getType,
|
342
408
|
getReference,
|
343
409
|
validateJSDocComment,
|
@@ -346,10 +412,12 @@ export {
|
|
346
412
|
hasTag,
|
347
413
|
findTag,
|
348
414
|
findAllTags,
|
349
|
-
getJSDocErrors,
|
350
415
|
getTypeRefs,
|
351
416
|
normalizeDescription,
|
352
417
|
formatArrays,
|
353
418
|
isClass,
|
354
|
-
normalizeTagType
|
419
|
+
normalizeTagType,
|
420
|
+
displayDocumentationErrors,
|
421
|
+
logDocumentationError,
|
422
|
+
toKebabCase
|
355
423
|
};
|
package/lib/cem/validate.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
const Ajv = require('ajv');
|
3
3
|
const path = require('path');
|
4
|
-
|
5
4
|
// Load your JSON schema
|
6
5
|
const extenalSchema = require('./schema.json');
|
7
6
|
const internalSchema = require('./schema-internal.json');
|
@@ -10,54 +9,59 @@ const internalSchema = require('./schema-internal.json');
|
|
10
9
|
const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
|
11
10
|
const customManifest = fs.readFileSync(inputFilePath, 'utf8');
|
12
11
|
const inputDataInternal = JSON.parse(customManifest);
|
12
|
+
const devMode = process.env.UI5_CEM_MODE === "dev";
|
13
|
+
|
14
|
+
inputDataInternal.modules.forEach(moduleDoc => {
|
15
|
+
moduleDoc.exports = moduleDoc.exports.
|
16
|
+
filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
|
17
|
+
})
|
13
18
|
|
14
19
|
const clearProps = (data) => {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
return data;
|
37
|
-
}
|
20
|
+
if (Array.isArray(data)) {
|
21
|
+
for (let i = 0; i < data.length; i++) {
|
22
|
+
if (typeof data[i] === "object") {
|
23
|
+
if (["enum", "interface"].includes(data[i].kind)) {
|
24
|
+
data.splice(i, 1);
|
25
|
+
i--;
|
26
|
+
} else {
|
27
|
+
clearProps(data[i]);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
} else if (typeof data === "object") {
|
32
|
+
Object.keys(data).forEach(prop => {
|
33
|
+
if (prop.startsWith("_ui5")) {
|
34
|
+
delete data[prop];
|
35
|
+
} else if (typeof data[prop] === "object") {
|
36
|
+
clearProps(data[prop]);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
38
40
|
|
39
|
-
|
41
|
+
return data;
|
42
|
+
}
|
40
43
|
|
41
44
|
const ajv = new Ajv({ allowUnionTypes: true, allError: true })
|
42
|
-
|
43
45
|
let validate = ajv.compile(internalSchema)
|
44
46
|
|
45
47
|
// Validate the JSON data against the schema
|
46
|
-
if (
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
if (devMode) {
|
49
|
+
if (validate(inputDataInternal)) {
|
50
|
+
console.log('Internal custom element manifest is validated successfully');
|
51
|
+
} else {
|
52
|
+
console.log(validate.errors)
|
53
|
+
throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
|
54
|
+
}
|
51
55
|
}
|
52
56
|
|
57
|
+
const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
|
53
58
|
validate = ajv.compile(extenalSchema)
|
54
59
|
|
55
60
|
// Validate the JSON data against the schema
|
56
61
|
if (validate(inputDataExternal)) {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
} else {
|
61
|
-
|
62
|
-
// console.error('Validation of external custom-elements failed:', ajv.errorsText(validate.errors));
|
62
|
+
console.log('Custom element manifest is validated successfully');
|
63
|
+
fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
|
64
|
+
fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
|
65
|
+
} else if (devMode) {
|
66
|
+
throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
|
63
67
|
}
|
@@ -21,8 +21,8 @@ export default "${collection}/${name}";
|
|
21
21
|
export { pathData, ltr, accData };`;
|
22
22
|
|
23
23
|
|
24
|
-
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
25
|
-
import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
|
24
|
+
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName, versioned) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
25
|
+
import { ${accData.key} } from "${versioned ? "../" : "./"}generated/i18n/i18n-defaults.js";
|
26
26
|
|
27
27
|
const name = "${name}";
|
28
28
|
const pathData = "${pathData}";
|
@@ -38,14 +38,16 @@ export { pathData, ltr, accData };`;
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
const collectionTemplate = (name, versions, fullName) => `import {
|
41
|
+
const collectionTemplate = (name, versions, fullName) => `import { isLegacyThemeFamilyAsync } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
42
|
import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
|
43
43
|
import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
|
44
44
|
|
45
|
-
const
|
45
|
+
const getPathData = async() => {
|
46
|
+
return await isLegacyThemeFamilyAsync() ? pathDatav4 : pathDatav5;
|
47
|
+
};
|
46
48
|
|
47
49
|
export default "${fullName}";
|
48
|
-
export {
|
50
|
+
export { getPathData, ltr, accData };`;
|
49
51
|
|
50
52
|
|
51
53
|
const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
|
@@ -56,13 +58,13 @@ declare const _default: "${collection}/${name}";
|
|
56
58
|
export default _default;
|
57
59
|
export { pathData, ltr, accData };`
|
58
60
|
|
59
|
-
const collectionTypeDefinitionTemplate = (name, accData) => `declare const
|
61
|
+
const collectionTypeDefinitionTemplate = (name, accData) => `declare const getPathData: () => Promise<string>;
|
60
62
|
declare const ltr: boolean;
|
61
63
|
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
62
64
|
declare const _default: "${name}";
|
63
65
|
|
64
66
|
export default _default;
|
65
|
-
export {
|
67
|
+
export { getPathData, ltr, accData };`
|
66
68
|
|
67
69
|
|
68
70
|
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
@@ -82,8 +84,9 @@ const createIcons = async (file) => {
|
|
82
84
|
const acc = iconData.acc;
|
83
85
|
const packageName = json.packageName;
|
84
86
|
const collection = json.collection;
|
87
|
+
const versioned = json.version;
|
85
88
|
|
86
|
-
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName) : iconTemplate(name, pathData, ltr, collection, packageName);
|
89
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, collection, packageName);
|
87
90
|
|
88
91
|
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
89
92
|
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
@@ -91,10 +94,10 @@ const createIcons = async (file) => {
|
|
91
94
|
|
92
95
|
// For versioned icons collections, the script creates top level (unversioned) module that internally imports the versioned ones.
|
93
96
|
// For example, the top level "@ui5/ui5-webcomponents-icons/dist/accept.js" imports:
|
94
|
-
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
97
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
95
98
|
// - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
|
96
99
|
|
97
|
-
if (
|
100
|
+
if (versioned) {
|
98
101
|
// The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
|
99
102
|
// to add or not the collection name to the exported value:
|
100
103
|
// For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
|
@@ -20,7 +20,15 @@ const generate = async () => {
|
|
20
20
|
SuccessScreen: "SuccessScreen",
|
21
21
|
NoMail: "NoMail",
|
22
22
|
NoSavedItems: "NoSavedItems",
|
23
|
-
NoTasks: "NoTasks"
|
23
|
+
NoTasks: "NoTasks",
|
24
|
+
NoDimensionsSet: "NoDimensionsSet",
|
25
|
+
AddPeople: "AddPeople",
|
26
|
+
AddColumn: "AddColumn",
|
27
|
+
SortColumn: "SortColumn",
|
28
|
+
FilterTable: "FilterTable",
|
29
|
+
ResizeColumn: "ResizeColumn",
|
30
|
+
GroupTable: "GroupTable",
|
31
|
+
UploadCollection: "UploadCollection"
|
24
32
|
};
|
25
33
|
|
26
34
|
const FALLBACK_TEXTS = {
|
@@ -47,6 +55,16 @@ const generate = async () => {
|
|
47
55
|
SimpleNotFoundMagnifier: ORIGINAL_TEXTS.NoSearchResults,
|
48
56
|
SimpleReload: ORIGINAL_TEXTS.UnableToLoad,
|
49
57
|
SimpleTask: ORIGINAL_TEXTS.NoTasks,
|
58
|
+
NoChartData: ORIGINAL_TEXTS.NoDimensionsSet,
|
59
|
+
AddingColumns: ORIGINAL_TEXTS.AddColumn,
|
60
|
+
SortingColumns: ORIGINAL_TEXTS.SortColumn,
|
61
|
+
FilteringColumns: ORIGINAL_TEXTS.FilterTable,
|
62
|
+
ResizingColumns: ORIGINAL_TEXTS.ResizeColumn,
|
63
|
+
GroupingColumns: ORIGINAL_TEXTS.GroupTable,
|
64
|
+
AddPeopleToCalendar: ORIGINAL_TEXTS.AddPeople,
|
65
|
+
DragFilesToUpload: ORIGINAL_TEXTS.UploadCollection,
|
66
|
+
KeyTask: ORIGINAL_TEXTS.SuccessScreen,
|
67
|
+
ReceiveAppreciation: ORIGINAL_TEXTS.BalloonSky,
|
50
68
|
SuccessBalloon: ORIGINAL_TEXTS.BalloonSky,
|
51
69
|
SuccessCheckMark: ORIGINAL_TEXTS.SuccessScreen,
|
52
70
|
SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
|
@@ -62,6 +80,8 @@ const generate = async () => {
|
|
62
80
|
// collect each illustration name because each one should have Sample.js file
|
63
81
|
const fileNames = new Set();
|
64
82
|
|
83
|
+
let dotIllustrationNames = [];
|
84
|
+
|
65
85
|
try {
|
66
86
|
await fs.access(srcPath);
|
67
87
|
} catch (error) {
|
@@ -77,8 +97,14 @@ const generate = async () => {
|
|
77
97
|
const svgToJs = async fileName => {
|
78
98
|
const svg = await fs.readFile(path.join(srcPath, fileName), { encoding: "utf-8" });
|
79
99
|
const fileContent = svgImportTemplate(svg);
|
100
|
+
const fileNameSplitArr = fileName.split('-');
|
80
101
|
fileName = fileName.replace(/\.svg$/, ".js");
|
81
102
|
|
103
|
+
if (fileNameSplitArr[1] === 'Dot') {
|
104
|
+
// we keep the Dot illustration names to import them later. If no Dot is present, Spot will be used
|
105
|
+
dotIllustrationNames.push(fileNameSplitArr[2].split('.')[0]);
|
106
|
+
}
|
107
|
+
|
82
108
|
return fs.writeFile(path.join(destPath, fileName), fileContent);
|
83
109
|
};
|
84
110
|
const illustrationImportTemplate = illustrationName => {
|
@@ -93,11 +119,14 @@ const generate = async () => {
|
|
93
119
|
}
|
94
120
|
|
95
121
|
const illustrationNameUpperCase = illustrationNameForTranslation.toUpperCase();
|
122
|
+
// If no Dot is present, Spot will be imported as Dot
|
123
|
+
const hasDot = dotIllustrationNames.indexOf(illustrationName) !== -1 ? 'Dot' : 'Spot';
|
96
124
|
|
97
125
|
return `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
98
126
|
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
99
127
|
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
100
|
-
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js"
|
128
|
+
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
129
|
+
import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${
|
101
130
|
defaultText ? `import {
|
102
131
|
IM_TITLE_${illustrationNameUpperCase},
|
103
132
|
IM_SUBTITLE_${illustrationNameUpperCase},
|
@@ -112,7 +141,8 @@ const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};` : ``}
|
|
112
141
|
registerIllustration(name, {
|
113
142
|
dialogSvg,
|
114
143
|
sceneSvg,
|
115
|
-
spotSvg
|
144
|
+
spotSvg,
|
145
|
+
dotSvg,${defaultText ? `
|
116
146
|
title,
|
117
147
|
subtitle,` : ``}
|
118
148
|
set,
|
@@ -124,6 +154,7 @@ export {
|
|
124
154
|
dialogSvg,
|
125
155
|
sceneSvg,
|
126
156
|
spotSvg,
|
157
|
+
dotSvg,
|
127
158
|
};`
|
128
159
|
};
|
129
160
|
|
@@ -131,10 +162,11 @@ export {
|
|
131
162
|
return `declare const dialogSvg: string;
|
132
163
|
declare const sceneSvg: string;
|
133
164
|
declare const spotSvg: string;
|
165
|
+
declare const dotSvg: string;
|
134
166
|
declare const _default: "${illustrationSet === "fiori" ? "" : `${illustrationSet}/`}${illustrationName}";
|
135
167
|
|
136
168
|
export default _default;
|
137
|
-
export { dialogSvg, sceneSvg, spotSvg };`
|
169
|
+
export { dialogSvg, sceneSvg, spotSvg, dotSvg };`
|
138
170
|
};
|
139
171
|
|
140
172
|
await fs.mkdir(destPath, { recursive: true });
|
@@ -152,12 +184,15 @@ export { dialogSvg, sceneSvg, spotSvg };`
|
|
152
184
|
}
|
153
185
|
});
|
154
186
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
187
|
+
return Promise.all(promises).then(() => {
|
188
|
+
const nestedPromises = [];
|
189
|
+
for (let illustrationName of fileNames) {
|
190
|
+
nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
|
191
|
+
nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
|
192
|
+
}
|
159
193
|
|
160
|
-
|
194
|
+
return Promise.all(nestedPromises);
|
195
|
+
});
|
161
196
|
};
|
162
197
|
|
163
198
|
generate().then(() => {
|