node-dependency-injection 3.0.0-alpha.8 → 3.0.0-beta.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.
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
10
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
15
 
12
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -32,68 +36,193 @@ var Compiler = /*#__PURE__*/function () {
32
36
 
33
37
  (0, _createClass2["default"])(Compiler, [{
34
38
  key: "run",
35
- value: function run() {
36
- try {
37
- if (!this._container.frozen) {
38
- this._loadExtensions();
39
-
40
- this._optimize();
41
-
42
- this._remove();
43
- }
44
- } catch (error) {
45
- if (error instanceof RangeError) {
46
- throw new _ServiceCircularReferenceException["default"]();
47
- }
48
-
49
- throw error;
39
+ value: function () {
40
+ var _run = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
41
+ return _regenerator["default"].wrap(function _callee$(_context) {
42
+ while (1) {
43
+ switch (_context.prev = _context.next) {
44
+ case 0:
45
+ _context.prev = 0;
46
+
47
+ if (this._container.frozen) {
48
+ _context.next = 8;
49
+ break;
50
+ }
51
+
52
+ _context.next = 4;
53
+ return this._loadExtensions();
54
+
55
+ case 4:
56
+ _context.next = 6;
57
+ return this._optimize();
58
+
59
+ case 6:
60
+ _context.next = 8;
61
+ return this._remove();
62
+
63
+ case 8:
64
+ _context.next = 14;
65
+ break;
66
+
67
+ case 10:
68
+ _context.prev = 10;
69
+ _context.t0 = _context["catch"](0);
70
+
71
+ if (!(_context.t0 instanceof RangeError)) {
72
+ _context.next = 14;
73
+ break;
74
+ }
75
+
76
+ throw new _ServiceCircularReferenceException["default"]();
77
+
78
+ case 14:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }
83
+ }, _callee, this, [[0, 10]]);
84
+ }));
85
+
86
+ function run() {
87
+ return _run.apply(this, arguments);
50
88
  }
51
- }
89
+
90
+ return run;
91
+ }()
52
92
  /**
53
93
  * @private
54
94
  */
55
95
 
56
96
  }, {
57
97
  key: "_loadExtensions",
58
- value: function _loadExtensions() {
59
- var _iterator = _createForOfIteratorHelper(this._container.extensions),
60
- _step;
61
-
62
- try {
63
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
64
- var extension = _step.value;
65
- extension.load(this);
66
- }
67
- } catch (err) {
68
- _iterator.e(err);
69
- } finally {
70
- _iterator.f();
98
+ value: function () {
99
+ var _loadExtensions2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
100
+ var _iterator, _step, extension;
101
+
102
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
103
+ while (1) {
104
+ switch (_context2.prev = _context2.next) {
105
+ case 0:
106
+ _iterator = _createForOfIteratorHelper(this._container.extensions);
107
+ _context2.prev = 1;
108
+
109
+ _iterator.s();
110
+
111
+ case 3:
112
+ if ((_step = _iterator.n()).done) {
113
+ _context2.next = 9;
114
+ break;
115
+ }
116
+
117
+ extension = _step.value;
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);
132
+
133
+ _iterator.e(_context2.t0);
134
+
135
+ case 14:
136
+ _context2.prev = 14;
137
+
138
+ _iterator.f();
139
+
140
+ return _context2.finish(14);
141
+
142
+ case 17:
143
+ case "end":
144
+ return _context2.stop();
145
+ }
146
+ }
147
+ }, _callee2, this, [[1, 11, 14, 17]]);
148
+ }));
149
+
150
+ function _loadExtensions() {
151
+ return _loadExtensions2.apply(this, arguments);
71
152
  }
72
- }
153
+
154
+ return _loadExtensions;
155
+ }()
73
156
  /**
74
157
  * @private
75
158
  */
76
159
 
77
160
  }, {
78
161
  key: "_optimize",
79
- value: function _optimize() {
80
- this._container._compilerPass.process(_PassConfig["default"].TYPE_BEFORE_OPTIMIZATION);
162
+ value: function () {
163
+ var _optimize2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
164
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
165
+ while (1) {
166
+ switch (_context3.prev = _context3.next) {
167
+ case 0:
168
+ _context3.next = 2;
169
+ return this._container._compilerPass.process(_PassConfig["default"].TYPE_BEFORE_OPTIMIZATION);
170
+
171
+ case 2:
172
+ _context3.next = 4;
173
+ return this._container._compilerPass.process(_PassConfig["default"].TYPE_OPTIMIZE);
174
+
175
+ case 4:
176
+ case "end":
177
+ return _context3.stop();
178
+ }
179
+ }
180
+ }, _callee3, this);
181
+ }));
182
+
183
+ function _optimize() {
184
+ return _optimize2.apply(this, arguments);
185
+ }
81
186
 
