ditox 1.4.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/{index.d.ts → browser/index.d.ts} +98 -42
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/cjs/ditox.d.ts +125 -0
- package/dist/cjs/ditox.js +210 -0
- package/dist/cjs/ditox.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules.d.ts +118 -0
- package/dist/cjs/modules.js +109 -0
- package/dist/cjs/modules.js.map +1 -0
- package/dist/cjs/utils-deprecated.d.ts +59 -0
- package/dist/cjs/utils-deprecated.js +66 -0
- package/dist/cjs/utils-deprecated.js.map +1 -0
- package/dist/cjs/utils.d.ts +136 -0
- package/dist/cjs/utils.js +156 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/ditox.d.ts +125 -0
- package/{lib/index.js → dist/esm/ditox.js} +10 -201
- package/dist/esm/ditox.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules.d.ts +118 -0
- package/dist/esm/modules.js +102 -0
- package/dist/esm/modules.js.map +1 -0
- package/dist/esm/utils-deprecated.d.ts +59 -0
- package/dist/esm/utils-deprecated.js +59 -0
- package/dist/esm/utils-deprecated.js.map +1 -0
- package/dist/esm/utils.d.ts +136 -0
- package/dist/esm/utils.js +145 -0
- package/dist/esm/utils.js.map +1 -0
- package/{lib → dist/umd}/index.d.ts +98 -42
- package/dist/umd/index.js +2 -0
- package/dist/umd/index.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +250 -164
- package/docs/classes/{resolvererror.md → ResolverError.md} +14 -12
- package/package.json +15 -16
- package/src/ditox.test.ts +10 -1
- package/src/index.ts +13 -13
- package/src/modules.test.ts +2 -0
- package/src/modules.ts +1 -8
- package/src/utils.test.ts +173 -58
- package/src/utils.ts +164 -66
- package/CHANGELOG.md +0 -121
- package/dist/index.browser.js +0 -2
- package/dist/index.browser.js.flow +0 -4
- package/dist/index.browser.js.map +0 -1
- package/dist/index.js +0 -411
- package/dist/index.js.flow +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index.module.d.ts +0 -301
- package/dist/index.module.js +0 -393
- package/dist/index.module.js.flow +0 -4
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.d.ts +0 -301
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.flow +0 -4
- package/dist/index.umd.js.map +0 -1
- package/lib/index.js.flow +0 -4
- package/lib/index.js.map +0 -1
- package/mod.ts +0 -2
- package/src/ditox.js.flow +0 -131
- package/src/index.js.flow +0 -34
- package/src/modules.js.flow +0 -156
- package/src/utils.js.flow +0 -113
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Powerful dependency injection container for building modular apps.
|
|
|
34
34
|
- Scoped containers
|
|
35
35
|
- Dependency modules
|
|
36
36
|
- Multi-value tokens
|
|
37
|
-
- Typescript
|
|
37
|
+
- Typescript typings
|
|
38
38
|
- Supports Node.js, Deno and browsers
|
|
39
39
|
|
|
40
40
|
## Installation
|
|
@@ -119,7 +119,8 @@ container.bindFactory(
|
|
|
119
119
|
// A factory can have `transient` lifetime to create a value on each resolving.
|
|
120
120
|
container.bindFactory(TOKENS.Logger, createLogger, {scope: 'transient'});
|
|
121
121
|
|
|
122
|
-
//
|
|
122
|
+
// A class can be injected by `injectableClass()` which calls its constructor
|
|
123
|
+
// with injected dependencies as arguments.
|
|
123
124
|
container.bindFactory(
|
|
124
125
|
TOKENS.UserService,
|
|
125
126
|
injectable(
|
|
@@ -194,7 +195,7 @@ const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
|
194
195
|
|
|
195
196
|
const parent = createContainer();
|
|
196
197
|
parent.bindValue(TAG, 'parent');
|
|
197
|
-
parent.bindFactory(LOGGER, injectable(createLogger, TAG, {scope: 'singleton'})
|
|
198
|
+
parent.bindFactory(LOGGER, injectable(createLogger, TAG), {scope: 'singleton'});
|
|
198
199
|
|
|
199
200
|
const container1 = createContainer(parent);
|
|
200
201
|
container1.bindValue(TAG, 'container1');
|
|
@@ -221,7 +222,7 @@ const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
|
221
222
|
|
|
222
223
|
const parent = createContainer();
|
|
223
224
|
// `scoped` is default scope and can be omitted.
|
|
224
|
-
parent.bindFactory(LOGGER, injectable(createLogger, TAG, {scope: 'scoped'})
|
|
225
|
+
parent.bindFactory(LOGGER, injectable(createLogger, TAG), {scope: 'scoped'});
|
|
225
226
|
|
|
226
227
|
const container1 = createContainer(parent);
|
|
227
228
|
container1.bindValue(TAG, 'container1');
|
|
@@ -251,7 +252,7 @@ const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
|
251
252
|
|
|
252
253
|
const parent = createContainer();
|
|
253
254
|
parent.bindValue(TAG, 'parent');
|
|
254
|
-
parent.bindFactory(LOGGER, injectable(createLogger, TAG, {scope: 'singleton'})
|
|
255
|
+
parent.bindFactory(LOGGER, injectable(createLogger, TAG), {scope: 'singleton'});
|
|
255
256
|
|
|
256
257
|
const container1 = createContainer(parent);
|
|
257
258
|
container1.bindValue(TAG, 'container1');
|
|
@@ -108,72 +108,134 @@ declare type ValuesProps = {
|
|
|
108
108
|
declare type TokenProps<Props extends ValuesProps> = {
|
|
109
109
|
[K in keyof Props]: Token<Props[K]>;
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Checks if a value is the token
|
|
113
|
+
*/
|
|
114
|
+
declare function isToken<T>(value: unknown): value is Token<T>;
|
|
111
115
|
/**
|
|
112
116
|
* Rebinds the array by the token with added new value.
|
|
113
117
|
* @param container - Dependency container.
|
|
114
118
|
* @param token - Token for an array of values.
|
|
115
119
|
* @param value - New value which is added to the end of the array.
|
|
116
120
|
*/
|
|
117
|
-
declare function bindMultiValue<T>(container: Container, token: Token<
|
|
121
|
+
declare function bindMultiValue<T>(container: Container, token: Token<ReadonlyArray<T>>, value: T): void;
|
|
118
122
|
/**
|
|
119
|
-
*
|
|
123
|
+
* Tries to resolve a value by the provided token.
|
|
124
|
+
*
|
|
125
|
+
* If an argument is an object which has tokens as its properties,
|
|
126
|
+
* then returns an object containing resolved values as properties.
|
|
127
|
+
|
|
120
128
|
* If a token is not found, then `undefined` value is used.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const value = tryResolveValue(container, tokenA);
|
|
133
|
+
* console.log(value); // 1
|
|
134
|
+
*
|
|
135
|
+
* const props = tryResolveValue(container, {a: tokenA, b: tokenB});
|
|
136
|
+
* console.log(props); // {a: 1, b: 2}
|
|
137
|
+
* ```
|
|
121
138
|
*/
|
|
122
|
-
declare function
|
|
123
|
-
[
|
|
124
|
-
}>(container: Container,
|
|
139
|
+
declare function tryResolveValue<Tokens extends Token<unknown> | {
|
|
140
|
+
[key: string]: Token<unknown>;
|
|
141
|
+
}, Values extends Tokens extends Token<infer V> ? V | undefined : Tokens extends TokenProps<infer Props> ? Partial<Props> : never>(container: Container, token: Tokens): Values;
|
|
125
142
|
/**
|
|
126
|
-
* Returns an array of resolved values
|
|
127
|
-
*
|
|
143
|
+
* Returns an array of resolved values or objects with resolved values.
|
|
144
|
+
*
|
|
145
|
+
* If an item of the array is an object which has tokens as its properties,
|
|
146
|
+
* then returns an object containing resolved values as properties.
|
|
147
|
+
|
|
148
|
+
* If a token is not found, then `undefined` value is used.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const items1 = tryResolveValues(container, tokenA);
|
|
153
|
+
* console.log(items1); // [1]
|
|
154
|
+
*
|
|
155
|
+
* const items2 = tryResolveValues(container, tokenA, {a: tokenA, b: tokenB});
|
|
156
|
+
* console.log(items2); // [1, {a: 1, b: 2}]
|
|
157
|
+
* ```
|
|
128
158
|
*/
|
|
129
|
-
declare function
|
|
130
|
-
[
|
|
159
|
+
declare function tryResolveValues<Tokens extends (Token<unknown> | {
|
|
160
|
+
[key: string]: Token<unknown>;
|
|
161
|
+
})[], Values extends {
|
|
162
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V | undefined : Tokens[K] extends TokenProps<infer Props> ? Partial<Props> : never;
|
|
131
163
|
}>(container: Container, ...tokens: Tokens): Values;
|
|
132
164
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : never;
|
|
140
|
-
}, Result>(this: unknown, factory: (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
141
|
-
/**
|
|
142
|
-
* Returns an object with resolved properties which are specified by token properties.
|
|
143
|
-
* If a token is not found, then `undefined` value is used.
|
|
165
|
+
* Resolves a value by the provided token.
|
|
166
|
+
*
|
|
167
|
+
* If an argument is an object which has tokens as its properties,
|
|
168
|
+
* then returns an object containing resolved values as properties.
|
|
169
|
+
|
|
170
|
+
* If a value is not found by the token, then `ResolverError` is thrown.
|
|
144
171
|
*
|
|
145
172
|
* @example
|
|
146
173
|
* ```ts
|
|
147
|
-
* const
|
|
174
|
+
* const value = resolveValue(container, tokenA);
|
|
175
|
+
* console.log(value); // 1
|
|
176
|
+
*
|
|
177
|
+
* const props = resolveValue(container, {a: tokenA, b: tokenB});
|
|
148
178
|
* console.log(props); // {a: 1, b: 2}
|
|
149
179
|
* ```
|
|
150
180
|
*/
|
|
151
|
-
declare function
|
|
181
|
+
declare function resolveValue<Tokens extends Token<unknown> | {
|
|
182
|
+
[key: string]: Token<unknown>;
|
|
183
|
+
}, Values extends Tokens extends Token<infer V> ? V : Tokens extends TokenProps<infer Props> ? Props : never>(container: Container, token: Tokens): Values;
|
|
152
184
|
/**
|
|
153
|
-
* Returns an
|
|
185
|
+
* Returns an array of resolved values or objects with resolved values.
|
|
186
|
+
*
|
|
187
|
+
* If an item of the array is an object which has tokens as its properties,
|
|
188
|
+
* then returns an object containing resolved values as properties.
|
|
189
|
+
|
|
154
190
|
* If a token is not found, then `ResolverError` is thrown.
|
|
155
191
|
*
|
|
156
192
|
* @example
|
|
157
193
|
* ```ts
|
|
158
|
-
* const
|
|
159
|
-
* console.log(
|
|
194
|
+
* const items1 = resolveValues(container, tokenA);
|
|
195
|
+
* console.log(items1); // [1]
|
|
196
|
+
*
|
|
197
|
+
* const items2 = resolveValues(container, tokenA, {a: tokenA, b: tokenB});
|
|
198
|
+
* console.log(items2); // [1, {a: 1, b: 2}]
|
|
160
199
|
* ```
|
|
161
200
|
*/
|
|
162
|
-
declare function
|
|
201
|
+
declare function resolveValues<Tokens extends (Token<unknown> | {
|
|
202
|
+
[key: string]: Token<unknown>;
|
|
203
|
+
})[], Values extends {
|
|
204
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
205
|
+
}>(container: Container, ...tokens: Tokens): Values;
|
|
163
206
|
/**
|
|
164
|
-
* Decorates a factory by passing
|
|
207
|
+
* Decorates a factory by passing resolved values as factory arguments.
|
|
208
|
+
*
|
|
209
|
+
* If an argument is an object which has tokens as its properties,
|
|
210
|
+
* then returns an object containing resolved values as properties.
|
|
211
|
+
*
|
|
165
212
|
* @param factory - A factory.
|
|
166
|
-
* @param tokens -
|
|
213
|
+
* @param tokens - Tokens which correspond to factory arguments.
|
|
214
|
+
*
|
|
167
215
|
* @return Decorated factory which takes a dependency container as a single argument.
|
|
216
|
+
*/
|
|
217
|
+
declare function injectable<Tokens extends (Token<unknown> | {
|
|
218
|
+
[key: string]: Token<unknown>;
|
|
219
|
+
})[], Values extends {
|
|
220
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
221
|
+
}, Result>(this: unknown, factory: (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
222
|
+
/**
|
|
223
|
+
* Decorates a class by passing resolved values as arguments to its constructor.
|
|
168
224
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
225
|
+
* If an argument is an object which has tokens as its properties,
|
|
226
|
+
* then returns an object containing resolved values as properties.
|
|
227
|
+
*
|
|
228
|
+
* @param constructor - Constructor of a class
|
|
229
|
+
* @param tokens - Tokens which correspond to constructor arguments
|
|
230
|
+
*
|
|
231
|
+
* @return A factory function which takes a dependency container as a single argument
|
|
232
|
+
* and returns a new created class.
|
|
175
233
|
*/
|
|
176
|
-
declare function
|
|
234
|
+
declare function injectableClass<Tokens extends (Token<unknown> | {
|
|
235
|
+
[key: string]: Token<unknown>;
|
|
236
|
+
})[], Values extends {
|
|
237
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
238
|
+
}, Result>(this: unknown, constructor: new (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
177
239
|
|
|
178
240
|
declare type AnyObject = Record<string, any>;
|
|
179
241
|
declare type EmptyObject = Record<string, never>;
|
|
@@ -224,12 +286,6 @@ declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
224
286
|
exports?: {
|
|
225
287
|
[K in keyof GetModuleProps<T>]?: Token<GetModuleProps<T>[K]>;
|
|
226
288
|
};
|
|
227
|
-
/**
|
|
228
|
-
* Dictionary of module properties which are bound to tokens.
|
|
229
|
-
*
|
|
230
|
-
* @deprecated Use `exports` property.
|
|
231
|
-
*/
|
|
232
|
-
exportedProps?: ModuleDeclaration<T>['exports'];
|
|
233
289
|
/** Callback could be used to prepare an environment. It is called before binding the module. */
|
|
234
290
|
beforeBinding?: (container: Container) => void;
|
|
235
291
|
/** Callback could be used to export complex dependencies from the module. It is called after binding the module. */
|
|
@@ -298,4 +354,4 @@ declare function declareModule<T>(declaration: Omit<ModuleDeclaration<T>, 'token
|
|
|
298
354
|
*/
|
|
299
355
|
declare function declareModuleBindings(modules: ReadonlyArray<ModuleBindingEntry>): ModuleDeclaration<Module>;
|
|
300
356
|
|
|
301
|
-
export { BindModuleOptions, Container, FactoryOptions, FactoryScope, Module, ModuleBindingEntry, ModuleDeclaration, OptionalToken, RequiredToken, ResolverError, Token, bindModule, bindModules, bindMultiValue, createContainer, declareModule, declareModuleBindings,
|
|
357
|
+
export { BindModuleOptions, Container, FactoryOptions, FactoryScope, Module, ModuleBindingEntry, ModuleDeclaration, OptionalToken, RequiredToken, ResolverError, Token, bindModule, bindModules, bindMultiValue, createContainer, declareModule, declareModuleBindings, injectable, injectableClass, isToken, optional, resolveValue, resolveValues, token, tryResolveValue, tryResolveValues };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o=function(n,t){return o=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])},o(n,t)};var n=function(){return n=Object.assign||function(o){for(var n,t=1,r=arguments.length;t<r;t++)for(var e in n=arguments[t])Object.prototype.hasOwnProperty.call(n,e)&&(o[e]=n[e]);return o},n.apply(this,arguments)};function t(o,n,t){if(t||2===arguments.length)for(var r,e=0,i=n.length;e<i;e++)!r&&e in n||(r||(r=Array.prototype.slice.call(n,0,e)),r[e]=n[e]);return o.concat(r||Array.prototype.slice.call(n))}function r(o){return{symbol:Symbol(o)}}function e(o,n){return{symbol:o.symbol,isOptional:!0,optionalValue:n}}var i=function(n){function t(o){var t=this.constructor,r=n.call(this,o)||this;return Object.setPrototypeOf(r,t.prototype),r.name="ResolverError",r}return function(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=n}o(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,n),t}(Error),u=r("ditox.Container"),l=r("ditox.ParentContainer"),c=r("ditox.Resolver"),a=Symbol(),s=function(){throw new Error("FAKE_FACTORY")},f=r("ditox.FactoriesMap");function y(o){return o.symbol===u.symbol||o.symbol===l.symbol||o.symbol===c.symbol}function p(o){var n=new Map,t=new Map,r={bindValue:function(o,t){y(o)||n.set(o.symbol,t)},bindFactory:function(o,n,r){y(o)||t.set(o.symbol,{factory:n,options:r})},remove:function(o){var r;if(!y(o)){var e=null===(r=t.get(o.symbol))||void 0===r?void 0:r.options;e&&p(o.symbol,e),n.delete(o.symbol),t.delete(o.symbol)}},removeAll:function(){t.forEach((function(o,n){o.options&&p(n,o.options)})),n.clear(),t.clear(),v()},hasToken:function(r){var e;return n.has(r.symbol)||t.has(r.symbol)||null!==(e=null==o?void 0:o.hasToken(r))&&void 0!==e&&e},get:function(o){var n=e(o,r);return n!==a?n:o.isOptional?o.optionalValue:void 0},resolve:function(o){var n,t=e(o,r);if(t!==a)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 e(e,i){var u=n.get(e.symbol),l=void 0!==u||n.has(e.symbol);if(l&&i===r)return u;var f,y,p=t.get(e.symbol);if(p&&p.factory!==s)switch(f=p.options,null!==(y=null==f?void 0:f.scope)&&void 0!==y?y:"singleton"){case"singleton":if(l)return u;if(null==o?void 0:o.hasToken(e))break;var v=p.factory(r);return r.bindValue(e,v),v;case"scoped":var b=p.factory(i);return i.bindValue(e,b),i!==r&&i.bindFactory(e,s,p.options),b;case"transient":return p.factory(i)}if(l)return u;var d=null==o?void 0:o.get(c);return d?d(e,i):a}function p(o,t){var r=function(o){return void 0===o.scope||"scoped"===o.scope||"singleton"===o.scope?o.onRemoved:void 0}(t);if(r){var e=n.get(o);(void 0!==e||n.has(o))&&r(e)}}function v(){n.set(u.symbol,r),n.set(c.symbol,e),n.set(f.symbol,t),o&&n.set(l.symbol,o)}return v(),r}function v(o){return null!=o&&"object"==typeof o&&"symbol"in o&&"symbol"==typeof o.symbol}function b(o,n,r){var e,i=t(t([],null!==(e=o.get(n))&&void 0!==e?e:[],!0),[r],!1);o.bindValue(n,i)}function d(o,n){if(v(n))return o.get(n);var t={};return Object.keys(n).forEach((function(r){return t[r]=o.get(n[r])})),t}function m(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return d(o,n)}))}function h(o,n){if(v(n))return o.resolve(n);var t={};return Object.keys(n).forEach((function(r){return t[r]=o.resolve(n[r])})),t}function g(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return h(o,n)}))}function O(o){for(var n=this,r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return function(e){var i=g.apply(void 0,t([e],r,!1));return o.apply(n,i)}}function w(o){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return O.apply(void 0,t([function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new(o.bind.apply(o,t([void 0],n,!1)))}],n,!1))}function k(o,n,t){var r=n.token,e=n.imports,i=n.factory,u=n.beforeBinding,l=n.afterBinding,c=n.exports,a=null==t?void 0:t.scope;u&&u(o),e&&E(o,e);var s=new Set;c&&Object.keys(c).forEach((function(n){var t=c[n];t&&(s.add(t),o.bindFactory(t,O((function(o){return o[n]}),r),{scope:a}))}));o.bindFactory(r,i,{scope:a,onRemoved:function(n){n.destroy&&n.destroy(),s.forEach((function(n){return o.remove(n)})),s.clear()}}),l&&l(o)}function E(o,n){n.forEach((function(n){"module"in n?k(o,n.module,n.options):k(o,n)}))}function j(o){var t;return n(n({},o),{token:null!==(t=o.token)&&void 0!==t?t:r()})}function _(o){return j({factory:function(){return{}},imports:o})}export{i as ResolverError,k as bindModule,E as bindModules,b as bindMultiValue,p as createContainer,j as declareModule,_ as declareModuleBindings,O as injectable,w as injectableClass,v as isToken,e as optional,h as resolveValue,g as resolveValues,r as token,d as tryResolveValue,m as tryResolveValues};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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","optional","optionalValue","isOptional","message","_super","_this","_newTarget","name","TypeError","String","__","constructor","create","__extends","Error","CONTAINER","PARENT_CONTAINER","RESOLVER","NOT_FOUND","FAKE_FACTORY","FACTORIES_MAP","isInternalToken","createContainer","parentContainer","values","Map","factories","container","bindValue","value","set","bindFactory","factory","options","remove","get","executeOnRemoved","delete","removeAll","forEach","context","tokenSymbol","clear","bindInternalTokens","hasToken","has","resolver","resolve","ResolverError","origin","hasValue","undefined","factoryContext","scope","value_1","value_2","parentResolver","onRemoved","getOnRemoved","isToken","bindMultiValue","nextValues","tryResolveValue","obj","keys","key","tryResolveValues","_i","tokens","map","item","resolveValue","resolveValues","injectable","injectableClass","bindModule","moduleDeclaration","imports","beforeBinding","afterBinding","exports","bindModules","exportedValueTokens","Set","valueKey","valueToken","add","module","destroy","modules","entry","declareModule","declaration","declareModuleBindings"],"mappings":"AAgBA,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,GAAIA,GAA6B,IAArBP,UAAUC,OAAc,IAAK,IAA4BO,EAAxBV,EAAI,EAAGW,EAAIH,EAAKL,OAAYH,EAAIW,EAAGX,KACxEU,GAAQV,KAAKQ,IACRE,IAAIA,EAAKnB,MAAME,UAAUmB,MAAMjB,KAAKa,EAAM,EAAGR,IAClDU,EAAGV,GAAKQ,EAAKR,IAGrB,OAAOO,EAAGM,OAAOH,GAAMnB,MAAME,UAAUmB,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mD,MAC7DH,EAAoBxC,WAIpBqC,GACFA,EAAapD,YAUDsD,EACdtD,EACA8D,GAEAA,EAAQlD,SAAQ,SAACmD,GACX,WAAYA,EACdf,EAAWhD,EAAW+D,EAAMH,OAAQG,EAAMzD,SAE1C0C,EAAWhD,EAAW+D,eA2BZC,EACdC,SAGA,cAAWA,IAAahG,gBAAOgG,EAAYhG,qBAASA,eAQtCiG,EACdJ,GAEA,OAAOE,EAAc,CACnB3D,QAAS,WAAM,UACf6C,QAASY"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
* Binding token for mandatory value
|
|
4
|
+
*/
|
|
5
|
+
export declare type RequiredToken<T> = {
|
|
6
|
+
symbol: symbol;
|
|
7
|
+
type?: T;
|
|
8
|
+
isOptional?: false;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
* Binding token for optional value
|
|
13
|
+
*/
|
|
14
|
+
export declare type OptionalToken<T> = {
|
|
15
|
+
symbol: symbol;
|
|
16
|
+
type?: T;
|
|
17
|
+
isOptional: true;
|
|
18
|
+
optionalValue: T;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Binding token.
|
|
22
|
+
*/
|
|
23
|
+
export declare type Token<T> = RequiredToken<T> | OptionalToken<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new binding token.
|
|
26
|
+
* @param description - Token description for better error messages.
|
|
27
|
+
*/
|
|
28
|
+
export declare function token<T>(description?: string): Token<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Decorate a token with an optional value.
|
|
31
|
+
* This value is be used as default value in case a container does not have registered token.
|
|
32
|
+
* @param token - Existed token.
|
|
33
|
+
* @param optionalValue - Default value for the resolver.
|
|
34
|
+
*/
|
|
35
|
+
export declare function optional<T>(token: Token<T>, optionalValue: T): OptionalToken<T>;
|
|
36
|
+
export declare function optional<T>(token: Token<T>): OptionalToken<T | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* ResolverError is thrown by the resolver when a token is not found in a container.
|
|
39
|
+
*/
|
|
40
|
+
export declare class ResolverError extends Error {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @see https://github.com/mnasyrov/ditox#factory-lifetimes
|
|
45
|
+
*/
|
|
46
|
+
export declare type FactoryScope = 'scoped' | 'singleton' | 'transient';
|
|
47
|
+
/**
|
|
48
|
+
* Options for factory binding.
|
|
49
|
+
*
|
|
50
|
+
* `scope` types:
|
|
51
|
+
* - `singleton` - **This is the default**. The value is created and cached by the container which registered the factory.
|
|
52
|
+
* - `scoped` - The value is created and cached by the container which starts resolving.
|
|
53
|
+
* - `transient` - The value is created every time it is resolved.
|
|
54
|
+
*
|
|
55
|
+
* `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container.
|
|
56
|
+
*/
|
|
57
|
+
export declare type FactoryOptions<T> = {
|
|
58
|
+
scope?: 'scoped' | 'singleton';
|
|
59
|
+
onRemoved?: (value: T) => void;
|
|
60
|
+
} | {
|
|
61
|
+
scope: 'transient';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Dependency container.
|
|
65
|
+
*/
|
|
66
|
+
export declare type Container = {
|
|
67
|
+
/**
|
|
68
|
+
* Binds a value for the token
|
|
69
|
+
*/
|
|
70
|
+
bindValue<T>(token: Token<T>, value: T): void;
|
|
71
|
+
/**
|
|
72
|
+
* Binds a factory for the token.
|
|
73
|
+
*/
|
|
74
|
+
bindFactory<T>(token: Token<T>, factory: (container: Container) => T, options?: FactoryOptions<T>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the token is registered in the container hierarchy.
|
|
77
|
+
*/
|
|
78
|
+
hasToken(token: Token<unknown>): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a resolved value by the token, or returns `undefined` in case the token is not found.
|
|
81
|
+
*/
|
|
82
|
+
get<T>(token: Token<T>): T | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Returns a resolved value by the token, or throws `ResolverError` in case the token is not found.
|
|
85
|
+
*/
|
|
86
|
+
resolve<T>(token: Token<T>): T;
|
|
87
|
+
/**
|
|
88
|
+
* Removes a binding for the token.
|
|
89
|
+
*/
|
|
90
|
+
remove<T>(token: Token<T>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Removes all bindings in the container.
|
|
93
|
+
*/
|
|
94
|
+
removeAll(): void;
|
|
95
|
+
};
|
|
96
|
+
/** @internal */
|
|
97
|
+
export declare const CONTAINER: Token<Container>;
|
|
98
|
+
/** @internal */
|
|
99
|
+
export declare const PARENT_CONTAINER: Token<Container>;
|
|
100
|
+
/** @internal */
|
|
101
|
+
export declare const RESOLVER: Token<Resolver>;
|
|
102
|
+
/** @internal */
|
|
103
|
+
declare const NOT_FOUND: unique symbol;
|
|
104
|
+
/** @internal */
|
|
105
|
+
export declare const FAKE_FACTORY: () => never;
|
|
106
|
+
/** @internal */
|
|
107
|
+
declare type FactoryContext<T> = {
|
|
108
|
+
factory: (container: Container) => T;
|
|
109
|
+
options?: FactoryOptions<T>;
|
|
110
|
+
};
|
|
111
|
+
/** @internal */
|
|
112
|
+
export declare type FactoriesMap = Map<symbol, FactoryContext<any>>;
|
|
113
|
+
/** @internal */
|
|
114
|
+
export declare const FACTORIES_MAP: Token<FactoriesMap>;
|
|
115
|
+
/** @internal */
|
|
116
|
+
declare type Resolver = <T>(token: Token<T>, origin: Container) => T | typeof NOT_FOUND;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new dependency container.
|
|
119
|
+
*
|
|
120
|
+
* Container can have an optional parent to chain token resolution. The parent is used in case the current container does not have a registered token.
|
|
121
|
+
*
|
|
122
|
+
* @param parentContainer - Optional parent container.
|
|
123
|
+
*/
|
|
124
|
+
export declare function createContainer(parentContainer?: Container): Container;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContainer = exports.FACTORIES_MAP = exports.FAKE_FACTORY = exports.RESOLVER = exports.PARENT_CONTAINER = exports.CONTAINER = exports.ResolverError = exports.optional = exports.token = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new binding token.
|
|
6
|
+
* @param description - Token description for better error messages.
|
|
7
|
+
*/
|
|
8
|
+
function token(description) {
|
|
9
|
+
return { symbol: Symbol(description) };
|
|
10
|
+
}
|
|
11
|
+
exports.token = token;
|
|
12
|
+
function optional(token, optionalValue) {
|
|
13
|
+
return {
|
|
14
|
+
symbol: token.symbol,
|
|
15
|
+
isOptional: true,
|
|
16
|
+
optionalValue,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.optional = optional;
|
|
20
|
+
/**
|
|
21
|
+
* ResolverError is thrown by the resolver when a token is not found in a container.
|
|
22
|
+
*/
|
|
23
|
+
class ResolverError extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
27
|
+
this.name = 'ResolverError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ResolverError = ResolverError;
|
|
31
|
+
/** @internal */
|
|
32
|
+
exports.CONTAINER = token('ditox.Container');
|
|
33
|
+
/** @internal */
|
|
34
|
+
exports.PARENT_CONTAINER = token('ditox.ParentContainer');
|
|
35
|
+
/** @internal */
|
|
36
|
+
exports.RESOLVER = token('ditox.Resolver');
|
|
37
|
+
/** @internal */
|
|
38
|
+
const NOT_FOUND = Symbol();
|
|
39
|
+
/** @internal */
|
|
40
|
+
const FAKE_FACTORY = () => {
|
|
41
|
+
throw new Error('FAKE_FACTORY');
|
|
42
|
+
};
|
|
43
|
+
exports.FAKE_FACTORY = FAKE_FACTORY;
|
|
44
|
+
/** @internal */
|
|
45
|
+
const DEFAULT_SCOPE = 'singleton';
|
|
46
|
+
/** @internal */
|
|
47
|
+
exports.FACTORIES_MAP = token('ditox.FactoriesMap');
|
|
48
|
+
/** @internal */
|
|
49
|
+
function getScope(options) {
|
|
50
|
+
var _a;
|
|
51
|
+
return (_a = options === null || options === void 0 ? void 0 : options.scope) !== null && _a !== void 0 ? _a : DEFAULT_SCOPE;
|
|
52
|
+
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
function getOnRemoved(options) {
|
|
55
|
+
return options.scope === undefined ||
|
|
56
|
+
options.scope === 'scoped' ||
|
|
57
|
+
options.scope === 'singleton'
|
|
58
|
+
? options.onRemoved
|
|
59
|
+
: undefined;
|
|
60
|
+
}
|
|
61
|
+
/** @internal */
|
|
62
|
+
function isInternalToken(token) {
|
|
63
|
+
return (token.symbol === exports.CONTAINER.symbol ||
|
|
64
|
+
token.symbol === exports.PARENT_CONTAINER.symbol ||
|
|
65
|
+
token.symbol === exports.RESOLVER.symbol);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new dependency container.
|
|
69
|
+
*
|
|
70
|
+
* Container can have an optional parent to chain token resolution. The parent is used in case the current container does not have a registered token.
|
|
71
|
+
*
|
|
72
|
+
* @param parentContainer - Optional parent container.
|
|
73
|
+
*/
|
|
74
|
+
function createContainer(parentContainer) {
|
|
75
|
+
const values = new Map();
|
|
76
|
+
const factories = new Map();
|
|
77
|
+
const container = {
|
|
78
|
+
bindValue(token, value) {
|
|
79
|
+
if (isInternalToken(token)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
values.set(token.symbol, value);
|
|
83
|
+
},
|
|
84
|
+
bindFactory(token, factory, options) {
|
|
85
|
+
if (isInternalToken(token)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
factories.set(token.symbol, { factory, options });
|
|
89
|
+
},
|
|
90
|
+
remove(token) {
|
|
91
|
+
var _a;
|
|
92
|
+
if (isInternalToken(token)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const options = (_a = factories.get(token.symbol)) === null || _a === void 0 ? void 0 : _a.options;
|
|
96
|
+
if (options) {
|
|
97
|
+
executeOnRemoved(token.symbol, options);
|
|
98
|
+
}
|
|
99
|
+
values.delete(token.symbol);
|
|
100
|
+
factories.delete(token.symbol);
|
|
101
|
+
},
|
|
102
|
+
removeAll() {
|
|
103
|
+
factories.forEach((context, tokenSymbol) => {
|
|
104
|
+
if (context.options) {
|
|
105
|
+
executeOnRemoved(tokenSymbol, context.options);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
values.clear();
|
|
109
|
+
factories.clear();
|
|
110
|
+
bindInternalTokens();
|
|
111
|
+
},
|
|
112
|
+
hasToken(token) {
|
|
113
|
+
var _a;
|
|
114
|
+
return (values.has(token.symbol) ||
|
|
115
|
+
factories.has(token.symbol) ||
|
|
116
|
+
((_a = parentContainer === null || parentContainer === void 0 ? void 0 : parentContainer.hasToken(token)) !== null && _a !== void 0 ? _a : false));
|
|
117
|
+
},
|
|
118
|
+
get(token) {
|
|
119
|
+
const value = resolver(token, container);
|
|
120
|
+
if (value !== NOT_FOUND) {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
if (token.isOptional) {
|
|
124
|
+
return token.optionalValue;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
},
|
|
128
|
+
resolve(token) {
|
|
129
|
+
var _a;
|
|
130
|
+
const value = resolver(token, container);
|
|
131
|
+
if (value !== NOT_FOUND) {
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
if (token.isOptional) {
|
|
135
|
+
return token.optionalValue;
|
|
136
|
+
}
|
|
137
|
+
throw new ResolverError(`Token "${(_a = token.symbol.description) !== null && _a !== void 0 ? _a : ''}" is not provided`);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
function resolver(token, origin) {
|
|
141
|
+
const value = values.get(token.symbol);
|
|
142
|
+
const hasValue = value !== undefined || values.has(token.symbol);
|
|
143
|
+
if (hasValue && origin === container) {
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
const factoryContext = factories.get(token.symbol);
|
|
147
|
+
if (factoryContext && factoryContext.factory !== exports.FAKE_FACTORY) {
|
|
148
|
+
const scope = getScope(factoryContext.options);
|
|
149
|
+
switch (scope) {
|
|
150
|
+
case 'singleton': {
|
|
151
|
+
if (hasValue) {
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
else if (parentContainer === null || parentContainer === void 0 ? void 0 : parentContainer.hasToken(token)) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Cache the value in the same container where the factory is registered.
|
|
159
|
+
const value = factoryContext.factory(container);
|
|
160
|
+
container.bindValue(token, value);
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
case 'scoped': {
|
|
165
|
+
// Create a value within the origin container and cache it.
|
|
166
|
+
const value = factoryContext.factory(origin);
|
|
167
|
+
origin.bindValue(token, value);
|
|
168
|
+
if (origin !== container) {
|
|
169
|
+
// Bind a fake factory with actual options to make onRemoved() works.
|
|
170
|
+
origin.bindFactory(token, exports.FAKE_FACTORY, factoryContext.options);
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
case 'transient': {
|
|
175
|
+
// Create a value within the origin container and don't cache it.
|
|
176
|
+
return factoryContext.factory(origin);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (hasValue) {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
const parentResolver = parentContainer === null || parentContainer === void 0 ? void 0 : parentContainer.get(exports.RESOLVER);
|
|
184
|
+
if (parentResolver) {
|
|
185
|
+
return parentResolver(token, origin);
|
|
186
|
+
}
|
|
187
|
+
return NOT_FOUND;
|
|
188
|
+
}
|
|
189
|
+
function executeOnRemoved(tokenSymbol, options) {
|
|
190
|
+
const onRemoved = getOnRemoved(options);
|
|
191
|
+
if (onRemoved) {
|
|
192
|
+
const value = values.get(tokenSymbol);
|
|
193
|
+
if (value !== undefined || values.has(tokenSymbol)) {
|
|
194
|
+
onRemoved(value);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function bindInternalTokens() {
|
|
199
|
+
values.set(exports.CONTAINER.symbol, container);
|
|
200
|
+
values.set(exports.RESOLVER.symbol, resolver);
|
|
201
|
+
values.set(exports.FACTORIES_MAP.symbol, factories);
|
|
202
|
+
if (parentContainer) {
|
|
203
|
+
values.set(exports.PARENT_CONTAINER.symbol, parentContainer);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
bindInternalTokens();
|
|
207
|
+
return container;
|
|
208
|
+
}
|
|
209
|
+
exports.createContainer = createContainer;
|
|
210
|
+
//# sourceMappingURL=ditox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ditox.js","sourceRoot":"","sources":["../../src/ditox.ts"],"names":[],"mappings":";;;AA0BA;;;GAGG;AACH,SAAgB,KAAK,CAAI,WAAoB;IAC3C,OAAO,EAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,EAAC,CAAC;AACvC,CAAC;AAFD,sBAEC;AAaD,SAAgB,QAAQ,CACtB,KAAe,EACf,aAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,UAAU,EAAE,IAAI;QAChB,aAAa;KACd,CAAC;AACJ,CAAC;AATD,4BASC;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAND,sCAMC;AAsED,gBAAgB;AACH,QAAA,SAAS,GAAqB,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACpE,gBAAgB;AACH,QAAA,gBAAgB,GAA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WAAmB,EACnB,OAA0B;QAE1B,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE;YACb,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACtC,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;gBAClD,SAAS,CAAC,KAAK,CAAC,CAAC;aAClB;SACF;IACH,CAAC;IAED,SAAS,kBAAkB;QACzB,MAAM,CAAC,GAAG,CAAC,iBAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,gBAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,qBAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAE5C,IAAI,eAAe,EAAE;YACnB,MAAM,CAAC,GAAG,CAAC,wBAAgB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;SACtD;IACH,CAAC;IAED,kBAAkB,EAAE,CAAC;IACrB,OAAO,SAAS,CAAC;AACnB,CAAC;AA9KD,0CA8KC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { token, optional, ResolverError, createContainer } from './ditox';
|
|
2
|
+
export type { RequiredToken, OptionalToken, Token, FactoryScope, FactoryOptions, Container, } from './ditox';
|
|
3
|
+
export { isToken, bindMultiValue, tryResolveValue, tryResolveValues, resolveValue, resolveValues, injectable, injectableClass, } from './utils';
|
|
4
|
+
export { bindModule, bindModules, declareModule, declareModuleBindings, } from './modules';
|
|
5
|
+
export type { Module, ModuleDeclaration, BindModuleOptions, ModuleBindingEntry, } from './modules';
|