static-injector 2.0.0 → 2.1.1

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 (107) hide show
  1. package/import/commonjs/index.js +425 -163
  2. package/import/es2015/di/create_injector.js +5 -1
  3. package/import/es2015/di/forward_ref.js +3 -3
  4. package/import/es2015/di/injection_token.js +18 -11
  5. package/import/es2015/di/injector_compatibility.js +19 -10
  6. package/import/es2015/di/injector_token.js +3 -3
  7. package/import/es2015/di/interface/defs.js +21 -12
  8. package/import/es2015/di/interface/provider.js +3 -1
  9. package/import/es2015/di/null_injector.js +3 -3
  10. package/import/es2015/di/provider_collection.js +196 -1
  11. package/import/es2015/di/r3_injector.js +31 -28
  12. package/import/es2015/error_details_base_url.js +19 -0
  13. package/import/es2015/errors.js +42 -0
  14. package/import/es2015/interface/type.js +14 -1
  15. package/import/es2015/render3/definition_factory.js +2 -3
  16. package/import/es2015/render3/errors_di.js +2 -3
  17. package/import/es2015/render3/instructions/di.js +0 -7
  18. package/import/es2015/render3/util/stringify_utils.js +5 -5
  19. package/import/es2015/util/array_utils.js +0 -7
  20. package/import/es2015/util/decorators.js +24 -1
  21. package/import/es2015/util/empty.js +4 -0
  22. package/import/es2015/util/stringify.js +5 -5
  23. package/import/fesm2015/index.js +422 -161
  24. package/import/typings/di/forward_ref.d.ts +1 -1
  25. package/import/typings/di/injectable.d.ts +5 -4
  26. package/import/typings/di/injection_token.d.ts +21 -6
  27. package/import/typings/di/injector.d.ts +16 -0
  28. package/import/typings/di/injector_compatibility.d.ts +11 -5
  29. package/import/typings/di/injector_token.d.ts +2 -2
  30. package/import/typings/di/interface/defs.d.ts +15 -8
  31. package/import/typings/di/interface/provider.d.ts +62 -2
  32. package/import/typings/di/null_injector.d.ts +1 -1
  33. package/import/typings/di/provider_collection.d.ts +55 -2
  34. package/import/typings/di/provider_token.d.ts +3 -3
  35. package/import/typings/di/r3_injector.d.ts +3 -8
  36. package/import/typings/di/scope.d.ts +1 -1
  37. package/import/typings/error_details_base_url.d.ts +19 -0
  38. package/import/typings/errors.d.ts +89 -0
  39. package/import/typings/interface/type.d.ts +45 -0
  40. package/import/typings/render3/definition_factory.d.ts +1 -1
  41. package/import/typings/render3/errors_di.d.ts +7 -0
  42. package/import/typings/render3/instructions/di.d.ts +0 -7
  43. package/import/typings/util/array_utils.d.ts +15 -7
  44. package/import/typings/util/decorators.d.ts +2 -1
  45. package/import/typings/util/empty.d.ts +1 -0
  46. package/package.json +3 -3
  47. package/transform/compiler/compiler.d.ts +8 -0
  48. package/transform/compiler/compiler.js +28 -0
  49. package/transform/compiler/index.d.ts +8 -5
  50. package/transform/compiler/index.js +12 -5
  51. package/transform/compiler/public_api.d.ts +13 -0
  52. package/transform/compiler/public_api.js +30 -0
  53. package/transform/compiler/src/compiler.d.ts +27 -0
  54. package/transform/compiler/src/compiler.js +47 -0
  55. package/transform/compiler/src/output/output_ast.d.ts +1 -1
  56. package/transform/compiler/src/render3/partial/api.d.ts +1 -1
  57. package/transform/compiler/src/render3/partial/api.js +7 -0
  58. package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
  59. package/transform/compiler/src/render3/r3_factory.js +37 -56
  60. package/transform/compiler/src/render3/view/util.d.ts +0 -8
  61. package/transform/compiler/src/render3/view/util.js +0 -8
  62. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
  63. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
  64. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
  65. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
  66. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
  67. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +2 -2
  68. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -34
  69. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +18 -216
  70. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
  71. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +31 -50
  72. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
  73. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +7 -0
  74. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
  75. package/transform/compiler-cli/src/ngtsc/imports/index.js +7 -0
  76. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
  77. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
  78. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
  79. package/transform/compiler-cli/src/ngtsc/reflection/index.js +7 -0
  80. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +12 -13
  81. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +7 -28
  82. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +1 -1
  83. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +17 -41
  84. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
  85. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +46 -65
  86. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
  87. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -27
  88. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
  89. package/transform/compiler-cli/src/ngtsc/transform/index.js +7 -0
  90. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
  91. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
  92. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +15 -35
  93. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
  94. package/transform/compiler-cli/src/ngtsc/translator/index.js +7 -0
  95. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
  96. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +2 -2
  97. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -24
  98. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -2
  99. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +1 -1
  100. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -1
  101. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +76 -95
  102. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
  103. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +20 -126
  104. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +23 -147
  105. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
  106. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -31
  107. package/transform/injectable-transform.js +36 -7
