@sukujs/di 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/index.cjs +847 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +325 -0
- package/dist/index.d.mts +325 -0
- package/dist/index.mjs +811 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
// src/metadata.ts
|
|
3
|
+
const store = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function getTargetMap(target, property, create) {
|
|
5
|
+
let perTarget = store.get(target);
|
|
6
|
+
if (!perTarget) {
|
|
7
|
+
if (!create) return void 0;
|
|
8
|
+
perTarget = /* @__PURE__ */ new Map();
|
|
9
|
+
store.set(target, perTarget);
|
|
10
|
+
}
|
|
11
|
+
let perProperty = perTarget.get(property);
|
|
12
|
+
if (!perProperty && create) {
|
|
13
|
+
perProperty = /* @__PURE__ */ new Map();
|
|
14
|
+
perTarget.set(property, perProperty);
|
|
15
|
+
}
|
|
16
|
+
return perProperty;
|
|
17
|
+
}
|
|
18
|
+
function defineMetadata(key, value, target, property) {
|
|
19
|
+
getTargetMap(target, property, true).set(key, value);
|
|
20
|
+
}
|
|
21
|
+
function getOwnMetadata(key, target, property) {
|
|
22
|
+
return getTargetMap(target, property, false)?.get(key);
|
|
23
|
+
}
|
|
24
|
+
function hasOwnMetadata(key, target, property) {
|
|
25
|
+
return getTargetMap(target, property, false)?.has(key) ?? false;
|
|
26
|
+
}
|
|
27
|
+
/** Looks up metadata on the target and then along its prototype chain. */
|
|
28
|
+
function getMetadata(key, target, property) {
|
|
29
|
+
let current = target;
|
|
30
|
+
while (current) {
|
|
31
|
+
const map = getTargetMap(current, property, false);
|
|
32
|
+
if (map?.has(key)) return map.get(key);
|
|
33
|
+
current = Object.getPrototypeOf(current);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function hasMetadata(key, target, property) {
|
|
37
|
+
return getMetadata(key, target, property) !== void 0;
|
|
38
|
+
}
|
|
39
|
+
function getOwnMetadataKeys(target, property) {
|
|
40
|
+
return [...getTargetMap(target, property, false)?.keys() ?? []];
|
|
41
|
+
}
|
|
42
|
+
function getMetadataKeys(target, property) {
|
|
43
|
+
const keys = /* @__PURE__ */ new Set();
|
|
44
|
+
let current = target;
|
|
45
|
+
while (current) {
|
|
46
|
+
for (const key of getOwnMetadataKeys(current, property)) keys.add(key);
|
|
47
|
+
current = Object.getPrototypeOf(current);
|
|
48
|
+
}
|
|
49
|
+
return [...keys];
|
|
50
|
+
}
|
|
51
|
+
function deleteMetadata(key, target, property) {
|
|
52
|
+
return getTargetMap(target, property, false)?.delete(key) ?? false;
|
|
53
|
+
}
|
|
54
|
+
/** Decorator factory form, matching `Reflect.metadata` from reflect-metadata. */
|
|
55
|
+
function metadata(key, value) {
|
|
56
|
+
return (target, property) => {
|
|
57
|
+
defineMetadata(key, value, target, property);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Installs the shim on `globalThis.Reflect` unless a metadata API is already present. */
|
|
61
|
+
function installReflectShim() {
|
|
62
|
+
const R = globalThis.Reflect;
|
|
63
|
+
if (typeof R.metadata === "function") return false;
|
|
64
|
+
R.metadata = metadata;
|
|
65
|
+
R.defineMetadata = defineMetadata;
|
|
66
|
+
R.getMetadata = getMetadata;
|
|
67
|
+
R.getOwnMetadata = getOwnMetadata;
|
|
68
|
+
R.hasMetadata = hasMetadata;
|
|
69
|
+
R.hasOwnMetadata = hasOwnMetadata;
|
|
70
|
+
R.getMetadataKeys = getMetadataKeys;
|
|
71
|
+
R.getOwnMetadataKeys = getOwnMetadataKeys;
|
|
72
|
+
R.deleteMetadata = deleteMetadata;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
installReflectShim();
|
|
76
|
+
/**
|
|
77
|
+
* Read metadata through whatever Reflect implementation is active, so that the
|
|
78
|
+
* container still works when the user installed `reflect-metadata` before us.
|
|
79
|
+
*/
|
|
80
|
+
function readMetadata(key, target) {
|
|
81
|
+
const R = globalThis.Reflect;
|
|
82
|
+
if (R.getMetadata && R.getMetadata !== getMetadata) return R.getMetadata(key, target) ?? getMetadata(key, target);
|
|
83
|
+
return getMetadata(key, target);
|
|
84
|
+
}
|
|
85
|
+
function readOwnMetadata(key, target) {
|
|
86
|
+
const R = globalThis.Reflect;
|
|
87
|
+
if (R.getOwnMetadata && R.getOwnMetadata !== getOwnMetadata) return R.getOwnMetadata(key, target) ?? getOwnMetadata(key, target);
|
|
88
|
+
return getOwnMetadata(key, target);
|
|
89
|
+
}
|
|
90
|
+
const DESIGN_PARAMTYPES = "design:paramtypes";
|
|
91
|
+
|
|
92
|
+
// src/decorators.ts
|
|
93
|
+
const SERVICE_KEY = "suku:service";
|
|
94
|
+
const INJECT_KEY = "suku:inject";
|
|
95
|
+
const OPTIONAL_KEY = "suku:optional";
|
|
96
|
+
/**
|
|
97
|
+
* Marks a class as resolvable by the container. Any decorator makes TypeScript emit
|
|
98
|
+
* `design:paramtypes`, which is what the container reads to perform constructor
|
|
99
|
+
* injection; this one additionally records default registration options.
|
|
100
|
+
*/
|
|
101
|
+
function Service(options = {}) {
|
|
102
|
+
return (target) => {
|
|
103
|
+
defineMetadata(SERVICE_KEY, options, target);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getServiceOptions(target) {
|
|
107
|
+
return getOwnMetadata(SERVICE_KEY, target);
|
|
108
|
+
}
|
|
109
|
+
function isService(target) {
|
|
110
|
+
return getOwnMetadata(SERVICE_KEY, target) !== void 0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Overrides the token used for one constructor parameter. Required when the
|
|
114
|
+
* parameter type is an interface, a primitive, a string/symbol token, or an
|
|
115
|
+
* `InjectionToken`. Pass `key` to resolve a keyed registration.
|
|
116
|
+
*/
|
|
117
|
+
function Inject(token, key) {
|
|
118
|
+
return (target, _propertyKey, parameterIndex) => {
|
|
119
|
+
const map = getOwnMetadata("suku:inject", target) ?? /* @__PURE__ */ new Map();
|
|
120
|
+
map.set(parameterIndex, key === void 0 ? { token } : {
|
|
121
|
+
token,
|
|
122
|
+
key
|
|
123
|
+
});
|
|
124
|
+
defineMetadata(INJECT_KEY, map, target);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** Resolves to `undefined` instead of throwing when the parameter's service is missing. */
|
|
128
|
+
function Optional() {
|
|
129
|
+
return (target, _propertyKey, parameterIndex) => {
|
|
130
|
+
const set = getOwnMetadata("suku:optional", target) ?? /* @__PURE__ */ new Set();
|
|
131
|
+
set.add(parameterIndex);
|
|
132
|
+
defineMetadata(OPTIONAL_KEY, set, target);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/types.ts
|
|
137
|
+
/**
|
|
138
|
+
* Opaque token for registering values that have no class to stand in for them
|
|
139
|
+
* (configuration objects, primitives, interfaces). Carries its type parameter so
|
|
140
|
+
* `provider.get(TOKEN)` is typed.
|
|
141
|
+
*/
|
|
142
|
+
var InjectionToken = class {
|
|
143
|
+
constructor(description) {
|
|
144
|
+
this.description = description;
|
|
145
|
+
}
|
|
146
|
+
toString() {
|
|
147
|
+
return `InjectionToken(${this.description})`;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
function isConstructor(value) {
|
|
151
|
+
if (typeof value !== "function") return false;
|
|
152
|
+
const desc = Object.getOwnPropertyDescriptor(value, "prototype");
|
|
153
|
+
return desc !== void 0 && desc.writable === false;
|
|
154
|
+
}
|
|
155
|
+
function isToken(value) {
|
|
156
|
+
return typeof value === "function" || typeof value === "string" || typeof value === "symbol" || value instanceof InjectionToken;
|
|
157
|
+
}
|
|
158
|
+
function tokenName(token) {
|
|
159
|
+
if (typeof token === "function") return token.name || "<anonymous class>";
|
|
160
|
+
if (token instanceof InjectionToken) return token.toString();
|
|
161
|
+
if (typeof token === "symbol") return token.toString();
|
|
162
|
+
if (typeof token === "string") return JSON.stringify(token);
|
|
163
|
+
return String(token);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/errors.ts
|
|
167
|
+
var DiError = class extends Error {
|
|
168
|
+
constructor(..._args) {
|
|
169
|
+
super(..._args);
|
|
170
|
+
this.name = "DiError";
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
function describe$1(d) {
|
|
174
|
+
return `${tokenName(d.token)}${d.key === void 0 ? "" : `[key=${String(d.key)}]`} (${d.lifetime})`;
|
|
175
|
+
}
|
|
176
|
+
function formatChain(chain) {
|
|
177
|
+
return chain.map(describe$1).join(" -> ");
|
|
178
|
+
}
|
|
179
|
+
var MissingServiceError = class extends DiError {
|
|
180
|
+
constructor(token, key, chain) {
|
|
181
|
+
const what = key === void 0 ? tokenName(token) : `${tokenName(token)}[key=${String(key)}]`;
|
|
182
|
+
const where = chain.length ? ` while resolving ${formatChain(chain)}` : "";
|
|
183
|
+
super(`No service registered for ${what}${where}. Register it on the ServiceCollection.`);
|
|
184
|
+
this.token = token;
|
|
185
|
+
this.key = key;
|
|
186
|
+
this.name = "MissingServiceError";
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var CircularDependencyError = class extends DiError {
|
|
190
|
+
constructor(chain) {
|
|
191
|
+
super(`Circular dependency detected: ${formatChain(chain)}`);
|
|
192
|
+
this.chain = chain;
|
|
193
|
+
this.name = "CircularDependencyError";
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
var ScopedFromRootError = class extends DiError {
|
|
197
|
+
constructor(descriptor, chain) {
|
|
198
|
+
const target = `scoped service ${tokenName(descriptor.token)}`;
|
|
199
|
+
super(chain.length ? `Cannot resolve ${target} from the root provider while constructing ${formatChain(chain)}. A singleton (or a transient created from the root) may not depend on a scoped service; this is a captive dependency.` : `Cannot resolve ${target} from the root provider. Create a scope first: provider.createScope().`);
|
|
200
|
+
this.descriptor = descriptor;
|
|
201
|
+
this.name = "ScopedFromRootError";
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var CaptiveDependencyError = class extends DiError {
|
|
205
|
+
constructor(consumer, dependency) {
|
|
206
|
+
super(`Captive dependency: ${describe$1(consumer)} depends on ${describe$1(dependency)}. A longer-lived service would hold a shorter-lived one for its entire lifetime.`);
|
|
207
|
+
this.consumer = consumer;
|
|
208
|
+
this.dependency = dependency;
|
|
209
|
+
this.name = "CaptiveDependencyError";
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var UnresolvableParameterError = class extends DiError {
|
|
213
|
+
constructor(cls, index, reason) {
|
|
214
|
+
super(index < 0 ? `Cannot construct ${tokenName(cls)}: ${reason}` : `Cannot resolve constructor parameter #${index} of ${tokenName(cls)}: ${reason}`);
|
|
215
|
+
this.name = "UnresolvableParameterError";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
var InvalidDescriptorError = class extends DiError {
|
|
219
|
+
constructor(..._args2) {
|
|
220
|
+
super(..._args2);
|
|
221
|
+
this.name = "InvalidDescriptorError";
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
var ProviderDisposedError = class extends DiError {
|
|
225
|
+
constructor() {
|
|
226
|
+
super("This ServiceProvider has been disposed.");
|
|
227
|
+
this.name = "ProviderDisposedError";
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/service.ts
|
|
232
|
+
/**
|
|
233
|
+
* A service declared without a class. It is its own injection token and carries its own
|
|
234
|
+
* registration, so it can be listed in `services`, injected with `@Inject(Def)`, and named in
|
|
235
|
+
* a route's or another service's `services`.
|
|
236
|
+
*/
|
|
237
|
+
var ServiceDefinition = class extends InjectionToken {
|
|
238
|
+
constructor(name, lifetime, dependencies, create) {
|
|
239
|
+
super(name);
|
|
240
|
+
const entries = Object.entries(dependencies);
|
|
241
|
+
this.descriptor = {
|
|
242
|
+
kind: "factory",
|
|
243
|
+
token: this,
|
|
244
|
+
lifetime,
|
|
245
|
+
dependsOn: entries.map(([, token]) => token),
|
|
246
|
+
useFactory: (provider) => {
|
|
247
|
+
const deps = {};
|
|
248
|
+
for (const [key, token] of entries) deps[key] = provider.get(token);
|
|
249
|
+
return create(deps);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function service(name, optionsOrCreate) {
|
|
255
|
+
if (typeof optionsOrCreate === "function") return new ServiceDefinition(name, "singleton", {}, optionsOrCreate);
|
|
256
|
+
const { lifetime = "singleton", services = {}, create } = optionsOrCreate;
|
|
257
|
+
return new ServiceDefinition(name, lifetime, services, create);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/descriptor.ts
|
|
261
|
+
const USE_KEYS = [
|
|
262
|
+
"useClass",
|
|
263
|
+
"useFactory",
|
|
264
|
+
"useValue",
|
|
265
|
+
"useExisting"
|
|
266
|
+
];
|
|
267
|
+
function withKey(d, key) {
|
|
268
|
+
return key === void 0 ? d : {
|
|
269
|
+
...d,
|
|
270
|
+
key
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** Builds a descriptor from `(token, implementation, lifetime)` as the add* methods receive it. */
|
|
274
|
+
function describe(token, impl, lifetime, key) {
|
|
275
|
+
if (!isToken(token)) throw new InvalidDescriptorError(`Invalid token: ${String(token)}`);
|
|
276
|
+
if (impl === void 0 && token instanceof ServiceDefinition) return withKey({
|
|
277
|
+
...token.descriptor,
|
|
278
|
+
lifetime
|
|
279
|
+
}, key);
|
|
280
|
+
if (impl === void 0) {
|
|
281
|
+
if (!isConstructor(token)) throw new InvalidDescriptorError(`${tokenName(token)} is not a class; supply an implementation (class, factory, or { useValue }).`);
|
|
282
|
+
return withKey({
|
|
283
|
+
kind: "class",
|
|
284
|
+
token,
|
|
285
|
+
lifetime,
|
|
286
|
+
useClass: token
|
|
287
|
+
}, key);
|
|
288
|
+
}
|
|
289
|
+
if (isConstructor(impl)) return withKey({
|
|
290
|
+
kind: "class",
|
|
291
|
+
token,
|
|
292
|
+
lifetime,
|
|
293
|
+
useClass: impl
|
|
294
|
+
}, key);
|
|
295
|
+
if (typeof impl === "function") return withKey({
|
|
296
|
+
kind: "factory",
|
|
297
|
+
token,
|
|
298
|
+
lifetime,
|
|
299
|
+
useFactory: impl
|
|
300
|
+
}, key);
|
|
301
|
+
if (impl !== null && typeof impl === "object") {
|
|
302
|
+
if (USE_KEYS.filter((k) => k in impl).length !== 1) throw new InvalidDescriptorError(`Implementation for ${tokenName(token)} must have exactly one of ${USE_KEYS.join(", ")}.`);
|
|
303
|
+
if ("useClass" in impl) {
|
|
304
|
+
if (!isConstructor(impl.useClass)) throw new InvalidDescriptorError(`useClass for ${tokenName(token)} is not a class.`);
|
|
305
|
+
return withKey({
|
|
306
|
+
kind: "class",
|
|
307
|
+
token,
|
|
308
|
+
lifetime,
|
|
309
|
+
useClass: impl.useClass
|
|
310
|
+
}, key);
|
|
311
|
+
}
|
|
312
|
+
if ("useFactory" in impl) {
|
|
313
|
+
if (typeof impl.useFactory !== "function") throw new InvalidDescriptorError(`useFactory for ${tokenName(token)} is not a function.`);
|
|
314
|
+
return withKey({
|
|
315
|
+
kind: "factory",
|
|
316
|
+
token,
|
|
317
|
+
lifetime,
|
|
318
|
+
useFactory: impl.useFactory
|
|
319
|
+
}, key);
|
|
320
|
+
}
|
|
321
|
+
if ("useValue" in impl) return withKey({
|
|
322
|
+
kind: "value",
|
|
323
|
+
token,
|
|
324
|
+
lifetime: "singleton",
|
|
325
|
+
useValue: impl.useValue
|
|
326
|
+
}, key);
|
|
327
|
+
if (!isToken(impl.useExisting)) throw new InvalidDescriptorError(`useExisting for ${tokenName(token)} is not a token.`);
|
|
328
|
+
return withKey({
|
|
329
|
+
kind: "existing",
|
|
330
|
+
token,
|
|
331
|
+
lifetime,
|
|
332
|
+
useExisting: impl.useExisting
|
|
333
|
+
}, key);
|
|
334
|
+
}
|
|
335
|
+
throw new InvalidDescriptorError(`Invalid implementation for ${tokenName(token)}.`);
|
|
336
|
+
}
|
|
337
|
+
/** Converts NestJS-style provider shorthand into a descriptor. Bare classes default to singleton. */
|
|
338
|
+
function normalizeProvider(provider) {
|
|
339
|
+
if (provider instanceof ServiceDefinition) return provider.descriptor;
|
|
340
|
+
if (isConstructor(provider)) return describe(provider, void 0, getServiceOptions(provider)?.lifetime ?? "singleton");
|
|
341
|
+
if (provider === null || typeof provider !== "object" || !("provide" in provider)) throw new InvalidDescriptorError(`Provider must be a class or an object with a \`provide\` field and one of ${USE_KEYS.join(", ")}.`);
|
|
342
|
+
const { provide, lifetime, key, ...rest } = provider;
|
|
343
|
+
const impl = Object.fromEntries(Object.entries(rest).filter(([k]) => USE_KEYS.includes(k)));
|
|
344
|
+
return describe(provide, impl, lifetime ?? ("useClass" in impl ? getServiceOptions(impl.useClass)?.lifetime : void 0) ?? "singleton", key);
|
|
345
|
+
}
|
|
346
|
+
function isServiceDescriptor(value) {
|
|
347
|
+
return value !== null && typeof value === "object" && "kind" in value && "token" in value && "lifetime" in value && !("provide" in value);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/reflection.ts
|
|
351
|
+
function isEntryObject(value) {
|
|
352
|
+
return typeof value === "object" && value !== null && "token" in value;
|
|
353
|
+
}
|
|
354
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
355
|
+
/** Types TypeScript emits for parameters it cannot represent at runtime. */
|
|
356
|
+
const UNUSABLE = /* @__PURE__ */ new Set([
|
|
357
|
+
void 0,
|
|
358
|
+
null,
|
|
359
|
+
Object,
|
|
360
|
+
Function,
|
|
361
|
+
String,
|
|
362
|
+
Number,
|
|
363
|
+
Boolean,
|
|
364
|
+
Symbol,
|
|
365
|
+
Array,
|
|
366
|
+
Promise
|
|
367
|
+
]);
|
|
368
|
+
function maxIndex(iter) {
|
|
369
|
+
let max = -1;
|
|
370
|
+
if (iter) {
|
|
371
|
+
for (const i of iter) if (i > max) max = i;
|
|
372
|
+
}
|
|
373
|
+
return max;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Determines the token for each constructor parameter of `cls`, combining
|
|
377
|
+
* `design:paramtypes` (emitted by TypeScript) with `@Inject` / `@Optional` overrides.
|
|
378
|
+
* Results are cached per class.
|
|
379
|
+
*/
|
|
380
|
+
function getConstructorParameters(cls) {
|
|
381
|
+
const cached = cache.get(cls);
|
|
382
|
+
if (cached) return cached;
|
|
383
|
+
const explicit = cls.inject;
|
|
384
|
+
if (Array.isArray(explicit) && Object.hasOwn(cls, "inject")) {
|
|
385
|
+
const params = explicit.map((entry, index) => {
|
|
386
|
+
const e = isTokenLike(entry) && !isEntryObject(entry) ? { token: entry } : entry;
|
|
387
|
+
if (!isTokenLike(e.token)) throw new UnresolvableParameterError(cls, index, "static inject entry is not a token.");
|
|
388
|
+
const info = {
|
|
389
|
+
index,
|
|
390
|
+
token: e.token,
|
|
391
|
+
optional: e.optional ?? false
|
|
392
|
+
};
|
|
393
|
+
return e.key === void 0 ? info : {
|
|
394
|
+
...info,
|
|
395
|
+
key: e.key
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
cache.set(cls, params);
|
|
399
|
+
return params;
|
|
400
|
+
}
|
|
401
|
+
const read = hasOwnMetadata("design:paramtypes", cls) ? readOwnMetadata : readMetadata;
|
|
402
|
+
const types = readMetadata(DESIGN_PARAMTYPES, cls);
|
|
403
|
+
const injects = read(INJECT_KEY, cls);
|
|
404
|
+
const optionals = read(OPTIONAL_KEY, cls);
|
|
405
|
+
const count = Math.max(types?.length ?? 0, maxIndex(injects?.keys()) + 1, maxIndex(optionals) + 1);
|
|
406
|
+
if (count === 0 && cls.length > 0) throw new UnresolvableParameterError(cls, -1, `it declares ${cls.length} constructor parameter(s) but no type metadata was emitted. Decorate the class with @Service() and compile with "emitDecoratorMetadata": true, or annotate each parameter with @Inject(token).`);
|
|
407
|
+
const params = [];
|
|
408
|
+
for (let i = 0; i < count; i++) {
|
|
409
|
+
const override = injects?.get(i);
|
|
410
|
+
const token = override?.token ?? types?.[i];
|
|
411
|
+
if (UNUSABLE.has(token) || !isTokenLike(token)) throw new UnresolvableParameterError(cls, i, token === void 0 && types !== void 0 ? "its type is undefined at runtime (usually a circular import or a type-only import). Use @Inject(token) with an explicit token." : `its type (${describeType(token)}) is an interface, primitive, or union that does not exist at runtime. Use @Inject(token) with a class, InjectionToken, string, or symbol.`);
|
|
412
|
+
const info = {
|
|
413
|
+
index: i,
|
|
414
|
+
token,
|
|
415
|
+
optional: optionals?.has(i) ?? false
|
|
416
|
+
};
|
|
417
|
+
params.push(override?.key === void 0 ? info : {
|
|
418
|
+
...info,
|
|
419
|
+
key: override.key
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
cache.set(cls, params);
|
|
423
|
+
return params;
|
|
424
|
+
}
|
|
425
|
+
function isTokenLike(value) {
|
|
426
|
+
return typeof value === "function" || typeof value === "string" || typeof value === "symbol" || typeof value === "object" && value !== null;
|
|
427
|
+
}
|
|
428
|
+
function describeType(t) {
|
|
429
|
+
if (typeof t === "function") return t.name || "anonymous";
|
|
430
|
+
return String(t);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/provider.ts
|
|
434
|
+
const ASYNC_DISPOSE = Symbol.asyncDispose;
|
|
435
|
+
const SYNC_DISPOSE = Symbol.dispose;
|
|
436
|
+
function isDisposable(value) {
|
|
437
|
+
if (value === null || typeof value !== "object") return false;
|
|
438
|
+
const v = value;
|
|
439
|
+
return typeof v.dispose === "function" || typeof v.onDispose === "function" || ASYNC_DISPOSE !== void 0 && typeof v[ASYNC_DISPOSE] === "function" || SYNC_DISPOSE !== void 0 && typeof v[SYNC_DISPOSE] === "function";
|
|
440
|
+
}
|
|
441
|
+
async function disposeOne(value) {
|
|
442
|
+
if (ASYNC_DISPOSE && typeof value[ASYNC_DISPOSE] === "function") await value[ASYNC_DISPOSE]();
|
|
443
|
+
else if (SYNC_DISPOSE && typeof value[SYNC_DISPOSE] === "function") value[SYNC_DISPOSE]();
|
|
444
|
+
else if (typeof value.dispose === "function") await value.dispose();
|
|
445
|
+
else if (typeof value.onDispose === "function") await value.onDispose();
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Resolves services. The root provider is returned by `ServiceCollection.build()`;
|
|
449
|
+
* `createScope()` returns a child provider with its own scoped instances.
|
|
450
|
+
*
|
|
451
|
+
* `ServiceProvider` is itself injectable: a class that declares a `ServiceProvider`
|
|
452
|
+
* constructor parameter receives the provider it is being resolved from.
|
|
453
|
+
*/
|
|
454
|
+
var ServiceProvider = class {
|
|
455
|
+
/** Enables `await using provider = collection.build()`. */
|
|
456
|
+
[Symbol.asyncDispose]() {
|
|
457
|
+
return this.dispose();
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
var Registry = class {
|
|
461
|
+
constructor(descriptors, options) {
|
|
462
|
+
this.descriptors = descriptors;
|
|
463
|
+
this.byToken = /* @__PURE__ */ new Map();
|
|
464
|
+
this.keyed = /* @__PURE__ */ new Map();
|
|
465
|
+
this.stack = [];
|
|
466
|
+
this.options = {
|
|
467
|
+
validateScopes: options.validateScopes ?? true,
|
|
468
|
+
validateOnBuild: options.validateOnBuild ?? false
|
|
469
|
+
};
|
|
470
|
+
for (const d of descriptors) if (d.key === void 0) push(this.byToken, d.token, d);
|
|
471
|
+
else {
|
|
472
|
+
let perKey = this.keyed.get(d.token);
|
|
473
|
+
if (!perKey) {
|
|
474
|
+
perKey = /* @__PURE__ */ new Map();
|
|
475
|
+
this.keyed.set(d.token, perKey);
|
|
476
|
+
}
|
|
477
|
+
push(perKey, d.key, d);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
lookup(token, key) {
|
|
481
|
+
return key === void 0 ? this.byToken.get(token) : this.keyed.get(token)?.get(key);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
function push(map, key, value) {
|
|
485
|
+
const list = map.get(key);
|
|
486
|
+
if (list) list.push(value);
|
|
487
|
+
else map.set(key, [value]);
|
|
488
|
+
}
|
|
489
|
+
var Container = class Container extends ServiceProvider {
|
|
490
|
+
constructor(registry, parent) {
|
|
491
|
+
super();
|
|
492
|
+
this.registry = registry;
|
|
493
|
+
this.parent = parent;
|
|
494
|
+
this.cache = null;
|
|
495
|
+
this.disposables = null;
|
|
496
|
+
this.children = null;
|
|
497
|
+
this.disposed = false;
|
|
498
|
+
}
|
|
499
|
+
get isRoot() {
|
|
500
|
+
return this.parent === null;
|
|
501
|
+
}
|
|
502
|
+
get root() {
|
|
503
|
+
return this.parent ?? this;
|
|
504
|
+
}
|
|
505
|
+
get(token) {
|
|
506
|
+
return this.resolveToken(token, void 0, false);
|
|
507
|
+
}
|
|
508
|
+
getOptional(token) {
|
|
509
|
+
return this.resolveToken(token, void 0, true);
|
|
510
|
+
}
|
|
511
|
+
getKeyed(token, key) {
|
|
512
|
+
return this.resolveToken(token, key, false);
|
|
513
|
+
}
|
|
514
|
+
getKeyedOptional(token, key) {
|
|
515
|
+
return this.resolveToken(token, key, true);
|
|
516
|
+
}
|
|
517
|
+
getAll(token) {
|
|
518
|
+
this.assertAlive();
|
|
519
|
+
const list = this.registry.lookup(token, void 0);
|
|
520
|
+
if (!list) return token === ServiceProvider ? [this] : [];
|
|
521
|
+
return list.map((d) => this.resolve(d));
|
|
522
|
+
}
|
|
523
|
+
has(token, key) {
|
|
524
|
+
return token === ServiceProvider || (this.registry.lookup(token, key)?.length ?? 0) > 0;
|
|
525
|
+
}
|
|
526
|
+
create(cls) {
|
|
527
|
+
this.assertAlive();
|
|
528
|
+
const instance = this.construct(cls);
|
|
529
|
+
this.track(instance);
|
|
530
|
+
return instance;
|
|
531
|
+
}
|
|
532
|
+
createScope() {
|
|
533
|
+
this.assertAlive();
|
|
534
|
+
const rootContainer = this.parent ?? this;
|
|
535
|
+
const scope = new Container(this.registry, rootContainer);
|
|
536
|
+
(rootContainer.children ??= /* @__PURE__ */ new Set()).add(scope);
|
|
537
|
+
return scope;
|
|
538
|
+
}
|
|
539
|
+
async dispose() {
|
|
540
|
+
if (this.disposed) return;
|
|
541
|
+
this.disposed = true;
|
|
542
|
+
this.parent?.children?.delete(this);
|
|
543
|
+
if (this.children) {
|
|
544
|
+
for (const child of [...this.children].reverse()) await child.dispose();
|
|
545
|
+
this.children = null;
|
|
546
|
+
}
|
|
547
|
+
if (this.disposables) {
|
|
548
|
+
for (let i = this.disposables.length - 1; i >= 0; i--) await disposeOne(this.disposables[i]);
|
|
549
|
+
this.disposables = null;
|
|
550
|
+
}
|
|
551
|
+
this.cache = null;
|
|
552
|
+
}
|
|
553
|
+
assertAlive() {
|
|
554
|
+
if (this.disposed) throw new ProviderDisposedError();
|
|
555
|
+
}
|
|
556
|
+
resolveToken(token, key, optional) {
|
|
557
|
+
this.assertAlive();
|
|
558
|
+
if (token === ServiceProvider && key === void 0) return this;
|
|
559
|
+
const list = this.registry.lookup(token, key);
|
|
560
|
+
if (!list || list.length === 0) {
|
|
561
|
+
if (optional) return void 0;
|
|
562
|
+
throw new MissingServiceError(token, key, [...this.registry.stack]);
|
|
563
|
+
}
|
|
564
|
+
return this.resolve(list[list.length - 1]);
|
|
565
|
+
}
|
|
566
|
+
resolve(d) {
|
|
567
|
+
switch (d.kind) {
|
|
568
|
+
case "value": return d.useValue;
|
|
569
|
+
case "existing": return this.resolveToken(d.useExisting, void 0, false);
|
|
570
|
+
}
|
|
571
|
+
switch (d.lifetime) {
|
|
572
|
+
case "singleton": return (this.parent ?? this).getOrCreate(d);
|
|
573
|
+
case "scoped":
|
|
574
|
+
if (this.isRoot && this.registry.options.validateScopes) throw new ScopedFromRootError(d, [...this.registry.stack]);
|
|
575
|
+
return this.getOrCreate(d);
|
|
576
|
+
case "transient": {
|
|
577
|
+
const instance = this.instantiate(d);
|
|
578
|
+
this.track(instance);
|
|
579
|
+
return instance;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
getOrCreate(d) {
|
|
584
|
+
const cache = this.cache ??= /* @__PURE__ */ new Map();
|
|
585
|
+
if (cache.has(d)) return cache.get(d);
|
|
586
|
+
const instance = this.instantiate(d);
|
|
587
|
+
cache.set(d, instance);
|
|
588
|
+
this.track(instance);
|
|
589
|
+
return instance;
|
|
590
|
+
}
|
|
591
|
+
/** Creates an instance, resolving its dependencies from `this`. */
|
|
592
|
+
instantiate(d) {
|
|
593
|
+
const stack = this.registry.stack;
|
|
594
|
+
if (stack.includes(d)) throw new CircularDependencyError([...stack, d]);
|
|
595
|
+
stack.push(d);
|
|
596
|
+
try {
|
|
597
|
+
if (d.kind === "factory") return d.useFactory(this);
|
|
598
|
+
return this.construct(d.useClass);
|
|
599
|
+
} finally {
|
|
600
|
+
stack.pop();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
construct(cls) {
|
|
604
|
+
const params = getConstructorParameters(cls);
|
|
605
|
+
const args = new Array(params.length);
|
|
606
|
+
for (const p of params) args[p.index] = this.resolveToken(p.token, p.key, p.optional);
|
|
607
|
+
return new cls(...args);
|
|
608
|
+
}
|
|
609
|
+
track(instance) {
|
|
610
|
+
if (isDisposable(instance)) (this.disposables ??= []).push(instance);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
/** Static checks run when `validateOnBuild` is set. */
|
|
614
|
+
function validate(registry) {
|
|
615
|
+
const { validateScopes } = registry.options;
|
|
616
|
+
const resolveDependency = (p) => {
|
|
617
|
+
const list = registry.lookup(p.token, p.key);
|
|
618
|
+
return list?.[list.length - 1];
|
|
619
|
+
};
|
|
620
|
+
/** Follows `useExisting` aliases to the descriptor that actually produces the instance. */
|
|
621
|
+
const concrete = (d, seen = /* @__PURE__ */ new Set()) => {
|
|
622
|
+
if (d.kind !== "existing" || seen.has(d)) return d;
|
|
623
|
+
seen.add(d);
|
|
624
|
+
const target = resolveDependency({ token: d.useExisting });
|
|
625
|
+
return target ? concrete(target, seen) : d;
|
|
626
|
+
};
|
|
627
|
+
const dependenciesOf = (d) => {
|
|
628
|
+
const c = concrete(d);
|
|
629
|
+
if (c.kind === "factory" && c.dependsOn) {
|
|
630
|
+
const declared = [];
|
|
631
|
+
for (const token of c.dependsOn) {
|
|
632
|
+
if (token === ServiceProvider) continue;
|
|
633
|
+
const dep = resolveDependency({ token });
|
|
634
|
+
if (!dep) throw new MissingServiceError(token, void 0, [d]);
|
|
635
|
+
declared.push(dep);
|
|
636
|
+
}
|
|
637
|
+
return declared;
|
|
638
|
+
}
|
|
639
|
+
if (c.kind !== "class") return [];
|
|
640
|
+
const deps = [];
|
|
641
|
+
for (const p of getConstructorParameters(c.useClass)) {
|
|
642
|
+
if (p.token === ServiceProvider) continue;
|
|
643
|
+
const dep = resolveDependency(p);
|
|
644
|
+
if (!dep) {
|
|
645
|
+
if (p.optional) continue;
|
|
646
|
+
throw new MissingServiceError(p.token, p.key, [d]);
|
|
647
|
+
}
|
|
648
|
+
deps.push(dep);
|
|
649
|
+
}
|
|
650
|
+
return deps;
|
|
651
|
+
};
|
|
652
|
+
for (const d of registry.descriptors) for (const dep of dependenciesOf(d)) {
|
|
653
|
+
const target = concrete(dep);
|
|
654
|
+
if (validateScopes && d.kind !== "value" && target.kind !== "value" && d.lifetime === "singleton" && target.lifetime === "scoped") throw new CaptiveDependencyError(d, target);
|
|
655
|
+
}
|
|
656
|
+
const WHITE = 0;
|
|
657
|
+
const GREY = 1;
|
|
658
|
+
const BLACK = 2;
|
|
659
|
+
const color = /* @__PURE__ */ new Map();
|
|
660
|
+
const path = [];
|
|
661
|
+
const visit = (d) => {
|
|
662
|
+
const c = color.get(d) ?? WHITE;
|
|
663
|
+
if (c === BLACK) return;
|
|
664
|
+
if (c === GREY) {
|
|
665
|
+
const start = path.indexOf(d);
|
|
666
|
+
throw new CircularDependencyError([...path.slice(start), d]);
|
|
667
|
+
}
|
|
668
|
+
color.set(d, GREY);
|
|
669
|
+
path.push(d);
|
|
670
|
+
for (const dep of dependenciesOf(d)) visit(dep);
|
|
671
|
+
path.pop();
|
|
672
|
+
color.set(d, BLACK);
|
|
673
|
+
};
|
|
674
|
+
for (const d of registry.descriptors) visit(d);
|
|
675
|
+
}
|
|
676
|
+
function buildServiceProvider(descriptors, options = {}) {
|
|
677
|
+
const registry = new Registry(descriptors, options);
|
|
678
|
+
if (registry.options.validateOnBuild) validate(registry);
|
|
679
|
+
return new Container(registry, null);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// src/collection.ts
|
|
683
|
+
/**
|
|
684
|
+
* Ordered list of registrations, modelled on .NET's `IServiceCollection`.
|
|
685
|
+
*
|
|
686
|
+
* - `get(token)` resolves the **last** registration for a token.
|
|
687
|
+
* - `getAll(token)` resolves every registration, in order.
|
|
688
|
+
* - `tryAdd*` only registers when the token has no registration yet.
|
|
689
|
+
*/
|
|
690
|
+
var ServiceCollection = class {
|
|
691
|
+
constructor() {
|
|
692
|
+
this.items = [];
|
|
693
|
+
}
|
|
694
|
+
get descriptors() {
|
|
695
|
+
return this.items;
|
|
696
|
+
}
|
|
697
|
+
get size() {
|
|
698
|
+
return this.items.length;
|
|
699
|
+
}
|
|
700
|
+
/** Adds a descriptor, or a NestJS-style provider (`Class` or `{ provide, use* }`). */
|
|
701
|
+
add(entry) {
|
|
702
|
+
this.items.push(isServiceDescriptor(entry) ? entry : normalizeProvider(entry));
|
|
703
|
+
return this;
|
|
704
|
+
}
|
|
705
|
+
addRange(entries) {
|
|
706
|
+
for (const e of entries) this.add(e);
|
|
707
|
+
return this;
|
|
708
|
+
}
|
|
709
|
+
addSingleton(token, impl) {
|
|
710
|
+
return this.add(describe(token, impl, "singleton"));
|
|
711
|
+
}
|
|
712
|
+
addScoped(token, impl) {
|
|
713
|
+
return this.add(describe(token, impl, "scoped"));
|
|
714
|
+
}
|
|
715
|
+
addTransient(token, impl) {
|
|
716
|
+
return this.add(describe(token, impl, "transient"));
|
|
717
|
+
}
|
|
718
|
+
addKeyedSingleton(token, key, impl) {
|
|
719
|
+
return this.add(describe(token, impl, "singleton", key));
|
|
720
|
+
}
|
|
721
|
+
addKeyedScoped(token, key, impl) {
|
|
722
|
+
return this.add(describe(token, impl, "scoped", key));
|
|
723
|
+
}
|
|
724
|
+
addKeyedTransient(token, key, impl) {
|
|
725
|
+
return this.add(describe(token, impl, "transient", key));
|
|
726
|
+
}
|
|
727
|
+
/** Adds only if nothing is registered for the token (and key). */
|
|
728
|
+
tryAdd(entry) {
|
|
729
|
+
const d = isServiceDescriptor(entry) ? entry : normalizeProvider(entry);
|
|
730
|
+
if (!this.has(d.token, d.key)) this.items.push(d);
|
|
731
|
+
return this;
|
|
732
|
+
}
|
|
733
|
+
tryAddSingleton(token, impl) {
|
|
734
|
+
return this.tryAdd(describe(token, impl, "singleton"));
|
|
735
|
+
}
|
|
736
|
+
tryAddScoped(token, impl) {
|
|
737
|
+
return this.tryAdd(describe(token, impl, "scoped"));
|
|
738
|
+
}
|
|
739
|
+
tryAddTransient(token, impl) {
|
|
740
|
+
return this.tryAdd(describe(token, impl, "transient"));
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Adds only if no registration for the token has the same implementation
|
|
744
|
+
* (class, factory, or alias). Useful for plugin collections resolved with `getAll`.
|
|
745
|
+
*/
|
|
746
|
+
tryAddEnumerable(entry) {
|
|
747
|
+
const d = isServiceDescriptor(entry) ? entry : normalizeProvider(entry);
|
|
748
|
+
if (!this.items.some((x) => x.token === d.token && x.key === d.key && x.kind === d.kind && x.useClass === d.useClass && x.useFactory === d.useFactory && x.useExisting === d.useExisting && (x.kind !== "value" || x.useValue === d.useValue))) this.items.push(d);
|
|
749
|
+
return this;
|
|
750
|
+
}
|
|
751
|
+
has(token, key) {
|
|
752
|
+
return this.items.some((d) => d.token === token && d.key === key);
|
|
753
|
+
}
|
|
754
|
+
/** Removes every registration for the token (and key). */
|
|
755
|
+
remove(token, key) {
|
|
756
|
+
for (let i = this.items.length - 1; i >= 0; i--) {
|
|
757
|
+
const d = this.items[i];
|
|
758
|
+
if (d.token === token && d.key === key) this.items.splice(i, 1);
|
|
759
|
+
}
|
|
760
|
+
return this;
|
|
761
|
+
}
|
|
762
|
+
/** Removes all registrations for the entry's token, then adds it. */
|
|
763
|
+
replace(entry) {
|
|
764
|
+
const d = isServiceDescriptor(entry) ? entry : normalizeProvider(entry);
|
|
765
|
+
return this.remove(d.token, d.key).add(d);
|
|
766
|
+
}
|
|
767
|
+
/** Builds the root `ServiceProvider`. The collection may still be modified afterwards. */
|
|
768
|
+
build(options) {
|
|
769
|
+
return buildServiceProvider([...this.items], options);
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
// src/helpers.ts
|
|
774
|
+
/**
|
|
775
|
+
* Typed registration helpers. Unlike `{ provide, useClass }` objects, the implementation is
|
|
776
|
+
* checked against the token: `singleton(Logger, ConsoleLogger)` fails to compile unless
|
|
777
|
+
* `ConsoleLogger` is assignable to `Logger`.
|
|
778
|
+
*
|
|
779
|
+
* ```ts
|
|
780
|
+
* services: [
|
|
781
|
+
* singleton(Logger, ConsoleLogger),
|
|
782
|
+
* scoped(UnitOfWork),
|
|
783
|
+
* value(CONFIG, { port: 3000 }),
|
|
784
|
+
* factory(Mailer, (sp) => new Mailer(sp.get(Logger))),
|
|
785
|
+
* alias(Cache, RedisCache),
|
|
786
|
+
* ]
|
|
787
|
+
* ```
|
|
788
|
+
*/
|
|
789
|
+
function singleton(token, impl, options) {
|
|
790
|
+
return describe(token, impl, "singleton", options?.key);
|
|
791
|
+
}
|
|
792
|
+
function scoped(token, impl, options) {
|
|
793
|
+
return describe(token, impl, "scoped", options?.key);
|
|
794
|
+
}
|
|
795
|
+
function transient(token, impl, options) {
|
|
796
|
+
return describe(token, impl, "transient", options?.key);
|
|
797
|
+
}
|
|
798
|
+
/** Registers an existing instance or constant. Never disposed by the container. */
|
|
799
|
+
function value(token, instance, options) {
|
|
800
|
+
return describe(token, { useValue: instance }, "singleton", options?.key);
|
|
801
|
+
}
|
|
802
|
+
/** Registers a factory. Singleton unless a lifetime is given. */
|
|
803
|
+
function factory(token, create, lifetime = "singleton", options) {
|
|
804
|
+
return describe(token, { useFactory: create }, lifetime, options?.key);
|
|
805
|
+
}
|
|
806
|
+
/** Makes `token` resolve to whatever `existing` resolves to. */
|
|
807
|
+
function alias(token, existing, options) {
|
|
808
|
+
return describe(token, { useExisting: existing }, "singleton", options?.key);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
exports.CaptiveDependencyError = CaptiveDependencyError;
|
|
812
|
+
exports.CircularDependencyError = CircularDependencyError;
|
|
813
|
+
exports.DiError = DiError;
|
|
814
|
+
exports.Inject = Inject;
|
|
815
|
+
exports.InjectionToken = InjectionToken;
|
|
816
|
+
exports.InvalidDescriptorError = InvalidDescriptorError;
|
|
817
|
+
exports.MissingServiceError = MissingServiceError;
|
|
818
|
+
exports.Optional = Optional;
|
|
819
|
+
exports.ProviderDisposedError = ProviderDisposedError;
|
|
820
|
+
exports.ScopedFromRootError = ScopedFromRootError;
|
|
821
|
+
exports.Service = Service;
|
|
822
|
+
exports.ServiceCollection = ServiceCollection;
|
|
823
|
+
exports.ServiceDefinition = ServiceDefinition;
|
|
824
|
+
exports.ServiceProvider = ServiceProvider;
|
|
825
|
+
exports.UnresolvableParameterError = UnresolvableParameterError;
|
|
826
|
+
exports.alias = alias;
|
|
827
|
+
exports.buildServiceProvider = buildServiceProvider;
|
|
828
|
+
exports.defineMetadata = defineMetadata;
|
|
829
|
+
exports.describe = describe;
|
|
830
|
+
exports.factory = factory;
|
|
831
|
+
exports.getConstructorParameters = getConstructorParameters;
|
|
832
|
+
exports.getMetadata = getMetadata;
|
|
833
|
+
exports.getOwnMetadata = getOwnMetadata;
|
|
834
|
+
exports.getServiceOptions = getServiceOptions;
|
|
835
|
+
exports.hasMetadata = hasMetadata;
|
|
836
|
+
exports.hasOwnMetadata = hasOwnMetadata;
|
|
837
|
+
exports.installReflectShim = installReflectShim;
|
|
838
|
+
exports.isConstructor = isConstructor;
|
|
839
|
+
exports.isService = isService;
|
|
840
|
+
exports.normalizeProvider = normalizeProvider;
|
|
841
|
+
exports.scoped = scoped;
|
|
842
|
+
exports.service = service;
|
|
843
|
+
exports.singleton = singleton;
|
|
844
|
+
exports.tokenName = tokenName;
|
|
845
|
+
exports.transient = transient;
|
|
846
|
+
exports.value = value;
|
|
847
|
+
//# sourceMappingURL=index.cjs.map
|