@ui5/webcomponents-tools 1.22.0-rc.0 → 1.22.0-rc.2

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.
@@ -1,4 +1,12 @@
1
- export type Privacy = "private" | "protected" | "public"
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
4
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ * Code distributed by Google as part of the polymer project is also
8
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ */
2
10
 
3
11
  /**
4
12
  * The top-level interface of a custom elements manifest file.
@@ -15,14 +23,10 @@ export type Privacy = "private" | "protected" | "public"
15
23
  */
16
24
  export interface Package {
17
25
  /**
18
- * Whether the package is deprecated.
19
- * If the value is a string, it's the reason for the deprecation.
20
- */
21
- deprecated?: string | boolean
22
- /**
23
- * An array of the modules this package contains.
26
+ * The version of the schema used in this file.
24
27
  */
25
- modules: JavaScriptModule[]
28
+ schemaVersion: string;
29
+
26
30
  /**
27
31
  * The Markdown to use for the main readme of this package.
28
32
  *
@@ -30,131 +34,135 @@ export interface Package {
30
34
  * file contains information irrelevant to custom element catalogs and
31
35
  * documentation viewers.
32
36
  */
33
- readme?: string
37
+ readme?: string;
38
+
34
39
  /**
35
- * The version of the schema used in this file.
40
+ * An array of the modules this package contains.
41
+ */
42
+ modules: Array<Module>;
43
+
44
+ /**
45
+ * Whether the package is deprecated.
46
+ * If the value is a string, it's the reason for the deprecation.
36
47
  */
37
- schemaVersion: string
48
+ deprecated?: boolean | string;
38
49
  }
50
+
51
+ // This type may expand in the future to include JSON, CSS, or HTML
52
+ // modules.
53
+ export type Module = JavaScriptModule;
54
+
39
55
  export interface JavaScriptModule {
56
+ kind: 'javascript-module';
57
+
40
58
  /**
41
- * The declarations of a module.
42
- *
43
- * For documentation purposes, all declarations that are reachable from
44
- * exports should be described here. Ie, functions and objects that may be
45
- * properties of exported objects, or passed as arguments to functions.
59
+ * Path to the javascript file needed to be imported.
60
+ * (not the path for example to a typescript file.)
46
61
  */
47
- declarations?: (
48
- | ClassDeclaration
49
- | FunctionDeclaration
50
- | MixinDeclaration
51
- | VariableDeclaration
52
- | CustomElementDeclaration
53
- | CustomElementMixinDeclaration
54
- )[]
62
+ path: string;
63
+
55
64
  /**
56
- * Whether the module is deprecated.
57
- * If the value is a string, it's the reason for the deprecation.
65
+ * A markdown summary suitable for display in a listing.
58
66
  */
59
- deprecated?: string | boolean
67
+ summary?: string;
68
+
60
69
  /**
61
70
  * A markdown description of the module.
62
71
  */
63
- description?: string
64
- /**
65
- * The exports of a module. This includes JavaScript exports and
66
- * custom element definitions.
67
- */
68
- exports?: (JavaScriptExport | CustomElementExport)[]
69
- kind: "javascript-module"
72
+ description?: string;
73
+
70
74
  /**
71
- * Path to the javascript file needed to be imported.
72
- * (not the path for example to a typescript file.)
75
+ * The declarations of a module.
76
+ *
77
+ * For documentation purposes, all declarations that are reachable from
78
+ * exports should be described here. Ie, functions and objects that may be
79
+ * properties of exported objects, or passed as arguments to functions.
73
80
  */
74
- path: string
81
+ declarations?: Array<Declaration>;
82
+
75
83
  /**
76
- * A markdown summary suitable for display in a listing.
84
+ * The exports of a module. This includes JavaScript exports and
85
+ * custom element definitions.
77
86
  */
78
- summary?: string
79
- }
80
- export interface ClassDeclaration {
87
+ exports?: Array<Export>;
88
+
81
89
  /**
82
- * Whether the class or mixin is deprecated.
90
+ * Whether the module is deprecated.
83
91
  * If the value is a string, it's the reason for the deprecation.
84
92
  */
85
- deprecated?: string | boolean
86
- /**
87
- * A markdown description of the class.
88
- */
89
- description?: string
90
- kind: "class"
91
- members?: (ClassField | ClassMethod)[]
93
+ deprecated?: boolean | string;
94
+ }
95
+
96
+ export type Export = JavaScriptExport | CustomElementExport;
97
+
98
+ export interface JavaScriptExport {
99
+ kind: 'js';
100
+
92
101
  /**
93
- * Any class mixins applied in the extends clause of this class.
102
+ * The name of the exported symbol.
94
103
  *
95
- * If mixins are applied in the class definition, then the true superclass
96
- * of this class is the result of applying mixins in order to the superclass.
104
+ * JavaScript has a number of ways to export objects which determine the
105
+ * correct name to use.
97
106
  *
98
- * Mixins must be listed in order of their application to the superclass or
99
- * previous mixin application. This means that the innermost mixin is listed
100
- * first. This may read backwards from the common order in JavaScript, but
101
- * matches the order of language used to describe mixin application, like
102
- * "S with A, B".
103
- */
104
- mixins?: Reference[]
105
- name: string
106
- source?: SourceReference
107
- /**
108
- * A markdown summary suitable for display in a listing.
107
+ * - Default exports must use the name "default".
108
+ * - Named exports use the name that is exported. If the export is renamed
109
+ * with the "as" clause, use the exported name.
110
+ * - Aggregating exports (`* from`) should use the name `*`
109
111
  */
110
- summary?: string
112
+ name: string;
113
+
111
114
  /**
112
- * A reference to an export of a module.
113
- *
114
- * All references are required to be publically accessible, so the canonical
115
- * representation of a reference is the export it's available from.
115
+ * A reference to the exported declaration.
116
116
  *
117
- * `package` should generally refer to an npm package name. If `package` is
118
- * undefined then the reference is local to this package. If `module` is
119
- * undefined the reference is local to the containing module.
120
- *
121
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
122
- * use a `package` name of `"global:"`.
123
- */
124
- superclass?: {
125
- module?: string
126
- name: string
127
- package?: string
128
- [k: string]: unknown
129
- }
130
- }
131
- export interface ClassField {
132
- default?: string
117
+ * In the case of aggregating exports, the reference's `module` field must be
118
+ * defined and the `name` field must be `"*"`.
119
+ */
120
+ declaration: Reference;
121
+
133
122
  /**
134
- * Whether the property is deprecated.
123
+ * Whether the export is deprecated. For example, the name of the export was changed.
135
124
  * If the value is a string, it's the reason for the deprecation.
136
125
  */
137
- deprecated?: string | boolean
126
+ deprecated?: boolean | string;
127
+ }
128
+
129
+ /**
130
+ * A global custom element defintion, ie the result of a
131
+ * `customElements.define()` call.
132
+ *
133
+ * This is represented as an export because a definition makes the element
134
+ * available outside of the module it's defined it.
135
+ */
136
+ export interface CustomElementExport {
137
+ kind: 'custom-element-definition';
138
+
138
139
  /**
139
- * A markdown description of the field.
140
+ * The tag name of the custom element.
140
141
  */
141
- description?: string
142
- inheritedFrom?: Reference
143
- kind: "field"
144
- name: string
145
- privacy?: Privacy
142
+ name: string;
143
+
146
144
  /**
147
- * Whether the property is read-only.
145
+ * A reference to the class or other declaration that implements the
146
+ * custom element.
148
147
  */
149
- readonly?: boolean
150
- source?: SourceReference
151
- static?: boolean
148
+ declaration: Reference;
149
+
152
150
  /**
153
- * A markdown summary suitable for display in a listing.
151
+ * Whether the custom-element export is deprecated.
152
+ * For example, a future version will not register the custom element in this file.
153
+ * If the value is a string, it's the reason for the deprecation.
154
154
  */
155
- summary?: string
156
- type?: Type
155
+ deprecated?: boolean | string;
157
156
  }
