1 | ;
|
2 | /**
|
3 | * @license
|
4 | * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
5 | * This code may only be used under the BSD style license found at
|
6 | * http://polymer.github.io/LICENSE.txt
|
7 | * The complete set of authors may be found at
|
8 | * http://polymer.github.io/AUTHORS.txt
|
9 | * The complete set of contributors may be found at
|
10 | * http://polymer.github.io/CONTRIBUTORS.txt
|
11 | * Code distributed by Google as part of the polymer project is also
|
12 | * subject to an additional IP rights grant found at
|
13 | * http://polymer.github.io/PATENTS.txt
|
14 | */
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const class_1 = require("../model/class");
|
17 | const model_1 = require("../model/model");
|
18 | /**
|
19 | * A scanned Polymer 1.x core "feature".
|
20 | */
|
21 | class ScannedPolymerCoreFeature extends model_1.ScannedFeature {
|
22 | constructor() {
|
23 | super(...arguments);
|
24 | this.warnings = [];
|
25 | this.properties = new Map();
|
26 | this.methods = new Map();
|
27 | }
|
28 | resolve(document) {
|
29 | if (this.warnings.length > 0) {
|
30 | return;
|
31 | }
|
32 | // Sniff for the root `_addFeatures` call by presence of this method. This
|
33 | // method must only appear once (in the root `polymer.html` document).
|
34 | const isRootAddFeatureCall = this.methods.has('_finishRegisterFeatures');
|
35 | if (!isRootAddFeatureCall) {
|
36 | // We're at the `Polymer.Base` assignment or a regular `_addFeature`
|
37 | // call. We'll merge all of these below.
|
38 | return new PolymerCoreFeature(this.properties, this.methods);
|
39 | }
|
40 | // Otherwise we're at the root of the `_addFeatures` tree. Thanks to HTML
|
41 | // imports, we can be sure that this is the final core feature we'll
|
42 | // resolve. Now we'll emit a "fake" class representing the union of all the
|
43 | // feature objects.
|
44 | const allProperties = new Map(this.properties);
|
45 | const allMethods = new Map(this.methods);
|
46 | const otherCoreFeatures = document.getFeatures({
|
47 | kind: 'polymer-core-feature',
|
48 | imported: true,
|
49 | externalPackages: true,
|
50 | });
|
51 | for (const feature of otherCoreFeatures) {
|
52 | for (const [key, prop] of feature.properties) {
|
53 | allProperties.set(key, prop);
|
54 | }
|
55 | for (const [key, method] of feature.methods) {
|
56 | allMethods.set(key, method);
|
57 | }
|
58 | }
|
59 | return new class_1.Class({
|
60 | name: 'Polymer.Base',
|
61 | className: 'Polymer.Base',
|
62 | properties: allProperties,
|
63 | methods: allMethods,
|
64 | staticMethods: new Map(),
|
65 | abstract: true,
|
66 | privacy: 'public',
|
67 | // TODO(aomarks) The following should probably come from the
|
68 | // Polymer.Base assignment instead of this final addFeature call.
|
69 | jsdoc: this.jsdoc,
|
70 | description: this.description || '',
|
71 | summary: '',
|
72 | sourceRange: this.sourceRange,
|
73 | astNode: this.astNode,
|
74 | statementAst: undefined,
|
75 | }, document);
|
76 | }
|
77 | }
|
78 | exports.ScannedPolymerCoreFeature = ScannedPolymerCoreFeature;
|
79 | /**
|
80 | * A resolved Polymer 1.x core "feature".
|
81 | */
|
82 | class PolymerCoreFeature {
|
83 | constructor(properties, methods) {
|
84 | this.properties = properties;
|
85 | this.methods = methods;
|
86 | this.kinds = new Set(['polymer-core-feature']);
|
87 | this.identifiers = new Set();
|
88 | this.warnings = [];
|
89 | this.statementAst = undefined;
|
90 | }
|
91 | }
|
92 | exports.PolymerCoreFeature = PolymerCoreFeature;
|
93 | //# sourceMappingURL=polymer-core-feature.js.map |
\ | No newline at end of file |