1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4 | * This code may only be used under the BSD style license found at
|
5 | * http://polymer.github.io/LICENSE.txt
|
6 | * The complete set of authors may be found at
|
7 | * http://polymer.github.io/AUTHORS.txt
|
8 | * The complete set of contributors may be found at
|
9 | * http://polymer.github.io/CONTRIBUTORS.txt
|
10 | * Code distributed by Google as part of the polymer project is also
|
11 | * subject to an additional IP rights grant found at
|
12 | * http://polymer.github.io/PATENTS.txt
|
13 | */
|
14 | import * as babel from '@babel/types';
|
15 | import { MapWithDefault, ScannedClass, ScannedFeature, ScannedMethod, ScannedProperty, Warning } from '../model/model';
|
16 | import { ScannedPolymerElement } from '../polymer/polymer-element';
|
17 | import { ScannedPolymerElementMixin } from '../polymer/polymer-element-mixin';
|
18 | import { Visitor } from './estree-visitor';
|
19 | import { JavaScriptDocument } from './javascript-document';
|
20 | import { JavaScriptScanner } from './javascript-scanner';
|
21 | export interface ScannedAttribute extends ScannedFeature {
|
22 | name: string;
|
23 | type?: string;
|
24 | }
|
25 | declare type ClassType = ScannedPolymerElement | ScannedClass | ScannedPolymerElementMixin;
|
26 | /**
|
27 | * Find and classify classes from source code.
|
28 | *
|
29 | * Currently this has a bunch of Polymer stuff baked in that shouldn't be here
|
30 | * in order to support generating only one feature for stuff that's essentially
|
31 | * more specific kinds of classes, like Elements, PolymerElements, Mixins, etc.
|
32 | *
|
33 | * In a future change we'll add a mechanism whereby plugins can claim and
|
34 | * specialize classes.
|
35 | */
|
36 | export declare class ClassScanner implements JavaScriptScanner {
|
37 | scan(document: JavaScriptDocument, visit: (visitor: Visitor) => Promise<void>): Promise<{
|
38 | features: ClassType[];
|
39 | warnings: Warning[];
|
40 | }>;
|
41 | /**
|
42 | * Handle the pattern where a class's superclass is declared as a separate
|
43 | * variable, usually so that mixins can be applied in a way that is compatible
|
44 | * with the Closure compiler. We consider a class ephemeral if:
|
45 | *
|
46 | * 1) It is the superclass of one or more classes.
|
47 | * 2) It is declared using a const, let, or var.
|
48 | * 3) It is annotated as @private.
|
49 | */
|
50 | private collapseEphemeralSuperclasses;
|
51 | private _makeElementFeature;
|
52 | private _getObservers;
|
53 | private _getObservedAttributes;
|
54 | /**
|
55 | * Extract attributes from the array expression inside a static
|
56 | * observedAttributes method.
|
57 | *
|
58 | * e.g.
|
59 | * static get observedAttributes() {
|
60 | * return [
|
61 | * /** @type {boolean} When given the element is totally inactive *\/
|
62 | * 'disabled',
|
63 | * /** @type {boolean} When given the element is expanded *\/
|
64 | * 'open'
|
65 | * ];
|
66 | * }
|
67 | */
|
68 | private _extractAttributesFromObservedAttributes;
|
69 | }
|
70 | export declare class PrototypeMemberFinder implements Visitor {
|
71 | readonly members: MapWithDefault<string, {
|
72 | methods: Map<string, ScannedMethod>;
|
73 | properties: Map<string, ScannedProperty>;
|
74 | }>;
|
75 | private readonly _document;
|
76 | constructor(document: JavaScriptDocument);
|
77 | enterExpressionStatement(node: babel.ExpressionStatement): void;
|
78 | private _createMemberFromAssignment;
|
79 | private _addMethodToClass;
|
80 | private _addPropertyToClass;
|
81 | private _createMemberFromMemberExpression;
|
82 | private _createPropertyFromExpression;
|
83 | private _createMethodFromExpression;
|
84 | }
|
85 | export declare function extractPropertiesFromClass(astNode: babel.Node, document: JavaScriptDocument): Map<string, ScannedProperty>;
|
86 | export {};
|