@codefast/di 0.3.13-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/LICENSE +21 -0
- package/README.md +572 -0
- package/dist/binding-select.d.mts +22 -0
- package/dist/binding-select.mjs +50 -0
- package/dist/binding.d.mts +219 -0
- package/dist/binding.mjs +240 -0
- package/dist/constraints.d.mts +18 -0
- package/dist/constraints.mjs +24 -0
- package/dist/container.d.mts +82 -0
- package/dist/container.mjs +406 -0
- package/dist/decorators/inject.d.mts +24 -0
- package/dist/decorators/inject.mjs +69 -0
- package/dist/decorators/injectable.d.mts +40 -0
- package/dist/decorators/injectable.mjs +62 -0
- package/dist/decorators/lifecycle-decorators.d.mts +13 -0
- package/dist/decorators/lifecycle-decorators.mjs +34 -0
- package/dist/dependency-graph.d.mts +35 -0
- package/dist/dependency-graph.mjs +126 -0
- package/dist/environment.d.mts +14 -0
- package/dist/environment.mjs +20 -0
- package/dist/errors.d.mts +100 -0
- package/dist/errors.mjs +152 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +8 -0
- package/dist/inspector.d.mts +76 -0
- package/dist/inspector.mjs +247 -0
- package/dist/lifecycle.d.mts +34 -0
- package/dist/lifecycle.mjs +83 -0
- package/dist/metadata/metadata-keys.d.mts +17 -0
- package/dist/metadata/metadata-keys.mjs +19 -0
- package/dist/metadata/metadata-types.d.mts +55 -0
- package/dist/metadata/metadata-types.mjs +1 -0
- package/dist/metadata/param-registry.d.mts +16 -0
- package/dist/metadata/param-registry.mjs +25 -0
- package/dist/metadata/symbol-metadata-reader.d.mts +15 -0
- package/dist/metadata/symbol-metadata-reader.mjs +32 -0
- package/dist/module.d.mts +60 -0
- package/dist/module.mjs +57 -0
- package/dist/registry.d.mts +38 -0
- package/dist/registry.mjs +65 -0
- package/dist/resolver.d.mts +102 -0
- package/dist/resolver.mjs +361 -0
- package/dist/scope-validation.d.mts +20 -0
- package/dist/scope-validation.mjs +34 -0
- package/dist/scope.d.mts +80 -0
- package/dist/scope.mjs +185 -0
- package/dist/token.d.mts +20 -0
- package/dist/token.mjs +9 -0
- package/package.json +157 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ScopeViolationError } from "./errors.mjs";
|
|
2
|
+
import { registryKeyLabel } from "./binding-select.mjs";
|
|
3
|
+
import { listResolvedDependencies } from "./dependency-graph.mjs";
|
|
4
|
+
//#region src/scope-validation.ts
|
|
5
|
+
/**
|
|
6
|
+
* Walks every binding in the registry and throws {@link ScopeViolationError} on the first
|
|
7
|
+
* captive-dependency violation found: a singleton that directly or transitively depends on a
|
|
8
|
+
* scoped or transient binding. Constant bindings are exempt (no stateful instance to capture).
|
|
9
|
+
*
|
|
10
|
+
* Called by {@link Container.validate} and automatically after each `load()` in non-production
|
|
11
|
+
* environments.
|
|
12
|
+
*/
|
|
13
|
+
function validateScopeRules(context) {
|
|
14
|
+
const reader = context.getMetadataReader();
|
|
15
|
+
const lookupBindings = (key) => context.lookupBindings(key);
|
|
16
|
+
for (const registryKey of context.collectAllRegistryKeys()) {
|
|
17
|
+
const bindings = lookupBindings(registryKey);
|
|
18
|
+
if (bindings === void 0 || bindings.length === 0) continue;
|
|
19
|
+
for (const consumer of bindings) {
|
|
20
|
+
const deps = listResolvedDependencies(consumer, lookupBindings, reader, [registryKeyLabel(registryKey)]);
|
|
21
|
+
for (const dep of deps) if (consumer.scope === "singleton" && dep.binding.kind !== "constant" && (dep.binding.scope === "transient" || dep.binding.scope === "scoped")) throw new ScopeViolationError({
|
|
22
|
+
consumerBindingId: consumer.id,
|
|
23
|
+
consumerKind: consumer.kind,
|
|
24
|
+
consumerScope: consumer.scope,
|
|
25
|
+
dependencyBindingId: dep.binding.id,
|
|
26
|
+
dependencyKind: dep.binding.kind,
|
|
27
|
+
dependencyScope: dep.binding.scope,
|
|
28
|
+
resolutionPath: dep.path
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { validateScopeRules };
|
package/dist/scope.d.mts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Binding, BindingIdentifier } from "./binding.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/scope.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Caches singleton and scoped instances and runs deactivation hooks on disposal.
|
|
6
|
+
*/
|
|
7
|
+
declare class ScopeManager {
|
|
8
|
+
/** Cached singleton instances: `bindingId → { binding, instance }`. */
|
|
9
|
+
private readonly singletonCache;
|
|
10
|
+
/** Cached scoped instances for this container level: `bindingId → { binding, instance }`. */
|
|
11
|
+
private readonly scopedCache;
|
|
12
|
+
private readonly ownsSingletonDisposal;
|
|
13
|
+
/** In-flight async singleton creation promises (deduplicate concurrent resolveAsync calls). */
|
|
14
|
+
private readonly singletonPendingPromises;
|
|
15
|
+
private readonly scopedPendingPromises;
|
|
16
|
+
private constructor();
|
|
17
|
+
/** Creates a root scope manager that owns both the singleton cache and scoped cache. */
|
|
18
|
+
static createRoot(): ScopeManager;
|
|
19
|
+
/**
|
|
20
|
+
* Shares the parent singleton cache; receives a fresh scoped cache (for child containers).
|
|
21
|
+
*/
|
|
22
|
+
createChildScope(): ScopeManager;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a singleton/scoped binding currently has a cached instance (always false for transient).
|
|
25
|
+
*/
|
|
26
|
+
isBindingCached(binding: Binding<unknown>): boolean;
|
|
27
|
+
/** Returns the cached instance for singleton/scoped bindings, or calls `createInstance` on first access. */
|
|
28
|
+
getOrCreate(binding: Binding<unknown>, createInstance: () => unknown): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Async variant of {@link getOrCreate}. Deduplicates concurrent creation calls for the same
|
|
31
|
+
* binding using an in-flight promise map, preventing double-instantiation under parallel resolves.
|
|
32
|
+
*/
|
|
33
|
+
getOrCreateAsync(binding: Binding<unknown>, createInstance: () => Promise<unknown>): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Runs synchronous `onDeactivation` hooks for scoped instances owned by this manager.
|
|
36
|
+
* Throws if any hook returns a Promise.
|
|
37
|
+
*/
|
|
38
|
+
dispose(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Runs `onDeactivation` hooks for scoped instances; root also disposes shared singletons.
|
|
41
|
+
*/
|
|
42
|
+
disposeAsync(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Drops a cached singleton/scoped instance for `bindingId` and runs `onDeactivation` synchronously.
|
|
45
|
+
*/
|
|
46
|
+
releaseByBindingId(bindingId: BindingIdentifier): void;
|
|
47
|
+
/**
|
|
48
|
+
* Drops a cached singleton/scoped instance for `bindingId` and awaits `onDeactivation`.
|
|
49
|
+
*/
|
|
50
|
+
releaseByBindingIdAsync(bindingId: BindingIdentifier): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Drops a cached singleton/scoped instance for `binding.id` and runs `onDeactivation` synchronously.
|
|
53
|
+
*/
|
|
54
|
+
releaseBinding(binding: Binding<unknown>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Drops a cached singleton/scoped instance for `binding.id` and awaits `onDeactivation`.
|
|
57
|
+
*/
|
|
58
|
+
releaseBindingAsync(binding: Binding<unknown>): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a single entry from `store`, runs `onDeactivation` synchronously, then calls
|
|
61
|
+
* `@preDestroy`. Throws {@link InternalError} if the handler returns a Promise.
|
|
62
|
+
*/
|
|
63
|
+
private releaseFromStore;
|
|
64
|
+
/**
|
|
65
|
+
* Async counterpart of {@link releaseFromStore}: awaits `onDeactivation` then `@preDestroy`.
|
|
66
|
+
*/
|
|
67
|
+
private releaseFromStoreAsync;
|
|
68
|
+
/**
|
|
69
|
+
* Iterates all entries in `store`, clears each one, runs `onDeactivation` + `@preDestroy`
|
|
70
|
+
* synchronously. Throws {@link InternalError} if any handler returns a Promise.
|
|
71
|
+
*/
|
|
72
|
+
private disposeMap;
|
|
73
|
+
/**
|
|
74
|
+
* Async counterpart of {@link disposeMap}: clears the store first, then runs all
|
|
75
|
+
* deactivation hooks; collects errors and rethrows as `AggregateError` when multiple fail.
|
|
76
|
+
*/
|
|
77
|
+
private disposeMapAsync;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { ScopeManager };
|
package/dist/scope.mjs
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { InternalError } from "./errors.mjs";
|
|
2
|
+
import { runPreDestroy, runPreDestroyAsync } from "./lifecycle.mjs";
|
|
3
|
+
//#region src/scope.ts
|
|
4
|
+
/** Returns `true` when `value` is a thenable (duck-typed Promise check). */
|
|
5
|
+
function isPromiseLike(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Caches singleton and scoped instances and runs deactivation hooks on disposal.
|
|
10
|
+
*/
|
|
11
|
+
var ScopeManager = class ScopeManager {
|
|
12
|
+
/** Cached singleton instances: `bindingId → { binding, instance }`. */
|
|
13
|
+
singletonCache;
|
|
14
|
+
/** Cached scoped instances for this container level: `bindingId → { binding, instance }`. */
|
|
15
|
+
scopedCache;
|
|
16
|
+
ownsSingletonDisposal;
|
|
17
|
+
/** In-flight async singleton creation promises (deduplicate concurrent resolveAsync calls). */
|
|
18
|
+
singletonPendingPromises;
|
|
19
|
+
scopedPendingPromises;
|
|
20
|
+
constructor(singletonCache, scopedCache, ownsSingletonDisposal, singletonPendingPromises, scopedPendingPromises) {
|
|
21
|
+
this.singletonCache = singletonCache;
|
|
22
|
+
this.scopedCache = scopedCache;
|
|
23
|
+
this.ownsSingletonDisposal = ownsSingletonDisposal;
|
|
24
|
+
this.singletonPendingPromises = singletonPendingPromises;
|
|
25
|
+
this.scopedPendingPromises = scopedPendingPromises;
|
|
26
|
+
}
|
|
27
|
+
/** Creates a root scope manager that owns both the singleton cache and scoped cache. */
|
|
28
|
+
static createRoot() {
|
|
29
|
+
return new ScopeManager(/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), true, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Shares the parent singleton cache; receives a fresh scoped cache (for child containers).
|
|
33
|
+
*/
|
|
34
|
+
createChildScope() {
|
|
35
|
+
return new ScopeManager(this.singletonCache, /* @__PURE__ */ new Map(), false, this.singletonPendingPromises, /* @__PURE__ */ new Map());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a singleton/scoped binding currently has a cached instance (always false for transient).
|
|
39
|
+
*/
|
|
40
|
+
isBindingCached(binding) {
|
|
41
|
+
if (binding.scope === "transient") return false;
|
|
42
|
+
return (binding.scope === "singleton" ? this.singletonCache : this.scopedCache).has(binding.id);
|
|
43
|
+
}
|
|
44
|
+
/** Returns the cached instance for singleton/scoped bindings, or calls `createInstance` on first access. */
|
|
45
|
+
getOrCreate(binding, createInstance) {
|
|
46
|
+
if (binding.scope === "transient") return createInstance();
|
|
47
|
+
const cache = binding.scope === "singleton" ? this.singletonCache : this.scopedCache;
|
|
48
|
+
const cached = cache.get(binding.id);
|
|
49
|
+
if (cached !== void 0) return cached.instance;
|
|
50
|
+
const instance = createInstance();
|
|
51
|
+
cache.set(binding.id, {
|
|
52
|
+
binding,
|
|
53
|
+
instance
|
|
54
|
+
});
|
|
55
|
+
return instance;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Async variant of {@link getOrCreate}. Deduplicates concurrent creation calls for the same
|
|
59
|
+
* binding using an in-flight promise map, preventing double-instantiation under parallel resolves.
|
|
60
|
+
*/
|
|
61
|
+
async getOrCreateAsync(binding, createInstance) {
|
|
62
|
+
if (binding.scope === "transient") return createInstance();
|
|
63
|
+
const cache = binding.scope === "singleton" ? this.singletonCache : this.scopedCache;
|
|
64
|
+
const pendingCreationMap = binding.scope === "singleton" ? this.singletonPendingPromises : this.scopedPendingPromises;
|
|
65
|
+
const cached = cache.get(binding.id);
|
|
66
|
+
if (cached !== void 0) return cached.instance;
|
|
67
|
+
let pendingCreation = pendingCreationMap.get(binding.id);
|
|
68
|
+
if (pendingCreation === void 0) {
|
|
69
|
+
pendingCreation = (async () => {
|
|
70
|
+
try {
|
|
71
|
+
const instance = await createInstance();
|
|
72
|
+
cache.set(binding.id, {
|
|
73
|
+
binding,
|
|
74
|
+
instance
|
|
75
|
+
});
|
|
76
|
+
return instance;
|
|
77
|
+
} finally {
|
|
78
|
+
pendingCreationMap.delete(binding.id);
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
pendingCreationMap.set(binding.id, pendingCreation);
|
|
82
|
+
}
|
|
83
|
+
return pendingCreation;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Runs synchronous `onDeactivation` hooks for scoped instances owned by this manager.
|
|
87
|
+
* Throws if any hook returns a Promise.
|
|
88
|
+
*/
|
|
89
|
+
dispose() {
|
|
90
|
+
this.disposeMap(this.scopedCache);
|
|
91
|
+
if (this.ownsSingletonDisposal) this.disposeMap(this.singletonCache);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Runs `onDeactivation` hooks for scoped instances; root also disposes shared singletons.
|
|
95
|
+
*/
|
|
96
|
+
async disposeAsync() {
|
|
97
|
+
await this.disposeMapAsync(this.scopedCache);
|
|
98
|
+
if (this.ownsSingletonDisposal) await this.disposeMapAsync(this.singletonCache);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Drops a cached singleton/scoped instance for `bindingId` and runs `onDeactivation` synchronously.
|
|
102
|
+
*/
|
|
103
|
+
releaseByBindingId(bindingId) {
|
|
104
|
+
this.releaseFromStore(this.singletonCache, bindingId);
|
|
105
|
+
this.releaseFromStore(this.scopedCache, bindingId);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Drops a cached singleton/scoped instance for `bindingId` and awaits `onDeactivation`.
|
|
109
|
+
*/
|
|
110
|
+
async releaseByBindingIdAsync(bindingId) {
|
|
111
|
+
await this.releaseFromStoreAsync(this.singletonCache, bindingId);
|
|
112
|
+
await this.releaseFromStoreAsync(this.scopedCache, bindingId);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Drops a cached singleton/scoped instance for `binding.id` and runs `onDeactivation` synchronously.
|
|
116
|
+
*/
|
|
117
|
+
releaseBinding(binding) {
|
|
118
|
+
this.releaseByBindingId(binding.id);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Drops a cached singleton/scoped instance for `binding.id` and awaits `onDeactivation`.
|
|
122
|
+
*/
|
|
123
|
+
async releaseBindingAsync(binding) {
|
|
124
|
+
await this.releaseByBindingIdAsync(binding.id);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Removes a single entry from `store`, runs `onDeactivation` synchronously, then calls
|
|
128
|
+
* `@preDestroy`. Throws {@link InternalError} if the handler returns a Promise.
|
|
129
|
+
*/
|
|
130
|
+
releaseFromStore(store, bindingId) {
|
|
131
|
+
const entry = store.get(bindingId);
|
|
132
|
+
if (entry === void 0) return;
|
|
133
|
+
store.delete(bindingId);
|
|
134
|
+
const handler = entry.binding.onDeactivation;
|
|
135
|
+
if (handler !== void 0) {
|
|
136
|
+
if (isPromiseLike(handler(entry.instance))) throw new InternalError("onDeactivation returned a Promise during synchronous scope release; use releaseBindingAsync() or unloadAsync().");
|
|
137
|
+
}
|
|
138
|
+
if (entry.binding.kind === "class") runPreDestroy(entry.binding.implementationClass, entry.instance);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Async counterpart of {@link releaseFromStore}: awaits `onDeactivation` then `@preDestroy`.
|
|
142
|
+
*/
|
|
143
|
+
async releaseFromStoreAsync(store, bindingId) {
|
|
144
|
+
const entry = store.get(bindingId);
|
|
145
|
+
if (entry === void 0) return;
|
|
146
|
+
store.delete(bindingId);
|
|
147
|
+
const handler = entry.binding.onDeactivation;
|
|
148
|
+
if (handler !== void 0) await handler(entry.instance);
|
|
149
|
+
if (entry.binding.kind === "class") await runPreDestroyAsync(entry.binding.implementationClass, entry.instance);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Iterates all entries in `store`, clears each one, runs `onDeactivation` + `@preDestroy`
|
|
153
|
+
* synchronously. Throws {@link InternalError} if any handler returns a Promise.
|
|
154
|
+
*/
|
|
155
|
+
disposeMap(store) {
|
|
156
|
+
for (const [bindingId, entry] of [...store.entries()]) {
|
|
157
|
+
store.delete(bindingId);
|
|
158
|
+
const handler = entry.binding.onDeactivation;
|
|
159
|
+
if (handler !== void 0) {
|
|
160
|
+
if (isPromiseLike(handler(entry.instance))) throw new InternalError("onDeactivation returned a Promise; use disposeAsync() instead of dispose().");
|
|
161
|
+
}
|
|
162
|
+
if (entry.binding.kind === "class") runPreDestroy(entry.binding.implementationClass, entry.instance);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Async counterpart of {@link disposeMap}: clears the store first, then runs all
|
|
167
|
+
* deactivation hooks; collects errors and rethrows as `AggregateError` when multiple fail.
|
|
168
|
+
*/
|
|
169
|
+
async disposeMapAsync(store) {
|
|
170
|
+
const entries = [...store.values()];
|
|
171
|
+
store.clear();
|
|
172
|
+
const errors = [];
|
|
173
|
+
for (const entry of entries) try {
|
|
174
|
+
const handler = entry.binding.onDeactivation;
|
|
175
|
+
if (handler !== void 0) await handler(entry.instance);
|
|
176
|
+
if (entry.binding.kind === "class") await runPreDestroyAsync(entry.binding.implementationClass, entry.instance);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
errors.push(error);
|
|
179
|
+
}
|
|
180
|
+
if (errors.length === 1) throw errors[0];
|
|
181
|
+
if (errors.length > 1) throw new AggregateError(errors, "disposeAsync: multiple deactivation handlers failed");
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
export { ScopeManager };
|
package/dist/token.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/token.d.ts
|
|
2
|
+
declare const TOKEN_BRAND: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Opaque injection key branded by `Value` so distinct tokens do not unify in the type system.
|
|
5
|
+
* Registry keys rely on **reference equality** — always reuse the same `token()` result as the key.
|
|
6
|
+
*/
|
|
7
|
+
type Token<Value> = {
|
|
8
|
+
readonly [TOKEN_BRAND]: Value;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Extracts the value type carried by a {@link Token}.
|
|
13
|
+
*/
|
|
14
|
+
type TokenValue<Type> = Type extends Token<infer Value> ? Value : Type extends (abstract new (...args: never[]) => infer Value) ? Value : never;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a type-safe injection token identified by `name` (for debugging and errors).
|
|
17
|
+
*/
|
|
18
|
+
declare function token<Value>(name: string): Token<Value>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Token, TokenValue, token };
|
package/dist/token.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codefast/di",
|
|
3
|
+
"version": "0.3.13-canary.4",
|
|
4
|
+
"description": "Lightweight dependency injection primitives for Codefast",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"codefast",
|
|
7
|
+
"dependency-injection",
|
|
8
|
+
"di",
|
|
9
|
+
"inversion-of-control",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Vuong Phan <mr.thevuong@gmail.com>",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/codefastlabs/codefast.git",
|
|
17
|
+
"directory": "packages/di"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.mjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"imports": {
|
|
31
|
+
"#/*": [
|
|
32
|
+
"./src/*",
|
|
33
|
+
"./src/*.ts",
|
|
34
|
+
"./src/*.tsx",
|
|
35
|
+
"./src/*/index.ts",
|
|
36
|
+
"./src/*/index.tsx"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.mts",
|
|
42
|
+
"import": "./dist/index.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./binding": {
|
|
45
|
+
"types": "./dist/binding.d.mts",
|
|
46
|
+
"import": "./dist/binding.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./binding-select": {
|
|
49
|
+
"types": "./dist/binding-select.d.mts",
|
|
50
|
+
"import": "./dist/binding-select.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./constraints": {
|
|
53
|
+
"types": "./dist/constraints.d.mts",
|
|
54
|
+
"import": "./dist/constraints.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./container": {
|
|
57
|
+
"types": "./dist/container.d.mts",
|
|
58
|
+
"import": "./dist/container.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./decorators/inject": {
|
|
61
|
+
"types": "./dist/decorators/inject.d.mts",
|
|
62
|
+
"import": "./dist/decorators/inject.mjs"
|
|
63
|
+
},
|
|
64
|
+
"./decorators/injectable": {
|
|
65
|
+
"types": "./dist/decorators/injectable.d.mts",
|
|
66
|
+
"import": "./dist/decorators/injectable.mjs"
|
|
67
|
+
},
|
|
68
|
+
"./decorators/lifecycle-decorators": {
|
|
69
|
+
"types": "./dist/decorators/lifecycle-decorators.d.mts",
|
|
70
|
+
"import": "./dist/decorators/lifecycle-decorators.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./dependency-graph": {
|
|
73
|
+
"types": "./dist/dependency-graph.d.mts",
|
|
74
|
+
"import": "./dist/dependency-graph.mjs"
|
|
75
|
+
},
|
|
76
|
+
"./environment": {
|
|
77
|
+
"types": "./dist/environment.d.mts",
|
|
78
|
+
"import": "./dist/environment.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./errors": {
|
|
81
|
+
"types": "./dist/errors.d.mts",
|
|
82
|
+
"import": "./dist/errors.mjs"
|
|
83
|
+
},
|
|
84
|
+
"./inspector": {
|
|
85
|
+
"types": "./dist/inspector.d.mts",
|
|
86
|
+
"import": "./dist/inspector.mjs"
|
|
87
|
+
},
|
|
88
|
+
"./lifecycle": {
|
|
89
|
+
"types": "./dist/lifecycle.d.mts",
|
|
90
|
+
"import": "./dist/lifecycle.mjs"
|
|
91
|
+
},
|
|
92
|
+
"./metadata/metadata-keys": {
|
|
93
|
+
"types": "./dist/metadata/metadata-keys.d.mts",
|
|
94
|
+
"import": "./dist/metadata/metadata-keys.mjs"
|
|
95
|
+
},
|
|
96
|
+
"./metadata/metadata-types": {
|
|
97
|
+
"types": "./dist/metadata/metadata-types.d.mts",
|
|
98
|
+
"import": "./dist/metadata/metadata-types.mjs"
|
|
99
|
+
},
|
|
100
|
+
"./metadata/param-registry": {
|
|
101
|
+
"types": "./dist/metadata/param-registry.d.mts",
|
|
102
|
+
"import": "./dist/metadata/param-registry.mjs"
|
|
103
|
+
},
|
|
104
|
+
"./metadata/symbol-metadata-reader": {
|
|
105
|
+
"types": "./dist/metadata/symbol-metadata-reader.d.mts",
|
|
106
|
+
"import": "./dist/metadata/symbol-metadata-reader.mjs"
|
|
107
|
+
},
|
|
108
|
+
"./module": {
|
|
109
|
+
"types": "./dist/module.d.mts",
|
|
110
|
+
"import": "./dist/module.mjs"
|
|
111
|
+
},
|
|
112
|
+
"./registry": {
|
|
113
|
+
"types": "./dist/registry.d.mts",
|
|
114
|
+
"import": "./dist/registry.mjs"
|
|
115
|
+
},
|
|
116
|
+
"./resolver": {
|
|
117
|
+
"types": "./dist/resolver.d.mts",
|
|
118
|
+
"import": "./dist/resolver.mjs"
|
|
119
|
+
},
|
|
120
|
+
"./scope": {
|
|
121
|
+
"types": "./dist/scope.d.mts",
|
|
122
|
+
"import": "./dist/scope.mjs"
|
|
123
|
+
},
|
|
124
|
+
"./scope-validation": {
|
|
125
|
+
"types": "./dist/scope-validation.d.mts",
|
|
126
|
+
"import": "./dist/scope-validation.mjs"
|
|
127
|
+
},
|
|
128
|
+
"./token": {
|
|
129
|
+
"types": "./dist/token.d.mts",
|
|
130
|
+
"import": "./dist/token.mjs"
|
|
131
|
+
},
|
|
132
|
+
"./package.json": "./package.json"
|
|
133
|
+
},
|
|
134
|
+
"publishConfig": {
|
|
135
|
+
"access": "public"
|
|
136
|
+
},
|
|
137
|
+
"devDependencies": {
|
|
138
|
+
"@types/node": "^25.6.0",
|
|
139
|
+
"@typescript/native-preview": "7.0.0-dev.20260411.1",
|
|
140
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
141
|
+
"typescript": "^6.0.2",
|
|
142
|
+
"unplugin-swc": "^1.5.9",
|
|
143
|
+
"vitest": "^4.1.4",
|
|
144
|
+
"@codefast/typescript-config": "0.3.13-canary.4"
|
|
145
|
+
},
|
|
146
|
+
"engines": {
|
|
147
|
+
"node": ">=22.0.0"
|
|
148
|
+
},
|
|
149
|
+
"scripts": {
|
|
150
|
+
"build": "tsdown",
|
|
151
|
+
"check-types": "tsgo --noEmit",
|
|
152
|
+
"clean": "rm -rf dist",
|
|
153
|
+
"test": "vitest run",
|
|
154
|
+
"test:coverage": "vitest run --coverage",
|
|
155
|
+
"test:watch": "vitest"
|
|
156
|
+
}
|
|
157
|
+
}
|