@@ -1,10 +1,18 @@
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
1
  export declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
9
2
  export declare function newArray<T = any>(size: number): T[];
10
3
  export declare function newArray<T>(size: number, value: T): T[];
4
+ /**
5
+ * `KeyValueArray` is an array where even positions contain keys and odd positions contain values.
6
+ *
7
+ * `KeyValueArray` provides a very efficient way of iterating over its contents. For small
8
+ * sets (~10) the cost of binary searching an `KeyValueArray` has about the same performance
9
+ * characteristics that of a `Map` with significantly better memory footprint.
10
+ *
11
+ * If used as a `Map` the keys are stored in alphabetical order so that they can be binary searched
12
+ * for retrieval.
13
+ *
14
+ * See: `keyValueArraySet`, `keyValueArrayGet`, `keyValueArrayIndexOf`, `keyValueArrayDelete`.
15
+ */
16
+ export interface KeyValueArray<VALUE> extends Array<VALUE | string> {
17
+ __brand__: 'array-map';
18
+ }
@@ -24,4 +24,5 @@ export interface TypeDecorator {
24
24
  <T extends Type<any>>(type: T): T;
25
25
  (target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
26
26
  }
27
- export declare function makeParamDecorator(name: string, props?: (...args: any[]) => any): any;
27
+ export declare const PARAMETERS = "__parameters__";
28
+ export declare function makeParamDecorator(name: string, props?: (...args: any[]) => any, parentClass?: any): any;
@@ -11,4 +11,5 @@
11
11
  * allows for identity checks against these values to be consistently used by the framework
12
12
  * code.
13
13
  */
14
+ export declare const EMPTY_OBJ: {};
14
15
  export declare const EMPTY_ARRAY: any[];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "static-injector",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Angular的静态注入器独立使用版本",
5
5
  "keywords": [
6
6
  "angular",
7
7
  "injector",
8
8
  "typescript",
9
- "typescript 4.8",
9
+ "typescript 4.9",
10
10
  "injectable",
11
11
  "static-inject"
12
12
  ],
@@ -29,7 +29,7 @@
29
29
  "author": "wszgrcy",
30
30
  "license": "MIT",
31
31
  "peerDependencies": {
32
- "typescript": "^4.0.0"
32
+ "typescript": "^4.9.3"
33
33
  },
34
34
  "devDependencies": {},
35
35
  "sideEffects": false
@@ -0,0 +1,8 @@
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
+ export * from './public_api';
@@ -0,0 +1,28 @@
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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ // This file is not used to build this module. It is only used during editing
25
+ // by the TypeScript language service and during build for verification. `ngc`
26
+ // replaces this file with production index.ts when it rewrites private symbol
27
+ // names.
28
+ __exportStar(require("./public_api"), exports);
@@ -1,5 +1,8 @@
1
- export * from './src/injectable_compiler_2';
2
- export * from './src/render3/r3_factory';
3
- export * from './src/output/output_ast';
4
- export * from './src/render3/util';
5
- export * from './src/parse_util';
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
+ export * from './compiler';
@@ -1,4 +1,11 @@
1
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
+ */
2
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
10
  if (k2 === undefined) k2 = k;
4
11
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -14,8 +21,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
22
  };
