ditox 2.1.0 → 2.3.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/dist/browser/index.d.ts +24 -88
- 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/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules.d.ts +10 -15
- package/dist/cjs/modules.js +1 -2
- 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/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules.d.ts +10 -15
- package/dist/esm/modules.js +1 -2
- package/dist/esm/modules.js.map +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/umd/index.d.ts +24 -88
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/docs/README.md +207 -388
- package/docs/classes/ResolverError.md +19 -17
- package/package.json +2 -2
- package/src/index.ts +0 -7
- package/src/modules.ts +4 -9
- 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/src/utils-deprecated.test.ts +0 -286
- package/src/utils-deprecated.ts +0 -87
package/dist/browser/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
|
/**
|
|
@@ -138,7 +138,7 @@ declare function bindMultiValue<T>(container: Container, token: Token<ReadonlyAr
|
|
|
138
138
|
*/
|
|
139
139
|
declare function tryResolveValue<Tokens extends Token<unknown> | {
|
|
140
140
|
[key: string]: Token<unknown>;
|
|
141
|
-
}, Values extends Tokens extends Token<infer V> ? V | undefined : Tokens extends TokenProps
|
|
141
|
+
}, Values extends Tokens extends Token<infer V> ? V | undefined : Tokens extends TokenProps<infer Props> ? Partial<Props> : never>(container: Container, token: Tokens): Values;
|
|
142
142
|
/**
|
|
143
143
|
* Returns an array of resolved values or objects with resolved values.
|
|
144
144
|
*
|
|
@@ -159,7 +159,7 @@ declare function tryResolveValue<Tokens extends Token<unknown> | {
|
|
|
159
159
|
declare function tryResolveValues<Tokens extends (Token<unknown> | {
|
|
160
160
|
[key: string]: Token<unknown>;
|
|
161
161
|
})[], Values extends {
|
|
162
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V | undefined : Tokens[K] extends TokenProps
|
|
162
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V | undefined : Tokens[K] extends TokenProps<infer Props> ? Partial<Props> : never;
|
|
163
163
|
}>(container: Container, ...tokens: Tokens): Values;
|
|
164
164
|
/**
|
|
165
165
|
* Resolves a value by the provided token.
|
|
@@ -180,7 +180,7 @@ declare function tryResolveValues<Tokens extends (Token<unknown> | {
|
|
|
180
180
|
*/
|
|
181
181
|
declare function resolveValue<Tokens extends Token<unknown> | {
|
|
182
182
|
[key: string]: Token<unknown>;
|
|
183
|
-
}, Values extends Tokens extends Token<infer V> ? V : Tokens extends TokenProps
|
|
183
|
+
}, Values extends Tokens extends Token<infer V> ? V : Tokens extends TokenProps<infer Props> ? Props : never>(container: Container, token: Tokens): Values;
|
|
184
184
|
/**
|
|
185
185
|
* Returns an array of resolved values or objects with resolved values.
|
|
186
186
|
*
|
|
@@ -201,7 +201,7 @@ declare function resolveValue<Tokens extends Token<unknown> | {
|
|
|
201
201
|
declare function resolveValues<Tokens extends (Token<unknown> | {
|
|
202
202
|
[key: string]: Token<unknown>;
|
|
203
203
|
})[], Values extends {
|
|
204
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps
|
|
204
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
205
205
|
}>(container: Container, ...tokens: Tokens): Values;
|
|
206
206
|
/**
|
|
207
207
|
* Decorates a factory by passing resolved values as factory arguments.
|
|
@@ -217,7 +217,7 @@ declare function resolveValues<Tokens extends (Token<unknown> | {
|
|
|
217
217
|
declare function injectable<Tokens extends (Token<unknown> | {
|
|
218
218
|
[key: string]: Token<unknown>;
|
|
219
219
|
})[], Values extends {
|
|
220
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps
|
|
220
|
+
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
221
221
|
}, Result>(this: unknown, factory: (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
222
222
|
/**
|
|
223
223
|
* Decorates a class by passing resolved values as arguments to its constructor.
|
|
@@ -234,70 +234,12 @@ declare function injectable<Tokens extends (Token<unknown> | {
|
|
|
234
234
|
declare function injectableClass<Tokens extends (Token<unknown> | {
|
|
235
235
|
[key: string]: Token<unknown>;
|
|
236
236
|
})[], Values extends {
|
|
237
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps
|
|
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
|
-
|
|
243
|
-
declare type TokenProps<Props extends ValuesProps> = {
|
|
244
|
-
[K in keyof Props]: Token<Props[K]>;
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* Returns an array of resolved values by the specified token.
|
|
248
|
-
* If a token is not found, then `undefined` value is used.
|
|
249
|
-
*
|
|
250
|
-
* @deprecated Use `tryResolveValues()` function.
|
|
251
|
-
*/
|
|
252
|
-
declare function getValues<Tokens extends Token<unknown>[], Values extends {
|
|
253
|
-
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : never;
|
|
254
|
-
}>(container: Container, ...tokens: Tokens): Values;
|
|
255
|
-
/**
|
|
256
|
-
* Returns an object with resolved properties which are specified by token properties.
|
|
257
|
-
* If a token is not found, then `undefined` value is used.
|
|
258
|
-
*
|
|
259
|
-
* @deprecated Use `tryResolveValue()` function.
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```ts
|
|
263
|
-
* const props = getProps(container, {a: tokenA, b: tokenB});
|
|
264
|
-
* console.log(props); // {a: 1, b: 2}
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
declare function getProps<Props extends ValuesProps>(container: Container, tokens: TokenProps<Props>): Partial<Props>;
|
|
268
|
-
/**
|
|
269
|
-
* Returns an object with resolved properties which are specified by token properties.
|
|
270
|
-
* If a token is not found, then `ResolverError` is thrown.
|
|
271
|
-
*
|
|
272
|
-
* @deprecated Use `resolveValue()` function.
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```ts
|
|
276
|
-
* const props = resolveProps(container, {a: tokenA, b: tokenB});
|
|
277
|
-
* console.log(props); // {a: 1, b: 2}
|
|
278
|
-
* ```
|
|
279
|
-
*/
|
|
280
|
-
declare function resolveProps<Props extends ValuesProps>(container: Container, tokens: TokenProps<Props>): Props;
|
|
281
|
-
/**
|
|
282
|
-
* Decorates a factory by passing a resolved object with tokens as the first argument.
|
|
283
|
-
* @param factory - A factory.
|
|
284
|
-
* @param tokens - Object with tokens.
|
|
285
|
-
* @return Decorated factory which takes a dependency container as a single argument.
|
|
286
|
-
*
|
|
287
|
-
* @deprecated Use `injectable()` function.
|
|
288
|
-
*
|
|
289
|
-
* @example
|
|
290
|
-
* ```ts
|
|
291
|
-
* const factory = ({a, b}: {a: number, b: number}) => a + b;
|
|
292
|
-
* const decoratedFactory = injectableProps(factory, {a: tokenA, b: tokenB});
|
|
293
|
-
* const result = decoratedFactory(container);
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
declare function injectableProps<Props extends ValuesProps, Result>(factory: (props: Props) => Result, tokens: TokenProps<Props>): (container: Container) => Result;
|
|
297
|
-
|
|
298
|
-
declare type AnyObject = Record<string, any>;
|
|
299
|
-
declare type EmptyObject = Record<string, never>;
|
|
300
|
-
declare type ModuleController = {
|
|
240
|
+
type AnyObject = Record<string, any>;
|
|
241
|
+
type EmptyObject = Record<string, never>;
|
|
242
|
+
type ModuleController = {
|
|
301
243
|
/** Dispose the module and clean its resources */
|
|
302
244
|
destroy?: () => void;
|
|
303
245
|
};
|
|
@@ -311,8 +253,8 @@ declare type ModuleController = {
|
|
|
311
253
|
* }>;
|
|
312
254
|
* ```
|
|
313
255
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
256
|
+
type Module<ModuleProps extends AnyObject = EmptyObject> = ModuleController & ModuleProps;
|
|
257
|
+
type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
316
258
|
/**
|
|
317
259
|
* Description how to bind the module in declarative way.
|
|
318
260
|
*
|
|
@@ -333,7 +275,7 @@ declare type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
|
333
275
|
* };
|
|
334
276
|
* ```
|
|
335
277
|
*/
|
|
336
|
-
|
|
278
|
+
type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
337
279
|
/** Token for the module */
|
|
338
280
|
token: Token<T>;
|
|
339
281
|
/** Modules for binding */
|
|
@@ -344,12 +286,6 @@ declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
344
286
|
exports?: {
|
|
345
287
|
[K in keyof GetModuleProps<T>]?: Token<GetModuleProps<T>[K]>;
|
|
346
288
|
};
|
|
347
|
-
/**
|
|
348
|
-
* Dictionary of module properties which are bound to tokens.
|
|
349
|
-
*
|
|
350
|
-
* @deprecated Use `exports` property.
|
|
351
|
-
*/
|
|
352
|
-
exportedProps?: ModuleDeclaration<T>['exports'];
|
|
353
289
|
/** Callback could be used to prepare an environment. It is called before binding the module. */
|
|
354
290
|
beforeBinding?: (container: Container) => void;
|
|
355
291
|
/** Callback could be used to export complex dependencies from the module. It is called after binding the module. */
|
|
@@ -362,10 +298,10 @@ declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
362
298
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
363
299
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
364
300
|
*/
|
|
365
|
-
|
|
301
|
+
type BindModuleOptions = {
|
|
366
302
|
scope?: 'scoped' | 'singleton';
|
|
367
303
|
};
|
|
368
|
-
|
|
304
|
+
type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
369
305
|
module: ModuleDeclaration<AnyObject>;
|
|
370
306
|
options: BindModuleOptions;
|
|
371
307
|
};
|
|
@@ -410,7 +346,7 @@ declare function bindModules(container: Container, modules: ReadonlyArray<Module
|
|
|
410
346
|
* });
|
|
411
347
|
* ```
|
|
412
348
|
*/
|
|
413
|
-
declare function declareModule<T
|
|
349
|
+
declare function declareModule<T extends Module<AnyObject>>(declaration: Omit<ModuleDeclaration<T>, 'token'> & Partial<Pick<ModuleDeclaration<T>, 'token'>>): ModuleDeclaration<T>;
|
|
414
350
|
/**
|
|
415
351
|
* Declares bindings of several modules
|
|
416
352
|
*
|
|
@@ -418,4 +354,4 @@ declare function declareModule<T>(declaration: Omit<ModuleDeclaration<T>, 'token
|
|
|
418
354
|
*/
|
|
419
355
|
declare function declareModuleBindings(modules: ReadonlyArray<ModuleBindingEntry>): ModuleDeclaration<Module>;
|
|
420
356
|
|
|
421
|
-
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 };
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
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
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/tslib/tslib.es6.js","../../src/ditox.ts","../../src/utils.ts","../../src/utils-deprecated.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,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","getValues","getProps","resolveProps","injectableProps","bindModule","moduleDeclaration","imports","beforeBinding","afterBinding","exports","exportedProps","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,EA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GAEpB7C,SAAQ,SAACkD,GACZ,IAAMC,EAAaN,EAAQK,GACvBC,IACFH,EAAoBI,IAAID,GAExB/D,EAAUI,YACR2D,EACAjB,GAAW,SAACmB,GAAW,OAAAA,EAAOH,KAAW7F,GACzC,CAACyD,cAMT1B,EAAUI,YAAYnC,EAAOoC,EAAS,CACpCqB,QACAI,UAAW,SAACmC,GACNA,EAAOC,SACTD,EAAOC,UAGTN,EAAoBhD,SAAQ,SAACmD,GAAe,OAAA/D,EAAUO,OAAOwD,MAC7DH,EAAoB7C,WAIpByC,GACFA,EAAaxD,YAUD2D,EACd3D,EACAmE,GAEAA,EAAQvD,SAAQ,SAACwD,GACX,WAAYA,EACdhB,EAAWpD,EAAWoE,EAAMH,OAAQG,EAAM9D,SAE1C8C,EAAWpD,EAAWoE,eA2BZC,EACdC,SAGA,cAAWA,IAAarG,gBAAOqG,EAAYrG,qBAASA,eAQtCsG,EACdJ,GAEA,OAAOE,EAAc,CACnBhE,QAAS,WAAM,UACfiD,QAASa"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
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/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { token, optional, ResolverError, createContainer } from './ditox';
|
|
2
2
|
export type { RequiredToken, OptionalToken, Token, FactoryScope, FactoryOptions, Container, } from './ditox';
|
|
3
3
|
export { isToken, bindMultiValue, tryResolveValue, tryResolveValues, resolveValue, resolveValues, injectable, injectableClass, } from './utils';
|
|
4
|
-
export { getValues, getProps, resolveProps, injectableProps, } from './utils-deprecated';
|
|
5
4
|
export { bindModule, bindModules, declareModule, declareModuleBindings, } from './modules';
|
|
6
5
|
export type { Module, ModuleDeclaration, BindModuleOptions, ModuleBindingEntry, } from './modules';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.declareModuleBindings = exports.declareModule = exports.bindModules = exports.bindModule = exports.
|
|
3
|
+
exports.declareModuleBindings = exports.declareModule = exports.bindModules = exports.bindModule = exports.injectableClass = exports.injectable = exports.resolveValues = exports.resolveValue = exports.tryResolveValues = exports.tryResolveValue = exports.bindMultiValue = exports.isToken = exports.createContainer = exports.ResolverError = exports.optional = exports.token = void 0;
|
|
4
4
|
var ditox_1 = require("./ditox");
|
|
5
5
|
Object.defineProperty(exports, "token", { enumerable: true, get: function () { return ditox_1.token; } });
|
|
6
6
|
Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return ditox_1.optional; } });
|
|
@@ -15,11 +15,6 @@ Object.defineProperty(exports, "resolveValue", { enumerable: true, get: function
|
|
|
15
15
|
Object.defineProperty(exports, "resolveValues", { enumerable: true, get: function () { return utils_1.resolveValues; } });
|
|
16
16
|
Object.defineProperty(exports, "injectable", { enumerable: true, get: function () { return utils_1.injectable; } });
|
|
17
17
|
Object.defineProperty(exports, "injectableClass", { enumerable: true, get: function () { return utils_1.injectableClass; } });
|
|
18
|
-
var utils_deprecated_1 = require("./utils-deprecated");
|
|
19
|
-
Object.defineProperty(exports, "getValues", { enumerable: true, get: function () { return utils_deprecated_1.getValues; } });
|
|
20
|
-
Object.defineProperty(exports, "getProps", { enumerable: true, get: function () { return utils_deprecated_1.getProps; } });
|
|
21
|
-
Object.defineProperty(exports, "resolveProps", { enumerable: true, get: function () { return utils_deprecated_1.resolveProps; } });
|
|
22
|
-
Object.defineProperty(exports, "injectableProps", { enumerable: true, get: function () { return utils_deprecated_1.injectableProps; } });
|
|
23
18
|
var modules_1 = require("./modules");
|
|
24
19
|
Object.defineProperty(exports, "bindModule", { enumerable: true, get: function () { return modules_1.bindModule; } });
|
|
25
20
|
Object.defineProperty(exports, "bindModules", { enumerable: true, get: function () { return modules_1.bindModules; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAwE;AAAhE,8FAAA,KAAK,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA;AAUvD,iCASiB;AARf,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,yGAAA,gBAAgB,OAAA;AAChB,qGAAA,YAAY,OAAA;AACZ,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA;AACV,wGAAA,eAAe,OAAA;AAGjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAwE;AAAhE,8FAAA,KAAK,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAAE,sGAAA,aAAa,OAAA;AAAE,wGAAA,eAAe,OAAA;AAUvD,iCASiB;AARf,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,yGAAA,gBAAgB,OAAA;AAChB,qGAAA,YAAY,OAAA;AACZ,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA;AACV,wGAAA,eAAe,OAAA;AAGjB,qCAKmB;AAJjB,qGAAA,UAAU,OAAA;AACV,sGAAA,WAAW,OAAA;AACX,wGAAA,aAAa,OAAA;AACb,gHAAA,qBAAqB,OAAA"}
|
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 */
|
|
@@ -48,17 +48,12 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
48
48
|
exports?: {
|
|
49
49
|
[K in keyof GetModuleProps<T>]?: Token<GetModuleProps<T>[K]>;
|
|
50
50
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Dictionary of module properties which are bound to tokens.
|
|
53
|
-
*
|
|
54
|
-
* @deprecated Use `exports` property.
|
|
55
|
-
*/
|
|
56
|
-
exportedProps?: ModuleDeclaration<T>['exports'];
|
|
57
51
|
/** Callback could be used to prepare an environment. It is called before binding the module. */
|
|
58
52
|
beforeBinding?: (container: Container) => void;
|
|
59
53
|
/** Callback could be used to export complex dependencies from the module. It is called after binding the module. */
|
|
60
54
|
afterBinding?: (container: Container) => void;
|
|
61
55
|
};
|
|
56
|
+
export type AnyModuleDeclaration = ModuleDeclaration<Module<AnyObject>>;
|
|
62
57
|
/**
|
|
63
58
|
* Options for module binding.
|
|
64
59
|
*
|
|
@@ -66,10 +61,10 @@ export declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
66
61
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
67
62
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
68
63
|
*/
|
|
69
|
-
export
|
|
64
|
+
export type BindModuleOptions = {
|
|
70
65
|
scope?: 'scoped' | 'singleton';
|
|
71
66
|
};
|
|
72
|
-
export
|
|
67
|
+
export type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
73
68
|
module: ModuleDeclaration<AnyObject>;
|
|
74
69
|
options: BindModuleOptions;
|
|
75
70
|
};
|
|
@@ -114,7 +109,7 @@ export declare function bindModules(container: Container, modules: ReadonlyArray
|
|
|
114
109
|
* });
|
|
115
110
|
* ```
|
|
116
111
|
*/
|
|
117
|
-
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>;
|
|
118
113
|
/**
|
|
119
114
|
* Declares bindings of several modules
|
|
120
115
|
*
|
package/dist/cjs/modules.js
CHANGED
|
@@ -15,9 +15,8 @@ const utils_1 = require("./utils");
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
function bindModule(container, moduleDeclaration, options) {
|
|
18
|
-
var _a;
|
|
19
18
|
const { token, imports, factory, beforeBinding, afterBinding } = moduleDeclaration;
|
|
20
|
-
const exports =
|
|
19
|
+
const exports = moduleDeclaration.exports;
|
|
21
20
|
const scope = options === null || options === void 0 ? void 0 : options.scope;
|
|
22
21
|
if (beforeBinding) {
|
|
23
22
|
beforeBinding(container);
|
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;IACpB,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;IAE1C,MAAM,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;IAE7B,IAAI,aAAa,EAAE;QACjB,aAAa,CAAC,SAAS,CAAC,CAAC;KAC1B;IAED,IAAI,OAAO,EAAE;QACX,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;KACjC;IAED,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtD,IAAI,OAAO,EAAE;QACX,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAElC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,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AAO,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/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { token, optional, ResolverError, createContainer } from './ditox';
|
|
2
2
|
export type { RequiredToken, OptionalToken, Token, FactoryScope, FactoryOptions, Container, } from './ditox';
|
|
3
3
|
export { isToken, bindMultiValue, tryResolveValue, tryResolveValues, resolveValue, resolveValues, injectable, injectableClass, } from './utils';
|
|
4
|
-
export { getValues, getProps, resolveProps, injectableProps, } from './utils-deprecated';
|
|
5
4
|
export { bindModule, bindModules, declareModule, declareModuleBindings, } from './modules';
|
|
6
5
|
export type { Module, ModuleDeclaration, BindModuleOptions, ModuleBindingEntry, } from './modules';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { token, optional, ResolverError, createContainer } from './ditox';
|
|
2
2
|
export { isToken, bindMultiValue, tryResolveValue, tryResolveValues, resolveValue, resolveValues, injectable, injectableClass, } from './utils';
|
|
3
|
-
export { getValues, getProps, resolveProps, injectableProps, } from './utils-deprecated';
|
|
4
3
|
export { bindModule, bindModules, declareModule, declareModuleBindings, } from './modules';
|
|
5
4
|
//# sourceMappingURL=index.js.map
|