@tstdl/base 0.85.16 → 0.85.17
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/data-structures/set-collection.d.ts +2 -2
- package/data-structures/set-collection.js +2 -2
- package/injector/decorators.d.ts +11 -6
- package/injector/decorators.js +3 -3
- package/injector/injector.d.ts +4 -4
- package/injector/injector.js +5 -5
- package/injector/type-info.d.ts +1 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class SetCollection<T> extends
|
|
1
|
+
import { DistinctCollection } from './distinct-collection.js';
|
|
2
|
+
export declare class SetCollection<T> extends DistinctCollection<T, SetCollection<T>> implements globalThis.Set<T> {
|
|
3
3
|
private readonly backingSet;
|
|
4
4
|
readonly [Symbol.toStringTag]: string;
|
|
5
5
|
constructor(items?: Iterable<T>);
|
|
@@ -21,8 +21,8 @@ __export(set_collection_exports, {
|
|
|
21
21
|
SetCollection: () => SetCollection
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(set_collection_exports);
|
|
24
|
-
var
|
|
25
|
-
class SetCollection extends
|
|
24
|
+
var import_distinct_collection = require("./distinct-collection.js");
|
|
25
|
+
class SetCollection extends import_distinct_collection.DistinctCollection {
|
|
26
26
|
backingSet;
|
|
27
27
|
[Symbol.toStringTag] = "Set";
|
|
28
28
|
constructor(items) {
|
package/injector/decorators.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Decorator } from '../reflection/index.js';
|
|
2
|
-
import type { Constructor, Simplify, TypedOmit } from '../types.js';
|
|
2
|
+
import type { Constructor, OneOrMany, Simplify, TypedOmit } from '../types.js';
|
|
3
|
+
import type { Provider } from './provider.js';
|
|
3
4
|
import type { InjectionToken } from './token.js';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
5
|
+
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper, RegistrationOptions } from './types.js';
|
|
6
|
+
type InjectDecorator = Decorator<'accessor' | 'constructorParameter'>;
|
|
7
|
+
export type InjectableOptions<T, A> = RegistrationOptions<T, A> & {
|
|
8
|
+
/** aliases (tokens) for the class. Useful for example for circular dependencies when you can't use the class itself as a token */
|
|
9
|
+
alias?: OneOrMany<InjectionToken>;
|
|
10
|
+
/** custom provider. Useful for example if initialization is required */
|
|
11
|
+
provider?: Provider<T, A>;
|
|
12
|
+
};
|
|
8
13
|
export type InjectableOptionsWithoutLifecycle<T, A> = Simplify<TypedOmit<InjectableOptions<T, A>, 'lifecycle'>>;
|
|
9
14
|
/**
|
|
10
15
|
* Helper decorator to replace a class definition with an other
|
|
@@ -13,7 +18,7 @@ export type InjectableOptionsWithoutLifecycle<T, A> = Simplify<TypedOmit<Injecta
|
|
|
13
18
|
*/
|
|
14
19
|
export declare function ReplaceClass<T>(constructor: Constructor<T>): ClassDecorator;
|
|
15
20
|
/**
|
|
16
|
-
* registers the class
|
|
21
|
+
* Globally registers the class for injection
|
|
17
22
|
* @param options registration options
|
|
18
23
|
*/
|
|
19
24
|
export declare function Injectable<T = any, A = any>(options?: InjectableOptions<T, A>): ClassDecorator;
|
package/injector/decorators.js
CHANGED
|
@@ -41,16 +41,16 @@ function ReplaceClass(constructor) {
|
|
|
41
41
|
}
|
|
42
42
|
function Injectable(options = {}) {
|
|
43
43
|
return (0, import_reflection.createClassDecorator)({
|
|
44
|
-
data: { [import_symbols.injectableMetadataSymbol]:
|
|
44
|
+
data: { [import_symbols.injectableMetadataSymbol]: {} },
|
|
45
45
|
mergeData: true,
|
|
46
46
|
handler: (data) => {
|
|
47
47
|
const { alias: aliases, provider, ...registrationOptions } = options;
|
|
48
48
|
const token = data.constructor;
|
|
49
49
|
const targetProvider = provider ?? { useClass: token };
|
|
50
|
-
import_injector.Injector.
|
|
50
|
+
import_injector.Injector.register(token, targetProvider, registrationOptions);
|
|
51
51
|
if ((0, import_type_guards.isDefined)(aliases)) {
|
|
52
52
|
for (const alias of (0, import_array.toArray)(aliases)) {
|
|
53
|
-
import_injector.Injector.
|
|
53
|
+
import_injector.Injector.register(alias, { useToken: token }, registrationOptions);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
package/injector/injector.d.ts
CHANGED
|
@@ -43,19 +43,19 @@ export declare class Injector {
|
|
|
43
43
|
readonly name: string;
|
|
44
44
|
constructor(name: string, parent?: Injector | null);
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Globally register a provider for a token
|
|
47
47
|
* @param token token to register
|
|
48
48
|
* @param provider provider used to resolve the token
|
|
49
49
|
* @param options registration options
|
|
50
50
|
*/
|
|
51
|
-
static
|
|
51
|
+
static register<T, A = any>(token: InjectionToken<T, A>, provider: Provider<T, A>, options?: RegistrationOptions<T, A>): void;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Globally register a provider for a token as a singleton. Alias for {@link register} with `singleton` lifecycle
|
|
54
54
|
* @param token token to register
|
|
55
55
|
* @param provider provider used to resolve the token
|
|
56
56
|
* @param options registration options
|
|
57
57
|
*/
|
|
58
|
-
static
|
|
58
|
+
static registerSingleton<T, A = any>(token: InjectionToken<T, A>, provider: Provider<T, A>, options?: TypedOmit<RegistrationOptions<T, A>, 'lifecycle'>): void;
|
|
59
59
|
fork(name: string): Injector;
|
|
60
60
|
/**
|
|
61
61
|
* Register a provider for a token
|
package/injector/injector.js
CHANGED
|
@@ -48,12 +48,12 @@ class Injector {
|
|
|
48
48
|
this.register(Injector, { useValue: this });
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Globally register a provider for a token
|
|
52
52
|
* @param token token to register
|
|
53
53
|
* @param provider provider used to resolve the token
|
|
54
54
|
* @param options registration options
|
|
55
55
|
*/
|
|
56
|
-
static
|
|
56
|
+
static register(token, provider, options = {}) {
|
|
57
57
|
const registration = {
|
|
58
58
|
token,
|
|
59
59
|
provider,
|
|
@@ -62,13 +62,13 @@ class Injector {
|
|
|
62
62
|
addRegistration(Injector.#globalRegistrations, registration);
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Globally register a provider for a token as a singleton. Alias for {@link register} with `singleton` lifecycle
|
|
66
66
|
* @param token token to register
|
|
67
67
|
* @param provider provider used to resolve the token
|
|
68
68
|
* @param options registration options
|
|
69
69
|
*/
|
|
70
|
-
static
|
|
71
|
-
Injector.
|
|
70
|
+
static registerSingleton(token, provider, options) {
|
|
71
|
+
Injector.register(token, provider, { ...options, lifecycle: "singleton" });
|
|
72
72
|
}
|
|
73
73
|
fork(name) {
|
|
74
74
|
return new Injector(name, this);
|
package/injector/type-info.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import type { OneOrMany } from '../types.js';
|
|
2
|
-
import type { Provider } from './provider.js';
|
|
3
1
|
import type { InjectionToken } from './token.js';
|
|
4
|
-
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper
|
|
5
|
-
export type InjectableMetadata<T, A> = RegistrationOptions<T, A> & {
|
|
6
|
-
/** aliases (tokens) for the class. Useful for example for circular dependencies when you can't use the class itself as a token */
|
|
7
|
-
alias?: OneOrMany<InjectionToken>;
|
|
8
|
-
/** custom provider. Useful for example if initialization is required */
|
|
9
|
-
provider?: Provider<T, A>;
|
|
10
|
-
};
|
|
2
|
+
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper } from './types.js';
|
|
11
3
|
export type InjectMetadata = {
|
|
12
4
|
/** token overwrite by inject decorator */
|
|
13
5
|
injectToken?: InjectionToken;
|