16
23
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./src/injectable_compiler_2"), exports);
18
- __exportStar(require("./src/render3/r3_factory"), exports);
19
- __exportStar(require("./src/output/output_ast"), exports);
20
- __exportStar(require("./src/render3/util"), exports);
21
- __exportStar(require("./src/parse_util"), exports);
24
+ // This file is not used to build this module. It is only used during editing
25
+ // by the TypeScript language service and during build for verification. `ngc`
26
+ // replaces this file with production index.ts when it rewrites private symbol
27
+ // names.
28
+ __exportStar(require("./compiler"), exports);
@@ -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
+ /**
9
+ * @module
10
+ * @description
11
+ * Entry point for all public APIs of this package.
12
+ */
13
+ export * from './src/compiler';
@@ -0,0 +1,30 @@
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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ /**
25
+ * @module
26
+ * @description
27
+ * Entry point for all public APIs of this package.
28
+ */
29
+ __exportStar(require("./src/compiler"), exports);
30
+ // This file only reexports content of the `src` folder. Keep it that way.
@@ -0,0 +1,27 @@
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
+ /**
9
+ * @module
10
+ * @description
11
+ * Entry point for all APIs of the compiler package.
12
+ *
13
+ * <div class="callout is-critical">
14
+ * <header>Unstable APIs</header>
15
+ * <p>
16
+ * All compiler apis are currently considered experimental and private!
17
+ * </p>
18
+ * <p>
19
+ * We expect the APIs in this package to keep on changing. Do not rely on them.
20
+ * </p>
21
+ * </div>
22
+ */
23
+ export * from './injectable_compiler_2';
24
+ export * from './render3/r3_factory';
25
+ export * from './output/output_ast';
26
+ export * from './render3/util';
27
+ export * from './parse_util';
@@ -0,0 +1,47 @@
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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ //////////////////////////////////////
25
+ // THIS FILE HAS GLOBAL SIDE EFFECT //
26
+ // (see bottom of file) //
27
+ //////////////////////////////////////
28
+ /**
29
+ * @module
30
+ * @description
31
+ * Entry point for all APIs of the compiler package.
32
+ *
33
+ * <div class="callout is-critical">
34
+ * <header>Unstable APIs</header>
35
+ * <p>
36
+ * All compiler apis are currently considered experimental and private!
37
+ * </p>
38
+ * <p>
39
+ * We expect the APIs in this package to keep on changing. Do not rely on them.
40
+ * </p>
41
+ * </div>
42
+ */
43
+ __exportStar(require("./injectable_compiler_2"), exports);
44
+ __exportStar(require("./render3/r3_factory"), exports);
45
+ __exportStar(require("./output/output_ast"), exports);
46
+ __exportStar(require("./render3/util"), exports);
47
+ __exportStar(require("./parse_util"), exports);
@@ -446,7 +446,7 @@ export declare const enum JSDocTagName {
446
446
  Meaning = "meaning",
447
447
  Suppress = "suppress"
448
448
  }
