@orion-js/services 3.11.8 → 4.0.0-alpha.2

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/index.cjs ADDED
@@ -0,0 +1,1325 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
19
+ var __toCommonJS = (from) => {
20
+ var entry = __moduleCache.get(from), desc;
21
+ if (entry)
22
+ return entry;
23
+ entry = __defProp({}, "__esModule", { value: true });
24
+ if (from && typeof from === "object" || typeof from === "function")
25
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
+ get: () => from[key],
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ }));
29
+ __moduleCache.set(from, entry);
30
+ return entry;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, {
36
+ get: all[name],
37
+ enumerable: true,
38
+ configurable: true,
39
+ set: (newValue) => all[name] = () => newValue
40
+ });
41
+ };
42
+
43
+ // ../../node_modules/typedi/cjs/token.class.js
44
+ var require_token_class = __commonJS((exports2) => {
45
+ Object.defineProperty(exports2, "__esModule", { value: true });
46
+ exports2.Token = undefined;
47
+
48
+ class Token {
49
+ constructor(name) {
50
+ this.name = name;
51
+ }
52
+ }
53
+ exports2.Token = Token;
54
+ });
55
+
56
+ // ../../node_modules/typedi/cjs/error/service-not-found.error.js
57
+ var require_service_not_found_error = __commonJS((exports2) => {
58
+ Object.defineProperty(exports2, "__esModule", { value: true });
59
+ exports2.ServiceNotFoundError = undefined;
60
+ var token_class_1 = require_token_class();
61
+
62
+ class ServiceNotFoundError extends Error {
63
+ constructor(identifier) {
64
+ var _a, _b;
65
+ super();
66
+ this.name = "ServiceNotFoundError";
67
+ this.normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
68
+ if (typeof identifier === "string") {
69
+ this.normalizedIdentifier = identifier;
70
+ } else if (identifier instanceof token_class_1.Token) {
71
+ this.normalizedIdentifier = `Token<${identifier.name || "UNSET_NAME"}>`;
72
+ } else if (identifier && (identifier.name || ((_a = identifier.prototype) === null || _a === undefined ? undefined : _a.name))) {
73
+ this.normalizedIdentifier = `MaybeConstructable<${identifier.name}>` || `MaybeConstructable<${(_b = identifier.prototype) === null || _b === undefined ? undefined : _b.name}>`;
74
+ }
75
+ }
76
+ get message() {
77
+ return `Service with "${this.normalizedIdentifier}" identifier was not found in the container. ` + `Register it before usage via explicitly calling the "Container.set" function or using the "@Service()" decorator.`;
78
+ }
79
+ }
80
+ exports2.ServiceNotFoundError = ServiceNotFoundError;
81
+ });
82
+
83
+ // ../../node_modules/typedi/cjs/error/cannot-instantiate-value.error.js
84
+ var require_cannot_instantiate_value_error = __commonJS((exports2) => {
85
+ Object.defineProperty(exports2, "__esModule", { value: true });
86
+ exports2.CannotInstantiateValueError = undefined;
87
+ var token_class_1 = require_token_class();
88
+
89
+ class CannotInstantiateValueError extends Error {
90
+ constructor(identifier) {
91
+ var _a, _b;
92
+ super();
93
+ this.name = "CannotInstantiateValueError";
94
+ this.normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
95
+ if (typeof identifier === "string") {
96
+ this.normalizedIdentifier = identifier;
97
+ } else if (identifier instanceof token_class_1.Token) {
98
+ this.normalizedIdentifier = `Token<${identifier.name || "UNSET_NAME"}>`;
99
+ } else if (identifier && (identifier.name || ((_a = identifier.prototype) === null || _a === undefined ? undefined : _a.name))) {
100
+ this.normalizedIdentifier = `MaybeConstructable<${identifier.name}>` || `MaybeConstructable<${(_b = identifier.prototype) === null || _b === undefined ? undefined : _b.name}>`;
101
+ }
102
+ }
103
+ get message() {
104
+ return `Cannot instantiate the requested value for the "${this.normalizedIdentifier}" identifier. ` + `The related metadata doesn't contain a factory or a type to instantiate.`;
105
+ }
106
+ }
107
+ exports2.CannotInstantiateValueError = CannotInstantiateValueError;
108
+ });
109
+
110
+ // ../../node_modules/typedi/cjs/empty.const.js
111
+ var require_empty_const = __commonJS((exports2) => {
112
+ Object.defineProperty(exports2, "__esModule", { value: true });
113
+ exports2.EMPTY_VALUE = undefined;
114
+ exports2.EMPTY_VALUE = Symbol("EMPTY_VALUE");
115
+ });
116
+
117
+ // ../../node_modules/typedi/cjs/container-instance.class.js
118
+ var require_container_instance_class = __commonJS((exports2) => {
119
+ Object.defineProperty(exports2, "__esModule", { value: true });
120
+ exports2.ContainerInstance = undefined;
121
+ var container_class_1 = require_container_class();
122
+ var service_not_found_error_1 = require_service_not_found_error();
123
+ var cannot_instantiate_value_error_1 = require_cannot_instantiate_value_error();
124
+ var token_class_1 = require_token_class();
125
+ var empty_const_1 = require_empty_const();
126
+
127
+ class ContainerInstance {
128
+ constructor(id) {
129
+ this.services = [];
130
+ this.id = id;
131
+ }
132
+ has(identifier) {
133
+ return !!this.findService(identifier);
134
+ }
135
+ get(identifier) {
136
+ const globalContainer = container_class_1.Container.of(undefined);
137
+ const globalService = globalContainer.findService(identifier);
138
+ const scopedService = this.findService(identifier);
139
+ if (globalService && globalService.global === true)
140
+ return this.getServiceValue(globalService);
141
+ if (scopedService)
142
+ return this.getServiceValue(scopedService);
143
+ if (globalService && this !== globalContainer) {
144
+ const clonedService = { ...globalService };
145
+ clonedService.value = empty_const_1.EMPTY_VALUE;
146
+ this.set(clonedService);
147
+ const value = this.getServiceValue(clonedService);
148
+ this.set({ ...clonedService, value });
149
+ return value;
150
+ }
151
+ if (globalService)
152
+ return this.getServiceValue(globalService);
153
+ throw new service_not_found_error_1.ServiceNotFoundError(identifier);
154
+ }
155
+ getMany(identifier) {
156
+ return this.findAllServices(identifier).map((service) => this.getServiceValue(service));
157
+ }
158
+ set(identifierOrServiceMetadata, value) {
159
+ if (identifierOrServiceMetadata instanceof Array) {
160
+ identifierOrServiceMetadata.forEach((data) => this.set(data));
161
+ return this;
162
+ }
163
+ if (typeof identifierOrServiceMetadata === "string" || identifierOrServiceMetadata instanceof token_class_1.Token) {
164
+ return this.set({
165
+ id: identifierOrServiceMetadata,
166
+ type: null,
167
+ value,
168
+ factory: undefined,
169
+ global: false,
170
+ multiple: false,
171
+ eager: false,
172
+ transient: false
173
+ });
174
+ }
175
+ if (typeof identifierOrServiceMetadata === "function") {
176
+ return this.set({
177
+ id: identifierOrServiceMetadata,
178
+ type: identifierOrServiceMetadata,
179
+ value,
180
+ factory: undefined,
181
+ global: false,
182
+ multiple: false,
183
+ eager: false,
184
+ transient: false
185
+ });
186
+ }
187
+ const newService = {
188
+ id: new token_class_1.Token("UNREACHABLE"),
189
+ type: null,
190
+ factory: undefined,
191
+ value: empty_const_1.EMPTY_VALUE,
192
+ global: false,
193
+ multiple: false,
194
+ eager: false,
195
+ transient: false,
196
+ ...identifierOrServiceMetadata
197
+ };
198
+ const service = this.findService(newService.id);
199
+ if (service && service.multiple !== true) {
200
+ Object.assign(service, newService);
201
+ } else {
202
+ this.services.push(newService);
203
+ }
204
+ if (newService.eager) {
205
+ this.get(newService.id);
206
+ }
207
+ return this;
208
+ }
209
+ remove(identifierOrIdentifierArray) {
210
+ if (Array.isArray(identifierOrIdentifierArray)) {
211
+ identifierOrIdentifierArray.forEach((id) => this.remove(id));
212
+ } else {
213
+ this.services = this.services.filter((service) => {
214
+ if (service.id === identifierOrIdentifierArray) {
215
+ this.destroyServiceInstance(service);
216
+ return false;
217
+ }
218
+ return true;
219
+ });
220
+ }
221
+ return this;
222
+ }
223
+ reset(options = { strategy: "resetValue" }) {
224
+ switch (options.strategy) {
225
+ case "resetValue":
226
+ this.services.forEach((service) => this.destroyServiceInstance(service));
227
+ break;
228
+ case "resetServices":
229
+ this.services.forEach((service) => this.destroyServiceInstance(service));
230
+ this.services = [];
231
+ break;
232
+ default:
233
+ throw new Error("Received invalid reset strategy.");
234
+ }
235
+ return this;
236
+ }
237
+ findAllServices(identifier) {
238
+ return this.services.filter((service) => service.id === identifier);
239
+ }
240
+ findService(identifier) {
241
+ return this.services.find((service) => service.id === identifier);
242
+ }
243
+ getServiceValue(serviceMetadata) {
244
+ var _a;
245
+ let value = empty_const_1.EMPTY_VALUE;
246
+ if (serviceMetadata.value !== empty_const_1.EMPTY_VALUE) {
247
+ return serviceMetadata.value;
248
+ }
249
+ if (!serviceMetadata.factory && !serviceMetadata.type) {
250
+ throw new cannot_instantiate_value_error_1.CannotInstantiateValueError(serviceMetadata.id);
251
+ }
252
+ if (serviceMetadata.factory) {
253
+ if (serviceMetadata.factory instanceof Array) {
254
+ let factoryInstance;
255
+ try {
256
+ factoryInstance = this.get(serviceMetadata.factory[0]);
257
+ } catch (error) {
258
+ if (error instanceof service_not_found_error_1.ServiceNotFoundError) {
259
+ factoryInstance = new serviceMetadata.factory[0];
260
+ } else {
261
+ throw error;
262
+ }
263
+ }
264
+ value = factoryInstance[serviceMetadata.factory[1]](this, serviceMetadata.id);
265
+ } else {
266
+ value = serviceMetadata.factory(this, serviceMetadata.id);
267
+ }
268
+ }
269
+ if (!serviceMetadata.factory && serviceMetadata.type) {
270
+ const constructableTargetType = serviceMetadata.type;
271
+ const paramTypes = ((_a = Reflect) === null || _a === undefined ? undefined : _a.getMetadata("design:paramtypes", constructableTargetType)) || [];
272
+ const params = this.initializeParams(constructableTargetType, paramTypes);
273
+ params.push(this);
274
+ value = new constructableTargetType(...params);
275
+ }
276
+ if (!serviceMetadata.transient && value !== empty_const_1.EMPTY_VALUE) {
277
+ serviceMetadata.value = value;
278
+ }
279
+ if (value === empty_const_1.EMPTY_VALUE) {
280
+ throw new cannot_instantiate_value_error_1.CannotInstantiateValueError(serviceMetadata.id);
281
+ }
282
+ if (serviceMetadata.type) {
283
+ this.applyPropertyHandlers(serviceMetadata.type, value);
284
+ }
285
+ return value;
286
+ }
287
+ initializeParams(target, paramTypes) {
288
+ return paramTypes.map((paramType, index) => {
289
+ const paramHandler = container_class_1.Container.handlers.find((handler) => {
290
+ return (handler.object === target || handler.object === Object.getPrototypeOf(target)) && handler.index === index;
291
+ });
292
+ if (paramHandler)
293
+ return paramHandler.value(this);
294
+ if (paramType && paramType.name && !this.isPrimitiveParamType(paramType.name)) {
295
+ return this.get(paramType);
296
+ }
297
+ return;
298
+ });
299
+ }
300
+ isPrimitiveParamType(paramTypeName) {
301
+ return ["string", "boolean", "number", "object"].includes(paramTypeName.toLowerCase());
302
+ }
303
+ applyPropertyHandlers(target, instance) {
304
+ container_class_1.Container.handlers.forEach((handler) => {
305
+ if (typeof handler.index === "number")
306
+ return;
307
+ if (handler.object.constructor !== target && !(target.prototype instanceof handler.object.constructor))
308
+ return;
309
+ if (handler.propertyName) {
310
+ instance[handler.propertyName] = handler.value(this);
311
+ }
312
+ });
313
+ }
314
+ destroyServiceInstance(serviceMetadata, force = false) {
315
+ const shouldResetValue = force || !!serviceMetadata.type || !!serviceMetadata.factory;
316
+ if (shouldResetValue) {
317
+ if (typeof (serviceMetadata === null || serviceMetadata === undefined ? undefined : serviceMetadata.value)["destroy"] === "function") {
318
+ try {
319
+ serviceMetadata.value.destroy();
320
+ } catch (error) {
321
+ }
322
+ }
323
+ serviceMetadata.value = empty_const_1.EMPTY_VALUE;
324
+ }
325
+ }
326
+ }
327
+ exports2.ContainerInstance = ContainerInstance;
328
+ });
329
+
330
+ // ../../node_modules/typedi/cjs/container.class.js
331
+ var require_container_class = __commonJS((exports2) => {
332
+ Object.defineProperty(exports2, "__esModule", { value: true });
333
+ exports2.Container = undefined;
334
+ var container_instance_class_1 = require_container_instance_class();
335
+
336
+ class Container {
337
+ static of(containerId = "default") {
338
+ if (containerId === "default")
339
+ return this.globalInstance;
340
+ let container = this.instances.find((instance) => instance.id === containerId);
341
+ if (!container) {
342
+ container = new container_instance_class_1.ContainerInstance(containerId);
343
+ this.instances.push(container);
344
+ }
345
+ return container;
346
+ }
347
+ static has(identifier) {
348
+ return this.globalInstance.has(identifier);
349
+ }
350
+ static get(identifier) {
351
+ return this.globalInstance.get(identifier);
352
+ }
353
+ static getMany(id) {
354
+ return this.globalInstance.getMany(id);
355
+ }
356
+ static set(identifierOrServiceMetadata, value) {
357
+ this.globalInstance.set(identifierOrServiceMetadata, value);
358
+ return this;
359
+ }
360
+ static remove(identifierOrIdentifierArray) {
361
+ this.globalInstance.remove(identifierOrIdentifierArray);
362
+ return this;
363
+ }
364
+ static reset(containerId = "default") {
365
+ if (containerId == "default") {
366
+ this.globalInstance.reset();
367
+ this.instances.forEach((instance) => instance.reset());
368
+ } else {
369
+ const instance = this.instances.find((instance2) => instance2.id === containerId);
370
+ if (instance) {
371
+ instance.reset();
372
+ this.instances.splice(this.instances.indexOf(instance), 1);
373
+ }
374
+ }
375
+ return this;
376
+ }
377
+ static registerHandler(handler) {
378
+ this.handlers.push(handler);
379
+ return this;
380
+ }
381
+ static import(services) {
382
+ return this;
383
+ }
384
+ }
385
+ exports2.Container = Container;
386
+ Container.handlers = [];
387
+ Container.globalInstance = new container_instance_class_1.ContainerInstance("default");
388
+ Container.instances = [];
389
+ });
390
+
391
+ // ../../node_modules/typedi/cjs/error/cannot-inject-value.error.js
392
+ var require_cannot_inject_value_error = __commonJS((exports2) => {
393
+ Object.defineProperty(exports2, "__esModule", { value: true });
394
+ exports2.CannotInjectValueError = undefined;
395
+
396
+ class CannotInjectValueError extends Error {
397
+ constructor(target, propertyName) {
398
+ super();
399
+ this.target = target;
400
+ this.propertyName = propertyName;
401
+ this.name = "CannotInjectValueError";
402
+ }
403
+ get message() {
404
+ return `Cannot inject value into "${this.target.constructor.name}.${this.propertyName}". ` + `Please make sure you setup reflect-metadata properly and you don't use interfaces without service tokens as injection value.`;
405
+ }
406
+ }
407
+ exports2.CannotInjectValueError = CannotInjectValueError;
408
+ });
409
+
410
+ // ../../node_modules/typedi/cjs/utils/resolve-to-type-wrapper.util.js
411
+ var require_resolve_to_type_wrapper_util = __commonJS((exports2) => {
412
+ Object.defineProperty(exports2, "__esModule", { value: true });
413
+ exports2.resolveToTypeWrapper = undefined;
414
+ var token_class_1 = require_token_class();
415
+ function resolveToTypeWrapper(typeOrIdentifier, target, propertyName, index) {
416
+ let typeWrapper;
417
+ if (typeOrIdentifier && typeof typeOrIdentifier === "string" || typeOrIdentifier instanceof token_class_1.Token) {
418
+ typeWrapper = { eagerType: typeOrIdentifier, lazyType: () => typeOrIdentifier };
419
+ }
420
+ if (typeOrIdentifier && typeof typeOrIdentifier === "function") {
421
+ typeWrapper = { eagerType: null, lazyType: () => typeOrIdentifier() };
422
+ }
423
+ if (!typeOrIdentifier && propertyName) {
424
+ const identifier = Reflect.getMetadata("design:type", target, propertyName);
425
+ typeWrapper = { eagerType: identifier, lazyType: () => identifier };
426
+ }
427
+ if (!typeOrIdentifier && typeof index == "number" && Number.isInteger(index)) {
428
+ const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyName);
429
+ const identifier = paramTypes === null || paramTypes === undefined ? undefined : paramTypes[index];
430
+ typeWrapper = { eagerType: identifier, lazyType: () => identifier };
431
+ }
432
+ return typeWrapper;
433
+ }
434
+ exports2.resolveToTypeWrapper = resolveToTypeWrapper;
435
+ });
436
+
437
+ // ../../node_modules/typedi/cjs/decorators/inject-many.decorator.js
438
+ var require_inject_many_decorator = __commonJS((exports2) => {
439
+ Object.defineProperty(exports2, "__esModule", { value: true });
440
+ exports2.InjectMany = undefined;
441
+ var container_class_1 = require_container_class();
442
+ var cannot_inject_value_error_1 = require_cannot_inject_value_error();
443
+ var resolve_to_type_wrapper_util_1 = require_resolve_to_type_wrapper_util();
444
+ function InjectMany(typeOrIdentifier) {
445
+ return function(target, propertyName, index) {
446
+ const typeWrapper = resolve_to_type_wrapper_util_1.resolveToTypeWrapper(typeOrIdentifier, target, propertyName, index);
447
+ if (typeWrapper === undefined || typeWrapper.eagerType === undefined || typeWrapper.eagerType === Object) {
448
+ throw new cannot_inject_value_error_1.CannotInjectValueError(target, propertyName);
449
+ }
450
+ container_class_1.Container.registerHandler({
451
+ object: target,
452
+ propertyName,
453
+ index,
454
+ value: (containerInstance) => {
455
+ const evaluatedLazyType = typeWrapper.lazyType();
456
+ if (evaluatedLazyType === undefined || evaluatedLazyType === Object) {
457
+ throw new cannot_inject_value_error_1.CannotInjectValueError(target, propertyName);
458
+ }
459
+ return containerInstance.getMany(evaluatedLazyType);
460
+ }
461
+ });
462
+ };
463
+ }
464
+ exports2.InjectMany = InjectMany;
465
+ });
466
+
467
+ // ../../node_modules/typedi/cjs/decorators/inject.decorator.js
468
+ var require_inject_decorator = __commonJS((exports2) => {
469
+ Object.defineProperty(exports2, "__esModule", { value: true });
470
+ exports2.Inject = undefined;
471
+ var container_class_1 = require_container_class();
472
+ var cannot_inject_value_error_1 = require_cannot_inject_value_error();
473
+ var resolve_to_type_wrapper_util_1 = require_resolve_to_type_wrapper_util();
474
+ function Inject(typeOrIdentifier) {
475
+ return function(target, propertyName, index) {
476
+ const typeWrapper = resolve_to_type_wrapper_util_1.resolveToTypeWrapper(typeOrIdentifier, target, propertyName, index);
477
+ if (typeWrapper === undefined || typeWrapper.eagerType === undefined || typeWrapper.eagerType === Object) {
478
+ throw new cannot_inject_value_error_1.CannotInjectValueError(target, propertyName);
479
+ }
480
+ container_class_1.Container.registerHandler({
481
+ object: target,
482
+ propertyName,
483
+ index,
484
+ value: (containerInstance) => {
485
+ const evaluatedLazyType = typeWrapper.lazyType();
486
+ if (evaluatedLazyType === undefined || evaluatedLazyType === Object) {
487
+ throw new cannot_inject_value_error_1.CannotInjectValueError(target, propertyName);
488
+ }
489
+ return containerInstance.get(evaluatedLazyType);
490
+ }
491
+ });
492
+ };
493
+ }
494
+ exports2.Inject = Inject;
495
+ });
496
+
497
+ // ../../node_modules/typedi/cjs/decorators/service.decorator.js
498
+ var require_service_decorator = __commonJS((exports2) => {
499
+ Object.defineProperty(exports2, "__esModule", { value: true });
500
+ exports2.Service = undefined;
501
+ var container_class_1 = require_container_class();
502
+ var token_class_1 = require_token_class();
503
+ var empty_const_1 = require_empty_const();
504
+ function Service(optionsOrServiceIdentifier) {
505
+ return (targetConstructor) => {
506
+ const serviceMetadata = {
507
+ id: targetConstructor,
508
+ type: targetConstructor,
509
+ factory: undefined,
510
+ multiple: false,
511
+ global: false,
512
+ eager: false,
513
+ transient: false,
514
+ value: empty_const_1.EMPTY_VALUE
515
+ };
516
+ if (optionsOrServiceIdentifier instanceof token_class_1.Token || typeof optionsOrServiceIdentifier === "string") {
517
+ serviceMetadata.id = optionsOrServiceIdentifier;
518
+ } else if (optionsOrServiceIdentifier) {
519
+ serviceMetadata.id = optionsOrServiceIdentifier.id || targetConstructor;
520
+ serviceMetadata.factory = optionsOrServiceIdentifier.factory || undefined;
521
+ serviceMetadata.multiple = optionsOrServiceIdentifier.multiple || false;
522
+ serviceMetadata.global = optionsOrServiceIdentifier.global || false;
523
+ serviceMetadata.eager = optionsOrServiceIdentifier.eager || false;
524
+ serviceMetadata.transient = optionsOrServiceIdentifier.transient || false;
525
+ }
526
+ container_class_1.Container.set(serviceMetadata);
527
+ };
528
+ }
529
+ exports2.Service = Service;
530
+ });
531
+
532
+ // ../../node_modules/typedi/cjs/index.js
533
+ var require_cjs = __commonJS((exports2) => {
534
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
535
+ if (k2 === undefined)
536
+ k2 = k;
537
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
538
+ return m[k];
539
+ } });
540
+ } : function(o, m, k, k2) {
541
+ if (k2 === undefined)
542
+ k2 = k;
543
+ o[k2] = m[k];
544
+ });
545
+ var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
546
+ for (var p in m)
547
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p))
548
+ __createBinding(exports3, m, p);
549
+ };
550
+ Object.defineProperty(exports2, "__esModule", { value: true });
551
+ exports2.Token = exports2.Container = exports2.ContainerInstance = undefined;
552
+ var container_class_1 = require_container_class();
553
+ __exportStar(require_inject_many_decorator(), exports2);
554
+ __exportStar(require_inject_decorator(), exports2);
555
+ __exportStar(require_service_decorator(), exports2);
556
+ __exportStar(require_cannot_inject_value_error(), exports2);
557
+ __exportStar(require_cannot_instantiate_value_error(), exports2);
558
+ __exportStar(require_service_not_found_error(), exports2);
559
+ var container_instance_class_1 = require_container_instance_class();
560
+ Object.defineProperty(exports2, "ContainerInstance", { enumerable: true, get: function() {
561
+ return container_instance_class_1.ContainerInstance;
562
+ } });
563
+ var container_class_2 = require_container_class();
564
+ Object.defineProperty(exports2, "Container", { enumerable: true, get: function() {
565
+ return container_class_2.Container;
566
+ } });
567
+ var token_class_1 = require_token_class();
568
+ Object.defineProperty(exports2, "Token", { enumerable: true, get: function() {
569
+ return token_class_1.Token;
570
+ } });
571
+ exports2.default = container_class_1.Container;
572
+ });
573
+
574
+ // src/index.ts
575
+ var exports_src = {};
576
+ __export(exports_src, {
577
+ getInstance: () => getInstance,
578
+ Service: () => import_typedi2.Service,
579
+ Inject: () => import_typedi2.Inject,
580
+ Container: () => import_typedi2.Container
581
+ });
582
+ module.exports = __toCommonJS(exports_src);
583
+
584
+ // ../../node_modules/reflect-metadata/Reflect.js
585
+ /*! *****************************************************************************
586
+ Copyright (C) Microsoft. All rights reserved.
587
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
588
+ this file except in compliance with the License. You may obtain a copy of the
589
+ License at http://www.apache.org/licenses/LICENSE-2.0
590
+
591
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
592
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
593
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
594
+ MERCHANTABLITY OR NON-INFRINGEMENT.
595
+
596
+ See the Apache Version 2.0 License for specific language governing permissions
597
+ and limitations under the License.
598
+ ***************************************************************************** */
599
+ var Reflect2;
600
+ (function(Reflect3) {
601
+ (function(factory) {
602
+ var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : Function("return this;")();
603
+ var exporter = makeExporter(Reflect3);
604
+ if (typeof root.Reflect === "undefined") {
605
+ root.Reflect = Reflect3;
606
+ } else {
607
+ exporter = makeExporter(root.Reflect, exporter);
608
+ }
609
+ factory(exporter);
610
+ function makeExporter(target, previous) {
611
+ return function(key, value) {
612
+ if (typeof target[key] !== "function") {
613
+ Object.defineProperty(target, key, { configurable: true, writable: true, value });
614
+ }
615
+ if (previous)
616
+ previous(key, value);
617
+ };
618
+ }
619
+ })(function(exporter) {
620
+ var hasOwn = Object.prototype.hasOwnProperty;
621
+ var supportsSymbol = typeof Symbol === "function";
622
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
623
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
624
+ var supportsCreate = typeof Object.create === "function";
625
+ var supportsProto = { __proto__: [] } instanceof Array;
626
+ var downLevel = !supportsCreate && !supportsProto;
627
+ var HashMap = {
628
+ create: supportsCreate ? function() {
629
+ return MakeDictionary(Object.create(null));
630
+ } : supportsProto ? function() {
631
+ return MakeDictionary({ __proto__: null });
632
+ } : function() {
633
+ return MakeDictionary({});
634
+ },
635
+ has: downLevel ? function(map, key) {
636
+ return hasOwn.call(map, key);
637
+ } : function(map, key) {
638
+ return key in map;
639
+ },
640
+ get: downLevel ? function(map, key) {
641
+ return hasOwn.call(map, key) ? map[key] : undefined;
642
+ } : function(map, key) {
643
+ return map[key];
644
+ }
645
+ };
646
+ var functionPrototype = Object.getPrototypeOf(Function);
647
+ var usePolyfill = typeof process === "object" && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true";
648
+ var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
649
+ var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
650
+ var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
651
+ var Metadata = new _WeakMap;
652
+ function decorate(decorators, target, propertyKey, attributes) {
653
+ if (!IsUndefined(propertyKey)) {
654
+ if (!IsArray(decorators))
655
+ throw new TypeError;
656
+ if (!IsObject(target))
657
+ throw new TypeError;
658
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
659
+ throw new TypeError;
660
+ if (IsNull(attributes))
661
+ attributes = undefined;
662
+ propertyKey = ToPropertyKey(propertyKey);
663
+ return DecorateProperty(decorators, target, propertyKey, attributes);
664
+ } else {
665
+ if (!IsArray(decorators))
666
+ throw new TypeError;
667
+ if (!IsConstructor(target))
668
+ throw new TypeError;
669
+ return DecorateConstructor(decorators, target);
670
+ }
671
+ }
672
+ exporter("decorate", decorate);
673
+ function metadata(metadataKey, metadataValue) {
674
+ function decorator(target, propertyKey) {
675
+ if (!IsObject(target))
676
+ throw new TypeError;
677
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
678
+ throw new TypeError;
679
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
680
+ }
681
+ return decorator;
682
+ }
683
+ exporter("metadata", metadata);
684
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
685
+ if (!IsObject(target))
686
+ throw new TypeError;
687
+ if (!IsUndefined(propertyKey))
688
+ propertyKey = ToPropertyKey(propertyKey);
689
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
690
+ }
691
+ exporter("defineMetadata", defineMetadata);
692
+ function hasMetadata(metadataKey, target, propertyKey) {
693
+ if (!IsObject(target))
694
+ throw new TypeError;
695
+ if (!IsUndefined(propertyKey))
696
+ propertyKey = ToPropertyKey(propertyKey);
697
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
698
+ }
699
+ exporter("hasMetadata", hasMetadata);
700
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
701
+ if (!IsObject(target))
702
+ throw new TypeError;
703
+ if (!IsUndefined(propertyKey))
704
+ propertyKey = ToPropertyKey(propertyKey);
705
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
706
+ }
707
+ exporter("hasOwnMetadata", hasOwnMetadata);
708
+ function getMetadata(metadataKey, target, propertyKey) {
709
+ if (!IsObject(target))
710
+ throw new TypeError;
711
+ if (!IsUndefined(propertyKey))
712
+ propertyKey = ToPropertyKey(propertyKey);
713
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
714
+ }
715
+ exporter("getMetadata", getMetadata);
716
+ function getOwnMetadata(metadataKey, target, propertyKey) {
717
+ if (!IsObject(target))
718
+ throw new TypeError;
719
+ if (!IsUndefined(propertyKey))
720
+ propertyKey = ToPropertyKey(propertyKey);
721
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
722
+ }
723
+ exporter("getOwnMetadata", getOwnMetadata);
724
+ function getMetadataKeys(target, propertyKey) {
725
+ if (!IsObject(target))
726
+ throw new TypeError;
727
+ if (!IsUndefined(propertyKey))
728
+ propertyKey = ToPropertyKey(propertyKey);
729
+ return OrdinaryMetadataKeys(target, propertyKey);
730
+ }
731
+ exporter("getMetadataKeys", getMetadataKeys);
732
+ function getOwnMetadataKeys(target, propertyKey) {
733
+ if (!IsObject(target))
734
+ throw new TypeError;
735
+ if (!IsUndefined(propertyKey))
736
+ propertyKey = ToPropertyKey(propertyKey);
737
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
738
+ }
739
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
740
+ function deleteMetadata(metadataKey, target, propertyKey) {
741
+ if (!IsObject(target))
742
+ throw new TypeError;
743
+ if (!IsUndefined(propertyKey))
744
+ propertyKey = ToPropertyKey(propertyKey);
745
+ var metadataMap = GetOrCreateMetadataMap(target, propertyKey, false);
746
+ if (IsUndefined(metadataMap))
747
+ return false;
748
+ if (!metadataMap.delete(metadataKey))
749
+ return false;
750
+ if (metadataMap.size > 0)
751
+ return true;
752
+ var targetMetadata = Metadata.get(target);
753
+ targetMetadata.delete(propertyKey);
754
+ if (targetMetadata.size > 0)
755
+ return true;
756
+ Metadata.delete(target);
757
+ return true;
758
+ }
759
+ exporter("deleteMetadata", deleteMetadata);
760
+ function DecorateConstructor(decorators, target) {
761
+ for (var i = decorators.length - 1;i >= 0; --i) {
762
+ var decorator = decorators[i];
763
+ var decorated = decorator(target);
764
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
765
+ if (!IsConstructor(decorated))
766
+ throw new TypeError;
767
+ target = decorated;
768
+ }
769
+ }
770
+ return target;
771
+ }
772
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
773
+ for (var i = decorators.length - 1;i >= 0; --i) {
774
+ var decorator = decorators[i];
775
+ var decorated = decorator(target, propertyKey, descriptor);
776
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
777
+ if (!IsObject(decorated))
778
+ throw new TypeError;
779
+ descriptor = decorated;
780
+ }
781
+ }
782
+ return descriptor;
783
+ }
784
+ function GetOrCreateMetadataMap(O, P, Create) {
785
+ var targetMetadata = Metadata.get(O);
786
+ if (IsUndefined(targetMetadata)) {
787
+ if (!Create)
788
+ return;
789
+ targetMetadata = new _Map;
790
+ Metadata.set(O, targetMetadata);
791
+ }
792
+ var metadataMap = targetMetadata.get(P);
793
+ if (IsUndefined(metadataMap)) {
794
+ if (!Create)
795
+ return;
796
+ metadataMap = new _Map;
797
+ targetMetadata.set(P, metadataMap);
798
+ }
799
+ return metadataMap;
800
+ }
801
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
802
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
803
+ if (hasOwn2)
804
+ return true;
805
+ var parent = OrdinaryGetPrototypeOf(O);
806
+ if (!IsNull(parent))
807
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
808
+ return false;
809
+ }
810
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
811
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
812
+ if (IsUndefined(metadataMap))
813
+ return false;
814
+ return ToBoolean(metadataMap.has(MetadataKey));
815
+ }
816
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
817
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
818
+ if (hasOwn2)
819
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
820
+ var parent = OrdinaryGetPrototypeOf(O);
821
+ if (!IsNull(parent))
822
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
823
+ return;
824
+ }
825
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
826
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
827
+ if (IsUndefined(metadataMap))
828
+ return;
829
+ return metadataMap.get(MetadataKey);
830
+ }
831
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
832
+ var metadataMap = GetOrCreateMetadataMap(O, P, true);
833
+ metadataMap.set(MetadataKey, MetadataValue);
834
+ }
835
+ function OrdinaryMetadataKeys(O, P) {
836
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
837
+ var parent = OrdinaryGetPrototypeOf(O);
838
+ if (parent === null)
839
+ return ownKeys;
840
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
841
+ if (parentKeys.length <= 0)
842
+ return ownKeys;
843
+ if (ownKeys.length <= 0)
844
+ return parentKeys;
845
+ var set = new _Set;
846
+ var keys = [];
847
+ for (var _i = 0, ownKeys_1 = ownKeys;_i < ownKeys_1.length; _i++) {
848
+ var key = ownKeys_1[_i];
849
+ var hasKey = set.has(key);
850
+ if (!hasKey) {
851
+ set.add(key);
852
+ keys.push(key);
853
+ }
854
+ }
855
+ for (var _a = 0, parentKeys_1 = parentKeys;_a < parentKeys_1.length; _a++) {
856
+ var key = parentKeys_1[_a];
857
+ var hasKey = set.has(key);
858
+ if (!hasKey) {
859
+ set.add(key);
860
+ keys.push(key);
861
+ }
862
+ }
863
+ return keys;
864
+ }
865
+ function OrdinaryOwnMetadataKeys(O, P) {
866
+ var keys = [];
867
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
868
+ if (IsUndefined(metadataMap))
869
+ return keys;
870
+ var keysObj = metadataMap.keys();
871
+ var iterator = GetIterator(keysObj);
872
+ var k = 0;
873
+ while (true) {
874
+ var next = IteratorStep(iterator);
875
+ if (!next) {
876
+ keys.length = k;
877
+ return keys;
878
+ }
879
+ var nextValue = IteratorValue(next);
880
+ try {
881
+ keys[k] = nextValue;
882
+ } catch (e) {
883
+ try {
884
+ IteratorClose(iterator);
885
+ } finally {
886
+ throw e;
887
+ }
888
+ }
889
+ k++;
890
+ }
891
+ }
892
+ function Type(x) {
893
+ if (x === null)
894
+ return 1;
895
+ switch (typeof x) {
896
+ case "undefined":
897
+ return 0;
898
+ case "boolean":
899
+ return 2;
900
+ case "string":
901
+ return 3;
902
+ case "symbol":
903
+ return 4;
904
+ case "number":
905
+ return 5;
906
+ case "object":
907
+ return x === null ? 1 : 6;
908
+ default:
909
+ return 6;
910
+ }
911
+ }
912
+ function IsUndefined(x) {
913
+ return x === undefined;
914
+ }
915
+ function IsNull(x) {
916
+ return x === null;
917
+ }
918
+ function IsSymbol(x) {
919
+ return typeof x === "symbol";
920
+ }
921
+ function IsObject(x) {
922
+ return typeof x === "object" ? x !== null : typeof x === "function";
923
+ }
924
+ function ToPrimitive(input, PreferredType) {
925
+ switch (Type(input)) {
926
+ case 0:
927
+ return input;
928
+ case 1:
929
+ return input;
930
+ case 2:
931
+ return input;
932
+ case 3:
933
+ return input;
934
+ case 4:
935
+ return input;
936
+ case 5:
937
+ return input;
938
+ }
939
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
940
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
941
+ if (exoticToPrim !== undefined) {
942
+ var result = exoticToPrim.call(input, hint);
943
+ if (IsObject(result))
944
+ throw new TypeError;
945
+ return result;
946
+ }
947
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
948
+ }
949
+ function OrdinaryToPrimitive(O, hint) {
950
+ if (hint === "string") {
951
+ var toString_1 = O.toString;
952
+ if (IsCallable(toString_1)) {
953
+ var result = toString_1.call(O);
954
+ if (!IsObject(result))
955
+ return result;
956
+ }
957
+ var valueOf = O.valueOf;
958
+ if (IsCallable(valueOf)) {
959
+ var result = valueOf.call(O);
960
+ if (!IsObject(result))
961
+ return result;
962
+ }
963
+ } else {
964
+ var valueOf = O.valueOf;
965
+ if (IsCallable(valueOf)) {
966
+ var result = valueOf.call(O);
967
+ if (!IsObject(result))
968
+ return result;
969
+ }
970
+ var toString_2 = O.toString;
971
+ if (IsCallable(toString_2)) {
972
+ var result = toString_2.call(O);
973
+ if (!IsObject(result))
974
+ return result;
975
+ }
976
+ }
977
+ throw new TypeError;
978
+ }
979
+ function ToBoolean(argument) {
980
+ return !!argument;
981
+ }
982
+ function ToString(argument) {
983
+ return "" + argument;
984
+ }
985
+ function ToPropertyKey(argument) {
986
+ var key = ToPrimitive(argument, 3);
987
+ if (IsSymbol(key))
988
+ return key;
989
+ return ToString(key);
990
+ }
991
+ function IsArray(argument) {
992
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
993
+ }
994
+ function IsCallable(argument) {
995
+ return typeof argument === "function";
996
+ }
997
+ function IsConstructor(argument) {
998
+ return typeof argument === "function";
999
+ }
1000
+ function IsPropertyKey(argument) {
1001
+ switch (Type(argument)) {
1002
+ case 3:
1003
+ return true;
1004
+ case 4:
1005
+ return true;
1006
+ default:
1007
+ return false;
1008
+ }
1009
+ }
1010
+ function GetMethod(V, P) {
1011
+ var func = V[P];
1012
+ if (func === undefined || func === null)
1013
+ return;
1014
+ if (!IsCallable(func))
1015
+ throw new TypeError;
1016
+ return func;
1017
+ }
1018
+ function GetIterator(obj) {
1019
+ var method = GetMethod(obj, iteratorSymbol);
1020
+ if (!IsCallable(method))
1021
+ throw new TypeError;
1022
+ var iterator = method.call(obj);
1023
+ if (!IsObject(iterator))
1024
+ throw new TypeError;
1025
+ return iterator;
1026
+ }
1027
+ function IteratorValue(iterResult) {
1028
+ return iterResult.value;
1029
+ }
1030
+ function IteratorStep(iterator) {
1031
+ var result = iterator.next();
1032
+ return result.done ? false : result;
1033
+ }
1034
+ function IteratorClose(iterator) {
1035
+ var f = iterator["return"];
1036
+ if (f)
1037
+ f.call(iterator);
1038
+ }
1039
+ function OrdinaryGetPrototypeOf(O) {
1040
+ var proto = Object.getPrototypeOf(O);
1041
+ if (typeof O !== "function" || O === functionPrototype)
1042
+ return proto;
1043
+ if (proto !== functionPrototype)
1044
+ return proto;
1045
+ var prototype = O.prototype;
1046
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
1047
+ if (prototypeProto == null || prototypeProto === Object.prototype)
1048
+ return proto;
1049
+ var constructor = prototypeProto.constructor;
1050
+ if (typeof constructor !== "function")
1051
+ return proto;
1052
+ if (constructor === O)
1053
+ return proto;
1054
+ return constructor;
1055
+ }
1056
+ function CreateMapPolyfill() {
1057
+ var cacheSentinel = {};
1058
+ var arraySentinel = [];
1059
+ var MapIterator = function() {
1060
+ function MapIterator2(keys, values, selector) {
1061
+ this._index = 0;
1062
+ this._keys = keys;
1063
+ this._values = values;
1064
+ this._selector = selector;
1065
+ }
1066
+ MapIterator2.prototype["@@iterator"] = function() {
1067
+ return this;
1068
+ };
1069
+ MapIterator2.prototype[iteratorSymbol] = function() {
1070
+ return this;
1071
+ };
1072
+ MapIterator2.prototype.next = function() {
1073
+ var index = this._index;
1074
+ if (index >= 0 && index < this._keys.length) {
1075
+ var result = this._selector(this._keys[index], this._values[index]);
1076
+ if (index + 1 >= this._keys.length) {
1077
+ this._index = -1;
1078
+ this._keys = arraySentinel;
1079
+ this._values = arraySentinel;
1080
+ } else {
1081
+ this._index++;
1082
+ }
1083
+ return { value: result, done: false };
1084
+ }
1085
+ return { value: undefined, done: true };
1086
+ };
1087
+ MapIterator2.prototype.throw = function(error) {
1088
+ if (this._index >= 0) {
1089
+ this._index = -1;
1090
+ this._keys = arraySentinel;
1091
+ this._values = arraySentinel;
1092
+ }
1093
+ throw error;
1094
+ };
1095
+ MapIterator2.prototype.return = function(value) {
1096
+ if (this._index >= 0) {
1097
+ this._index = -1;
1098
+ this._keys = arraySentinel;
1099
+ this._values = arraySentinel;
1100
+ }
1101
+ return { value, done: true };
1102
+ };
1103
+ return MapIterator2;
1104
+ }();
1105
+ return function() {
1106
+ function Map2() {
1107
+ this._keys = [];
1108
+ this._values = [];
1109
+ this._cacheKey = cacheSentinel;
1110
+ this._cacheIndex = -2;
1111
+ }
1112
+ Object.defineProperty(Map2.prototype, "size", {
1113
+ get: function() {
1114
+ return this._keys.length;
1115
+ },
1116
+ enumerable: true,
1117
+ configurable: true
1118
+ });
1119
+ Map2.prototype.has = function(key) {
1120
+ return this._find(key, false) >= 0;
1121
+ };
1122
+ Map2.prototype.get = function(key) {
1123
+ var index = this._find(key, false);
1124
+ return index >= 0 ? this._values[index] : undefined;
1125
+ };
1126
+ Map2.prototype.set = function(key, value) {
1127
+ var index = this._find(key, true);
1128
+ this._values[index] = value;
1129
+ return this;
1130
+ };
1131
+ Map2.prototype.delete = function(key) {
1132
+ var index = this._find(key, false);
1133
+ if (index >= 0) {
1134
+ var size = this._keys.length;
1135
+ for (var i = index + 1;i < size; i++) {
1136
+ this._keys[i - 1] = this._keys[i];
1137
+ this._values[i - 1] = this._values[i];
1138
+ }
1139
+ this._keys.length--;
1140
+ this._values.length--;
1141
+ if (key === this._cacheKey) {
1142
+ this._cacheKey = cacheSentinel;
1143
+ this._cacheIndex = -2;
1144
+ }
1145
+ return true;
1146
+ }
1147
+ return false;
1148
+ };
1149
+ Map2.prototype.clear = function() {
1150
+ this._keys.length = 0;
1151
+ this._values.length = 0;
1152
+ this._cacheKey = cacheSentinel;
1153
+ this._cacheIndex = -2;
1154
+ };
1155
+ Map2.prototype.keys = function() {
1156
+ return new MapIterator(this._keys, this._values, getKey);
1157
+ };
1158
+ Map2.prototype.values = function() {
1159
+ return new MapIterator(this._keys, this._values, getValue);
1160
+ };
1161
+ Map2.prototype.entries = function() {
1162
+ return new MapIterator(this._keys, this._values, getEntry);
1163
+ };
1164
+ Map2.prototype["@@iterator"] = function() {
1165
+ return this.entries();
1166
+ };
1167
+ Map2.prototype[iteratorSymbol] = function() {
1168
+ return this.entries();
1169
+ };
1170
+ Map2.prototype._find = function(key, insert) {
1171
+ if (this._cacheKey !== key) {
1172
+ this._cacheIndex = this._keys.indexOf(this._cacheKey = key);
1173
+ }
1174
+ if (this._cacheIndex < 0 && insert) {
1175
+ this._cacheIndex = this._keys.length;
1176
+ this._keys.push(key);
1177
+ this._values.push(undefined);
1178
+ }
1179
+ return this._cacheIndex;
1180
+ };
1181
+ return Map2;
1182
+ }();
1183
+ function getKey(key, _) {
1184
+ return key;
1185
+ }
1186
+ function getValue(_, value) {
1187
+ return value;
1188
+ }
1189
+ function getEntry(key, value) {
1190
+ return [key, value];
1191
+ }
1192
+ }
1193
+ function CreateSetPolyfill() {
1194
+ return function() {
1195
+ function Set2() {
1196
+ this._map = new _Map;
1197
+ }
1198
+ Object.defineProperty(Set2.prototype, "size", {
1199
+ get: function() {
1200
+ return this._map.size;
1201
+ },
1202
+ enumerable: true,
1203
+ configurable: true
1204
+ });
1205
+ Set2.prototype.has = function(value) {
1206
+ return this._map.has(value);
1207
+ };
1208
+ Set2.prototype.add = function(value) {
1209
+ return this._map.set(value, value), this;
1210
+ };
1211
+ Set2.prototype.delete = function(value) {
1212
+ return this._map.delete(value);
1213
+ };
1214
+ Set2.prototype.clear = function() {
1215
+ this._map.clear();
1216
+ };
1217
+ Set2.prototype.keys = function() {
1218
+ return this._map.keys();
1219
+ };
1220
+ Set2.prototype.values = function() {
1221
+ return this._map.values();
1222
+ };
1223
+ Set2.prototype.entries = function() {
1224
+ return this._map.entries();
1225
+ };
1226
+ Set2.prototype["@@iterator"] = function() {
1227
+ return this.keys();
1228
+ };
1229
+ Set2.prototype[iteratorSymbol] = function() {
1230
+ return this.keys();
1231
+ };
1232
+ return Set2;
1233
+ }();
1234
+ }
1235
+ function CreateWeakMapPolyfill() {
1236
+ var UUID_SIZE = 16;
1237
+ var keys = HashMap.create();
1238
+ var rootKey = CreateUniqueKey();
1239
+ return function() {
1240
+ function WeakMap2() {
1241
+ this._key = CreateUniqueKey();
1242
+ }
1243
+ WeakMap2.prototype.has = function(target) {
1244
+ var table = GetOrCreateWeakMapTable(target, false);
1245
+ return table !== undefined ? HashMap.has(table, this._key) : false;
1246
+ };
1247
+ WeakMap2.prototype.get = function(target) {
1248
+ var table = GetOrCreateWeakMapTable(target, false);
1249
+ return table !== undefined ? HashMap.get(table, this._key) : undefined;
1250
+ };
1251
+ WeakMap2.prototype.set = function(target, value) {
1252
+ var table = GetOrCreateWeakMapTable(target, true);
1253
+ table[this._key] = value;
1254
+ return this;
1255
+ };
1256
+ WeakMap2.prototype.delete = function(target) {
1257
+ var table = GetOrCreateWeakMapTable(target, false);
1258
+ return table !== undefined ? delete table[this._key] : false;
1259
+ };
1260
+ WeakMap2.prototype.clear = function() {
1261
+ this._key = CreateUniqueKey();
1262
+ };
1263
+ return WeakMap2;
1264
+ }();
1265
+ function CreateUniqueKey() {
1266
+ var key;
1267
+ do
1268
+ key = "@@WeakMap@@" + CreateUUID();
1269
+ while (HashMap.has(keys, key));
1270
+ keys[key] = true;
1271
+ return key;
1272
+ }
1273
+ function GetOrCreateWeakMapTable(target, create) {
1274
+ if (!hasOwn.call(target, rootKey)) {
1275
+ if (!create)
1276
+ return;
1277
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
1278
+ }
1279
+ return target[rootKey];
1280
+ }
1281
+ function FillRandomBytes(buffer, size) {
1282
+ for (var i = 0;i < size; ++i)
1283
+ buffer[i] = Math.random() * 255 | 0;
1284
+ return buffer;
1285
+ }
1286
+ function GenRandomBytes(size) {
1287
+ if (typeof Uint8Array === "function") {
1288
+ if (typeof crypto !== "undefined")
1289
+ return crypto.getRandomValues(new Uint8Array(size));
1290
+ if (typeof msCrypto !== "undefined")
1291
+ return msCrypto.getRandomValues(new Uint8Array(size));
1292
+ return FillRandomBytes(new Uint8Array(size), size);
1293
+ }
1294
+ return FillRandomBytes(new Array(size), size);
1295
+ }
1296
+ function CreateUUID() {
1297
+ var data = GenRandomBytes(UUID_SIZE);
1298
+ data[6] = data[6] & 79 | 64;
1299
+ data[8] = data[8] & 191 | 128;
1300
+ var result = "";
1301
+ for (var offset = 0;offset < UUID_SIZE; ++offset) {
1302
+ var byte = data[offset];
1303
+ if (offset === 4 || offset === 6 || offset === 8)
1304
+ result += "-";
1305
+ if (byte < 16)
1306
+ result += "0";
1307
+ result += byte.toString(16).toLowerCase();
1308
+ }
1309
+ return result;
1310
+ }
1311
+ }
1312
+ function MakeDictionary(obj) {
1313
+ obj.__ = undefined;
1314
+ delete obj.__;
1315
+ return obj;
1316
+ }
1317
+ });
1318
+ })(Reflect2 || (Reflect2 = {}));
1319
+
1320
+ // src/typedi.ts
1321
+ var import_typedi = __toESM(require_cjs());
1322
+ var import_typedi2 = __toESM(require_cjs());
1323
+ function getInstance(service) {
1324
+ return import_typedi.default.get(service);
1325
+ }