source: trip-planner-front/node_modules/@angular/compiler/src/render3/view/util.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 29.3 KB
Line 
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(function (factory) {
9 if (typeof module === "object" && typeof module.exports === "object") {
10 var v = factory(require, exports);
11 if (v !== undefined) module.exports = v;
12 }
13 else if (typeof define === "function" && define.amd) {
14 define("@angular/compiler/src/render3/view/util", ["require", "exports", "tslib", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/util", "@angular/compiler/src/render3/r3_ast", "@angular/compiler/src/render3/view/i18n/util"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.getInterpolationArgsLength = exports.chainedInstruction = exports.getAttrsForDirectiveMatching = exports.DefinitionMap = exports.getQueryPredicate = exports.trimTrailingNulls = exports.conditionallyCreateMapObjectLiteral = exports.asLiteral = exports.invalid = exports.unsupported = exports.temporaryAllocator = exports.RESTORED_VIEW_CONTEXT_NAME = exports.NON_BINDABLE_ATTR = exports.IMPLICIT_REFERENCE = exports.REFERENCE_PREFIX = exports.RENDER_FLAGS = exports.CONTEXT_NAME = exports.TEMPORARY_NAME = void 0;
20 var tslib_1 = require("tslib");
21 var o = require("@angular/compiler/src/output/output_ast");
22 var util_1 = require("@angular/compiler/src/util");
23 var t = require("@angular/compiler/src/render3/r3_ast");
24 var util_2 = require("@angular/compiler/src/render3/view/i18n/util");
25 /**
26 * Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in
27 * quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may
28 * bot work in some cases when object keys are mangled by minifier.
29 *
30 * TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
31 * inputs that contain potentially unsafe chars.
32 */
33 var UNSAFE_OBJECT_KEY_NAME_REGEXP = /[-.]/;
34 /** Name of the temporary to use during data binding */
35 exports.TEMPORARY_NAME = '_t';
36 /** Name of the context parameter passed into a template function */
37 exports.CONTEXT_NAME = 'ctx';
38 /** Name of the RenderFlag passed into a template function */
39 exports.RENDER_FLAGS = 'rf';
40 /** The prefix reference variables */
41 exports.REFERENCE_PREFIX = '_r';
42 /** The name of the implicit context reference */
43 exports.IMPLICIT_REFERENCE = '$implicit';
44 /** Non bindable attribute name **/
45 exports.NON_BINDABLE_ATTR = 'ngNonBindable';
46 /** Name for the variable keeping track of the context returned by `ɵɵrestoreView`. */
47 exports.RESTORED_VIEW_CONTEXT_NAME = 'restoredCtx';
48 /**
49 * Creates an allocator for a temporary variable.
50 *
51 * A variable declaration is added to the statements the first time the allocator is invoked.
52 */
53 function temporaryAllocator(statements, name) {
54 var temp = null;
55 return function () {
56 if (!temp) {
57 statements.push(new o.DeclareVarStmt(exports.TEMPORARY_NAME, undefined, o.DYNAMIC_TYPE));
58 temp = o.variable(name);
59 }
60 return temp;
61 };
62 }
63 exports.temporaryAllocator = temporaryAllocator;
64 function unsupported(feature) {
65 if (this) {
66 throw new Error("Builder " + this.constructor.name + " doesn't support " + feature + " yet");
67 }
68 throw new Error("Feature " + feature + " is not supported yet");
69 }
70 exports.unsupported = unsupported;
71 function invalid(arg) {
72 throw new Error("Invalid state: Visitor " + this.constructor.name + " doesn't handle " + arg.constructor.name);
73 }
74 exports.invalid = invalid;
75 function asLiteral(value) {
76 if (Array.isArray(value)) {
77 return o.literalArr(value.map(asLiteral));
78 }
79 return o.literal(value, o.INFERRED_TYPE);
80 }
81 exports.asLiteral = asLiteral;
82 function conditionallyCreateMapObjectLiteral(keys, keepDeclared) {
83 if (Object.getOwnPropertyNames(keys).length > 0) {
84 return mapToExpression(keys, keepDeclared);
85 }
86 return null;
87 }
88 exports.conditionallyCreateMapObjectLiteral = conditionallyCreateMapObjectLiteral;
89 function mapToExpression(map, keepDeclared) {
90 return o.literalMap(Object.getOwnPropertyNames(map).map(function (key) {
91 var _a, _b;
92 // canonical syntax: `dirProp: publicProp`
93 // if there is no `:`, use dirProp = elProp
94 var value = map[key];
95 var declaredName;
96 var publicName;
97 var minifiedName;
98 var needsDeclaredName;
99 if (Array.isArray(value)) {
100 _a = tslib_1.__read(value, 2), publicName = _a[0], declaredName = _a[1];
101 minifiedName = key;
102 needsDeclaredName = publicName !== declaredName;
103 }
104 else {
105 _b = tslib_1.__read(util_1.splitAtColon(key, [key, value]), 2), declaredName = _b[0], publicName = _b[1];
106 minifiedName = declaredName;
107 // Only include the declared name if extracted from the key, i.e. the key contains a colon.
108 // Otherwise the declared name should be omitted even if it is different from the public name,
109 // as it may have already been minified.
110 needsDeclaredName = publicName !== declaredName && key.includes(':');
111 }
112 return {
113 key: minifiedName,
114 // put quotes around keys that contain potentially unsafe characters
115 quoted: UNSAFE_OBJECT_KEY_NAME_REGEXP.test(minifiedName),
116 value: (keepDeclared && needsDeclaredName) ?
117 o.literalArr([asLiteral(publicName), asLiteral(declaredName)]) :
118 asLiteral(publicName)
119 };
120 }));
121 }
122 /**
123 * Remove trailing null nodes as they are implied.
124 */
125 function trimTrailingNulls(parameters) {
126 while (o.isNull(parameters[parameters.length - 1])) {
127 parameters.pop();
128 }
129 return parameters;
130 }
131 exports.trimTrailingNulls = trimTrailingNulls;
132 function getQueryPredicate(query, constantPool) {
133 if (Array.isArray(query.predicate)) {
134 var predicate_1 = [];
135 query.predicate.forEach(function (selector) {
136 // Each item in predicates array may contain strings with comma-separated refs
137 // (for ex. 'ref, ref1, ..., refN'), thus we extract individual refs and store them
138 // as separate array entities
139 var selectors = selector.split(',').map(function (token) { return o.literal(token.trim()); });
140 predicate_1.push.apply(predicate_1, tslib_1.__spreadArray([], tslib_1.__read(selectors)));
141 });
142 return constantPool.getConstLiteral(o.literalArr(predicate_1), true);
143 }
144 else {
145 return query.predicate;
146 }
147 }
148 exports.getQueryPredicate = getQueryPredicate;
149 /**
150 * A representation for an object literal used during codegen of definition objects. The generic
151 * type `T` allows to reference a documented type of the generated structure, such that the
152 * property names that are set can be resolved to their documented declaration.
153 */
154 var DefinitionMap = /** @class */ (function () {
155 function DefinitionMap() {
156 this.values = [];
157 }
158 DefinitionMap.prototype.set = function (key, value) {
159 if (value) {
160 this.values.push({ key: key, value: value, quoted: false });
161 }
162 };
163 DefinitionMap.prototype.toLiteralMap = function () {
164 return o.literalMap(this.values);
165 };
166 return DefinitionMap;
167 }());
168 exports.DefinitionMap = DefinitionMap;
169 /**
170 * Extract a map of properties to values for a given element or template node, which can be used
171 * by the directive matching machinery.
172 *
173 * @param elOrTpl the element or template in question
174 * @return an object set up for directive matching. For attributes on the element/template, this
175 * object maps a property name to its (static) value. For any bindings, this map simply maps the
176 * property name to an empty string.
177 */
178 function getAttrsForDirectiveMatching(elOrTpl) {
179 var attributesMap = {};
180 if (elOrTpl instanceof t.Template && elOrTpl.tagName !== 'ng-template') {
181 elOrTpl.templateAttrs.forEach(function (a) { return attributesMap[a.name] = ''; });
182 }
183 else {
184 elOrTpl.attributes.forEach(function (a) {
185 if (!util_2.isI18nAttribute(a.name)) {
186 attributesMap[a.name] = a.value;
187 }
188 });
189 elOrTpl.inputs.forEach(function (i) {
190 attributesMap[i.name] = '';
191 });
192 elOrTpl.outputs.forEach(function (o) {
193 attributesMap[o.name] = '';
194 });
195 }
196 return attributesMap;
197 }
198 exports.getAttrsForDirectiveMatching = getAttrsForDirectiveMatching;
199 /** Returns a call expression to a chained instruction, e.g. `property(params[0])(params[1])`. */
200 function chainedInstruction(reference, calls, span) {
201 var expression = o.importExpr(reference, null, span);
202 if (calls.length > 0) {
203 for (var i = 0; i < calls.length; i++) {
204 expression = expression.callFn(calls[i], span);
205 }
206 }
207 else {
208 // Add a blank invocation, in case the `calls` array is empty.
209 expression = expression.callFn([], span);
210 }
211 return expression;
212 }
213 exports.chainedInstruction = chainedInstruction;
214 /**
215 * Gets the number of arguments expected to be passed to a generated instruction in the case of
216 * interpolation instructions.
217 * @param interpolation An interpolation ast
218 */
219 function getInterpolationArgsLength(interpolation) {
220 var expressions = interpolation.expressions, strings = interpolation.strings;
221 if (expressions.length === 1 && strings.length === 2 && strings[0] === '' && strings[1] === '') {
222 // If the interpolation has one interpolated value, but the prefix and suffix are both empty
223 // strings, we only pass one argument, to a special instruction like `propertyInterpolate` or
224 // `textInterpolate`.
225 return 1;
226 }
227 else {
228 return expressions.length + strings.length;
229 }
230 }
231 exports.getInterpolationArgsLength = getInterpolationArgsLength;
232});
233//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5kZXIzL3ZpZXcvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7O0lBSUgsMkRBQTZDO0lBRTdDLG1EQUF3QztJQUN4Qyx3REFBK0I7SUFHL0IscUVBQTRDO0lBRzVDOzs7Ozs7O09BT0c7SUFDSCxJQUFNLDZCQUE2QixHQUFHLE1BQU0sQ0FBQztJQUU3Qyx1REFBdUQ7SUFDMUMsUUFBQSxjQUFjLEdBQUcsSUFBSSxDQUFDO0lBRW5DLG9FQUFvRTtJQUN2RCxRQUFBLFlBQVksR0FBRyxLQUFLLENBQUM7SUFFbEMsNkRBQTZEO0lBQ2hELFFBQUEsWUFBWSxHQUFHLElBQUksQ0FBQztJQUVqQyxxQ0FBcUM7SUFDeEIsUUFBQSxnQkFBZ0IsR0FBRyxJQUFJLENBQUM7SUFFckMsaURBQWlEO0lBQ3BDLFFBQUEsa0JBQWtCLEdBQUcsV0FBVyxDQUFDO0lBRTlDLG1DQUFtQztJQUN0QixRQUFBLGlCQUFpQixHQUFHLGVBQWUsQ0FBQztJQUVqRCxzRkFBc0Y7SUF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