static-injector 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/import/commonjs/index.js +1248 -0
  2. package/import/es2015/decorator/injectable.js +14 -0
  3. package/import/es2015/decorator/interface/provider.js +8 -0
  4. package/import/es2015/di/forward_ref.js +53 -0
  5. package/import/es2015/di/inject_switch.js +31 -0
  6. package/import/es2015/di/injection_token.js +71 -0
  7. package/import/es2015/di/injector.js +63 -0
  8. package/import/es2015/di/injector_compatibility.js +172 -0
  9. package/import/es2015/di/injector_marker.js +8 -0
  10. package/import/es2015/di/injector_token.js +21 -0
  11. package/import/es2015/di/interface/defs.js +72 -0
  12. package/import/es2015/di/interface/injector.js +25 -0
  13. package/import/es2015/di/interface/provider.js +8 -0
  14. package/import/es2015/di/metadata.js +49 -0
  15. package/import/es2015/di/null_injector.js +19 -0
  16. package/import/es2015/di/provider_token.js +8 -0
  17. package/import/es2015/di/r3_injector.js +382 -0
  18. package/import/es2015/di/scope.js +14 -0
  19. package/import/es2015/index.js +11 -0
  20. package/import/es2015/interface/lifecycle_hooks.js +8 -0
  21. package/import/es2015/interface/type.js +8 -0
  22. package/import/es2015/render3/definition_factory.js +15 -0
  23. package/import/es2015/render3/error_code.js +29 -0
  24. package/import/es2015/render3/errors_di.js +14 -0
  25. package/import/es2015/render3/fields.js +11 -0
  26. package/import/es2015/render3/instructions/di.js +23 -0
  27. package/import/es2015/render3/util/stringify_utils.js +37 -0
  28. package/import/es2015/util/array_utils.js +17 -0
  29. package/import/es2015/util/closure.js +19 -0
  30. package/import/es2015/util/decorators.js +30 -0
  31. package/import/es2015/util/empty.js +14 -0
  32. package/import/es2015/util/property.js +15 -0
  33. package/import/es2015/util/stringify.js +30 -0
  34. package/import/fesm2015/index.js +1211 -0
  35. package/import/typings/decorator/injectable.d.ts +82 -0
  36. package/import/typings/decorator/interface/provider.d.ts +312 -0
  37. package/import/typings/di/forward_ref.d.ts +49 -0
  38. package/import/typings/di/inject_switch.d.ts +17 -0
  39. package/import/typings/di/injection_token.d.ts +57 -0
  40. package/import/typings/di/injector.d.ts +76 -0
  41. package/import/typings/di/injector_compatibility.d.ts +77 -0
  42. package/import/typings/di/injector_marker.d.ts +23 -0
  43. package/import/typings/di/injector_token.d.ts +18 -0
  44. package/import/typings/di/interface/defs.d.ts +155 -0
  45. package/import/typings/di/interface/injector.d.ts +48 -0
  46. package/import/typings/di/interface/provider.d.ts +312 -0
  47. package/import/typings/di/metadata.d.ts +176 -0
  48. package/import/typings/di/null_injector.d.ts +11 -0
  49. package/import/typings/di/provider_token.d.ts +17 -0
  50. package/import/typings/di/r3_injector.d.ts +92 -0
  51. package/import/typings/di/scope.d.ts +14 -0
  52. package/import/typings/index.d.ts +11 -0
  53. package/import/typings/interface/lifecycle_hooks.d.ts +28 -0
  54. package/import/typings/interface/type.d.ts +21 -0
  55. package/import/typings/render3/definition_factory.d.ts +24 -0
  56. package/import/typings/render3/error_code.d.ts +24 -0
  57. package/import/typings/render3/errors_di.d.ts +2 -0
  58. package/import/typings/render3/fields.d.ts +8 -0
  59. package/import/typings/render3/instructions/di.d.ts +20 -0
  60. package/import/typings/render3/util/stringify_utils.d.ts +20 -0
  61. package/import/typings/util/array_utils.d.ts +10 -0
  62. package/import/typings/util/closure.d.ts +17 -0
  63. package/import/typings/util/decorators.d.ts +27 -0
  64. package/import/typings/util/empty.d.ts +14 -0
  65. package/import/typings/util/property.d.ts +8 -0
  66. package/import/typings/util/stringify.d.ts +8 -0
  67. package/package.json +34 -0
  68. package/readme.md +27 -0
  69. package/transform/compiler/index.d.ts +5 -0
  70. package/transform/compiler/index.js +17 -0
  71. package/transform/compiler/src/core.d.ts +19 -0
  72. package/transform/compiler/src/core.js +9 -0
  73. package/transform/compiler/src/injectable_compiler_2.d.ts +53 -0
  74. package/transform/compiler/src/injectable_compiler_2.js +159 -0
  75. package/transform/compiler/src/output/output_ast.d.ts +534 -0
  76. package/transform/compiler/src/output/output_ast.js +986 -0
  77. package/transform/compiler/src/parse_util.d.ts +50 -0
  78. package/transform/compiler/src/parse_util.js +61 -0
  79. package/transform/compiler/src/render3/partial/api.d.ts +166 -0
  80. package/transform/compiler/src/render3/partial/api.js +11 -0
  81. package/transform/compiler/src/render3/partial/util.d.ts +16 -0
  82. package/transform/compiler/src/render3/partial/util.js +44 -0
  83. package/transform/compiler/src/render3/r3_factory.d.ts +97 -0
  84. package/transform/compiler/src/render3/r3_factory.js +239 -0
  85. package/transform/compiler/src/render3/r3_identifiers.d.ts +20 -0
  86. package/transform/compiler/src/render3/r3_identifiers.js +51 -0
  87. package/transform/compiler/src/render3/util.d.ts +21 -0
  88. package/transform/compiler/src/render3/util.js +41 -0
  89. package/transform/compiler/src/render3/view/util.d.ts +30 -0
  90. package/transform/compiler/src/render3/view/util.js +57 -0
  91. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.d.ts +11 -0
  92. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.js +21 -0
  93. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +42 -0
  94. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +278 -0
  95. package/transform/compiler-cli/src/ngtsc/annotations/src/util.d.ts +91 -0
  96. package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +370 -0
  97. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +24 -0
  98. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +76 -0
  99. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +188 -0
  100. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +206 -0
  101. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +2 -0
  102. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +14 -0
  103. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +1 -0
  104. package/transform/compiler-cli/src/ngtsc/imports/index.js +13 -0
  105. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +36 -0
  106. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +25 -0
  107. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +3 -0
  108. package/transform/compiler-cli/src/ngtsc/reflection/index.js +15 -0
  109. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +667 -0
  110. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +98 -0
  111. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +24 -0
  112. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +271 -0
  113. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +50 -0
  114. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +396 -0
  115. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +12 -0
  116. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +45 -0
  117. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +2 -0
  118. package/transform/compiler-cli/src/ngtsc/transform/index.js +14 -0
  119. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +115 -0
  120. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +30 -0
  121. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +15 -0
  122. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +84 -0
  123. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +5 -0
  124. package/transform/compiler-cli/src/ngtsc/translator/index.js +17 -0
  125. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +274 -0
  126. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js +9 -0
  127. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +27 -0
  128. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +9 -0
  129. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +18 -0
  130. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +27 -0
  131. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +29 -0
  132. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +70 -0
  133. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +58 -0
  134. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +270 -0
  135. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +54 -0
  136. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +245 -0
  137. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +13 -0
  138. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +21 -0
  139. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +11 -0
  140. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +39 -0
  141. package/transform/index.d.ts +1 -0
  142. package/transform/index.js +13 -0
  143. package/transform/injectable-transform.d.ts +41 -0
  144. package/transform/injectable-transform.js +195 -0
  145. package/transform/node-Iteration.d.ts +2 -0
  146. package/transform/node-Iteration.js +12 -0
