@ui5/webcomponents-tools 0.0.0-7a547f8cc → 0.0.0-7c7170d4a

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 (61) hide show
  1. package/CHANGELOG.md +1019 -0
  2. package/README.md +2 -1
  3. package/assets-meta.js +15 -10
  4. package/components-package/eslint.js +36 -28
  5. package/components-package/nps.js +55 -46
  6. package/components-package/postcss.components.js +1 -21
  7. package/components-package/postcss.themes.js +1 -26
  8. package/components-package/vite.config.js +6 -5
  9. package/components-package/wdio.js +34 -13
  10. package/icons-collection/nps.js +9 -7
  11. package/lib/amd-to-es6/index.js +102 -0
  12. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  13. package/lib/cem/custom-elements-manifest.config.mjs +501 -0
  14. package/lib/cem/event.mjs +131 -0
  15. package/lib/cem/schema-internal.json +1357 -0
  16. package/lib/cem/schema.json +1098 -0
  17. package/lib/cem/types-internal.d.ts +796 -0
  18. package/lib/cem/types.d.ts +736 -0
  19. package/lib/cem/utils.mjs +384 -0
  20. package/lib/cem/validate.js +70 -0
  21. package/lib/create-icons/index.js +38 -13
  22. package/lib/create-illustrations/index.js +51 -30
  23. package/lib/create-new-component/index.js +61 -101
  24. package/lib/create-new-component/tsFileContentTemplate.js +71 -0
  25. package/lib/css-processors/css-processor-component-styles.mjs +48 -0
  26. package/lib/css-processors/css-processor-components.mjs +77 -0
  27. package/lib/css-processors/css-processor-themes.mjs +79 -0
  28. package/lib/css-processors/scope-variables.mjs +49 -0
  29. package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
  30. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  31. package/lib/dev-server/ssr-dom-shim-loader.js +26 -0
  32. package/lib/dev-server/virtual-index-html-plugin.js +1 -2
  33. package/lib/generate-js-imports/illustrations.js +78 -64
  34. package/lib/generate-json-imports/i18n.js +10 -37
  35. package/lib/generate-json-imports/themes.js +9 -31
  36. package/lib/hbs2lit/src/compiler.js +9 -6
  37. package/lib/hbs2lit/src/litVisitor2.js +42 -17
  38. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  39. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
  40. package/lib/hbs2ui5/index.js +21 -4
  41. package/lib/i18n/defaults.js +1 -1
  42. package/lib/i18n/toJSON.js +1 -1
  43. package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
  44. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  45. package/lib/scoping/get-all-tags.js +1 -1
  46. package/lib/scoping/lint-src.js +8 -7
  47. package/lib/scoping/scope-test-pages.js +2 -1
  48. package/lib/test-runner/test-runner.js +10 -2
  49. package/package.json +19 -11
  50. package/components-package/wdio.sync.js +0 -360
  51. package/lib/esm-abs-to-rel/index.js +0 -58
  52. package/lib/generate-custom-elements-manifest/index.js +0 -327
  53. package/lib/jsdoc/config.json +0 -29
  54. package/lib/jsdoc/configTypescript.json +0 -29
  55. package/lib/jsdoc/plugin.js +0 -2468
  56. package/lib/jsdoc/preprocess.js +0 -146
  57. package/lib/jsdoc/template/publish.js +0 -4120
  58. package/lib/postcss-css-to-json/index.js +0 -47
  59. package/lib/postcss-new-files/index.js +0 -36
  60. package/lib/postcss-p/postcss-p.mjs +0 -14
  61. 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;