@zudojs/container 0.1.0 → 1.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 +221 -8
- package/dist/containerCore/containerCore.core.d.ts +112 -14
- package/dist/containerCore/containerCore.core.js +228 -46
- package/dist/containerCore/containerCore.scope.d.ts +66 -18
- package/dist/containerCore/containerCore.scope.js +120 -31
- package/dist/containerCore/containerCore.type.d.ts +22 -16
- package/dist/containerLifecycle/containerLifecycle.core.d.ts +59 -9
- package/dist/containerLifecycle/containerLifecycle.core.js +60 -15
- package/dist/containerOptions/containerOptions.type.d.ts +7 -17
- package/dist/containerOptions/containerOptions.type.js +0 -19
- package/dist/containerProvider/containerProvider.core.d.ts +11 -3
- package/dist/containerProvider/containerProvider.core.js +11 -5
- package/dist/containerRegistration/containerRegistration.core.d.ts +9 -3
- package/dist/containerRegistration/containerRegistration.core.js +0 -6
- package/dist/containerRegistry/containerRegistry.core.d.ts +23 -9
- package/dist/containerRegistry/containerRegistry.core.js +50 -47
- package/dist/containerRegistry/containerRegistry.type.d.ts +3 -1
- package/dist/containerRegistry/containerRegistry.type.js +2 -0
- package/dist/containerRegistry/index.d.ts +0 -1
- package/dist/containerRegistry/index.js +0 -1
- package/dist/containerResolution/containerResolution.core.d.ts +51 -10
- package/dist/containerResolution/containerResolution.core.js +255 -64
- package/dist/containerResolution/containerResolution.error.d.ts +68 -3
- package/dist/containerResolution/containerResolution.error.js +107 -3
- package/dist/containerResolution/containerResolution.type.d.ts +35 -3
- package/dist/containerResolution/index.d.ts +1 -0
- package/dist/containerResolution/index.js +1 -0
- package/dist/containerToken/containerToken.type.d.ts +26 -1
- package/dist/containerToken/containerToken.type.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/package.json +25 -12
- package/dist/.tsbuildinfo +0 -1
- package/dist/containerCore/containerCore.core.d.ts.map +0 -1
- package/dist/containerCore/containerCore.core.js.map +0 -1
- package/dist/containerCore/containerCore.scope.d.ts.map +0 -1
- package/dist/containerCore/containerCore.scope.js.map +0 -1
- package/dist/containerCore/containerCore.type.d.ts.map +0 -1
- package/dist/containerCore/containerCore.type.js.map +0 -1
- package/dist/containerCore/index.d.ts.map +0 -1
- package/dist/containerCore/index.js.map +0 -1
- package/dist/containerLifecycle/containerLifecycle.core.d.ts.map +0 -1
- package/dist/containerLifecycle/containerLifecycle.core.js.map +0 -1
- package/dist/containerLifecycle/index.d.ts.map +0 -1
- package/dist/containerLifecycle/index.js.map +0 -1
- package/dist/containerOptions/containerOptions.type.d.ts.map +0 -1
- package/dist/containerOptions/containerOptions.type.js.map +0 -1
- package/dist/containerOptions/index.d.ts.map +0 -1
- package/dist/containerOptions/index.js.map +0 -1
- package/dist/containerProvider/containerProvider.core.d.ts.map +0 -1
- package/dist/containerProvider/containerProvider.core.js.map +0 -1
- package/dist/containerProvider/index.d.ts.map +0 -1
- package/dist/containerProvider/index.js.map +0 -1
- package/dist/containerRegistration/containerRegistration.core.d.ts.map +0 -1
- package/dist/containerRegistration/containerRegistration.core.js.map +0 -1
- package/dist/containerRegistration/index.d.ts.map +0 -1
- package/dist/containerRegistration/index.js.map +0 -1
- package/dist/containerRegistry/containerRegistry.core.d.ts.map +0 -1
- package/dist/containerRegistry/containerRegistry.core.js.map +0 -1
- package/dist/containerRegistry/containerRegistry.error.d.ts +0 -12
- package/dist/containerRegistry/containerRegistry.error.d.ts.map +0 -1
- package/dist/containerRegistry/containerRegistry.error.js +0 -22
- package/dist/containerRegistry/containerRegistry.error.js.map +0 -1
- package/dist/containerRegistry/containerRegistry.type.d.ts.map +0 -1
- package/dist/containerRegistry/containerRegistry.type.js.map +0 -1
- package/dist/containerRegistry/index.d.ts.map +0 -1
- package/dist/containerRegistry/index.js.map +0 -1
- package/dist/containerResolution/containerResolution.core.d.ts.map +0 -1
- package/dist/containerResolution/containerResolution.core.js.map +0 -1
- package/dist/containerResolution/containerResolution.error.d.ts.map +0 -1
- package/dist/containerResolution/containerResolution.error.js.map +0 -1
- package/dist/containerResolution/containerResolution.type.d.ts.map +0 -1
- package/dist/containerResolution/containerResolution.type.js.map +0 -1
- package/dist/containerResolution/index.d.ts.map +0 -1
- package/dist/containerResolution/index.js.map +0 -1
- package/dist/containerScope/containerScope.type.d.ts.map +0 -1
- package/dist/containerScope/containerScope.type.js.map +0 -1
- package/dist/containerScope/index.d.ts.map +0 -1
- package/dist/containerScope/index.js.map +0 -1
- package/dist/containerToken/containerToken.type.d.ts.map +0 -1
- package/dist/containerToken/containerToken.type.js.map +0 -1
- package/dist/containerToken/index.d.ts.map +0 -1
- package/dist/containerToken/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
* Dependency injection token definitions for Zudojs.
|
|
3
3
|
* Tokens identify dependencies within the container.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* A class constructor usable as a token or provider implementation.
|
|
7
|
+
*
|
|
8
|
+
* The parameter list is intentionally loose (`any[]`) so classes with typed
|
|
9
|
+
* constructor parameters are accepted; the container supplies arguments via
|
|
10
|
+
* the provider's `inject` list (or none for zero-arg constructors).
|
|
11
|
+
*/
|
|
5
12
|
export interface Constructor<T = unknown> {
|
|
6
|
-
new (...args:
|
|
13
|
+
new (...args: any[]): T;
|
|
7
14
|
}
|
|
8
15
|
export type TokenSymbol = symbol;
|
|
9
16
|
export type TokenString = string;
|
|
@@ -12,7 +19,25 @@ export interface InjectionToken<T = unknown> {
|
|
|
12
19
|
readonly token: Token<T>;
|
|
13
20
|
readonly description?: string;
|
|
14
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a unique, typed injection token backed by a fresh `Symbol`.
|
|
24
|
+
*
|
|
25
|
+
* Note on typing: plain string and symbol tokens are *untyped casts* — the
|
|
26
|
+
* container cannot verify at compile time that the value registered under a
|
|
27
|
+
* string/symbol actually has type `T`. Prefer `InjectionToken`s created here
|
|
28
|
+
* (or constructor tokens) so the association between token and type lives in
|
|
29
|
+
* one place.
|
|
30
|
+
*/
|
|
15
31
|
export declare function createToken<T>(description: string): InjectionToken<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a typed injection token backed by `Symbol.for(key)`.
|
|
34
|
+
*
|
|
35
|
+
* Because `Symbol.for` uses the process-wide global symbol registry, two
|
|
36
|
+
* independent calls (even from different packages) with the same `key`
|
|
37
|
+
* produce the SAME token and will collide in the container — this is by
|
|
38
|
+
* design for cross-package sharing, but means keys must be namespaced
|
|
39
|
+
* (e.g. `"myapp:db"`). Use {@link createToken} for collision-free tokens.
|
|
40
|
+
*/
|
|
16
41
|
export declare function createGlobalToken<T>(key: string): InjectionToken<T>;
|
|
17
42
|
export declare function unwrapToken<T>(token: Token<T> | InjectionToken<T>): Token<T>;
|
|
18
43
|
export declare function isInjectionToken<T = unknown>(value: unknown): value is InjectionToken<T>;
|
|
@@ -2,9 +2,27 @@
|
|
|
2
2
|
* Dependency injection token definitions for Zudojs.
|
|
3
3
|
* Tokens identify dependencies within the container.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a unique, typed injection token backed by a fresh `Symbol`.
|
|
7
|
+
*
|
|
8
|
+
* Note on typing: plain string and symbol tokens are *untyped casts* — the
|
|
9
|
+
* container cannot verify at compile time that the value registered under a
|
|
10
|
+
* string/symbol actually has type `T`. Prefer `InjectionToken`s created here
|
|
11
|
+
* (or constructor tokens) so the association between token and type lives in
|
|
12
|
+
* one place.
|
|
13
|
+
*/
|
|
5
14
|
export function createToken(description) {
|
|
6
15
|
return Object.freeze({ token: Symbol(description), description });
|
|
7
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a typed injection token backed by `Symbol.for(key)`.
|
|
19
|
+
*
|
|
20
|
+
* Because `Symbol.for` uses the process-wide global symbol registry, two
|
|
21
|
+
* independent calls (even from different packages) with the same `key`
|
|
22
|
+
* produce the SAME token and will collide in the container — this is by
|
|
23
|
+
* design for cross-package sharing, but means keys must be namespaced
|
|
24
|
+
* (e.g. `"myapp:db"`). Use {@link createToken} for collision-free tokens.
|
|
25
|
+
*/
|
|
8
26
|
export function createGlobalToken(key) {
|
|
9
27
|
return Object.freeze({ token: Symbol.for(key), description: key });
|
|
10
28
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export * from "./containerRegistry/index.js";
|
|
|
12
12
|
export * from "./containerResolution/index.js";
|
|
13
13
|
export * from "./containerScope/index.js";
|
|
14
14
|
export * from "./containerToken/index.js";
|
|
15
|
+
export { CircularDependencyError, DuplicateRegistrationError, RegistrationNotFoundError, ProviderResolutionError, } from "@zudojs/errors";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,7 @@ export * from "./containerRegistry/index.js";
|
|
|
12
12
|
export * from "./containerResolution/index.js";
|
|
13
13
|
export * from "./containerScope/index.js";
|
|
14
14
|
export * from "./containerToken/index.js";
|
|
15
|
+
// Error classes the container throws but that live in @zudojs/errors,
|
|
16
|
+
// re-exported so `instanceof` checks need only this package.
|
|
17
|
+
export { CircularDependencyError, DuplicateRegistrationError, RegistrationNotFoundError, ProviderResolutionError, } from "@zudojs/errors";
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/container",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Token-based dependency injection container for managing application dependencies and service lifetimes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,27 +12,29 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist"
|
|
15
|
+
"dist",
|
|
16
|
+
"!dist/**/*.map",
|
|
17
|
+
"!dist/**/*.tsbuildinfo",
|
|
18
|
+
"!dist/.tsbuildinfo"
|
|
16
19
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc -p tsconfig.json",
|
|
19
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
20
|
-
"clean": "tsc -p tsconfig.json --clean"
|
|
21
|
-
},
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"@zudojs/errors": "0.1
|
|
21
|
+
"@zudojs/errors": "1.0.1"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
26
|
-
"typescript": "
|
|
24
|
+
"typescript": "7.0.2",
|
|
25
|
+
"vitest": "^4.1.11"
|
|
27
26
|
},
|
|
28
27
|
"license": "MIT",
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Oluwayemi Oyinlola",
|
|
30
|
+
"url": "https://github.com/oyinlola-tech"
|
|
31
|
+
},
|
|
29
32
|
"publishConfig": {
|
|
30
33
|
"access": "public"
|
|
31
34
|
},
|
|
32
35
|
"engines": {
|
|
33
36
|
"node": ">=24.0.0"
|
|
34
37
|
},
|
|
35
|
-
"module": "./dist/index.js",
|
|
36
38
|
"keywords": [
|
|
37
39
|
"zudojs",
|
|
38
40
|
"di",
|
|
@@ -40,8 +42,19 @@
|
|
|
40
42
|
"container"
|
|
41
43
|
],
|
|
42
44
|
"homepage": "https://github.com/oyinlola-tech/zudo#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/oyinlola-tech/zudo/issues"
|
|
47
|
+
},
|
|
43
48
|
"repository": {
|
|
44
49
|
"type": "git",
|
|
45
|
-
"url": "https://github.com/oyinlola-tech/zudo"
|
|
50
|
+
"url": "https://github.com/oyinlola-tech/zudo",
|
|
51
|
+
"directory": "packages/container"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsc -p tsconfig.json",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
56
|
+
"clean": "rm -rf dist",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest"
|
|
46
59
|
}
|
|
47
|
-
}
|
|
60
|
+
}
|