@ui5/webcomponents-tools 0.0.0-b132dd7b9 → 0.0.0-b3a4f8020

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 (96) hide show
  1. package/CHANGELOG.md +501 -0
  2. package/LICENSE.txt +201 -0
  3. package/README.md +7 -7
  4. package/bin/dev.js +10 -4
  5. package/bin/ui5nps.js +301 -0
  6. package/components-package/nps.js +97 -94
  7. package/components-package/wdio.js +8 -2
  8. package/icons-collection/nps.js +30 -21
  9. package/lib/amd-to-es6/index.js +17 -10
  10. package/lib/cem/cem.js +16 -0
  11. package/lib/cem/custom-elements-manifest.config.mjs +56 -4
  12. package/lib/cem/merge.mjs +220 -0
  13. package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
  14. package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
  15. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
  16. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
  17. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
  18. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
  19. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
  20. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
  21. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
  22. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
  23. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
  24. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
  25. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
  26. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
  27. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
  28. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
  29. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
  30. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
  31. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
  32. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
  33. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
  34. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
  35. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
  36. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
  37. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
  38. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
  39. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
  40. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
  41. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
  42. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
  43. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
  44. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
  45. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
  46. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
  47. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
  48. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
  49. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
  50. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
  51. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
  52. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
  53. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
  54. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
  55. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
  56. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
  57. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
  58. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
  59. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
  60. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
  61. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
  62. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
  63. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
  64. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
  65. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
  66. package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
  67. package/lib/cem/schema-internal.json +41 -1
  68. package/lib/cem/schema.json +41 -1
  69. package/lib/cem/types-internal.d.ts +32 -2
  70. package/lib/cem/types.d.ts +32 -2
  71. package/lib/cem/utils.mjs +13 -3
  72. package/lib/cem/validate.js +61 -47
  73. package/lib/chokidar/chokidar.js +28 -0
  74. package/lib/copy-and-watch/index.js +110 -97
  75. package/lib/copy-list/index.js +18 -10
  76. package/lib/create-icons/index.js +19 -15
  77. package/lib/create-illustrations/index.js +57 -29
  78. package/lib/create-new-component/index.js +5 -3
  79. package/lib/css-processors/css-processor-components.mjs +85 -60
  80. package/lib/css-processors/css-processor-themes.mjs +105 -57
  81. package/lib/css-processors/postcss-plugin.mjs +153 -0
  82. package/lib/css-processors/scope-variables.mjs +26 -1
  83. package/lib/css-processors/shared.mjs +8 -17
  84. package/lib/dev-server/dev-server.mjs +23 -11
  85. package/lib/eslint/eslint.js +44 -0
  86. package/lib/generate-js-imports/illustrations.js +55 -54
  87. package/lib/generate-json-imports/i18n.js +22 -11
  88. package/lib/generate-json-imports/themes.js +24 -12
  89. package/lib/i18n/defaults.js +14 -7
  90. package/lib/i18n/toJSON.js +40 -12
  91. package/lib/icons-hash/icons-hash.mjs +149 -0
  92. package/lib/remove-dev-mode/remove-dev-mode.mjs +38 -24
  93. package/lib/rimraf/rimraf.js +31 -0
  94. package/lib/test-runner/test-runner.js +56 -48
  95. package/lib/vite-bundler/vite-bundler.mjs +35 -0
  96. package/package.json +15 -14
