1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { createComponent, createContentChild, createContentChildren, createDirective, createHostBinding, createHostListener, createInput, createOutput, createViewChild, createViewChildren } from './core';
|
---|
9 | import { resolveForwardRef, splitAtColon, stringify } from './util';
|
---|
10 | const QUERY_METADATA_IDENTIFIERS = [
|
---|
11 | createViewChild,
|
---|
12 | createViewChildren,
|
---|
13 | createContentChild,
|
---|
14 | createContentChildren,
|
---|
15 | ];
|
---|
16 | /*
|
---|
17 | * Resolve a `Type` for {@link Directive}.
|
---|
18 | *
|
---|
19 | * This interface can be overridden by the application developer to create custom behavior.
|
---|
20 | *
|
---|
21 | * See {@link Compiler}
|
---|
22 | */
|
---|
23 | export class DirectiveResolver {
|
---|
24 | constructor(_reflector) {
|
---|
25 | this._reflector = _reflector;
|
---|
26 | }
|
---|
27 | isDirective(type) {
|
---|
28 | const typeMetadata = this._reflector.annotations(resolveForwardRef(type));
|
---|
29 | return typeMetadata && typeMetadata.some(isDirectiveMetadata);
|
---|
30 | }
|
---|
31 | resolve(type, throwIfNotFound = true) {
|
---|
32 | const typeMetadata = this._reflector.annotations(resolveForwardRef(type));
|
---|
33 | if (typeMetadata) {
|
---|
34 | const metadata = findLast(typeMetadata, isDirectiveMetadata);
|
---|
35 | if (metadata) {
|
---|
36 | const propertyMetadata = this._reflector.propMetadata(type);
|
---|
37 | const guards = this._reflector.guards(type);
|
---|
38 | return this._mergeWithPropertyMetadata(metadata, propertyMetadata, guards, type);
|
---|
39 | }
|
---|
40 | }
|
---|
41 | if (throwIfNotFound) {
|
---|
42 | throw new Error(`No Directive annotation found on ${stringify(type)}`);
|
---|
43 | }
|
---|
44 | return null;
|
---|
45 | }
|
---|
46 | _mergeWithPropertyMetadata(dm, propertyMetadata, guards, directiveType) {
|
---|
47 | const inputs = [];
|
---|
48 | const outputs = [];
|
---|
49 | const host = {};
|
---|
50 | const queries = {};
|
---|
51 | Object.keys(propertyMetadata).forEach((propName) => {
|
---|
52 | const input = findLast(propertyMetadata[propName], (a) => createInput.isTypeOf(a));
|
---|
53 | if (input) {
|
---|
54 | if (input.bindingPropertyName) {
|
---|
55 | inputs.push(`${propName}: ${input.bindingPropertyName}`);
|
---|
56 | }
|
---|
57 | else {
|
---|
58 | inputs.push(propName);
|
---|
59 | }
|
---|
60 | }
|
---|
61 | const output = findLast(propertyMetadata[propName], (a) => createOutput.isTypeOf(a));
|
---|
62 | if (output) {
|
---|
63 | if (output.bindingPropertyName) {
|
---|
64 | outputs.push(`${propName}: ${output.bindingPropertyName}`);
|
---|
65 | }
|
---|
66 | else {
|
---|
67 | outputs.push(propName);
|
---|
68 | }
|
---|
69 | }
|
---|
70 | const hostBindings = propertyMetadata[propName].filter(a => createHostBinding.isTypeOf(a));
|
---|
71 | hostBindings.forEach(hostBinding => {
|
---|
72 | if (hostBinding.hostPropertyName) {
|
---|
73 | const startWith = hostBinding.hostPropertyName[0];
|
---|
74 | if (startWith === '(') {
|
---|
75 | throw new Error(`@HostBinding can not bind to events. Use @HostListener instead.`);
|
---|
76 | }
|
---|
77 | else if (startWith === '[') {
|
---|
78 | throw new Error(`@HostBinding parameter should be a property name, 'class.<name>', or 'attr.<name>'.`);
|
---|
79 | }
|
---|
80 | host[`[${hostBinding.hostPropertyName}]`] = propName;
|
---|
81 | }
|
---|
82 | else {
|
---|
83 | host[`[${propName}]`] = propName;
|
---|
84 | }
|
---|
85 | });
|
---|
86 | const hostListeners = propertyMetadata[propName].filter(a => createHostListener.isTypeOf(a));
|
---|
87 | hostListeners.forEach(hostListener => {
|
---|
88 | const args = hostListener.args || [];
|
---|
89 | host[`(${hostListener.eventName})`] = `${propName}(${args.join(',')})`;
|
---|
90 | });
|
---|
91 | const query = findLast(propertyMetadata[propName], (a) => QUERY_METADATA_IDENTIFIERS.some(i => i.isTypeOf(a)));
|
---|
92 | if (query) {
|
---|
93 | queries[propName] = query;
|
---|
94 | }
|
---|
95 | });
|
---|
96 | return this._merge(dm, inputs, outputs, host, queries, guards, directiveType);
|
---|
97 | }
|
---|
98 | _extractPublicName(def) {
|
---|
99 | return splitAtColon(def, [null, def])[1].trim();
|
---|
100 | }
|
---|
101 | _dedupeBindings(bindings) {
|
---|
102 | const names = new Set();
|
---|
103 | const publicNames = new Set();
|
---|
104 | const reversedResult = [];
|
---|
105 | // go last to first to allow later entries to overwrite previous entries
|
---|
106 | for (let i = bindings.length - 1; i >= 0; i--) {
|
---|
107 | const binding = bindings[i];
|
---|
108 | const name = this._extractPublicName(binding);
|
---|
109 | publicNames.add(name);
|
---|
110 | if (!names.has(name)) {
|
---|
111 | names.add(name);
|
---|
112 | reversedResult.push(binding);
|
---|
113 | }
|
---|
114 | }
|
---|
115 | return reversedResult.reverse();
|
---|
116 | }
|
---|
117 | _merge(directive, inputs, outputs, host, queries, guards, directiveType) {
|
---|
118 | const mergedInputs = this._dedupeBindings(directive.inputs ? directive.inputs.concat(inputs) : inputs);
|
---|
119 | const mergedOutputs = this._dedupeBindings(directive.outputs ? directive.outputs.concat(outputs) : outputs);
|
---|
120 | const mergedHost = directive.host ? Object.assign(Object.assign({}, directive.host), host) : host;
|
---|
121 | const mergedQueries = directive.queries ? Object.assign(Object.assign({}, directive.queries), queries) : queries;
|
---|
122 | if (createComponent.isTypeOf(directive)) {
|
---|
123 | const comp = directive;
|
---|
124 | return createComponent({
|
---|
125 | selector: comp.selector,
|
---|
126 | inputs: mergedInputs,
|
---|
127 | outputs: mergedOutputs,
|
---|
128 | host: mergedHost,
|
---|
129 | exportAs: comp.exportAs,
|
---|
130 | moduleId: comp.moduleId,
|
---|
131 | queries: mergedQueries,
|
---|
132 | changeDetection: comp.changeDetection,
|
---|
133 | providers: comp.providers,
|
---|
134 | viewProviders: comp.viewProviders,
|
---|
135 | entryComponents: comp.entryComponents,
|
---|
136 | template: comp.template,
|
---|
137 | templateUrl: comp.templateUrl,
|
---|
138 | styles: comp.styles,
|
---|
139 | styleUrls: comp.styleUrls,
|
---|
140 | encapsulation: comp.encapsulation,
|
---|
141 | animations: comp.animations,
|
---|
142 | interpolation: comp.interpolation,
|
---|
143 | preserveWhitespaces: directive.preserveWhitespaces,
|
---|
144 | });
|
---|
145 | }
|
---|
146 | else {
|
---|
147 | return createDirective({
|
---|
148 | selector: directive.selector,
|
---|
149 | inputs: mergedInputs,
|
---|
150 | outputs: mergedOutputs,
|
---|
151 | host: mergedHost,
|
---|
152 | exportAs: directive.exportAs,
|
---|
153 | queries: mergedQueries,
|
---|
154 | providers: directive.providers,
|
---|
155 | guards
|
---|
156 | });
|
---|
157 | }
|
---|
158 | }
|
---|
159 | }
|
---|
160 | function isDirectiveMetadata(type) {
|
---|
161 | return createDirective.isTypeOf(type) || createComponent.isTypeOf(type);
|
---|
162 | }
|
---|
163 | export function findLast(arr, condition) {
|
---|
164 | for (let i = arr.length - 1; i >= 0; i--) {
|
---|
165 | if (condition(arr[i])) {
|
---|
166 | return arr[i];
|
---|
167 | }
|
---|
168 | }
|
---|
169 | return null;
|
---|
170 | }
|
---|
171 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlyZWN0aXZlX3Jlc29sdmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL2RpcmVjdGl2ZV9yZXNvbHZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFHSCxPQUFPLEVBQVksZUFBZSxFQUFFLGtCQUFrQixFQUFFLHFCQUFxQixFQUFFLGVBQWUsRUFBRSxpQkFBaUIsRUFBRSxrQkFBa0IsRUFBRSxXQUFXLEVBQUUsWUFBWSxFQUFFLGVBQWUsRUFBRSxrQkFBa0IsRUFBa0IsTUFBTSxRQUF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3V0cHV0cy5wdXNoKGAke3Byb3BOYW1lfTogJHtvdXRwdXQuYmluZGluZ1Byb3BlcnR5TmFtZX1gKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBvdXRwdXRzLnB1c2gocHJvcE5hbWUpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBjb25zdCBob3N0QmluZGluZ3MgPSBwcm9wZXJ0eU1ldGFkYXRhW3Byb3BOYW1lXS5maWx0ZXIoYSA9PiBjcmVhdGVIb3N0QmluZGluZy5pc1R5cGVPZihhKSk7XG4gICAgICBob3N0QmluZGluZ3MuZm9yRWFjaChob3N0QmluZGluZyA9PiB7XG4gICAgICAgIGlmIChob3N0QmluZGluZy5ob3N0UHJvcGVydHlOYW1lKSB7XG4gICAgICAgICAgY29uc3Qgc3RhcnRXaXRoID0gaG9zdEJpbmRpbmcuaG9zdFByb3BlcnR5TmFtZVswXTtcbiAgICAgICAgICBpZiAoc3RhcnRXaXRoID09PSAnKCcpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQEhvc3RCaW5kaW5nIGNhbiBub3QgYmluZCB0byBldmVudHMuIFVzZSBASG9zdExpc3RlbmVyIGluc3RlYWQuYCk7XG4gICAgICAgICAgfSBlbHNlIGlmIChzdGFydFdpdGggPT09ICdbJykge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgICAgIGBASG9zdEJpbmRpbmcgcGFyYW1ldGVyIHNob3VsZCBiZSBhIHByb3BlcnR5IG5hbWUsICdjbGFzcy48bmFtZT4nLCBvciAnYXR0ci48bmFtZT4nLmApO1xuICAgICAgICAgIH1cbiAgICAgICAgICBob3N0W2BbJHtob3N0QmluZGluZy5ob3N0UHJvcGVydHlOYW1lfV1gXSA9IHByb3BOYW1lO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGhvc3RbYFske3Byb3BOYW1lfV1gXSA9IHByb3BOYW1lO1xuICAgICAgICB9XG4gICAgICB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