449
- export declare type JSDocTag = {
449
+ export type JSDocTag = {
450
450
  tagName: JSDocTagName | string;
451
451
  text?: string;
452
452
  } | {
@@ -17,7 +17,7 @@ export interface R3PartialDeclaration {
17
17
  */
18
18
  version: string;
19
19
  /**
20
- * A reference to the `static-injector` ES module, which allows access
20
+ * A reference to the `@angular/core` ES module, which allows access
21
21
  * to all Angular exports, including Ivy instructions.
22
22
  */
23
23
  ngImport: o.Expression;
@@ -1,4 +1,11 @@
1
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
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.FactoryTarget = void 0;
4
11
  var FactoryTarget;
@@ -1,11 +1,4 @@
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 outputAst from '../output/output_ast';
1
+ import * as o from '../output/output_ast';
9
2
  import { R3CompiledExpression, R3Reference } from './util';
10
3
  /**
11
4
  * Metadata required by the factory generator to generate a `factory` function for a type.
@@ -26,7 +19,7 @@ export interface R3ConstructorFactoryMetadata {
26
19
  * This can differ from the outer `type` if the class is being compiled by ngcc and is inside
27
20
  * an IIFE structure that uses a different name internally.
28
21
  */
29
- internalType: outputAst.Expression;
22
+ internalType: o.Expression;
30
23
  /** Number of arguments for the `type`. */
31
24
  typeArgumentCount: number;
32
25
  /**
@@ -48,14 +41,14 @@ export declare enum R3FactoryDelegateType {
48
41
  Function = 1
49
42
  }
50
43
  export interface R3DelegatedFnOrClassMetadata extends R3ConstructorFactoryMetadata {
51
- delegate: outputAst.Expression;
44
+ delegate: o.Expression;
52
45
  delegateType: R3FactoryDelegateType;
53
46
  delegateDeps: R3DependencyMetadata[];
54
47
  }
55
48
  export interface R3ExpressionFactoryMetadata extends R3ConstructorFactoryMetadata {
56
- expression: outputAst.Expression;
49
+ expression: o.Expression;
57
50
  }
58
- export declare type R3FactoryMetadata = R3ConstructorFactoryMetadata | R3DelegatedFnOrClassMetadata | R3ExpressionFactoryMetadata;
51
+ export type R3FactoryMetadata = R3ConstructorFactoryMetadata | R3DelegatedFnOrClassMetadata | R3ExpressionFactoryMetadata;
59
52
  export declare enum FactoryTarget {
60
53
  Directive = 0,
61
54
  Component = 1,
@@ -68,13 +61,13 @@ export interface R3DependencyMetadata {
68
61
  * An expression representing the token or value to be injected.
69
62
  * Or `null` if the dependency could not be resolved - making it invalid.
70
63
  */
71
- token: outputAst.Expression | null;
64
+ token: o.Expression | null;
72
65
  /**
73
66
  * If an @Attribute decorator is present, this is the literal type of the attribute name, or
74
67
  * the unknown type if no literal type is available (e.g. the attribute name is an expression).
75
68
  * Otherwise it is null;
76
69
  */
77
- attributeNameType: outputAst.Expression | null;
70
+ attributeNameType: o.Expression | null;
78
71
  /**
79
72
  * Whether the dependency has an @Optional qualifier.
80
73
  */
@@ -92,6 +85,6 @@ export interface R3DependencyMetadata {
92
85
  * Construct a factory function expression for the given `R3FactoryMetadata`.
93
86
  */
94
87
  export declare function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpression;
95
- export declare function createFactoryType(meta: R3FactoryMetadata): outputAst.ExpressionType;
88
+ export declare function createFactoryType(meta: R3FactoryMetadata): o.ExpressionType;
96
89
  export declare function isDelegatedFactoryMetadata(meta: R3FactoryMetadata): meta is R3DelegatedFnOrClassMetadata;
97
90
  export declare function isExpressionFactoryMetadata(meta: R3FactoryMetadata): meta is R3ExpressionFactoryMetadata;
@@ -1,11 +1,4 @@
1
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
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
3
  if (k2 === undefined) k2 = k;
11
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -31,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
24
  };
32
25
  Object.defineProperty(exports, "__esModule", { value: true });
33
26
  exports.isExpressionFactoryMetadata = exports.isDelegatedFactoryMetadata = exports.createFactoryType = exports.compileFactoryFunction = exports.FactoryTarget = exports.R3FactoryDelegateType = void 0;
34
- const outputAst = __importStar(require("../output/output_ast"));
27
+ const o = __importStar(require("../output/output_ast"));
35
28
  const r3_identifiers_1 = require("../render3/r3_identifiers");
36
29
  const util_1 = require("./util");
37
30
  var R3FactoryDelegateType;
@@ -51,7 +44,7 @@ var FactoryTarget;
51
44
  * Construct a factory function expression for the given `R3FactoryMetadata`.
52
45
  */
53
46
  function compileFactoryFunction(meta) {
54
- const t = outputAst.variable('t');
47
+ const t = o.variable('t');
55
48
  let baseFactoryVar = null;
56
49
  // The type to instantiate via constructor invocation. If there is no delegated factory, meaning
57
50
  // this type is always created by constructor invocation, then this is the type-to-create
@@ -59,29 +52,29 @@ function compileFactoryFunction(meta) {
59
52
  // delegated factory (which is used to create the current type) then this is only the type-to-
60
53
  // create parameter (t).
61
54
  const typeForCtor = !isDelegatedFactoryMetadata(meta)
62
- ? new outputAst.BinaryOperatorExpr(outputAst.BinaryOperator.Or, t, meta.internalType)
55
+ ? new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.internalType)
63
56
  : t;
64
57
  let ctorExpr = null;
65
58
  if (meta.deps !== null) {
66
59
  // There is a constructor (either explicitly or implicitly defined).
67
60
  if (meta.deps !== 'invalid') {
68
- ctorExpr = new outputAst.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));
61
+ ctorExpr = new o.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));
69
62
  }
70
63
  }