@@ -0,0 +1,194 @@
1
+ /**
2
+ * UTILITIES RELATED TO GETTING INFORMATION OUT OF A MANIFEST OR DOC
3
+ */
4
+
5
+ import { has } from "./index.js";
6
+
7
+ /**
8
+ * @typedef {import('custom-elements-manifest/schema').Package} Package
9
+ */
10
+
11
+ function loopThroughDeclarations(manifest, predicate) {
12
+ manifest?.modules?.forEach(_module => {
13
+ _module?.declarations?.forEach(predicate);
14
+ });
15
+ }
16
+
17
+ function loopThroughExports(manifest, predicate) {
18
+ manifest?.modules?.forEach(_module => {
19
+ _module?.exports?.forEach(predicate);
20
+ });
21
+ }
22
+
23
+ /**
24
+ * Loops through all modules' exports, and returns the kind provided by the users
25
+ *
26
+ * @example getKind('class');
27
+ * @example getKind('custom-element-definition');
28
+ */
29
+ export function getAllExportsOfKind(manifest, kind) {
30
+ const result = [];
31
+ loopThroughExports(manifest, (_export) => {
32
+ if(_export.kind === kind) {
33
+ result.push(_export);
34
+ }
35
+ });
36
+ return result;
37
+ }
38
+
39
+
40
+ /**
41
+ * Loops through all modules' declarations, and returns the kind provided by the users
42
+ *
43
+ * @example getKind('class');
44
+ * @example getKind('custom-element-definition');
45
+ */
46
+ export function getAllDeclarationsOfKind(manifest, kind) {
47
+ const result = [];
48
+ loopThroughDeclarations(manifest, (declaration) => {
49
+ if(declaration.kind === kind) {
50
+ result.push(declaration);
51
+ }
52
+ });
53
+ return result;
54
+ }
55
+
56
+ /**
57
+ * Gets the inheritance tree from a manifest given a className
58
+ * Returns an array of a classes mixins/superclasses all the way up the chain
59
+ *
60
+ * @param {Package[]} manifests
61
+ * @param {string} className
62
+ */
63
+ export function getInheritanceTree(manifests, className) {
64
+ const tree = [];
65
+ const allClassLikes = new Map();
66
+ const _classes = [];
67
+ const _mixins = [];
68
+
69
+ manifests.forEach((cem) => {
70
+ _classes.push(...getAllDeclarationsOfKind(cem, 'class'));
71
+ _mixins.push(...getAllDeclarationsOfKind(cem, 'mixin'));
72
+ });
73
+
74
+ [..._mixins, ..._classes].forEach((klass) => {
75
+ allClassLikes.set(klass.name, klass);
76
+ });
77
+
78
+ let klass = allClassLikes.get(className)
79
+
80
+ if(klass) {
81
+ tree.push(klass)
82
+
83
+ klass?.mixins?.forEach(mixin => {
84
+ let foundMixin = _mixins.find(m => m.name === mixin.name);
85
+ if(foundMixin) {
86
+ tree.push(foundMixin);
87
+
88
+ while(has(foundMixin?.mixins)) {
89
+ foundMixin?.mixins?.forEach(mixin => {
90
+ foundMixin = _mixins.find(m => m.name === mixin.name);
91
+ if(foundMixin) {
92
+ tree.push(foundMixin);
93
+ }
94
+ });
95
+ }
96
+ }
97
+ });
98
+
99
+ while(allClassLikes.has(klass.superclass?.name)) {
100
+ const newKlass = allClassLikes.get(klass.superclass.name);
101
+ let allMixins = [];
102
+ if (klass?.mixins) {
103
+ allMixins = [...klass.mixins];
104
+ }
105
+ if (newKlass?.mixins) {
106
+ allMixins = [...allMixins, ...newKlass.mixins];
107
+ }
108
+
109
+ allMixins.forEach(mixin => {
110
+ let foundMixin = _mixins.find(m => m.name === mixin.name);
111
+ if(foundMixin) {
112
+ tree.push(foundMixin);
113
+
114
+ while(has(foundMixin?.mixins)) {
115
+ foundMixin?.mixins?.forEach(mixin => {
116
+ foundMixin = _mixins.find(m => m.name === mixin.name);
117
+ if(foundMixin) {
118
+ tree.push(foundMixin);
119
+ }
120
+ });
121
+ }
122
+ }
123
+ });
124
+
125
+ tree.push(newKlass);
126
+ klass = newKlass;
127
+ }
128
+ return tree;
129
+ }
130
+ return [];
131
+ }
132
+
133
+ /**
134
+ * @param {Package[]} manifests
135
+ * @param {string} modulePath
136
+ */
137
+ export function getModuleFromManifests(manifests, modulePath) {
138
+ let result = undefined;
139
+
140
+ manifests.forEach((cem) => {
141
+ cem?.modules?.forEach((_module) => {
142
+ if (_module.path === modulePath) {
143
+ result = _module;
144
+ }
145
+ });
146
+ });
147
+
148
+ return result;
149
+ }
150
+
151
+ /**
152
+ * @param {Package[]} manifests
153
+ * @param {string} className
154
+ */
155
+ export function getModuleForClassLike(manifests, className) {
156
+ let result = undefined;
157
+
158
+ manifests.forEach((cem) => {
159
+ cem?.modules?.forEach(_module => {
160
+ _module?.declarations?.forEach(declaration => {
161
+ if((declaration.kind === 'class' || declaration.kind === 'mixin') && declaration.name === className) {
162
+ result = _module.path;
163
+ }
164
+ });
165
+ });
166
+ });
167
+
168
+ return result;
169
+ }
170
+
171
+ /**
172
+ * Given a manifest module, a class name, and a class member name, gets the
173
+ * manifest doc for the module's class' member.
174
+ *
175
+ * @param {Partial<import('custom-elements-manifest/schema').Module>} moduleDoc Manifest module
176
+ * @param {string} className Class to get member of
177
+ * @param {string} memberName Class member to get
178
+ * @param {boolean} isStatic Is it a static member?
179
+ * @return {import('custom-elements-manifest/schema').ClassMember|void} the requested class member
180
+ */
181
+ export function getClassMemberDoc(moduleDoc, className, memberName, isStatic = false) {
182
+ /** @type {import('custom-elements-manifest/schema').ClassDeclaration} */
183
+ const classDoc = (moduleDoc.declarations.find(x => x.name === className));
184
+
185
+ if (!classDoc || !has(classDoc.members))
186
+ return;
187
+
188
+ const memberDoc = classDoc.members.find(x =>
189
+ x.name === memberName &&
190
+ (x.static ?? false) === isStatic
191
+ );
192
+
193
+ return memberDoc;
194
+ }
@@ -0,0 +1,112 @@
1
+ import ts from 'typescript';
2
+
3
+ import { getReturnValue } from '../utils/ast-helpers.js';
4
+
5
+ export const isMixin = node => !!extractMixinNodes(node);
6
+
7
+ export function extractMixinNodes(node) {
8
+ if (ts.isVariableStatement(node) || ts.isFunctionDeclaration(node)) {
9
+ if (ts.isVariableStatement(node)) {
10
+ /**
11
+ * @example const MyMixin = klass => class MyMixin extends klass {}
12
+ * @example export const MyMixin = klass => class MyMixin extends klass {}
13
+ */
14
+ const variableDeclaration = node.declarationList.declarations.find(declaration =>
15
+ ts.isVariableDeclaration(declaration),
16
+ );
17
+ if (variableDeclaration) {
18
+ const body = variableDeclaration?.initializer?.body;
19
+ if (body && ts.isClassExpression(body)) {
20
+ return {
21
+ mixinFunction: node,
22
+ mixinClass: body,
23
+ };
24
+ }
25
+
26
+ /**
27
+ * @example const MyMixin = klass => { return class MyMixin extends Klass{} }
28
+ */
29
+ if (body && ts.isBlock(body)) {
30
+ const returnStatement = body.statements.find(statement => ts.isReturnStatement(statement));
31
+
32
+ if (returnStatement && returnStatement?.expression?.kind && ts.isClassExpression(returnStatement.expression)) {
33
+ return {
34
+ mixinFunction: variableDeclaration.initializer,
35
+ mixinClass: returnStatement.expression
36
+ };
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @example const MyMixin = klass => { class MyMixin extends klass {} return MyMixin;}
42
+ */
43
+ if (body && ts.isBlock(body)) {
44
+ const classDeclaration = body.statements.find(statement => ts.isClassDeclaration(statement));
45
+ const returnStatement = body.statements.find(statement => ts.isReturnStatement(statement));
46
+ /** Avoid undefined === undefined */
47
+ if(!(classDeclaration && returnStatement))
48
+ return;
49
+ const classDeclarationName = classDeclaration.name?.getText?.();
50
+ const returnValue = getReturnValue(returnStatement)
51
+ /**
52
+ * If the classDeclaration inside the function body has the same name as whats being
53
+ * returned from the function, consider it a mixin
54
+ */
55
+ if (classDeclarationName === returnValue) {
56
+ return {
57
+ mixinFunction: node,
58
+ mixinClass: classDeclaration
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @example function MyMixin(klass) { return class MyMixin extends Klass{} }
67
+ */
68
+ if (ts.isFunctionDeclaration(node)) {
69
+ if (node.body && ts.isBlock(node.body)) {
70
+
71
+ const returnStatement = node.body.statements.find(statement => ts.isReturnStatement(statement));
72
+
73
+ if (returnStatement?.expression && ts.isClassExpression(returnStatement.expression)) {
74
+ return {
75
+ mixinFunction: node,
76
+ mixinClass: returnStatement.expression
77
+ };
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * @example function MyMixin(klass) {class A extends klass {} return A;}
84
+ */
85
+ if (ts.isFunctionDeclaration(node)) {
86
+ if (node.body && ts.isBlock(node.body)) {
87
+ const classDeclaration = node.body.statements.find(statement => ts.isClassDeclaration(statement));
88
+ const returnStatement = node.body.statements.find(statement => ts.isReturnStatement(statement));
89
+
90
+ /** Avoid undefined === undefined */
91
+ if(!(classDeclaration && returnStatement))
92
+ return;
93
+
94
+ const classDeclarationName = classDeclaration.name?.getText?.();
95
+
96
+ const returnValue = getReturnValue(returnStatement)
97
+
98
+ /**
99
+ * If the classDeclaration inside the function body has the same name as whats being
100
+ * returned from the function, consider it a mixin
101
+ */
102
+ if (classDeclarationName === returnValue) {
103
+ return {
104
+ mixinFunction: node,
105
+ mixinClass: classDeclaration
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ return false;
112
+ }
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "definitions": {
4
+ "CssCustomState": {
5
+ "description": "The description of a CSS Custom State\nhttps://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet",
6
+ "properties": {
7
+ "deprecated": {
8
+ "description": "Whether the CSS custom state is deprecated.\nIf the value is a string, it's the reason for the deprecation.",
9
+ "type": [
10
+ "string",
11
+ "boolean"
12
+ ]
13
+ },
14
+ "description": {
15
+ "description": "A markdown description.",
16
+ "type": "string"
17
+ },
18
+ "name": {
19
+ "description": "The name of the state. Note: Unlike CSS custom properties, custom states\ndo not have a leading `--`.",
20
+ "type": "string"
21
+ },
22
+ "summary": {
23
+ "description": "A markdown summary suitable for display in a listing.",
24
+ "type": "string"
25
+ }
26
+ },
27
+ "required": [
28
+ "name"
29
+ ],
30
+ "type": "object"
31
+ },
4
32
  "Attribute": {
5
33
  "additionalProperties": false,
6
34
  "properties": {
@@ -521,6 +549,12 @@
521
549
  },
522
550
  "type": "array"
523
551
  },
552
+ "cssStates": {
553
+ "items": {
554
+ "$ref": "#/definitions/CssCustomState"
555
+ },
556
+ "type": "array"
557
+ },
524
558
  "customElement": {
525
559
  "description": "Distinguishes a regular JavaScript class from a\ncustom element class",
526
560
  "enum": [
@@ -676,6 +710,12 @@
676
710
  },
677
711
  "type": "array"
678
712
  },
713
+ "cssStates": {
714
+ "items": {
715
+ "$ref": "#/definitions/CssCustomState"
716
+ },
717
+ "type": "array"
718
+ },
679
719
  "customElement": {
680
720
  "description": "Distinguishes a regular JavaScript class from a\ncustom element class",
681
721
  "enum": [
@@ -1039,7 +1079,7 @@
1039
1079
  "type": "string"
1040
1080
  },
1041
1081
  "path": {
1042
- "description": "Path to the javascript file needed to be imported. \n(not the path for example to a typescript file.)",
1082
+ "description": "Path to the javascript file needed to be imported.\n(not the path for example to a typescript file.)",
1043
1083
  "type": "string"
1044
1084
  },
1045
1085
  "summary": {
@@ -258,6 +258,34 @@
258
258
  ],
259
259
  "type": "object"
260
260
  },
261
+ "CssCustomState": {
262
+ "description": "The description of a CSS Custom State\nhttps://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet",
263
+ "properties": {
264
+ "deprecated": {
265
+ "description": "Whether the CSS custom state is deprecated.\nIf the value is a string, it's the reason for the deprecation.",
266
+ "type": [
267
+ "string",
268
+ "boolean"
269
+ ]
270
+ },
271
+ "description": {
272
+ "description": "A markdown description.",
273
+ "type": "string"
274
+ },
275
+ "name": {
276
+ "description": "The name of the state. Note: Unlike CSS custom properties, custom states\ndo not have a leading `--`.",
277
+ "type": "string"
278
+ },
279
+ "summary": {
280
+ "description": "A markdown summary suitable for display in a listing.",
281
+ "type": "string"
282
+ }
283
+ },
284
+ "required": [
285
+ "name"
286
+ ],
287
+ "type": "object"
288
+ },
261
289
  "CssPart": {
262
290
  "description": "The description of a CSS Part",
263
291
  "properties": {
@@ -307,6 +335,12 @@
307
335
  },
308
336
  "type": "array"
309
337
  },
338
+ "cssStates": {
339
+ "items": {
340
+ "$ref": "#/definitions/CssCustomState"
341
+ },
342
+ "type": "array"
343
+ },
310
344
  "customElement": {
311
345
  "description": "Distinguishes a regular JavaScript class from a\ncustom element class",
312
346
  "enum": [
@@ -451,6 +485,12 @@
451
485
  },
452
486
  "type": "array"
453
487
  },
488
+ "cssStates": {
489
+ "items": {
490
+ "$ref": "#/definitions/CssCustomState"
491
+ },
492
+ "type": "array"
493
+ },
454
494
  "customElement": {
455
495
  "description": "Distinguishes a regular JavaScript class from a\ncustom element class",
456
496
  "enum": [
@@ -765,7 +805,7 @@
765
805
  "type": "string"
766
806
  },
767
807
  "path": {
768
- "description": "Path to the javascript file needed to be imported. \n(not the path for example to a typescript file.)",
808
+ "description": "Path to the javascript file needed to be imported.\n(not the path for example to a typescript file.)",
769
809
  "type": "string"
770
810
  },
771
811
  "summary": {
@@ -56,7 +56,7 @@ export interface JavaScriptModule {
56
56
  kind: 'javascript-module';
57
57
 
58
58
  /**
59
- * Path to the javascript file needed to be imported.
59
+ * Path to the javascript file needed to be imported.
60
60
  * (not the path for example to a typescript file.)
61
61
  */
62
62
  path: string;
@@ -258,6 +258,8 @@ export interface CustomElement extends ClassLike {
258
258
 
259
259
  cssProperties?: CssCustomProperty[];
260
260
 
261
+ cssStates?: CssCustomState[];
262
+
261
263
  demos?: Demo[];
262
264
 
263
265
  /**
@@ -416,6 +418,34 @@ export interface CssPart {
416
418
  deprecated?: boolean | string;
417
419
  }
418
420
 
421
+ /**
422
+ * The description of a CSS Custom State
423
+ * https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet
424
+ */
425
+ export interface CssCustomState {
426
+ /**
427
+ * The name of the state. Note: Unlike CSS custom properties, custom states
428
+ * do not have a leading `--`.
429
+ */
430
+ name: string;
431
+
432
+ /**
433
+ * A markdown summary suitable for display in a listing.
434
+ */
435
+ summary?: string;
436
+
437
+ /**
438
+ * A markdown description.
439
+ */
440
+ description?: string;
441
+
442
+ /**
443
+ * Whether the CSS custom state is deprecated.
444
+ * If the value is a string, it's the reason for the deprecation.
445
+ */
446
+ deprecated?: boolean | string;
447
+ }
448
+
419
449
  export interface CssCustomProperty {
420
450
  /**
421
451
  * The name of the property, including leading `--`.
@@ -632,7 +662,7 @@ export interface ClassField extends PropertyLike {
632
662
  export interface CustomElementField extends ClassField {
633
663
  /**
634
664
  * The corresponding attribute name if there is one.
635
- *
665
+ *
636
666
  * If this property is defined, the attribute must be listed in the classes'
637
667
  * `attributes` array.
638
668
  */
@@ -56,7 +56,7 @@ export interface JavaScriptModule {
56
56
  kind: 'javascript-module';
57
57
 
58
58
  /**
59
- * Path to the javascript file needed to be imported.
59
+ * Path to the javascript file needed to be imported.
60
60
  * (not the path for example to a typescript file.)
61
61
  */
62
62
  path: string;
@@ -250,6 +250,8 @@ export interface CustomElement extends ClassLike {
250
250
 
251
251
  cssProperties?: CssCustomProperty[];
252
252
 
253
+ cssStates?: CssCustomState[];
254
+
253
255
  demos?: Demo[];
254
256
 
255
257
  /**
@@ -372,6 +374,34 @@ export interface CssPart {
372
374
  deprecated?: boolean | string;
373
375
  }
374
376
 
377
+ /**
378
+ * The description of a CSS Custom State
379
+ * https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet
380
+ */
381
+ export interface CssCustomState {
382
+ /**
383
+ * The name of the state. Note: Unlike CSS custom properties, custom states
384
+ * do not have a leading `--`.
385
+ */
386
+ name: string;
387
+
388
+ /**
389
+ * A markdown summary suitable for display in a listing.
390
+ */
391
+ summary?: string;
392
+
393
+ /**
394
+ * A markdown description.
395
+ */
396
+ description?: string;
397
+
398
+ /**
399
+ * Whether the CSS custom state is deprecated.
400
+ * If the value is a string, it's the reason for the deprecation.
401
+ */
402
+ deprecated?: boolean | string;
403
+ }
404
+
375
405
  export interface CssCustomProperty {
376
406
  /**
377
407
  * The name of the property, including leading `--`.
@@ -573,7 +603,7 @@ export interface ClassField extends PropertyLike {
573
603
  export interface CustomElementField extends ClassField {
574
604
  /**
575
605
  * The corresponding attribute name if there is one.
576
- *
606
+ *
577
607
  * If this property is defined, the attribute must be listed in the classes'
578
608
  * `attributes` array.
579
609
  */
package/lib/cem/utils.mjs CHANGED
@@ -240,7 +240,7 @@ const allowedTags = {
240
240
  event: [...commonTags, "param", "native", "allowPreventDefault"],
241
241
  eventParam: [...commonTags],
242
242
  method: [...commonTags, "param", "returns", "override"],
243
- class: [...commonTags, "constructor", "class", "abstract", "experimental", "implements", "extends", "slot", "csspart"],
243
+ class: [...commonTags, "constructor", "class", "abstract", "experimental", "implements", "extends", "slot", "csspart", "cssstate", "cssState"],
244
244
  enum: [...commonTags, "experimental",],
245
245
  enumMember: [...commonTags, "experimental",],
246
246
  interface: [...commonTags, "experimental",],
@@ -330,6 +330,9 @@ const validateJSDocTag = (tag) => {
330
330
  return tag.type && tag.name && tag.description;
331
331
  case "csspart":
332
332
  return !tag.type && tag.name && tag.description;
333
+ case "cssState":
334
+ case "cssstate":
335
+ return !tag.type && tag.name && tag.description;
333
336
  case "since":
334
337
  return !tag.type && tag.name;
335
338
  case "returns":
@@ -360,7 +363,8 @@ const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
360
363
  }
361
364
 
362
365
  if (!isValid) {
363
- logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
366
+ const nodeName = node ? ` in '${node}'` : '';
367
+ logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}${nodeName}. Ensure it is part of ${fieldType} JSDoc tags.`)
364
368
  }
365
369
 
366
370
  return !!isValid;
@@ -396,7 +400,12 @@ const displayDocumentationErrors = () => {
396
400
  }
397
401
 
398
402
  const formatArrays = (typeText) => {
399
- return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
403
+ return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>");
404
+ }
405
+
406
+ // Convert Slot<T> and DefaultSlot<T> to Array<T> (the array is built into these types)
407
+ const formatSlotTypes = (typeText) => {
408
+ return typeText?.replace(/(Default)?Slot<(.+?)>/g, 'Array<$2>');
400
409
  }
401
410
 
402
411
  export {
@@ -415,6 +424,7 @@ export {
415
424
  getTypeRefs,
416
425
  normalizeDescription,
417
426
  formatArrays,
427
+ formatSlotTypes,
418
428
  isClass,
419
429
  normalizeTagType,
420
430
  displayDocumentationErrors,