ditox 2.2.0 → 2.3.1
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 +1 -1
- package/README.md +134 -129
- package/dist/browser/index.d.ts +17 -17
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/ditox.d.ts +9 -9
- package/dist/cjs/modules.d.ts +10 -9
- package/dist/cjs/modules.js.map +1 -1
- package/dist/cjs/utils.d.ts +2 -2
- package/dist/esm/ditox.d.ts +9 -9
- package/dist/esm/modules.d.ts +10 -9
- package/dist/esm/modules.js.map +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/umd/index.d.ts +17 -17
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +11 -6
- package/src/modules.ts +3 -1
- package/dist/cjs/utils-deprecated.d.ts +0 -59
- package/dist/cjs/utils-deprecated.js +0 -66
- package/dist/cjs/utils-deprecated.js.map +0 -1
- package/dist/esm/utils-deprecated.d.ts +0 -59
- package/dist/esm/utils-deprecated.js +0 -59
- package/dist/esm/utils-deprecated.js.map +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/README.md +0 -794
- package/docs/classes/ResolverError.md +0 -165
package/dist/cjs/ditox.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @ignore
|
|
3
3
|
* Binding token for mandatory value
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type RequiredToken<T> = {
|
|
6
6
|
symbol: symbol;
|
|
7
7
|
type?: T;
|
|
8
8
|
isOptional?: false;
|
|
@@ -11,7 +11,7 @@ export declare type RequiredToken<T> = {
|
|
|
11
11
|
* @ignore
|
|
12
12
|
* Binding token for optional value
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type OptionalToken<T> = {
|
|
15
15
|
symbol: symbol;
|
|
16
16
|
type?: T;
|
|
17
17
|
isOptional: true;
|
|
@@ -20,7 +20,7 @@ export declare type OptionalToken<T> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Binding token.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type Token<T> = RequiredToken<T> | OptionalToken<T>;
|
|
24
24
|
/**
|
|
25
25
|
* Creates a new binding token.
|
|
26
26
|
* @param description - Token description for better error messages.
|
|
@@ -43,7 +43,7 @@ export declare class ResolverError extends Error {
|
|
|
43
43
|
/**
|
|
44
44
|
* @see https://github.com/mnasyrov/ditox#factory-lifetimes
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
47
47
|
/**
|
|
48
48
|
* Options for factory binding.
|
|
49
49
|
*
|
|
@@ -54,7 +54,7 @@ export declare type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
|
54
54
|
*
|
|
55
55
|
* `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container.
|
|
56
56
|
*/
|
|
57
|
-
export
|
|
57
|
+
export type FactoryOptions<T> = {
|
|
58
58
|
scope?: 'scoped' | 'singleton';
|
|
59
59
|
onRemoved?: (value: T) => void;
|
|
60
60
|
} | {
|
|
@@ -63,7 +63,7 @@ export declare type FactoryOptions<T> = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Dependency container.
|
|
65
65
|
*/
|
|
66
|
-
export
|
|
66
|
+
export type Container = {
|
|
67
67
|
/**
|
|
68
68
|
* Binds a value for the token
|
|
69
69
|
*/
|
|
@@ -104,16 +104,16 @@ declare const NOT_FOUND: unique symbol;
|
|
|
104
104
|
/** @internal */
|
|
105
105
|
export declare const FAKE_FACTORY: () => never;
|
|
106
106
|
/** @internal */
|
|
107
|
-
|
|
107
|
+
type FactoryContext<T> = {
|
|
108
108
|
factory: (container: Container) => T;
|
|
109
109
|
options?: FactoryOptions<T>;
|
|
110
110
|
};
|
|
111
111
|
/** @internal */
|
|
112
|
-
export
|
|
112
|
+
export type FactoriesMap = Map<symbol, FactoryContext<any>>;
|
|
113
113
|
/** @internal */
|
|
114
114
|
export declare const FACTORIES_MAP: Token<FactoriesMap>;
|
|
115
115
|
/** @internal */
|
|
116
|
-
|
|
116
|
+
type Resolver = <T>(token: Token<T>, origin: Container) => T | typeof NOT_FOUND;
|
|
117
117
|
/**
|
|
118
118
|
* Creates a new dependency container.
|
|
119
119
|
*
|
package/dist/cjs/modules.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Container, Token } from './ditox';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type AnyObject = Record<string, any>;
|
|
3
|
+
type EmptyObject = Record<string, never>;
|
|
4
|
+
type ModuleController = {
|
|
5
5
|
/** Dispose the module and clean its resources */
|
|
6
6
|
destroy?: () => void;
|
|
7
7
|
};
|
|
@@ -15,8 +15,8 @@ declare type ModuleController = {
|
|
|
15
15
|
* }>;
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
18
|
+
export type Module<ModuleProps extends AnyObject = EmptyObject> = ModuleController & ModuleProps;
|
|
19
|
+
type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
20
20
|
/**
|
|
21
21
|
* Description how to bind the module in declarative way.
|
|
22
22
|
*
|
|
@@ -37,7 +37,7 @@ declare type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
|
37
37
|
* };
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
41
41
|
/** Token for the module */
|
|
42
42
|
token: Token<T>;
|
|
43
43
|
/** Modules for binding */
|
|
@@ -53,6 +53,7 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
53
53
|
/** Callback could be used to export complex dependencies from the module. It is called after binding the module. */
|
|
54
54
|
afterBinding?: (container: Container) => void;
|
|
55
55
|
};
|
|
56
|
+
export type AnyModuleDeclaration = ModuleDeclaration<Module<AnyObject>>;
|
|
56
57
|
/**
|
|
57
58
|
* Options for module binding.
|
|
58
59
|
*
|
|
@@ -60,10 +61,10 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
60
61
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
61
62
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
62
63
|
*/
|
|
63
|
-
export
|
|
64
|
+
export type BindModuleOptions = {
|
|
64
65
|
scope?: 'scoped' | 'singleton';
|
|
65
66
|
};
|
|
66
|
-
export
|
|
67
|
+
export type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
67
68
|
module: ModuleDeclaration<AnyObject>;
|
|
68
69
|
options: BindModuleOptions;
|
|
69
70
|
};
|
|
@@ -108,7 +109,7 @@ export declare function bindModules(container: Container, modules: ReadonlyArray
|
|
|
108
109
|
* });
|
|
109
110
|
* ```
|
|
110
111
|
*/
|
|
111
|
-
export declare function declareModule<T
|
|
112
|
+
export declare function declareModule<T extends Module<AnyObject>>(declaration: Omit<ModuleDeclaration<T>, 'token'> & Partial<Pick<ModuleDeclaration<T>, 'token'>>): ModuleDeclaration<T>;
|
|
112
113
|
/**
|
|
113
114
|
* Declares bindings of several modules
|
|
114
115
|
*
|
package/dist/cjs/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/modules.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAChD,mCAAmC;
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/modules.ts"],"names":[],"mappings":";;;AAAA,mCAAgD;AAChD,mCAAmC;AAuFnC;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,SAAoB,EACpB,iBAAuC,EACvC,OAA2B;IAE3B,MAAM,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAC,GAC1D,iBAAiB,CAAC;I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ACH,CAAC;AArDD,gCAqDC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,SAAoB,EACpB,OAA0C;IAE1C,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,QAAQ,IAAI,KAAK,EAAE;YACrB,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SACpD;aAAM;YACL,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,kCAWC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,aAAa,CAC3B,WAC8C;;IAE9C,OAAO,EAAC,GAAG,WAAW,EAAE,KAAK,EAAE,MAAA,WAAW,CAAC,KAAK,mCAAI,IAAA,aAAK,GAAE,EAAC,CAAC;AAC/D,CAAC;AALD,sCAKC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CACnC,OAA0C;IAE1C,OAAO,aAAa,CAAC;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC;AAPD,sDAOC"}
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Container, Token } from './ditox';
|
|
2
|
-
|
|
2
|
+
type ValuesProps = {
|
|
3
3
|
[key: string]: unknown;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type TokenProps<Props extends ValuesProps> = {
|
|
6
6
|
[K in keyof Props]: Token<Props[K]>;
|
|
7
7
|
};
|
|
8
8
|
/**
|
package/dist/esm/ditox.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @ignore
|
|
3
3
|
* Binding token for mandatory value
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type RequiredToken<T> = {
|
|
6
6
|
symbol: symbol;
|
|
7
7
|
type?: T;
|
|
8
8
|
isOptional?: false;
|
|
@@ -11,7 +11,7 @@ export declare type RequiredToken<T> = {
|
|
|
11
11
|
* @ignore
|
|
12
12
|
* Binding token for optional value
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export type OptionalToken<T> = {
|
|
15
15
|
symbol: symbol;
|
|
16
16
|
type?: T;
|
|
17
17
|
isOptional: true;
|
|
@@ -20,7 +20,7 @@ export declare type OptionalToken<T> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Binding token.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type Token<T> = RequiredToken<T> | OptionalToken<T>;
|
|
24
24
|
/**
|
|
25
25
|
* Creates a new binding token.
|
|
26
26
|
* @param description - Token description for better error messages.
|
|
@@ -43,7 +43,7 @@ export declare class ResolverError extends Error {
|
|
|
43
43
|
/**
|
|
44
44
|
* @see https://github.com/mnasyrov/ditox#factory-lifetimes
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
47
47
|
/**
|
|
48
48
|
* Options for factory binding.
|
|
49
49
|
*
|
|
@@ -54,7 +54,7 @@ export declare type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
|
54
54
|
*
|
|
55
55
|
* `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container.
|
|
56
56
|
*/
|
|
57
|
-
export
|
|
57
|
+
export type FactoryOptions<T> = {
|
|
58
58
|
scope?: 'scoped' | 'singleton';
|
|
59
59
|
onRemoved?: (value: T) => void;
|
|
60
60
|
} | {
|
|
@@ -63,7 +63,7 @@ export declare type FactoryOptions<T> = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Dependency container.
|
|
65
65
|
*/
|
|
66
|
-
export
|
|
66
|
+
export type Container = {
|
|
67
67
|
/**
|
|
68
68
|
* Binds a value for the token
|
|
69
69
|
*/
|
|
@@ -104,16 +104,16 @@ declare const NOT_FOUND: unique symbol;
|
|
|
104
104
|
/** @internal */
|
|
105
105
|
export declare const FAKE_FACTORY: () => never;
|
|
106
106
|
/** @internal */
|
|
107
|
-
|
|
107
|
+
type FactoryContext<T> = {
|
|
108
108
|
factory: (container: Container) => T;
|
|
109
109
|
options?: FactoryOptions<T>;
|
|
110
110
|
};
|
|
111
111
|
/** @internal */
|
|
112
|
-
export
|
|
112
|
+
export type FactoriesMap = Map<symbol, FactoryContext<any>>;
|
|
113
113
|
/** @internal */
|
|
114
114
|
export declare const FACTORIES_MAP: Token<FactoriesMap>;
|
|
115
115
|
/** @internal */
|
|
116
|
-
|
|
116
|
+
type Resolver = <T>(token: Token<T>, origin: Container) => T | typeof NOT_FOUND;
|
|
117
117
|
/**
|
|
118
118
|
* Creates a new dependency container.
|
|
119
119
|
*
|
package/dist/esm/modules.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Container, Token } from './ditox';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type AnyObject = Record<string, any>;
|
|
3
|
+
type EmptyObject = Record<string, never>;
|
|
4
|
+
type ModuleController = {
|
|
5
5
|
/** Dispose the module and clean its resources */
|
|
6
6
|
destroy?: () => void;
|
|
7
7
|
};
|
|
@@ -15,8 +15,8 @@ declare type ModuleController = {
|
|
|
15
15
|
* }>;
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
18
|
+
export type Module<ModuleProps extends AnyObject = EmptyObject> = ModuleController & ModuleProps;
|
|
19
|
+
type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
20
20
|
/**
|
|
21
21
|
* Description how to bind the module in declarative way.
|
|
22
22
|
*
|
|
@@ -37,7 +37,7 @@ declare type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
|
37
37
|
* };
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
41
41
|
/** Token for the module */
|
|
42
42
|
token: Token<T>;
|
|
43
43
|
/** Modules for binding */
|
|
@@ -53,6 +53,7 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
53
53
|
/** Callback could be used to export complex dependencies from the module. It is called after binding the module. */
|
|
54
54
|
afterBinding?: (container: Container) => void;
|
|
55
55
|
};
|
|
56
|
+
export type AnyModuleDeclaration = ModuleDeclaration<Module<AnyObject>>;
|
|
56
57
|
/**
|
|
57
58
|
* Options for module binding.
|
|
58
59
|
*
|
|
@@ -60,10 +61,10 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
60
61
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
61
62
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
62
63
|
*/
|
|
63
|
-
export
|
|
64
|
+
export type BindModuleOptions = {
|
|
64
65
|
scope?: 'scoped' | 'singleton';
|
|
65
66
|
};
|
|
66
|
-
export
|
|
67
|
+
export type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
67
68
|
module: ModuleDeclaration<AnyObject>;
|
|
68
69
|
options: BindModuleOptions;
|
|
69
70
|
};
|
|
@@ -108,7 +109,7 @@ export declare function bindModules(container: Container, modules: ReadonlyArray
|
|
|
108
109
|
* });
|
|
109
110
|
* ```
|
|
110
111
|
*/
|
|
111
|
-
export declare function declareModule<T
|
|
112
|
+
export declare function declareModule<T extends Module<AnyObject>>(declaration: Omit<ModuleDeclaration<T>, 'token'> & Partial<Pick<ModuleDeclaration<T>, 'token'>>): ModuleDeclaration<T>;
|
|
112
113
|
/**
|
|
113
114
|
* Declares bindings of several modules
|
|
114
115
|
*
|
package/dist/esm/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAQ,MAAM,SAAS,CAAC;AACh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2
|
+
type ValuesProps = {
|
|
3
3
|
[key: string]: unknown;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type TokenProps<Props extends ValuesProps> = {
|
|
6
6
|
[K in keyof Props]: Token<Props[K]>;
|
|
7
7
|
};
|
|
8
8
|
/**
|
package/dist/umd/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @ignore
|
|
3
3
|
* Binding token for mandatory value
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
type RequiredToken<T> = {
|
|
6
6
|
symbol: symbol;
|
|
7
7
|
type?: T;
|
|
8
8
|
isOptional?: false;
|
|
@@ -11,7 +11,7 @@ declare type RequiredToken<T> = {
|
|
|
11
11
|
* @ignore
|
|
12
12
|
* Binding token for optional value
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
type OptionalToken<T> = {
|
|
15
15
|
symbol: symbol;
|
|
16
16
|
type?: T;
|
|
17
17
|
isOptional: true;
|
|
@@ -20,7 +20,7 @@ declare type OptionalToken<T> = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Binding token.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
type Token<T> = RequiredToken<T> | OptionalToken<T>;
|
|
24
24
|
/**
|
|
25
25
|
* Creates a new binding token.
|
|
26
26
|
* @param description - Token description for better error messages.
|
|
@@ -43,7 +43,7 @@ declare class ResolverError extends Error {
|
|
|
43
43
|
/**
|
|
44
44
|
* @see https://github.com/mnasyrov/ditox#factory-lifetimes
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
47
47
|
/**
|
|
48
48
|
* Options for factory binding.
|
|
49
49
|
*
|
|
@@ -54,7 +54,7 @@ declare type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
|
54
54
|
*
|
|
55
55
|
* `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
type FactoryOptions<T> = {
|
|
58
58
|
scope?: 'scoped' | 'singleton';
|
|
59
59
|
onRemoved?: (value: T) => void;
|
|
60
60
|
} | {
|
|
@@ -63,7 +63,7 @@ declare type FactoryOptions<T> = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Dependency container.
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
type Container = {
|
|
67
67
|
/**
|
|
68
68
|
* Binds a value for the token
|
|
69
69
|
*/
|
|
@@ -102,10 +102,10 @@ declare type Container = {
|
|
|
102
102
|
*/
|
|
103
103
|
declare function createContainer(parentContainer?: Container): Container;
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
type ValuesProps = {
|
|
106
106
|
[key: string]: unknown;
|
|
107
107
|
};
|
|
108
|
-
|
|
108
|
+
type TokenProps<Props extends ValuesProps> = {
|
|
109
109
|
[K in keyof Props]: Token<Props[K]>;
|
|
110
110
|
};
|
|
111
111
|
/**
|
|
@@ -237,9 +237,9 @@ declare function injectableClass<Tokens extends (Token<unknown> | {
|
|
|
237
237
|
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
238
238
|
}, Result>(this: unknown, constructor: new (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
type AnyObject = Record<string, any>;
|
|
241
|
+
type EmptyObject = Record<string, never>;
|
|
242
|
+
type ModuleController = {
|
|
243
243
|
/** Dispose the module and clean its resources */
|
|
244
244
|
destroy?: () => void;
|
|
245
245
|
};
|
|
@@ -253,8 +253,8 @@ declare type ModuleController = {
|
|
|
253
253
|
* }>;
|
|
254
254
|
* ```
|
|
255
255
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
type Module<ModuleProps extends AnyObject = EmptyObject> = ModuleController & ModuleProps;
|
|
257
|
+
type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
258
258
|
/**
|
|
259
259
|
* Description how to bind the module in declarative way.
|
|
260
260
|
*
|
|
@@ -275,7 +275,7 @@ declare type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
|
275
275
|
* };
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
|
|
278
|
+
type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
279
279
|
/** Token for the module */
|
|
280
280
|
token: Token<T>;
|
|
281
281
|
/** Modules for binding */
|
|
@@ -298,10 +298,10 @@ declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
298
298
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
299
299
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
type BindModuleOptions = {
|
|
302
302
|
scope?: 'scoped' | 'singleton';
|
|
303
303
|
};
|
|
304
|
-
|
|
304
|
+
type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
305
305
|
module: ModuleDeclaration<AnyObject>;
|
|
306
306
|
options: BindModuleOptions;
|
|
307
307
|
};
|
|
@@ -346,7 +346,7 @@ declare function bindModules(container: Container, modules: ReadonlyArray<Module
|
|
|
346
346
|
* });
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
|
-
declare function declareModule<T
|
|
349
|
+
declare function declareModule<T extends Module<AnyObject>>(declaration: Omit<ModuleDeclaration<T>, 'token'> & Partial<Pick<ModuleDeclaration<T>, 'token'>>): ModuleDeclaration<T>;
|
|
350
350
|
/**
|
|
351
351
|
* Declares bindings of several modules
|
|
352
352
|
*
|
package/dist/umd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(o,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((o="undefined"!=typeof globalThis?globalThis:o||self).Ditox={})}(this,(function(o){"use strict";var n=function(o,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(o[t]=n[t])},n(o,t)};var t=function(){return t=Object.assign||function(o){for(var n,t=1,e=arguments.length;t<e;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(o[r]=n[r]);return o},t.apply(this,arguments)};function e(o,n,t){if(t||2===arguments.length)for(var e,r=0,i=n.length;r<i;r++)!e&&r in n||(e||(e=Array.prototype.slice.call(n,0,r)),e[r]=n[r]);return o.concat(e||Array.prototype.slice.call(n))}function r(o){return{symbol:Symbol(o)}}var i=function(o){function t(n){var t=this.constructor,e=o.call(this,n)||this;return Object.setPrototypeOf(e,t.prototype),e.name="ResolverError",e}return function(o,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=o}n(o,t),o.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}(t,o),t}(Error),l=r("ditox.Container"),u=r("ditox.ParentContainer"),a=r("ditox.Resolver"),s=Symbol(),c=function(){throw new Error("FAKE_FACTORY")},f=r("ditox.FactoriesMap");function
|
|
1
|
+
!function(o,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((o="undefined"!=typeof globalThis?globalThis:o||self).Ditox={})}(this,(function(o){"use strict";var n=function(o,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(o[t]=n[t])},n(o,t)};var t=function(){return t=Object.assign||function(o){for(var n,t=1,e=arguments.length;t<e;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(o[r]=n[r]);return o},t.apply(this,arguments)};function e(o,n,t){if(t||2===arguments.length)for(var e,r=0,i=n.length;r<i;r++)!e&&r in n||(e||(e=Array.prototype.slice.call(n,0,r)),e[r]=n[r]);return o.concat(e||Array.prototype.slice.call(n))}function r(o){return{symbol:Symbol(o)}}var i=function(o){function t(n){var t=this.constructor,e=o.call(this,n)||this;return Object.setPrototypeOf(e,t.prototype),e.name="ResolverError",e}return function(o,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=o}n(o,t),o.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}(t,o),t}(Error),l=r("ditox.Container"),u=r("ditox.ParentContainer"),a=r("ditox.Resolver"),s=Symbol(),c=function(){throw new Error("FAKE_FACTORY")},f="singleton",p=r("ditox.FactoriesMap");function y(o){return o.symbol===l.symbol||o.symbol===u.symbol||o.symbol===a.symbol}function v(o){return null!=o&&"object"==typeof o&&"symbol"in o&&"symbol"==typeof o.symbol}function d(o,n){if(v(n))return o.get(n);var t={};return Object.keys(n).forEach((function(e){return t[e]=o.get(n[e])})),t}function b(o,n){if(v(n))return o.resolve(n);var t={};return Object.keys(n).forEach((function(e){return t[e]=o.resolve(n[e])})),t}function m(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return b(o,n)}))}function h(o){for(var n=this,t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function(r){var i=m.apply(void 0,e([r],t,!1));return o.apply(n,i)}}function g(o,n,t){var e=n.token,r=n.imports,i=n.factory,l=n.beforeBinding,u=n.afterBinding,a=n.exports,s=null==t?void 0:t.scope;l&&l(o),r&&O(o,r);var c=new Set;a&&Object.keys(a).forEach((function(n){var t=a[n];t&&(c.add(t),o.bindFactory(t,h((function(o){return o[n]}),e),{scope:s}))}));o.bindFactory(e,i,{scope:s,onRemoved:function(n){n.destroy&&n.destroy(),c.forEach((function(n){return o.remove(n)})),c.clear()}}),u&&u(o)}function O(o,n){n.forEach((function(n){"module"in n?g(o,n.module,n.options):g(o,n)}))}function w(o){var n;return t(t({},o),{token:null!==(n=o.token)&&void 0!==n?n:r()})}o.ResolverError=i,o.bindModule=g,o.bindModules=O,o.bindMultiValue=function(o,n,t){var r,i=e(e([],null!==(r=o.get(n))&&void 0!==r?r:[],!0),[t],!1);o.bindValue(n,i)},o.createContainer=function(o){var n=new Map,t=new Map,e={bindValue:function(o,t){y(o)||n.set(o.symbol,t)},bindFactory:function(o,n,e){y(o)||t.set(o.symbol,{factory:n,options:e})},remove:function(o){var e;if(!y(o)){var r=null===(e=t.get(o.symbol))||void 0===e?void 0:e.options;r&&v(o.symbol,r),n.delete(o.symbol),t.delete(o.symbol)}},removeAll:function(){t.forEach((function(o,n){o.options&&v(n,o.options)})),n.clear(),t.clear(),d()},hasToken:function(e){var r;return n.has(e.symbol)||t.has(e.symbol)||null!==(r=null==o?void 0:o.hasToken(e))&&void 0!==r&&r},get:function(o){var n=r(o,e);return n!==s?n:o.isOptional?o.optionalValue:void 0},resolve:function(o){var n,t=r(o,e);if(t!==s)return t;if(o.isOptional)return o.optionalValue;throw new i('Token "'.concat(null!==(n=o.symbol.description)&&void 0!==n?n:"",'" is not provided'))}};function r(r,i){var l=n.get(r.symbol),u=void 0!==l||n.has(r.symbol);if(u&&i===e)return l;var p,y,v=t.get(r.symbol);if(v&&v.factory!==c)switch(p=v.options,null!==(y=null==p?void 0:p.scope)&&void 0!==y?y:f){case"singleton":if(u)return l;if(null==o?void 0:o.hasToken(r))break;var d=v.factory(e);return e.bindValue(r,d),d;case"scoped":var b=v.factory(i);return i.bindValue(r,b),i!==e&&i.bindFactory(r,c,v.options),b;case"transient":return v.factory(i)}if(u)return l;var m=null==o?void 0:o.get(a);return m?m(r,i):s}function v(o,t){var e=function(o){return void 0===o.scope||"scoped"===o.scope||"singleton"===o.scope?o.onRemoved:void 0}(t);if(e){var r=n.get(o);(void 0!==r||n.has(o))&&e(r)}}function d(){n.set(l.symbol,e),n.set(a.symbol,r),n.set(p.symbol,t),o&&n.set(u.symbol,o)}return d(),e},o.declareModule=w,o.declareModuleBindings=function(o){return w({factory:function(){return{}},imports:o})},o.injectable=h,o.injectableClass=function(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return h.apply(void 0,e([function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return new(o.bind.apply(o,e([void 0],n,!1)))}],n,!1))},o.isToken=v,o.optional=function(o,n){return{symbol:o.symbol,isOptional:!0,optionalValue:n}},o.resolveValue=b,o.resolveValues=m,o.token=r,o.tryResolveValue=d,o.tryResolveValues=function(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return d(o,n)}))}}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/ditox.ts","../../src/utils.ts","../../src/modules.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n",null,null,null],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","__assign","assign","t","s","i","n","arguments","length","apply","this","__spreadArray","to","from","pack","ar","l","slice","concat","token","description","symbol","Symbol","message","_super","_this","_newTarget","name","TypeError","String","__","constructor","create","__extends","Error","CONTAINER","PARENT_CONTAINER","RESOLVER","NOT_FOUND","FAKE_FACTORY","FACTORIES_MAP","isInternalToken","isToken","value","tryResolveValue","container","get","obj","keys","forEach","key","resolveValue","resolve","resolveValues","_i","tokens","map","item","injectable","factory","values","bindModule","moduleDeclaration","options","imports","beforeBinding","afterBinding","exports","scope","bindModules","exportedValueTokens","Set","valueKey","valueToken","add","bindFactory","module","onRemoved","destroy","remove","clear","modules","entry","declareModule","declaration","nextValues","bindValue","parentContainer","Map","factories","set","executeOnRemoved","delete","removeAll","context","tokenSymbol","bindInternalTokens","hasToken","has","resolver","isOptional","optionalValue","ResolverError","origin","hasValue","undefined","factoryContext","value_1","value_2","parentResolver","getOnRemoved"],"mappings":"6OAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOC,OAAOK,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,KACzFP,EAAcC,EAAGC,IAWrB,IAAIS,EAAW,WAQlB,OAPAA,EAAWR,OAAOS,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIR,KADTO,EAAIG,UAAUF,GACOZ,OAAOK,UAAUC,eAAeC,KAAKI,EAAGP,KAAIM,EAAEN,GAAKO,EAAEP,IAE9E,OAAOM,GAEJF,EAASQ,MAAMC,KAAMH,YA6HzB,SAASI,EAAcC,EAAIC,EAAMC,GACpC,GAA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D,IACPpC,EAAO8B,IAAIvD,EAAUd,OAAQwB,GAC7Be,EAAO8B,IAAIrD,EAAShB,OAAQ8E,GAC5BvC,EAAO8B,IAAIlD,EAAcnB,OAAQoE,GAE7BF,GACF3B,EAAO8B,IAAItD,EAAiBf,OAAQkE,GAKxC,OADAS,IACOnD,sDE1KPoC,GAEA,OAAOE,EAAc,CACnBxB,QAAS,WAAM,UACfK,QAASiB,+CDYXlD,OACA,aAAAuB,mBAAAA,IAAAC,oBAEA,OAAOG,kBACL,eAAC,aAAAJ,mBAAAA,IAAAM,kBAAc,WAAI7B,aAAAA,aAAe6B,UAC/BL,wCDrLLpC,EACAkF,GAEA,MAAO,CACLhF,OAAQF,EAAME,OACd+E,YAAY,EACZC,+GC4CFxD,OAAsB,aAAAS,mBAAAA,IAAAC,oBACtB,OAAOA,EAAOC,KAAI,SAACC,GAAS,OAAAb,EAAgBC,EAAWY"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ditox",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"description": "Dependency injection for modular web applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mikhail Nasyrov <mikhail@mnasyrov.com> (https://github.com/mnasyrov)",
|
|
7
7
|
"homepage": "https://github.com/mnasyrov/ditox",
|
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
"url": "https://github.com/mnasyrov/ditox.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
|
-
"
|
|
15
|
-
"dependency
|
|
14
|
+
"dependency container",
|
|
15
|
+
"dependency injection",
|
|
16
|
+
"typescript",
|
|
17
|
+
"javascript",
|
|
18
|
+
"npm",
|
|
16
19
|
"dependency",
|
|
17
20
|
"injection",
|
|
18
21
|
"container",
|
|
22
|
+
"module",
|
|
19
23
|
"ioc",
|
|
20
24
|
"di"
|
|
21
25
|
],
|
|
@@ -45,7 +49,8 @@
|
|
|
45
49
|
"build": "npm run build:cjs && npm run build:esm && npm run build:rollup",
|
|
46
50
|
"build:cjs": "tsc -p tsconfig.build.json --outDir dist/cjs --module commonjs",
|
|
47
51
|
"build:esm": "tsc -p tsconfig.build.json --outDir dist/esm --module es2015",
|
|
48
|
-
"build:rollup": "rollup -c"
|
|
52
|
+
"build:rollup": "rollup -c",
|
|
53
|
+
"typedoc": "typedoc"
|
|
49
54
|
},
|
|
50
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1e10e32350931dba38acc4d00b2cc1cd6d5cffb5"
|
|
51
56
|
}
|
package/src/modules.ts
CHANGED
|
@@ -66,6 +66,8 @@ export type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
66
66
|
afterBinding?: (container: Container) => void;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
export type AnyModuleDeclaration = ModuleDeclaration<Module<AnyObject>>;
|
|
70
|
+
|
|
69
71
|
/**
|
|
70
72
|
* Options for module binding.
|
|
71
73
|
*
|
|
@@ -191,7 +193,7 @@ export function bindModules(
|
|
|
191
193
|
* });
|
|
192
194
|
* ```
|
|
193
195
|
*/
|
|
194
|
-
export function declareModule<T
|
|
196
|
+
export function declareModule<T extends Module<AnyObject>>(
|
|
195
197
|
declaration: Omit<ModuleDeclaration<T>, 'token'> &
|
|
196
198
|
Partial<Pick<ModuleDeclaration<T>, 'token'>>,
|
|
197
199
|
): ModuleDeclaration<T> {
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { Container, Token } from './ditox';
|
|
2
|
-
declare type ValuesProps = {
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
};
|
|
5
|
-
declare type TokenProps<Props extends ValuesProps> = {
|
|
6
|
-
[K in keyof Props]: Token<Props[K]>;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Returns an array of resolved values by the specified token.
|
|
10
|
-
* If a token is not found, then `undefined` value is used.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Use `tryResolveValues()` function.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getValues<Tokens extends Token<unknown>[], Values extends {
|
|
15
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : never;
|
|
16
|
-
}>(container: Container, ...tokens: Tokens): Values;
|
|
17
|
-
/**
|
|
18
|
-
* Returns an object with resolved properties which are specified by token properties.
|
|
19
|
-
* If a token is not found, then `undefined` value is used.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Use `tryResolveValue()` function.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const props = getProps(container, {a: tokenA, b: tokenB});
|
|
26
|
-
* console.log(props); // {a: 1, b: 2}
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare function getProps<Props extends ValuesProps>(container: Container, tokens: TokenProps<Props>): Partial<Props>;
|
|
30
|
-
/**
|
|
31
|
-
* Returns an object with resolved properties which are specified by token properties.
|
|
32
|
-
* If a token is not found, then `ResolverError` is thrown.
|
|
33
|
-
*
|
|
34
|
-
* @deprecated Use `resolveValue()` function.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```ts
|
|
38
|
-
* const props = resolveProps(container, {a: tokenA, b: tokenB});
|
|
39
|
-
* console.log(props); // {a: 1, b: 2}
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function resolveProps<Props extends ValuesProps>(container: Container, tokens: TokenProps<Props>): Props;
|
|
43
|
-
/**
|
|
44
|
-
* Decorates a factory by passing a resolved object with tokens as the first argument.
|
|
45
|
-
* @param factory - A factory.
|
|
46
|
-
* @param tokens - Object with tokens.
|
|
47
|
-
* @return Decorated factory which takes a dependency container as a single argument.
|
|
48
|
-
*
|
|
49
|
-
* @deprecated Use `injectable()` function.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* const factory = ({a, b}: {a: number, b: number}) => a + b;
|
|
54
|
-
* const decoratedFactory = injectableProps(factory, {a: tokenA, b: tokenB});
|
|
55
|
-
* const result = decoratedFactory(container);
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function injectableProps<Props extends ValuesProps, Result>(factory: (props: Props) => Result, tokens: TokenProps<Props>): (container: Container) => Result;
|
|
59
|
-
export {};
|