71
64
  else {
72
65
  // There is no constructor, use the base class' factory to construct typeForCtor.
73
- baseFactoryVar = outputAst.variable(`ɵ${meta.name}_BaseFactory`);
66
+ baseFactoryVar = o.variable(`ɵ${meta.name}_BaseFactory`);
74
67
  ctorExpr = baseFactoryVar.callFn([typeForCtor]);
75
68
  }
76
69
  const body = [];
77
70
  let retExpr = null;
78
71
  function makeConditionalFactory(nonCtorExpr) {
79
- const r = outputAst.variable('r');
80
- body.push(r.set(outputAst.NULL_EXPR).toDeclStmt());
72
+ const r = o.variable('r');
73
+ body.push(r.set(o.NULL_EXPR).toDeclStmt());
81
74
  const ctorStmt = ctorExpr !== null
82
75
  ? r.set(ctorExpr).toStmt()
83
- : outputAst.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt();
84
- body.push(outputAst.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));
76
+ : o.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt();
77
+ body.push(o.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));
85
78
  return r;
86
79
  }
87
80
  if (isDelegatedFactoryMetadata(meta)) {
@@ -90,8 +83,8 @@ function compileFactoryFunction(meta) {
90
83
  const delegateArgs = injectDependencies(meta.delegateDeps, meta.target);
91
84
  // Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
92
85
  const factoryExpr = new (meta.delegateType === R3FactoryDelegateType.Class
93
- ? outputAst.InstantiateExpr
94
- : outputAst.InvokeFunctionExpr)(meta.delegate, delegateArgs);
86
+ ? o.InstantiateExpr
87
+ : o.InvokeFunctionExpr)(meta.delegate, delegateArgs);
95
88
  retExpr = makeConditionalFactory(factoryExpr);
96
89
  }