82
- this._container._compilerPass.process(_PassConfig["default"].TYPE_OPTIMIZE);
83
- }
187
+ return _optimize;
188
+ }()
84
189
  /**
85
190
  * @private
86
191
  */
87
192
 
88
193
  }, {
89
194
  key: "_remove",
90
- value: function _remove() {
91
- this._container._compilerPass.process(_PassConfig["default"].TYPE_BEFORE_REMOVING);
92
-
93
- this._container._compilerPass.process(_PassConfig["default"].TYPE_REMOVE);
195
+ value: function () {
196
+ var _remove2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
197
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
198
+ while (1) {
199
+ switch (_context4.prev = _context4.next) {
200
+ case 0:
201
+ _context4.next = 2;
202
+ return this._container._compilerPass.process(_PassConfig["default"].TYPE_BEFORE_REMOVING);
203
+
204
+ case 2:
205
+ _context4.next = 4;
206
+ return this._container._compilerPass.process(_PassConfig["default"].TYPE_REMOVE);
207
+
208
+ case 4:
209
+ _context4.next = 6;
210
+ return this._container._compilerPass.process(_PassConfig["default"].TYPE_AFTER_REMOVING);
211
+
212
+ case 6:
213
+ case "end":
214
+ return _context4.stop();
215
+ }
216
+ }
217
+ }, _callee4, this);
218
+ }));
219
+
220
+ function _remove() {
221
+ return _remove2.apply(this, arguments);
222
+ }
94
223
 
95
- this._container._compilerPass.process(_PassConfig["default"].TYPE_AFTER_REMOVING);
96
- }
224
+ return _remove;
225
+ }()
97
226
  }]);
98
227
  return Compiler;
99
228
  }();
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
10
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
15
 
12
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -64,44 +68,61 @@ var DecoratePass = /*#__PURE__*/function () {
64
68
 
65
69
  }, {
66
70
  key: "process",
67
- value: function process(container) {
68
- this._container = container;
69
- this._priority = [];
70
-
71
- var _iterator = _createForOfIteratorHelper(container.definitions.keys()),
72
- _step;
73
-
74
- try {
75
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
76
- var definitionId = _step.value;
77
-
78
- this._processDefinitionKeys(definitionId);
79
- }
80
- } catch (err) {
81
- _iterator.e(err);
82
- } finally {
83
- _iterator.f();
71
+ value: function () {
72
+ var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(container) {
73
+ var _iterator, _step, definitionId, decorates, _iterator2, _step2, decorate;
74
+
75
+ return _regenerator["default"].wrap(function _callee$(_context) {
76
+ while (1) {
77
+ switch (_context.prev = _context.next) {
78
+ case 0:
79
+ this._container = container;
80
+ this._priority = [];
81
+ _iterator = _createForOfIteratorHelper(container.definitions.keys());
82
+
83
+ try {
84
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
85
+ definitionId = _step.value;
86
+
87
+ this._processDefinitionKeys(definitionId);
88
+ }
89
+ } catch (err) {
90
+ _iterator.e(err);
91
+ } finally {
92
+ _iterator.f();
93
+ }
94
+
95
+ decorates = this._priority.filter(function (item) {
96
+ return item !== null;
97
+ });
98
+ _iterator2 = _createForOfIteratorHelper(decorates);
99
+
100
+ try {
101
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
102
+ decorate = _step2.value;
103
+
104
+ this._processDecorates(decorate);
105
+ }
106
+ } catch (err) {
107
+ _iterator2.e(err);
108
+ } finally {
109
+ _iterator2.f();
110
+ }
111
+
112
+ case 7:
113
+ case "end":
114
+ return _context.stop();
115
+ }
116
+ }
117
+ }, _callee, this);
118
+ }));
119
+
120
+ function process(_x) {
121
+ return _process.apply(this, arguments);
84
122
  }
85
123
 