157
+
158
+ export type Declaration =
159
+ | ClassDeclaration
160
+ | FunctionDeclaration
161
+ | MixinDeclaration
162
+ | VariableDeclaration
163
+ | CustomElementDeclaration
164
+ | CustomElementMixinDeclaration;
165
+
158
166
  /**
159
167
  * A reference to an export of a module.
160
168
  *
@@ -169,10 +177,11 @@ export interface ClassField {
169
177
  * use a `package` name of `"global:"`.
170
178
  */
171
179
  export interface Reference {
172
- module?: string
173
- name: string
174
- package?: string
180
+ name: string;
181
+ package?: string;
182
+ module?: string;
175
183
  }
184
+
176
185
  /**
177
186
  * A reference to the source of a declaration or member.
178
187
  */
@@ -180,437 +189,195 @@ export interface SourceReference {
180
189
  /**
181
190
  * An absolute URL to the source (ie. a GitHub URL).
182
191
  */
183
- href: string
192
+ href: string;
184
193
  }
185
- export interface Type {
194
+
195
+ /**
196
+ * A description of a custom element class.
197
+ *
198
+ * Custom elements are JavaScript classes, so this extends from
199
+ * `ClassDeclaration` and adds custom-element-specific features like
200
+ * attributes, events, and slots.
201
+ *
202
+ * Note that `tagName` in this interface is optional. Tag names are not
203
+ * neccessarily part of a custom element class, but belong to the definition
204
+ * (often called the "registration") or the `customElements.define()` call.
205
+ *
206
+ * Because classes and tag names can only be registered once, there's a
207
+ * one-to-one relationship between classes and tag names. For ease of use,
208
+ * we allow the tag name here.
209
+ *
210
+ * Some packages define and register custom elements in separate modules. In
211
+ * these cases one `Module` should contain the `CustomElement` without a
212
+ * tagName, and another `Module` should contain the
213
+ * `CustomElementExport`.
214
+ */
215
+ // Note: this needs to be an interface to be included in the generated JSON
216
+ // Schema output.
217
+ export interface CustomElementDeclaration
218
+ extends ClassDeclaration,
219
+ CustomElement {}
220
+
221
+ /**
222
+ * The additional fields that a custom element adds to classes and mixins.
223
+ */
224
+ export interface CustomElement extends ClassLike {
186
225
  /**
187
- * An array of references to the types in the type string.
226
+ * An optional tag name that should be specified if this is a
227
+ * self-registering element.
188
228
  *
189
- * These references have optional indices into the type string so that tools
190
- * can understand the references in the type string independently of the type
191
- * system and syntax. For example, a documentation viewer could display the
192
- * type `Array<FooElement | BarElement>` with cross-references to `FooElement`
193
- * and `BarElement` without understanding arrays, generics, or union types.
229
+ * Self-registering elements must also include a CustomElementExport
230
+ * in the module's exports.
194
231
  */
195
- references?: TypeReference[]
196
- source?: SourceReference
232
+ tagName?: string;
233
+
197
234
  /**
198
- * The full string representation of the type, in whatever type syntax is
199
- * used, such as JSDoc, Closure, or TypeScript.
235
+ * The attributes that this element is known to understand.
200
236
  */
201
- text: string
202
- }
203
- /**
204
- * A reference that is associated with a type string and optionally a range
205
- * within the string.
206
- *
207
- * Start and end must both be present or not present. If they're present, they
208
- * are indices into the associated type string. If they are missing, the entire
209
- * type string is the symbol referenced and the name should match the type
210
- * string.
211
- */
212
- export interface TypeReference {
213
- end?: number
214
- module?: string
215
- name: string
216
- package?: string
217
- start?: number
218
- }
219
- export interface ClassMethod {
237
+ attributes?: Attribute[];
238
+
220
239
  /**
221
- * Whether the function is deprecated.
222
- * If the value is a string, it's the reason for the deprecation.
240
+ * The events that this element fires.
223
241
  */
224
- deprecated?: string | boolean
242
+ events?: Event[];
243
+
225
244
  /**
226
- * A markdown description.
245
+ * The shadow dom content slots that this element accepts.
227
246
  */
228
- description?: string
229
- inheritedFrom?: Reference
230
- kind: "method"
231
- name: string
232
- parameters?: Parameter[]
233
- privacy?: Privacy
234
- return?: {
235
- /**
236
- * A markdown description.
237
- */
238
- description?: string
239
- /**
240
- * A markdown summary suitable for display in a listing.
241
- */
242
- summary?: string
243
- type?: Type
244
- [k: string]: unknown
245
- }
246
- source?: SourceReference
247
- static?: boolean
247
+ slots?: Slot[];
248
+
249
+ cssParts?: CssPart[];
250
+
251
+ cssProperties?: CssCustomProperty[];
252
+
253
+ demos?: Demo[];
254
+
248
255
  /**
249
- * A markdown summary suitable for display in a listing.
256
+ * Distinguishes a regular JavaScript class from a
257
+ * custom element class
250
258
  */
251
- summary?: string
259
+ customElement: true;
252
260
  }
253
- export interface Parameter {
254
- default?: string
261
+
262
+ export interface Attribute {
263
+ name: string;
264
+
255
265
  /**
256
- * Whether the property is deprecated.
257
- * If the value is a string, it's the reason for the deprecation.
266
+ * A markdown summary suitable for display in a listing.
258
267
  */
259
- deprecated?: string | boolean
268
+ summary?: string;
269
+
260
270
  /**
261
- * A markdown description of the field.
271
+ * A markdown description.
262
272
  */
263
- description?: string
264
- name: string
273
+ description?: string;
274
+
275
+ inheritedFrom?: Reference;
276
+
265
277
  /**
266
- * Whether the parameter is optional. Undefined implies non-optional.
278
+ * The type that the attribute will be serialized/deserialized as.
267
279
  */
268
- optional?: boolean
280
+ type?: Type;
281
+
269
282
  /**
270
- * Whether the property is read-only.
283
+ * The default value of the attribute, if any.
284
+ *
285
+ * As attributes are always strings, this is the actual value, not a human
286
+ * readable description.
271
287
  */
272
- readonly?: boolean
288
+ default?: string;
289
+
273
290
  /**
274
- * Whether the parameter is a rest parameter. Only the last parameter may be a rest parameter.
275
- * Undefined implies single parameter.
291
+ * The name of the field this attribute is associated with, if any.
276
292
  */
277
- rest?: boolean
293
+ fieldName?: string;
294
+
278
295
  /**
279
- * A markdown summary suitable for display in a listing.
296
+ * Whether the attribute is deprecated.
297
+ * If the value is a string, it's the reason for the deprecation.
280
298
  */
281
- summary?: string
282
- type?: Type
299
+ deprecated?: boolean | string;
283
300
  }
284
- export interface FunctionDeclaration {
301
+
302
+ export interface Event {
303
+ name: string;
304
+
285
305
  /**
286
- * Whether the function is deprecated.
287
- * If the value is a string, it's the reason for the deprecation.
306
+ * A markdown summary suitable for display in a listing.
288
307
  */
289
- deprecated?: string | boolean
308
+ summary?: string;
309
+
290
310
  /**
291
311
  * A markdown description.
292
312
  */
293
- description?: string
294
- kind: "function"
295
- name: string
296
- parameters?: Parameter[]
297
- return?: {
298
- /**
299
- * A markdown description.
300
- */
301
- description?: string
302
- /**
303
- * A markdown summary suitable for display in a listing.
304
- */
305
- summary?: string
306
- type?: Type
307
- [k: string]: unknown
308
- }
309
- source?: SourceReference
313
+ description?: string;
314
+
310
315
  /**
311
- * A markdown summary suitable for display in a listing.
316
+ * The type of the event object that's fired.
312
317
  */
313
- summary?: string
314
- }
315
- /**
316
- * A description of a class mixin.
317
- *
318
- * Mixins are functions which generate a new subclass of a given superclass.
319
- * This interfaces describes the class and custom element features that
320
- * are added by the mixin. As such, it extends the CustomElement interface and
321
- * ClassLike interface.
322
- *
323
- * Since mixins are functions, it also extends the FunctionLike interface. This
324
- * means a mixin is callable, and has parameters and a return type.
325
- *
326
- * The return type is often hard or impossible to accurately describe in type
327
- * systems like TypeScript. It requires generics and an `extends` operator
328
- * that TypeScript lacks. Therefore it's recommended that the return type is
329
- * left empty. The most common form of a mixin function takes a single
330
- * argument, so consumers of this interface should assume that the return type
331
- * is the single argument subclassed by this declaration.
332
- *
333
- * A mixin should not have a superclass. If a mixins composes other mixins,
334
- * they should be listed in the `mixins` field.
335
- *
336
- * See [this article]{@link https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/}
337
- * for more information on the classmixin pattern in JavaScript.
338
- */
339
- export interface MixinDeclaration {
318
+ type: Type;
319
+
320
+ inheritedFrom?: Reference;
321
+
340
322
  /**
341
- * Whether the class or mixin is deprecated.
323
+ * Whether the event is deprecated.
342
324
  * If the value is a string, it's the reason for the deprecation.
343
325
  */
344
- deprecated?: string | boolean
326
+ deprecated?: boolean | string;
327
+ }
328
+
329
+ export interface Slot {
345
330
  /**
346
- * A markdown description of the class.
331
+ * The slot name, or the empty string for an unnamed slot.
347
332
  */
348
- description?: string
349
- kind: "mixin"
350
- members?: (ClassField | ClassMethod)[]
351
- /**
352
- * Any class mixins applied in the extends clause of this class.
353
- *
354
- * If mixins are applied in the class definition, then the true superclass
355
- * of this class is the result of applying mixins in order to the superclass.
356
- *
357
- * Mixins must be listed in order of their application to the superclass or
358
- * previous mixin application. This means that the innermost mixin is listed
359
- * first. This may read backwards from the common order in JavaScript, but
360
- * matches the order of language used to describe mixin application, like
361
- * "S with A, B".
362
- */
363
- mixins?: Reference[]
364
- name: string
365
- parameters?: Parameter[]
366
- return?: {
367
- /**
368
- * A markdown description.
369
- */
370
- description?: string
371
- /**
372
- * A markdown summary suitable for display in a listing.
373
- */
374
- summary?: string
375
- type?: Type
376
- [k: string]: unknown
377
- }
378
- source?: SourceReference
379
- /**
380
- * A markdown summary suitable for display in a listing.
381
- */
382
- summary?: string
383
- /**
384
- * A reference to an export of a module.
385
- *
386
- * All references are required to be publically accessible, so the canonical
387
- * representation of a reference is the export it's available from.
388
- *
389
- * `package` should generally refer to an npm package name. If `package` is
390
- * undefined then the reference is local to this package. If `module` is
391
- * undefined the reference is local to the containing module.
392
- *
393
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
394
- * use a `package` name of `"global:"`.
395
- */
396
- superclass?: {
397
- module?: string
398
- name: string
399
- package?: string
400
- [k: string]: unknown
401
- }
402
- }
403
- export interface VariableDeclaration {
404
- default?: string
405
- /**
406
- * Whether the property is deprecated.
407
- * If the value is a string, it's the reason for the deprecation.
408
- */
409
- deprecated?: string | boolean
410
- /**
411
- * A markdown description of the field.
412
- */
413
- description?: string
414
- kind: "variable"
415
- name: string
416
- /**
417
- * Whether the property is read-only.
418
- */
419
- readonly?: boolean
420
- source?: SourceReference
421
- /**
422
- * A markdown summary suitable for display in a listing.
423
- */
424
- summary?: string
425
- type?: Type
426
- }
427
- /**
428
- * A description of a custom element class.
429
- *
430
- * Custom elements are JavaScript classes, so this extends from
431
- * `ClassDeclaration` and adds custom-element-specific features like
432
- * attributes, events, and slots.
433
- *
434
- * Note that `tagName` in this interface is optional. Tag names are not
435
- * neccessarily part of a custom element class, but belong to the definition
436
- * (often called the "registration") or the `customElements.define()` call.
437
- *
438
- * Because classes and tag names can only be registered once, there's a
439
- * one-to-one relationship between classes and tag names. For ease of use,
440
- * we allow the tag name here.
441
- *
442
- * Some packages define and register custom elements in separate modules. In
443
- * these cases one `Module` should contain the `CustomElement` without a
444
- * tagName, and another `Module` should contain the
445
- * `CustomElementExport`.
446
- */
447
- export interface CustomElementDeclaration {
448
- /**
449
- * The attributes that this element is known to understand.
450
- */
451
- attributes?: Attribute[]
452
- cssParts?: CssPart[]
453
- cssProperties?: CssCustomProperty[]
454
- /**
455
- * Distinguishes a regular JavaScript class from a
456
- * custom element class
457
- */
458
- customElement: true
459
- demos?: Demo[]
460
- /**
461
- * Whether the class or mixin is deprecated.
462
- * If the value is a string, it's the reason for the deprecation.
463
- */
464
- deprecated?: string | boolean
465
- /**
466
- * A markdown description of the class.
467
- */
468
- description?: string
469
- /**
470
- * The events that this element fires.
471
- */
472
- events?: Event[]
473
- kind: "class"
474
- members?: (ClassField | ClassMethod)[]
475
- /**
476
- * Any class mixins applied in the extends clause of this class.
477
- *
478
- * If mixins are applied in the class definition, then the true superclass
479
- * of this class is the result of applying mixins in order to the superclass.
480
- *
481
- * Mixins must be listed in order of their application to the superclass or
482
- * previous mixin application. This means that the innermost mixin is listed
483
- * first. This may read backwards from the common order in JavaScript, but
484
- * matches the order of language used to describe mixin application, like
485
- * "S with A, B".
486
- */
487
- mixins?: Reference[]
488
- name: string
489
- /**
490
- * The shadow dom content slots that this element accepts.
491
- */
492
- slots?: Slot[]
493
- source?: SourceReference
333
+ name: string;
334
+
494
335
  /**
495
336
  * A markdown summary suitable for display in a listing.
496
337
  */
497
- summary?: string
498
- /**
499
- * A reference to an export of a module.
500
- *
501
- * All references are required to be publically accessible, so the canonical
502
- * representation of a reference is the export it's available from.
503
- *
504
- * `package` should generally refer to an npm package name. If `package` is
505
- * undefined then the reference is local to this package. If `module` is
506
- * undefined the reference is local to the containing module.
507
- *
508
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
509
- * use a `package` name of `"global:"`.
510
- */
511
- superclass?: {
512
- module?: string
513
- name: string
514
- package?: string
515
- [k: string]: unknown
516
- }
517
- /**
518
- * An optional tag name that should be specified if this is a
519
- * self-registering element.
520
- *
521
- * Self-registering elements must also include a CustomElementExport
522
- * in the module's exports.
523
- */
524
- tagName?: string
525
- }
526
- export interface Attribute {
527
- /**
528
- * The default value of the attribute, if any.
529
- *
530
- * As attributes are always strings, this is the actual value, not a human
531
- * readable description.
532
- */
533
- default?: string
534
- /**
535
- * Whether the attribute is deprecated.
536
- * If the value is a string, it's the reason for the deprecation.
537
- */
538
- deprecated?: string | boolean
338
+ summary?: string;
339
+
539
340
  /**
540
341
  * A markdown description.
541
342
  */
542
- description?: string
543
- /**
544
- * The name of the field this attribute is associated with, if any.
545
- */
546
- fieldName?: string
547
- inheritedFrom?: Reference
548
- name: string
549
- /**
550
- * A markdown summary suitable for display in a listing.
551
- */
552
- summary?: string
343
+ description?: string;
344
+
553
345
  /**
554
- * The type that the attribute will be serialized/deserialized as.
346
+ * Whether the slot is deprecated.
347
+ * If the value is a string, it's the reason for the deprecation.
555
348
  */
556
- type?: {
557
- /**
558
- * An array of references to the types in the type string.
559
- *
560
- * These references have optional indices into the type string so that tools
561
- * can understand the references in the type string independently of the type
562
- * system and syntax. For example, a documentation viewer could display the
563
- * type `Array<FooElement | BarElement>` with cross-references to `FooElement`
564
- * and `BarElement` without understanding arrays, generics, or union types.
565
- */
566
- references?: TypeReference[]
567
- source?: SourceReference
568
- /**
569
- * The full string representation of the type, in whatever type syntax is
570
- * used, such as JSDoc, Closure, or TypeScript.
571
- */
572
- text: string
573
- [k: string]: unknown
574
- }
349
+ deprecated?: boolean | string;
575
350
  }
351
+
576
352
  /**
577
353
  * The description of a CSS Part
578
354
  */
579
355
  export interface CssPart {
356
+ name: string;
357
+
580
358
  /**
581
- * Whether the CSS shadow part is deprecated.
582
- * If the value is a string, it's the reason for the deprecation.
359
+ * A markdown summary suitable for display in a listing.
583
360
  */
584
- deprecated?: string | boolean
361
+ summary?: string;
362
+
585
363
  /**
586
364
  * A markdown description.
587
365
  */
588
- description?: string
589
- name: string
366
+ description?: string;
367
+
590
368
  /**
591
- * A markdown summary suitable for display in a listing.
369
+ * Whether the CSS shadow part is deprecated.
370
+ * If the value is a string, it's the reason for the deprecation.
592
371
  */
593
- summary?: string
372
+ deprecated?: boolean | string;
594
373
  }
374
+
595
375
  export interface CssCustomProperty {
596
- default?: string
597
- /**
598
- * Whether the CSS custom property is deprecated.
599
- * If the value is a string, it's the reason for the deprecation.
600
- */
601
- deprecated?: string | boolean
602
- /**
603
- * A markdown description.
604
- */
605
- description?: string
606
376
  /**
607
377
  * The name of the property, including leading `--`.
608
378
  */
609
- name: string
610
- /**
611
- * A markdown summary suitable for display in a listing.
612
- */
613
- summary?: string
379
+ name: string;
380
+
614
381
  /**
615
382
  * The expected syntax of the defined property. Defaults to "*".
616
383
  *
@@ -624,109 +391,87 @@ export interface CssCustomProperty {
624
391
  * "small | medium | large": accepts one of these values set as custom idents.
625
392
  * "*": any valid token
626
393
  */
627
- syntax?: string
628
- }
629
- export interface Demo {
630
- /**
631
- * A markdown description of the demo.
632
- */
633
- description?: string
634
- source?: SourceReference
635
- /**
636
- * Relative URL of the demo if it's published with the package. Absolute URL
637
- * if it's hosted.
638
- */
639
- url: string
640
- }
641
- export interface Event {
642
- /**
643
- * Whether the event is deprecated.
644
- * If the value is a string, it's the reason for the deprecation.
645
- */
646
- deprecated?: string | boolean
647
- /**
648
- * A markdown description.
649
- */
650
- description?: string
651
- inheritedFrom?: Reference
652
- name: string
394
+ syntax?: string;
395
+
396
+ default?: string;
397
+
653
398
  /**
654
399
  * A markdown summary suitable for display in a listing.
655
400
  */
656
- summary?: string
401
+ summary?: string;
402
+
657
403
  /**
658
- * The type of the event object that's fired.
404
+ * A markdown description.
659
405
  */
660
- type: {
661
- /**
662
- * An array of references to the types in the type string.
663
- *
664
- * These references have optional indices into the type string so that tools
665
- * can understand the references in the type string independently of the type
666
- * system and syntax. For example, a documentation viewer could display the
667
- * type `Array<FooElement | BarElement>` with cross-references to `FooElement`
668
- * and `BarElement` without understanding arrays, generics, or union types.
669
- */
670
- references?: TypeReference[]
671
- source?: SourceReference
672
- /**
673
- * The full string representation of the type, in whatever type syntax is
674
- * used, such as JSDoc, Closure, or TypeScript.
675
- */
676
- text: string
677
- [k: string]: unknown
678
- }
679
- }
680
- export interface Slot {
406
+ description?: string;
407
+
681
408
  /**
682
- * Whether the slot is deprecated.
409
+ * Whether the CSS custom property is deprecated.
683
410
  * If the value is a string, it's the reason for the deprecation.
684
411
  */
685
- deprecated?: string | boolean
686
- /**
687
- * A markdown description.
688
- */
689
- description?: string
412
+ deprecated?: boolean | string;
413
+ }
414
+
415
+ export interface Type {
690
416
  /**
691
- * The slot name, or the empty string for an unnamed slot.
417
+ * The full string representation of the type, in whatever type syntax is
418
+ * used, such as JSDoc, Closure, or TypeScript.
692
419
  */
693
- name: string
420
+ text: string;
421
+
694
422
  /**
695
- * A markdown summary suitable for display in a listing.
423
+ * An array of references to the types in the type string.
424
+ *
425
+ * These references have optional indices into the type string so that tools
426
+ * can understand the references in the type string independently of the type
427
+ * system and syntax. For example, a documentation viewer could display the
428
+ * type `Array<FooElement | BarElement>` with cross-references to `FooElement`
429
+ * and `BarElement` without understanding arrays, generics, or union types.
696
430
  */
697
- summary?: string
431
+ references?: TypeReference[];
432
+
433
+ source?: SourceReference;
698
434
  }
435
+
699
436
  /**
700
- * A class mixin that also adds custom element related properties.
437
+ * A reference that is associated with a type string and optionally a range
438
+ * within the string.
439
+ *
440
+ * Start and end must both be present or not present. If they're present, they
441
+ * are indices into the associated type string. If they are missing, the entire
442
+ * type string is the symbol referenced and the name should match the type
443
+ * string.
701
444
  */
702
- export interface CustomElementMixinDeclaration {
703
- /**
704
- * The attributes that this element is known to understand.
705
- */
706
- attributes?: Attribute[]
707
- cssParts?: CssPart[]
708
- cssProperties?: CssCustomProperty[]
709
- /**
710
- * Distinguishes a regular JavaScript class from a
711
- * custom element class
712
- */
713
- customElement: true
714
- demos?: Demo[]
445
+ export interface TypeReference extends Reference {
446
+ start?: number;
447
+ end?: number;
448
+ }
449
+
450
+ /**
451
+ * The common interface of classes and mixins.
452
+ */
453
+ export interface ClassLike {
454
+ name: string;
455
+
715
456
  /**
716
- * Whether the class or mixin is deprecated.
717
- * If the value is a string, it's the reason for the deprecation.
457
+ * A markdown summary suitable for display in a listing.
718
458
  */
719
- deprecated?: string | boolean
459
+ summary?: string;
460
+
720
461
  /**
721
462
  * A markdown description of the class.
722
463
  */
723
- description?: string
464
+ description?: string;
465
+
724
466
  /**
725
- * The events that this element fires.
467
+ * The superclass of this class.
468
+ *
469
+ * If this class is defined with mixin applications, the prototype chain
470
+ * includes the mixin applications and the true superclass is computed
471
+ * from them.
726
472
  */
727
- events?: Event[]
728
- kind: "mixin"
729
- members?: (ClassField | ClassMethod)[]
473
+ superclass?: Reference;
474
+
730
475
  /**
731
476
  * Any class mixins applied in the extends clause of this class.
732
477
  *
@@ -738,134 +483,254 @@ export interface CustomElementMixinDeclaration {
738
483
  * first. This may read backwards from the common order in JavaScript, but
739
484
  * matches the order of language used to describe mixin application, like
740
485
  * "S with A, B".
741
- */
742
- mixins?: Reference[]
743
- name: string
744
- parameters?: Parameter[]
745
- return?: {
746
- /**
747
- * A markdown description.
748
- */
749
- description?: string
750
- /**
751
- * A markdown summary suitable for display in a listing.
752
- */
753
- summary?: string
754
- type?: Type
755
- [k: string]: unknown
756
- }
486
+ *
487
+ * @example
488
+ *
489
+ * ```javascript
490
+ * class T extends B(A(S)) {}
491
+ * ```
492
+ *
493
+ * is described by:
494
+ * ```json
495
+ * {
496
+ * "kind": "class",
497
+ * "superclass": {
498
+ * "name": "S"
499
+ * },
500
+ * "mixins": [
501
+ * {
502
+ * "name": "A"
503
+ * },
504
+ * {
505
+ * "name": "B"
506
+ * },
507
+ * ]
508
+ * }
509
+ * ```
510
+ */
511
+ mixins?: Array<Reference>;
512
+ members?: Array<ClassMember>;
513
+
514
+ source?: SourceReference;
515
+
757
516
  /**
758
- * The shadow dom content slots that this element accepts.
517
+ * Whether the class or mixin is deprecated.
518
+ * If the value is a string, it's the reason for the deprecation.
759
519
  */
760
- slots?: Slot[]
761
- source?: SourceReference
520
+ deprecated?: boolean | string;
521
+ }
522
+
523
+ export interface ClassDeclaration extends ClassLike {
524
+ kind: 'class';
525
+ }
526
+
527
+ export type ClassMember = ClassField | ClassMethod;
528
+
529
+ /**
530
+ * The common interface of variables, class fields, and function
531
+ * parameters.
532
+ */
533
+ export interface PropertyLike {
534
+ name: string;
535
+
762
536
  /**
763
537
  * A markdown summary suitable for display in a listing.
764
538
  */
765
- summary?: string
539
+ summary?: string;
540
+
766
541
  /**
767
- * A reference to an export of a module.
768
- *
769
- * All references are required to be publically accessible, so the canonical
770
- * representation of a reference is the export it's available from.
771
- *
772
- * `package` should generally refer to an npm package name. If `package` is
773
- * undefined then the reference is local to this package. If `module` is
774
- * undefined the reference is local to the containing module.
775
- *
776
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
777
- * use a `package` name of `"global:"`.
542
+ * A markdown description of the field.
778
543
  */
779
- superclass?: {
780
- module?: string
781
- name: string
782
- package?: string
783
- [k: string]: unknown
784
- }
544
+ description?: string;
545
+
546
+ type?: Type;
547
+
548
+ default?: string;
549
+
785
550
  /**
786
- * An optional tag name that should be specified if this is a
787
- * self-registering element.
788
- *
789
- * Self-registering elements must also include a CustomElementExport
790
- * in the module's exports.
551
+ * Whether the property is deprecated.
552
+ * If the value is a string, it's the reason for the deprecation.
791
553
  */
792
- tagName?: string
793
- }
794
- export interface JavaScriptExport {
554
+ deprecated?: boolean | string;
555
+
795
556
  /**
796
- * A reference to an export of a module.
797
- *
798
- * All references are required to be publically accessible, so the canonical
799
- * representation of a reference is the export it's available from.
800
- *
801
- * `package` should generally refer to an npm package name. If `package` is
802
- * undefined then the reference is local to this package. If `module` is
803
- * undefined the reference is local to the containing module.
804
- *
805
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
806
- * use a `package` name of `"global:"`.
557
+ * Whether the property is read-only.
807
558
  */
808
- declaration: {
809
- module?: string
810
- name: string
811
- package?: string
812
- [k: string]: unknown
813
- }
559
+ readonly?: boolean;
560
+ }
561
+
562
+ export interface ClassField extends PropertyLike {
563
+ kind: 'field';
564
+ static?: boolean;
565
+ privacy?: Privacy;
566
+ inheritedFrom?: Reference;
567
+ source?: SourceReference;
568
+ }
569
+
570
+ /**
571
+ * Additional metadata for fields on custom elements.
572
+ */
573
+ export interface CustomElementField extends ClassField {
814
574
  /**
815
- * Whether the export is deprecated. For example, the name of the export was changed.
816
- * If the value is a string, it's the reason for the deprecation.
575
+ * The corresponding attribute name if there is one.
576
+ *
577
+ * If this property is defined, the attribute must be listed in the classes'
578
+ * `attributes` array.
817
579
  */
818
- deprecated?: string | boolean
819
- kind: "js"
580
+ attribute?: string;
581
+
820
582
  /**
821
- * The name of the exported symbol.
822
- *
823
- * JavaScript has a number of ways to export objects which determine the
824
- * correct name to use.
583
+ * If the property reflects to an attribute.
825
584
  *
826
- * - Default exports must use the name "default".
827
- * - Named exports use the name that is exported. If the export is renamed
828
- * with the "as" clause, use the exported name.
829
- * - Aggregating exports (`* from`) should use the name `*`
585
+ * If this is true, the `attribute` property must be defined.
830
586
  */
831
- name: string
587
+ reflects?: boolean;
588
+ }
589
+
590
+ export interface ClassMethod extends FunctionLike {
591
+ kind: 'method';
592
+ static?: boolean;
593
+ privacy?: Privacy;
594
+ inheritedFrom?: Reference;
595
+ source?: SourceReference;
832
596
  }
597
+
833
598
  /**
834
- * A global custom element defintion, ie the result of a
835
- * `customElements.define()` call.
599
+ * A description of a class mixin.
836
600
  *
837
- * This is represented as an export because a definition makes the element
838
- * available outside of the module it's defined it.
601
+ * Mixins are functions which generate a new subclass of a given superclass.
602
+ * This interfaces describes the class and custom element features that
603
+ * are added by the mixin. As such, it extends the CustomElement interface and
604
+ * ClassLike interface.
605
+ *
606
+ * Since mixins are functions, it also extends the FunctionLike interface. This
607
+ * means a mixin is callable, and has parameters and a return type.
608
+ *
609
+ * The return type is often hard or impossible to accurately describe in type
610
+ * systems like TypeScript. It requires generics and an `extends` operator
611
+ * that TypeScript lacks. Therefore it's recommended that the return type is
612
+ * left empty. The most common form of a mixin function takes a single
613
+ * argument, so consumers of this interface should assume that the return type
614
+ * is the single argument subclassed by this declaration.
615
+ *
616
+ * A mixin should not have a superclass. If a mixins composes other mixins,
617
+ * they should be listed in the `mixins` field.
618
+ *
619
+ * See [this article]{@link https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/}
620
+ * for more information on the classmixin pattern in JavaScript.
621
+ *
622
+ * @example
623
+ *
624
+ * This JavaScript mixin declaration:
625
+ * ```javascript
626
+ * const MyMixin = (base) => class extends base {
627
+ * foo() { ... }
628
+ * }
629
+ * ```
630
+ *
631
+ * Is described by this JSON:
632
+ * ```json
633
+ * {
634
+ * "kind": "mixin",
635
+ * "name": "MyMixin",
636
+ * "parameters": [
637
+ * {
638
+ * "name": "base",
639
+ * }
640
+ * ],
641
+ * "members": [
642
+ * {
643
+ * "kind": "method",
644
+ * "name": "foo",
645
+ * }
646
+ * ]
647
+ * }
648
+ * ```
839
649
  */
840
- export interface CustomElementExport {
650
+ export interface MixinDeclaration extends ClassLike, FunctionLike {
651
+ kind: 'mixin';
652
+ }
653
+
654
+ /**
655
+ * A class mixin that also adds custom element related properties.
656
+ */
657
+ // Note: this needs to be an interface to be included in the generated JSON
658
+ // Schema output.
659
+ export interface CustomElementMixinDeclaration
660
+ extends MixinDeclaration,
661
+ CustomElement {}
662
+
663
+ export interface VariableDeclaration extends PropertyLike {
664
+ kind: 'variable';
665
+ source?: SourceReference;
666
+ }
667
+
668
+ export interface FunctionDeclaration extends FunctionLike {
669
+ kind: 'function';
670
+ source?: SourceReference;
671
+ }
672
+
673
+ export interface Parameter extends PropertyLike {
841
674
  /**
842
- * A reference to an export of a module.
843
- *
844
- * All references are required to be publically accessible, so the canonical
845
- * representation of a reference is the export it's available from.
846
- *
847
- * `package` should generally refer to an npm package name. If `package` is
848
- * undefined then the reference is local to this package. If `module` is
849
- * undefined the reference is local to the containing module.
850
- *
851
- * References to global symbols like `Array`, `HTMLElement`, or `Event` should
852
- * use a `package` name of `"global:"`.
675
+ * Whether the parameter is optional. Undefined implies non-optional.
853
676
  */
854
- declaration: {
855
- module?: string
856
- name: string
857
- package?: string
858
- [k: string]: unknown
859
- }
677
+ optional?: boolean;
860
678
  /**
861
- * Whether the custom-element export is deprecated.
862
- * For example, a future version will not register the custom element in this file.
863
- * If the value is a string, it's the reason for the deprecation.
679
+ * Whether the parameter is a rest parameter. Only the last parameter may be a rest parameter.
680
+ * Undefined implies single parameter.
681
+ */
682
+ rest?: boolean;
683
+ }
684
+
685
+ export interface FunctionLike {
686
+ name: string;
687
+
688
+ /**
689
+ * A markdown summary suitable for display in a listing.
690
+ */
691
+ summary?: string;
692
+
693
+ /**
694
+ * A markdown description.
864
695
  */
865
- deprecated?: string | boolean
866
- kind: "custom-element-definition"
696
+ description?: string;
697
+
867
698
  /**
868
- * The tag name of the custom element.
699
+ * Whether the function is deprecated.
700
+ * If the value is a string, it's the reason for the deprecation.
869
701
  */
870
- name: string
702
+ deprecated?: boolean | string;
703
+
704
+ parameters?: Parameter[];
705
+
706
+ return?: {
707
+ type?: Type;
708
+
709
+ /**
710
+ * A markdown summary suitable for display in a listing.
711
+ */
712
+ summary?: string;
713
+
714
+ /**
715
+ * A markdown description.
716
+ */
717
+ description?: string;
718
+ };
871
719
  }
720
+
721
+ export type Privacy = 'public' | 'private' | 'protected';
722
+
723
+ export interface Demo {
724
+ /**
725
+ * A markdown description of the demo.
726
+ */
727
+ description?: string;
728
+
729
+ /**
730
+ * Relative URL of the demo if it's published with the package. Absolute URL
731
+ * if it's hosted.
732
+ */
733
+ url: string;
734
+
735
+ source?: SourceReference;
736
+ }