node-dependency-injection 3.0.0-alpha.7 → 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 +171 -92
- 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 +3 -1
- package/tsconfig.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
|
@@ -19,6 +19,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
19
19
|
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
21
|
|
|
22
|
+
var _json = _interopRequireDefault(require("json5"));
|
|
23
|
+
|
|
22
24
|
var _typescriptEstree = require("@typescript-eslint/typescript-estree");
|
|
23
25
|
|
|
24
26
|
var _Definition = _interopRequireDefault(require("./Definition"));
|
|
@@ -41,7 +43,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
41
43
|
|
|
42
44
|
try {
|
|
43
45
|
this._tsConfigFullPath = tsConfigFullPath || _path["default"].join(process.cwd(), 'tsconfig.json');
|
|
44
|
-
this._tsConfigPaths =
|
|
46
|
+
this._tsConfigPaths = _json["default"].parse(_fs["default"].readFileSync(this._tsConfigFullPath, 'utf-8')).compilerOptions.paths;
|
|
45
47
|
} catch (e) {
|
|
46
48
|
this._tsConfigPaths = null;
|
|
47
49
|
}
|
|
@@ -130,10 +132,6 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
130
132
|
var extension = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.ts';
|
|
131
133
|
return path.replace(/\//g, '_').replace(extension, '').replace('@', '_').concat("_".concat(type));
|
|
132
134
|
}
|
|
133
|
-
/**
|
|
134
|
-
* @returns {void}
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
135
|
}, {
|
|
138
136
|
key: "process",
|
|
139
137
|
value: function () {
|
|
@@ -145,37 +143,89 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
145
143
|
switch (_context2.prev = _context2.next) {
|
|
146
144
|
case 0:
|
|
147
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);
|
|
148
158
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
parsedFile = _path["default"].parse(filePath);
|
|
153
|
-
|
|
154
|
-
if (parsedFile.ext === '.ts') {
|
|
155
|
-
_this$_getClassDeclar = this._getClassDeclaration(filePath), classDeclaration = _this$_getClassDeclar.classDeclaration, body = _this$_getClassDeclar.body;
|
|
156
|
-
Class = require(filePath)["default"];
|
|
157
|
-
|
|
158
|
-
if (Class && classDeclaration) {
|
|
159
|
-
definition = this._getDefinition(classDeclaration, body, parsedFile, Class);
|
|
160
|
-
serviceId = this._getServiceIdFromPath(filePath, Class.name);
|
|
161
|
-
this.container.setDefinition(serviceId, definition);
|
|
162
|
-
|
|
163
|
-
this._interfaceImplementations(classDeclaration, body, parsedFile, serviceId);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
} catch (err) {
|
|
168
|
-
_iterator2.e(err);
|
|
169
|
-
} finally {
|
|
170
|
-
_iterator2.f();
|
|
159
|
+
if (!(parsedFile.ext !== '.ts')) {
|
|
160
|
+
_context2.next = 8;
|
|
161
|
+
break;
|
|
171
162
|
}
|
|
172
163
|
|
|
173
|
-
|
|
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:
|
|
174
224
|
case "end":
|
|
175
225
|
return _context2.stop();
|
|
176
226
|
}
|
|
177
227
|
}
|
|
178
|
-
}, _callee, this);
|
|
228
|
+
}, _callee, this, [[1, 24, 27, 30]]);
|
|
179
229
|
}));
|
|
180
230
|
|
|
181
231
|
function process() {
|
|
@@ -201,114 +251,143 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
201
251
|
}, {
|
|
202
252
|
key: "_getDefinition",
|
|
203
253
|
value: function _getDefinition(classDeclaration, body, parsedFile, ServiceClass) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return method.key.name === 'constructor';
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
if (classDeclaration.declaration["abstract"]) {
|
|
210
|
-
definition["abstract"] = true;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (classDeclaration.declaration.superClass) {
|
|
214
|
-
var typeParent = classDeclaration.declaration.superClass.name;
|
|
215
|
-
|
|
216
|
-
var parentId = this._getIdentifierFromImports(typeParent, body, parsedFile);
|
|
254
|
+
try {
|
|
255
|
+
var definition = new _Definition["default"](ServiceClass);
|
|
217
256
|
|
|
218
|
-
|
|
219
|
-
definition.parent = parentId;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
257
|
+
var constructorParams = this._getConstructorParamsByDefinition(definition, classDeclaration, body, parsedFile);
|
|
222
258
|
|
|
223
|
-
|
|
224
|
-
var _iterator3 = _createForOfIteratorHelper(constructorDeclaration.value.params),
|
|
259
|
+
var _iterator3 = _createForOfIteratorHelper(constructorParams),
|
|
225
260
|
_step3;
|
|
226
261
|
|
|
227
262
|
try {
|
|
228
263
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
229
264
|
var parameterDeclaration = _step3.value;
|
|
265
|
+
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
230
266
|
|
|
231
|
-
|
|
232
|
-
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
267
|
+
var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
|
|
233
268
|
|
|
234
|
-
|
|
269
|
+
if (!argumentId) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
235
272
|
|
|
236
|
-
|
|
237
|
-
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
238
|
-
}
|
|
239
|
-
} catch (e) {}
|
|
273
|
+
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
240
274
|
}
|
|
241
275
|
} catch (err) {
|
|
242
276
|
_iterator3.e(err);
|
|
243
277
|
} finally {
|
|
244
278
|
_iterator3.f();
|
|
245
279
|
}
|
|
280
|
+
|
|
281
|
+
return definition;
|
|
282
|
+
} catch (e) {}
|
|
283
|
+
|
|
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
|
+
});
|
|
292
|
+
|
|
293
|
+
if (classDeclaration.declaration["abstract"]) {
|
|
294
|
+
definition["abstract"] = true;
|
|
246
295
|
}
|
|
247
296
|
|
|
248
|
-
|
|
297
|
+
this._parentDefinition(classDeclaration, body, parsedFile, definition);
|
|
298
|
+
|
|
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
|
+
}
|
|
313
|
+
}
|
|
249
314
|
}
|
|
250
315
|
}, {
|
|
251
316
|
key: "_interfaceImplementations",
|
|
252
317
|
value: function _interfaceImplementations(classDeclaration, body, parsedFile, serviceId) {
|
|
253
|
-
|
|
254
|
-
var _iterator4 = _createForOfIteratorHelper(classDeclaration.declaration["implements"]),
|
|
255
|
-
_step4;
|
|
318
|
+
var _classDeclaration$dec;
|
|
256
319
|
|
|
257
|
-
|
|
258
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
259
|
-
var implement = _step4.value;
|
|
260
|
-
var interfaceType = implement.expression.name;
|
|
320
|
+
var implementations = (_classDeclaration$dec = classDeclaration.declaration["implements"]) !== null && _classDeclaration$dec !== void 0 ? _classDeclaration$dec : [];
|
|
261
321
|
|
|
262
|
-
|
|
322
|
+
var _iterator4 = _createForOfIteratorHelper(implementations),
|
|
323
|
+
_step4;
|
|
263
324
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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;
|
|
267
334
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} finally {
|
|
271
|
-
_iterator4.f();
|
|
335
|
+
|
|
336
|
+
this.container.setAlias(aliasId, serviceId);
|
|
272
337
|
}
|
|
338
|
+
} catch (err) {
|
|
339
|
+
_iterator4.e(err);
|
|
340
|
+
} finally {
|
|
341
|
+
_iterator4.f();
|
|
273
342
|
}
|
|
274
343
|
}
|
|
275
344
|
}, {
|
|
276
345
|
key: "_getIdentifierFromImports",
|
|
277
346
|
value: function _getIdentifierFromImports(type, body, parsedFile) {
|
|
278
347
|
try {
|
|
279
|
-
var
|
|
280
|
-
var relativeImportForImplement = body.find(function (declaration) {
|
|
281
|
-
if (declaration.specifiers) {
|
|
282
|
-
return declaration.specifiers.find(function (specifier) {
|
|
283
|
-
return specifier.local.name === type;
|
|
284
|
-
});
|
|
285
|
-
}
|
|
348
|
+
var _this$_tsConfigPaths;
|
|
286
349
|
|
|
287
|
-
|
|
288
|
-
}).source.value;
|
|
350
|
+
var rootDir = parsedFile.dir;
|
|
289
351
|
|
|
290
|
-
|
|
291
|
-
for (var pathConfig in this._tsConfigPaths) {
|
|
292
|
-
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
293
|
-
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
294
|
-
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
352
|
+
var relativeImportForImplement = this._getRelativeImport(body, type);
|
|
295
353
|
|
|
296
|
-
|
|
297
|
-
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
354
|
+
var configPaths = (_this$_tsConfigPaths = this._tsConfigPaths) !== null && _this$_tsConfigPaths !== void 0 ? _this$_tsConfigPaths : [];
|
|
298
355
|
|
|
299
|
-
|
|
356
|
+
for (var pathConfig in configPaths) {
|
|
357
|
+
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
358
|
+
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
359
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
300
360
|
|
|
301
|
-
|
|
302
|
-
|
|
361
|
+
if (!relativeImportForImplement.includes(tsConfigPath)) {
|
|
362
|
+
continue;
|
|
303
363
|
}
|
|
364
|
+
|
|
365
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
366
|
+
|
|
367
|
+
var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
368
|
+
|
|
369
|
+
rootDir = parsedTsConfigPath.dir;
|
|
304
370
|
}
|
|
305
371
|
|
|
306
372
|
var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
307
373
|
|
|
308
374
|
return this._getServiceIdFromPath(absolutePathImportForImplement, type);
|
|
309
|
-
} 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
|
+
|
|
310
389
|
return null;
|
|
311
|
-
}
|
|
390
|
+
}).source.value;
|
|
312
391
|
}
|
|
313
392
|
}]);
|
|
314
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
|
}();
|