node-dependency-injection 3.0.0-alpha.9 → 3.0.0-beta.0
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/CHANGELOG-3.md +4 -1
- package/README.md +39 -3
- package/UPGRADE-3.0.md +3 -1
- package/dist/lib/Autowire.js +172 -99
- package/dist/lib/Compiler.js +169 -40
- package/dist/lib/CompilerPass/DecoratePass.js +57 -36
- package/dist/lib/CompilerPass/index.js +63 -17
- package/dist/lib/ContainerBuilder.js +27 -3
- package/dist/lib/InstanceManager.js +10 -2
- package/dist/lib/Loader/FileLoader.js +223 -59
- package/dist/lib/Loader/JsFileLoader.js +49 -15
- package/dist/lib/Loader/YamlFileLoader.js +70 -24
- package/package.json +2 -1
package/CHANGELOG-3.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
# [3.0.0] - 2022-05-
|
|
3
|
+
# [3.0.0] - 2022-05-19
|
|
4
4
|
### Changed
|
|
5
|
+
- File Loader load method is now Promised
|
|
6
|
+
- ContainerBuilder compile is now Promised
|
|
7
|
+
- Custom Compiler Pass process needs to be Promised
|
|
5
8
|
### Added
|
|
6
9
|
- Autowire support for TypeScript
|
|
7
10
|
- Get container service from a class instance
|
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@ The Node Dependency Injection component allows you to standardize and centralize
|
|
|
9
9
|
|
|
10
10
|
[](https://badge.fury.io/js/node-dependency-injection)
|
|
11
11
|
[](https://travis-ci.org/zazoomauro/node-dependency-injection)
|
|
12
|
-
[](https://david-dm.org/zazoomauro/node-dependency-injection)
|
|
13
|
-
[](https://david-dm.org/zazoomauro/node-dependency-injection#info=devDependencies)
|
|
14
12
|
[](https://codecov.io/gh/zazoomauro/node-dependency-injection)
|
|
15
13
|
[](https://codeclimate.com/github/zazoomauro/node-dependency-injection)
|
|
16
14
|
[](http://standardjs.com/)
|
|
@@ -68,6 +66,43 @@ And get services from your container
|
|
|
68
66
|
const mailer = container.get('service.mailer')
|
|
69
67
|
```
|
|
70
68
|
|
|
69
|
+
Autowire for TypeScript
|
|
70
|
+
------------
|
|
71
|
+
|
|
72
|
+
> WARNING: Is only available for node-ts or node with ts-node-register.
|
|
73
|
+
|
|
74
|
+
> WARNING: It doesn´t work with `babel` or `tsc` or any other transpilation/compilation process.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import {ContainerBuilder, Autowire} from 'node-dependency-injection'
|
|
78
|
+
|
|
79
|
+
const container = new ContainerBuilder(
|
|
80
|
+
true,
|
|
81
|
+
'/path/to/src'
|
|
82
|
+
)
|
|
83
|
+
const autowire = new Autowire(container)
|
|
84
|
+
await autowire.process()
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
or from yaml-json-js configuration
|
|
89
|
+
|
|
90
|
+
```yaml
|
|
91
|
+
# /path/to/services.yml
|
|
92
|
+
services:
|
|
93
|
+
_defaults:
|
|
94
|
+
autowire: true
|
|
95
|
+
rootDir: "/path/to/src"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can also get a service from a class definition
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import SomeService from '@src/service/SomeService'
|
|
102
|
+
|
|
103
|
+
container.get(SomeService)
|
|
104
|
+
```
|
|
105
|
+
|
|
71
106
|
|
|
72
107
|
Configuration files: how to load and use configuration files
|
|
73
108
|
------------
|
|
@@ -90,7 +125,7 @@ import {ContainerBuilder, YamlFileLoader} from 'node-dependency-injection'
|
|
|
90
125
|
|
|
91
126
|
let container = new ContainerBuilder()
|
|
92
127
|
let loader = new YamlFileLoader(container)
|
|
93
|
-
loader.load('/path/to/file.yml')
|
|
128
|
+
await loader.load('/path/to/file.yml')
|
|
94
129
|
```
|
|
95
130
|
|
|
96
131
|
And get services from your container easily
|
|
@@ -103,6 +138,7 @@ const mailer = container.get('service.mailer')
|
|
|
103
138
|
List of features
|
|
104
139
|
------------
|
|
105
140
|
|
|
141
|
+
- Autowire only for TypeScript
|
|
106
142
|
- Configuration files with JS, YAML or JSON.
|
|
107
143
|
- Multiple configuration files
|
|
108
144
|
- Custom relative service directory
|
package/UPGRADE-3.0.md
CHANGED
|
@@ -3,4 +3,6 @@ UPGRADE FROM 2.x to 3.x
|
|
|
3
3
|
|
|
4
4
|
### Removed deprecations
|
|
5
5
|
|
|
6
|
-
-
|
|
6
|
+
- FileLoader load method is now Promised. Add await to be sync
|
|
7
|
+
- ContainerBuilder compile method is now Promised. Add await to be sync
|
|
8
|
+
- All your custom Compiler Pass process method needs to be promised
|
package/dist/lib/Autowire.js
CHANGED
|
@@ -132,10 +132,6 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
132
132
|
var extension = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.ts';
|
|
133
133
|
return path.replace(/\//g, '_').replace(extension, '').replace('@', '_').concat("_".concat(type));
|
|
134
134
|
}
|
|
135
|
-
/**
|
|
136
|
-
* @returns {void}
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
135
|
}, {
|
|
140
136
|
key: "process",
|
|
141
137
|
value: function () {
|
|
@@ -147,40 +143,89 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
147
143
|
switch (_context2.prev = _context2.next) {
|
|
148
144
|
case 0:
|
|
149
145
|
_iterator2 = _createForOfIteratorHelper(this._walkSync(this._rootDirectory));
|
|
146
|
+
_context2.prev = 1;
|
|
147
|
+
|
|
148
|
+
_iterator2.s();
|
|
149
|
+
|
|
150
|
+
case 3:
|
|
151
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
152
|
+
_context2.next = 22;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
filePath = _step2.value;
|
|
157
|
+
parsedFile = _path["default"].parse(filePath);
|
|
150
158
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
parsedFile = _path["default"].parse(filePath);
|
|
155
|
-
|
|
156
|
-
if (parsedFile.ext === '.ts') {
|
|
157
|
-
_this$_getClassDeclar = this._getClassDeclaration(filePath), classDeclaration = _this$_getClassDeclar.classDeclaration, body = _this$_getClassDeclar.body;
|
|
158
|
-
Class = require(filePath)["default"];
|
|
159
|
-
|
|
160
|
-
if (Class && classDeclaration) {
|
|
161
|
-
definition = this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
162
|
-
|
|
163
|
-
if (definition) {
|
|
164
|
-
serviceId = this._getServiceIdFromPath(filePath, Class.name);
|
|
165
|
-
this.container.setDefinition(serviceId, definition);
|
|
166
|
-
|
|
167
|
-
this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} catch (err) {
|
|
173
|
-
_iterator2.e(err);
|
|
174
|
-
} finally {
|
|
175
|
-
_iterator2.f();
|
|
159
|
+
if (!(parsedFile.ext !== '.ts')) {
|
|
160
|
+
_context2.next = 8;
|
|
161
|
+
break;
|
|
176
162
|
}
|
|
177
163
|
|
|
178
|
-
|
|
164
|
+
return _context2.abrupt("continue", 20);
|
|
165
|
+
|
|
166
|
+
case 8:
|
|
167
|
+
_this$_getClassDeclar = this._getClassDeclaration(filePath), classDeclaration = _this$_getClassDeclar.classDeclaration, body = _this$_getClassDeclar.body;
|
|
168
|
+
|
|
169
|
+
if (classDeclaration) {
|
|
170
|
+
_context2.next = 11;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return _context2.abrupt("continue", 20);
|
|
175
|
+
|
|
176
|
+
case 11:
|
|
177
|
+
Class = require(filePath)["default"];
|
|
178
|
+
|
|
179
|
+
if (Class) {
|
|
180
|
+
_context2.next = 14;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return _context2.abrupt("continue", 20);
|
|
185
|
+
|
|
186
|
+
case 14:
|
|
187
|
+
definition = this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
188
|
+
|
|
189
|
+
if (definition) {
|
|
190
|
+
_context2.next = 17;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return _context2.abrupt("continue", 20);
|
|
195
|
+
|
|
196
|
+
case 17:
|
|
197
|
+
serviceId = this._getServiceIdFromPath(filePath, Class.name);
|
|
198
|
+
this.container.setDefinition(serviceId, definition);
|
|
199
|
+
|
|
200
|
+
this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
201
|
+
|
|
202
|
+
case 20:
|
|
203
|
+
_context2.next = 3;
|
|
204
|
+
break;
|
|
205
|
+
|
|
206
|
+
case 22:
|
|
207
|
+
_context2.next = 27;
|
|
208
|
+
break;
|
|
209
|
+
|
|
210
|
+
case 24:
|
|
211
|
+
_context2.prev = 24;
|
|
212
|
+
_context2.t0 = _context2["catch"](1);
|
|
213
|
+
|
|
214
|
+
_iterator2.e(_context2.t0);
|
|
215
|
+
|
|
216
|
+
case 27:
|
|
217
|
+
_context2.prev = 27;
|
|
218
|
+
|
|
219
|
+
_iterator2.f();
|
|
220
|
+
|
|
221
|
+
return _context2.finish(27);
|
|
222
|
+
|
|
223
|
+
case 30:
|
|
179
224
|
case "end":
|
|
180
225
|
return _context2.stop();
|
|
181
226
|
}
|
|
182
227
|
}
|
|
183
|
-
}, _callee, this);
|
|
228
|
+
}, _callee, this, [[1, 24, 27, 30]]);
|
|
184
229
|
}));
|
|
185
230
|
|
|
186
231
|
function process() {
|
|
@@ -208,113 +253,141 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
208
253
|
value: function _getDefinition(classDeclaration, body, parsedFile, ServiceClass) {
|
|
209
254
|
try {
|
|
210
255
|
var definition = new _Definition["default"](ServiceClass);
|
|
211
|
-
var constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
|
|
212
|
-
return method.key.name === 'constructor';
|
|
213
|
-
});
|
|
214
256
|
|
|
215
|
-
|
|
216
|
-
definition["abstract"] = true;
|
|
217
|
-
}
|
|
257
|
+
var constructorParams = this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
|
|
218
258
|
|
|
219
|
-
|
|
220
|
-
|
|
259
|
+
var _iterator3 = _createForOfIteratorHelper(constructorParams),
|
|
260
|
+
_step3;
|
|
221
261
|
|
|
222
|
-
|
|
262
|
+
try {
|
|
263
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
264
|
+
var parameterDeclaration = _step3.value;
|
|
265
|
+
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
223
266
|
|
|
224
|
-
|
|
225
|
-
|
|
267
|
+
var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
|
|
268
|
+
|
|
269
|
+
if (!argumentId) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
226
274
|
}
|
|
275
|
+
} catch (err) {
|
|
276
|
+
_iterator3.e(err);
|
|
277
|
+
} finally {
|
|
278
|
+
_iterator3.f();
|
|
227
279
|
}
|
|
228
280
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
_step3;
|
|
281
|
+
return definition;
|
|
282
|
+
} catch (e) {}
|
|
232
283
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "_getConstructorParamsByDefinition",
|
|
288
|
+
value: function _getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile) {
|
|
289
|
+
var constructorDeclaration = classDeclaration.declaration.body.body.find(function (method) {
|
|
290
|
+
return method.key.name === 'constructor';
|
|
291
|
+
});
|
|
237
292
|
|
|
238
|
-
|
|
293
|
+
if (classDeclaration.declaration["abstract"]) {
|
|
294
|
+
definition["abstract"] = true;
|
|
295
|
+
}
|
|
239
296
|
|
|
240
|
-
|
|
241
|
-
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
} catch (err) {
|
|
245
|
-
_iterator3.e(err);
|
|
246
|
-
} finally {
|
|
247
|
-
_iterator3.f();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
297
|
+
this._parentDefinition(classDeclaration, body, parsedFile, definition);
|
|
250
298
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
299
|
+
var constructorParams = constructorDeclaration ? constructorDeclaration.value.params : [];
|
|
300
|
+
return constructorParams;
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
303
|
+
key: "_parentDefinition",
|
|
304
|
+
value: function _parentDefinition(classDeclaration, body, parsedFile, definition) {
|
|
305
|
+
if (classDeclaration.declaration.superClass) {
|
|
306
|
+
var typeParent = classDeclaration.declaration.superClass.name;
|
|
307
|
+
|
|
308
|
+
var parentId = this._getIdentifierFromImports(typeParent, body, parsedFile);
|
|
309
|
+
|
|
310
|
+
if (parentId) {
|
|
311
|
+
definition.parent = parentId;
|
|
312
|
+
}
|
|
254
313
|
}
|
|
255
314
|
}
|
|
256
315
|
}, {
|
|
257
316
|
key: "_interfaceImplementations",
|
|
258
317
|
value: function _interfaceImplementations(classDeclaration, body, parsedFile, serviceId) {
|
|
259
|
-
|
|
260
|
-
var _iterator4 = _createForOfIteratorHelper(classDeclaration.declaration["implements"]),
|
|
261
|
-
_step4;
|
|
318
|
+
var _classDeclaration$dec;
|
|
262
319
|
|
|
263
|
-
|
|
264
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
265
|
-
var implement = _step4.value;
|
|
266
|
-
var interfaceType = implement.expression.name;
|
|
320
|
+
var implementations = (_classDeclaration$dec = classDeclaration.declaration["implements"]) !== null && _classDeclaration$dec !== void 0 ? _classDeclaration$dec : [];
|
|
267
321
|
|
|
268
|
-
|
|
322
|
+
var _iterator4 = _createForOfIteratorHelper(implementations),
|
|
323
|
+
_step4;
|
|
269
324
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
325
|
+
try {
|
|
326
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
327
|
+
var implement = _step4.value;
|
|
328
|
+
var interfaceType = implement.expression.name;
|
|
329
|
+
|
|
330
|
+
var aliasId = this._getIdentifierFromImports(interfaceType, body, parsedFile);
|
|
331
|
+
|
|
332
|
+
if (!aliasId || this.container.hasAlias(aliasId)) {
|
|
333
|
+
continue;
|
|
273
334
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
} finally {
|
|
277
|
-
_iterator4.f();
|
|
335
|
+
|
|
336
|
+
this.container.setAlias(aliasId, serviceId);
|
|
278
337
|
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_iterator4.e(err);
|
|
340
|
+
} finally {
|
|
341
|
+
_iterator4.f();
|
|
279
342
|
}
|
|
280
343
|
}
|
|
281
344
|
}, {
|
|
282
345
|
key: "_getIdentifierFromImports",
|
|
283
346
|
value: function _getIdentifierFromImports(type, body, parsedFile) {
|
|
284
347
|
try {
|
|
285
|
-
var
|
|
286
|
-
var relativeImportForImplement = body.find(function (declaration) {
|
|
287
|
-
if (declaration.specifiers) {
|
|
288
|
-
return declaration.specifiers.find(function (specifier) {
|
|
289
|
-
return specifier.local.name === type;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
348
|
+
var _this$_tsConfigPaths;
|
|
292
349
|
|
|
293
|
-
|
|
294
|
-
}).source.value;
|
|
350
|
+
var rootDir = parsedFile.dir;
|
|
295
351
|
|
|
296
|
-
|
|
297
|
-
for (var pathConfig in this._tsConfigPaths) {
|
|
298
|
-
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
299
|
-
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
300
|
-
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
352
|
+
var relativeImportForImplement = this._getRelativeImport(body, type);
|
|
301
353
|
|
|
302
|
-
|
|
303
|
-
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
354
|
+
var configPaths = (_this$_tsConfigPaths = this._tsConfigPaths) !== null && _this$_tsConfigPaths !== void 0 ? _this$_tsConfigPaths : [];
|
|
304
355
|
|
|
305
|
-
|
|
356
|
+
for (var pathConfig in configPaths) {
|
|
357
|
+
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
358
|
+
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
359
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
306
360
|
|
|
307
|
-
|
|
308
|
-
|
|
361
|
+
if (!relativeImportForImplement.includes(tsConfigPath)) {
|
|
362
|
+
continue;
|
|
309
363
|
}
|
|
364
|
+
|
|
365
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
366
|
+
|
|
367
|
+
var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
368
|
+
|
|
369
|
+
rootDir = parsedTsConfigPath.dir;
|
|
310
370
|
}
|
|
311
371
|
|
|
312
372
|
var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
313
373
|
|
|
314
374
|
return this._getServiceIdFromPath(absolutePathImportForImplement, type);
|
|
315
|
-
} catch (e) {
|
|
375
|
+
} catch (e) {}
|
|
376
|
+
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
}, {
|
|
380
|
+
key: "_getRelativeImport",
|
|
381
|
+
value: function _getRelativeImport(body, type) {
|
|
382
|
+
return body.find(function (declaration) {
|
|
383
|
+
if (declaration.specifiers) {
|
|
384
|
+
return declaration.specifiers.find(function (specifier) {
|
|
385
|
+
return specifier.local.name === type;
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
|
|
316
389
|
return null;
|
|
317
|
-
}
|
|
390
|
+
}).source.value;
|
|
318
391
|
}
|
|
319
392
|
}]);
|
|
320
393
|
return Autowire;
|
package/dist/lib/Compiler.js
CHANGED
|
@@ -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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
80
|
-
|
|
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
|
-
|
|
83
|
-
}
|
|
187
|
+
return _optimize;
|
|
188
|
+
}()
|
|
84
189
|
/**
|
|
85
190
|
* @private
|
|
86
191
|
*/
|
|
87
192
|
|
|
88
193
|
}, {
|
|
89
194
|
key: "_remove",
|
|
90
|
-
value: function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
}
|
|
224
|
+
return _remove;
|
|
225
|
+
}()
|
|
97
226
|
}]);
|
|
98
227
|
return Compiler;
|
|
99
228
|
}();
|