@ui5/webcomponents-tools 0.0.0-f651a470c → 0.0.0-f79db712b
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 +405 -0
- package/README.md +2 -1
- package/assets-meta.js +16 -7
- package/components-package/eslint.js +2 -0
- package/components-package/nps.js +37 -30
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -26
- package/components-package/wdio.js +15 -3
- package/components-package/wdio.sync.js +9 -1
- package/icons-collection/nps.js +8 -6
- package/lib/cem/custom-elements-manifest.config.mjs +499 -0
- package/lib/cem/event.mjs +135 -0
- package/lib/cem/schema-internal.json +1354 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +801 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +354 -0
- package/lib/cem/validate.js +67 -0
- package/lib/create-illustrations/index.js +32 -28
- package/lib/create-new-component/index.js +28 -58
- package/lib/create-new-component/jsFileContentTemplate.js +0 -4
- package/lib/create-new-component/tsFileContentTemplate.js +2 -15
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +79 -0
- package/lib/css-processors/scope-variables.mjs +46 -0
- package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/esm-abs-to-rel/index.js +4 -1
- package/lib/generate-custom-elements-manifest/index.js +1 -1
- package/lib/generate-js-imports/illustrations.js +78 -64
- package/lib/generate-json-imports/i18n.js +10 -5
- package/lib/generate-json-imports/themes.js +10 -5
- package/lib/hbs2lit/src/compiler.js +9 -6
- package/lib/hbs2lit/src/litVisitor2.js +42 -17
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
- package/lib/hbs2ui5/index.js +21 -4
- package/lib/jsdoc/preprocess.js +1 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
- package/lib/scoping/get-all-tags.js +1 -1
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +2 -2
- package/package.json +10 -9
- package/lib/postcss-css-to-json/index.js +0 -47
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -14
@@ -0,0 +1,135 @@
|
|
1
|
+
import { parse } from "comment-parser";
|
2
|
+
import {
|
3
|
+
getPrivacyStatus,
|
4
|
+
getDeprecatedStatus,
|
5
|
+
getSinceStatus,
|
6
|
+
getType,
|
7
|
+
getTypeRefs,
|
8
|
+
validateJSDocComment,
|
9
|
+
hasTag,
|
10
|
+
findTag,
|
11
|
+
findAllTags,
|
12
|
+
getReference,
|
13
|
+
normalizeDescription,
|
14
|
+
normalizeTagType,
|
15
|
+
getJSDocErrors
|
16
|
+
} from "./utils.mjs";
|
17
|
+
|
18
|
+
const jsDocRegExp = /\/\*\*(.|\n)+?\s+\*\//;
|
19
|
+
|
20
|
+
const getParams = (ts, eventDetails, commentParams, classNode, moduleDoc) => {
|
21
|
+
return commentParams?.map(commentParam => {
|
22
|
+
const decoratorParam = eventDetails?.find(prop => prop?.name?.text === commentParam?.name);
|
23
|
+
|
24
|
+
if (!decoratorParam || !decoratorParam?.jsDoc?.[0]) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
const decoratorParamParsedComment = parse(decoratorParam?.jsDoc?.[0]?.getText?.(), { spacing: 'preserve' })[0];
|
29
|
+
|
30
|
+
validateJSDocComment("eventParam", decoratorParamParsedComment, decoratorParam.name?.text, moduleDoc);
|
31
|
+
|
32
|
+
const { typeName, name } = getType(normalizeTagType(commentParam?.type));
|
33
|
+
let type;
|
34
|
+
|
35
|
+
if (typeName) {
|
36
|
+
type = { text: typeName };
|
37
|
+
|
38
|
+
let typeRefs = name?.split("|")
|
39
|
+
?.map(e => getReference(ts, e.trim(), classNode, moduleDoc.path))
|
40
|
+
.filter(Boolean);
|
41
|
+
|
42
|
+
if (typeRefs?.length) {
|
43
|
+
type.references = typeRefs;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return {
|
48
|
+
type,
|
49
|
+
name: commentParam?.name,
|
50
|
+
_ui5privacy: getPrivacyStatus(decoratorParamParsedComment),
|
51
|
+
description: normalizeDescription(commentParam?.description),
|
52
|
+
_ui5since: getSinceStatus(decoratorParamParsedComment),
|
53
|
+
deprecated: getDeprecatedStatus(decoratorParamParsedComment),
|
54
|
+
};
|
55
|
+
}).filter(pair => !!pair);
|
56
|
+
};
|
57
|
+
|
58
|
+
function processEvent(ts, event, classNode, moduleDoc) {
|
59
|
+
const name = event?.expression?.arguments?.[0]?.text;
|
60
|
+
const result = {
|
61
|
+
name,
|
62
|
+
_ui5privacy: "private",
|
63
|
+
type: { text: "CustomEvent" }
|
64
|
+
};
|
65
|
+
|
66
|
+
const comment = event.getFullText?.().match(jsDocRegExp)?.[0];
|
67
|
+
|
68
|
+
if (!comment) {
|
69
|
+
return result;
|
70
|
+
}
|
71
|
+
|
72
|
+
const eventParsedComment = parse(comment, { spacing: 'preserve' })[0];
|
73
|
+
|
74
|
+
validateJSDocComment("event", eventParsedComment, name, moduleDoc);
|
75
|
+
|
76
|
+
const deprecatedTag = findTag(eventParsedComment, "deprecated");
|
77
|
+
const privacy = findTag(eventParsedComment, ["public", "private", "protected"])?.tag || "private";
|
78
|
+
const sinceTag = findTag(eventParsedComment, "since");
|
79
|
+
const commentParams = findAllTags(eventParsedComment, "param");
|
80
|
+
const allowPreventDefault = hasTag(eventParsedComment, "allowPreventDefault") || undefined;
|
81
|
+
const description = normalizeDescription(eventParsedComment?.description);
|
82
|
+
const native = hasTag(eventParsedComment, "native");
|
83
|
+
const eventDetails = event?.expression?.arguments?.[1]?.properties?.find(prop => prop?.name?.text === "detail")?.initializer?.properties;
|
84
|
+
|
85
|
+
if (event?.expression?.arguments?.[1] && !event?.expression?.typeArguments) {
|
86
|
+
const JSDocErrors = getJSDocErrors();
|
87
|
+
|
88
|
+
JSDocErrors.push(
|
89
|
+
`=== ERROR: Problem found with ${name}'s description in ${moduleDoc.path}: \n\t- Event details have to be described with type via generics type passed to the decorator ( @event<TypeForDetails>("example-name", {details}) ) `
|
90
|
+
);
|
91
|
+
}
|
92
|
+
|
93
|
+
result.description = description;
|
94
|
+
result._ui5allowPreventDefault = allowPreventDefault;
|
95
|
+
|
96
|
+
if (native) {
|
97
|
+
result.type = { text: "Event" };
|
98
|
+
} else if (event?.expression?.typeArguments) {
|
99
|
+
const typesText = event?.expression?.typeArguments.map(type => type.typeName?.text).filter(Boolean).join(" | ");
|
100
|
+
const typeRefs = (getTypeRefs(ts, event.expression)
|
101
|
+
?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
|
102
|
+
|
103
|
+
result.type = { text: `CustomEvent<${typesText}>` };
|
104
|
+
|
105
|
+
if (typeRefs.length) {
|
106
|
+
result.type.references = typeRefs;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
if (privacy) {
|
111
|
+
result._ui5privacy = privacy;
|
112
|
+
}
|
113
|
+
|
114
|
+
if (deprecatedTag?.name) {
|
115
|
+
result.deprecated = deprecatedTag.description
|
116
|
+
? `${deprecatedTag.name} ${deprecatedTag.description}`
|
117
|
+
: deprecatedTag.name;
|
118
|
+
} else if (deprecatedTag) {
|
119
|
+
result.deprecated = true;
|
120
|
+
}
|
121
|
+
|
122
|
+
if (sinceTag?.name) {
|
123
|
+
result._ui5since = sinceTag?.description
|
124
|
+
? `${sinceTag.name} ${sinceTag.description}`
|
125
|
+
: sinceTag.name;
|
126
|
+
}
|
127
|
+
|
128
|
+
if (commentParams && eventDetails) {
|
129
|
+
result._ui5parameters = getParams(ts, eventDetails, commentParams, classNode, moduleDoc);
|
130
|
+
}
|
131
|
+
|
132
|
+
return result;
|
133
|
+
}
|
134
|
+
|
135
|
+
export default processEvent;
|