86
- var decorates = this._priority.filter(function (item) {
87
- return item !== null;
88
- });
89
-
90
- var _iterator2 = _createForOfIteratorHelper(decorates),
91
- _step2;
92
-
93
- try {
94
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
95
- var decorate = _step2.value;
96
-
97
- this._processDecorates(decorate);
98
- }
99
- } catch (err) {
100
- _iterator2.e(err);
101
- } finally {
102
- _iterator2.f();
103
- }
104
- }
124
+ return process;
125
+ }()
105
126
  }], [{
106
127
  key: "POSTFIX_INNER",
107
128
  get:
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
10
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
15
 
12
16
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -103,27 +107,69 @@ var CompilerPass = /*#__PURE__*/function () {
103
107
 
104
108
  }, {
105
109
  key: "process",
106
- value: function process(type) {
107
- this._checkAndAdd(type);
110
+ value: function () {
111
+ var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(type) {
112
+ var _iterator, _step, compilerPass;
108
113
 
109
- this[type] = this[type].filter(function (i) {
110
- return i !== null;
111
- });
114
+ return _regenerator["default"].wrap(function _callee$(_context) {
115
+ while (1) {
116
+ switch (_context.prev = _context.next) {
117
+ case 0:
118
+ this._checkAndAdd(type);
112
119
 
113
- var _iterator = _createForOfIteratorHelper(this[type]),
114
- _step;
120
+ this[type] = this[type].filter(function (i) {
121
+ return i !== null;
122
+ });
123
+ _iterator = _createForOfIteratorHelper(this[type]);
124
+ _context.prev = 3;
115
125
 
116
- try {
117
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
- var compilerPass = _step.value;
119
- compilerPass.process(this._container);
120
- }
121
- } catch (err) {
122
- _iterator.e(err);
123
- } finally {
124
- _iterator.f();
126
+ _iterator.s();
127
+
128
+ case 5:
129
+ if ((_step = _iterator.n()).done) {
130
+ _context.next = 11;
131
+ break;
132
+ }
133
+
134
+ compilerPass = _step.value;
135
+ _context.next = 9;
136
+ return compilerPass.process(this._container);
137
+
138
+ case 9:
139
+ _context.next = 5;
140
+ break;
141
+
142
+ case 11:
143
+ _context.next = 16;
144
+ break;
145
+
146
+ case 13:
147
+ _context.prev = 13;
148
+ _context.t0 = _context["catch"](3);
149
+
150
+ _iterator.e(_context.t0);
151
+
152
+ case 16:
153
+ _context.prev = 16;
154
+
155
+ _iterator.f();
156
+
157
+ return _context.finish(16);
158
+
159
+ case 19:
160
+ case "end":
161
+ return _context.stop();
162
+ }
163
+ }
164
+ }, _callee, this, [[3, 13, 16, 19]]);
165
+ }));
166
+
167
+ function process(_x) {
168
+ return _process.apply(this, arguments);
125
169
  }
126
- }
170
+
171
+ return process;
172
+ }()
127
173
  }]);
128
174
  return CompilerPass;
129
175
  }();
@@ -7,10 +7,14 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
10
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
13
 
12
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
15
 
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
+
14
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
19
 
16
20
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -220,9 +224,29 @@ var ContainerBuilder = /*#__PURE__*/function () {
220
224
  }
221
225
  }, {
222
226
  key: "compile",
223
- value: function compile() {
224
- new _Compiler["default"](this).run();
225
- }
227
+ value: function () {
228
+ var _compile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
229
+ return _regenerator["default"].wrap(function _callee$(_context) {
230
+ while (1) {
231
+ switch (_context.prev = _context.next) {
232
+ case 0:
233
+ _context.next = 2;
234
+ return new _Compiler["default"](this).run();
235
+
236
+ case 2:
237
+ case "end":
238
+ return _context.stop();
239
+ }
240
+ }
241
+ }, _callee, this);
242
+ }));
243
+
244
+ function compile() {
245
+ return _compile.apply(this, arguments);
246
+ }
247
+
248
+ return compile;
249
+ }()
226
250
  /**
227
251
  * @param {*} compilerPass
228
252
  * @param {string} type
@@ -89,7 +89,7 @@ var InstanceManager = /*#__PURE__*/function () {
89
89
  }
90
90
  }
91
91
 
92
- this._containerBuilder.logger.warn("The service ".concat(id, " is not registered"));
92
+ this._containerBuilder.logger.warn("The service ".concat(typeof id === 'function' ? id.name : id, " is not registered"));
93
93
 
94
94
  throw new _ServiceNotFoundException["default"](id);
95
95
  }
@@ -183,7 +183,15 @@ var InstanceManager = /*#__PURE__*/function () {
183
183
  var args = this._resolveArguments(definition.args);
184
184
 
185
185
  if (definition.parent) {
186
- args = this._appendParentArgumentsFromDefinition(definition, args);
186
+ try {
187
+ args = this._appendParentArgumentsFromDefinition(definition, args);
188
+ } catch (e) {
189
+ if (e instanceof _NotAbstractServiceException["default"]) {
190
+ throw e;
191
+ }
192
+
193
+ args = [];
194
+ }
187
195
  }
188
196
 
189
197
  var instance = (0, _construct2["default"])(definition.Object, (0, _toConsumableArray2["default"])(args));