node-dependency-injection 3.0.0-beta.1 → 3.0.0-beta.4
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.
- package/README.md +1 -1
- package/dist/lib/Autowire.js +171 -41
- package/dist/lib/Compiler.js +14 -34
- package/dist/lib/CompilerPass/DecoratePass.js +72 -31
- package/dist/lib/CompilerPass/OptimizePass.js +42 -20
- package/dist/lib/CompilerPass/RemovePass.js +40 -18
- package/dist/lib/CompilerPass/index.js +52 -50
- package/dist/lib/ContainerBuilder.js +9 -0
- package/dist/lib/Dump/Dumper.js +19 -0
- package/dist/lib/Dump/JsDumper.js +77 -0
- package/dist/lib/Dump/JsonDumper.js +75 -0
- package/dist/lib/Dump/YamlDumper.js +77 -0
- package/dist/lib/Exception/ServiceFileNotAbsolute.js +44 -0
- package/dist/lib/Exception/ServiceFileNotValidExtension.js +44 -0
- package/dist/lib/Exception/UnableToGetInstanceFromId.js +50 -0
- package/dist/lib/InstanceManager.js +105 -63
- package/dist/lib/Loader/FileLoader.js +104 -59
- package/dist/lib/Loader/JsFileLoader.js +3 -4
- package/dist/lib/Loader/JsonFileLoader.js +1 -2
- package/dist/lib/Loader/YamlFileLoader.js +3 -4
- package/dist/lib/ServiceFile.js +188 -0
- package/dist/lib/types/index.d.ts +7 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ const mailer = container.get('service.mailer')
|
|
|
138
138
|
List of features
|
|
139
139
|
------------
|
|
140
140
|
|
|
141
|
-
- Autowire
|
|
141
|
+
- Autowire for TypeScript
|
|
142
142
|
- Configuration files with JS, YAML or JSON.
|
|
143
143
|
- Multiple configuration files
|
|
144
144
|
- Custom relative service directory
|
package/dist/lib/Autowire.js
CHANGED
|
@@ -27,6 +27,8 @@ var _Definition = _interopRequireDefault(require("./Definition"));
|
|
|
27
27
|
|
|
28
28
|
var _Reference = _interopRequireDefault(require("./Reference"));
|
|
29
29
|
|
|
30
|
+
var _ServiceFile = _interopRequireDefault(require("./ServiceFile"));
|
|
31
|
+
|
|
30
32
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
31
33
|
|
|
32
34
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -40,6 +42,8 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
40
42
|
this._interfaceImplementation = new Map();
|
|
41
43
|
this._rootDirectory = container.defaultDir;
|
|
42
44
|
this._container = container;
|
|
45
|
+
this._excludedFolders = [];
|
|
46
|
+
this._dumpServiceFile = null;
|
|
43
47
|
|
|
44
48
|
try {
|
|
45
49
|
this._tsConfigFullPath = tsConfigFullPath || _path["default"].join(process.cwd(), 'tsconfig.json');
|
|
@@ -58,12 +62,18 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
58
62
|
get: function get() {
|
|
59
63
|
return this._container;
|
|
60
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
|
|
61
69
|
}, {
|
|
62
|
-
key: "
|
|
63
|
-
value:
|
|
64
|
-
|
|
70
|
+
key: "_walk",
|
|
71
|
+
value:
|
|
72
|
+
/*#__PURE__*/
|
|
73
|
+
_regenerator["default"].mark(function _walk(dir) {
|
|
74
|
+
var files, _iterator, _step, file, filePath;
|
|
65
75
|
|
|
66
|
-
return _regenerator["default"].wrap(function
|
|
76
|
+
return _regenerator["default"].wrap(function _walk$(_context) {
|
|
67
77
|
while (1) {
|
|
68
78
|
switch (_context.prev = _context.next) {
|
|
69
79
|
case 0:
|
|
@@ -77,55 +87,101 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
77
87
|
|
|
78
88
|
case 4:
|
|
79
89
|
if ((_step = _iterator.n()).done) {
|
|
80
|
-
_context.next =
|
|
90
|
+
_context.next = 20;
|
|
81
91
|
break;
|
|
82
92
|
}
|
|
83
93
|
|
|
84
94
|
file = _step.value;
|
|
85
95
|
|
|
86
96
|
if (!file.isDirectory()) {
|
|
87
|
-
_context.next =
|
|
97
|
+
_context.next = 9;
|
|
88
98
|
break;
|
|
89
99
|
}
|
|
90
100
|
|
|
91
|
-
return _context.delegateYield(this.
|
|
101
|
+
return _context.delegateYield(this._walk(_path["default"].join(dir, file.name)), "t0", 8);
|
|
92
102
|
|
|
93
103
|
case 8:
|
|
94
|
-
_context.
|
|
95
|
-
break;
|
|
104
|
+
return _context.abrupt("continue", 18);
|
|
96
105
|
|
|
97
|
-
case
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
case 9:
|
|
107
|
+
filePath = _path["default"].join(dir, file.name);
|
|
108
|
+
_context.prev = 10;
|
|
100
109
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
this._ensureFileIsNotExcluded(filePath);
|
|
111
|
+
|
|
112
|
+
_context.next = 14;
|
|
113
|
+
return filePath;
|
|
104
114
|
|
|
105
115
|
case 14:
|
|
106
|
-
_context.next =
|
|
116
|
+
_context.next = 18;
|
|
107
117
|
break;
|
|
108
118
|
|
|
109
119
|
case 16:
|
|
110
120
|
_context.prev = 16;
|
|
111
|
-
_context.t1 = _context["catch"](
|
|
121
|
+
_context.t1 = _context["catch"](10);
|
|
112
122
|
|
|
113
|
-
|
|
123
|
+
case 18:
|
|
124
|
+
_context.next = 4;
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 20:
|
|
128
|
+
_context.next = 25;
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
case 22:
|
|
132
|
+
_context.prev = 22;
|
|
133
|
+
_context.t2 = _context["catch"](2);
|
|
114
134
|
|
|
115
|
-
|
|
116
|
-
|
|
135
|
+
_iterator.e(_context.t2);
|
|
136
|
+
|
|
137
|
+
case 25:
|
|
138
|
+
_context.prev = 25;
|
|
117
139
|
|
|
118
140
|
_iterator.f();
|
|
119
141
|
|
|
120
|
-
return _context.finish(
|
|
142
|
+
return _context.finish(25);
|
|
121
143
|
|
|
122
|
-
case
|
|
144
|
+
case 28:
|
|
123
145
|
case "end":
|
|
124
146
|
return _context.stop();
|
|
125
147
|
}
|
|
126
148
|
}
|
|
127
|
-
},
|
|
149
|
+
}, _walk, this, [[2, 22, 25, 28], [10, 16]]);
|
|
128
150
|
})
|
|
151
|
+
/**
|
|
152
|
+
* @private
|
|
153
|
+
* @param {string} filePath
|
|
154
|
+
* @returns {void}
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
}, {
|
|
158
|
+
key: "_ensureFileIsNotExcluded",
|
|
159
|
+
value: function _ensureFileIsNotExcluded(filePath) {
|
|
160
|
+
this._excludedFolders.forEach(function (excludedFolder) {
|
|
161
|
+
if (filePath.includes(excludedFolder)) {
|
|
162
|
+
throw new Error('Excluded Folder!');
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @param {string} path
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
}, {
|
|
171
|
+
key: "addExclude",
|
|
172
|
+
value: function addExclude(relativePath) {
|
|
173
|
+
var fullPathToExclude = _path["default"].join(this._rootDirectory, relativePath);
|
|
174
|
+
|
|
175
|
+
this._excludedFolders.push(fullPathToExclude);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @private
|
|
179
|
+
* @param {string} path
|
|
180
|
+
* @param {string} type
|
|
181
|
+
* @param {string} extension
|
|
182
|
+
* @returns {Promise}
|
|
183
|
+
*/
|
|
184
|
+
|
|
129
185
|
}, {
|
|
130
186
|
key: "_getServiceIdFromPath",
|
|
131
187
|
value: function () {
|
|
@@ -137,7 +193,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
137
193
|
switch (_context2.prev = _context2.next) {
|
|
138
194
|
case 0:
|
|
139
195
|
extension = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : '.ts';
|
|
140
|
-
return _context2.abrupt("return", path.replace(/\//g, '
|
|
196
|
+
return _context2.abrupt("return", path.replace(/\//g, '__').replace(extension, '').replace('@', '__').concat("__".concat(type)));
|
|
141
197
|
|
|
142
198
|
case 2:
|
|
143
199
|
case "end":
|
|
@@ -153,6 +209,10 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
153
209
|
|
|
154
210
|
return _getServiceIdFromPath;
|
|
155
211
|
}()
|
|
212
|
+
/**
|
|
213
|
+
* @return {Promise}
|
|
214
|
+
*/
|
|
215
|
+
|
|
156
216
|
}, {
|
|
157
217
|
key: "process",
|
|
158
218
|
value: function () {
|
|
@@ -164,7 +224,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
164
224
|
switch (_context3.prev = _context3.next) {
|
|
165
225
|
case 0:
|
|
166
226
|
promises = [];
|
|
167
|
-
_iterator2 = _createForOfIteratorHelper(this.
|
|
227
|
+
_iterator2 = _createForOfIteratorHelper(this._walk(this._rootDirectory));
|
|
168
228
|
|
|
169
229
|
try {
|
|
170
230
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -181,6 +241,15 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
181
241
|
return Promise.all(promises);
|
|
182
242
|
|
|
183
243
|
case 5:
|
|
244
|
+
if (!(this._dumpServiceFile instanceof _ServiceFile["default"])) {
|
|
245
|
+
_context3.next = 8;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
_context3.next = 8;
|
|
250
|
+
return this._dumpServiceFile._generateFromContainer(this._container);
|
|
251
|
+
|
|
252
|
+
case 8:
|
|
184
253
|
case "end":
|
|
185
254
|
return _context3.stop();
|
|
186
255
|
}
|
|
@@ -194,6 +263,12 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
194
263
|
|
|
195
264
|
return process;
|
|
196
265
|
}()
|
|
266
|
+
/**
|
|
267
|
+
* @param {string} filePath
|
|
268
|
+
* @returns {Promise}
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
|
|
197
272
|
}, {
|
|
198
273
|
key: "_executeFilePath",
|
|
199
274
|
value: function () {
|
|
@@ -277,6 +352,13 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
277
352
|
|
|
278
353
|
return _executeFilePath;
|
|
279
354
|
}()
|
|
355
|
+
/**
|
|
356
|
+
*
|
|
357
|
+
* @param {string} filePath
|
|
358
|
+
* @returns {Promise}
|
|
359
|
+
* @private
|
|
360
|
+
*/
|
|
361
|
+
|
|
280
362
|
}, {
|
|
281
363
|
key: "_getClassDeclaration",
|
|
282
364
|
value: function () {
|
|
@@ -310,6 +392,16 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
310
392
|
|
|
311
393
|
return _getClassDeclaration;
|
|
312
394
|
}()
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @param {object} classDeclaration
|
|
398
|
+
* @param {string} body
|
|
399
|
+
* @param {any} parsedFile
|
|
400
|
+
* @param {any} ServiceClass
|
|
401
|
+
* @returns
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
|
|
313
405
|
}, {
|
|
314
406
|
key: "_getDefinition",
|
|
315
407
|
value: function () {
|
|
@@ -385,9 +477,6 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
385
477
|
_context6.t1 = _context6["catch"](0);
|
|
386
478
|
|
|
387
479
|
case 32:
|
|
388
|
-
return _context6.abrupt("return", null);
|
|
389
|
-
|
|
390
|
-
case 33:
|
|
391
480
|
case "end":
|
|
392
481
|
return _context6.stop();
|
|
393
482
|
}
|
|
@@ -401,6 +490,15 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
401
490
|
|
|
402
491
|
return _getDefinition;
|
|
403
492
|
}()
|
|
493
|
+
/**
|
|
494
|
+
* @private
|
|
495
|
+
* @param {Definition} definition
|
|
496
|
+
* @param {object} classDeclaration
|
|
497
|
+
* @param {any} body
|
|
498
|
+
* @param {any} parsedFile
|
|
499
|
+
* @returns
|
|
500
|
+
*/
|
|
501
|
+
|
|
404
502
|
}, {
|
|
405
503
|
key: "_getConstructorParamsByDefinition",
|
|
406
504
|
value: function () {
|
|
@@ -439,6 +537,14 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
439
537
|
|
|
440
538
|
return _getConstructorParamsByDefinition;
|
|
441
539
|
}()
|
|
540
|
+
/**
|
|
541
|
+
* @private
|
|
542
|
+
* @param {object} classDeclaration
|
|
543
|
+
* @param {any} body
|
|
544
|
+
* @param {any} parsedFile
|
|
545
|
+
* @param {Definition} definition
|
|
546
|
+
*/
|
|
547
|
+
|
|
442
548
|
}, {
|
|
443
549
|
key: "_parentDefinition",
|
|
444
550
|
value: function () {
|
|
@@ -478,6 +584,14 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
478
584
|
|
|
479
585
|
return _parentDefinition;
|
|
480
586
|
}()
|
|
587
|
+
/**
|
|
588
|
+
* @private
|
|
589
|
+
* @param {any} classDeclaration
|
|
590
|
+
* @param {any} body
|
|
591
|
+
* @param {any} parsedFile
|
|
592
|
+
* @param {string} serviceId
|
|
593
|
+
*/
|
|
594
|
+
|
|
481
595
|
}, {
|
|
482
596
|
key: "_interfaceImplementations",
|
|
483
597
|
value: function () {
|
|
@@ -555,6 +669,14 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
555
669
|
|
|
556
670
|
return _interfaceImplementations;
|
|
557
671
|
}()
|
|
672
|
+
/**
|
|
673
|
+
* @private
|
|
674
|
+
* @param {string} type
|
|
675
|
+
* @param {any} body
|
|
676
|
+
* @param {anty} parsedFile
|
|
677
|
+
* @returns {Promise}
|
|
678
|
+
*/
|
|
679
|
+
|
|
558
680
|
}, {
|
|
559
681
|
key: "_getIdentifierFromImports",
|
|
560
682
|
value: function () {
|
|
@@ -577,46 +699,42 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
577
699
|
|
|
578
700
|
case 7:
|
|
579
701
|
if ((_context10.t1 = _context10.t0()).done) {
|
|
580
|
-
_context10.next =
|
|
702
|
+
_context10.next = 18;
|
|
581
703
|
break;
|
|
582
704
|
}
|
|
583
705
|
|
|
584
706
|
pathConfig = _context10.t1.value;
|
|
585
707
|
tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
586
|
-
tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
587
|
-
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
708
|
+
tsRelativePath = this._tsConfigPaths[pathConfig][0].replace(/\*/g, '');
|
|
588
709
|
|
|
589
710
|
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
590
|
-
_context10.next =
|
|
711
|
+
_context10.next = 13;
|
|
591
712
|
break;
|
|
592
713
|
}
|
|
593
714
|
|
|
594
715
|
return _context10.abrupt("continue", 7);
|
|
595
716
|
|
|
596
|
-
case
|
|
717
|
+
case 13:
|
|
597
718
|
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
598
719
|
parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
599
720
|
rootDir = parsedTsConfigPath.dir;
|
|
600
721
|
_context10.next = 7;
|
|
601
722
|
break;
|
|
602
723
|
|
|
603
|
-
case
|
|
724
|
+
case 18:
|
|
604
725
|
absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
605
726
|
return _context10.abrupt("return", this._getServiceIdFromPath(absolutePathImportForImplement, type));
|
|
606
727
|
|
|
607
|
-
case
|
|
608
|
-
_context10.prev =
|
|
728
|
+
case 22:
|
|
729
|
+
_context10.prev = 22;
|
|
609
730
|
_context10.t2 = _context10["catch"](0);
|
|
610
731
|
|
|
611
|
-
case
|
|
612
|
-
return _context10.abrupt("return", null);
|
|
613
|
-
|
|
614
|
-
case 26:
|
|
732
|
+
case 24:
|
|
615
733
|
case "end":
|
|
616
734
|
return _context10.stop();
|
|
617
735
|
}
|
|
618
736
|
}
|
|
619
|
-
}, _callee9, this, [[0,
|
|
737
|
+
}, _callee9, this, [[0, 22]]);
|
|
620
738
|
}));
|
|
621
739
|
|
|
622
740
|
function _getIdentifierFromImports(_x21, _x22, _x23) {
|
|
@@ -625,6 +743,13 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
625
743
|
|
|
626
744
|
return _getIdentifierFromImports;
|
|
627
745
|
}()
|
|
746
|
+
/**
|
|
747
|
+
* @private
|
|
748
|
+
* @param {any} body
|
|
749
|
+
* @param {string} type
|
|
750
|
+
* @returns {Promise}
|
|
751
|
+
*/
|
|
752
|
+
|
|
628
753
|
}, {
|
|
629
754
|
key: "_getRelativeImport",
|
|
630
755
|
value: function () {
|
|
@@ -657,6 +782,11 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
657
782
|
|
|
658
783
|
return _getRelativeImport;
|
|
659
784
|
}()
|
|
785
|
+
}, {
|
|
786
|
+
key: "enableDump",
|
|
787
|
+
value: function enableDump(servicesDumpPath) {
|
|
788
|
+
this._dumpServiceFile = new _ServiceFile["default"](servicesDumpPath);
|
|
789
|
+
}
|
|
660
790
|
}]);
|
|
661
791
|
return Autowire;
|
|
662
792
|
}();
|
package/dist/lib/Compiler.js
CHANGED
|
@@ -97,54 +97,34 @@ var Compiler = /*#__PURE__*/function () {
|
|
|
97
97
|
key: "_loadExtensions",
|
|
98
98
|
value: function () {
|
|
99
99
|
var _loadExtensions2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
100
|
-
var _iterator, _step, extension;
|
|
100
|
+
var promises, _iterator, _step, extension;
|
|
101
101
|
|
|
102
102
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
103
103
|
while (1) {
|
|
104
104
|
switch (_context2.prev = _context2.next) {
|
|
105
105
|
case 0:
|
|
106
|
+
promises = [];
|
|
106
107
|
_iterator = _createForOfIteratorHelper(this._container.extensions);
|
|
107
|
-
_context2.prev = 1;
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
try {
|
|
110
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
111
|
+
extension = _step.value;
|
|
112
|
+
promises.push(extension.load(this));
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
_iterator.e(err);
|
|
116
|
+
} finally {
|
|
117
|
+
_iterator.f();
|
|
115
118
|
}
|
|
116
119
|
|
|
117
|
-
|
|
118
|
-
_context2.next = 7;
|
|
119
|
-
return extension.load(this);
|
|
120
|
-
|
|
121
|
-
case 7:
|
|
122
|
-
_context2.next = 3;
|
|
123
|
-
break;
|
|
124
|
-
|
|
125
|
-
case 9:
|
|
126
|
-
_context2.next = 14;
|
|
127
|
-
break;
|
|
128
|
-
|
|
129
|
-
case 11:
|
|
130
|
-
_context2.prev = 11;
|
|
131
|
-
_context2.t0 = _context2["catch"](1);
|
|
120
|
+
Promise.all(promises);
|
|
132
121
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
case 14:
|
|
136
|
-
_context2.prev = 14;
|
|
137
|
-
|
|
138
|
-
_iterator.f();
|
|
139
|
-
|
|
140
|
-
return _context2.finish(14);
|
|
141
|
-
|
|
142
|
-
case 17:
|
|
122
|
+
case 4:
|
|
143
123
|
case "end":
|
|
144
124
|
return _context2.stop();
|
|
145
125
|
}
|
|
146
126
|
}
|
|
147
|
-
}, _callee2, this
|
|
127
|
+
}, _callee2, this);
|
|
148
128
|
}));
|
|
149
129
|
|
|
150
130
|
function _loadExtensions() {
|
|
@@ -33,21 +33,41 @@ var DecoratePass = /*#__PURE__*/function () {
|
|
|
33
33
|
* @param {string} definitionId
|
|
34
34
|
* @private
|
|
35
35
|
*/
|
|
36
|
-
function
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
function () {
|
|
37
|
+
var _processDefinitionKeys2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(definitionId) {
|
|
38
|
+
var definition;
|
|
39
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
40
|
+
while (1) {
|
|
41
|
+
switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
definition = this._container.definitions.get(definitionId);
|
|
44
|
+
|
|
45
|
+
if (definition.decorationPriority) {
|
|
46
|
+
this._priority[definition.decorationPriority] = {
|
|
47
|
+
name: definitionId,
|
|
48
|
+
definition: definition
|
|
49
|
+
};
|
|
50
|
+
} else if (definition.decoratedService && !definitionId.includes(DecoratePass.POSTFIX_INNER)) {
|
|
51
|
+
this._priority.push({
|
|
52
|
+
name: definitionId,
|
|
53
|
+
definition: definition
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
case 2:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, _callee, this);
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
function _processDefinitionKeys(_x) {
|
|
66
|
+
return _processDefinitionKeys2.apply(this, arguments);
|
|
49
67
|
}
|
|
50
|
-
|
|
68
|
+
|
|
69
|
+
return _processDefinitionKeys;
|
|
70
|
+
}()
|
|
51
71
|
/**
|
|
52
72
|
* @param {object} decorate
|
|
53
73
|
* @private
|
|
@@ -55,13 +75,32 @@ var DecoratePass = /*#__PURE__*/function () {
|
|
|
55
75
|
|
|
56
76
|
}, {
|
|
57
77
|
key: "_processDecorates",
|
|
58
|
-
value: function
|
|
59
|
-
|
|
78
|
+
value: function () {
|
|
79
|
+
var _processDecorates2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(decorate) {
|
|
80
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
81
|
+
while (1) {
|
|
82
|
+
switch (_context2.prev = _context2.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
this._container.setDefinition("".concat(decorate.name, ".").concat(DecoratePass.POSTFIX_INNER), this._container.definitions.get(decorate.definition.decoratedService));
|
|
60
85
|
|
|
61
|
-
|
|
86
|
+
decorate.definition["public"] = true;
|
|
62
87
|
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
this._container.setDefinition(decorate.definition.decoratedService, decorate.definition);
|
|
89
|
+
|
|
90
|
+
case 3:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context2.stop();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, _callee2, this);
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
function _processDecorates(_x2) {
|
|
99
|
+
return _processDecorates2.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return _processDecorates;
|
|
103
|
+
}()
|
|
65
104
|
/**
|
|
66
105
|
* @param {ContainerBuilder} container
|
|
67
106
|
*/
|
|
@@ -69,22 +108,22 @@ var DecoratePass = /*#__PURE__*/function () {
|
|
|
69
108
|
}, {
|
|
70
109
|
key: "process",
|
|
71
110
|
value: function () {
|
|
72
|
-
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
73
|
-
var _iterator, _step, definitionId, decorates, _iterator2, _step2, decorate;
|
|
111
|
+
var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(container) {
|
|
112
|
+
var promises, _iterator, _step, definitionId, decorates, _iterator2, _step2, decorate;
|
|
74
113
|
|
|
75
|
-
return _regenerator["default"].wrap(function
|
|
114
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
76
115
|
while (1) {
|
|
77
|
-
switch (
|
|
116
|
+
switch (_context3.prev = _context3.next) {
|
|
78
117
|
case 0:
|
|
79
118
|
this._container = container;
|
|
80
119
|
this._priority = [];
|
|
120
|
+
promises = [];
|
|
81
121
|
_iterator = _createForOfIteratorHelper(container.definitions.keys());
|
|
82
122
|
|
|
83
123
|
try {
|
|
84
124
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
85
125
|
definitionId = _step.value;
|
|
86
|
-
|
|
87
|
-
this._processDefinitionKeys(definitionId);
|
|
126
|
+
promises.push(this._processDefinitionKeys(definitionId));
|
|
88
127
|
}
|
|
89
128
|
} catch (err) {
|
|
90
129
|
_iterator.e(err);
|
|
@@ -100,8 +139,7 @@ var DecoratePass = /*#__PURE__*/function () {
|
|
|
100
139
|
try {
|
|
101
140
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
102
141
|
decorate = _step2.value;
|
|
103
|
-
|
|
104
|
-
this._processDecorates(decorate);
|
|
142
|
+
promises.push(this._processDecorates(decorate));
|
|
105
143
|
}
|
|
106
144
|
} catch (err) {
|
|
107
145
|
_iterator2.e(err);
|
|
@@ -109,15 +147,18 @@ var DecoratePass = /*#__PURE__*/function () {
|
|
|
109
147
|
_iterator2.f();
|
|
110
148
|
}
|
|
111
149
|
|
|
112
|
-
|
|
150
|
+
_context3.next = 10;
|
|
151
|
+
return Promise.all(promises);
|
|
152
|
+
|
|
153
|
+
case 10:
|
|
113
154
|
case "end":
|
|
114
|
-
return
|
|
155
|
+
return _context3.stop();
|
|
115
156
|
}
|
|
116
157
|
}
|
|
117
|
-
},
|
|
158
|
+
}, _callee3, this);
|
|
118
159
|
}));
|
|
119
160
|
|
|
120
|
-
function process(
|
|
161
|
+
function process(_x3) {
|
|
121
162
|
return _process.apply(this, arguments);
|
|
122
163
|
}
|
|
123
164
|
|