node-dependency-injection 3.0.0 → 3.0.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.
- package/dist/bin/Services/File/BaseAdapter.js +3 -50
- package/dist/bin/Services/File/FileManager.js +3 -49
- package/dist/bin/Services/File/JsAdapter.js +5 -62
- package/dist/bin/Services/File/JsonAdapter.js +5 -60
- package/dist/bin/Services/File/YamlAdapter.js +5 -65
- package/dist/bin/ndi-config:check.js +1 -55
- package/dist/bin/ndi-config:create.js +1 -40
- package/dist/bin/ndi-container:service.js +1 -131
- package/dist/bin/ndi.js +1 -9
- package/dist/lib/Autowire.js +73 -823
- package/dist/lib/AutowireIdentifier.js +7 -43
- package/dist/lib/Compiler.js +8 -209
- package/dist/lib/CompilerPass/DecoratePass.js +11 -180
- package/dist/lib/CompilerPass/OptimizePass.js +3 -82
- package/dist/lib/CompilerPass/RemovePass.js +3 -79
- package/dist/lib/CompilerPass/index.js +12 -175
- package/dist/lib/ContainerBuilder.js +85 -549
- package/dist/lib/Definition.js +77 -368
- package/dist/lib/Dump/Dumper.js +1 -19
- package/dist/lib/Dump/JsDumper.js +1 -77
- package/dist/lib/Dump/JsonDumper.js +1 -75
- package/dist/lib/Dump/YamlDumper.js +1 -77
- package/dist/lib/Exception/AbstractServiceException.js +2 -46
- package/dist/lib/Exception/AttributesMapException.js +1 -44
- package/dist/lib/Exception/ConfigurationFileNotFoundException.js +2 -46
- package/dist/lib/Exception/ContainerDefaultDirMustBeSet.js +2 -46
- package/dist/lib/Exception/DefinitionNotFoundException.js +2 -46
- package/dist/lib/Exception/FrozenContainerException.js +1 -44
- package/dist/lib/Exception/LoadMethodNotFoundException.js +2 -46
- package/dist/lib/Exception/LoggerWarnMethodNotFoundException.js +1 -44
- package/dist/lib/Exception/MethodCallEmptyException.js +1 -44
- package/dist/lib/Exception/MethodCallNotFoundException.js +2 -46
- package/dist/lib/Exception/NotAbstractServiceException.js +2 -46
- package/dist/lib/Exception/PrivateServiceException.js +2 -46
- package/dist/lib/Exception/ProcessMethodNotFoundException.js +2 -46
- package/dist/lib/Exception/RootDirectoryMustBeAbsolute.js +1 -44
- package/dist/lib/Exception/RootDirectoryNotFound.js +1 -44
- package/dist/lib/Exception/ServiceCircularReferenceException.js +1 -44
- package/dist/lib/Exception/ServiceFileNotAbsolute.js +1 -44
- package/dist/lib/Exception/ServiceFileNotFoundException.js +2 -46
- package/dist/lib/Exception/ServiceFileNotLoadedException.js +2 -46
- package/dist/lib/Exception/ServiceFileNotValidExtension.js +1 -44
- package/dist/lib/Exception/ServiceNotFoundException.js +2 -47
- package/dist/lib/Exception/UnableToGetInstanceFromId.js +2 -49
- package/dist/lib/Exception/WrongCompilerPassTypeException.js +2 -46
- package/dist/lib/Exception/WrongDefinitionException.js +1 -44
- package/dist/lib/InstanceManager.js +54 -406
- package/dist/lib/Loader/FileLoader.js +72 -624
- package/dist/lib/Loader/JsFileLoader.js +3 -101
- package/dist/lib/Loader/JsonFileLoader.js +1 -39
- package/dist/lib/Loader/YamlFileLoader.js +3 -133
- package/dist/lib/PackageReference.js +3 -35
- package/dist/lib/PassConfig.js +14 -78
- package/dist/lib/Reference.js +5 -46
- package/dist/lib/ServiceFile.js +18 -230
- package/dist/lib/TagReference.js +3 -35
- package/dist/lib/index.js +1 -95
- package/package.json +3 -3
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/bin/Services/File/BaseAdapter.js.html +0 -158
- package/coverage/lcov-report/bin/Services/File/FileManager.js.html +0 -176
- package/coverage/lcov-report/bin/Services/File/JsAdapter.js.html +0 -140
- package/coverage/lcov-report/bin/Services/File/JsonAdapter.js.html +0 -131
- package/coverage/lcov-report/bin/Services/File/YamlAdapter.js.html +0 -155
- package/coverage/lcov-report/bin/Services/File/index.html +0 -171
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -171
- package/coverage/lcov-report/lib/Autowire.js.html +0 -506
- package/coverage/lcov-report/lib/Compiler.js.html +0 -239
- package/coverage/lcov-report/lib/CompilerPass/DecoratePass.js.html +0 -248
- package/coverage/lcov-report/lib/CompilerPass/OptimizePass.js.html +0 -128
- package/coverage/lcov-report/lib/CompilerPass/RemovePass.js.html +0 -116
- package/coverage/lcov-report/lib/CompilerPass/index.html +0 -156
- package/coverage/lcov-report/lib/CompilerPass/index.js.html +0 -326
- package/coverage/lcov-report/lib/ContainerBuilder.js.html +0 -1115
- package/coverage/lcov-report/lib/Definition.js.html +0 -962
- package/coverage/lcov-report/lib/Exception/AbstractServiceException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/AttributesMapException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/ConfigurationFileNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/DefinitionNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/FrozenContainerException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/LoadMethodNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/LoggerWarnMethodNotFoundException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/MethodCallEmptyException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/MethodCallNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/NotAbstractServiceException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/PrivateServiceException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/ProcessMethodNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/ServiceCircularReferenceException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/ServiceFileNotFoundException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/ServiceFileNotLoadedException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/ServiceNotFoundException.js.html +0 -113
- package/coverage/lcov-report/lib/Exception/WrongCompilerPassTypeException.js.html +0 -110
- package/coverage/lcov-report/lib/Exception/WrongDefinitionException.js.html +0 -101
- package/coverage/lcov-report/lib/Exception/index.html +0 -366
- package/coverage/lcov-report/lib/InstanceManager.js.html +0 -839
- package/coverage/lcov-report/lib/Loader/FileLoader.js.html +0 -1034
- package/coverage/lcov-report/lib/Loader/JsFileLoader.js.html +0 -155
- package/coverage/lcov-report/lib/Loader/JsonFileLoader.js.html +0 -98
- package/coverage/lcov-report/lib/Loader/YamlFileLoader.js.html +0 -188
- package/coverage/lcov-report/lib/Loader/index.html +0 -156
- package/coverage/lcov-report/lib/PackageReference.js.html +0 -131
- package/coverage/lcov-report/lib/PassConfig.js.html +0 -230
- package/coverage/lcov-report/lib/Reference.js.html +0 -158
- package/coverage/lcov-report/lib/TagReference.js.html +0 -131
- package/coverage/lcov-report/lib/index.html +0 -231
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov.info +0 -1516
|
@@ -1,551 +1,87 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
|
-
|
|
20
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
|
-
|
|
22
|
-
var _path = _interopRequireDefault(require("path"));
|
|
23
|
-
|
|
24
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
25
|
-
|
|
26
|
-
var _Definition = _interopRequireDefault(require("./Definition"));
|
|
27
|
-
|
|
28
|
-
var _PassConfig = _interopRequireDefault(require("./PassConfig"));
|
|
29
|
-
|
|
30
|
-
var _Compiler = _interopRequireDefault(require("./Compiler"));
|
|
31
|
-
|
|
32
|
-
var _CompilerPass = _interopRequireDefault(require("./CompilerPass"));
|
|
33
|
-
|
|
34
|
-
var _InstanceManager = _interopRequireDefault(require("./InstanceManager"));
|
|
35
|
-
|
|
36
|
-
var _DefinitionNotFoundException = _interopRequireDefault(require("./Exception/DefinitionNotFoundException"));
|
|
37
|
-
|
|
38
|
-
var _LoadMethodNotFoundException = _interopRequireDefault(require("./Exception/LoadMethodNotFoundException"));
|
|
39
|
-
|
|
40
|
-
var _LoggerWarnMethodNotFoundException = _interopRequireDefault(require("./Exception/LoggerWarnMethodNotFoundException"));
|
|
41
|
-
|
|
42
|
-
var _WrongDefinitionException = _interopRequireDefault(require("./Exception/WrongDefinitionException"));
|
|
43
|
-
|
|
44
|
-
var _FrozenContainerException = _interopRequireDefault(require("./Exception/FrozenContainerException"));
|
|
45
|
-
|
|
46
|
-
var _RootDirectoryNotFound = _interopRequireDefault(require("./Exception/RootDirectoryNotFound"));
|
|
47
|
-
|
|
48
|
-
var _RootDirectoryMustBeAbsolute = _interopRequireDefault(require("./Exception/RootDirectoryMustBeAbsolute"));
|
|
49
|
-
|
|
50
|
-
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; } } }; }
|
|
51
|
-
|
|
52
|
-
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); }
|
|
53
|
-
|
|
54
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
55
|
-
|
|
56
|
-
var ContainerBuilder = /*#__PURE__*/function () {
|
|
57
|
-
/**
|
|
1
|
+
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));var _Definition=_interopRequireDefault(require("./Definition"));var _PassConfig=_interopRequireDefault(require("./PassConfig"));var _Compiler=_interopRequireDefault(require("./Compiler"));var _CompilerPass=_interopRequireDefault(require("./CompilerPass"));var _InstanceManager=_interopRequireDefault(require("./InstanceManager"));var _DefinitionNotFoundException=_interopRequireDefault(require("./Exception/DefinitionNotFoundException"));var _LoadMethodNotFoundException=_interopRequireDefault(require("./Exception/LoadMethodNotFoundException"));var _LoggerWarnMethodNotFoundException=_interopRequireDefault(require("./Exception/LoggerWarnMethodNotFoundException"));var _WrongDefinitionException=_interopRequireDefault(require("./Exception/WrongDefinitionException"));var _FrozenContainerException=_interopRequireDefault(require("./Exception/FrozenContainerException"));var _RootDirectoryNotFound=_interopRequireDefault(require("./Exception/RootDirectoryNotFound"));var _RootDirectoryMustBeAbsolute=_interopRequireDefault(require("./Exception/RootDirectoryMustBeAbsolute"));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;}}};}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);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}var ContainerBuilder=/*#__PURE__*/function(){/**
|
|
58
2
|
* @param {boolean} containerReferenceAsService
|
|
59
3
|
* @param {String} defaultDir
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
}, {
|
|
147
|
-
key: "instanceManager",
|
|
148
|
-
get: function get() {
|
|
149
|
-
if (!this._instanceManager) {
|
|
150
|
-
this._instanceManager = new _InstanceManager["default"](this, this._definitions, this._alias);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return this._instanceManager;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* @returns {Array}
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
}, {
|
|
160
|
-
key: "extensions",
|
|
161
|
-
get: function get() {
|
|
162
|
-
return this._extensions;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @returns {Console|*}
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
}, {
|
|
169
|
-
key: "logger",
|
|
170
|
-
get: function get() {
|
|
171
|
-
return this._logger;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @param {Console|*} value
|
|
175
|
-
*/
|
|
176
|
-
,
|
|
177
|
-
set: function set(value) {
|
|
178
|
-
if (typeof value.warn !== 'function') {
|
|
179
|
-
throw new _LoggerWarnMethodNotFoundException["default"]();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this._logger = value;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @return {Map}
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
}, {
|
|
189
|
-
key: "services",
|
|
190
|
-
get: function get() {
|
|
191
|
-
return this._container;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @param {string} id
|
|
195
|
-
* @param {*|null} object
|
|
196
|
-
* @param {Array} args
|
|
197
|
-
* @returns {Definition}
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
}, {
|
|
201
|
-
key: "register",
|
|
202
|
-
value: function register(id) {
|
|
203
|
-
var object = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
204
|
-
var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
205
|
-
|
|
206
|
-
if (!this.frozen) {
|
|
207
|
-
var definition = new _Definition["default"]();
|
|
208
|
-
definition.Object = object;
|
|
209
|
-
definition.args = args;
|
|
210
|
-
|
|
211
|
-
if (!object) {
|
|
212
|
-
definition.synthetic = true;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return this.setDefinition(id, definition);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
throw new _FrozenContainerException["default"]();
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @param {string|any} id
|
|
222
|
-
*/
|
|
223
|
-
|
|
224
|
-
}, {
|
|
225
|
-
key: "get",
|
|
226
|
-
value: function get(id) {
|
|
227
|
-
return this.instanceManager.getInstance(id);
|
|
228
|
-
}
|
|
229
|
-
}, {
|
|
230
|
-
key: "compile",
|
|
231
|
-
value: function () {
|
|
232
|
-
var _compile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
233
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
234
|
-
while (1) {
|
|
235
|
-
switch (_context.prev = _context.next) {
|
|
236
|
-
case 0:
|
|
237
|
-
_context.next = 2;
|
|
238
|
-
return new _Compiler["default"](this).run();
|
|
239
|
-
|
|
240
|
-
case 2:
|
|
241
|
-
case "end":
|
|
242
|
-
return _context.stop();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}, _callee, this);
|
|
246
|
-
}));
|
|
247
|
-
|
|
248
|
-
function compile() {
|
|
249
|
-
return _compile.apply(this, arguments);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return compile;
|
|
253
|
-
}()
|
|
254
|
-
/**
|
|
255
|
-
* @param {*} compilerPass
|
|
256
|
-
* @param {string} type
|
|
257
|
-
* @param {number} priority
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
}, {
|
|
261
|
-
key: "addCompilerPass",
|
|
262
|
-
value: function addCompilerPass(compilerPass) {
|
|
263
|
-
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _PassConfig["default"].TYPE_BEFORE_OPTIMIZATION;
|
|
264
|
-
var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
265
|
-
|
|
266
|
-
this._compilerPass.register(compilerPass, type, priority);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* @param {string} alias
|
|
270
|
-
* @param {string} id
|
|
271
|
-
*/
|
|
272
|
-
|
|
273
|
-
}, {
|
|
274
|
-
key: "setAlias",
|
|
275
|
-
value: function setAlias(alias, id) {
|
|
276
|
-
this._alias.set(alias, id);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* @param {string} alias
|
|
280
|
-
* @returns {boolean}
|
|
281
|
-
*/
|
|
282
|
-
|
|
283
|
-
}, {
|
|
284
|
-
key: "hasAlias",
|
|
285
|
-
value: function hasAlias(alias) {
|
|
286
|
-
return this._alias.has(alias);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* @param {string} id
|
|
290
|
-
* @param {Definition} definition
|
|
291
|
-
* @returns {Definition}
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
}, {
|
|
295
|
-
key: "setDefinition",
|
|
296
|
-
value: function setDefinition(id, definition) {
|
|
297
|
-
if (definition instanceof _Definition["default"]) {
|
|
298
|
-
this._definitions.set(id, definition);
|
|
299
|
-
|
|
300
|
-
return definition;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
throw new _WrongDefinitionException["default"]();
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @param {string} name
|
|
307
|
-
* @returns {Iterable}
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
}, {
|
|
311
|
-
key: "findTaggedServiceIds",
|
|
312
|
-
value:
|
|
313
|
-
/*#__PURE__*/
|
|
314
|
-
_regenerator["default"].mark(function findTaggedServiceIds(name) {
|
|
315
|
-
var _iterator, _step, _step$value, id, definition;
|
|
316
|
-
|
|
317
|
-
return _regenerator["default"].wrap(function findTaggedServiceIds$(_context2) {
|
|
318
|
-
while (1) {
|
|
319
|
-
switch (_context2.prev = _context2.next) {
|
|
320
|
-
case 0:
|
|
321
|
-
_iterator = _createForOfIteratorHelper(this._definitions);
|
|
322
|
-
_context2.prev = 1;
|
|
323
|
-
|
|
324
|
-
_iterator.s();
|
|
325
|
-
|
|
326
|
-
case 3:
|
|
327
|
-
if ((_step = _iterator.n()).done) {
|
|
328
|
-
_context2.next = 10;
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
_step$value = (0, _slicedToArray2["default"])(_step.value, 2), id = _step$value[0], definition = _step$value[1];
|
|
333
|
-
|
|
334
|
-
if (!definition.tags.some(function (tag) {
|
|
335
|
-
return tag.name === name;
|
|
336
|
-
})) {
|
|
337
|
-
_context2.next = 8;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
_context2.next = 8;
|
|
342
|
-
return {
|
|
343
|
-
id: id,
|
|
344
|
-
definition: definition
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
case 8:
|
|
348
|
-
_context2.next = 3;
|
|
349
|
-
break;
|
|
350
|
-
|
|
351
|
-
case 10:
|
|
352
|
-
_context2.next = 15;
|
|
353
|
-
break;
|
|
354
|
-
|
|
355
|
-
case 12:
|
|
356
|
-
_context2.prev = 12;
|
|
357
|
-
_context2.t0 = _context2["catch"](1);
|
|
358
|
-
|
|
359
|
-
_iterator.e(_context2.t0);
|
|
360
|
-
|
|
361
|
-
case 15:
|
|
362
|
-
_context2.prev = 15;
|
|
363
|
-
|
|
364
|
-
_iterator.f();
|
|
365
|
-
|
|
366
|
-
return _context2.finish(15);
|
|
367
|
-
|
|
368
|
-
case 18:
|
|
369
|
-
case "end":
|
|
370
|
-
return _context2.stop();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}, findTaggedServiceIds, this, [[1, 12, 15, 18]]);
|
|
374
|
-
})
|
|
375
|
-
/**
|
|
376
|
-
* @param {string} key
|
|
377
|
-
* @param {string||Array|boolean|Object} value
|
|
378
|
-
*/
|
|
379
|
-
|
|
380
|
-
}, {
|
|
381
|
-
key: "setParameter",
|
|
382
|
-
value: function setParameter(key, value) {
|
|
383
|
-
if (typeof value !== 'string' && !Array.isArray(value) && typeof value !== 'boolean' && (0, _typeof2["default"])(value) !== 'object') {
|
|
384
|
-
throw new TypeError('The expected value is not a flat string, an array, a boolean or an object');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
this._parameters.set(key, value);
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* @param {string} key
|
|
391
|
-
* @returns {string|Array}
|
|
392
|
-
*/
|
|
393
|
-
|
|
394
|
-
}, {
|
|
395
|
-
key: "getParameter",
|
|
396
|
-
value: function getParameter(key) {
|
|
397
|
-
return this._parameters.get(key);
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* @param {string} key
|
|
401
|
-
* @returns {boolean}
|
|
402
|
-
*/
|
|
403
|
-
|
|
404
|
-
}, {
|
|
405
|
-
key: "hasParameter",
|
|
406
|
-
value: function hasParameter(key) {
|
|
407
|
-
return this._parameters.has(key);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* @param {string} key
|
|
411
|
-
* @returns {boolean}
|
|
412
|
-
*/
|
|
413
|
-
|
|
414
|
-
}, {
|
|
415
|
-
key: "hasDefinition",
|
|
416
|
-
value: function hasDefinition(key) {
|
|
417
|
-
return this._definitions.has(key);
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* @param {string} key
|
|
421
|
-
* @returns {boolean}
|
|
422
|
-
*/
|
|
423
|
-
|
|
424
|
-
}, {
|
|
425
|
-
key: "has",
|
|
426
|
-
value: function has(key) {
|
|
427
|
-
return this._definitions.has(key) || this._parameters.has(key) || this._alias.has(key);
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* @param {string} method
|
|
431
|
-
* @param {string} key
|
|
432
|
-
* @returns {Definition|boolean}
|
|
433
|
-
* @private
|
|
434
|
-
*/
|
|
435
|
-
|
|
436
|
-
}, {
|
|
437
|
-
key: "_definition",
|
|
438
|
-
value: function _definition(method, key) {
|
|
439
|
-
if (this._definitions.has(key)) {
|
|
440
|
-
return this._definitions[method](key);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
throw new _DefinitionNotFoundException["default"](key);
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* @param {string} key
|
|
447
|
-
* @returns {Definition}
|
|
448
|
-
*/
|
|
449
|
-
|
|
450
|
-
}, {
|
|
451
|
-
key: "getDefinition",
|
|
452
|
-
value: function getDefinition(key) {
|
|
453
|
-
return this._definition('get', key);
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* @param {string} key
|
|
457
|
-
* @returns {boolean}
|
|
458
|
-
*/
|
|
459
|
-
|
|
460
|
-
}, {
|
|
461
|
-
key: "removeDefinition",
|
|
462
|
-
value: function removeDefinition(key) {
|
|
463
|
-
return this._definition('delete', key);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* @param {string} key
|
|
467
|
-
* @returns {Definition}
|
|
468
|
-
*/
|
|
469
|
-
|
|
470
|
-
}, {
|
|
471
|
-
key: "findDefinition",
|
|
472
|
-
value: function () {
|
|
473
|
-
var _findDefinition = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key) {
|
|
474
|
-
return _regenerator["default"].wrap(function _callee2$(_context3) {
|
|
475
|
-
while (1) {
|
|
476
|
-
switch (_context3.prev = _context3.next) {
|
|
477
|
-
case 0:
|
|
478
|
-
key = this._alias.get(key) || key;
|
|
479
|
-
|
|
480
|
-
if (!this._definitions.has(key)) {
|
|
481
|
-
_context3.next = 3;
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return _context3.abrupt("return", this._definitions.get(key));
|
|
486
|
-
|
|
487
|
-
case 3:
|
|
488
|
-
throw new _DefinitionNotFoundException["default"](key);
|
|
489
|
-
|
|
490
|
-
case 4:
|
|
491
|
-
case "end":
|
|
492
|
-
return _context3.stop();
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}, _callee2, this);
|
|
496
|
-
}));
|
|
497
|
-
|
|
498
|
-
function findDefinition(_x) {
|
|
499
|
-
return _findDefinition.apply(this, arguments);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return findDefinition;
|
|
503
|
-
}()
|
|
504
|
-
/**
|
|
505
|
-
* @param {*} extension
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
}, {
|
|
509
|
-
key: "registerExtension",
|
|
510
|
-
value: function registerExtension(extension) {
|
|
511
|
-
if (typeof extension.load !== 'function') {
|
|
512
|
-
throw new _LoadMethodNotFoundException["default"](extension.constructor.name);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
this._extensions.push(extension);
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* @param {string} id
|
|
519
|
-
* @param {*} instance
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
|
-
}, {
|
|
523
|
-
key: "set",
|
|
524
|
-
value: function set(id, instance) {
|
|
525
|
-
this._container.set(id, instance);
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* @param {string} id
|
|
529
|
-
*/
|
|
530
|
-
|
|
531
|
-
}, {
|
|
532
|
-
key: "remove",
|
|
533
|
-
value: function remove(id) {
|
|
534
|
-
this._container["delete"](id);
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* @param {string} id
|
|
538
|
-
* @returns {boolean}
|
|
539
|
-
*/
|
|
540
|
-
|
|
541
|
-
}, {
|
|
542
|
-
key: "isSet",
|
|
543
|
-
value: function isSet(id) {
|
|
544
|
-
return this._container.has(id);
|
|
545
|
-
}
|
|
546
|
-
}]);
|
|
547
|
-
return ContainerBuilder;
|
|
548
|
-
}();
|
|
549
|
-
|
|
550
|
-
var _default = ContainerBuilder;
|
|
551
|
-
exports["default"] = _default;
|
|
4
|
+
*/function ContainerBuilder(){var containerReferenceAsService=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var defaultDir=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;(0,_classCallCheck2["default"])(this,ContainerBuilder);this.ensureIsAbsolute(defaultDir);this.ensureDirectoryExists(defaultDir);this._definitions=new Map();this._parameters=new Map();this._alias=new Map();this._container=new Map();this._frozen=false;this._compilerPass=new _CompilerPass["default"](this);this._extensions=[];this._logger=console;this._instanceManager=undefined;this._containerReferenceAsService=containerReferenceAsService;this._defaultDir=defaultDir;}(0,_createClass2["default"])(ContainerBuilder,[{key:"ensureDirectoryExists",value:function ensureDirectoryExists(directory){if(directory&&_fs["default"].existsSync(directory)===false){throw new _RootDirectoryNotFound["default"]();}}},{key:"ensureIsAbsolute",value:function ensureIsAbsolute(directory){if(directory&&_path["default"].isAbsolute(directory)===false){throw new _RootDirectoryMustBeAbsolute["default"]();}}/**
|
|
5
|
+
* @returns {String}
|
|
6
|
+
*/},{key:"defaultDir",get:function get(){return this._defaultDir;},set:function set(value){this.ensureIsAbsolute(value);this.ensureDirectoryExists(value);this._defaultDir=value;}/**
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/},{key:"containerReferenceAsService",get:function get(){return this._containerReferenceAsService;}/**
|
|
9
|
+
* @returns {Map}
|
|
10
|
+
*/},{key:"definitions",get:function get(){return this._definitions;}/**
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/},{key:"frozen",get:function get(){return this._frozen;}/**
|
|
13
|
+
* @param {boolean} value
|
|
14
|
+
*/,set:function set(value){this._frozen=value;}/**
|
|
15
|
+
* @return {InstanceManager}
|
|
16
|
+
*/},{key:"instanceManager",get:function get(){if(!this._instanceManager){this._instanceManager=new _InstanceManager["default"](this,this._definitions,this._alias);}return this._instanceManager;}/**
|
|
17
|
+
* @returns {Array}
|
|
18
|
+
*/},{key:"extensions",get:function get(){return this._extensions;}/**
|
|
19
|
+
* @returns {Console|*}
|
|
20
|
+
*/},{key:"logger",get:function get(){return this._logger;}/**
|
|
21
|
+
* @param {Console|*} value
|
|
22
|
+
*/,set:function set(value){if(typeof value.warn!=='function'){throw new _LoggerWarnMethodNotFoundException["default"]();}this._logger=value;}/**
|
|
23
|
+
* @return {Map}
|
|
24
|
+
*/},{key:"services",get:function get(){return this._container;}/**
|
|
25
|
+
* @param {string} id
|
|
26
|
+
* @param {*|null} object
|
|
27
|
+
* @param {Array} args
|
|
28
|
+
* @returns {Definition}
|
|
29
|
+
*/},{key:"register",value:function register(id){var object=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var args=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];if(!this.frozen){var definition=new _Definition["default"]();definition.Object=object;definition.args=args;if(!object){definition.synthetic=true;}return this.setDefinition(id,definition);}throw new _FrozenContainerException["default"]();}/**
|
|
30
|
+
* @param {string|any} id
|
|
31
|
+
*/},{key:"get",value:function get(id){return this.instanceManager.getInstance(id);}},{key:"compile",value:function(){var _compile=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(){return _regenerator["default"].wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return new _Compiler["default"](this).run();case 2:case"end":return _context.stop();}}},_callee,this);}));function compile(){return _compile.apply(this,arguments);}return compile;}()/**
|
|
32
|
+
* @param {*} compilerPass
|
|
33
|
+
* @param {string} type
|
|
34
|
+
* @param {number} priority
|
|
35
|
+
*/},{key:"addCompilerPass",value:function addCompilerPass(compilerPass){var type=arguments.length>1&&arguments[1]!==undefined?arguments[1]:_PassConfig["default"].TYPE_BEFORE_OPTIMIZATION;var priority=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;this._compilerPass.register(compilerPass,type,priority);}/**
|
|
36
|
+
* @param {string} alias
|
|
37
|
+
* @param {string} id
|
|
38
|
+
*/},{key:"setAlias",value:function setAlias(alias,id){this._alias.set(alias,id);}/**
|
|
39
|
+
* @param {string} alias
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/},{key:"hasAlias",value:function hasAlias(alias){return this._alias.has(alias);}/**
|
|
42
|
+
* @param {string} id
|
|
43
|
+
* @param {Definition} definition
|
|
44
|
+
* @returns {Definition}
|
|
45
|
+
*/},{key:"setDefinition",value:function setDefinition(id,definition){if(definition instanceof _Definition["default"]){this._definitions.set(id,definition);return definition;}throw new _WrongDefinitionException["default"]();}/**
|
|
46
|
+
* @param {string} name
|
|
47
|
+
* @returns {Iterable}
|
|
48
|
+
*/},{key:"findTaggedServiceIds",value:/*#__PURE__*/_regenerator["default"].mark(function findTaggedServiceIds(name){var _iterator,_step,_step$value,id,definition;return _regenerator["default"].wrap(function findTaggedServiceIds$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_iterator=_createForOfIteratorHelper(this._definitions);_context2.prev=1;_iterator.s();case 3:if((_step=_iterator.n()).done){_context2.next=10;break;}_step$value=(0,_slicedToArray2["default"])(_step.value,2),id=_step$value[0],definition=_step$value[1];if(!definition.tags.some(function(tag){return tag.name===name;})){_context2.next=8;break;}_context2.next=8;return{id:id,definition:definition};case 8:_context2.next=3;break;case 10:_context2.next=15;break;case 12:_context2.prev=12;_context2.t0=_context2["catch"](1);_iterator.e(_context2.t0);case 15:_context2.prev=15;_iterator.f();return _context2.finish(15);case 18:case"end":return _context2.stop();}}},findTaggedServiceIds,this,[[1,12,15,18]]);})/**
|
|
49
|
+
* @param {string} key
|
|
50
|
+
* @param {string||Array|boolean|Object} value
|
|
51
|
+
*/},{key:"setParameter",value:function setParameter(key,value){if(typeof value!=='string'&&!Array.isArray(value)&&typeof value!=='boolean'&&(0,_typeof2["default"])(value)!=='object'){throw new TypeError('The expected value is not a flat string, an array, a boolean or an object');}this._parameters.set(key,value);}/**
|
|
52
|
+
* @param {string} key
|
|
53
|
+
* @returns {string|Array}
|
|
54
|
+
*/},{key:"getParameter",value:function getParameter(key){return this._parameters.get(key);}/**
|
|
55
|
+
* @param {string} key
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/},{key:"hasParameter",value:function hasParameter(key){return this._parameters.has(key);}/**
|
|
58
|
+
* @param {string} key
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/},{key:"hasDefinition",value:function hasDefinition(key){return this._definitions.has(key);}/**
|
|
61
|
+
* @param {string} key
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/},{key:"has",value:function has(key){return this._definitions.has(key)||this._parameters.has(key)||this._alias.has(key);}/**
|
|
64
|
+
* @param {string} method
|
|
65
|
+
* @param {string} key
|
|
66
|
+
* @returns {Definition|boolean}
|
|
67
|
+
* @private
|
|
68
|
+
*/},{key:"_definition",value:function _definition(method,key){if(this._definitions.has(key)){return this._definitions[method](key);}throw new _DefinitionNotFoundException["default"](key);}/**
|
|
69
|
+
* @param {string} key
|
|
70
|
+
* @returns {Definition}
|
|
71
|
+
*/},{key:"getDefinition",value:function getDefinition(key){return this._definition('get',key);}/**
|
|
72
|
+
* @param {string} key
|
|
73
|
+
* @returns {boolean}
|
|
74
|
+
*/},{key:"removeDefinition",value:function removeDefinition(key){return this._definition('delete',key);}/**
|
|
75
|
+
* @param {string} key
|
|
76
|
+
* @returns {Definition}
|
|
77
|
+
*/},{key:"findDefinition",value:function(){var _findDefinition=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(key){return _regenerator["default"].wrap(function _callee2$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:key=this._alias.get(key)||key;if(!this._definitions.has(key)){_context3.next=3;break;}return _context3.abrupt("return",this._definitions.get(key));case 3:throw new _DefinitionNotFoundException["default"](key);case 4:case"end":return _context3.stop();}}},_callee2,this);}));function findDefinition(_x){return _findDefinition.apply(this,arguments);}return findDefinition;}()/**
|
|
78
|
+
* @param {*} extension
|
|
79
|
+
*/},{key:"registerExtension",value:function registerExtension(extension){if(typeof extension.load!=='function'){throw new _LoadMethodNotFoundException["default"](extension.constructor.name);}this._extensions.push(extension);}/**
|
|
80
|
+
* @param {string} id
|
|
81
|
+
* @param {*} instance
|
|
82
|
+
*/},{key:"set",value:function set(id,instance){this._container.set(id,instance);}/**
|
|
83
|
+
* @param {string} id
|
|
84
|
+
*/},{key:"remove",value:function remove(id){this._container["delete"](id);}/**
|
|
85
|
+
* @param {string} id
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/},{key:"isSet",value:function isSet(id){return this._container.has(id);}}]);return ContainerBuilder;}();var _default=ContainerBuilder;exports["default"]=_default;
|