@h3ravel/config 1.3.7 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,92 +1,1465 @@
1
- import {
2
- ServiceProvider,
3
- __name
4
- } from "./chunk-Q3X4OHHO.js";
5
-
6
- // src/ConfigRepository.ts
1
+ import "node:module";
7
2
  import { safeDot, setNested } from "@h3ravel/support";
8
- import path from "path";
9
- import { readdir } from "fs/promises";
3
+ import path from "node:path";
4
+ import { readdir } from "node:fs/promises";
5
+ import { EnvParser, PathLoader } from "@h3ravel/shared";
6
+ import "node:os";
7
+ import "node:net";
8
+ import { debuglog } from "node:util";
9
+ import "node:child_process";
10
+ import "dotenv";
11
+ import "edge.js";
12
+
13
+ //#region rolldown:runtime
14
+ var __create = Object.create;
15
+ var __defProp = Object.defineProperty;
16
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
+ var __getOwnPropNames = Object.getOwnPropertyNames;
18
+ var __getProtoOf = Object.getPrototypeOf;
19
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
20
+ var __commonJS = (cb, mod) => function() {
21
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
+ key = keys[i];
26
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
34
+ value: mod,
35
+ enumerable: true
36
+ }) : target, mod));
37
+
38
+ //#endregion
39
+ //#region src/ConfigRepository.ts
10
40
  var ConfigRepository = class {
11
- static {
12
- __name(this, "ConfigRepository");
13
- }
14
- app;
15
- loaded = false;
16
- configs = {};
17
- constructor(app) {
18
- this.app = app;
19
- }
20
- get(key, def) {
21
- return safeDot(this.configs, key) ?? def;
22
- }
23
- /**
24
- * Modify the defined configurations
25
- */
26
- set(key, value) {
27
- setNested(this.configs, key, value);
28
- }
29
- async load() {
30
- if (!this.loaded) {
31
- const configPath = this.app.getPath("config");
32
- const files = (await readdir(configPath)).filter((e) => {
33
- return !e.includes(".d.ts") && !e.includes(".map");
34
- });
35
- for (let i = 0; i < files.length; i++) {
36
- const configModule = await import(path.join(configPath, files[i]));
37
- const name = files[i].replaceAll(/\.ts|\.js/g, "");
38
- if (typeof configModule.default === "function") {
39
- this.configs[name] = configModule.default(this.app);
40
- }
41
- }
42
- this.loaded = true;
43
- }
44
- return this;
45
- }
41
+ loaded = false;
42
+ configs = {};
43
+ constructor(app) {
44
+ this.app = app;
45
+ }
46
+ get(key, def) {
47
+ return safeDot(this.configs, key) ?? def;
48
+ }
49
+ /**
50
+ * Modify the defined configurations
51
+ */
52
+ set(key, value) {
53
+ setNested(this.configs, key, value);
54
+ }
55
+ async load() {
56
+ if (!this.loaded) {
57
+ const configPath = this.app.getPath("config");
58
+ const files = (await readdir(configPath)).filter((e) => {
59
+ return !e.includes(".d.ts") && !e.includes(".d.cts") && !e.includes(".map");
60
+ });
61
+ for (let i = 0; i < files.length; i++) {
62
+ const configModule = await import(path.join(configPath, files[i]));
63
+ const name = files[i].replaceAll(/\.ts|\.js/g, "");
64
+ if (typeof configModule.default === "function") this.configs[name] = configModule.default(this.app);
65
+ }
66
+ this.loaded = true;
67
+ }
68
+ return this;
69
+ }
46
70
  };
47
71
 
48
- // src/EnvLoader.ts
49
- import { safeDot as safeDot2 } from "@h3ravel/support";
72
+ //#endregion
73
+ //#region src/EnvLoader.ts
50
74
  var EnvLoader = class {
51
- static {
52
- __name(this, "EnvLoader");
53
- }
54
- _app;
55
- constructor(_app) {
56
- this._app = _app;
57
- }
58
- get(key, def) {
59
- return safeDot2(process.env, key) ?? def;
60
- }
75
+ constructor(_app) {
76
+ this._app = _app;
77
+ }
78
+ get(key, def) {
79
+ return safeDot(EnvParser.parse(process.env), key) ?? def;
80
+ }
61
81
  };
62
82
 
