@ui5/webcomponents-tools 0.0.0-d9b978d1d → 0.0.0-da0d3eb88

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +514 -0
  2. package/assets-meta.js +2 -6
  3. package/components-package/eslint.js +1 -0
  4. package/components-package/nps.js +20 -17
  5. package/components-package/wdio.js +414 -405
  6. package/icons-collection/nps.js +2 -2
  7. package/lib/amd-to-es6/index.js +102 -0
  8. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  9. package/lib/cem/custom-elements-manifest.config.mjs +501 -0
  10. package/lib/cem/event.mjs +131 -0
  11. package/lib/cem/schema-internal.json +1357 -0
  12. package/lib/cem/schema.json +1098 -0
  13. package/lib/cem/types-internal.d.ts +796 -0
  14. package/lib/cem/types.d.ts +736 -0
  15. package/lib/cem/utils.mjs +384 -0
  16. package/lib/cem/validate.js +70 -0
  17. package/lib/create-icons/index.js +8 -6
  18. package/lib/create-illustrations/index.js +40 -33
  19. package/lib/create-new-component/index.js +4 -11
  20. package/lib/create-new-component/tsFileContentTemplate.js +3 -12
  21. package/lib/css-processors/css-processor-component-styles.mjs +48 -0
  22. package/lib/css-processors/scope-variables.mjs +3 -0
  23. package/lib/dev-server/ssr-dom-shim-loader.js +26 -0
  24. package/lib/generate-js-imports/illustrations.js +9 -9
  25. package/lib/generate-json-imports/i18n.js +3 -35
  26. package/lib/generate-json-imports/themes.js +2 -29
  27. package/lib/i18n/defaults.js +1 -1
  28. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  29. package/lib/scoping/lint-src.js +8 -7
  30. package/package.json +6 -2
  31. package/components-package/wdio.sync.js +0 -368
  32. package/lib/create-new-component/jsFileContentTemplate.js +0 -73
  33. package/lib/esm-abs-to-rel/index.js +0 -61
  34. package/lib/generate-custom-elements-manifest/index.js +0 -327
  35. package/lib/jsdoc/config.json +0 -29
  36. package/lib/jsdoc/configTypescript.json +0 -29
  37. package/lib/jsdoc/plugin.js +0 -2468
  38. package/lib/jsdoc/preprocess.js +0 -146
  39. package/lib/jsdoc/template/publish.js +0 -4120
  40. package/lib/replace-global-core/index.js +0 -25
@@ -0,0 +1,131 @@
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
+ logDocumentationError
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
+ logDocumentationError(moduleDoc.path, `Event details for event '${name}' must be described using generics. Add type via generics to the decorator: @event<TypeForDetails>("${name}", {details}).`)
87
+ }
88
+
89
+ result.description = description;
90
+ result._ui5allowPreventDefault = allowPreventDefault;
91
+
92
+ if (native) {
93
+ result.type = { text: "Event" };
94
+ } else if (event?.expression?.typeArguments) {
95
+ const typesText = event?.expression?.typeArguments.map(type => type.typeName?.text).filter(Boolean).join(" | ");
96
+ const typeRefs = (getTypeRefs(ts, event.expression)
97
+ ?.map(e => getReference(ts, e, event, moduleDoc.path)).filter(Boolean)) || [];
98
+
99
+ result.type = { text: `CustomEvent<${typesText}>` };
100
+
101
+ if (typeRefs.length) {
102
+ result.type.references = typeRefs;
103
+ }
104
+ }
105
+
106
+ if (privacy) {
107
+ result._ui5privacy = privacy;
108
+ }
109
+
110
+ if (deprecatedTag?.name) {
111
+ result.deprecated = deprecatedTag.description
112
+ ? `${deprecatedTag.name} ${deprecatedTag.description}`
113
+ : deprecatedTag.name;
114
+ } else if (deprecatedTag) {
115
+ result.deprecated = true;
116
+ }
117
+
118
+ if (sinceTag?.name) {
119
+ result._ui5since = sinceTag?.description
120
+ ? `${sinceTag.name} ${sinceTag.description}`
121
+ : sinceTag.name;
122
+ }
123
+
124
+ if (commentParams && eventDetails) {
125
+ result._ui5parameters = getParams(ts, eventDetails, commentParams, classNode, moduleDoc);
126
+ }
127
+
128
+ return result;
129
+ }
130
+
131
+ export default processEvent;