@@ -0,0 +1,54 @@
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 * as ts from "typescript";
9
+ import { AstFactory, BinaryOperator, LeadingComment, ObjectLiteralProperty, SourceMapRange, TemplateLiteral, UnaryOperator, VariableDeclarationType } from "./api/ast_factory";
10
+ /**
11
+ * A TypeScript flavoured implementation of the AstFactory.
12
+ */
13
+ export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts.Expression> {
14
+ private annotateForClosureCompiler;
15
+ private externalSourceFiles;
16
+ constructor(annotateForClosureCompiler: boolean);
17
+ attachComments: typeof attachComments;
18
+ createArrayLiteral: (elements?: readonly ts.Expression[], multiLine?: boolean) => ts.ArrayLiteralExpression;
19
+ createAssignment(target: ts.Expression, value: ts.Expression): ts.Expression;
20
+ createBinaryExpression(leftOperand: ts.Expression, operator: BinaryOperator, rightOperand: ts.Expression): ts.Expression;
21
+ createBlock(body: ts.Statement[]): ts.Statement;
22
+ createCallExpression(callee: ts.Expression, args: ts.Expression[], pure: boolean): ts.Expression;
23
+ createConditional: {
24
+ (condition: ts.Expression, whenTrue: ts.Expression, whenFalse: ts.Expression): ts.ConditionalExpression;
25
+ (condition: ts.Expression, questionToken: ts.QuestionToken, whenTrue: ts.Expression, colonToken: ts.ColonToken, whenFalse: ts.Expression): ts.ConditionalExpression;
26
+ };
27
+ createElementAccess: (expression: ts.Expression, index: number | ts.Expression) => ts.ElementAccessExpression;
28
+ createExpressionStatement: (expression: ts.Expression) => ts.ExpressionStatement;
29
+ createFunctionDeclaration(functionName: string, parameters: string[], body: ts.Statement): ts.Statement;
30
+ createFunctionExpression(functionName: string | null, parameters: string[], body: ts.Statement): ts.Expression;
31
+ createIdentifier: (text: string) => ts.Identifier;
32
+ createIfStatement(condition: ts.Expression, thenStatement: ts.Statement, elseStatement: ts.Statement | null): ts.Statement;
33
+ createLiteral(value: string | number | boolean | null | undefined): ts.Expression;
34
+ createNewExpression(expression: ts.Expression, args: ts.Expression[]): ts.Expression;
35
+ createObjectLiteral(properties: ObjectLiteralProperty<ts.Expression>[]): ts.Expression;
36
+ createParenthesizedExpression: (expression: ts.Expression) => ts.ParenthesizedExpression;
37
+ createPropertyAccess: (expression: ts.Expression, name: string | ts.MemberName) => ts.PropertyAccessExpression;
38
+ createReturnStatement(expression: ts.Expression | null): ts.Statement;
39
+ createTaggedTemplate(tag: ts.Expression, template: TemplateLiteral<ts.Expression>): ts.Expression;
40
+ createThrowStatement: (expression: ts.Expression) => ts.ThrowStatement;
41
+ createTypeOfExpression: (expression: ts.Expression) => ts.TypeOfExpression;
42
+ createUnaryExpression(operator: UnaryOperator, operand: ts.Expression): ts.Expression;
43
+ createVariableDeclaration(variableName: string, initializer: ts.Expression | null, type: VariableDeclarationType): ts.Statement;
44
+ setSourceMapRange<T extends ts.Node>(node: T, sourceMapRange: SourceMapRange | null): T;
45
+ }
46
+ export declare function createTemplateMiddle(cooked: string, raw: string): ts.TemplateMiddle;
47
+ export declare function createTemplateTail(cooked: string, raw: string): ts.TemplateTail;
48
+ /**
49
+ * Attach the given `leadingComments` to the `statement` node.
50
+ *
51
+ * @param statement The statement that will have comments attached.
52
+ * @param leadingComments The comments to attach to the statement.
53
+ */
54
+ export declare function attachComments(statement: ts.Statement, leadingComments: LeadingComment[]): void;
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.attachComments = exports.createTemplateTail = exports.createTemplateMiddle = exports.TypeScriptAstFactory = void 0;
23
+ /**
24
+ * @license
25
+ * Copyright Google LLC All Rights Reserved.
26
+ *
27
+ * Use of this source code is governed by an MIT-style license that can be
28
+ * found in the LICENSE file at https://angular.io/license
29
+ */
30
+ const ts = __importStar(require("typescript"));
31
+ /**
32
+ * Different optimizers use different annotations on a function or method call to indicate its pure
33
+ * status.
34
+ */
35
+ var PureAnnotation;
36
+ (function (PureAnnotation) {
37
+ /**
38
+ * Closure's annotation for purity is `@pureOrBreakMyCode`, but this needs to be in a semantic
39
+ * (jsdoc) enabled comment. Thus, the actual comment text for Closure must include the `*` that
40
+ * turns a `/*` comment into a `/**` comment, as well as surrounding whitespace.
41
+ */
42
+ PureAnnotation["CLOSURE"] = "* @pureOrBreakMyCode ";
43
+ PureAnnotation["TERSER"] = "@__PURE__";
44
+ })(PureAnnotation || (PureAnnotation = {}));
45
+ const UNARY_OPERATORS = {
46
+ "+": ts.SyntaxKind.PlusToken,
47
+ "-": ts.SyntaxKind.MinusToken,
48
+ "!": ts.SyntaxKind.ExclamationToken,
49
+ };
50
+ const BINARY_OPERATORS = {
51
+ "&&": ts.SyntaxKind.AmpersandAmpersandToken,
52
+ ">": ts.SyntaxKind.GreaterThanToken,
53
+ ">=": ts.SyntaxKind.GreaterThanEqualsToken,
54
+ "&": ts.SyntaxKind.AmpersandToken,
55
+ "/": ts.SyntaxKind.SlashToken,
56
+ "==": ts.SyntaxKind.EqualsEqualsToken,
57
+ "===": ts.SyntaxKind.EqualsEqualsEqualsToken,
58
+ "<": ts.SyntaxKind.LessThanToken,
59
+ "<=": ts.SyntaxKind.LessThanEqualsToken,
60
+ "-": ts.SyntaxKind.MinusToken,
61
+ "%": ts.SyntaxKind.PercentToken,
62
+ "*": ts.SyntaxKind.AsteriskToken,
63
+ "!=": ts.SyntaxKind.ExclamationEqualsToken,
64
+ "!==": ts.SyntaxKind.ExclamationEqualsEqualsToken,
65
+ "||": ts.SyntaxKind.BarBarToken,
66
+ "+": ts.SyntaxKind.PlusToken,
67
+ "??": ts.SyntaxKind.QuestionQuestionToken,
68
+ };
69
+ const VAR_TYPES = {
70
+ const: ts.NodeFlags.Const,
71
+ let: ts.NodeFlags.Let,
72
+ var: ts.NodeFlags.None,
73
+ };
74
+ /**
75
+ * A TypeScript flavoured implementation of the AstFactory.
76
+ */
77
+ class TypeScriptAstFactory {
78
+ constructor(annotateForClosureCompiler) {
79
+ this.annotateForClosureCompiler = annotateForClosureCompiler;
80
+ this.externalSourceFiles = new Map();
81
+ this.attachComments = attachComments;
82
+ this.createArrayLiteral = ts.createArrayLiteral;
83
+ this.createConditional = ts.createConditional;
84
+ this.createElementAccess = ts.createElementAccess;
85
+ this.createExpressionStatement = ts.createExpressionStatement;
86
+ this.createIdentifier = ts.createIdentifier;
87
+ this.createParenthesizedExpression = ts.createParen;
88
+ this.createPropertyAccess = ts.createPropertyAccess;
89
+ this.createThrowStatement = ts.createThrow;
90
+ this.createTypeOfExpression = ts.createTypeOf;
91
+ }
92
+ createAssignment(target, value) {
93
+ return ts.createBinary(target, ts.SyntaxKind.EqualsToken, value);
94
+ }
95
+ createBinaryExpression(leftOperand, operator, rightOperand) {
96
+ return ts.createBinary(leftOperand, BINARY_OPERATORS[operator], rightOperand);
97
+ }
98
+ createBlock(body) {
99
+ return ts.createBlock(body);
100
+ }
101
+ createCallExpression(callee, args, pure) {
102
+ const call = ts.createCall(callee, undefined, args);
103
+ if (pure) {
104
+ ts.addSyntheticLeadingComment(call, ts.SyntaxKind.MultiLineCommentTrivia, this.annotateForClosureCompiler
105
+ ? PureAnnotation.CLOSURE
106
+ : PureAnnotation.TERSER,
107
+ /* trailing newline */ false);
108
+ }
109
+ return call;
110
+ }
111
+ createFunctionDeclaration(functionName, parameters, body) {
112
+ if (!ts.isBlock(body)) {
113
+ throw new Error(`Invalid syntax, expected a block, but got ${ts.SyntaxKind[body.kind]}.`);
114
+ }
115
+ return ts.createFunctionDeclaration(undefined, undefined, undefined, functionName, undefined, parameters.map((param) => ts.createParameter(undefined, undefined, undefined, param)), undefined, body);
116
+ }
117
+ createFunctionExpression(functionName, parameters, body) {
118
+ if (!ts.isBlock(body)) {
119
+ throw new Error(`Invalid syntax, expected a block, but got ${ts.SyntaxKind[body.kind]}.`);
120
+ }
121
+ return ts.createFunctionExpression(undefined, undefined, functionName !== null && functionName !== void 0 ? functionName : undefined, undefined, parameters.map((param) => ts.createParameter(undefined, undefined, undefined, param)), undefined, body);
122
+ }
123
+ createIfStatement(condition, thenStatement, elseStatement) {
124
+ return ts.createIf(condition, thenStatement, elseStatement !== null && elseStatement !== void 0 ? elseStatement : undefined);
125
+ }
126
+ createLiteral(value) {
127
+ if (value === undefined) {
128
+ return ts.createIdentifier("undefined");
129
+ }
130
+ else if (value === null) {
131
+ return ts.createNull();
132
+ }
133
+ else {
134
+ return ts.createLiteral(value);
135
+ }
136
+ }
137
+ createNewExpression(expression, args) {
138
+ return ts.createNew(expression, undefined, args);
139
+ }
140
+ createObjectLiteral(properties) {
141
+ return ts.createObjectLiteral(properties.map((prop) => ts.createPropertyAssignment(prop.quoted
142
+ ? ts.createLiteral(prop.propertyName)
143
+ : ts.createIdentifier(prop.propertyName), prop.value)));
144
+ }
145
+ createReturnStatement(expression) {
146
+ return ts.createReturn(expression !== null && expression !== void 0 ? expression : undefined);
147
+ }
148
+ createTaggedTemplate(tag, template) {
149
+ let templateLiteral;
150
+ const length = template.elements.length;
151
+ const head = template.elements[0];
152
+ if (length === 1) {
153
+ templateLiteral = ts.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
154
+ }
155
+ else {
156
+ const spans = [];
157
+ // Create the middle parts
158
+ for (let i = 1; i < length - 1; i++) {
159
+ const { cooked, raw, range } = template.elements[i];
160
+ const middle = createTemplateMiddle(cooked, raw);
161
+ if (range !== null) {
162
+ this.setSourceMapRange(middle, range);
163
+ }
164
+ spans.push(ts.createTemplateSpan(template.expressions[i - 1], middle));
165
+ }
166
+ // Create the tail part
167
+ const resolvedExpression = template.expressions[length - 2];
168
+ const templatePart = template.elements[length - 1];
169
+ const templateTail = createTemplateTail(templatePart.cooked, templatePart.raw);
170
+ if (templatePart.range !== null) {
171
+ this.setSourceMapRange(templateTail, templatePart.range);
172
+ }
173
+ spans.push(ts.createTemplateSpan(resolvedExpression, templateTail));
174
+ // Put it all together
175
+ templateLiteral = ts.createTemplateExpression(ts.createTemplateHead(head.cooked, head.raw), spans);
176
+ }
177
+ if (head.range !== null) {
178
+ this.setSourceMapRange(templateLiteral, head.range);
179
+ }
180
+ return ts.createTaggedTemplate(tag, templateLiteral);
181
+ }
182
+ createUnaryExpression(operator, operand) {
183
+ return ts.createPrefix(UNARY_OPERATORS[operator], operand);
184
+ }
185
+ createVariableDeclaration(variableName, initializer, type) {
186
+ return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
187
+ ts.createVariableDeclaration(variableName, undefined, initializer !== null && initializer !== void 0 ? initializer : undefined),
188
+ ], VAR_TYPES[type]));
189
+ }
190
+ setSourceMapRange(node, sourceMapRange) {
191
+ if (sourceMapRange === null) {
192
+ return node;
193
+ }
194
+ const url = sourceMapRange.url;
195
+ if (!this.externalSourceFiles.has(url)) {
196
+ this.externalSourceFiles.set(url, ts.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
197
+ }
198
+ const source = this.externalSourceFiles.get(url);
199
+ ts.setSourceMapRange(node, {
200
+ pos: sourceMapRange.start.offset,
201
+ end: sourceMapRange.end.offset,
202
+ source,
203
+ });
204
+ return node;
205
+ }
206
+ }
207
+ exports.TypeScriptAstFactory = TypeScriptAstFactory;
208
+ // HACK: Use this in place of `ts.createTemplateMiddle()`.
209
+ // Revert once https://github.com/microsoft/TypeScript/issues/35374 is fixed.
210
+ function createTemplateMiddle(cooked, raw) {
211
+ const node = ts.createTemplateHead(cooked, raw);
212
+ node.kind = ts.SyntaxKind.TemplateMiddle;
213
+ return node;
214
+ }
215
+ exports.createTemplateMiddle = createTemplateMiddle;
216
+ // HACK: Use this in place of `ts.createTemplateTail()`.
217
+ // Revert once https://github.com/microsoft/TypeScript/issues/35374 is fixed.
218
+ function createTemplateTail(cooked, raw) {
219
+ const node = ts.createTemplateHead(cooked, raw);
220
+ node.kind = ts.SyntaxKind.TemplateTail;
221
+ return node;
222
+ }
223
+ exports.createTemplateTail = createTemplateTail;
224
+ /**
225
+ * Attach the given `leadingComments` to the `statement` node.
226
+ *
227
+ * @param statement The statement that will have comments attached.
228
+ * @param leadingComments The comments to attach to the statement.
229
+ */
230
+ function attachComments(statement, leadingComments) {
231
+ for (const comment of leadingComments) {
232
+ const commentKind = comment.multiline
233
+ ? ts.SyntaxKind.MultiLineCommentTrivia
234
+ : ts.SyntaxKind.SingleLineCommentTrivia;
235
+ if (comment.multiline) {
236
+ ts.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
237
+ }
238
+ else {
239
+ for (const line of comment.toString().split("\n")) {
240
+ ts.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
241
+ }
242
+ }
243
+ }
244
+ }
245
+ exports.attachComments = attachComments;
@@ -0,0 +1,13 @@
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 * as o from "../../../../../compiler";
9
+ import * as ts from "typescript";
10
+ import { ImportGenerator } from "./api/import_generator";
11
+ import { TranslatorOptions } from "./translator";
12
+ export declare function translateExpression(expression: o.Expression, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Expression;
13
+ export declare function translateStatement(statement: o.Statement, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Statement;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.translateStatement = exports.translateExpression = void 0;
11
+ const context_1 = require("./context");
12
+ const translator_1 = require("./translator");
13
+ const typescript_ast_factory_1 = require("./typescript_ast_factory");
14
+ function translateExpression(expression, imports, options = {}) {
15
+ return expression.visitExpression(new translator_1.ExpressionTranslatorVisitor(new typescript_ast_factory_1.TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new context_1.Context(false));
16
+ }
17
+ exports.translateExpression = translateExpression;
18
+ function translateStatement(statement, imports, options = {}) {
19
+ return statement.visitStatement(new translator_1.ExpressionTranslatorVisitor(new typescript_ast_factory_1.TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new context_1.Context(true));
20
+ }
21
+ exports.translateStatement = translateStatement;
@@ -0,0 +1,11 @@
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 * as ts from "typescript";
9
+ export declare function identifierOfNode(decl: ts.Node & {
10
+ name?: ts.Node;
11
+ }): ts.Identifier | null;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.identifierOfNode = void 0;
30
+ const ts = __importStar(require("typescript"));
31
+ function identifierOfNode(decl) {
32
+ if (decl.name !== undefined && ts.isIdentifier(decl.name)) {
33
+ return decl.name;
34
+ }
35
+ else {
36
+ return null;
37
+ }
38
+ }
39
+ exports.identifierOfNode = identifierOfNode;
@@ -0,0 +1 @@
1
+ export * from "./injectable-transform";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./injectable-transform"), exports);
@@ -0,0 +1,41 @@
1
+ import ts from 'typescript';
2
+ import { InjectableDecoratorHandler } from './compiler-cli/src/ngtsc/annotations/src/injectable';
3
+ import { TypeScriptReflectionHost } from './compiler-cli/src/ngtsc/reflection';
4
+ export interface InjectableTransformerFactoryOptions {
5
+ strictCtorDeps?: boolean;
6
+ }
7
+ export declare function createTransformer(program: ts.Program, options?: InjectableTransformerFactoryOptions): (context: ts.TransformationContext) => (sf: ts.SourceFile) => any;
8
+ export declare class InjectableTransformerFactory {
9
+ private program;
10
+ private options;
11
+ typeChecker: ts.TypeChecker;
12
+ reflectionHost: TypeScriptReflectionHost;
13
+ handler: InjectableDecoratorHandler;
14
+ constructor(program: ts.Program, options?: InjectableTransformerFactoryOptions);
15
+ getTransform(): (context: ts.TransformationContext) => (sf: ts.SourceFile) => any;
16
+ private visit;
17
+ private transform;
18
+ private preAnalysis;
19
+ private translate;
20
+ /**
21
+ * Remove Angular decorators from a `ts.Node` in a shallow manner.
22
+ *
23
+ * This will remove decorators from class elements (getters, setters, properties, methods) as well
24
+ * as parameters of constructors.
25
+ */
26
+ private _stripAngularDecorators;
27
+ /**
28
+ * Return all decorators on a `Declaration` which are from static-injector, or an empty set if none
29
+ * are.
30
+ */
31
+ private _angularCoreDecorators;
32
+ /**
33
+ * Given a `ts.Node`, filter the decorators array and return a version containing only non-Angular
34
+ * decorators.
35
+ *
36
+ * If all decorators are removed (or none existed in the first place), this method returns
37
+ * `undefined`.
38
+ */
39
+ private _nonCoreDecoratorsOnly;
40
+ private updateStatements;
41
+ }