63
- // src/Providers/ConfigServiceProvider.ts
64
- var ConfigServiceProvider = class extends ServiceProvider {
65
- static {
66
- __name(this, "ConfigServiceProvider");
67
- }
68
- static priority = 998;
69
- // public static order = 'before:CoreServiceProvider';
70
- async register() {
71
- this.app.singleton("env", () => {
72
- return new EnvLoader(this.app).get;
73
- });
74
- const repo = new ConfigRepository(this.app);
75
- await repo.load();
76
- this.app.singleton("config", () => {
77
- return {
78
- get: /* @__PURE__ */ __name((key, def) => repo.get(key, def), "get"),
79
- set: repo.set
80
- };
81
- });
82
- this.app.make("http.app").use((e) => {
83
- repo.set("app.url", e.url.origin);
84
- });
85
- }
83
+ //#endregion
84
+ //#region src/Helpers.ts
85
+ var Helpers = class {};
86
+
87
+ //#endregion
88
+ //#region ../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
89
+ var require_Reflect = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js": (() => {
90
+ /*! *****************************************************************************
91
+ Copyright (C) Microsoft. All rights reserved.
92
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
93
+ this file except in compliance with the License. You may obtain a copy of the
94
+ License at http://www.apache.org/licenses/LICENSE-2.0
95
+
96
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
97
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
98
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
99
+ MERCHANTABLITY OR NON-INFRINGEMENT.
100
+
101
+ See the Apache Version 2.0 License for specific language governing permissions
102
+ and limitations under the License.
103
+ ***************************************************************************** */
104
+ var Reflect$1;
105
+ (function(Reflect$2) {
106
+ (function(factory) {
107
+ var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
108
+ var exporter = makeExporter(Reflect$2);
109
+ if (typeof root.Reflect !== "undefined") exporter = makeExporter(root.Reflect, exporter);
110
+ factory(exporter, root);
111
+ if (typeof root.Reflect === "undefined") root.Reflect = Reflect$2;
112
+ function makeExporter(target, previous) {
113
+ return function(key, value) {
114
+ Object.defineProperty(target, key, {
115
+ configurable: true,
116
+ writable: true,
117
+ value
118
+ });
119
+ if (previous) previous(key, value);
120
+ };
121
+ }
122
+ function functionThis() {
123
+ try {
124
+ return Function("return this;")();
125
+ } catch (_) {}
126
+ }
127
+ function indirectEvalThis() {
128
+ try {
129
+ return (0, eval)("(function() { return this; })()");
130
+ } catch (_) {}
131
+ }
132
+ function sloppyModeThis() {
133
+ return functionThis() || indirectEvalThis();
134
+ }
135
+ })(function(exporter, root) {
136
+ var hasOwn = Object.prototype.hasOwnProperty;
137
+ var supportsSymbol = typeof Symbol === "function";
138
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
139
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
140
+ var supportsCreate = typeof Object.create === "function";
141
+ var supportsProto = { __proto__: [] } instanceof Array;
142
+ var downLevel = !supportsCreate && !supportsProto;
143
+ var HashMap = {
144
+ create: supportsCreate ? function() {
145
+ return MakeDictionary(Object.create(null));
146
+ } : supportsProto ? function() {
147
+ return MakeDictionary({ __proto__: null });
148
+ } : function() {
149
+ return MakeDictionary({});
150
+ },
151
+ has: downLevel ? function(map, key) {
152
+ return hasOwn.call(map, key);
153
+ } : function(map, key) {
154
+ return key in map;
155
+ },
156
+ get: downLevel ? function(map, key) {
157
+ return hasOwn.call(map, key) ? map[key] : void 0;
158
+ } : function(map, key) {
159
+ return map[key];
160
+ }
161
+ };
162
+ var functionPrototype = Object.getPrototypeOf(Function);
163
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
164
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
165
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
166
+ var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
167
+ var metadataRegistry = GetOrCreateMetadataRegistry();
168
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
169
+ /**
170
+ * Applies a set of decorators to a property of a target object.
171
+ * @param decorators An array of decorators.
172
+ * @param target The target object.
173
+ * @param propertyKey (Optional) The property key to decorate.
174
+ * @param attributes (Optional) The property descriptor for the target key.
175
+ * @remarks Decorators are applied in reverse order.
176
+ * @example
177
+ *
178
+ * class Example {
179
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
180
+ * // static staticProperty;
181
+ * // property;
182
+ *
183
+ * constructor(p) { }
184
+ * static staticMethod(p) { }
185
+ * method(p) { }
186
+ * }
187
+ *
188
+ * // constructor
189
+ * Example = Reflect.decorate(decoratorsArray, Example);
190
+ *
191
+ * // property (on constructor)
192
+ * Reflect.decorate(decoratorsArray, Example, "staticProperty");
193
+ *
194
+ * // property (on prototype)
195
+ * Reflect.decorate(decoratorsArray, Example.prototype, "property");
196
+ *
197
+ * // method (on constructor)
198
+ * Object.defineProperty(Example, "staticMethod",
199
+ * Reflect.decorate(decoratorsArray, Example, "staticMethod",
200
+ * Object.getOwnPropertyDescriptor(Example, "staticMethod")));
201
+ *
202
+ * // method (on prototype)
203
+ * Object.defineProperty(Example.prototype, "method",
204
+ * Reflect.decorate(decoratorsArray, Example.prototype, "method",
205
+ * Object.getOwnPropertyDescriptor(Example.prototype, "method")));
206
+ *
207
+ */
208
+ function decorate(decorators, target, propertyKey, attributes) {
209
+ if (!IsUndefined(propertyKey)) {
210
+ if (!IsArray(decorators)) throw new TypeError();
211
+ if (!IsObject(target)) throw new TypeError();
212
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes)) throw new TypeError();
213
+ if (IsNull(attributes)) attributes = void 0;
214
+ propertyKey = ToPropertyKey(propertyKey);
215
+ return DecorateProperty(decorators, target, propertyKey, attributes);
216
+ } else {
217
+ if (!IsArray(decorators)) throw new TypeError();
218
+ if (!IsConstructor(target)) throw new TypeError();
219
+ return DecorateConstructor(decorators, target);
220
+ }
221
+ }
222
+ exporter("decorate", decorate);
223
+ /**
224
+ * A default metadata decorator factory that can be used on a class, class member, or parameter.
225
+ * @param metadataKey The key for the metadata entry.
226
+ * @param metadataValue The value for the metadata entry.
227
+ * @returns A decorator function.
228
+ * @remarks
229
+ * If `metadataKey` is already defined for the target and target key, the
230
+ * metadataValue for that key will be overwritten.
231
+ * @example
232
+ *
233
+ * // constructor
234
+ * @Reflect.metadata(key, value)
235
+ * class Example {
236
+ * }
237
+ *
238
+ * // property (on constructor, TypeScript only)
239
+ * class Example {
240
+ * @Reflect.metadata(key, value)
241
+ * static staticProperty;
242
+ * }
243
+ *
244
+ * // property (on prototype, TypeScript only)
245
+ * class Example {
246
+ * @Reflect.metadata(key, value)
247
+ * property;
248
+ * }
249
+ *
250
+ * // method (on constructor)
251
+ * class Example {
252
+ * @Reflect.metadata(key, value)
253
+ * static staticMethod() { }
254
+ * }
255
+ *
256
+ * // method (on prototype)
257
+ * class Example {
258
+ * @Reflect.metadata(key, value)
259
+ * method() { }
260
+ * }
261
+ *
262
+ */
263
+ function metadata(metadataKey, metadataValue) {
264
+ function decorator(target, propertyKey) {
265
+ if (!IsObject(target)) throw new TypeError();
266
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey)) throw new TypeError();
267
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
268
+ }
269
+ return decorator;
270
+ }
271
+ exporter("metadata", metadata);
272
+ /**
273
+ * Define a unique metadata entry on the target.
274
+ * @param metadataKey A key used to store and retrieve metadata.
275
+ * @param metadataValue A value that contains attached metadata.
276
+ * @param target The target object on which to define metadata.
277
+ * @param propertyKey (Optional) The property key for the target.
278
+ * @example
279
+ *
280
+ * class Example {
281
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
282
+ * // static staticProperty;
283
+ * // property;
284
+ *
285
+ * constructor(p) { }
286
+ * static staticMethod(p) { }
287
+ * method(p) { }
288
+ * }
289
+ *
290
+ * // constructor
291
+ * Reflect.defineMetadata("custom:annotation", options, Example);
292
+ *
293
+ * // property (on constructor)
294
+ * Reflect.defineMetadata("custom:annotation", options, Example, "staticProperty");
295
+ *
296
+ * // property (on prototype)
297
+ * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "property");
298
+ *
299
+ * // method (on constructor)
300
+ * Reflect.defineMetadata("custom:annotation", options, Example, "staticMethod");
301
+ *
302
+ * // method (on prototype)
303
+ * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "method");
304
+ *
305
+ * // decorator factory as metadata-producing annotation.
306
+ * function MyAnnotation(options): Decorator {
307
+ * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
308
+ * }
309
+ *
310
+ */
311
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
312
+ if (!IsObject(target)) throw new TypeError();
313
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
314
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
315
+ }
316
+ exporter("defineMetadata", defineMetadata);
317
+ /**
318
+ * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
319
+ * @param metadataKey A key used to store and retrieve metadata.
320
+ * @param target The target object on which the metadata is defined.
321
+ * @param propertyKey (Optional) The property key for the target.
322
+ * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
323
+ * @example
324
+ *
325
+ * class Example {
326
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
327
+ * // static staticProperty;
328
+ * // property;
329
+ *
330
+ * constructor(p) { }
331
+ * static staticMethod(p) { }
332
+ * method(p) { }
333
+ * }
334
+ *
335
+ * // constructor
336
+ * result = Reflect.hasMetadata("custom:annotation", Example);
337
+ *
338
+ * // property (on constructor)
339
+ * result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty");
340
+ *
341
+ * // property (on prototype)
342
+ * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property");
343
+ *
344
+ * // method (on constructor)
345
+ * result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod");
346
+ *
347
+ * // method (on prototype)
348
+ * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method");
349
+ *
350
+ */
351
+ function hasMetadata(metadataKey, target, propertyKey) {
352
+ if (!IsObject(target)) throw new TypeError();
353
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
354
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
355
+ }
356
+ exporter("hasMetadata", hasMetadata);
357
+ /**
358
+ * Gets a value indicating whether the target object has the provided metadata key defined.
359
+ * @param metadataKey A key used to store and retrieve metadata.
360
+ * @param target The target object on which the metadata is defined.
361
+ * @param propertyKey (Optional) The property key for the target.
362
+ * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
363
+ * @example
364
+ *
365
+ * class Example {
366
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
367
+ * // static staticProperty;
368
+ * // property;
369
+ *
370
+ * constructor(p) { }
371
+ * static staticMethod(p) { }
372
+ * method(p) { }
373
+ * }
374
+ *
375
+ * // constructor
376
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example);
377
+ *
378
+ * // property (on constructor)
379
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty");
380
+ *
381
+ * // property (on prototype)
382
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property");
383
+ *
384
+ * // method (on constructor)
385
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod");
386
+ *
387
+ * // method (on prototype)
388
+ * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method");
389
+ *
390
+ */
391
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
392
+ if (!IsObject(target)) throw new TypeError();
393
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
394
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
395
+ }
396
+ exporter("hasOwnMetadata", hasOwnMetadata);
397
+ /**
398
+ * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
399
+ * @param metadataKey A key used to store and retrieve metadata.
400
+ * @param target The target object on which the metadata is defined.
401
+ * @param propertyKey (Optional) The property key for the target.
402
+ * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
403
+ * @example
404
+ *
405
+ * class Example {
406
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
407
+ * // static staticProperty;
408
+ * // property;
409
+ *
410
+ * constructor(p) { }
411
+ * static staticMethod(p) { }
412
+ * method(p) { }
413
+ * }
414
+ *
415
+ * // constructor
416
+ * result = Reflect.getMetadata("custom:annotation", Example);
417
+ *
418
+ * // property (on constructor)
419
+ * result = Reflect.getMetadata("custom:annotation", Example, "staticProperty");
420
+ *
421
+ * // property (on prototype)
422
+ * result = Reflect.getMetadata("custom:annotation", Example.prototype, "property");
423
+ *
424
+ * // method (on constructor)
425
+ * result = Reflect.getMetadata("custom:annotation", Example, "staticMethod");
426
+ *
427
+ * // method (on prototype)
428
+ * result = Reflect.getMetadata("custom:annotation", Example.prototype, "method");
429
+ *
430
+ */
431
+ function getMetadata(metadataKey, target, propertyKey) {
432
+ if (!IsObject(target)) throw new TypeError();
433
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
434
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
435
+ }
436
+ exporter("getMetadata", getMetadata);
437
+ /**
438
+ * Gets the metadata value for the provided metadata key on the target object.
439
+ * @param metadataKey A key used to store and retrieve metadata.
440
+ * @param target The target object on which the metadata is defined.
441
+ * @param propertyKey (Optional) The property key for the target.
442
+ * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
443
+ * @example
444
+ *
445
+ * class Example {
446
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
447
+ * // static staticProperty;
448
+ * // property;
449
+ *
450
+ * constructor(p) { }
451
+ * static staticMethod(p) { }
452
+ * method(p) { }
453
+ * }
454
+ *
455
+ * // constructor
456
+ * result = Reflect.getOwnMetadata("custom:annotation", Example);
457
+ *
458
+ * // property (on constructor)
459
+ * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty");
460
+ *
461
+ * // property (on prototype)
462
+ * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property");
463
+ *
464
+ * // method (on constructor)
465
+ * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod");
466
+ *
467
+ * // method (on prototype)
468
+ * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method");
469
+ *
470
+ */
471
+ function getOwnMetadata(metadataKey, target, propertyKey) {
472
+ if (!IsObject(target)) throw new TypeError();
473
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
474
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
475
+ }
476
+ exporter("getOwnMetadata", getOwnMetadata);
477
+ /**
478
+ * Gets the metadata keys defined on the target object or its prototype chain.
479
+ * @param target The target object on which the metadata is defined.
480
+ * @param propertyKey (Optional) The property key for the target.
481
+ * @returns An array of unique metadata keys.
482
+ * @example
483
+ *
484
+ * class Example {
485
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
486
+ * // static staticProperty;
487
+ * // property;
488
+ *
489
+ * constructor(p) { }
490
+ * static staticMethod(p) { }
491
+ * method(p) { }
492
+ * }
493
+ *
494
+ * // constructor
495
+ * result = Reflect.getMetadataKeys(Example);
496
+ *
497
+ * // property (on constructor)
498
+ * result = Reflect.getMetadataKeys(Example, "staticProperty");
499
+ *
500
+ * // property (on prototype)
501
+ * result = Reflect.getMetadataKeys(Example.prototype, "property");
502
+ *
503
+ * // method (on constructor)
504
+ * result = Reflect.getMetadataKeys(Example, "staticMethod");
505
+ *
506
+ * // method (on prototype)
507
+ * result = Reflect.getMetadataKeys(Example.prototype, "method");
508
+ *
509
+ */
510
+ function getMetadataKeys(target, propertyKey) {
511
+ if (!IsObject(target)) throw new TypeError();
512
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
513
+ return OrdinaryMetadataKeys(target, propertyKey);
514
+ }
515
+ exporter("getMetadataKeys", getMetadataKeys);
516
+ /**
517
+ * Gets the unique metadata keys defined on the target object.
518
+ * @param target The target object on which the metadata is defined.
519
+ * @param propertyKey (Optional) The property key for the target.
520
+ * @returns An array of unique metadata keys.
521
+ * @example
522
+ *
523
+ * class Example {
524
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
525
+ * // static staticProperty;
526
+ * // property;
527
+ *
528
+ * constructor(p) { }
529
+ * static staticMethod(p) { }
530
+ * method(p) { }
531
+ * }
532
+ *
533
+ * // constructor
534
+ * result = Reflect.getOwnMetadataKeys(Example);
535
+ *
536
+ * // property (on constructor)
537
+ * result = Reflect.getOwnMetadataKeys(Example, "staticProperty");
538
+ *
539
+ * // property (on prototype)
540
+ * result = Reflect.getOwnMetadataKeys(Example.prototype, "property");
541
+ *
542
+ * // method (on constructor)
543
+ * result = Reflect.getOwnMetadataKeys(Example, "staticMethod");
544
+ *
545
+ * // method (on prototype)
546
+ * result = Reflect.getOwnMetadataKeys(Example.prototype, "method");
547
+ *
548
+ */
549
+ function getOwnMetadataKeys(target, propertyKey) {
550
+ if (!IsObject(target)) throw new TypeError();
551
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
552
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
553
+ }
554
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
555
+ /**
556
+ * Deletes the metadata entry from the target object with the provided key.
557
+ * @param metadataKey A key used to store and retrieve metadata.
558
+ * @param target The target object on which the metadata is defined.
559
+ * @param propertyKey (Optional) The property key for the target.
560
+ * @returns `true` if the metadata entry was found and deleted; otherwise, false.
561
+ * @example
562
+ *
563
+ * class Example {
564
+ * // property declarations are not part of ES6, though they are valid in TypeScript:
565
+ * // static staticProperty;
566
+ * // property;
567
+ *
568
+ * constructor(p) { }
569
+ * static staticMethod(p) { }
570
+ * method(p) { }
571
+ * }
572
+ *
573
+ * // constructor
574
+ * result = Reflect.deleteMetadata("custom:annotation", Example);
575
+ *
576
+ * // property (on constructor)
577
+ * result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty");
578
+ *
579
+ * // property (on prototype)
580
+ * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property");
581
+ *
582
+ * // method (on constructor)
583
+ * result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod");
584
+ *
585
+ * // method (on prototype)
586
+ * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method");
587
+ *
588
+ */
589
+ function deleteMetadata(metadataKey, target, propertyKey) {
590
+ if (!IsObject(target)) throw new TypeError();
591
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
592
+ if (!IsObject(target)) throw new TypeError();
593
+ if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
594
+ var provider = GetMetadataProvider(target, propertyKey, false);
595
+ if (IsUndefined(provider)) return false;
596
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
597
+ }
598
+ exporter("deleteMetadata", deleteMetadata);
599
+ function DecorateConstructor(decorators, target) {
600
+ for (var i = decorators.length - 1; i >= 0; --i) {
601
+ var decorator = decorators[i];
602
+ var decorated = decorator(target);
603
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
604
+ if (!IsConstructor(decorated)) throw new TypeError();
605
+ target = decorated;
606
+ }
607
+ }
608
+ return target;
609
+ }
610
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
611
+ for (var i = decorators.length - 1; i >= 0; --i) {
612
+ var decorator = decorators[i];
613
+ var decorated = decorator(target, propertyKey, descriptor);
614
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
615
+ if (!IsObject(decorated)) throw new TypeError();
616
+ descriptor = decorated;
617
+ }
618
+ }
619
+ return descriptor;
620
+ }
621
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
622
+ if (OrdinaryHasOwnMetadata(MetadataKey, O, P)) return true;
623
+ var parent = OrdinaryGetPrototypeOf(O);
624
+ if (!IsNull(parent)) return OrdinaryHasMetadata(MetadataKey, parent, P);
625
+ return false;
626
+ }
627
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
628
+ var provider = GetMetadataProvider(O, P, false);
629
+ if (IsUndefined(provider)) return false;
630
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
631
+ }
632
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
633
+ if (OrdinaryHasOwnMetadata(MetadataKey, O, P)) return OrdinaryGetOwnMetadata(MetadataKey, O, P);
634
+ var parent = OrdinaryGetPrototypeOf(O);
635
+ if (!IsNull(parent)) return OrdinaryGetMetadata(MetadataKey, parent, P);
636
+ }
637
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
638
+ var provider = GetMetadataProvider(O, P, false);
639
+ if (IsUndefined(provider)) return;
640
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
641
+ }
642
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
643
+ GetMetadataProvider(O, P, true).OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
644
+ }
645
+ function OrdinaryMetadataKeys(O, P) {
646
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
647
+ var parent = OrdinaryGetPrototypeOf(O);
648
+ if (parent === null) return ownKeys;
649
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
650
+ if (parentKeys.length <= 0) return ownKeys;
651
+ if (ownKeys.length <= 0) return parentKeys;
652
+ var set = new _Set();
653
+ var keys = [];
654
+ for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
655
+ var key = ownKeys_1[_i];
656
+ var hasKey = set.has(key);
657
+ if (!hasKey) {
658
+ set.add(key);
659
+ keys.push(key);
660
+ }
661
+ }
662
+ for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
663
+ var key = parentKeys_1[_a];
664
+ var hasKey = set.has(key);
665
+ if (!hasKey) {
666
+ set.add(key);
667
+ keys.push(key);
668
+ }
669
+ }
670
+ return keys;
671
+ }
672
+ function OrdinaryOwnMetadataKeys(O, P) {
673
+ var provider = GetMetadataProvider(O, P, false);
674
+ if (!provider) return [];
675
+ return provider.OrdinaryOwnMetadataKeys(O, P);
676
+ }
677
+ function Type(x) {
678
+ if (x === null) return 1;
679
+ switch (typeof x) {
680
+ case "undefined": return 0;
681
+ case "boolean": return 2;
682
+ case "string": return 3;
683
+ case "symbol": return 4;
684
+ case "number": return 5;
685
+ case "object": return x === null ? 1 : 6;
686
+ default: return 6;
687
+ }
688
+ }
689
+ function IsUndefined(x) {
690
+ return x === void 0;
691
+ }
692
+ function IsNull(x) {
693
+ return x === null;
694
+ }
695
+ function IsSymbol(x) {
696
+ return typeof x === "symbol";
697
+ }
698
+ function IsObject(x) {
699
+ return typeof x === "object" ? x !== null : typeof x === "function";
700
+ }
701
+ function ToPrimitive(input, PreferredType) {
702
+ switch (Type(input)) {
703
+ case 0: return input;
704
+ case 1: return input;
705
+ case 2: return input;
706
+ case 3: return input;
707
+ case 4: return input;
708
+ case 5: return input;
709
+ }
710
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
711
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
712
+ if (exoticToPrim !== void 0) {
713
+ var result = exoticToPrim.call(input, hint);
714
+ if (IsObject(result)) throw new TypeError();
715
+ return result;
716
+ }
717
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
718
+ }
719
+ function OrdinaryToPrimitive(O, hint) {
720
+ if (hint === "string") {
721
+ var toString_1 = O.toString;
722
+ if (IsCallable(toString_1)) {
723
+ var result = toString_1.call(O);
724
+ if (!IsObject(result)) return result;
725
+ }
726
+ var valueOf = O.valueOf;
727
+ if (IsCallable(valueOf)) {
728
+ var result = valueOf.call(O);
729
+ if (!IsObject(result)) return result;
730
+ }
731
+ } else {
732
+ var valueOf = O.valueOf;
733
+ if (IsCallable(valueOf)) {
734
+ var result = valueOf.call(O);
735
+ if (!IsObject(result)) return result;
736
+ }
737
+ var toString_2 = O.toString;
738
+ if (IsCallable(toString_2)) {
739
+ var result = toString_2.call(O);
740
+ if (!IsObject(result)) return result;
741
+ }
742
+ }
743
+ throw new TypeError();
744
+ }
745
+ function ToBoolean(argument) {
746
+ return !!argument;
747
+ }
748
+ function ToString(argument) {
749
+ return "" + argument;
750
+ }
751
+ function ToPropertyKey(argument) {
752
+ var key = ToPrimitive(argument, 3);
753
+ if (IsSymbol(key)) return key;
754
+ return ToString(key);
755
+ }
756
+ function IsArray(argument) {
757
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
758
+ }
759
+ function IsCallable(argument) {
760
+ return typeof argument === "function";
761
+ }
762
+ function IsConstructor(argument) {
763
+ return typeof argument === "function";
764
+ }
765
+ function IsPropertyKey(argument) {
766
+ switch (Type(argument)) {
767
+ case 3: return true;
768
+ case 4: return true;
769
+ default: return false;
770
+ }
771
+ }
772
+ function SameValueZero(x, y) {
773
+ return x === y || x !== x && y !== y;
774
+ }
775
+ function GetMethod(V, P) {
776
+ var func = V[P];
777
+ if (func === void 0 || func === null) return void 0;
778
+ if (!IsCallable(func)) throw new TypeError();
779
+ return func;
780
+ }
781
+ function GetIterator(obj) {
782
+ var method = GetMethod(obj, iteratorSymbol);
783
+ if (!IsCallable(method)) throw new TypeError();
784
+ var iterator = method.call(obj);
785
+ if (!IsObject(iterator)) throw new TypeError();
786
+ return iterator;
787
+ }
788
+ function IteratorValue(iterResult) {
789
+ return iterResult.value;
790
+ }
791
+ function IteratorStep(iterator) {
792
+ var result = iterator.next();
793
+ return result.done ? false : result;
794
+ }
795
+ function IteratorClose(iterator) {
796
+ var f = iterator["return"];
797
+ if (f) f.call(iterator);
798
+ }
799
+ function OrdinaryGetPrototypeOf(O) {
800
+ var proto = Object.getPrototypeOf(O);
801
+ if (typeof O !== "function" || O === functionPrototype) return proto;
802
+ if (proto !== functionPrototype) return proto;
803
+ var prototype = O.prototype;
804
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
805
+ if (prototypeProto == null || prototypeProto === Object.prototype) return proto;
806
+ var constructor = prototypeProto.constructor;
807
+ if (typeof constructor !== "function") return proto;
808
+ if (constructor === O) return proto;
809
+ return constructor;
810
+ }
811
+ /**
812
+ * Creates a registry used to allow multiple `reflect-metadata` providers.
813
+ */
814
+ function CreateMetadataRegistry() {
815
+ var fallback;
816
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") fallback = CreateFallbackProvider(root.Reflect);
817
+ var first;
818
+ var second;
819
+ var rest;
820
+ var targetProviderMap = new _WeakMap();
821
+ var registry = {
822
+ registerProvider,
823
+ getProvider,
824
+ setProvider
825
+ };
826
+ return registry;
827
+ function registerProvider(provider) {
828
+ if (!Object.isExtensible(registry)) throw new Error("Cannot add provider to a frozen registry.");
829
+ switch (true) {
830
+ case fallback === provider: break;
831
+ case IsUndefined(first):
832
+ first = provider;
833
+ break;
834
+ case first === provider: break;
835
+ case IsUndefined(second):
836
+ second = provider;
837
+ break;
838
+ case second === provider: break;
839
+ default:
840
+ if (rest === void 0) rest = new _Set();
841
+ rest.add(provider);
842
+ break;
843
+ }
844
+ }
845
+ function getProviderNoCache(O, P) {
846
+ if (!IsUndefined(first)) {
847
+ if (first.isProviderFor(O, P)) return first;
848
+ if (!IsUndefined(second)) {
849
+ if (second.isProviderFor(O, P)) return first;
850
+ if (!IsUndefined(rest)) {
851
+ var iterator = GetIterator(rest);
852
+ while (true) {
853
+ var next = IteratorStep(iterator);
854
+ if (!next) return;
855
+ var provider = IteratorValue(next);
856
+ if (provider.isProviderFor(O, P)) {
857
+ IteratorClose(iterator);
858
+ return provider;
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) return fallback;
865
+ }
866
+ function getProvider(O, P) {
867
+ var providerMap = targetProviderMap.get(O);
868
+ var provider;
869
+ if (!IsUndefined(providerMap)) provider = providerMap.get(P);
870
+ if (!IsUndefined(provider)) return provider;
871
+ provider = getProviderNoCache(O, P);
872
+ if (!IsUndefined(provider)) {
873
+ if (IsUndefined(providerMap)) {
874
+ providerMap = new _Map();
875
+ targetProviderMap.set(O, providerMap);
876
+ }
877
+ providerMap.set(P, provider);
878
+ }
879
+ return provider;
880
+ }
881
+ function hasProvider(provider) {
882
+ if (IsUndefined(provider)) throw new TypeError();
883
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
884
+ }
885
+ function setProvider(O, P, provider) {
886
+ if (!hasProvider(provider)) throw new Error("Metadata provider not registered.");
887
+ var existingProvider = getProvider(O, P);
888
+ if (existingProvider !== provider) {
889
+ if (!IsUndefined(existingProvider)) return false;
890
+ var providerMap = targetProviderMap.get(O);
891
+ if (IsUndefined(providerMap)) {
892
+ providerMap = new _Map();
893
+ targetProviderMap.set(O, providerMap);
894
+ }
895
+ providerMap.set(P, provider);
896
+ }
897
+ return true;
898
+ }
899
+ }
900
+ /**
901
+ * Gets or creates the shared registry of metadata providers.
902
+ */
903
+ function GetOrCreateMetadataRegistry() {
904
+ var metadataRegistry$1;
905
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) metadataRegistry$1 = root.Reflect[registrySymbol];
906
+ if (IsUndefined(metadataRegistry$1)) metadataRegistry$1 = CreateMetadataRegistry();
907
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) Object.defineProperty(root.Reflect, registrySymbol, {
908
+ enumerable: false,
909
+ configurable: false,
910
+ writable: false,
911
+ value: metadataRegistry$1
912
+ });
913
+ return metadataRegistry$1;
914
+ }
915
+ function CreateMetadataProvider(registry) {
916
+ var metadata$1 = new _WeakMap();
917
+ var provider = {
918
+ isProviderFor: function(O, P) {
919
+ var targetMetadata = metadata$1.get(O);
920
+ if (IsUndefined(targetMetadata)) return false;
921
+ return targetMetadata.has(P);
922
+ },
923
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata$1,
924
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata$1,
925
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata$1,
926
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys$1,
927
+ OrdinaryDeleteMetadata
928
+ };
929
+ metadataRegistry.registerProvider(provider);
930
+ return provider;
931
+ function GetOrCreateMetadataMap(O, P, Create) {
932
+ var targetMetadata = metadata$1.get(O);
933
+ var createdTargetMetadata = false;
934
+ if (IsUndefined(targetMetadata)) {
935
+ if (!Create) return void 0;
936
+ targetMetadata = new _Map();
937
+ metadata$1.set(O, targetMetadata);
938
+ createdTargetMetadata = true;
939
+ }
940
+ var metadataMap = targetMetadata.get(P);
941
+ if (IsUndefined(metadataMap)) {
942
+ if (!Create) return void 0;
943
+ metadataMap = new _Map();
944
+ targetMetadata.set(P, metadataMap);
945
+ if (!registry.setProvider(O, P, provider)) {
946
+ targetMetadata.delete(P);
947
+ if (createdTargetMetadata) metadata$1.delete(O);
948
+ throw new Error("Wrong provider for target.");
949
+ }
950
+ }
951
+ return metadataMap;
952
+ }
953
+ function OrdinaryHasOwnMetadata$1(MetadataKey, O, P) {
954
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
955
+ if (IsUndefined(metadataMap)) return false;
956
+ return ToBoolean(metadataMap.has(MetadataKey));
957
+ }
958
+ function OrdinaryGetOwnMetadata$1(MetadataKey, O, P) {
959
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
960
+ if (IsUndefined(metadataMap)) return void 0;
961
+ return metadataMap.get(MetadataKey);
962
+ }
963
+ function OrdinaryDefineOwnMetadata$1(MetadataKey, MetadataValue, O, P) {
964
+ GetOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
965
+ }
966
+ function OrdinaryOwnMetadataKeys$1(O, P) {
967
+ var keys = [];
968
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
969
+ if (IsUndefined(metadataMap)) return keys;
970
+ var keysObj = metadataMap.keys();
971
+ var iterator = GetIterator(keysObj);
972
+ var k = 0;
973
+ while (true) {
974
+ var next = IteratorStep(iterator);
975
+ if (!next) {
976
+ keys.length = k;
977
+ return keys;
978
+ }
979
+ var nextValue = IteratorValue(next);
980
+ try {
981
+ keys[k] = nextValue;
982
+ } catch (e) {
983
+ try {
984
+ IteratorClose(iterator);
985
+ } finally {
986
+ throw e;
987
+ }
988
+ }
989
+ k++;
990
+ }
991
+ }
992
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
993
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
994
+ if (IsUndefined(metadataMap)) return false;
995
+ if (!metadataMap.delete(MetadataKey)) return false;
996
+ if (metadataMap.size === 0) {
997
+ var targetMetadata = metadata$1.get(O);
998
+ if (!IsUndefined(targetMetadata)) {
999
+ targetMetadata.delete(P);
1000
+ if (targetMetadata.size === 0) metadata$1.delete(targetMetadata);
1001
+ }
1002
+ }
1003
+ return true;
1004
+ }
1005
+ }
1006
+ function CreateFallbackProvider(reflect) {
1007
+ var defineMetadata$1 = reflect.defineMetadata, hasOwnMetadata$1 = reflect.hasOwnMetadata, getOwnMetadata$1 = reflect.getOwnMetadata, getOwnMetadataKeys$1 = reflect.getOwnMetadataKeys, deleteMetadata$1 = reflect.deleteMetadata;
1008
+ var metadataOwner = new _WeakMap();
1009
+ return {
1010
+ isProviderFor: function(O, P) {
1011
+ var metadataPropertySet = metadataOwner.get(O);
1012
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) return true;
1013
+ if (getOwnMetadataKeys$1(O, P).length) {
1014
+ if (IsUndefined(metadataPropertySet)) {
1015
+ metadataPropertySet = new _Set();
1016
+ metadataOwner.set(O, metadataPropertySet);
1017
+ }
1018
+ metadataPropertySet.add(P);
1019
+ return true;
1020
+ }
1021
+ return false;
1022
+ },
1023
+ OrdinaryDefineOwnMetadata: defineMetadata$1,
1024
+ OrdinaryHasOwnMetadata: hasOwnMetadata$1,
1025
+ OrdinaryGetOwnMetadata: getOwnMetadata$1,
1026
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys$1,
1027
+ OrdinaryDeleteMetadata: deleteMetadata$1
1028
+ };
1029
+ }
1030
+ /**
1031
+ * Gets the metadata provider for an object. If the object has no metadata provider and this is for a create operation,
1032
+ * then this module's metadata provider is assigned to the object.
1033
+ */
1034
+ function GetMetadataProvider(O, P, Create) {
1035
+ var registeredProvider = metadataRegistry.getProvider(O, P);
1036
+ if (!IsUndefined(registeredProvider)) return registeredProvider;
1037
+ if (Create) {
1038
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) return metadataProvider;
1039
+ throw new Error("Illegal state.");
1040
+ }
1041
+ }
1042
+ function CreateMapPolyfill() {
1043
+ var cacheSentinel = {};
1044
+ var arraySentinel = [];
1045
+ var MapIterator = function() {
1046
+ function MapIterator$1(keys, values, selector) {
1047
+ this._index = 0;
1048
+ this._keys = keys;
1049
+ this._values = values;
1050
+ this._selector = selector;
1051
+ }
1052
+ MapIterator$1.prototype["@@iterator"] = function() {
1053
+ return this;
1054
+ };
1055
+ MapIterator$1.prototype[iteratorSymbol] = function() {
1056
+ return this;
1057
+ };
1058
+ MapIterator$1.prototype.next = function() {
1059
+ var index = this._index;
1060
+ if (index >= 0 && index < this._keys.length) {
1061
+ var result = this._selector(this._keys[index], this._values[index]);
1062
+ if (index + 1 >= this._keys.length) {
1063
+ this._index = -1;
1064
+ this._keys = arraySentinel;
1065
+ this._values = arraySentinel;
1066
+ } else this._index++;
1067
+ return {
1068
+ value: result,
1069
+ done: false
1070
+ };
1071
+ }
1072
+ return {
1073
+ value: void 0,
1074
+ done: true
1075
+ };
1076
+ };
1077
+ MapIterator$1.prototype.throw = function(error) {
1078
+ if (this._index >= 0) {
1079
+ this._index = -1;
1080
+ this._keys = arraySentinel;
1081
+ this._values = arraySentinel;
1082
+ }
1083
+ throw error;
1084
+ };
1085
+ MapIterator$1.prototype.return = function(value) {
1086
+ if (this._index >= 0) {
1087
+ this._index = -1;
1088
+ this._keys = arraySentinel;
1089
+ this._values = arraySentinel;
1090
+ }
1091
+ return {
1092
+ value,
1093
+ done: true
1094
+ };
1095
+ };
1096
+ return MapIterator$1;
1097
+ }();
1098
+ return function() {
1099
+ function Map$1() {
1100
+ this._keys = [];
1101
+ this._values = [];
1102
+ this._cacheKey = cacheSentinel;
1103
+ this._cacheIndex = -2;
1104
+ }
1105
+ Object.defineProperty(Map$1.prototype, "size", {
1106
+ get: function() {
1107
+ return this._keys.length;
1108
+ },
1109
+ enumerable: true,
1110
+ configurable: true
1111
+ });
1112
+ Map$1.prototype.has = function(key) {
1113
+ return this._find(key, false) >= 0;
1114
+ };
1115
+ Map$1.prototype.get = function(key) {
1116
+ var index = this._find(key, false);
1117
+ return index >= 0 ? this._values[index] : void 0;
1118
+ };
1119
+ Map$1.prototype.set = function(key, value) {
1120
+ var index = this._find(key, true);
1121
+ this._values[index] = value;
1122
+ return this;
1123
+ };
1124
+ Map$1.prototype.delete = function(key) {
1125
+ var index = this._find(key, false);
1126
+ if (index >= 0) {
1127
+ var size = this._keys.length;
1128
+ for (var i = index + 1; i < size; i++) {
1129
+ this._keys[i - 1] = this._keys[i];
1130
+ this._values[i - 1] = this._values[i];
1131
+ }
1132
+ this._keys.length--;
1133
+ this._values.length--;
1134
+ if (SameValueZero(key, this._cacheKey)) {
1135
+ this._cacheKey = cacheSentinel;
1136
+ this._cacheIndex = -2;
1137
+ }
1138
+ return true;
1139
+ }
1140
+ return false;
1141
+ };
1142
+ Map$1.prototype.clear = function() {
1143
+ this._keys.length = 0;
1144
+ this._values.length = 0;
1145
+ this._cacheKey = cacheSentinel;
1146
+ this._cacheIndex = -2;
1147
+ };
1148
+ Map$1.prototype.keys = function() {
1149
+ return new MapIterator(this._keys, this._values, getKey);
1150
+ };
1151
+ Map$1.prototype.values = function() {
1152
+ return new MapIterator(this._keys, this._values, getValue);
1153
+ };
1154
+ Map$1.prototype.entries = function() {
1155
+ return new MapIterator(this._keys, this._values, getEntry);
1156
+ };
1157
+ Map$1.prototype["@@iterator"] = function() {
1158
+ return this.entries();
1159
+ };
1160
+ Map$1.prototype[iteratorSymbol] = function() {
1161
+ return this.entries();
1162
+ };
1163
+ Map$1.prototype._find = function(key, insert) {
1164
+ if (!SameValueZero(this._cacheKey, key)) {
1165
+ this._cacheIndex = -1;
1166
+ for (var i = 0; i < this._keys.length; i++) if (SameValueZero(this._keys[i], key)) {
1167
+ this._cacheIndex = i;
1168
+ break;
1169
+ }
1170
+ }
1171
+ if (this._cacheIndex < 0 && insert) {
1172
+ this._cacheIndex = this._keys.length;
1173
+ this._keys.push(key);
1174
+ this._values.push(void 0);
1175
+ }
1176
+ return this._cacheIndex;
1177
+ };
1178
+ return Map$1;
1179
+ }();
1180
+ function getKey(key, _) {
1181
+ return key;
1182
+ }
1183
+ function getValue(_, value) {
1184
+ return value;
1185
+ }
1186
+ function getEntry(key, value) {
1187
+ return [key, value];
1188
+ }
1189
+ }
1190
+ function CreateSetPolyfill() {
1191
+ return function() {
1192
+ function Set$1() {
1193
+ this._map = new _Map();
1194
+ }
1195
+ Object.defineProperty(Set$1.prototype, "size", {
1196
+ get: function() {
1197
+ return this._map.size;
1198
+ },
1199
+ enumerable: true,
1200
+ configurable: true
1201
+ });
1202
+ Set$1.prototype.has = function(value) {
1203
+ return this._map.has(value);
1204
+ };
1205
+ Set$1.prototype.add = function(value) {
1206
+ return this._map.set(value, value), this;
1207
+ };
1208
+ Set$1.prototype.delete = function(value) {
1209
+ return this._map.delete(value);
1210
+ };
1211
+ Set$1.prototype.clear = function() {
1212
+ this._map.clear();
1213
+ };
1214
+ Set$1.prototype.keys = function() {
1215
+ return this._map.keys();
1216
+ };
1217
+ Set$1.prototype.values = function() {
1218
+ return this._map.keys();
1219
+ };
1220
+ Set$1.prototype.entries = function() {
1221
+ return this._map.entries();
1222
+ };
1223
+ Set$1.prototype["@@iterator"] = function() {
1224
+ return this.keys();
1225
+ };
1226
+ Set$1.prototype[iteratorSymbol] = function() {
1227
+ return this.keys();
1228
+ };
1229
+ return Set$1;
1230
+ }();
1231
+ }
1232
+ function CreateWeakMapPolyfill() {
1233
+ var UUID_SIZE = 16;
1234
+ var keys = HashMap.create();
1235
+ var rootKey = CreateUniqueKey();
1236
+ return function() {
1237
+ function WeakMap$1() {
1238
+ this._key = CreateUniqueKey();
1239
+ }
1240
+ WeakMap$1.prototype.has = function(target) {
1241
+ var table = GetOrCreateWeakMapTable(target, false);
1242
+ return table !== void 0 ? HashMap.has(table, this._key) : false;
1243
+ };
1244
+ WeakMap$1.prototype.get = function(target) {
1245
+ var table = GetOrCreateWeakMapTable(target, false);
1246
+ return table !== void 0 ? HashMap.get(table, this._key) : void 0;
1247
+ };
1248
+ WeakMap$1.prototype.set = function(target, value) {
1249
+ var table = GetOrCreateWeakMapTable(target, true);
1250
+ table[this._key] = value;
1251
+ return this;
1252
+ };
1253
+ WeakMap$1.prototype.delete = function(target) {
1254
+ var table = GetOrCreateWeakMapTable(target, false);
1255
+ return table !== void 0 ? delete table[this._key] : false;
1256
+ };
1257
+ WeakMap$1.prototype.clear = function() {
1258
+ this._key = CreateUniqueKey();
1259
+ };
1260
+ return WeakMap$1;
1261
+ }();
1262
+ function CreateUniqueKey() {
1263
+ var key;
1264
+ do
1265
+ key = "@@WeakMap@@" + CreateUUID();
1266
+ while (HashMap.has(keys, key));
1267
+ keys[key] = true;
1268
+ return key;
1269
+ }
1270
+ function GetOrCreateWeakMapTable(target, create) {
1271
+ if (!hasOwn.call(target, rootKey)) {
1272
+ if (!create) return void 0;
1273
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
1274
+ }
1275
+ return target[rootKey];
1276
+ }
1277
+ function FillRandomBytes(buffer, size) {
1278
+ for (var i = 0; i < size; ++i) buffer[i] = Math.random() * 255 | 0;
1279
+ return buffer;
1280
+ }
1281
+ function GenRandomBytes(size) {
1282
+ if (typeof Uint8Array === "function") {
1283
+ var array = new Uint8Array(size);
1284
+ if (typeof crypto !== "undefined") crypto.getRandomValues(array);
1285
+ else if (typeof msCrypto !== "undefined") msCrypto.getRandomValues(array);
1286
+ else FillRandomBytes(array, size);
1287
+ return array;
1288
+ }
1289
+ return FillRandomBytes(new Array(size), size);
1290
+ }
1291
+ function CreateUUID() {
1292
+ var data = GenRandomBytes(UUID_SIZE);
1293
+ data[6] = data[6] & 79 | 64;
1294
+ data[8] = data[8] & 191 | 128;
1295
+ var result = "";
1296
+ for (var offset = 0; offset < UUID_SIZE; ++offset) {
1297
+ var byte = data[offset];
1298
+ if (offset === 4 || offset === 6 || offset === 8) result += "-";
1299
+ if (byte < 16) result += "0";
1300
+ result += byte.toString(16).toLowerCase();
1301
+ }
1302
+ return result;
1303
+ }
1304
+ }
1305
+ function MakeDictionary(obj) {
1306
+ obj.__ = void 0;
1307
+ delete obj.__;
1308
+ return obj;
1309
+ }
1310
+ });
1311
+ })(Reflect$1 || (Reflect$1 = {}));
1312
+ }) });
1313
+
1314
+ //#endregion
1315
+ //#region ../../node_modules/.pnpm/address@2.0.3/node_modules/address/dist/esm/address.js
1316
+ var import_Reflect = /* @__PURE__ */ __toESM(require_Reflect(), 1);
1317
+
1318
+ //#endregion
1319
+ //#region ../../node_modules/.pnpm/detect-port@2.1.0/node_modules/detect-port/dist/esm/detect-port.js
1320
+ const debug$1 = debuglog("detect-port");
1321
+
1322
+ //#endregion
1323
+ //#region ../../node_modules/.pnpm/detect-port@2.1.0/node_modules/detect-port/dist/esm/wait-port.js
1324
+ const debug = debuglog("detect-port:wait-port");
1325
+
1326
+ //#endregion
1327
+ //#region ../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js
1328
+ var require_main = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js": ((exports, module) => {
1329
+ function _resolveEscapeSequences(value) {
1330
+ return value.replace(/\\\$/g, "$");
1331
+ }
1332
+ function expandValue(value, processEnv, runningParsed) {
1333
+ const env$1 = {
1334
+ ...runningParsed,
1335
+ ...processEnv
1336
+ };
1337
+ const regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g;
1338
+ let result = value;
1339
+ let match;
1340
+ const seen = /* @__PURE__ */ new Set();
1341
+ while ((match = regex.exec(result)) !== null) {
1342
+ seen.add(result);
1343
+ const [template, bracedExpression, unbracedExpression] = match;
1344
+ const expression = bracedExpression || unbracedExpression;
1345
+ const opMatch = expression.match(/(:\+|\+|:-|-)/);
1346
+ const splitter = opMatch ? opMatch[0] : null;
1347
+ const r = expression.split(splitter);
1348
+ let defaultValue;
1349
+ let value$1;
1350
+ const key = r.shift();
1351
+ if ([":+", "+"].includes(splitter)) {
1352
+ defaultValue = env$1[key] ? r.join(splitter) : "";
1353
+ value$1 = null;
1354
+ } else {
1355
+ defaultValue = r.join(splitter);
1356
+ value$1 = env$1[key];
1357
+ }
1358
+ if (value$1) if (seen.has(value$1)) result = result.replace(template, defaultValue);
1359
+ else result = result.replace(template, value$1);
1360
+ else result = result.replace(template, defaultValue);
1361
+ if (result === runningParsed[key]) break;
1362
+ regex.lastIndex = 0;
1363
+ }
1364
+ return result;
1365
+ }
1366
+ function expand(options) {
1367
+ const runningParsed = {};
1368
+ let processEnv = process.env;
1369
+ if (options && options.processEnv != null) processEnv = options.processEnv;
1370
+ for (const key in options.parsed) {
1371
+ let value = options.parsed[key];
1372
+ if (processEnv[key] && processEnv[key] !== value) value = processEnv[key];
1373
+ else value = expandValue(value, processEnv, runningParsed);
1374
+ options.parsed[key] = _resolveEscapeSequences(value);
1375
+ runningParsed[key] = _resolveEscapeSequences(value);
1376
+ }
1377
+ for (const processKey in options.parsed) processEnv[processKey] = options.parsed[processKey];
1378
+ return options;
1379
+ }
1380
+ module.exports.expand = expand;
1381
+ }) });
1382
+
1383
+ //#endregion
1384
+ //#region ../core/dist/index.js
1385
+ var import_main = /* @__PURE__ */ __toESM(require_main(), 1);
1386
+ var ServiceProvider = class {
1387
+ /**
1388
+ * Sort order
1389
+ */
1390
+ static order;
1391
+ /**
1392
+ * Sort priority
1393
+ */
1394
+ static priority = 0;
1395
+ /**
1396
+ * Indicate that this service provider only runs in console
1397
+ */
1398
+ static console = false;
1399
+ /**
1400
+ * List of registered console commands
1401
+ */
1402
+ registeredCommands;
1403
+ app;
1404
+ constructor(app) {
1405
+ this.app = app;
1406
+ }
1407
+ /**
1408
+ * An array of console commands to register.
1409
+ */
1410
+ commands(commands) {
1411
+ this.registeredCommands = commands;
1412
+ }
86
1413
  };