97
90
  else if (isExpressionFactoryMetadata(meta)) {
@@ -103,29 +96,29 @@ function compileFactoryFunction(meta) {
103
96
  }
104
97
  if (retExpr === null) {
105
98
  // The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
106
- body.push(outputAst.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt());
99
+ body.push(o.importExpr(r3_identifiers_1.Identifiers.invalidFactory).callFn([]).toStmt());
107
100
  }
108
101
  else if (baseFactoryVar !== null) {
109
102
  // This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
110
- const getInheritedFactoryCall = outputAst
103
+ const getInheritedFactoryCall = o
111
104
  .importExpr(r3_identifiers_1.Identifiers.getInheritedFactory)
112
105
  .callFn([meta.internalType]);
113
106
  // Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
114
- const baseFactory = new outputAst.BinaryOperatorExpr(outputAst.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
115
- body.push(new outputAst.ReturnStatement(baseFactory.callFn([typeForCtor])));
107
+ const baseFactory = new o.BinaryOperatorExpr(o.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
108
+ body.push(new o.ReturnStatement(baseFactory.callFn([typeForCtor])));
116
109
  }
117
110
  else {
118
111
  // This is straightforward factory, just return it.
119
- body.push(new outputAst.ReturnStatement(retExpr));
112
+ body.push(new o.ReturnStatement(retExpr));
120
113
  }
121
- let factoryFn = outputAst.fn([new outputAst.FnParam('t', outputAst.DYNAMIC_TYPE)], body, outputAst.INFERRED_TYPE, undefined, `${meta.name}_Factory`);
114
+ let factoryFn = o.fn([new o.FnParam('t', o.DYNAMIC_TYPE)], body, o.INFERRED_TYPE, undefined, `${meta.name}_Factory`);
122
115
  if (baseFactoryVar !== null) {
123
116
  // There is a base factory variable so wrap its declaration along with the factory function into
124
117
  // an IIFE.
125
- factoryFn = outputAst
118
+ factoryFn = o
126
119
  .fn([], [
127
- new outputAst.DeclareVarStmt(baseFactoryVar.name),
128
- new outputAst.ReturnStatement(factoryFn),
120
+ new o.DeclareVarStmt(baseFactoryVar.name),
121
+ new o.ReturnStatement(factoryFn),
129
122
  ])
130
123
  .callFn([], /* sourceSpan */ undefined, /* pure */ true);
131
124
  }
@@ -139,8 +132,8 @@ exports.compileFactoryFunction = compileFactoryFunction;
139
132
  function createFactoryType(meta) {
140
133
  const ctorDepsType = meta.deps !== null && meta.deps !== 'invalid'
141
134
  ? createCtorDepsType(meta.deps)
142
- : outputAst.NONE_TYPE;
143
- return outputAst.expressionType(outputAst.importExpr(r3_identifiers_1.Identifiers.FactoryDeclaration, [
135
+ : o.NONE_TYPE;
136
+ return o.expressionType(o.importExpr(r3_identifiers_1.Identifiers.FactoryDeclaration, [
144
137
  (0, util_1.typeWithParameters)(meta.type.type, meta.typeArgumentCount),
145
138
  ctorDepsType,
146
139
  ]));
@@ -152,29 +145,29 @@ function injectDependencies(deps, target) {
152
145
  function compileInjectDependency(dep, target, index) {
153
146
  // Interpret the dependency according to its resolved type.
154
147
  if (dep.token === null) {
155
- return outputAst
156
- .importExpr(r3_identifiers_1.Identifiers.invalidFactoryDep)
157
- .callFn([outputAst.literal(index)]);
148
+ return o.importExpr(r3_identifiers_1.Identifiers.invalidFactoryDep).callFn([o.literal(index)]);
158
149
  }
159
150
  else if (dep.attributeNameType === null) {
160
151
  // Build up the injection flags according to the metadata.
161
152
  const flags = 0 /* InjectFlags.Default */ |
162
153
  (dep.self ? 2 /* InjectFlags.Self */ : 0) |
163
154
  (dep.skipSelf ? 4 /* InjectFlags.SkipSelf */ : 0) |
164
- (dep.optional ? 8 /* InjectFlags.Optional */ : 0);
155
+ 0 |
156
+ (dep.optional ? 8 /* InjectFlags.Optional */ : 0) |
157
+ 0;
165
158
  // If this dependency is optional or otherwise has non-default flags, then additional
166
159
  // parameters describing how to inject the dependency must be passed to the inject function
167
160
  // that's being used.
168
- let flagsParam = flags !== 0 /* InjectFlags.Default */ || dep.optional
169
- ? outputAst.literal(flags)
170
- : null;
161
+ let flagsParam = flags !== 0 /* InjectFlags.Default */ || dep.optional ? o.literal(flags) : null;
171
162
  // Build up the arguments to the injectFn call.
172
163
  const injectArgs = [dep.token];
173
164
  if (flagsParam) {
174
165
  injectArgs.push(flagsParam);
175
166
  }
176
167
  const injectFn = getInjectFn(target);
177
- return outputAst.importExpr(injectFn).callFn(injectArgs);
168
+ return o.importExpr(injectFn).callFn(injectArgs);
169
+ }
170
+ else {
178
171
  }
179
172
  }
180
173
  function createCtorDepsType(deps) {
@@ -186,40 +179,28 @@ function createCtorDepsType(deps) {
186
179
  return type;
187
180
  }
188
181
  else {
189
- return outputAst.literal(null);
182
+ return o.literal(null);
190
183
  }
191
184
  });
192
185
  if (hasTypes) {
193
- return outputAst.expressionType(outputAst.literalArr(attributeTypes));
186
+ return o.expressionType(o.literalArr(attributeTypes));
194
187
  }
195
188
  else {
196
- return outputAst.NONE_TYPE;
189
+ return o.NONE_TYPE;
197
190
  }
198
191
  }
199
192
  function createCtorDepType(dep) {
200
193
  const entries = [];
201
194
  if (dep.optional) {
202
- entries.push({
203
- key: 'optional',
204
- value: outputAst.literal(true),
205
- quoted: false,
206
- });
195
+ entries.push({ key: 'optional', value: o.literal(true), quoted: false });
207
196
  }
208
197
  if (dep.self) {
209
- entries.push({
210
- key: 'self',
211
- value: outputAst.literal(true),
212
- quoted: false,
213
- });
198
+ entries.push({ key: 'self', value: o.literal(true), quoted: false });
214
199
  }
215
200
  if (dep.skipSelf) {
216
- entries.push({
217
- key: 'skipSelf',
218
- value: outputAst.literal(true),
219
- quoted: false,
220
- });
201
+ entries.push({ key: 'skipSelf', value: o.literal(true), quoted: false });
221
202
  }
222
- return entries.length > 0 ? outputAst.literalMap(entries) : null;
203
+ return entries.length > 0 ? o.literalMap(entries) : null;
223
204
  }
224
205
  function isDelegatedFactoryMetadata(meta) {
225
206
  return meta.delegateType !== undefined;
@@ -6,14 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import * as o from '../../output/output_ast';
9
- /**
10
- * Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in
11
- * quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may
12
- * bot work in some cases when object keys are mangled by minifier.
13
- *
14
- * TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
15
- * inputs that contain potentially unsafe chars.
16
- */
17
9
  /**
18
10
  * A representation for an object literal used during codegen of definition objects. The generic
19
11
  * type `T` allows to reference a documented type of the generated structure, such that the
@@ -32,14 +32,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.DefinitionMap = void 0;
34
34
  const o = __importStar(require("../../output/output_ast"));
35
- /**
36
- * Checks whether an object key contains potentially unsafe chars, thus the key should be wrapped in
37
- * quotes. Note: we do not wrap all keys into quotes, as it may have impact on minification and may
38
- * bot work in some cases when object keys are mangled by minifier.
39
- *
40
- * TODO(FW-1136): this is a temporary solution, we need to come up with a better way of working with
41
- * inputs that contain potentially unsafe chars.
42
- */
43
35
  /**
44
36
  * A representation for an object literal used during codegen of definition objects. The generic
45
37
  * type `T` allows to reference a documented type of the generated structure, such that the
@@ -0,0 +1,10 @@
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
+ export * from './src/di';
9
+ export * from './src/factory';
10
+ export * from './src/util';
@@ -0,0 +1,26 @@
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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ __exportStar(require("./src/di"), exports);
25
+ __exportStar(require("./src/factory"), exports);
26
+ __exportStar(require("./src/util"), exports);