1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388 | 1
1
2
4
33
1
1
1
1
7
7
1
7
1
1
1
1
2
2
2
2
2
1
2
2
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
5
5
5
5
1
1
5
2
3
1
5
5
1
1
1
1
4
4
4
1
1
4
1
2
1
1
1
1
1
1
75
1
1
1
1
1
1
1
1
1
1
| System.register(['core-js'], function (_export) {
'use strict';
var core, TransientRegistration, SingletonRegistration, Resolver, Lazy, All, Optional, Parent, ClassActivator, FactoryActivator;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Iif (protoProps) defineProperties(Constructor.prototype, protoProps); Eif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _inherits(subClass, superClass) { Iif (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
return {
setters: [function (_coreJs) {
core = _coreJs['default'];
}],
execute: function () {
/**
* Used to allow functions/classes to indicate that they should be registered as transients with the container.
*
* @class TransientRegistration
* @constructor
* @param {Object} [key] The key to register as.
*/
TransientRegistration = (function () {
function TransientRegistration(key) {
_classCallCheck(this, TransientRegistration);
this.key = key;
}
/**
* Called by the container to register the annotated function/class as transient.
*
* @method register
* @param {Container} container The container to register with.
* @param {Object} key The key to register as.
* @param {Object} fn The function to register (target of the annotation).
*/
TransientRegistration.prototype.register = function register(container, key, fn) {
container.registerTransient(this.key || key, fn);
};
return TransientRegistration;
})();
_export('TransientRegistration', TransientRegistration);
/**
* Used to allow functions/classes to indicate that they should be registered as singletons with the container.
*
* @class SingletonRegistration
* @constructor
* @param {Object} [key] The key to register as.
*/
SingletonRegistration = (function () {
function SingletonRegistration(keyOrRegisterInChild) {
var registerInChild = arguments[1] === undefined ? false : arguments[1];
_classCallCheck(this, SingletonRegistration);
Iif (typeof keyOrRegisterInChild === 'boolean') {
this.registerInChild = keyOrRegisterInChild;
} else {
this.key = keyOrRegisterInChild;
this.registerInChild = registerInChild;
}
}
/**
* Called by the container to register the annotated function/class as a singleton.
*
* @method register
* @param {Container} container The container to register with.
* @param {Object} key The key to register as.
* @param {Object} fn The function to register (target of the annotation).
*/
SingletonRegistration.prototype.register = function register(container, key, fn) {
var destination = this.registerInChild ? container : container.root;
destination.registerSingleton(this.key || key, fn);
};
return SingletonRegistration;
})();
_export('SingletonRegistration', SingletonRegistration);
/**
* An abstract resolver used to allow functions/classes to specify custom dependency resolution logic.
*
* @class Resolver
* @constructor
*/
Resolver = (function () {
function Resolver() {
_classCallCheck(this, Resolver);
}
/**
* Called by the container to allow custom resolution of dependencies for a function/class.
*
* @method get
* @param {Container} container The container to resolve from.
* @return {Object} Returns the resolved object.
*/
Resolver.prototype.get = function get(container) {
throw new Error('A custom Resolver must implement get(container) and return the resolved instance(s).');
};
return Resolver;
})();
_export('Resolver', Resolver);
/**
* Used to allow functions/classes to specify lazy resolution logic.
*
* @class Lazy
* @constructor
* @extends Resolver
* @param {Object} key The key to lazily resolve.
*/
Lazy = (function (_Resolver) {
function Lazy(key) {
_classCallCheck(this, Lazy);
_Resolver.call(this);
this.key = key;
}
_inherits(Lazy, _Resolver);
/**
* Called by the container to lazily resolve the dependency into a lazy locator function.
*
* @method get
* @param {Container} container The container to resolve from.
* @return {Function} Returns a function which can be invoked at a later time to obtain the actual dependency.
*/
Lazy.prototype.get = function get(container) {
var _this = this;
return function () {
return container.get(_this.key);
};
};
/**
* Creates a Lazy Resolver for the supplied key.
*
* @method of
* @static
* @param {Object} key The key to lazily resolve.
* @return {Lazy} Returns an insance of Lazy for the key.
*/
Lazy.of = function of(key) {
return new Lazy(key);
};
return Lazy;
})(Resolver);
_export('Lazy', Lazy);
/**
* Used to allow functions/classes to specify resolution of all matches to a key.
*
* @class All
* @constructor
* @extends Resolver
* @param {Object} key The key to lazily resolve all matches for.
*/
All = (function (_Resolver2) {
function All(key) {
_classCallCheck(this, All);
_Resolver2.call(this);
this.key = key;
}
_inherits(All, _Resolver2);
/**
* Called by the container to resolve all matching dependencies as an array of instances.
*
* @method get
* @param {Container} container The container to resolve from.
* @return {Object[]} Returns an array of all matching instances.
*/
All.prototype.get = function get(container) {
return container.getAll(this.key);
};
/**
* Creates an All Resolver for the supplied key.
*
* @method of
* @static
* @param {Object} key The key to resolve all instances for.
* @return {All} Returns an insance of All for the key.
*/
All.of = function of(key) {
return new All(key);
};
return All;
})(Resolver);
_export('All', All);
/**
* Used to allow functions/classes to specify an optional dependency, which will be resolved only if already registred with the container.
*
* @class Optional
* @constructor
* @extends Resolver
* @param {Object} key The key to optionally resolve for.
* @param {Boolean} [checkParent=false] Indicates whether or not the parent container hierarchy should be checked.
*/
Optional = (function (_Resolver3) {
function Optional(key) {
var checkParent = arguments[1] === undefined ? false : arguments[1];
_classCallCheck(this, Optional);
_Resolver3.call(this);
this.key = key;
this.checkParent = checkParent;
}
_inherits(Optional, _Resolver3);
/**
* Called by the container to provide optional resolution of the key.
*
* @method get
* @param {Container} container The container to resolve from.
* @return {Object} Returns the instance if found; otherwise null.
*/
Optional.prototype.get = function get(container) {
if (container.hasHandler(this.key, this.checkParent)) {
return container.get(this.key);
}
return null;
};
/**
* Creates an Optional Resolver for the supplied key.
*
* @method of
* @static
* @param {Object} key The key to optionally resolve for.
* @param {Boolean} [checkParent=false] Indicates whether or not the parent container hierarchy should be checked.
* @return {Optional} Returns an insance of Optional for the key.
*/
Optional.of = function of(key) {
var checkParent = arguments[1] === undefined ? false : arguments[1];
return new Optional(key, checkParent);
};
return Optional;
})(Resolver);
_export('Optional', Optional);
/**
* Used to inject the dependency from the parent container instead of the current one.
*
* @class Parent
* @constructor
* @extends Resolver
* @param {Object} key The key to resolve from the parent container.
*/
Parent = (function (_Resolver4) {
function Parent(key) {
_classCallCheck(this, Parent);
_Resolver4.call(this);
this.key = key;
}
_inherits(Parent, _Resolver4);
/**
* Called by the container to load the dependency from the parent container
*
* @method get
* @param {Container} container The container to resolve the parent from.
* @return {Function} Returns the matching instance from the parent container
*/
Parent.prototype.get = function get(container) {
return container.parent ? container.parent.get(this.key) : null;
};
/**
* Creates a Parent Resolver for the supplied key.
*
* @method of
* @static
* @param {Object} key The key to resolve.
* @return {Parent} Returns an insance of Parent for the key.
*/
Parent.of = function of(key) {
return new Parent(key);
};
return Parent;
})(Resolver);
_export('Parent', Parent);
/**
* Used to instantiate a class.
*
* @class ClassActivator
* @constructor
*/
ClassActivator = (function () {
function ClassActivator() {
_classCallCheck(this, ClassActivator);
}
ClassActivator.prototype.invoke = function invoke(fn, args) {
return Reflect.construct(fn, args);
};
_createClass(ClassActivator, null, [{
key: 'instance',
value: new ClassActivator(),
enumerable: true
}]);
return ClassActivator;
})();
_export('ClassActivator', ClassActivator);
/**
* Used to invoke a factory method.
*
* @class FactoryActivator
* @constructor
*/
FactoryActivator = (function () {
function FactoryActivator() {
_classCallCheck(this, FactoryActivator);
}
FactoryActivator.prototype.invoke = function invoke(fn, args) {
return fn.apply(undefined, args);
};
_createClass(FactoryActivator, null, [{
key: 'instance',
value: new FactoryActivator(),
enumerable: true
}]);
return FactoryActivator;
})();
_export('FactoryActivator', FactoryActivator);
}
};
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9FaXNlbmJlcmdFZmZlY3QvRG9jdW1lbnRzL0dpdEh1Yi9UaGUgRHVyYW5kYWwgUHJvamVjdC9hdXJlbGlhL2RlcGVuZGVuY3ktaW5qZWN0aW9uL3NyYy9tZXRhZGF0YS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7WUFTYSxxQkFBcUIsRUF5QnJCLHFCQUFxQixFQThCckIsUUFBUSxFQXFCUixJQUFJLEVBd0NKLEdBQUcsRUF1Q0gsUUFBUSxFQTZDUixNQUFNLEVBc0NOLGNBQWMsRUFjZCxnQkFBZ0I7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUE1UGhCLDJCQUFxQjtBQUNyQixpQkFEQSxxQk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