87
- export {
88
- ConfigRepository,
89
- ConfigServiceProvider,
90
- EnvLoader
1414
+
1415
+ //#endregion
1416
+ //#region src/Providers/ConfigServiceProvider.ts
1417
+ /**
1418
+ * Loads configuration and environment files.
1419
+ *
1420
+ * Load .env and merge with config files.
1421
+ * Bind ConfigRepository to the container.
1422
+ *
1423
+ * Auto-Registered
1424
+ */
1425
+ var ConfigServiceProvider = class extends ServiceProvider {
1426
+ static priority = 998;
1427
+ async register() {
1428
+ /**
1429
+ * Create singleton to load env
1430
+ */
1431
+ this.app.singleton("env", () => {
1432
+ const env$1 = new EnvLoader(this.app).get;
1433
+ globalThis.env = env$1;
1434
+ return env$1;
1435
+ });
1436
+ /**
1437
+ * Initialize the configuration through the repository
1438
+ */
1439
+ const repo = new ConfigRepository(this.app);
1440
+ await repo.load();
1441
+ /**
1442
+ * Create singleton to load configurations
1443
+ */
1444
+ this.app.singleton("config", () => {
1445
+ const config = {
1446
+ get: (key, def) => repo.get(key, def),
1447
+ set: repo.set
1448
+ };
1449
+ globalThis.config = ((key, def) => {
1450
+ if (!key || typeof key === "string") return config.get(key, def);
1451
+ Object.entries(key).forEach(([key$1, value]) => {
1452
+ config.set(key$1, value);
1453
+ });
1454
+ });
1455
+ return config;
1456
+ });
1457
+ this.app.make("http.app").use((e) => {
1458
+ repo.set("app.url", e.url.origin);
1459
+ });
1460
+ }
91
1461
  };
1462
+
1463
+ //#endregion
1464
+ export { ConfigRepository, ConfigServiceProvider, EnvLoader, Helpers };
92
1465
  //# sourceMappingURL=index.js.map