source: trip-planner-front/node_modules/@angular/compiler/src/injectable_compiler.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: 18.5 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/injectable_compiler", ["require", "exports", "@angular/compiler/src/identifiers", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/output/value_util", "@angular/compiler/src/parse_util", "@angular/compiler/src/render3/r3_identifiers"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.InjectableCompiler = void 0;
20 var identifiers_1 = require("@angular/compiler/src/identifiers");
21 var o = require("@angular/compiler/src/output/output_ast");
22 var value_util_1 = require("@angular/compiler/src/output/value_util");
23 var parse_util_1 = require("@angular/compiler/src/parse_util");
24 var r3_identifiers_1 = require("@angular/compiler/src/render3/r3_identifiers");
25 function mapEntry(key, value) {
26 return { key: key, value: value, quoted: false };
27 }
28 var InjectableCompiler = /** @class */ (function () {
29 function InjectableCompiler(reflector, alwaysGenerateDef) {
30 this.reflector = reflector;
31 this.alwaysGenerateDef = alwaysGenerateDef;
32 this.tokenInjector = reflector.resolveExternalReference(identifiers_1.Identifiers.Injector);
33 }
34 InjectableCompiler.prototype.depsArray = function (deps, ctx) {
35 var _this = this;
36 return deps.map(function (dep) {
37 var token = dep;
38 var args = [token];
39 var flags = 0 /* Default */;
40 if (Array.isArray(dep)) {
41 for (var i = 0; i < dep.length; i++) {
42 var v = dep[i];
43 if (v) {
44 if (v.ngMetadataName === 'Optional') {
45 flags |= 8 /* Optional */;
46 }
47 else if (v.ngMetadataName === 'SkipSelf') {
48 flags |= 4 /* SkipSelf */;
49 }
50 else if (v.ngMetadataName === 'Self') {
51 flags |= 2 /* Self */;
52 }
53 else if (v.ngMetadataName === 'Inject') {
54 token = v.token;
55 }
56 else {
57 token = v;
58 }
59 }
60 }
61 }
62 var tokenExpr;
63 if (typeof token === 'string') {
64 tokenExpr = o.literal(token);
65 }
66 else if (token === _this.tokenInjector) {
67 tokenExpr = o.importExpr(identifiers_1.Identifiers.INJECTOR);
68 }
69 else {
70 tokenExpr = ctx.importExpr(token);
71 }
72 if (flags !== 0 /* Default */) {
73 args = [tokenExpr, o.literal(flags)];
74 }
75 else {
76 args = [tokenExpr];
77 }
78 return o.importExpr(identifiers_1.Identifiers.inject).callFn(args);
79 });
80 };
81 InjectableCompiler.prototype.factoryFor = function (injectable, ctx) {
82 var retValue;
83 if (injectable.useExisting) {
84 retValue = o.importExpr(identifiers_1.Identifiers.inject).callFn([ctx.importExpr(injectable.useExisting)]);
85 }
86 else if (injectable.useFactory) {
87 var deps = injectable.deps || [];
88 if (deps.length > 0) {
89 retValue = ctx.importExpr(injectable.useFactory).callFn(this.depsArray(deps, ctx));
90 }
91 else {
92 return ctx.importExpr(injectable.useFactory);
93 }
94 }
95 else if (injectable.useValue) {
96 retValue = value_util_1.convertValueToOutputAst(ctx, injectable.useValue);
97 }
98 else {
99 var clazz = injectable.useClass || injectable.symbol;
100 var depArgs = this.depsArray(this.reflector.parameters(clazz), ctx);
101 retValue = new o.InstantiateExpr(ctx.importExpr(clazz), depArgs);
102 }
103 return o.fn([], [new o.ReturnStatement(retValue)], undefined, undefined, injectable.symbol.name + '_Factory');
104 };
105 InjectableCompiler.prototype.injectableDef = function (injectable, ctx) {
106 var providedIn = o.NULL_EXPR;
107 if (injectable.providedIn !== undefined) {
108 if (injectable.providedIn === null) {
109 providedIn = o.NULL_EXPR;
110 }
111 else if (typeof injectable.providedIn === 'string') {
112 providedIn = o.literal(injectable.providedIn);
113 }
114 else {
115 providedIn = ctx.importExpr(injectable.providedIn);
116 }
117 }
118 var def = [
119 mapEntry('factory', this.factoryFor(injectable, ctx)),
120 mapEntry('token', ctx.importExpr(injectable.type.reference)),
121 mapEntry('providedIn', providedIn),
122 ];
123 return o.importExpr(r3_identifiers_1.Identifiers.ɵɵdefineInjectable).callFn([o.literalMap(def)], undefined, true);
124 };
125 InjectableCompiler.prototype.compile = function (injectable, ctx) {
126 if (this.alwaysGenerateDef || injectable.providedIn !== undefined) {
127 var className = parse_util_1.identifierName(injectable.type);
128 var clazz = new o.ClassStmt(className, null, [
129 new o.ClassField('ɵprov', o.INFERRED_TYPE, [o.StmtModifier.Static], this.injectableDef(injectable, ctx)),
130 ], [], new o.ClassMethod(null, [], []), []);
131 ctx.statements.push(clazz);
132 }
133 };
134 return InjectableCompiler;
135 }());
136 exports.InjectableCompiler = InjectableCompiler;
137});
138//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5qZWN0YWJsZV9jb21waWxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9pbmplY3RhYmxlX2NvbXBpbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7OztJQU9ILGlFQUEwQztJQUMxQywyREFBeUM7SUFDekMsc0VBQTREO0lBQzVELCtEQUE0QztJQUM1QywrRUFBMkQ7SUFTM0QsU0FBUyxRQUFRLENBQUMsR0FBVyxFQUFFLEtBQW1CO1FBQ2hELE9BQU8sRUFBQyxHQUFHLEtBQUEsRUFBRSxLQUFLLE9BQUEsRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFDLENBQUM7SUFDckMsQ0FBQztJQUVEO1FBRUUsNEJBQW9CLFNBQTJCLEVBQVUsaUJBQTBCO1lBQS9ELGNBQVMsR0FBVCxTQUFTLENBQWtCO1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RGbGFncy5PcHRpb25hbDtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodi5uZ01ldGFkYXRhTmFtZSA9PT0gJ1NraXBTZWxmJykge1xuICAgICAgICAgICAgICBmbGFncyB8PSBJbmplY3RGbGFncy5Ta2lwU2VsZjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodi5uZ01ldGFkYXRhTmFtZSA9PT0gJ1NlbGYnKSB7XG4gICAgICAgICAgICAgIGZsYWdzIHw9IEluamVjdEZsYWdzLlNlbGY7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHYubmdNZXRhZGF0YU5hbWUgPT09ICdJbmplY3QnKSB7XG4gICAgICAgICAgICAgIHRva2VuID0gdi50b2tlbjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHRva2VuID0gdjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgbGV0IHRva2VuRXhwcjogby5FeHByZXNzaW9uO1xuICAgICAgaWYgKHR5cGVvZiB0b2tlbiA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgdG9rZW5FeHByID0gby5saXRlcmFsKHRva2VuKTtcbiAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09IHRoaXMudG9rZW5JbmplY3Rvcikge1xuICAgICAgICB0b2tlbkV4cHIgPSBvLmltcG9ydEV4cHIoSWRlbnRpZmllcnMuSU5KRUNUT1IpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdG9rZW5FeHByID0gY3R4LmltcG9ydEV4cHIodG9rZW4pO1xuICAgICAgfVxuXG4gICAgICBpZiAoZmxhZ3MgIT09IEluamVjdEZsYWdzLkRlZmF1bHQpIHtcbiAgICAgICAgYXJncyA9IFt0b2tlbkV4cHIsIG8ubGl0ZXJhbChmbGFncyldO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgYXJncyA9IFt0b2tlbkV4cHJdO1xuICAgICAgfVxuICAgICAgcm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pbmplY3RhYmxlLCBjdHgpKSxcbiAgICAgIG1hcEVudHJ5KCd0b2tlbicsIGN0eC5pbXBvcnRFeHByKGluamVjdGFibGUudHlwZS5yZWZlcmVuY2UpKSxcbiAgICAgIG1hcEVudHJ5KCdwcm92aWRlZEluJywgcHJvdmlkZWRJbiksXG4gICAgXTtcbiAgICByZXR1cm4gby5pbXBvcnRFeHByKFIzLsm1ybVkZWZpbmVJbmplY3RhYmxlKS5jYWxsRm4oW28ubGl0ZXJhbE1hcChkZWYpXSwgdW5kZWZpbmVkLCB0cnVlKTtcbiAgfVxuXG4gIGNvbXBpbGUoaW5qZWN0YWJsZTogQ29tcGlsZUluamVjdGFibGVNZXRhZGF0YSwgY3R4OiBPdXRwdXRDb250ZXh0KTogdm9pZCB7XG4gICAgaWYgKHRoaXMuYWx3YXlzR2VuZXJhdGVEZWYgfHwgaW5qZWN0YWJsZS5wcm92aWRlZEluICE9PSB1bmRlZmluZWQpIHtcbiAgICAgIGNvbnN0IGNsYXNzTmFtZSA9IGlkZW50aWZpZXJOYW1lKGluamVjdGFibGUudHlwZSkhO1xuICAgICAgY29uc3QgY2xhenogPSBuZXcgby5DbGFzc1N0bXQoXG4gICAgICAgICAgY2xhc3NOYW1lLCBudWxsLFxuICAgICAgICAgIFtcbiAgICAgICAgICAgIG5ldyBvLkNsYXNzRmllbGQoXG4gICAgICAgICAgICAgICAgJ8m1cHJvdicsIG8uSU5GRVJSRURfVFlQRSwgW28uU3RtdE1vZGlmaWVyLlN0YXRpY10sXG4gICAgICAgICAgICAgICAgdGhpcy5pbmplY3RhYmxlRGVmKGluamVjdGFibGUsIGN0eCkpLFxuICAgICAgICAgIF0sXG4gICAgICAgICAgW10sIG5ldyBvLkNsYXNzTWV0aG9kKG51bGwsIFtdLCBbXSksIFtdKTtcbiAgICAgIGN0eC5zdGF0ZW1lbnRzLnB1c2goY2xhenopO1xuICAgIH1cbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.