Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _b = parseNamedProperty(name_1), propertyName = _b.propertyName, unit = _b.unit;
styleBuilder.registerStyleInput(propertyName, binding.expression, unit, binding.sourceSpan);
}
else if (stylePrefix === 'class') {
styleBuilder.registerClassInput(parseNamedProperty(name_1).propertyName, binding.expression, binding.sourceSpan);
}
else {
// resolve literal arrays and literal objects
var value = binding.expression.visit(valueConverter);
var bindingExpr = bindingFn(bindingContext, value);
var _c = getBindingNameAndInstruction(binding), bindingName = _c.bindingName, instruction = _c.instruction, extraParams = _c.extraParams;
var instructionParams = [
elVarExp, o.literal(bindingName), o.importExpr(r3_identifiers_1.Identifiers.bind).callFn([bindingExpr.currValExpr])
];
updateStatements.push.apply(updateStatements, tslib_1.__spread(bindingExpr.stmts));
updateStatements.push(o.importExpr(instruction).callFn(instructionParams.concat(extraParams)).toStmt());
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (bindings_1_1 && !bindings_1_1.done && (_a = bindings_1.return)) _a.call(bindings_1);
}
finally { if (e_3) throw e_3.error; }
}
if (styleBuilder.hasBindingsOrInitialValues()) {
// since we're dealing with directives here and directives have a hostBinding
// function, we need to generate special instructions that deal with styling
// (both bindings and initial values). The instruction below will instruct
// all initial styling (styling that is inside of a host binding within a
// directive) to be attached to the host element of the directive.
var name_1 = binding.name;
var stylePrefix = getStylingPrefix(name_1);
if (stylePrefix === 'style') {
var _b = parseNamedProperty(name_1), propertyName = _b.propertyName, unit = _b.unit;
styleBuilder.registerStyleInput(propertyName, binding.expression, unit, binding.sourceSpan);
}
else if (stylePrefix === 'class') {
styleBuilder.registerClassInput(parseNamedProperty(name_1).propertyName, binding.expression, binding.sourceSpan);
}
else {
// resolve literal arrays and literal objects
var value = binding.expression.visit(valueConverter);
var bindingExpr = bindingFn(bindingContext, value);
var _c = getBindingNameAndInstruction(binding), bindingName = _c.bindingName, instruction = _c.instruction, extraParams = _c.extraParams;
var instructionParams = [
elVarExp, o.literal(bindingName), o.importExpr(r3_identifiers_1.Identifiers.bind).callFn([bindingExpr.currValExpr])
];
updateStatements.push.apply(updateStatements, tslib_1.__spread(bindingExpr.stmts));
updateStatements.push(o.importExpr(instruction).callFn(instructionParams.concat(extraParams)).toStmt());
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (bindings_1_1 && !bindings_1_1.done && (_a = bindings_1.return)) _a.call(bindings_1);
}
finally { if (e_3) throw e_3.error; }
}
if (styleBuilder.hasBindingsOrInitialValues()) {
// since we're dealing with directives here and directives have a hostBinding
// function, we need to generate special instructions that deal with styling
function createHostBindingsFunction(meta, bindingParser) {
var statements = [];
var temporary = util_2.temporaryAllocator(statements, util_2.TEMPORARY_NAME);
var hostBindingSourceSpan = meta.typeSourceSpan;
// Calculate the queries
for (var index = 0; index < meta.queries.length; index++) {
var query = meta.queries[index];
// e.g. r3.qR(tmp = r3.ld(dirIndex)[1]) && (r3.ld(dirIndex)[0].someDir = tmp);
var getDirectiveMemory = o.importExpr(r3_identifiers_1.Identifiers.load).callFn([o.variable('dirIndex')]);
// The query list is at the query index + 1 because the directive itself is in slot 0.
var getQueryList = getDirectiveMemory.key(o.literal(index + 1));
var assignToTemporary = temporary().set(getQueryList);
var callQueryRefresh = o.importExpr(r3_identifiers_1.Identifiers.queryRefresh).callFn([assignToTemporary]);
var updateDirective = getDirectiveMemory.key(o.literal(0, o.INFERRED_TYPE))
.prop(query.propertyName)
.set(query.first ? temporary().prop('first') : temporary());
var andExpression = callQueryRefresh.and(updateDirective);
statements.push(andExpression.toStmt());
}
var directiveSummary = metadataAsSummary(meta);
// Calculate the host property bindings
var bindings = bindingParser.createBoundHostProperties(directiveSummary, hostBindingSourceSpan);
var bindingContext = o.importExpr(r3_identifiers_1.Identifiers.load).callFn([o.variable('dirIndex')]);
if (bindings) {
try {
else if (meta.useValue !== undefined) {
// Note: it's safe to use `meta.useValue` instead of the `USE_VALUE in meta` check used for
// client code because meta.useValue is an Expression which will be defined even if the actual
// value is undefined.
result = r3_factory_1.compileFactoryFunction(tslib_1.__assign({}, factoryMeta, { expression: meta.useValue }));
}
else if (meta.useExisting !== undefined) {
// useExisting is an `inject` call on the existing token.
result = r3_factory_1.compileFactoryFunction(tslib_1.__assign({}, factoryMeta, { expression: o.importExpr(identifiers_1.Identifiers.inject).callFn([meta.useExisting]) }));
}
else {
result = r3_factory_1.compileFactoryFunction(factoryMeta);
}
var token = meta.type;
var providedIn = meta.providedIn;
var expression = o.importExpr(identifiers_1.Identifiers.defineInjectable).callFn([util_1.mapToMapExpression({ token: token, factory: result.factory, providedIn: providedIn })]);
var type = new o.ExpressionType(o.importExpr(identifiers_1.Identifiers.InjectableDef, [util_1.typeWithParameters(meta.type, meta.typeArgumentCount)]));
return {
expression: expression,
type: type,
statements: result.statements,
};
}
exports.compileInjectable = compileInjectable;
// Interpret the dependency according to its resolved type.
switch (dep.resolved) {
case R3ResolvedDependencyType.Token: {
// Build up the injection flags according to the metadata.
var flags = 0 /* Default */ | (dep.self ? 2 /* Self */ : 0) |
(dep.skipSelf ? 4 /* SkipSelf */ : 0) | (dep.host ? 1 /* Host */ : 0) |
(dep.optional ? 8 /* Optional */ : 0);
// Build up the arguments to the injectFn call.
var injectArgs = [dep.token];
// If this dependency is optional or otherwise has non-default flags, then additional
// parameters describing how to inject the dependency must be passed to the inject function
// that's being used.
if (flags !== 0 /* Default */ || dep.optional) {
injectArgs.push(o.literal(flags));
}
return o.importExpr(injectFn).callFn(injectArgs);
}
case R3ResolvedDependencyType.Attribute:
// In the case of attributes, the attribute name in question is given as the token.
return o.importExpr(r3_identifiers_1.Identifiers.injectAttribute).callFn([dep.token]);
default:
return util_1.unsupported("Unknown R3ResolvedDependencyType: " + R3ResolvedDependencyType[dep.resolved]);
}
}
/**
var startSlot = allocateSlots(1 + literalFactoryArguments.length);
literalFactoryArguments.length > 0 || util_1.error("Expected arguments to a literal factory function");
var _b = pureFunctionCallInfo(literalFactoryArguments), identifier = _b.identifier, isVarLength = _b.isVarLength;
// Literal factories are pure functions that only need to be re-invoked when the parameters
// change.
var args = [
o.literal(startSlot),
literalFactory,
];
if (isVarLength) {
args.push(o.literalArr(literalFactoryArguments));
}
else {
args.push.apply(args, tslib_1.__spread(literalFactoryArguments));
}
return o.importExpr(identifier).callFn(args);
}
var BindingScope = /** @class */ (function () {
definitionMap.set('directives', o.literalArr(Array.from(directivesUsed)));
}
// e.g. `pipes: [MyPipe]`
if (pipesUsed.size) {
definitionMap.set('pipes', o.literalArr(Array.from(pipesUsed)));
}
// e.g. `features: [NgOnChangesFeature(MyComponent)]`
var features = [];
if (meta.lifecycle.usesOnChanges) {
features.push(o.importExpr(r3_identifiers_1.Identifiers.NgOnChangesFeature, null, null).callFn([meta.type]));
}
if (features.length) {
definitionMap.set('features', o.literalArr(features));
}
var expression = o.importExpr(r3_identifiers_1.Identifiers.defineComponent).callFn([definitionMap.toLiteralMap()]);
var type = new o.ExpressionType(o.importExpr(r3_identifiers_1.Identifiers.ComponentDef, [new o.ExpressionType(meta.type)]));
return { expression: expression, type: type };
}
exports.compileComponent = compileComponent;
function compileDirective(meta, constantPool, bindingParser) {
var definitionMap = baseDirectiveFields(meta, constantPool, bindingParser);
var expression = o.importExpr(r3_identifiers_1.Identifiers.defineDirective).callFn([definitionMap.toLiteralMap()]);
var type = new o.ExpressionType(o.importExpr(r3_identifiers_1.Identifiers.DirectiveDef, [new o.ExpressionType(meta.type)]));
return { expression: expression, type: type };
}
exports.compileDirective = compileDirective;
case 3:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation1).callFn(args);
case 5:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation2).callFn(args);
case 7:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation3).callFn(args);
case 9:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation4).callFn(args);
case 11:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation5).callFn(args);
case 13:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation6).callFn(args);
case 15:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation7).callFn(args);
case 17:
return o.importExpr(r3_identifiers_1.Identifiers.interpolation8).callFn(args);
}
(args.length >= 19 && args.length % 2 == 1) ||
util_1.error("Invalid interpolation argument length " + args.length);
return o.importExpr(r3_identifiers_1.Identifiers.interpolationV).callFn([o.literalArr(args)]);
}
/**
function compileNgModule(meta) {
var moduleType = meta.type, bootstrap = meta.bootstrap, declarations = meta.declarations, imports = meta.imports, exports = meta.exports;
var expression = o.importExpr(r3_identifiers_1.Identifiers.defineNgModule).callFn([util_1.mapToMapExpression({
type: moduleType,
bootstrap: o.literalArr(bootstrap.map(function (ref) { return ref.value; })),
declarations: o.literalArr(declarations.map(function (ref) { return ref.value; })),
imports: o.literalArr(imports.map(function (ref) { return ref.value; })),
exports: o.literalArr(exports.map(function (ref) { return ref.value; })),
})]);
var type = new o.ExpressionType(o.importExpr(r3_identifiers_1.Identifiers.NgModuleDefWithMeta, [
new o.ExpressionType(moduleType), tupleTypeOf(declarations), tupleTypeOf(imports),
tupleTypeOf(exports)
]));
var additionalStatements = [];
return { expression: expression, type: type, additionalStatements: additionalStatements };
}
exports.compileNgModule = compileNgModule;