cem-plugin-wrec 0.0.1
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/README.md +90 -0
- package/SyntaxKind.md +401 -0
- package/dev.js +15 -0
- package/fixtures/default/actual.json +39 -0
- package/fixtures/default/expected.json +39 -0
- package/fixtures/default/sourcecode/default.js +6 -0
- package/index.js +135 -0
- package/my-counter.js +46 -0
- package/package.json +29 -0
- package/test/integration.test.js +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# cem-plugin-wrec
|
|
2
|
+
|
|
3
|
+
This is a Custom Elements Manifest (CEM) plugin
|
|
4
|
+
for the [wrec](https://github.com/mvolkmann/wrec) library.
|
|
5
|
+
|
|
6
|
+
## Installing
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i -D @custom-elements-manifest/analyzer
|
|
10
|
+
npm i -D cem-plugin-wrec
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuring
|
|
14
|
+
|
|
15
|
+
Add the following scripts in your `package.json` file:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
"cem": "custom-elements-manifest analyze",
|
|
19
|
+
"cem:watch": "custom-elements-manifest analyze --watch",
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Create the file `custom-elements-manifest.config.js` containing the following:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import wrecPlugin from "cem-plugin-wrec";
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
plugins: [wrecPlugin()],
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Supported syntax
|
|
33
|
+
|
|
34
|
+
This plugin supports web components implementing using the wrec library.
|
|
35
|
+
See the example component defined in `my-counter.js`.
|
|
36
|
+
|
|
37
|
+
## Expected output
|
|
38
|
+
|
|
39
|
+
Document an example of the expected output custom elements manifest
|
|
40
|
+
|
|
41
|
+
```diff
|
|
42
|
+
{
|
|
43
|
+
"schemaVersion": "1.0.0",
|
|
44
|
+
"readme": "",
|
|
45
|
+
"modules": [
|
|
46
|
+
{
|
|
47
|
+
"kind": "javascript-module",
|
|
48
|
+
"path": "src/my-element.js",
|
|
49
|
+
"declarations": [
|
|
50
|
+
{
|
|
51
|
+
"kind": "class",
|
|
52
|
+
"description": "This is a counter web component.",
|
|
53
|
+
"name": "MyCounter",
|
|
54
|
+
"members": [
|
|
55
|
+
{
|
|
56
|
+
"kind": "method",
|
|
57
|
+
"name": "decrement"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"attributes": [
|
|
61
|
+
{
|
|
62
|
+
"default": 0,
|
|
63
|
+
"description": "initial value",
|
|
64
|
+
"fieldName": "count",
|
|
65
|
+
"name": "count",
|
|
66
|
+
"type": "Number"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"superclass": {
|
|
70
|
+
"name": "Wrec",
|
|
71
|
+
"package": "wrec"
|
|
72
|
+
},
|
|
73
|
+
"tagName": "my-counter",
|
|
74
|
+
"customElement": true
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"exports": [
|
|
78
|
+
{
|
|
79
|
+
"kind": "custom-element-definition",
|
|
80
|
+
"name": "my-counter",
|
|
81
|
+
"declaration": {
|
|
82
|
+
"name": "MyCounter",
|
|
83
|
+
"module": "src/my-element.js"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
```
|
package/SyntaxKind.md
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
# ts.SyntaxKind Properties
|
|
2
|
+
|
|
3
|
+
0 - FirstToken
|
|
4
|
+
0 - Unknown
|
|
5
|
+
1 - EndOfFileToken
|
|
6
|
+
2 - FirstTriviaToken
|
|
7
|
+
2 - SingleLineCommentTrivia
|
|
8
|
+
3 - MultiLineCommentTrivia
|
|
9
|
+
4 - NewLineTrivia
|
|
10
|
+
5 - WhitespaceTrivia
|
|
11
|
+
6 - ShebangTrivia
|
|
12
|
+
7 - ConflictMarkerTrivia
|
|
13
|
+
7 - LastTriviaToken
|
|
14
|
+
8 - NonTextFileMarkerTrivia
|
|
15
|
+
9 - FirstLiteralToken
|
|
16
|
+
9 - NumericLiteral
|
|
17
|
+
10 - BigIntLiteral
|
|
18
|
+
11 - StringLiteral
|
|
19
|
+
12 - JsxText
|
|
20
|
+
13 - JsxTextAllWhiteSpaces
|
|
21
|
+
14 - RegularExpressionLiteral
|
|
22
|
+
15 - FirstTemplateToken
|
|
23
|
+
15 - LastLiteralToken
|
|
24
|
+
15 - NoSubstitutionTemplateLiteral
|
|
25
|
+
16 - TemplateHead
|
|
26
|
+
17 - TemplateMiddle
|
|
27
|
+
18 - LastTemplateToken
|
|
28
|
+
18 - TemplateTail
|
|
29
|
+
19 - FirstPunctuation
|
|
30
|
+
19 - OpenBraceToken
|
|
31
|
+
20 - CloseBraceToken
|
|
32
|
+
21 - OpenParenToken
|
|
33
|
+
22 - CloseParenToken
|
|
34
|
+
23 - OpenBracketToken
|
|
35
|
+
24 - CloseBracketToken
|
|
36
|
+
25 - DotToken
|
|
37
|
+
26 - DotDotDotToken
|
|
38
|
+
27 - SemicolonToken
|
|
39
|
+
28 - CommaToken
|
|
40
|
+
29 - QuestionDotToken
|
|
41
|
+
30 - FirstBinaryOperator
|
|
42
|
+
30 - LessThanToken
|
|
43
|
+
31 - LessThanSlashToken
|
|
44
|
+
32 - GreaterThanToken
|
|
45
|
+
33 - LessThanEqualsToken
|
|
46
|
+
34 - GreaterThanEqualsToken
|
|
47
|
+
35 - EqualsEqualsToken
|
|
48
|
+
36 - ExclamationEqualsToken
|
|
49
|
+
37 - EqualsEqualsEqualsToken
|
|
50
|
+
38 - ExclamationEqualsEqualsToken
|
|
51
|
+
39 - EqualsGreaterThanToken
|
|
52
|
+
40 - PlusToken
|
|
53
|
+
41 - MinusToken
|
|
54
|
+
42 - AsteriskToken
|
|
55
|
+
43 - AsteriskAsteriskToken
|
|
56
|
+
44 - SlashToken
|
|
57
|
+
45 - PercentToken
|
|
58
|
+
46 - PlusPlusToken
|
|
59
|
+
47 - MinusMinusToken
|
|
60
|
+
48 - LessThanLessThanToken
|
|
61
|
+
49 - GreaterThanGreaterThanToken
|
|
62
|
+
50 - GreaterThanGreaterThanGreaterThanToken
|
|
63
|
+
51 - AmpersandToken
|
|
64
|
+
52 - BarToken
|
|
65
|
+
53 - CaretToken
|
|
66
|
+
54 - ExclamationToken
|
|
67
|
+
55 - TildeToken
|
|
68
|
+
56 - AmpersandAmpersandToken
|
|
69
|
+
57 - BarBarToken
|
|
70
|
+
58 - QuestionToken
|
|
71
|
+
59 - ColonToken
|
|
72
|
+
60 - AtToken
|
|
73
|
+
61 - QuestionQuestionToken
|
|
74
|
+
62 - BacktickToken
|
|
75
|
+
63 - HashToken
|
|
76
|
+
64 - EqualsToken
|
|
77
|
+
64 - FirstAssignment
|
|
78
|
+
65 - FirstCompoundAssignment
|
|
79
|
+
65 - PlusEqualsToken
|
|
80
|
+
66 - MinusEqualsToken
|
|
81
|
+
67 - AsteriskEqualsToken
|
|
82
|
+
68 - AsteriskAsteriskEqualsToken
|
|
83
|
+
69 - SlashEqualsToken
|
|
84
|
+
70 - PercentEqualsToken
|
|
85
|
+
71 - LessThanLessThanEqualsToken
|
|
86
|
+
72 - GreaterThanGreaterThanEqualsToken
|
|
87
|
+
73 - GreaterThanGreaterThanGreaterThanEqualsToken
|
|
88
|
+
74 - AmpersandEqualsToken
|
|
89
|
+
75 - BarEqualsToken
|
|
90
|
+
76 - BarBarEqualsToken
|
|
91
|
+
77 - AmpersandAmpersandEqualsToken
|
|
92
|
+
78 - QuestionQuestionEqualsToken
|
|
93
|
+
79 - CaretEqualsToken
|
|
94
|
+
79 - LastAssignment
|
|
95
|
+
79 - LastBinaryOperator
|
|
96
|
+
79 - LastCompoundAssignment
|
|
97
|
+
79 - LastPunctuation
|
|
98
|
+
80 - Identifier
|
|
99
|
+
81 - PrivateIdentifier
|
|
100
|
+
82 - JSDocCommentTextToken
|
|
101
|
+
83 - BreakKeyword
|
|
102
|
+
83 - FirstKeyword
|
|
103
|
+
83 - FirstReservedWord
|
|
104
|
+
84 - CaseKeyword
|
|
105
|
+
85 - CatchKeyword
|
|
106
|
+
86 - ClassKeyword
|
|
107
|
+
87 - ConstKeyword
|
|
108
|
+
88 - ContinueKeyword
|
|
109
|
+
89 - DebuggerKeyword
|
|
110
|
+
90 - DefaultKeyword
|
|
111
|
+
91 - DeleteKeyword
|
|
112
|
+
92 - DoKeyword
|
|
113
|
+
93 - ElseKeyword
|
|
114
|
+
94 - EnumKeyword
|
|
115
|
+
95 - ExportKeyword
|
|
116
|
+
96 - ExtendsKeyword
|
|
117
|
+
97 - FalseKeyword
|
|
118
|
+
98 - FinallyKeyword
|
|
119
|
+
99 - ForKeyword
|
|
120
|
+
100 - FunctionKeyword
|
|
121
|
+
101 - IfKeyword
|
|
122
|
+
102 - ImportKeyword
|
|
123
|
+
103 - InKeyword
|
|
124
|
+
104 - InstanceOfKeyword
|
|
125
|
+
105 - NewKeyword
|
|
126
|
+
106 - NullKeyword
|
|
127
|
+
107 - ReturnKeyword
|
|
128
|
+
108 - SuperKeyword
|
|
129
|
+
109 - SwitchKeyword
|
|
130
|
+
110 - ThisKeyword
|
|
131
|
+
111 - ThrowKeyword
|
|
132
|
+
112 - TrueKeyword
|
|
133
|
+
113 - TryKeyword
|
|
134
|
+
114 - TypeOfKeyword
|
|
135
|
+
115 - VarKeyword
|
|
136
|
+
116 - VoidKeyword
|
|
137
|
+
117 - WhileKeyword
|
|
138
|
+
118 - LastReservedWord
|
|
139
|
+
118 - WithKeyword
|
|
140
|
+
119 - FirstFutureReservedWord
|
|
141
|
+
119 - ImplementsKeyword
|
|
142
|
+
120 - InterfaceKeyword
|
|
143
|
+
121 - LetKeyword
|
|
144
|
+
122 - PackageKeyword
|
|
145
|
+
123 - PrivateKeyword
|
|
146
|
+
124 - ProtectedKeyword
|
|
147
|
+
125 - PublicKeyword
|
|
148
|
+
126 - StaticKeyword
|
|
149
|
+
127 - LastFutureReservedWord
|
|
150
|
+
127 - YieldKeyword
|
|
151
|
+
128 - AbstractKeyword
|
|
152
|
+
128 - FirstContextualKeyword
|
|
153
|
+
129 - AccessorKeyword
|
|
154
|
+
130 - AsKeyword
|
|
155
|
+
131 - AssertsKeyword
|
|
156
|
+
132 - AssertKeyword
|
|
157
|
+
133 - AnyKeyword
|
|
158
|
+
134 - AsyncKeyword
|
|
159
|
+
135 - AwaitKeyword
|
|
160
|
+
136 - BooleanKeyword
|
|
161
|
+
137 - ConstructorKeyword
|
|
162
|
+
138 - DeclareKeyword
|
|
163
|
+
139 - GetKeyword
|
|
164
|
+
140 - InferKeyword
|
|
165
|
+
141 - IntrinsicKeyword
|
|
166
|
+
142 - IsKeyword
|
|
167
|
+
143 - KeyOfKeyword
|
|
168
|
+
144 - ModuleKeyword
|
|
169
|
+
145 - NamespaceKeyword
|
|
170
|
+
146 - NeverKeyword
|
|
171
|
+
147 - OutKeyword
|
|
172
|
+
148 - ReadonlyKeyword
|
|
173
|
+
149 - RequireKeyword
|
|
174
|
+
150 - NumberKeyword
|
|
175
|
+
151 - ObjectKeyword
|
|
176
|
+
152 - SatisfiesKeyword
|
|
177
|
+
153 - SetKeyword
|
|
178
|
+
154 - StringKeyword
|
|
179
|
+
155 - SymbolKeyword
|
|
180
|
+
156 - TypeKeyword
|
|
181
|
+
157 - UndefinedKeyword
|
|
182
|
+
158 - UniqueKeyword
|
|
183
|
+
159 - UnknownKeyword
|
|
184
|
+
160 - UsingKeyword
|
|
185
|
+
161 - FromKeyword
|
|
186
|
+
162 - GlobalKeyword
|
|
187
|
+
163 - BigIntKeyword
|
|
188
|
+
164 - OverrideKeyword
|
|
189
|
+
165 - LastContextualKeyword
|
|
190
|
+
165 - LastKeyword
|
|
191
|
+
165 - LastToken
|
|
192
|
+
165 - OfKeyword
|
|
193
|
+
166 - FirstNode
|
|
194
|
+
166 - QualifiedName
|
|
195
|
+
167 - ComputedPropertyName
|
|
196
|
+
168 - TypeParameter
|
|
197
|
+
169 - Parameter
|
|
198
|
+
170 - Decorator
|
|
199
|
+
171 - PropertySignature
|
|
200
|
+
172 - PropertyDeclaration
|
|
201
|
+
173 - MethodSignature
|
|
202
|
+
174 - MethodDeclaration
|
|
203
|
+
175 - ClassStaticBlockDeclaration
|
|
204
|
+
176 - Constructor
|
|
205
|
+
177 - GetAccessor
|
|
206
|
+
178 - SetAccessor
|
|
207
|
+
179 - CallSignature
|
|
208
|
+
180 - ConstructSignature
|
|
209
|
+
181 - IndexSignature
|
|
210
|
+
182 - FirstTypeNode
|
|
211
|
+
182 - TypePredicate
|
|
212
|
+
183 - TypeReference
|
|
213
|
+
184 - FunctionType
|
|
214
|
+
185 - ConstructorType
|
|
215
|
+
186 - TypeQuery
|
|
216
|
+
187 - TypeLiteral
|
|
217
|
+
188 - ArrayType
|
|
218
|
+
189 - TupleType
|
|
219
|
+
190 - OptionalType
|
|
220
|
+
191 - RestType
|
|
221
|
+
192 - UnionType
|
|
222
|
+
193 - IntersectionType
|
|
223
|
+
194 - ConditionalType
|
|
224
|
+
195 - InferType
|
|
225
|
+
196 - ParenthesizedType
|
|
226
|
+
197 - ThisType
|
|
227
|
+
198 - TypeOperator
|
|
228
|
+
199 - IndexedAccessType
|
|
229
|
+
200 - MappedType
|
|
230
|
+
201 - LiteralType
|
|
231
|
+
202 - NamedTupleMember
|
|
232
|
+
203 - TemplateLiteralType
|
|
233
|
+
204 - TemplateLiteralTypeSpan
|
|
234
|
+
205 - ImportType
|
|
235
|
+
205 - LastTypeNode
|
|
236
|
+
206 - ObjectBindingPattern
|
|
237
|
+
207 - ArrayBindingPattern
|
|
238
|
+
208 - BindingElement
|
|
239
|
+
209 - ArrayLiteralExpression
|
|
240
|
+
210 - ObjectLiteralExpression
|
|
241
|
+
211 - PropertyAccessExpression
|
|
242
|
+
212 - ElementAccessExpression
|
|
243
|
+
213 - CallExpression
|
|
244
|
+
214 - NewExpression
|
|
245
|
+
215 - TaggedTemplateExpression
|
|
246
|
+
216 - TypeAssertionExpression
|
|
247
|
+
217 - ParenthesizedExpression
|
|
248
|
+
218 - FunctionExpression
|
|
249
|
+
219 - ArrowFunction
|
|
250
|
+
220 - DeleteExpression
|
|
251
|
+
221 - TypeOfExpression
|
|
252
|
+
222 - VoidExpression
|
|
253
|
+
223 - AwaitExpression
|
|
254
|
+
224 - PrefixUnaryExpression
|
|
255
|
+
225 - PostfixUnaryExpression
|
|
256
|
+
226 - BinaryExpression
|
|
257
|
+
227 - ConditionalExpression
|
|
258
|
+
228 - TemplateExpression
|
|
259
|
+
229 - YieldExpression
|
|
260
|
+
230 - SpreadElement
|
|
261
|
+
231 - ClassExpression
|
|
262
|
+
232 - OmittedExpression
|
|
263
|
+
233 - ExpressionWithTypeArguments
|
|
264
|
+
234 - AsExpression
|
|
265
|
+
235 - NonNullExpression
|
|
266
|
+
236 - MetaProperty
|
|
267
|
+
237 - SyntheticExpression
|
|
268
|
+
238 - SatisfiesExpression
|
|
269
|
+
239 - TemplateSpan
|
|
270
|
+
240 - SemicolonClassElement
|
|
271
|
+
241 - Block
|
|
272
|
+
242 - EmptyStatement
|
|
273
|
+
243 - FirstStatement
|
|
274
|
+
243 - VariableStatement
|
|
275
|
+
244 - ExpressionStatement
|
|
276
|
+
245 - IfStatement
|
|
277
|
+
246 - DoStatement
|
|
278
|
+
247 - WhileStatement
|
|
279
|
+
248 - ForStatement
|
|
280
|
+
249 - ForInStatement
|
|
281
|
+
250 - ForOfStatement
|
|
282
|
+
251 - ContinueStatement
|
|
283
|
+
252 - BreakStatement
|
|
284
|
+
253 - ReturnStatement
|
|
285
|
+
254 - WithStatement
|
|
286
|
+
255 - SwitchStatement
|
|
287
|
+
256 - LabeledStatement
|
|
288
|
+
257 - ThrowStatement
|
|
289
|
+
258 - TryStatement
|
|
290
|
+
259 - DebuggerStatement
|
|
291
|
+
259 - LastStatement
|
|
292
|
+
260 - VariableDeclaration
|
|
293
|
+
261 - VariableDeclarationList
|
|
294
|
+
262 - FunctionDeclaration
|
|
295
|
+
263 - ClassDeclaration
|
|
296
|
+
264 - InterfaceDeclaration
|
|
297
|
+
265 - TypeAliasDeclaration
|
|
298
|
+
266 - EnumDeclaration
|
|
299
|
+
267 - ModuleDeclaration
|
|
300
|
+
268 - ModuleBlock
|
|
301
|
+
269 - CaseBlock
|
|
302
|
+
270 - NamespaceExportDeclaration
|
|
303
|
+
271 - ImportEqualsDeclaration
|
|
304
|
+
272 - ImportDeclaration
|
|
305
|
+
273 - ImportClause
|
|
306
|
+
274 - NamespaceImport
|
|
307
|
+
275 - NamedImports
|
|
308
|
+
276 - ImportSpecifier
|
|
309
|
+
277 - ExportAssignment
|
|
310
|
+
278 - ExportDeclaration
|
|
311
|
+
279 - NamedExports
|
|
312
|
+
280 - NamespaceExport
|
|
313
|
+
281 - ExportSpecifier
|
|
314
|
+
282 - MissingDeclaration
|
|
315
|
+
283 - ExternalModuleReference
|
|
316
|
+
284 - JsxElement
|
|
317
|
+
285 - JsxSelfClosingElement
|
|
318
|
+
286 - JsxOpeningElement
|
|
319
|
+
287 - JsxClosingElement
|
|
320
|
+
288 - JsxFragment
|
|
321
|
+
289 - JsxOpeningFragment
|
|
322
|
+
290 - JsxClosingFragment
|
|
323
|
+
291 - JsxAttribute
|
|
324
|
+
292 - JsxAttributes
|
|
325
|
+
293 - JsxSpreadAttribute
|
|
326
|
+
294 - JsxExpression
|
|
327
|
+
295 - JsxNamespacedName
|
|
328
|
+
296 - CaseClause
|
|
329
|
+
297 - DefaultClause
|
|
330
|
+
298 - HeritageClause
|
|
331
|
+
299 - CatchClause
|
|
332
|
+
300 - AssertClause
|
|
333
|
+
300 - ImportAttributes
|
|
334
|
+
301 - AssertEntry
|
|
335
|
+
301 - ImportAttribute
|
|
336
|
+
302 - ImportTypeAssertionContainer
|
|
337
|
+
303 - PropertyAssignment
|
|
338
|
+
304 - ShorthandPropertyAssignment
|
|
339
|
+
305 - SpreadAssignment
|
|
340
|
+
306 - EnumMember
|
|
341
|
+
307 - UnparsedPrologue
|
|
342
|
+
308 - UnparsedPrepend
|
|
343
|
+
309 - UnparsedText
|
|
344
|
+
310 - UnparsedInternalText
|
|
345
|
+
311 - UnparsedSyntheticReference
|
|
346
|
+
312 - SourceFile
|
|
347
|
+
313 - Bundle
|
|
348
|
+
314 - UnparsedSource
|
|
349
|
+
315 - InputFiles
|
|
350
|
+
316 - FirstJSDocNode
|
|
351
|
+
316 - JSDocTypeExpression
|
|
352
|
+
317 - JSDocNameReference
|
|
353
|
+
318 - JSDocMemberName
|
|
354
|
+
319 - JSDocAllType
|
|
355
|
+
320 - JSDocUnknownType
|
|
356
|
+
321 - JSDocNullableType
|
|
357
|
+
322 - JSDocNonNullableType
|
|
358
|
+
323 - JSDocOptionalType
|
|
359
|
+
324 - JSDocFunctionType
|
|
360
|
+
325 - JSDocVariadicType
|
|
361
|
+
326 - JSDocNamepathType
|
|
362
|
+
327 - JSDoc
|
|
363
|
+
327 - JSDocComment
|
|
364
|
+
328 - JSDocText
|
|
365
|
+
329 - JSDocTypeLiteral
|
|
366
|
+
330 - JSDocSignature
|
|
367
|
+
331 - JSDocLink
|
|
368
|
+
332 - JSDocLinkCode
|
|
369
|
+
333 - JSDocLinkPlain
|
|
370
|
+
334 - FirstJSDocTagNode
|
|
371
|
+
334 - JSDocTag
|
|
372
|
+
335 - JSDocAugmentsTag
|
|
373
|
+
336 - JSDocImplementsTag
|
|
374
|
+
337 - JSDocAuthorTag
|
|
375
|
+
338 - JSDocDeprecatedTag
|
|
376
|
+
339 - JSDocClassTag
|
|
377
|
+
340 - JSDocPublicTag
|
|
378
|
+
341 - JSDocPrivateTag
|
|
379
|
+
342 - JSDocProtectedTag
|
|
380
|
+
343 - JSDocReadonlyTag
|
|
381
|
+
344 - JSDocOverrideTag
|
|
382
|
+
345 - JSDocCallbackTag
|
|
383
|
+
346 - JSDocOverloadTag
|
|
384
|
+
347 - JSDocEnumTag
|
|
385
|
+
348 - JSDocParameterTag
|
|
386
|
+
349 - JSDocReturnTag
|
|
387
|
+
350 - JSDocThisTag
|
|
388
|
+
351 - JSDocTypeTag
|
|
389
|
+
352 - JSDocTemplateTag
|
|
390
|
+
353 - JSDocTypedefTag
|
|
391
|
+
354 - JSDocSeeTag
|
|
392
|
+
355 - JSDocPropertyTag
|
|
393
|
+
356 - JSDocThrowsTag
|
|
394
|
+
357 - JSDocSatisfiesTag
|
|
395
|
+
357 - LastJSDocNode
|
|
396
|
+
357 - LastJSDocTagNode
|
|
397
|
+
358 - SyntaxList
|
|
398
|
+
359 - NotEmittedStatement
|
|
399
|
+
360 - PartiallyEmittedExpression
|
|
400
|
+
361 - CommaListExpression
|
|
401
|
+
362 - SyntheticReferenceExpression
|
package/dev.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { create } from '@custom-elements-manifest/analyzer/src/create.js';
|
|
4
|
+
import myPlugin from './index.js';
|
|
5
|
+
|
|
6
|
+
const code = fs.readFileSync('fixtures/default/sourcecode/default.js').toString();
|
|
7
|
+
|
|
8
|
+
const modules = [ts.createSourceFile(
|
|
9
|
+
'my-element.js',
|
|
10
|
+
code,
|
|
11
|
+
ts.ScriptTarget.ES2015,
|
|
12
|
+
true,
|
|
13
|
+
)];
|
|
14
|
+
|
|
15
|
+
console.log(JSON.stringify(create({modules, plugins: [myPlugin()]}), null, 2));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "0.1.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "my-element.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "",
|
|
12
|
+
"name": "MyElement",
|
|
13
|
+
"members": [
|
|
14
|
+
{
|
|
15
|
+
"kind": "field",
|
|
16
|
+
"name": "someField",
|
|
17
|
+
"default": "",
|
|
18
|
+
"foo": "Some custom information!"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"superclass": {
|
|
22
|
+
"name": "HTMLElement"
|
|
23
|
+
},
|
|
24
|
+
"customElement": true
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"exports": [
|
|
28
|
+
{
|
|
29
|
+
"kind": "js",
|
|
30
|
+
"name": "MyElement",
|
|
31
|
+
"declaration": {
|
|
32
|
+
"name": "MyElement",
|
|
33
|
+
"module": "my-element.js"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "0.1.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "my-element.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "",
|
|
12
|
+
"name": "MyElement",
|
|
13
|
+
"members": [
|
|
14
|
+
{
|
|
15
|
+
"kind": "field",
|
|
16
|
+
"name": "someField",
|
|
17
|
+
"default": "",
|
|
18
|
+
"foo": "Some custom information!"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"superclass": {
|
|
22
|
+
"name": "HTMLElement"
|
|
23
|
+
},
|
|
24
|
+
"customElement": true
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"exports": [
|
|
28
|
+
{
|
|
29
|
+
"kind": "js",
|
|
30
|
+
"name": "MyElement",
|
|
31
|
+
"declaration": {
|
|
32
|
+
"name": "MyElement",
|
|
33
|
+
"module": "my-element.js"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
function wrecPlugin() {
|
|
2
|
+
//export default // TODO: Need this?
|
|
3
|
+
|
|
4
|
+
const MEMBERS_TO_HIDE = new Set(["css", "html", "properties"]);
|
|
5
|
+
|
|
6
|
+
let currentClass;
|
|
7
|
+
let isStatic = false;
|
|
8
|
+
let Kind = {};
|
|
9
|
+
let propertyName = "";
|
|
10
|
+
|
|
11
|
+
function nodeValue(node) {
|
|
12
|
+
const { initializer } = node;
|
|
13
|
+
switch (initializer.kind) {
|
|
14
|
+
case Kind.Identifier:
|
|
15
|
+
return initializer.getText();
|
|
16
|
+
case Kind.FalseKeyword:
|
|
17
|
+
return false;
|
|
18
|
+
case Kind.TrueKeyword:
|
|
19
|
+
return true;
|
|
20
|
+
case Kind.NumericLiteral:
|
|
21
|
+
return Number(node.initializer.text);
|
|
22
|
+
case Kind.NullKeyword:
|
|
23
|
+
return null;
|
|
24
|
+
case Kind.StringLiteral:
|
|
25
|
+
return node.initializer.text;
|
|
26
|
+
default:
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
name: "wrec-plugin",
|
|
33
|
+
|
|
34
|
+
// Runs before analysis starts
|
|
35
|
+
//initialize({ ts, customElementsManifest, context }) {},
|
|
36
|
+
|
|
37
|
+
// Runs for all modules in a project, before continuing to the analyzePhase
|
|
38
|
+
//collectPhase({ ts, node, context }) {},
|
|
39
|
+
|
|
40
|
+
// Runs for each module
|
|
41
|
+
analyzePhase({ ts, node, moduleDoc, context }) {
|
|
42
|
+
Kind = ts.SyntaxKind;
|
|
43
|
+
|
|
44
|
+
switch (node.kind) {
|
|
45
|
+
case Kind.ClassDeclaration:
|
|
46
|
+
const className = node.name.getText();
|
|
47
|
+
const heritage = node.heritageClauses[0];
|
|
48
|
+
if (heritage) {
|
|
49
|
+
const superclass = heritage.types[0].expression.getText();
|
|
50
|
+
if (superclass === "Wrec") {
|
|
51
|
+
const elementName = className
|
|
52
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
53
|
+
.toLowerCase();
|
|
54
|
+
moduleDoc.exports.push({
|
|
55
|
+
kind: "custom-element-definition",
|
|
56
|
+
name: elementName,
|
|
57
|
+
declaration: {
|
|
58
|
+
name: className,
|
|
59
|
+
module: moduleDoc.path,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
currentClass = moduleDoc?.declarations?.find(
|
|
63
|
+
(declaration) => declaration.name === className
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
case Kind.ObjectLiteralExpression: {
|
|
70
|
+
if (isStatic && propertyName === "properties") {
|
|
71
|
+
if (!currentClass.attributes) currentClass.attributes = [];
|
|
72
|
+
|
|
73
|
+
for (const property of node.properties) {
|
|
74
|
+
const name = property.name.getText();
|
|
75
|
+
let doc = "";
|
|
76
|
+
let type;
|
|
77
|
+
let value;
|
|
78
|
+
|
|
79
|
+
if (property.kind === Kind.PropertyAssignment) {
|
|
80
|
+
const { initializer } = property;
|
|
81
|
+
if (initializer.kind === Kind.ObjectLiteralExpression) {
|
|
82
|
+
for (const property2 of initializer.properties) {
|
|
83
|
+
const name2 = property2.name.getText();
|
|
84
|
+
const value2 = nodeValue(property2);
|
|
85
|
+
if (name2 === "doc") doc = value2;
|
|
86
|
+
if (name2 === "type") type = value2;
|
|
87
|
+
if (name2 === "value") value = value2;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
currentClass.attributes.push({
|
|
93
|
+
default: value,
|
|
94
|
+
description: doc,
|
|
95
|
+
fieldName: name,
|
|
96
|
+
name,
|
|
97
|
+
type,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
isStatic = false;
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
case Kind.PropertyDeclaration:
|
|
107
|
+
propertyName = node.name.getText();
|
|
108
|
+
break;
|
|
109
|
+
|
|
110
|
+
case Kind.StaticKeyword:
|
|
111
|
+
isStatic = true;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// Runs for each module, after analyzing, all information about your module should now be available
|
|
117
|
+
moduleLinkPhase({ moduleDoc, context }) {
|
|
118
|
+
const classes = moduleDoc?.declarations?.filter(
|
|
119
|
+
(declaration) => declaration.kind === "class"
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
for (aClass of classes) {
|
|
123
|
+
const { members } = aClass;
|
|
124
|
+
if (members) {
|
|
125
|
+
aClass.members = members.filter(
|
|
126
|
+
(member) => !MEMBERS_TO_HIDE.has(member.name)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
// Runs after modules have been parsed and after post-processing
|
|
133
|
+
//packageLinkPhase({ customElementsManifest, context }) {},
|
|
134
|
+
};
|
|
135
|
+
}
|
package/my-counter.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Wrec from "wrec";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a counter web component.
|
|
5
|
+
*/
|
|
6
|
+
class MyCounter extends Wrec {
|
|
7
|
+
static properties = {
|
|
8
|
+
count: { doc: "initial value", type: Number, reflect: true, value: 0 },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
css() {
|
|
12
|
+
return /*css*/ `
|
|
13
|
+
.counter {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 0.5rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
button {
|
|
20
|
+
background-color: lightgreen;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
button:disabled {
|
|
24
|
+
background-color: gray;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html() {
|
|
30
|
+
return /*html*/ `
|
|
31
|
+
<div>
|
|
32
|
+
<button onClick="decrement" type="button"
|
|
33
|
+
disabled="this.count === 0">-</button>
|
|
34
|
+
<span>this.count</span>
|
|
35
|
+
<button onClick="this.count++" type="button">+</button>
|
|
36
|
+
<span>(this.count < 10 ? "single" : "double") + " digit"</span>
|
|
37
|
+
</div>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
decrement() {
|
|
42
|
+
if (this.count > 0) this.count--;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
MyCounter.register();
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cem-plugin-wrec",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "plugin for use with @custom-elements-manifest/analyzer",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "nodemon dev.js",
|
|
9
|
+
"test": "uvu test"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"custom-elements",
|
|
13
|
+
"custom-elements-json",
|
|
14
|
+
"custom-elements-manifest",
|
|
15
|
+
"customelements",
|
|
16
|
+
"webcomponents",
|
|
17
|
+
"customelementsjson",
|
|
18
|
+
"customelementsmanifest"
|
|
19
|
+
],
|
|
20
|
+
"author": "R. Mark Volkmann",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@custom-elements-manifest/analyzer": "^0.1.14",
|
|
24
|
+
"globby": "^11.0.3",
|
|
25
|
+
"nodemon": "^2.0.7",
|
|
26
|
+
"typescript": "^4.3.2",
|
|
27
|
+
"uvu": "^0.5.1"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { test } from 'uvu';
|
|
2
|
+
import * as assert from 'uvu/assert';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import globby from 'globby';
|
|
6
|
+
import ts from 'typescript';
|
|
7
|
+
import { create } from '@custom-elements-manifest/analyzer/src/create.js';
|
|
8
|
+
import myPlugin from '../index.js';
|
|
9
|
+
|
|
10
|
+
const fixturesDir = path.join(process.cwd(), 'fixtures');
|
|
11
|
+
let testCases = fs.readdirSync(fixturesDir);
|
|
12
|
+
|
|
13
|
+
testCases.forEach(testCase => {
|
|
14
|
+
test(`Testcase ${testCase}`, async () => {
|
|
15
|
+
|
|
16
|
+
const fixturePath = path.join(fixturesDir, `${testCase}/expected.json`);
|
|
17
|
+
const fixture = JSON.parse(fs.readFileSync(fixturePath, 'utf-8'));
|
|
18
|
+
|
|
19
|
+
const packagePath = path.join(fixturesDir, `${testCase}/sourcecode`);
|
|
20
|
+
const packagePathPosix = packagePath.split(path.sep).join(path.posix.sep);
|
|
21
|
+
const outputPath = path.join(fixturesDir, `${testCase}/actual.json`);
|
|
22
|
+
|
|
23
|
+
const globs = await globby(packagePathPosix);
|
|
24
|
+
const modules = globs.map(glob => {
|
|
25
|
+
const relativeModulePath = `.${path.sep}${path.relative(process.cwd(), glob)}`;
|
|
26
|
+
const source = fs.readFileSync(relativeModulePath).toString();
|
|
27
|
+
|
|
28
|
+
return ts.createSourceFile(
|
|
29
|
+
'my-element.js',
|
|
30
|
+
source,
|
|
31
|
+
ts.ScriptTarget.ES2015,
|
|
32
|
+
true,
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const result = create({modules, plugins: [myPlugin()]});
|
|
37
|
+
|
|
38
|
+
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
|
|
39
|
+
|
|
40
|
+
assert.equal(result, fixture);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test.run();
|