@orion-js/services 4.0.0-next.3 → 4.0.0-next.4

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 CHANGED
@@ -1,7 +1,12 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
5
10
  var __export = (target, all) => {
6
11
  for (var name in all)
7
12
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -14,843 +19,479 @@ var __copyProps = (to, from, except, desc) => {
14
19
  }
15
20
  return to;
16
21
  };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
17
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
31
 
19
- // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- Container: () => import_typedi2.Container,
23
- Inject: () => import_typedi2.Inject,
24
- Service: () => import_typedi2.Service,
25
- getInstance: () => getInstance
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
- // node_modules/.pnpm/reflect-metadata@0.1.14/node_modules/reflect-metadata/Reflect.js
30
- var Reflect2;
31
- (function(Reflect3) {
32
- (function(factory) {
33
- var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : Function("return this;")();
34
- var exporter = makeExporter(Reflect3);
35
- if (typeof root.Reflect === "undefined") {
36
- root.Reflect = Reflect3;
37
- } else {
38
- exporter = makeExporter(root.Reflect, exporter);
39
- }
40
- factory(exporter);
41
- function makeExporter(target, previous) {
42
- return function(key, value) {
43
- if (typeof target[key] !== "function") {
44
- Object.defineProperty(target, key, { configurable: true, writable: true, value });
45
- }
46
- if (previous)
47
- previous(key, value);
48
- };
49
- }
50
- })(function(exporter) {
51
- var hasOwn = Object.prototype.hasOwnProperty;
52
- var supportsSymbol = typeof Symbol === "function";
53
- var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
54
- var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
55
- var supportsCreate = typeof Object.create === "function";
56
- var supportsProto = { __proto__: [] } instanceof Array;
57
- var downLevel = !supportsCreate && !supportsProto;
58
- var HashMap = {
59
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
60
- create: supportsCreate ? function() {
61
- return MakeDictionary(/* @__PURE__ */ Object.create(null));
62
- } : supportsProto ? function() {
63
- return MakeDictionary({ __proto__: null });
64
- } : function() {
65
- return MakeDictionary({});
66
- },
67
- has: downLevel ? function(map, key) {
68
- return hasOwn.call(map, key);
69
- } : function(map, key) {
70
- return key in map;
71
- },
72
- get: downLevel ? function(map, key) {
73
- return hasOwn.call(map, key) ? map[key] : void 0;
74
- } : function(map, key) {
75
- return map[key];
76
- }
32
+ // ../../node_modules/.pnpm/object-hash@2.2.0/node_modules/object-hash/index.js
33
+ var require_object_hash = __commonJS({
34
+ "../../node_modules/.pnpm/object-hash@2.2.0/node_modules/object-hash/index.js"(exports2, module2) {
35
+ "use strict";
36
+ var crypto2 = require("crypto");
37
+ exports2 = module2.exports = objectHash;
38
+ function objectHash(object, options) {
39
+ options = applyDefaults(object, options);
40
+ return hash2(object, options);
41
+ }
42
+ exports2.sha1 = function(object) {
43
+ return objectHash(object);
77
44
  };
78
- var functionPrototype = Object.getPrototypeOf(Function);
79
- var usePolyfill = typeof process === "object" && process["env"] && process["env"]["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true";
80
- var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
81
- var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
82
- var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
83
- var Metadata = new _WeakMap();
84
- function decorate(decorators, target, propertyKey, attributes) {
85
- if (!IsUndefined(propertyKey)) {
86
- if (!IsArray(decorators))
87
- throw new TypeError();
88
- if (!IsObject(target))
89
- throw new TypeError();
90
- if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
91
- throw new TypeError();
92
- if (IsNull(attributes))
93
- attributes = void 0;
94
- propertyKey = ToPropertyKey(propertyKey);
95
- return DecorateProperty(decorators, target, propertyKey, attributes);
96
- } else {
97
- if (!IsArray(decorators))
98
- throw new TypeError();
99
- if (!IsConstructor(target))
100
- throw new TypeError();
101
- return DecorateConstructor(decorators, target);
102
- }
103
- }
104
- exporter("decorate", decorate);
105
- function metadata(metadataKey, metadataValue) {
106
- function decorator(target, propertyKey) {
107
- if (!IsObject(target))
108
- throw new TypeError();
109
- if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
110
- throw new TypeError();
111
- OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
45
+ exports2.keys = function(object) {
46
+ return objectHash(object, { excludeValues: true, algorithm: "sha1", encoding: "hex" });
47
+ };
48
+ exports2.MD5 = function(object) {
49
+ return objectHash(object, { algorithm: "md5", encoding: "hex" });
50
+ };
51
+ exports2.keysMD5 = function(object) {
52
+ return objectHash(object, { algorithm: "md5", encoding: "hex", excludeValues: true });
53
+ };
54
+ var hashes = crypto2.getHashes ? crypto2.getHashes().slice() : ["sha1", "md5"];
55
+ hashes.push("passthrough");
56
+ var encodings = ["buffer", "hex", "binary", "base64"];
57
+ function applyDefaults(object, sourceOptions) {
58
+ sourceOptions = sourceOptions || {};
59
+ var options = {};
60
+ options.algorithm = sourceOptions.algorithm || "sha1";
61
+ options.encoding = sourceOptions.encoding || "hex";
62
+ options.excludeValues = sourceOptions.excludeValues ? true : false;
63
+ options.algorithm = options.algorithm.toLowerCase();
64
+ options.encoding = options.encoding.toLowerCase();
65
+ options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true;
66
+ options.respectType = sourceOptions.respectType === false ? false : true;
67
+ options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
68
+ options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
69
+ options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true;
70
+ options.unorderedSets = sourceOptions.unorderedSets === false ? false : true;
71
+ options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true;
72
+ options.replacer = sourceOptions.replacer || void 0;
73
+ options.excludeKeys = sourceOptions.excludeKeys || void 0;
74
+ if (typeof object === "undefined") {
75
+ throw new Error("Object argument required.");
112
76
  }
113
- return decorator;
114
- }
115
- exporter("metadata", metadata);
116
- function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
117
- if (!IsObject(target))
118
- throw new TypeError();
119
- if (!IsUndefined(propertyKey))
120
- propertyKey = ToPropertyKey(propertyKey);
121
- return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
122
- }
123
- exporter("defineMetadata", defineMetadata);
124
- function hasMetadata(metadataKey, target, propertyKey) {
125
- if (!IsObject(target))
126
- throw new TypeError();
127
- if (!IsUndefined(propertyKey))
128
- propertyKey = ToPropertyKey(propertyKey);
129
- return OrdinaryHasMetadata(metadataKey, target, propertyKey);
130
- }
131
- exporter("hasMetadata", hasMetadata);
132
- function hasOwnMetadata(metadataKey, target, propertyKey) {
133
- if (!IsObject(target))
134
- throw new TypeError();
135
- if (!IsUndefined(propertyKey))
136
- propertyKey = ToPropertyKey(propertyKey);
137
- return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
138
- }
139
- exporter("hasOwnMetadata", hasOwnMetadata);
140
- function getMetadata(metadataKey, target, propertyKey) {
141
- if (!IsObject(target))
142
- throw new TypeError();
143
- if (!IsUndefined(propertyKey))
144
- propertyKey = ToPropertyKey(propertyKey);
145
- return OrdinaryGetMetadata(metadataKey, target, propertyKey);
146
- }
147
- exporter("getMetadata", getMetadata);
148
- function getOwnMetadata(metadataKey, target, propertyKey) {
149
- if (!IsObject(target))
150
- throw new TypeError();
151
- if (!IsUndefined(propertyKey))
152
- propertyKey = ToPropertyKey(propertyKey);
153
- return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
154
- }
155
- exporter("getOwnMetadata", getOwnMetadata);
156
- function getMetadataKeys(target, propertyKey) {
157
- if (!IsObject(target))
158
- throw new TypeError();
159
- if (!IsUndefined(propertyKey))
160
- propertyKey = ToPropertyKey(propertyKey);
161
- return OrdinaryMetadataKeys(target, propertyKey);
162
- }
163
- exporter("getMetadataKeys", getMetadataKeys);
164
- function getOwnMetadataKeys(target, propertyKey) {
165
- if (!IsObject(target))
166
- throw new TypeError();
167
- if (!IsUndefined(propertyKey))
168
- propertyKey = ToPropertyKey(propertyKey);
169
- return OrdinaryOwnMetadataKeys(target, propertyKey);
170
- }
171
- exporter("getOwnMetadataKeys", getOwnMetadataKeys);
172
- function deleteMetadata(metadataKey, target, propertyKey) {
173
- if (!IsObject(target))
174
- throw new TypeError();
175
- if (!IsUndefined(propertyKey))
176
- propertyKey = ToPropertyKey(propertyKey);
177
- var metadataMap = GetOrCreateMetadataMap(
178
- target,
179
- propertyKey,
180
- /*Create*/
181
- false
182
- );
183
- if (IsUndefined(metadataMap))
184
- return false;
185
- if (!metadataMap.delete(metadataKey))
186
- return false;
187
- if (metadataMap.size > 0)
188
- return true;
189
- var targetMetadata = Metadata.get(target);
190
- targetMetadata.delete(propertyKey);
191
- if (targetMetadata.size > 0)
192
- return true;
193
- Metadata.delete(target);
194
- return true;
195
- }
196
- exporter("deleteMetadata", deleteMetadata);
197
- function DecorateConstructor(decorators, target) {
198
- for (var i = decorators.length - 1; i >= 0; --i) {
199
- var decorator = decorators[i];
200
- var decorated = decorator(target);
201
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
202
- if (!IsConstructor(decorated))
203
- throw new TypeError();
204
- target = decorated;
77
+ for (var i = 0; i < hashes.length; ++i) {
78
+ if (hashes[i].toLowerCase() === options.algorithm.toLowerCase()) {
79
+ options.algorithm = hashes[i];
205
80
  }
206
81
  }
207
- return target;
208
- }
209
- function DecorateProperty(decorators, target, propertyKey, descriptor) {
210
- for (var i = decorators.length - 1; i >= 0; --i) {
211
- var decorator = decorators[i];
212
- var decorated = decorator(target, propertyKey, descriptor);
213
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
214
- if (!IsObject(decorated))
215
- throw new TypeError();
216
- descriptor = decorated;
217
- }
82
+ if (hashes.indexOf(options.algorithm) === -1) {
83
+ throw new Error('Algorithm "' + options.algorithm + '" not supported. supported values: ' + hashes.join(", "));
218
84
  }
219
- return descriptor;
220
- }
221
- function GetOrCreateMetadataMap(O, P, Create) {
222
- var targetMetadata = Metadata.get(O);
223
- if (IsUndefined(targetMetadata)) {
224
- if (!Create)
225
- return void 0;
226
- targetMetadata = new _Map();
227
- Metadata.set(O, targetMetadata);
85
+ if (encodings.indexOf(options.encoding) === -1 && options.algorithm !== "passthrough") {
86
+ throw new Error('Encoding "' + options.encoding + '" not supported. supported values: ' + encodings.join(", "));
228
87
  }
229
- var metadataMap = targetMetadata.get(P);
230
- if (IsUndefined(metadataMap)) {
231
- if (!Create)
232
- return void 0;
233
- metadataMap = new _Map();
234
- targetMetadata.set(P, metadataMap);
235
- }
236
- return metadataMap;
237
- }
238
- function OrdinaryHasMetadata(MetadataKey, O, P) {
239
- var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
240
- if (hasOwn2)
241
- return true;
242
- var parent = OrdinaryGetPrototypeOf(O);
243
- if (!IsNull(parent))
244
- return OrdinaryHasMetadata(MetadataKey, parent, P);
245
- return false;
88
+ return options;
246
89
  }
247
- function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
248
- var metadataMap = GetOrCreateMetadataMap(
249
- O,
250
- P,
251
- /*Create*/
252
- false
253
- );
254
- if (IsUndefined(metadataMap))
90
+ function isNativeFunction(f) {
91
+ if (typeof f !== "function") {
255
92
  return false;
256
- return ToBoolean(metadataMap.has(MetadataKey));
257
- }
258
- function OrdinaryGetMetadata(MetadataKey, O, P) {
259
- var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
260
- if (hasOwn2)
261
- return OrdinaryGetOwnMetadata(MetadataKey, O, P);
262
- var parent = OrdinaryGetPrototypeOf(O);
263
- if (!IsNull(parent))
264
- return OrdinaryGetMetadata(MetadataKey, parent, P);
265
- return void 0;
266
- }
267
- function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
268
- var metadataMap = GetOrCreateMetadataMap(
269
- O,
270
- P,
271
- /*Create*/
272
- false
273
- );
274
- if (IsUndefined(metadataMap))
275
- return void 0;
276
- return metadataMap.get(MetadataKey);
277
- }
278
- function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
279
- var metadataMap = GetOrCreateMetadataMap(
280
- O,
281
- P,
282
- /*Create*/
283
- true
284
- );
285
- metadataMap.set(MetadataKey, MetadataValue);
286
- }
287
- function OrdinaryMetadataKeys(O, P) {
288
- var ownKeys = OrdinaryOwnMetadataKeys(O, P);
289
- var parent = OrdinaryGetPrototypeOf(O);
290
- if (parent === null)
291
- return ownKeys;
292
- var parentKeys = OrdinaryMetadataKeys(parent, P);
293
- if (parentKeys.length <= 0)
294
- return ownKeys;
295
- if (ownKeys.length <= 0)
296
- return parentKeys;
297
- var set = new _Set();
298
- var keys = [];
299
- for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
300
- var key = ownKeys_1[_i];
301
- var hasKey = set.has(key);
302
- if (!hasKey) {
303
- set.add(key);
304
- keys.push(key);
305
- }
306
- }
307
- for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
308
- var key = parentKeys_1[_a];
309
- var hasKey = set.has(key);
310
- if (!hasKey) {
311
- set.add(key);
312
- keys.push(key);
313
- }
314
93
  }
315
- return keys;
94
+ var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
95
+ return exp.exec(Function.prototype.toString.call(f)) != null;
316
96
  }
317
- function OrdinaryOwnMetadataKeys(O, P) {
318
- var keys = [];
319
- var metadataMap = GetOrCreateMetadataMap(
320
- O,
321
- P,
322
- /*Create*/
323
- false
324
- );
325
- if (IsUndefined(metadataMap))
326
- return keys;
327
- var keysObj = metadataMap.keys();
328
- var iterator = GetIterator(keysObj);
329
- var k = 0;
330
- while (true) {
331
- var next = IteratorStep(iterator);
332
- if (!next) {
333
- keys.length = k;
334
- return keys;
335
- }
336
- var nextValue = IteratorValue(next);
337
- try {
338
- keys[k] = nextValue;
339
- } catch (e) {
340
- try {
341
- IteratorClose(iterator);
342
- } finally {
343
- throw e;
344
- }
345
- }
346
- k++;
97
+ function hash2(object, options) {
98
+ var hashingStream;
99
+ if (options.algorithm !== "passthrough") {
100
+ hashingStream = crypto2.createHash(options.algorithm);
101
+ } else {
102
+ hashingStream = new PassThrough();
347
103
  }
348
- }
349
- function Type(x) {
350
- if (x === null)
351
- return 1;
352
- switch (typeof x) {
353
- case "undefined":
354
- return 0;
355
- case "boolean":
356
- return 2;
357
- case "string":
358
- return 3;
359
- case "symbol":
360
- return 4;
361
- case "number":
362
- return 5;
363
- case "object":
364
- return x === null ? 1 : 6;
365
- default:
366
- return 6;
104
+ if (typeof hashingStream.write === "undefined") {
105
+ hashingStream.write = hashingStream.update;
106
+ hashingStream.end = hashingStream.update;
367
107
  }
368
- }
369
- function IsUndefined(x) {
370
- return x === void 0;
371
- }
372
- function IsNull(x) {
373
- return x === null;
374
- }
375
- function IsSymbol(x) {
376
- return typeof x === "symbol";
377
- }
378
- function IsObject(x) {
379
- return typeof x === "object" ? x !== null : typeof x === "function";
380
- }
381
- function ToPrimitive(input, PreferredType) {
382
- switch (Type(input)) {
383
- case 0:
384
- return input;
385
- case 1:
386
- return input;
387
- case 2:
388
- return input;
389
- case 3:
390
- return input;
391
- case 4:
392
- return input;
393
- case 5:
394
- return input;
108
+ var hasher = typeHasher(options, hashingStream);
109
+ hasher.dispatch(object);
110
+ if (!hashingStream.update) {
111
+ hashingStream.end("");
395
112
  }
396
- var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
397
- var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
398
- if (exoticToPrim !== void 0) {
399
- var result = exoticToPrim.call(input, hint);
400
- if (IsObject(result))
401
- throw new TypeError();
402
- return result;
113
+ if (hashingStream.digest) {
114
+ return hashingStream.digest(options.encoding === "buffer" ? void 0 : options.encoding);
403
115
  }
404
- return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
405
- }
406
- function OrdinaryToPrimitive(O, hint) {
407
- if (hint === "string") {
408
- var toString_1 = O.toString;
409
- if (IsCallable(toString_1)) {
410
- var result = toString_1.call(O);
411
- if (!IsObject(result))
412
- return result;
413
- }
414
- var valueOf = O.valueOf;
415
- if (IsCallable(valueOf)) {
416
- var result = valueOf.call(O);
417
- if (!IsObject(result))
418
- return result;
419
- }
420
- } else {
421
- var valueOf = O.valueOf;
422
- if (IsCallable(valueOf)) {
423
- var result = valueOf.call(O);
424
- if (!IsObject(result))
425
- return result;
426
- }
427
- var toString_2 = O.toString;
428
- if (IsCallable(toString_2)) {
429
- var result = toString_2.call(O);
430
- if (!IsObject(result))
431
- return result;
432
- }
116
+ var buf = hashingStream.read();
117
+ if (options.encoding === "buffer") {
118
+ return buf;
433
119
  }
434
- throw new TypeError();
435
- }
436
- function ToBoolean(argument) {
437
- return !!argument;
438
- }
439
- function ToString(argument) {
440
- return "" + argument;
441
- }
442
- function ToPropertyKey(argument) {
443
- var key = ToPrimitive(
444
- argument,
445
- 3
446
- /* String */
447
- );
448
- if (IsSymbol(key))
449
- return key;
450
- return ToString(key);
120
+ return buf.toString(options.encoding);
451
121
  }
452
- function IsArray(argument) {
453
- return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
454
- }
455
- function IsCallable(argument) {
456
- return typeof argument === "function";
457
- }
458
- function IsConstructor(argument) {
459
- return typeof argument === "function";
460
- }
461
- function IsPropertyKey(argument) {
462
- switch (Type(argument)) {
463
- case 3:
464
- return true;
465
- case 4:
466
- return true;
467
- default:
468
- return false;
122
+ exports2.writeToStream = function(object, options, stream) {
123
+ if (typeof stream === "undefined") {
124
+ stream = options;
125
+ options = {};
469
126
  }
470
- }
471
- function GetMethod(V, P) {
472
- var func = V[P];
473
- if (func === void 0 || func === null)
474
- return void 0;
475
- if (!IsCallable(func))
476
- throw new TypeError();
477
- return func;
478
- }
479
- function GetIterator(obj) {
480
- var method = GetMethod(obj, iteratorSymbol);
481
- if (!IsCallable(method))
482
- throw new TypeError();
483
- var iterator = method.call(obj);
484
- if (!IsObject(iterator))
485
- throw new TypeError();
486
- return iterator;
487
- }
488
- function IteratorValue(iterResult) {
489
- return iterResult.value;
490
- }
491
- function IteratorStep(iterator) {
492
- var result = iterator.next();
493
- return result.done ? false : result;
494
- }
495
- function IteratorClose(iterator) {
496
- var f = iterator["return"];
497
- if (f)
498
- f.call(iterator);
499
- }
500
- function OrdinaryGetPrototypeOf(O) {
501
- var proto = Object.getPrototypeOf(O);
502
- if (typeof O !== "function" || O === functionPrototype)
503
- return proto;
504
- if (proto !== functionPrototype)
505
- return proto;
506
- var prototype = O.prototype;
507
- var prototypeProto = prototype && Object.getPrototypeOf(prototype);
508
- if (prototypeProto == null || prototypeProto === Object.prototype)
509
- return proto;
510
- var constructor = prototypeProto.constructor;
511
- if (typeof constructor !== "function")
512
- return proto;
513
- if (constructor === O)
514
- return proto;
515
- return constructor;
516
- }
517
- function CreateMapPolyfill() {
518
- var cacheSentinel = {};
519
- var arraySentinel = [];
520
- var MapIterator = (
521
- /** @class */
522
- function() {
523
- function MapIterator2(keys, values, selector) {
524
- this._index = 0;
525
- this._keys = keys;
526
- this._values = values;
527
- this._selector = selector;
127
+ options = applyDefaults(object, options);
128
+ return typeHasher(options, stream).dispatch(object);
129
+ };
130
+ function typeHasher(options, writeTo, context) {
131
+ context = context || [];
132
+ var write = function(str) {
133
+ if (writeTo.update) {
134
+ return writeTo.update(str, "utf8");
135
+ } else {
136
+ return writeTo.write(str, "utf8");
137
+ }
138
+ };
139
+ return {
140
+ dispatch: function(value) {
141
+ if (options.replacer) {
142
+ value = options.replacer(value);
528
143
  }
529
- MapIterator2.prototype["@@iterator"] = function() {
530
- return this;
531
- };
532
- MapIterator2.prototype[iteratorSymbol] = function() {
533
- return this;
534
- };
535
- MapIterator2.prototype.next = function() {
536
- var index = this._index;
537
- if (index >= 0 && index < this._keys.length) {
538
- var result = this._selector(this._keys[index], this._values[index]);
539
- if (index + 1 >= this._keys.length) {
540
- this._index = -1;
541
- this._keys = arraySentinel;
542
- this._values = arraySentinel;
543
- } else {
544
- this._index++;
545
- }
546
- return { value: result, done: false };
547
- }
548
- return { value: void 0, done: true };
549
- };
550
- MapIterator2.prototype.throw = function(error) {
551
- if (this._index >= 0) {
552
- this._index = -1;
553
- this._keys = arraySentinel;
554
- this._values = arraySentinel;
555
- }
556
- throw error;
557
- };
558
- MapIterator2.prototype.return = function(value) {
559
- if (this._index >= 0) {
560
- this._index = -1;
561
- this._keys = arraySentinel;
562
- this._values = arraySentinel;
563
- }
564
- return { value, done: true };
565
- };
566
- return MapIterator2;
567
- }()
568
- );
569
- return (
570
- /** @class */
571
- function() {
572
- function Map2() {
573
- this._keys = [];
574
- this._values = [];
575
- this._cacheKey = cacheSentinel;
576
- this._cacheIndex = -2;
144
+ var type = typeof value;
145
+ if (value === null) {
146
+ type = "null";
577
147
  }
578
- Object.defineProperty(Map2.prototype, "size", {
579
- get: function() {
580
- return this._keys.length;
581
- },
582
- enumerable: true,
583
- configurable: true
584
- });
585
- Map2.prototype.has = function(key) {
586
- return this._find(
587
- key,
588
- /*insert*/
589
- false
590
- ) >= 0;
591
- };
592
- Map2.prototype.get = function(key) {
593
- var index = this._find(
594
- key,
595
- /*insert*/
596
- false
597
- );
598
- return index >= 0 ? this._values[index] : void 0;
599
- };
600
- Map2.prototype.set = function(key, value) {
601
- var index = this._find(
602
- key,
603
- /*insert*/
604
- true
605
- );
606
- this._values[index] = value;
607
- return this;
608
- };
609
- Map2.prototype.delete = function(key) {
610
- var index = this._find(
611
- key,
612
- /*insert*/
613
- false
614
- );
615
- if (index >= 0) {
616
- var size = this._keys.length;
617
- for (var i = index + 1; i < size; i++) {
618
- this._keys[i - 1] = this._keys[i];
619
- this._values[i - 1] = this._values[i];
620
- }
621
- this._keys.length--;
622
- this._values.length--;
623
- if (key === this._cacheKey) {
624
- this._cacheKey = cacheSentinel;
625
- this._cacheIndex = -2;
626
- }
627
- return true;
148
+ return this["_" + type](value);
149
+ },
150
+ _object: function(object) {
151
+ var pattern = /\[object (.*)\]/i;
152
+ var objString = Object.prototype.toString.call(object);
153
+ var objType = pattern.exec(objString);
154
+ if (!objType) {
155
+ objType = "unknown:[" + objString + "]";
156
+ } else {
157
+ objType = objType[1];
158
+ }
159
+ objType = objType.toLowerCase();
160
+ var objectNumber = null;
161
+ if ((objectNumber = context.indexOf(object)) >= 0) {
162
+ return this.dispatch("[CIRCULAR:" + objectNumber + "]");
163
+ } else {
164
+ context.push(object);
165
+ }
166
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
167
+ write("buffer:");
168
+ return write(object);
169
+ }
170
+ if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
171
+ if (this["_" + objType]) {
172
+ this["_" + objType](object);
173
+ } else if (options.ignoreUnknown) {
174
+ return write("[" + objType + "]");
175
+ } else {
176
+ throw new Error('Unknown object type "' + objType + '"');
628
177
  }
629
- return false;
630
- };
631
- Map2.prototype.clear = function() {
632
- this._keys.length = 0;
633
- this._values.length = 0;
634
- this._cacheKey = cacheSentinel;
635
- this._cacheIndex = -2;
636
- };
637
- Map2.prototype.keys = function() {
638
- return new MapIterator(this._keys, this._values, getKey);
639
- };
640
- Map2.prototype.values = function() {
641
- return new MapIterator(this._keys, this._values, getValue);
642
- };
643
- Map2.prototype.entries = function() {
644
- return new MapIterator(this._keys, this._values, getEntry);
645
- };
646
- Map2.prototype["@@iterator"] = function() {
647
- return this.entries();
648
- };
649
- Map2.prototype[iteratorSymbol] = function() {
650
- return this.entries();
651
- };
652
- Map2.prototype._find = function(key, insert) {
653
- if (this._cacheKey !== key) {
654
- this._cacheIndex = this._keys.indexOf(this._cacheKey = key);
178
+ } else {
179
+ var keys = Object.keys(object);
180
+ if (options.unorderedObjects) {
181
+ keys = keys.sort();
655
182
  }
656
- if (this._cacheIndex < 0 && insert) {
657
- this._cacheIndex = this._keys.length;
658
- this._keys.push(key);
659
- this._values.push(void 0);
183
+ if (options.respectType !== false && !isNativeFunction(object)) {
184
+ keys.splice(0, 0, "prototype", "__proto__", "constructor");
660
185
  }
661
- return this._cacheIndex;
662
- };
663
- return Map2;
664
- }()
665
- );
666
- function getKey(key, _) {
667
- return key;
668
- }
669
- function getValue(_, value) {
670
- return value;
671
- }
672
- function getEntry(key, value) {
673
- return [key, value];
674
- }
675
- }
676
- function CreateSetPolyfill() {
677
- return (
678
- /** @class */
679
- function() {
680
- function Set2() {
681
- this._map = new _Map();
186
+ if (options.excludeKeys) {
187
+ keys = keys.filter(function(key) {
188
+ return !options.excludeKeys(key);
189
+ });
190
+ }
191
+ write("object:" + keys.length + ":");
192
+ var self = this;
193
+ return keys.forEach(function(key) {
194
+ self.dispatch(key);
195
+ write(":");
196
+ if (!options.excludeValues) {
197
+ self.dispatch(object[key]);
198
+ }
199
+ write(",");
200
+ });
201
+ }
202
+ },
203
+ _array: function(arr, unordered) {
204
+ unordered = typeof unordered !== "undefined" ? unordered : options.unorderedArrays !== false;
205
+ var self = this;
206
+ write("array:" + arr.length + ":");
207
+ if (!unordered || arr.length <= 1) {
208
+ return arr.forEach(function(entry) {
209
+ return self.dispatch(entry);
210
+ });
682
211
  }
683
- Object.defineProperty(Set2.prototype, "size", {
684
- get: function() {
685
- return this._map.size;
686
- },
687
- enumerable: true,
688
- configurable: true
212
+ var contextAdditions = [];
213
+ var entries = arr.map(function(entry) {
214
+ var strm = new PassThrough();
215
+ var localContext = context.slice();
216
+ var hasher = typeHasher(options, strm, localContext);
217
+ hasher.dispatch(entry);
218
+ contextAdditions = contextAdditions.concat(localContext.slice(context.length));
219
+ return strm.read().toString();
689
220
  });
690
- Set2.prototype.has = function(value) {
691
- return this._map.has(value);
692
- };
693
- Set2.prototype.add = function(value) {
694
- return this._map.set(value, value), this;
695
- };
696
- Set2.prototype.delete = function(value) {
697
- return this._map.delete(value);
698
- };
699
- Set2.prototype.clear = function() {
700
- this._map.clear();
701
- };
702
- Set2.prototype.keys = function() {
703
- return this._map.keys();
704
- };
705
- Set2.prototype.values = function() {
706
- return this._map.values();
707
- };
708
- Set2.prototype.entries = function() {
709
- return this._map.entries();
710
- };
711
- Set2.prototype["@@iterator"] = function() {
712
- return this.keys();
713
- };
714
- Set2.prototype[iteratorSymbol] = function() {
715
- return this.keys();
716
- };
717
- return Set2;
718
- }()
719
- );
720
- }
721
- function CreateWeakMapPolyfill() {
722
- var UUID_SIZE = 16;
723
- var keys = HashMap.create();
724
- var rootKey = CreateUniqueKey();
725
- return (
726
- /** @class */
727
- function() {
728
- function WeakMap2() {
729
- this._key = CreateUniqueKey();
221
+ context = context.concat(contextAdditions);
222
+ entries.sort();
223
+ return this._array(entries, false);
224
+ },
225
+ _date: function(date) {
226
+ return write("date:" + date.toJSON());
227
+ },
228
+ _symbol: function(sym) {
229
+ return write("symbol:" + sym.toString());
230
+ },
231
+ _error: function(err) {
232
+ return write("error:" + err.toString());
233
+ },
234
+ _boolean: function(bool) {
235
+ return write("bool:" + bool.toString());
236
+ },
237
+ _string: function(string) {
238
+ write("string:" + string.length + ":");
239
+ write(string.toString());
240
+ },
241
+ _function: function(fn) {
242
+ write("fn:");
243
+ if (isNativeFunction(fn)) {
244
+ this.dispatch("[native]");
245
+ } else {
246
+ this.dispatch(fn.toString());
730
247
  }
731
- WeakMap2.prototype.has = function(target) {
732
- var table = GetOrCreateWeakMapTable(
733
- target,
734
- /*create*/
735
- false
736
- );
737
- return table !== void 0 ? HashMap.has(table, this._key) : false;
738
- };
739
- WeakMap2.prototype.get = function(target) {
740
- var table = GetOrCreateWeakMapTable(
741
- target,
742
- /*create*/
743
- false
744
- );
745
- return table !== void 0 ? HashMap.get(table, this._key) : void 0;
746
- };
747
- WeakMap2.prototype.set = function(target, value) {
748
- var table = GetOrCreateWeakMapTable(
749
- target,
750
- /*create*/
751
- true
752
- );
753
- table[this._key] = value;
754
- return this;
755
- };
756
- WeakMap2.prototype.delete = function(target) {
757
- var table = GetOrCreateWeakMapTable(
758
- target,
759
- /*create*/
760
- false
761
- );
762
- return table !== void 0 ? delete table[this._key] : false;
763
- };
764
- WeakMap2.prototype.clear = function() {
765
- this._key = CreateUniqueKey();
766
- };
767
- return WeakMap2;
768
- }()
769
- );
770
- function CreateUniqueKey() {
771
- var key;
772
- do
773
- key = "@@WeakMap@@" + CreateUUID();
774
- while (HashMap.has(keys, key));
775
- keys[key] = true;
776
- return key;
777
- }
778
- function GetOrCreateWeakMapTable(target, create) {
779
- if (!hasOwn.call(target, rootKey)) {
780
- if (!create)
781
- return void 0;
782
- Object.defineProperty(target, rootKey, { value: HashMap.create() });
783
- }
784
- return target[rootKey];
785
- }
786
- function FillRandomBytes(buffer, size) {
787
- for (var i = 0; i < size; ++i)
788
- buffer[i] = Math.random() * 255 | 0;
789
- return buffer;
790
- }
791
- function GenRandomBytes(size) {
792
- if (typeof Uint8Array === "function") {
793
- if (typeof crypto !== "undefined")
794
- return crypto.getRandomValues(new Uint8Array(size));
795
- if (typeof msCrypto !== "undefined")
796
- return msCrypto.getRandomValues(new Uint8Array(size));
797
- return FillRandomBytes(new Uint8Array(size), size);
798
- }
799
- return FillRandomBytes(new Array(size), size);
800
- }
801
- function CreateUUID() {
802
- var data = GenRandomBytes(UUID_SIZE);
803
- data[6] = data[6] & 79 | 64;
804
- data[8] = data[8] & 191 | 128;
805
- var result = "";
806
- for (var offset = 0; offset < UUID_SIZE; ++offset) {
807
- var byte = data[offset];
808
- if (offset === 4 || offset === 6 || offset === 8)
809
- result += "-";
810
- if (byte < 16)
811
- result += "0";
812
- result += byte.toString(16).toLowerCase();
248
+ if (options.respectFunctionNames !== false) {
249
+ this.dispatch("function-name:" + String(fn.name));
250
+ }
251
+ if (options.respectFunctionProperties) {
252
+ this._object(fn);
253
+ }
254
+ },
255
+ _number: function(number) {
256
+ return write("number:" + number.toString());
257
+ },
258
+ _xml: function(xml) {
259
+ return write("xml:" + xml.toString());
260
+ },
261
+ _null: function() {
262
+ return write("Null");
263
+ },
264
+ _undefined: function() {
265
+ return write("Undefined");
266
+ },
267
+ _regexp: function(regex) {
268
+ return write("regex:" + regex.toString());
269
+ },
270
+ _uint8array: function(arr) {
271
+ write("uint8array:");
272
+ return this.dispatch(Array.prototype.slice.call(arr));
273
+ },
274
+ _uint8clampedarray: function(arr) {
275
+ write("uint8clampedarray:");
276
+ return this.dispatch(Array.prototype.slice.call(arr));
277
+ },
278
+ _int8array: function(arr) {
279
+ write("uint8array:");
280
+ return this.dispatch(Array.prototype.slice.call(arr));
281
+ },
282
+ _uint16array: function(arr) {
283
+ write("uint16array:");
284
+ return this.dispatch(Array.prototype.slice.call(arr));
285
+ },
286
+ _int16array: function(arr) {
287
+ write("uint16array:");
288
+ return this.dispatch(Array.prototype.slice.call(arr));
289
+ },
290
+ _uint32array: function(arr) {
291
+ write("uint32array:");
292
+ return this.dispatch(Array.prototype.slice.call(arr));
293
+ },
294
+ _int32array: function(arr) {
295
+ write("uint32array:");
296
+ return this.dispatch(Array.prototype.slice.call(arr));
297
+ },
298
+ _float32array: function(arr) {
299
+ write("float32array:");
300
+ return this.dispatch(Array.prototype.slice.call(arr));
301
+ },
302
+ _float64array: function(arr) {
303
+ write("float64array:");
304
+ return this.dispatch(Array.prototype.slice.call(arr));
305
+ },
306
+ _arraybuffer: function(arr) {
307
+ write("arraybuffer:");
308
+ return this.dispatch(new Uint8Array(arr));
309
+ },
310
+ _url: function(url) {
311
+ return write("url:" + url.toString(), "utf8");
312
+ },
313
+ _map: function(map) {
314
+ write("map:");
315
+ var arr = Array.from(map);
316
+ return this._array(arr, options.unorderedSets !== false);
317
+ },
318
+ _set: function(set) {
319
+ write("set:");
320
+ var arr = Array.from(set);
321
+ return this._array(arr, options.unorderedSets !== false);
322
+ },
323
+ _file: function(file) {
324
+ write("file:");
325
+ return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
326
+ },
327
+ _blob: function() {
328
+ if (options.ignoreUnknown) {
329
+ return write("[blob]");
330
+ }
331
+ throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n');
332
+ },
333
+ _domwindow: function() {
334
+ return write("domwindow");
335
+ },
336
+ _bigint: function(number) {
337
+ return write("bigint:" + number.toString());
338
+ },
339
+ /* Node.js standard native objects */
340
+ _process: function() {
341
+ return write("process");
342
+ },
343
+ _timer: function() {
344
+ return write("timer");
345
+ },
346
+ _pipe: function() {
347
+ return write("pipe");
348
+ },
349
+ _tcp: function() {
350
+ return write("tcp");
351
+ },
352
+ _udp: function() {
353
+ return write("udp");
354
+ },
355
+ _tty: function() {
356
+ return write("tty");
357
+ },
358
+ _statwatcher: function() {
359
+ return write("statwatcher");
360
+ },
361
+ _securecontext: function() {
362
+ return write("securecontext");
363
+ },
364
+ _connection: function() {
365
+ return write("connection");
366
+ },
367
+ _zlib: function() {
368
+ return write("zlib");
369
+ },
370
+ _context: function() {
371
+ return write("context");
372
+ },
373
+ _nodescript: function() {
374
+ return write("nodescript");
375
+ },
376
+ _httpparser: function() {
377
+ return write("httpparser");
378
+ },
379
+ _dataview: function() {
380
+ return write("dataview");
381
+ },
382
+ _signal: function() {
383
+ return write("signal");
384
+ },
385
+ _fsevent: function() {
386
+ return write("fsevent");
387
+ },
388
+ _tlswrap: function() {
389
+ return write("tlswrap");
813
390
  }
814
- return result;
815
- }
391
+ };
816
392
  }
817
- function MakeDictionary(obj) {
818
- obj.__ = void 0;
819
- delete obj.__;
820
- return obj;
393
+ function PassThrough() {
394
+ return {
395
+ buf: "",
396
+ write: function(b) {
397
+ this.buf += b;
398
+ },
399
+ end: function(b) {
400
+ this.buf += b;
401
+ },
402
+ read: function() {
403
+ return this.buf;
404
+ }
405
+ };
821
406
  }
822
- });
823
- })(Reflect2 || (Reflect2 = {}));
407
+ }
408
+ });
409
+
410
+ // src/index.ts
411
+ var index_exports = {};
412
+ __export(index_exports, {
413
+ Inject: () => Inject,
414
+ Service: () => Service,
415
+ getInstance: () => getInstance
416
+ });
417
+ module.exports = __toCommonJS(index_exports);
418
+
419
+ // ../helpers/dist/index.js
420
+ var import_object_hash = __toESM(require_object_hash(), 1);
421
+ var import_crypto = __toESM(require("crypto"), 1);
422
+ var UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghjkmnopqrstuvwxyz";
423
+ var hexString = function(digits) {
424
+ var numBytes = Math.ceil(digits / 2);
425
+ var bytes;
426
+ try {
427
+ bytes = import_crypto.default.randomBytes(numBytes);
428
+ } catch (e) {
429
+ bytes = import_crypto.default.pseudoRandomBytes(numBytes);
430
+ }
431
+ var result = bytes.toString("hex");
432
+ return result.substring(0, digits);
433
+ };
434
+ var fraction = function() {
435
+ var numerator = parseInt(hexString(8), 16);
436
+ return numerator * 23283064365386963e-26;
437
+ };
438
+ var choice = function(arrayOrString) {
439
+ var index = Math.floor(fraction() * arrayOrString.length);
440
+ if (typeof arrayOrString === "string") return arrayOrString.substr(index, 1);
441
+ else return arrayOrString[index];
442
+ };
443
+ var randomString = function(charsCount, alphabet) {
444
+ var digits = [];
445
+ for (var i = 0; i < charsCount; i++) {
446
+ digits[i] = choice(alphabet);
447
+ }
448
+ return digits.join("");
449
+ };
450
+ function generateId(charsCount, chars = UNMISTAKABLE_CHARS) {
451
+ if (!charsCount) {
452
+ charsCount = 17;
453
+ }
454
+ return randomString(charsCount, chars);
455
+ }
824
456
 
825
- // src/typedi.ts
826
- var import_typedi = require("typedi");
827
- var import_typedi2 = require("typedi");
828
- function getInstance(service) {
829
- return import_typedi.Container.get(service);
457
+ // src/di.ts
458
+ var instances = /* @__PURE__ */ new Map();
459
+ var serviceMetadata = /* @__PURE__ */ new WeakMap();
460
+ var injectionMetadata = /* @__PURE__ */ new WeakMap();
461
+ function Service() {
462
+ return (_target, context) => {
463
+ serviceMetadata.set(context, {
464
+ id: generateId(12),
465
+ name: context.name
466
+ });
467
+ };
468
+ }
469
+ function Inject(getDependency) {
470
+ return (_, context) => {
471
+ context.addInitializer(function() {
472
+ const metadata = injectionMetadata.get(this) || {};
473
+ metadata[context.name] = getDependency;
474
+ injectionMetadata.set(this, metadata);
475
+ });
476
+ };
477
+ }
478
+ function getInstance(token) {
479
+ if (!instances.has(token)) {
480
+ const instance = new token();
481
+ instances.set(token, instance);
482
+ const injections = injectionMetadata.get(instance);
483
+ if (injections) {
484
+ for (const [propertyKey, getDependency] of Object.entries(injections)) {
485
+ instance[propertyKey] = getInstance(getDependency());
486
+ }
487
+ }
488
+ }
489
+ return instances.get(token);
830
490
  }
831
491
  // Annotate the CommonJS export names for ESM import in node:
832
492
  0 && (module.exports = {
833
- Container,
834
493
  Inject,
835
494
  Service,
836
495
  getInstance
837
496
  });
838
- /*! Bundled license information:
839
-
840
- reflect-metadata/Reflect.js:
841
- (*! *****************************************************************************
842
- Copyright (C) Microsoft. All rights reserved.
843
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
844
- this file except in compliance with the License. You may obtain a copy of the
845
- License at http://www.apache.org/licenses/LICENSE-2.0
846
-
847
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
848
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
849
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
850
- MERCHANTABLITY OR NON-INFRINGEMENT.
851
-
852
- See the Apache Version 2.0 License for specific language governing permissions
853
- and limitations under the License.
854
- ***************************************************************************** *)
855
- */
856
497
  //# sourceMappingURL=index.cjs.map