@navios/di 0.1.10 → 0.1.12
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/docs/concepts/injectable.md +182 -0
- package/docs/concepts/injection-token.md +145 -0
- package/lib/_tsup-dts-rollup.d.mts +558 -0
- package/lib/_tsup-dts-rollup.d.ts +558 -0
- package/lib/index.d.mts +61 -433
- package/lib/index.d.ts +61 -433
- package/lib/index.js +861 -692
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +858 -668
- package/lib/index.mjs.map +1 -1
- package/package.json +4 -4
- package/project.json +4 -1
- package/src/__tests__/injectable.spec.mts +46 -2
- package/src/__tests__/service-locator.spec.mts +35 -0
- package/src/decorators/injectable.decorator.mts +24 -16
- package/src/injector.mts +2 -1
- package/src/resolve-service.mts +2 -2
- package/src/service-locator.mts +29 -18
- package/src/utils/get-injectors.mts +10 -2
- package/tsconfig.json +1 -1
- package/tsup.config.mts +12 -0
- package/lib/index.d.mts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/tsdown.config.mts +0 -10
package/lib/index.d.ts
CHANGED
|
@@ -1,433 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//#region src/enums/injectable-scope.enum.d.mts
|
|
63
|
-
//# sourceMappingURL=service-locator-event-bus.d.mts.map
|
|
64
|
-
declare enum InjectableScope {
|
|
65
|
-
/**
|
|
66
|
-
* Singleton scope: The instance is created once and shared across the application.
|
|
67
|
-
*/
|
|
68
|
-
Singleton = "Singleton",
|
|
69
|
-
/**
|
|
70
|
-
* Instance scope: A new instance is created for each injection.
|
|
71
|
-
*/
|
|
72
|
-
Instance = "Instance",
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/enums/injectable-type.enum.d.mts
|
|
77
|
-
//# sourceMappingURL=injectable-scope.enum.d.mts.map
|
|
78
|
-
declare enum InjectableType {
|
|
79
|
-
Class = "Class",
|
|
80
|
-
Factory = "Factory",
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/registry.d.mts
|
|
85
|
-
//# sourceMappingURL=injectable-type.enum.d.mts.map
|
|
86
|
-
type InjectionFactory<T = unknown, Args = unknown> = (ctx: FactoryContext, args: Args) => Promise<T>;
|
|
87
|
-
type FactoryRecord<Instance = any, Schema = any> = {
|
|
88
|
-
scope: InjectableScope;
|
|
89
|
-
originalToken: InjectionToken<Instance, Schema>;
|
|
90
|
-
factory: InjectionFactory<Instance, Schema extends AnyZodObject ? z.input<Schema> : unknown>;
|
|
91
|
-
};
|
|
92
|
-
declare class Registry {
|
|
93
|
-
private readonly parent?;
|
|
94
|
-
private readonly factories;
|
|
95
|
-
constructor(parent?: Registry | undefined);
|
|
96
|
-
has(token: InjectionToken<any, any>): boolean;
|
|
97
|
-
get<Instance, Schema>(token: InjectionToken<Instance, Schema>): FactoryRecord<Instance, Schema>;
|
|
98
|
-
set<Instance, Schema>(token: InjectionToken<Instance, Schema>, factory: InjectionFactory, scope: InjectableScope): void;
|
|
99
|
-
delete(token: InjectionToken<any, any>): void;
|
|
100
|
-
}
|
|
101
|
-
declare const globalRegistry: Registry;
|
|
102
|
-
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/errors/errors.enum.d.mts
|
|
105
|
-
//# sourceMappingURL=registry.d.mts.map
|
|
106
|
-
declare enum ErrorsEnum {
|
|
107
|
-
InstanceExpired = "InstanceExpired",
|
|
108
|
-
InstanceNotFound = "InstanceNotFound",
|
|
109
|
-
InstanceDestroying = "InstanceDestroying",
|
|
110
|
-
UnknownError = "UnknownError",
|
|
111
|
-
FactoryNotFound = "FactoryNotFound",
|
|
112
|
-
FactoryTokenNotResolved = "FactoryTokenNotResolved",
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/errors/factory-not-found.d.mts
|
|
117
|
-
//# sourceMappingURL=errors.enum.d.mts.map
|
|
118
|
-
declare class FactoryNotFound extends Error {
|
|
119
|
-
name: string;
|
|
120
|
-
code: ErrorsEnum;
|
|
121
|
-
constructor(name: string);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/errors/factory-token-not-resolved.d.mts
|
|
126
|
-
//# sourceMappingURL=factory-not-found.d.mts.map
|
|
127
|
-
declare class FactoryTokenNotResolved extends Error {
|
|
128
|
-
code: ErrorsEnum;
|
|
129
|
-
constructor(name: string | symbol | ClassType);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/errors/instance-destroying.d.mts
|
|
134
|
-
//# sourceMappingURL=factory-token-not-resolved.d.mts.map
|
|
135
|
-
declare class InstanceDestroying extends Error {
|
|
136
|
-
name: string;
|
|
137
|
-
code: ErrorsEnum;
|
|
138
|
-
constructor(name: string);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/errors/instance-expired.d.mts
|
|
143
|
-
//# sourceMappingURL=instance-destroying.d.mts.map
|
|
144
|
-
declare class InstanceExpired extends Error {
|
|
145
|
-
name: string;
|
|
146
|
-
code: ErrorsEnum;
|
|
147
|
-
constructor(name: string);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/errors/instance-not-found.d.mts
|
|
152
|
-
//# sourceMappingURL=instance-expired.d.mts.map
|
|
153
|
-
declare class InstanceNotFound extends Error {
|
|
154
|
-
name: string;
|
|
155
|
-
code: ErrorsEnum;
|
|
156
|
-
constructor(name: string);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/errors/unknown-error.d.mts
|
|
161
|
-
//# sourceMappingURL=instance-not-found.d.mts.map
|
|
162
|
-
declare class UnknownError extends Error {
|
|
163
|
-
code: ErrorsEnum;
|
|
164
|
-
parent?: Error;
|
|
165
|
-
constructor(message: string | Error);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/service-locator.d.mts
|
|
170
|
-
//# sourceMappingURL=unknown-error.d.mts.map
|
|
171
|
-
declare class ServiceLocator {
|
|
172
|
-
private readonly registry;
|
|
173
|
-
private readonly logger;
|
|
174
|
-
private readonly eventBus;
|
|
175
|
-
private readonly manager;
|
|
176
|
-
constructor(registry?: Registry, logger?: Console | null);
|
|
177
|
-
getEventBus(): ServiceLocatorEventBus;
|
|
178
|
-
storeInstance<Instance>(instance: Instance, token: BoundInjectionToken<Instance, any>): void;
|
|
179
|
-
storeInstance<Instance>(instance: Instance, token: FactoryInjectionToken<Instance, any>): void;
|
|
180
|
-
storeInstance<Instance>(instance: Instance, token: InjectionToken<Instance, undefined>): void;
|
|
181
|
-
storeInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject>>(instance: Instance, token: InjectionToken<Instance, Schema>, args: z.input<Schema>): void;
|
|
182
|
-
removeInstance<Instance>(token: BoundInjectionToken<Instance, any>): void;
|
|
183
|
-
removeInstance<Instance>(token: FactoryInjectionToken<Instance, any>): void;
|
|
184
|
-
removeInstance<Instance>(token: InjectionToken<Instance, undefined>): void;
|
|
185
|
-
removeInstance<Instance, Schema extends BaseInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args: z.input<Schema>): void;
|
|
186
|
-
removeInstance<Instance, Schema extends OptionalInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args?: z.input<Schema>): void;
|
|
187
|
-
private resolveTokenArgs;
|
|
188
|
-
getInstanceIdentifier<Instance, Schema extends BaseInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args: z.input<Schema>): string;
|
|
189
|
-
getInstanceIdentifier<Instance, Schema extends OptionalInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args?: z.input<Schema>): string;
|
|
190
|
-
getInstanceIdentifier<Instance>(token: InjectionToken<Instance, undefined>): string;
|
|
191
|
-
getInstanceIdentifier<Instance>(token: BoundInjectionToken<Instance, any>): string;
|
|
192
|
-
getInstanceIdentifier<Instance>(token: FactoryInjectionToken<Instance, any>): string;
|
|
193
|
-
getInstance<Instance, Schema extends BaseInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args: z.input<Schema>): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
|
|
194
|
-
getInstance<Instance, Schema extends OptionalInjectionTokenSchemaType>(token: InjectionToken<Instance, Schema>, args?: z.input<Schema>): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
|
|
195
|
-
getInstance<Instance>(token: InjectionToken<Instance, undefined>): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
|
|
196
|
-
getInstance<Instance>(token: BoundInjectionToken<Instance, any>): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
|
|
197
|
-
getInstance<Instance>(token: FactoryInjectionToken<Instance, any>): Promise<[undefined, Instance] | [UnknownError | FactoryNotFound]>;
|
|
198
|
-
getOrThrowInstance<Instance, Schema extends InjectionTokenSchemaType | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Promise<Instance>;
|
|
199
|
-
private notifyListeners;
|
|
200
|
-
private createInstance;
|
|
201
|
-
private resolveInstance;
|
|
202
|
-
private createFactoryContext;
|
|
203
|
-
getSyncInstance<Instance, Schema extends InjectionTokenSchemaType | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Instance | null;
|
|
204
|
-
invalidate(service: string, round?: number): Promise<any>;
|
|
205
|
-
ready(): Promise<null>;
|
|
206
|
-
makeInstanceName(token: InjectionToken<any, any> | BoundInjectionToken<any, any> | FactoryInjectionToken<any, any>, args: any): string;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/utils/get-injectors.d.mts
|
|
211
|
-
//# sourceMappingURL=service-locator.d.mts.map
|
|
212
|
-
interface CreateInjectorsOptions {
|
|
213
|
-
baseLocator: ServiceLocator;
|
|
214
|
-
}
|
|
215
|
-
type Join<TElements, TSeparator extends string> = TElements extends Readonly<[infer First, ...infer Rest]> ? Rest extends ReadonlyArray<string> ? First extends string ? `${First}${Rest extends [] ? '' : TSeparator}${Join<Rest, TSeparator>}` : never : never : '';
|
|
216
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
217
|
-
type UnionToOvlds<U> = UnionToIntersection<U extends any ? (f: U) => void : never>;
|
|
218
|
-
type PopUnion<U> = UnionToOvlds<U> extends ((a: infer A) => void) ? A : never;
|
|
219
|
-
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true;
|
|
220
|
-
type UnionToArray<T, A extends unknown[] = []> = IsUnion<T> extends true ? UnionToArray<Exclude<T, PopUnion<T>>, [PopUnion<T>, ...A]> : [T, ...A];
|
|
221
|
-
interface Injectors {
|
|
222
|
-
inject<T extends ClassType>(token: T): Promise<InstanceType<T>>;
|
|
223
|
-
inject<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): Promise<T>;
|
|
224
|
-
inject<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? Promise<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
225
|
-
inject<T>(token: InjectionToken<T, undefined>): Promise<T>;
|
|
226
|
-
inject<T>(token: BoundInjectionToken<T, any>): Promise<T>;
|
|
227
|
-
inject<T>(token: FactoryInjectionToken<T, any>): Promise<T>;
|
|
228
|
-
syncInject<T extends ClassType>(token: T): InstanceType<T>;
|
|
229
|
-
syncInject<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): T;
|
|
230
|
-
syncInject<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? T : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
231
|
-
syncInject<T>(token: InjectionToken<T, undefined>): T;
|
|
232
|
-
syncInject<T>(token: BoundInjectionToken<T, any>): T;
|
|
233
|
-
syncInject<T>(token: FactoryInjectionToken<T, any>): T;
|
|
234
|
-
wrapSyncInit(cb: () => any): () => [any, Promise<any>[]];
|
|
235
|
-
provideServiceLocator(locator: ServiceLocator): ServiceLocator;
|
|
236
|
-
}
|
|
237
|
-
declare const InjectorsBase: Map<ServiceLocator, Injectors>;
|
|
238
|
-
declare function getInjectors({
|
|
239
|
-
baseLocator
|
|
240
|
-
}: CreateInjectorsOptions): Injectors;
|
|
241
|
-
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/utils/get-injectable-token.d.mts
|
|
244
|
-
declare function getInjectableToken<R>(target: ClassType): R extends {
|
|
245
|
-
create(...args: any[]): infer V;
|
|
246
|
-
} ? InjectionToken<V> : InjectionToken<R>;
|
|
247
|
-
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/factory-context.d.mts
|
|
250
|
-
//# sourceMappingURL=get-injectable-token.d.mts.map
|
|
251
|
-
interface FactoryContext {
|
|
252
|
-
inject: Injectors['inject'];
|
|
253
|
-
on: ServiceLocatorEventBus['on'];
|
|
254
|
-
getDependencies: () => string[];
|
|
255
|
-
invalidate: () => void;
|
|
256
|
-
addEffect: (listener: () => void) => void;
|
|
257
|
-
getDestroyListeners: () => (() => void)[];
|
|
258
|
-
setTtl: (ttl: number) => void;
|
|
259
|
-
getTtl: () => number;
|
|
260
|
-
locator: ServiceLocator;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/interfaces/factory.interface.d.mts
|
|
265
|
-
//# sourceMappingURL=factory-context.d.mts.map
|
|
266
|
-
interface Factory<T> {
|
|
267
|
-
create(ctx?: FactoryContext): Promise<T> | T;
|
|
268
|
-
}
|
|
269
|
-
interface FactoryWithArgs<T, A extends InjectionTokenSchemaType> {
|
|
270
|
-
create(...args: [FactoryContext, z.output<A>]): Promise<T> | T;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/decorators/injectable.decorator.d.mts
|
|
275
|
-
//# sourceMappingURL=factory.interface.d.mts.map
|
|
276
|
-
interface InjectableOptions {
|
|
277
|
-
scope?: InjectableScope;
|
|
278
|
-
type?: InjectableType;
|
|
279
|
-
token?: InjectionToken<any, any>;
|
|
280
|
-
registry?: Registry;
|
|
281
|
-
}
|
|
282
|
-
declare function Injectable(): <T extends ClassType>(target: T, context: ClassDecoratorContext) => T;
|
|
283
|
-
declare function Injectable<R>(options: {
|
|
284
|
-
scope?: InjectableScope;
|
|
285
|
-
type: InjectableType.Factory;
|
|
286
|
-
}): <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T;
|
|
287
|
-
declare function Injectable<Type, Schema>(options: {
|
|
288
|
-
scope?: InjectableScope;
|
|
289
|
-
type?: InjectableType.Class;
|
|
290
|
-
token: InjectionToken<Type, Schema>;
|
|
291
|
-
}): Schema extends BaseInjectionTokenSchemaType ? Type extends undefined ? <T extends ClassTypeWithArgument<z.output<Schema>>>(target: T, context: ClassDecoratorContext) => T : <T extends ClassTypeWithInstanceAndArgument<Type, z.output<Schema>>>(target: T, context: ClassDecoratorContext) => T : Schema extends OptionalInjectionTokenSchemaType ? Type extends undefined ? <T extends ClassTypeWithOptionalArgument<z.output<Schema>>>(target: T, context: ClassDecoratorContext) => T : <T extends ClassTypeWithInstanceAndOptionalArgument<Type, z.output<Schema>>>(target: T, context: ClassDecoratorContext) => T : Schema extends undefined ? <R extends ClassTypeWithInstance<Type>>(target: R, context: ClassDecoratorContext) => R : never;
|
|
292
|
-
declare function Injectable<R, S>(options: {
|
|
293
|
-
scope?: InjectableScope;
|
|
294
|
-
type: InjectableType.Factory;
|
|
295
|
-
token: InjectionToken<R, S>;
|
|
296
|
-
}): R extends undefined ? never : S extends InjectionTokenSchemaType ? <T extends ClassTypeWithInstance<FactoryWithArgs<R, S>>>(target: T, context: ClassDecoratorContext) => T : S extends undefined ? <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T : never;
|
|
297
|
-
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/event-emitter.d.mts
|
|
300
|
-
//# sourceMappingURL=injectable.decorator.d.mts.map
|
|
301
|
-
type EventsConfig = {
|
|
302
|
-
[event: string]: any[];
|
|
303
|
-
};
|
|
304
|
-
type EventsNames<Events extends EventsConfig> = Exclude<keyof Events, symbol | number>;
|
|
305
|
-
type EventsArgs<Events extends EventsConfig, Name extends EventsNames<Events>> = Events[Name] extends any[] ? Events[Name] : [];
|
|
306
|
-
type ChannelEmitter<Events extends EventsConfig, Ns extends string, E extends EventsNames<Events>> = {
|
|
307
|
-
emit<Args extends EventsArgs<Events, E>>(ns: Ns, event: E, ...args: Args): Promise<any>;
|
|
308
|
-
};
|
|
309
|
-
interface EventEmitterInterface<Events extends EventsConfig> {
|
|
310
|
-
on<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, listener: (...args: Args) => void): () => void;
|
|
311
|
-
emit<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, ...args: Args): void;
|
|
312
|
-
addChannel<E extends EventsNames<Events>, Ns extends string, Emmiter extends ChannelEmitter<Events, Ns, E>>(ns: Ns, event: E, target: Emmiter): () => void;
|
|
313
|
-
}
|
|
314
|
-
declare class EventEmitter<Events extends EventsConfig = {}> implements EventEmitterInterface<Events> {
|
|
315
|
-
private listeners;
|
|
316
|
-
on<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, listener: (...args: Args) => void): () => void;
|
|
317
|
-
off<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, listener: (...args: Args) => void): void;
|
|
318
|
-
once<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, listener: (...args: Args) => void): () => void;
|
|
319
|
-
emit<E extends EventsNames<Events>, Args extends EventsArgs<Events, E>>(event: E, ...args: Args): Promise<any>;
|
|
320
|
-
addChannel<E extends EventsNames<Events>, Ns extends string, Emitter extends ChannelEmitter<Events, Ns, E>>(ns: Ns, event: E, target: Emitter): () => void;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/injector.d.mts
|
|
325
|
-
//# sourceMappingURL=event-emitter.d.mts.map
|
|
326
|
-
declare function getGlobalServiceLocator(): ServiceLocator;
|
|
327
|
-
declare const inject: Injectors['inject'];
|
|
328
|
-
declare const syncInject: Injectors['syncInject'];
|
|
329
|
-
declare const wrapSyncInit: Injectors['wrapSyncInit'];
|
|
330
|
-
declare const provideServiceLocator: Injectors['provideServiceLocator'];
|
|
331
|
-
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/proxy-service-locator.d.mts
|
|
334
|
-
//# sourceMappingURL=injector.d.mts.map
|
|
335
|
-
declare class ProxyServiceLocator implements ServiceLocator {
|
|
336
|
-
private readonly serviceLocator;
|
|
337
|
-
private readonly ctx;
|
|
338
|
-
constructor(serviceLocator: ServiceLocator, ctx: FactoryContext);
|
|
339
|
-
getEventBus(): ServiceLocatorEventBus;
|
|
340
|
-
getInstance(token: InjectionToken<any, any> | BoundInjectionToken<any, any> | FactoryInjectionToken<any, any>, args?: any): Promise<any[]>;
|
|
341
|
-
getOrThrowInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Promise<Instance>;
|
|
342
|
-
getSyncInstance<Instance, Schema extends AnyZodObject | ZodOptional<AnyZodObject> | undefined>(token: InjectionToken<Instance, Schema>, args: Schema extends AnyZodObject ? z.input<Schema> : Schema extends ZodOptional<AnyZodObject> ? z.input<Schema> | undefined : undefined): Instance | null;
|
|
343
|
-
invalidate(service: string, round?: number): Promise<any>;
|
|
344
|
-
ready(): Promise<null>;
|
|
345
|
-
makeInstanceName(token: InjectionToken<any, any>, args: any): string;
|
|
346
|
-
}
|
|
347
|
-
declare function makeProxyServiceLocator(serviceLocator: ServiceLocator, ctx: FactoryContext): ServiceLocator;
|
|
348
|
-
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/resolve-service.d.mts
|
|
351
|
-
//# sourceMappingURL=proxy-service-locator.d.mts.map
|
|
352
|
-
declare function resolveService<T extends ClassType>(ctx: FactoryContext, target: T, args?: any[]): Promise<InstanceType<T>>;
|
|
353
|
-
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/service-locator-instance-holder.d.mts
|
|
356
|
-
//# sourceMappingURL=resolve-service.d.mts.map
|
|
357
|
-
declare enum ServiceLocatorInstanceHolderKind {
|
|
358
|
-
Instance = "instance",
|
|
359
|
-
Factory = "factory",
|
|
360
|
-
AbstractFactory = "abstractFactory",
|
|
361
|
-
}
|
|
362
|
-
declare enum ServiceLocatorInstanceHolderStatus {
|
|
363
|
-
Created = "created",
|
|
364
|
-
Creating = "creating",
|
|
365
|
-
Destroying = "destroying",
|
|
366
|
-
}
|
|
367
|
-
type ServiceLocatorInstanceEffect = () => void;
|
|
368
|
-
type ServiceLocatorInstanceDestroyListener = () => void | Promise<void>;
|
|
369
|
-
interface ServiceLocatorInstanceHolderCreating<Instance> {
|
|
370
|
-
status: ServiceLocatorInstanceHolderStatus.Creating;
|
|
371
|
-
name: string;
|
|
372
|
-
instance: null;
|
|
373
|
-
creationPromise: Promise<[undefined, Instance]> | null;
|
|
374
|
-
destroyPromise: null;
|
|
375
|
-
kind: ServiceLocatorInstanceHolderKind;
|
|
376
|
-
effects: ServiceLocatorInstanceEffect[];
|
|
377
|
-
deps: string[];
|
|
378
|
-
destroyListeners: ServiceLocatorInstanceDestroyListener[];
|
|
379
|
-
createdAt: number;
|
|
380
|
-
ttl: number;
|
|
381
|
-
}
|
|
382
|
-
interface ServiceLocatorInstanceHolderCreated<Instance> {
|
|
383
|
-
status: ServiceLocatorInstanceHolderStatus.Created;
|
|
384
|
-
name: string;
|
|
385
|
-
instance: Instance;
|
|
386
|
-
creationPromise: null;
|
|
387
|
-
destroyPromise: null;
|
|
388
|
-
kind: ServiceLocatorInstanceHolderKind;
|
|
389
|
-
effects: ServiceLocatorInstanceEffect[];
|
|
390
|
-
deps: string[];
|
|
391
|
-
destroyListeners: ServiceLocatorInstanceDestroyListener[];
|
|
392
|
-
createdAt: number;
|
|
393
|
-
ttl: number;
|
|
394
|
-
}
|
|
395
|
-
interface ServiceLocatorInstanceHolderDestroying<Instance> {
|
|
396
|
-
status: ServiceLocatorInstanceHolderStatus.Destroying;
|
|
397
|
-
name: string;
|
|
398
|
-
instance: Instance | null;
|
|
399
|
-
creationPromise: null;
|
|
400
|
-
destroyPromise: Promise<void>;
|
|
401
|
-
kind: ServiceLocatorInstanceHolderKind;
|
|
402
|
-
effects: ServiceLocatorInstanceEffect[];
|
|
403
|
-
deps: string[];
|
|
404
|
-
destroyListeners: ServiceLocatorInstanceDestroyListener[];
|
|
405
|
-
createdAt: number;
|
|
406
|
-
ttl: number;
|
|
407
|
-
}
|
|
408
|
-
type ServiceLocatorInstanceHolder<Instance = unknown> = ServiceLocatorInstanceHolderCreating<Instance> | ServiceLocatorInstanceHolderCreated<Instance> | ServiceLocatorInstanceHolderDestroying<Instance>;
|
|
409
|
-
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region src/service-locator-manager.d.mts
|
|
412
|
-
//# sourceMappingURL=service-locator-instance-holder.d.mts.map
|
|
413
|
-
declare class ServiceLocatorManager {
|
|
414
|
-
private readonly logger;
|
|
415
|
-
private readonly instancesHolders;
|
|
416
|
-
constructor(logger?: Console | null);
|
|
417
|
-
get(name: string): [InstanceExpired | InstanceDestroying, ServiceLocatorInstanceHolder] | [InstanceNotFound] | [undefined, ServiceLocatorInstanceHolder];
|
|
418
|
-
set(name: string, holder: ServiceLocatorInstanceHolder): void;
|
|
419
|
-
has(name: string): [InstanceExpired | InstanceDestroying] | [undefined, boolean];
|
|
420
|
-
delete(name: string): boolean;
|
|
421
|
-
filter(predicate: (value: ServiceLocatorInstanceHolder<any>, key: string) => boolean): Map<string, ServiceLocatorInstanceHolder>;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/symbols/injectable-token.d.mts
|
|
426
|
-
//# sourceMappingURL=service-locator-manager.d.mts.map
|
|
427
|
-
declare const InjectableTokenMeta: unique symbol;
|
|
428
|
-
|
|
429
|
-
//#endregion
|
|
430
|
-
//# sourceMappingURL=injectable-token.d.mts.map
|
|
431
|
-
|
|
432
|
-
export { BaseInjectionTokenSchemaType, BoundInjectionToken, ChannelEmitter, ClassType, ClassTypeWithArgument, ClassTypeWithInstance, ClassTypeWithInstanceAndArgument, ClassTypeWithInstanceAndOptionalArgument, ClassTypeWithOptionalArgument, CreateInjectorsOptions, ErrorsEnum, EventEmitter, EventEmitterInterface, EventsArgs, EventsConfig, EventsNames, Factory, FactoryContext, FactoryInjectionToken, FactoryNotFound, FactoryRecord, FactoryTokenNotResolved, FactoryWithArgs, Injectable, InjectableOptions, InjectableScope, InjectableTokenMeta, InjectableType, InjectionFactory, InjectionToken, InjectionTokenSchemaType, Injectors, InjectorsBase, InstanceDestroying, InstanceExpired, InstanceNotFound, OptionalInjectionTokenSchemaType, ProxyServiceLocator, Registry, ServiceLocator, ServiceLocatorEventBus, ServiceLocatorInstanceDestroyListener, ServiceLocatorInstanceEffect, ServiceLocatorInstanceHolder, ServiceLocatorInstanceHolderCreated, ServiceLocatorInstanceHolderCreating, ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnknownError, getGlobalServiceLocator, getInjectableToken, getInjectors, globalRegistry, inject, makeProxyServiceLocator, provideServiceLocator, resolveService, syncInject, wrapSyncInit };
|
|
433
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { Injectable } from './_tsup-dts-rollup.js';
|
|
2
|
+
export { InjectableOptions } from './_tsup-dts-rollup.js';
|
|
3
|
+
export { InjectableScope } from './_tsup-dts-rollup.js';
|
|
4
|
+
export { InjectableType } from './_tsup-dts-rollup.js';
|
|
5
|
+
export { ErrorsEnum } from './_tsup-dts-rollup.js';
|
|
6
|
+
export { FactoryNotFound } from './_tsup-dts-rollup.js';
|
|
7
|
+
export { FactoryTokenNotResolved } from './_tsup-dts-rollup.js';
|
|
8
|
+
export { InstanceDestroying } from './_tsup-dts-rollup.js';
|
|
9
|
+
export { InstanceExpired } from './_tsup-dts-rollup.js';
|
|
10
|
+
export { InstanceNotFound } from './_tsup-dts-rollup.js';
|
|
11
|
+
export { UnknownError } from './_tsup-dts-rollup.js';
|
|
12
|
+
export { Factory } from './_tsup-dts-rollup.js';
|
|
13
|
+
export { FactoryWithArgs } from './_tsup-dts-rollup.js';
|
|
14
|
+
export { getInjectors } from './_tsup-dts-rollup.js';
|
|
15
|
+
export { CreateInjectorsOptions } from './_tsup-dts-rollup.js';
|
|
16
|
+
export { Injectors } from './_tsup-dts-rollup.js';
|
|
17
|
+
export { InjectorsBase } from './_tsup-dts-rollup.js';
|
|
18
|
+
export { getInjectableToken } from './_tsup-dts-rollup.js';
|
|
19
|
+
export { EventsConfig_alias_1 as EventsConfig } from './_tsup-dts-rollup.js';
|
|
20
|
+
export { EventsNames_alias_1 as EventsNames } from './_tsup-dts-rollup.js';
|
|
21
|
+
export { EventsArgs_alias_1 as EventsArgs } from './_tsup-dts-rollup.js';
|
|
22
|
+
export { ChannelEmitter_alias_1 as ChannelEmitter } from './_tsup-dts-rollup.js';
|
|
23
|
+
export { EventEmitterInterface_alias_1 as EventEmitterInterface } from './_tsup-dts-rollup.js';
|
|
24
|
+
export { EventEmitter_alias_1 as EventEmitter } from './_tsup-dts-rollup.js';
|
|
25
|
+
export { FactoryContext_alias_1 as FactoryContext } from './_tsup-dts-rollup.js';
|
|
26
|
+
export { ClassType } from './_tsup-dts-rollup.js';
|
|
27
|
+
export { ClassTypeWithArgument } from './_tsup-dts-rollup.js';
|
|
28
|
+
export { ClassTypeWithOptionalArgument } from './_tsup-dts-rollup.js';
|
|
29
|
+
export { ClassTypeWithInstance } from './_tsup-dts-rollup.js';
|
|
30
|
+
export { ClassTypeWithInstanceAndArgument } from './_tsup-dts-rollup.js';
|
|
31
|
+
export { ClassTypeWithInstanceAndOptionalArgument } from './_tsup-dts-rollup.js';
|
|
32
|
+
export { BaseInjectionTokenSchemaType } from './_tsup-dts-rollup.js';
|
|
33
|
+
export { OptionalInjectionTokenSchemaType } from './_tsup-dts-rollup.js';
|
|
34
|
+
export { InjectionTokenSchemaType } from './_tsup-dts-rollup.js';
|
|
35
|
+
export { InjectionToken } from './_tsup-dts-rollup.js';
|
|
36
|
+
export { BoundInjectionToken } from './_tsup-dts-rollup.js';
|
|
37
|
+
export { FactoryInjectionToken } from './_tsup-dts-rollup.js';
|
|
38
|
+
export { getGlobalServiceLocator } from './_tsup-dts-rollup.js';
|
|
39
|
+
export { inject } from './_tsup-dts-rollup.js';
|
|
40
|
+
export { syncInject } from './_tsup-dts-rollup.js';
|
|
41
|
+
export { wrapSyncInit } from './_tsup-dts-rollup.js';
|
|
42
|
+
export { provideServiceLocator } from './_tsup-dts-rollup.js';
|
|
43
|
+
export { makeProxyServiceLocator } from './_tsup-dts-rollup.js';
|
|
44
|
+
export { ProxyServiceLocator } from './_tsup-dts-rollup.js';
|
|
45
|
+
export { InjectionFactory } from './_tsup-dts-rollup.js';
|
|
46
|
+
export { FactoryRecord } from './_tsup-dts-rollup.js';
|
|
47
|
+
export { Registry } from './_tsup-dts-rollup.js';
|
|
48
|
+
export { globalRegistry } from './_tsup-dts-rollup.js';
|
|
49
|
+
export { resolveService } from './_tsup-dts-rollup.js';
|
|
50
|
+
export { ServiceLocator } from './_tsup-dts-rollup.js';
|
|
51
|
+
export { ServiceLocatorEventBus } from './_tsup-dts-rollup.js';
|
|
52
|
+
export { ServiceLocatorInstanceHolderKind } from './_tsup-dts-rollup.js';
|
|
53
|
+
export { ServiceLocatorInstanceHolderStatus } from './_tsup-dts-rollup.js';
|
|
54
|
+
export { ServiceLocatorInstanceEffect } from './_tsup-dts-rollup.js';
|
|
55
|
+
export { ServiceLocatorInstanceDestroyListener } from './_tsup-dts-rollup.js';
|
|
56
|
+
export { ServiceLocatorInstanceHolderCreating } from './_tsup-dts-rollup.js';
|
|
57
|
+
export { ServiceLocatorInstanceHolderCreated } from './_tsup-dts-rollup.js';
|
|
58
|
+
export { ServiceLocatorInstanceHolderDestroying } from './_tsup-dts-rollup.js';
|
|
59
|
+
export { ServiceLocatorInstanceHolder } from './_tsup-dts-rollup.js';
|
|
60
|
+
export { ServiceLocatorManager } from './_tsup-dts-rollup.js';
|
|
61
|
+
export { InjectableTokenMeta } from './_tsup-dts-rollup.js';
|