@vielzeug/conduit 1.0.2
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/README.md +95 -0
- package/dist/_dev.cjs +2 -0
- package/dist/_dev.cjs.map +1 -0
- package/dist/_dev.d.ts +2 -0
- package/dist/_dev.d.ts.map +1 -0
- package/dist/_dev.js +9 -0
- package/dist/_dev.js.map +1 -0
- package/dist/conduit.cjs +2 -0
- package/dist/conduit.cjs.map +1 -0
- package/dist/conduit.d.ts +5 -0
- package/dist/conduit.d.ts.map +1 -0
- package/dist/conduit.iife.js +2 -0
- package/dist/conduit.iife.js.map +1 -0
- package/dist/conduit.js +2 -0
- package/dist/conduit.js.map +1 -0
- package/dist/container.cjs +2 -0
- package/dist/container.cjs.map +1 -0
- package/dist/container.d.ts +5 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +262 -0
- package/dist/container.js.map +1 -0
- package/dist/errors.cjs +2 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +49 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +53 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +169 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +41 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +62 -0
- package/dist/utils.js.map +1 -0
- package/package.json +40 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export type Token<T = unknown> = symbol & {
|
|
2
|
+
__type?: T;
|
|
3
|
+
};
|
|
4
|
+
export declare function token<T>(description: string): Token<T>;
|
|
5
|
+
export type ScopeToken = symbol & {
|
|
6
|
+
__scopeToken?: never;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a named scope token. Factories registered with a ScopeToken lifetime
|
|
10
|
+
* are only resolvable from a container created with createScope(scopeToken).
|
|
11
|
+
*/
|
|
12
|
+
export declare function scope(name: string): ScopeToken;
|
|
13
|
+
/** Caching strategy for factory registrations. Named scopes use a ScopeToken. */
|
|
14
|
+
export type Lifetime = 'singleton' | 'transient' | ScopeToken;
|
|
15
|
+
export type ValueOptions<T> = {
|
|
16
|
+
dispose?: (instance: T) => Promise<void> | void;
|
|
17
|
+
};
|
|
18
|
+
export type FactoryOptions<T> = {
|
|
19
|
+
/** Optional statically-declared dependencies. Used for early validation in `freeze()`. */
|
|
20
|
+
deps?: readonly Token<any>[];
|
|
21
|
+
dispose?: (instance: T) => Promise<void> | void;
|
|
22
|
+
lifetime?: Lifetime;
|
|
23
|
+
};
|
|
24
|
+
/** Minimal resolver passed to every factory function. */
|
|
25
|
+
export interface FactoryResolver {
|
|
26
|
+
resolve<T>(tok: Token<T>): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve synchronously. Works for value providers and already-resolved
|
|
29
|
+
* singleton/scoped instances. Throws `ConduitSyncResolutionError` if the instance
|
|
30
|
+
* has not been resolved yet.
|
|
31
|
+
*/
|
|
32
|
+
resolveSync<T>(tok: Token<T>): T;
|
|
33
|
+
}
|
|
34
|
+
export type ContainerModule = (container: Container) => Promise<void> | void;
|
|
35
|
+
export type ContainerEvent = {
|
|
36
|
+
description: string;
|
|
37
|
+
kind: 'factory' | 'value';
|
|
38
|
+
source: string;
|
|
39
|
+
type: 'register';
|
|
40
|
+
} | {
|
|
41
|
+
description: string;
|
|
42
|
+
source: string;
|
|
43
|
+
type: 'resolve';
|
|
44
|
+
} | {
|
|
45
|
+
source: string;
|
|
46
|
+
type: 'dispose';
|
|
47
|
+
};
|
|
48
|
+
export type ContainerEventListener = (event: ContainerEvent) => void;
|
|
49
|
+
export type ResolveResult<T> = {
|
|
50
|
+
ok: true;
|
|
51
|
+
value: T;
|
|
52
|
+
} | {
|
|
53
|
+
error: unknown;
|
|
54
|
+
ok: false;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Infer the resolved-value tuple type from a `readonly` array of tokens.
|
|
58
|
+
* Mirrors the return type of `resolveMany`.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* const TOKENS = [AuthToken, LoggerToken] as const;
|
|
62
|
+
* type Services = InferTokenTypes<typeof TOKENS>;
|
|
63
|
+
* // → [AuthService, Logger]
|
|
64
|
+
*/
|
|
65
|
+
export type InferTokenTypes<T extends readonly Token<any>[]> = {
|
|
66
|
+
[K in keyof T]: T[K] extends Token<infer U> ? U : never;
|
|
67
|
+
};
|
|
68
|
+
/** Interceptor called after every successful resolution. Receives the token and resolved value. */
|
|
69
|
+
export type ResolveInterceptor = <T>(tok: Token<T>, value: T) => void;
|
|
70
|
+
export type ContainerNode = {
|
|
71
|
+
/** Statically-declared dependency token descriptions (from `deps:` option). */
|
|
72
|
+
deps?: string[];
|
|
73
|
+
description: string;
|
|
74
|
+
kind: 'factory' | 'value';
|
|
75
|
+
/** 'singleton', 'transient', or 'scope:<name>' for named scopes. */
|
|
76
|
+
lifetime?: 'singleton' | 'transient' | `scope:${string}`;
|
|
77
|
+
};
|
|
78
|
+
export type ContainerGraph = {
|
|
79
|
+
nodes: ContainerNode[];
|
|
80
|
+
};
|
|
81
|
+
export interface Container {
|
|
82
|
+
/** Delegates to `dispose()`. Enables `await using` declarations. */
|
|
83
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
84
|
+
/** Human-readable identifier for this container. Set via createContainer({ name }). */
|
|
85
|
+
readonly name: string;
|
|
86
|
+
/** `AbortSignal` aborted when the container is disposed. Use to tie external lifecycles to this container. */
|
|
87
|
+
readonly disposalSignal: AbortSignal;
|
|
88
|
+
/** Whether the container has been disposed. */
|
|
89
|
+
readonly disposed: boolean;
|
|
90
|
+
/** Register a static value. */
|
|
91
|
+
value<T>(tok: Token<T>, val: T, opts?: ValueOptions<T>): this;
|
|
92
|
+
/**
|
|
93
|
+
* Register a factory. The factory receives a `FactoryResolver` to resolve
|
|
94
|
+
* its own dependencies lazily via `resolver.resolve(Token)`.
|
|
95
|
+
*/
|
|
96
|
+
factory<T>(tok: Token<T>, fn: (resolver: FactoryResolver) => Promise<T> | T, opts?: FactoryOptions<T>): this;
|
|
97
|
+
/** Check whether a token is registered (walks parent chain). */
|
|
98
|
+
has<T>(tok: Token<T>): boolean;
|
|
99
|
+
/** Resolve a single registered provider. */
|
|
100
|
+
resolve<T>(tok: Token<T>): Promise<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Resolve a token synchronously.
|
|
103
|
+
* Works for value registrations and already-resolved singleton/scope instances.
|
|
104
|
+
* Throws `ConduitSyncResolutionError` for transient factories or unresolved singletons.
|
|
105
|
+
* Rethrows the cached rejection if the factory previously failed.
|
|
106
|
+
*/
|
|
107
|
+
resolveSync<T>(tok: Token<T>): T;
|
|
108
|
+
/**
|
|
109
|
+
* Resolve multiple tokens in parallel, returning a typed tuple.
|
|
110
|
+
*/
|
|
111
|
+
resolveMany<const D extends Token<any>[]>(toks: D): Promise<{
|
|
112
|
+
[K in keyof D]: D[K] extends Token<infer U> ? U : never;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Eagerly resolve all registered singleton factories across the entire
|
|
116
|
+
* container hierarchy. Useful for startup validation and pre-warming
|
|
117
|
+
* `resolveSync()` hot paths.
|
|
118
|
+
*
|
|
119
|
+
* Pass `{ includeScoped: true }` to also pre-warm named-scope factories
|
|
120
|
+
* registered on the current scope container.
|
|
121
|
+
*/
|
|
122
|
+
resolveAll(opts?: {
|
|
123
|
+
includeScoped?: boolean;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Return a serializable graph of every registered token.
|
|
127
|
+
* By default traverses the full parent chain (deep: true).
|
|
128
|
+
*/
|
|
129
|
+
inspect(opts?: {
|
|
130
|
+
deep?: boolean;
|
|
131
|
+
}): ContainerGraph;
|
|
132
|
+
/**
|
|
133
|
+
* Validate the registration graph without freezing it.
|
|
134
|
+
* Checks statically-declared `deps`: throws `ConduitProviderNotFoundError` if a
|
|
135
|
+
* declared dep is missing, or `ConduitCircularDependencyError` if they form a cycle.
|
|
136
|
+
* Throws `ConduitDisposedError` if the container is already disposed.
|
|
137
|
+
*/
|
|
138
|
+
validate(): this;
|
|
139
|
+
/**
|
|
140
|
+
* Freeze the container, locking it against further registrations.
|
|
141
|
+
* After `freeze()`, `value()` and `factory()` throw `ConduitFrozenError`.
|
|
142
|
+
* Validates statically-declared `deps`: throws `ConduitProviderNotFoundError` if a
|
|
143
|
+
* declared dep is missing, or `ConduitCircularDependencyError` if they form a cycle.
|
|
144
|
+
* Idempotent — calling `freeze()` again on an already-frozen container is a no-op.
|
|
145
|
+
* Note: cycle detection for lazy (undeclared) deps happens at resolve time.
|
|
146
|
+
*/
|
|
147
|
+
freeze(): this;
|
|
148
|
+
/**
|
|
149
|
+
* Create a child scope container. If `scopeToken` is provided, factories
|
|
150
|
+
* registered with that token as their lifetime are resolved and cached here.
|
|
151
|
+
* Omit `scopeToken` for a plain child container with no named scope.
|
|
152
|
+
*/
|
|
153
|
+
createScope(scopeToken?: ScopeToken, opts?: {
|
|
154
|
+
name?: string;
|
|
155
|
+
}): Container;
|
|
156
|
+
/**
|
|
157
|
+
* Subscribe to container events (register, resolve, dispose).
|
|
158
|
+
* Events propagate up to parent containers. Returns an unsubscribe function.
|
|
159
|
+
*/
|
|
160
|
+
on(listener: ContainerEventListener): () => void;
|
|
161
|
+
/**
|
|
162
|
+
* Register an interceptor called after every successful resolution.
|
|
163
|
+
* Returns an unsubscribe function. Interceptor errors are swallowed.
|
|
164
|
+
*/
|
|
165
|
+
onResolve(interceptor: ResolveInterceptor): () => void;
|
|
166
|
+
/** Dispose the container, running all registered cleanup hooks in parallel. */
|
|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AC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjC;;OAEG;IACH,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,EACtC,IAAI,EAAE,CAAC,GACN,OAAO,CAAC;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;KAAE,CAAC,CAAC;IAExE;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;OAGG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,cAAc,CAAC;IAEnD;;;;;OAKG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;;;;;OAOG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;;;OAIG;IACH,WAAW,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAE1E;;;OAGG;IACH,EAAE,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI,CAAC;IAEjD;;;OAGG;IACH,SAAS,CAAC,WAAW,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAAC;IAEvD,+EAA+E;IAC/E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Token\n// ---------------------------------------------------------------------------\n\nexport type Token<T = unknown> = symbol & { __type?: T };\n\nexport function token<T>(description: string): Token<T> {\n return Symbol(description) as Token<T>;\n}\n\n// ---------------------------------------------------------------------------\n// ScopeToken — named lifecycle scopes\n// ---------------------------------------------------------------------------\n\nexport type ScopeToken = symbol & { __scopeToken?: never };\n\n/**\n * Creates a named scope token. Factories registered with a ScopeToken lifetime\n * are only resolvable from a container created with createScope(scopeToken).\n */\nexport function scope(name: string): ScopeToken {\n return Symbol(name) as ScopeToken;\n}\n\n// ---------------------------------------------------------------------------\n// Lifetime & options\n// ---------------------------------------------------------------------------\n\n/** Caching strategy for factory registrations. Named scopes use a ScopeToken. */\nexport type Lifetime = 'singleton' | 'transient' | ScopeToken;\n\nexport type ValueOptions<T> = {\n dispose?: (instance: T) => Promise<void> | void;\n};\n\nexport type FactoryOptions<T> = {\n /** Optional statically-declared dependencies. Used for early validation in `freeze()`. */\n deps?: readonly Token<any>[];\n dispose?: (instance: T) => Promise<void> | void;\n lifetime?: Lifetime;\n};\n\n// ---------------------------------------------------------------------------\n// Resolver — injected into factories\n// ---------------------------------------------------------------------------\n\n/** Minimal resolver passed to every factory function. */\nexport interface FactoryResolver {\n resolve<T>(tok: Token<T>): Promise<T>;\n /**\n * Resolve synchronously. Works for value providers and already-resolved\n * singleton/scoped instances. Throws `ConduitSyncResolutionError` if the instance\n * has not been resolved yet.\n */\n resolveSync<T>(tok: Token<T>): T;\n}\n\n// ---------------------------------------------------------------------------\n// ContainerModule — grouping and async setup\n// ---------------------------------------------------------------------------\n\nexport type ContainerModule = (container: Container) => Promise<void> | void;\n\n// ---------------------------------------------------------------------------\n// Events — observable container state\n// ---------------------------------------------------------------------------\n\nexport type ContainerEvent =\n | { description: string; kind: 'factory' | 'value'; source: string; type: 'register' }\n | { description: string; source: string; type: 'resolve' }\n | { source: string; type: 'dispose' };\n\nexport type ContainerEventListener = (event: ContainerEvent) => void;\n\n// ---------------------------------------------------------------------------\n// Result type\n// ---------------------------------------------------------------------------\n\nexport type ResolveResult<T> = { ok: true; value: T } | { error: unknown; ok: false };\n\n/**\n * Infer the resolved-value tuple type from a `readonly` array of tokens.\n * Mirrors the return type of `resolveMany`.\n *\n * @example\n * const TOKENS = [AuthToken, LoggerToken] as const;\n * type Services = InferTokenTypes<typeof TOKENS>;\n * // → [AuthService, Logger]\n */\nexport type InferTokenTypes<T extends readonly Token<any>[]> = {\n [K in keyof T]: T[K] extends Token<infer U> ? U : never;\n};\n\n/** Interceptor called after every successful resolution. Receives the token and resolved value. */\nexport type ResolveInterceptor = <T>(tok: Token<T>, value: T) => void;\n\n// ---------------------------------------------------------------------------\n// ContainerGraph — inspect() output\n// ---------------------------------------------------------------------------\n\nexport type ContainerNode = {\n /** Statically-declared dependency token descriptions (from `deps:` option). */\n deps?: string[];\n description: string;\n kind: 'factory' | 'value';\n /** 'singleton', 'transient', or 'scope:<name>' for named scopes. */\n lifetime?: 'singleton' | 'transient' | `scope:${string}`;\n};\n\nexport type ContainerGraph = {\n nodes: ContainerNode[];\n};\n\n// ---------------------------------------------------------------------------\n// Container public interface\n// ---------------------------------------------------------------------------\n\nexport interface Container {\n /** Delegates to `dispose()`. Enables `await using` declarations. */\n [Symbol.asyncDispose](): Promise<void>;\n /** Human-readable identifier for this container. Set via createContainer({ name }). */\n readonly name: string;\n\n /** `AbortSignal` aborted when the container is disposed. Use to tie external lifecycles to this container. */\n readonly disposalSignal: AbortSignal;\n\n /** Whether the container has been disposed. */\n readonly disposed: boolean;\n\n /** Register a static value. */\n value<T>(tok: Token<T>, val: T, opts?: ValueOptions<T>): this;\n\n /**\n * Register a factory. The factory receives a `FactoryResolver` to resolve\n * its own dependencies lazily via `resolver.resolve(Token)`.\n */\n factory<T>(tok: Token<T>, fn: (resolver: FactoryResolver) => Promise<T> | T, opts?: FactoryOptions<T>): this;\n\n /** Check whether a token is registered (walks parent chain). */\n has<T>(tok: Token<T>): boolean;\n\n /** Resolve a single registered provider. */\n resolve<T>(tok: Token<T>): Promise<T>;\n\n /**\n * Resolve a token synchronously.\n * Works for value registrations and already-resolved singleton/scope instances.\n * Throws `ConduitSyncResolutionError` for transient factories or unresolved singletons.\n * Rethrows the cached rejection if the factory previously failed.\n */\n resolveSync<T>(tok: Token<T>): T;\n\n /**\n * Resolve multiple tokens in parallel, returning a typed tuple.\n */\n resolveMany<const D extends Token<any>[]>(\n toks: D,\n ): Promise<{ [K in keyof D]: D[K] extends Token<infer U> ? U : never }>;\n\n /**\n * Eagerly resolve all registered singleton factories across the entire\n * container hierarchy. Useful for startup validation and pre-warming\n * `resolveSync()` hot paths.\n *\n * Pass `{ includeScoped: true }` to also pre-warm named-scope factories\n * registered on the current scope container.\n */\n resolveAll(opts?: { includeScoped?: boolean }): Promise<void>;\n\n /**\n * Return a serializable graph of every registered token.\n * By default traverses the full parent chain (deep: true).\n */\n inspect(opts?: { deep?: boolean }): ContainerGraph;\n\n /**\n * Validate the registration graph without freezing it.\n * Checks statically-declared `deps`: throws `ConduitProviderNotFoundError` if a\n * declared dep is missing, or `ConduitCircularDependencyError` if they form a cycle.\n * Throws `ConduitDisposedError` if the container is already disposed.\n */\n validate(): this;\n\n /**\n * Freeze the container, locking it against further registrations.\n * After `freeze()`, `value()` and `factory()` throw `ConduitFrozenError`.\n * Validates statically-declared `deps`: throws `ConduitProviderNotFoundError` if a\n * declared dep is missing, or `ConduitCircularDependencyError` if they form a cycle.\n * Idempotent — calling `freeze()` again on an already-frozen container is a no-op.\n * Note: cycle detection for lazy (undeclared) deps happens at resolve time.\n */\n freeze(): this;\n\n /**\n * Create a child scope container. If `scopeToken` is provided, factories\n * registered with that token as their lifetime are resolved and cached here.\n * Omit `scopeToken` for a plain child container with no named scope.\n */\n createScope(scopeToken?: ScopeToken, opts?: { name?: string }): Container;\n\n /**\n * Subscribe to container events (register, resolve, dispose).\n * Events propagate up to parent containers. Returns an unsubscribe function.\n */\n on(listener: ContainerEventListener): () => void;\n\n /**\n * Register an interceptor called after every successful resolution.\n * Returns an unsubscribe function. Interceptor errors are swallowed.\n */\n onResolve(interceptor: ResolveInterceptor): () => void;\n\n /** Dispose the container, running all registered cleanup hooks in parallel. */\n dispose(): Promise<void>;\n}\n"],"mappings":";AAMA,SAAgB,EAAS,GAA+B;CACtD,OAAO,OAAO,CAAW;AAC3B;AAYA,SAAgB,EAAM,GAA0B;CAC9C,OAAO,OAAO,CAAI;AACpB"}
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./errors.cjs");async function t(t,n){try{return await t.resolve(n)}catch(t){if(t instanceof e.ConduitProviderNotFoundError)return;throw t}}async function n(e,n,r){let i=await t(e,n);return i===void 0?r:i}async function r(t,n){try{return{ok:!0,value:await t.resolve(n)}}catch(t){if(t instanceof e.ConduitProviderNotFoundError)return{error:t,ok:!1};throw t}}function i(t,n){try{return t.resolveSync(n)}catch(t){if(t instanceof e.ConduitProviderNotFoundError)return;throw t}}function a(e,t,n){let r=i(e,t);return r===void 0?n:r}function o(t,n){try{return{ok:!0,value:t.resolveSync(n)}}catch(t){if(t instanceof e.ConduitProviderNotFoundError)return{error:t,ok:!1};throw t}}async function s(e,...t){for(let n of t)await n(e);return e}exports.loadModules=s,exports.resolveOptional=t,exports.resolveOrDefault=n,exports.resolveSyncOptional=i,exports.resolveSyncOrDefault=a,exports.tryResolve=r,exports.trySyncResolve=o;
|
|
2
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Container, ContainerModule, ResolveResult, Token } from './types.js';\n\nimport { ConduitProviderNotFoundError } from './errors.js';\n\n/**\n * Resolve a token, returning `undefined` when not registered.\n * Re-throws any error other than `ConduitProviderNotFoundError`.\n */\nexport async function resolveOptional<T>(container: Container, tok: Token<T>): Promise<T | undefined> {\n try {\n return await container.resolve(tok);\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return undefined;\n\n throw error;\n }\n}\n\n/**\n * Resolve a token, returning `defaultValue` when not registered.\n * Re-throws any error other than `ConduitProviderNotFoundError`.\n */\nexport async function resolveOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): Promise<T> {\n const result = await resolveOptional(container, tok);\n\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Resolve a token, returning a result object instead of throwing.\n * Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the\n * token is not registered. Re-throws all other errors — including\n * `ConduitDisposedError` and `ConduitCircularDependencyError`.\n */\nexport async function tryResolve<T>(container: Container, tok: Token<T>): Promise<ResolveResult<T>> {\n try {\n const value = await container.resolve(tok);\n\n return { ok: true, value };\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return { error, ok: false };\n\n throw error;\n }\n}\n\n/**\n * Resolve a token synchronously, returning `undefined` when not registered.\n * Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.\n */\nexport function resolveSyncOptional<T>(container: Container, tok: Token<T>): T | undefined {\n try {\n return container.resolveSync(tok);\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return undefined;\n\n throw error;\n }\n}\n\n/**\n * Resolve a token synchronously, returning `defaultValue` when not registered.\n * Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.\n */\nexport function resolveSyncOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): T {\n const result = resolveSyncOptional(container, tok);\n\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Resolve a token synchronously, returning a result object instead of throwing.\n * Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the\n * token is not registered. Re-throws all other errors — including\n * `ConduitSyncResolutionError`, `ConduitDisposedError`, and `ConduitScopedResolutionError`.\n */\nexport function trySyncResolve<T>(container: Container, tok: Token<T>): ResolveResult<T> {\n try {\n const value = container.resolveSync(tok);\n\n return { ok: true, value };\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return { error, ok: false };\n\n throw error;\n }\n}\n\n/**\n * Apply container modules sequentially (each module may be async).\n * Returns the container for chaining.\n */\nexport async function loadModules(container: Container, ...modules: ContainerModule[]): Promise<Container> {\n for (const mod of modules) await mod(container);\n\n return container;\n}\n"],"mappings":"gCAQA,eAAsB,EAAmB,EAAsB,EAAuC,CACpG,GAAI,CACF,OAAO,MAAM,EAAU,QAAQ,CAAG,CACpC,OAAS,EAAO,CACd,GAAI,aAAiB,EAAA,6BAA8B,OAEnD,MAAM,CACR,CACF,CAMA,eAAsB,EAAoB,EAAsB,EAAe,EAA6B,CAC1G,IAAM,EAAS,MAAM,EAAgB,EAAW,CAAG,EAEnD,OAAO,IAAW,IAAA,GAAY,EAAe,CAC/C,CAQA,eAAsB,EAAc,EAAsB,EAA0C,CAClG,GAAI,CAGF,MAAO,CAAE,GAAI,GAAM,MAAA,MAFC,EAAU,QAAQ,CAAG,CAEhB,CAC3B,OAAS,EAAO,CACd,GAAI,aAAiB,EAAA,6BAA8B,MAAO,CAAE,QAAO,GAAI,EAAM,EAE7E,MAAM,CACR,CACF,CAMA,SAAgB,EAAuB,EAAsB,EAA8B,CACzF,GAAI,CACF,OAAO,EAAU,YAAY,CAAG,CAClC,OAAS,EAAO,CACd,GAAI,aAAiB,EAAA,6BAA8B,OAEnD,MAAM,CACR,CACF,CAMA,SAAgB,EAAwB,EAAsB,EAAe,EAAoB,CAC/F,IAAM,EAAS,EAAoB,EAAW,CAAG,EAEjD,OAAO,IAAW,IAAA,GAAY,EAAe,CAC/C,CAQA,SAAgB,EAAkB,EAAsB,EAAiC,CACvF,GAAI,CAGF,MAAO,CAAE,GAAI,GAAM,MAFL,EAAU,YAAY,CAEjB,CAAM,CAC3B,OAAS,EAAO,CACd,GAAI,aAAiB,EAAA,6BAA8B,MAAO,CAAE,QAAO,GAAI,EAAM,EAE7E,MAAM,CACR,CACF,CAMA,eAAsB,EAAY,EAAsB,GAAG,EAAgD,CACzG,IAAK,IAAM,KAAO,EAAS,MAAM,EAAI,CAAS,EAE9C,OAAO,CACT"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Container, ContainerModule, ResolveResult, Token } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a token, returning `undefined` when not registered.
|
|
4
|
+
* Re-throws any error other than `ConduitProviderNotFoundError`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveOptional<T>(container: Container, tok: Token<T>): Promise<T | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a token, returning `defaultValue` when not registered.
|
|
9
|
+
* Re-throws any error other than `ConduitProviderNotFoundError`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): Promise<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a token, returning a result object instead of throwing.
|
|
14
|
+
* Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the
|
|
15
|
+
* token is not registered. Re-throws all other errors — including
|
|
16
|
+
* `ConduitDisposedError` and `ConduitCircularDependencyError`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function tryResolve<T>(container: Container, tok: Token<T>): Promise<ResolveResult<T>>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a token synchronously, returning `undefined` when not registered.
|
|
21
|
+
* Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveSyncOptional<T>(container: Container, tok: Token<T>): T | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a token synchronously, returning `defaultValue` when not registered.
|
|
26
|
+
* Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveSyncOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): T;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a token synchronously, returning a result object instead of throwing.
|
|
31
|
+
* Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the
|
|
32
|
+
* token is not registered. Re-throws all other errors — including
|
|
33
|
+
* `ConduitSyncResolutionError`, `ConduitDisposedError`, and `ConduitScopedResolutionError`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function trySyncResolve<T>(container: Container, tok: Token<T>): ResolveResult<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Apply container modules sequentially (each module may be async).
|
|
38
|
+
* Returns the container for chaining.
|
|
39
|
+
*/
|
|
40
|
+
export declare function loadModules(container: Container, ...modules: ContainerModule[]): Promise<Container>;
|
|
41
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInF;;;GAGG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAQpG;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAI1G;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAUlG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAQzF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAI/F;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAUvF;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAIzG"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ConduitProviderNotFoundError as e } from "./errors.js";
|
|
2
|
+
//#region src/utils.ts
|
|
3
|
+
async function t(t, n) {
|
|
4
|
+
try {
|
|
5
|
+
return await t.resolve(n);
|
|
6
|
+
} catch (t) {
|
|
7
|
+
if (t instanceof e) return;
|
|
8
|
+
throw t;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function n(e, n, r) {
|
|
12
|
+
let i = await t(e, n);
|
|
13
|
+
return i === void 0 ? r : i;
|
|
14
|
+
}
|
|
15
|
+
async function r(t, n) {
|
|
16
|
+
try {
|
|
17
|
+
return {
|
|
18
|
+
ok: !0,
|
|
19
|
+
value: await t.resolve(n)
|
|
20
|
+
};
|
|
21
|
+
} catch (t) {
|
|
22
|
+
if (t instanceof e) return {
|
|
23
|
+
error: t,
|
|
24
|
+
ok: !1
|
|
25
|
+
};
|
|
26
|
+
throw t;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function i(t, n) {
|
|
30
|
+
try {
|
|
31
|
+
return t.resolveSync(n);
|
|
32
|
+
} catch (t) {
|
|
33
|
+
if (t instanceof e) return;
|
|
34
|
+
throw t;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function a(e, t, n) {
|
|
38
|
+
let r = i(e, t);
|
|
39
|
+
return r === void 0 ? n : r;
|
|
40
|
+
}
|
|
41
|
+
function o(t, n) {
|
|
42
|
+
try {
|
|
43
|
+
return {
|
|
44
|
+
ok: !0,
|
|
45
|
+
value: t.resolveSync(n)
|
|
46
|
+
};
|
|
47
|
+
} catch (t) {
|
|
48
|
+
if (t instanceof e) return {
|
|
49
|
+
error: t,
|
|
50
|
+
ok: !1
|
|
51
|
+
};
|
|
52
|
+
throw t;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function s(e, ...t) {
|
|
56
|
+
for (let n of t) await n(e);
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { s as loadModules, t as resolveOptional, n as resolveOrDefault, i as resolveSyncOptional, a as resolveSyncOrDefault, r as tryResolve, o as trySyncResolve };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Container, ContainerModule, ResolveResult, Token } from './types.js';\n\nimport { ConduitProviderNotFoundError } from './errors.js';\n\n/**\n * Resolve a token, returning `undefined` when not registered.\n * Re-throws any error other than `ConduitProviderNotFoundError`.\n */\nexport async function resolveOptional<T>(container: Container, tok: Token<T>): Promise<T | undefined> {\n try {\n return await container.resolve(tok);\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return undefined;\n\n throw error;\n }\n}\n\n/**\n * Resolve a token, returning `defaultValue` when not registered.\n * Re-throws any error other than `ConduitProviderNotFoundError`.\n */\nexport async function resolveOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): Promise<T> {\n const result = await resolveOptional(container, tok);\n\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Resolve a token, returning a result object instead of throwing.\n * Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the\n * token is not registered. Re-throws all other errors — including\n * `ConduitDisposedError` and `ConduitCircularDependencyError`.\n */\nexport async function tryResolve<T>(container: Container, tok: Token<T>): Promise<ResolveResult<T>> {\n try {\n const value = await container.resolve(tok);\n\n return { ok: true, value };\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return { error, ok: false };\n\n throw error;\n }\n}\n\n/**\n * Resolve a token synchronously, returning `undefined` when not registered.\n * Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.\n */\nexport function resolveSyncOptional<T>(container: Container, tok: Token<T>): T | undefined {\n try {\n return container.resolveSync(tok);\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return undefined;\n\n throw error;\n }\n}\n\n/**\n * Resolve a token synchronously, returning `defaultValue` when not registered.\n * Re-throws `ConduitSyncResolutionError`, `ConduitScopedResolutionError`, and `ConduitDisposedError`.\n */\nexport function resolveSyncOrDefault<T>(container: Container, tok: Token<T>, defaultValue: T): T {\n const result = resolveSyncOptional(container, tok);\n\n return result === undefined ? defaultValue : result;\n}\n\n/**\n * Resolve a token synchronously, returning a result object instead of throwing.\n * Returns `{ ok: true, value }` on success or `{ ok: false, error }` when the\n * token is not registered. Re-throws all other errors — including\n * `ConduitSyncResolutionError`, `ConduitDisposedError`, and `ConduitScopedResolutionError`.\n */\nexport function trySyncResolve<T>(container: Container, tok: Token<T>): ResolveResult<T> {\n try {\n const value = container.resolveSync(tok);\n\n return { ok: true, value };\n } catch (error) {\n if (error instanceof ConduitProviderNotFoundError) return { error, ok: false };\n\n throw error;\n }\n}\n\n/**\n * Apply container modules sequentially (each module may be async).\n * Returns the container for chaining.\n */\nexport async function loadModules(container: Container, ...modules: ContainerModule[]): Promise<Container> {\n for (const mod of modules) await mod(container);\n\n return container;\n}\n"],"mappings":";;AAQA,eAAsB,EAAmB,GAAsB,GAAuC;CACpG,IAAI;EACF,OAAO,MAAM,EAAU,QAAQ,CAAG;CACpC,SAAS,GAAO;EACd,IAAI,aAAiB,GAA8B;EAEnD,MAAM;CACR;AACF;AAMA,eAAsB,EAAoB,GAAsB,GAAe,GAA6B;CAC1G,IAAM,IAAS,MAAM,EAAgB,GAAW,CAAG;CAEnD,OAAO,MAAW,KAAA,IAAY,IAAe;AAC/C;AAQA,eAAsB,EAAc,GAAsB,GAA0C;CAClG,IAAI;EAGF,OAAO;GAAE,IAAI;GAAM,OAAA,MAFC,EAAU,QAAQ,CAAG;EAEhB;CAC3B,SAAS,GAAO;EACd,IAAI,aAAiB,GAA8B,OAAO;GAAE;GAAO,IAAI;EAAM;EAE7E,MAAM;CACR;AACF;AAMA,SAAgB,EAAuB,GAAsB,GAA8B;CACzF,IAAI;EACF,OAAO,EAAU,YAAY,CAAG;CAClC,SAAS,GAAO;EACd,IAAI,aAAiB,GAA8B;EAEnD,MAAM;CACR;AACF;AAMA,SAAgB,EAAwB,GAAsB,GAAe,GAAoB;CAC/F,IAAM,IAAS,EAAoB,GAAW,CAAG;CAEjD,OAAO,MAAW,KAAA,IAAY,IAAe;AAC/C;AAQA,SAAgB,EAAkB,GAAsB,GAAiC;CACvF,IAAI;EAGF,OAAO;GAAE,IAAI;GAAM,OAFL,EAAU,YAAY,CAEjB;EAAM;CAC3B,SAAS,GAAO;EACd,IAAI,aAAiB,GAA8B,OAAO;GAAE;GAAO,IAAI;EAAM;EAE7E,MAAM;CACR;AACF;AAMA,eAAsB,EAAY,GAAsB,GAAG,GAAgD;CACzG,KAAK,IAAM,KAAO,GAAS,MAAM,EAAI,CAAS;CAE9C,OAAO;AACT"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vielzeug/conduit",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Lightweight dependency injection container — singletons, transient instances, factories, and named scopes",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "vite build && pnpm run build:bundle && pnpm run build:types",
|
|
22
|
+
"build:types": "tsc -p tsconfig.declarations.json",
|
|
23
|
+
"fix": "eslint --fix src",
|
|
24
|
+
"lint": "eslint src",
|
|
25
|
+
"prepublishOnly": "pnpm run build",
|
|
26
|
+
"preview": "vite preview",
|
|
27
|
+
"test": "vitest",
|
|
28
|
+
"build:bundle": "vite build --config vite.bundle.config.ts"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^26.1.0",
|
|
36
|
+
"typescript": "~6.0.3",
|
|
37
|
+
"vite": "^8.1.3",
|
|
38
|
+
"vitest": "^4.1.9"
|
|
39
|
+
}
|
|
40
|
+
}
|