ditox 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +134 -129
- package/dist/browser/index.d.ts +17 -17
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/ditox.d.ts +9 -9
- package/dist/cjs/modules.d.ts +10 -9
- package/dist/cjs/modules.js.map +1 -1
- package/dist/cjs/utils.d.ts +2 -2
- package/dist/esm/ditox.d.ts +9 -9
- package/dist/esm/modules.d.ts +10 -9
- package/dist/esm/modules.js.map +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/umd/index.d.ts +17 -17
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +11 -6
- package/src/modules.ts +3 -1
- package/dist/cjs/utils-deprecated.d.ts +0 -59
- package/dist/cjs/utils-deprecated.js +0 -66
- package/dist/cjs/utils-deprecated.js.map +0 -1
- package/dist/esm/utils-deprecated.d.ts +0 -59
- package/dist/esm/utils-deprecated.js +0 -59
- package/dist/esm/utils-deprecated.js.map +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/README.md +0 -794
- package/docs/classes/ResolverError.md +0 -165
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,66 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ditox package
|
|
2
2
|
|
|
3
3
|
<img alt="lemon" src="https://raw.githubusercontent.com/mnasyrov/ditox/master/lemon.svg" width="120" />
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Dependency injection for modular web applications**
|
|
6
6
|
|
|
7
|
-
[
|
|
8
|
-
[](https://www.npmjs.com/package/ditox)
|
|
9
|
-
[](https://www.npmjs.com/package/ditox)
|
|
10
|
-
[](https://github.com/mnasyrov/ditox/blob/master/LICENSE)
|
|
11
|
-
[](https://coveralls.io/github/mnasyrov/ditox)
|
|
7
|
+
Please see the documentation at [ditox.js.org](https://ditox.js.org)
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- [Installation](#installation)
|
|
19
|
-
- [Usage](#usage)
|
|
20
|
-
- [Container Hierarchy](#container-hierarchy)
|
|
21
|
-
- [Factory Lifetimes](#factory-lifetimes)
|
|
22
|
-
* [`singleton`](#singleton)
|
|
23
|
-
* [`scoped`](#scoped)
|
|
24
|
-
* [`transient`](#transient)
|
|
25
|
-
- [Dependency modules](#dependency-modules)
|
|
26
|
-
- [API References](#api-references)
|
|
27
|
-
|
|
28
|
-
<!-- tocstop -->
|
|
29
|
-
|
|
30
|
-
## Features
|
|
31
|
-
|
|
32
|
-
- Simple and functional API
|
|
33
|
-
- Container hierarchy
|
|
34
|
-
- Scoped containers
|
|
35
|
-
- Dependency modules
|
|
36
|
-
- Multi-value tokens
|
|
37
|
-
- Typescript typings
|
|
38
|
-
- Supports Node.js, Deno and browsers
|
|
9
|
+
[](https://www.npmjs.com/package/ditox)
|
|
10
|
+
[](https://github.com/mnasyrov/ditox/stargazers)
|
|
11
|
+
[](https://www.npmjs.com/package/ditox)
|
|
12
|
+
[](https://github.com/mnasyrov/ditox/blob/master/LICENSE)
|
|
13
|
+
[](https://coveralls.io/github/mnasyrov/ditox)
|
|
39
14
|
|
|
40
15
|
## Installation
|
|
41
16
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
npm install ditox --save
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Or `yarn`
|
|
17
|
+
You can use the following command to install this package:
|
|
49
18
|
|
|
50
|
-
```
|
|
51
|
-
|
|
19
|
+
```shell
|
|
20
|
+
npm install --save ditox
|
|
52
21
|
```
|
|
53
22
|
|
|
54
|
-
|
|
23
|
+
The package can be used as [UMD](https://github.com/umdjs/umd) module. Use
|
|
24
|
+
[jsdelivr.com](https://jsdelivr.com) CDN site to load
|
|
25
|
+
[ditox](https://www.jsdelivr.com/package/npm/ditox):
|
|
55
26
|
|
|
56
27
|
```html
|
|
57
|
-
<script src="
|
|
28
|
+
<script src="//cdn.jsdelivr.net/npm/ditox/dist/umd/index.js" />
|
|
58
29
|
<script>
|
|
59
30
|
const container = Ditox.createContainer();
|
|
60
31
|
</script>
|
|
61
32
|
```
|
|
62
33
|
|
|
63
|
-
|
|
34
|
+
Using in Deno environment:
|
|
64
35
|
|
|
65
36
|
```ts
|
|
66
37
|
import {createContainer} from 'https://deno.land/x/ditox/mod.ts';
|
|
@@ -68,17 +39,32 @@ import {createContainer} from 'https://deno.land/x/ditox/mod.ts';
|
|
|
68
39
|
const container = createContainer();
|
|
69
40
|
```
|
|
70
41
|
|
|
71
|
-
##
|
|
42
|
+
## General description
|
|
43
|
+
|
|
44
|
+
DI pattern in general allows to declare and construct a code graph of an
|
|
45
|
+
application. It can be described by following phases:
|
|
46
|
+
|
|
47
|
+
1. Code declaration phase:
|
|
48
|
+
|
|
49
|
+
- Defining public API and types of business layer
|
|
50
|
+
- Creation of injection tokens
|
|
51
|
+
- Declaring DI modules
|
|
52
|
+
|
|
53
|
+
2. Binding phase:
|
|
54
|
+
|
|
55
|
+
- Creation of a container
|
|
56
|
+
- Binding values, factories and modules to the container
|
|
57
|
+
|
|
58
|
+
3. Runtime phase:
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
- Running the code
|
|
61
|
+
- Values are constructed by registered factories
|
|
75
62
|
|
|
76
|
-
|
|
63
|
+
Diagram:
|
|
77
64
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
- Resolve the tokens and use the provided values.
|
|
65
|
+
<img alt="diagram" src="../../media/diagram.svg" width="800" />
|
|
66
|
+
|
|
67
|
+
## Usage Example
|
|
82
68
|
|
|
83
69
|
```js
|
|
84
70
|
import {createContainer, injectable, optional, token} from 'ditox';
|
|
@@ -93,42 +79,41 @@ class UserService {
|
|
|
93
79
|
}
|
|
94
80
|
|
|
95
81
|
// Define tokens for injections.
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
82
|
+
const STORAGE_TOKEN = token < UserService > 'Token description for debugging';
|
|
83
|
+
const LOGGER_TOKEN = token();
|
|
84
|
+
const USER_SERVICE_TOKEN = token();
|
|
85
|
+
|
|
86
|
+
// Token can be optional with a default value.
|
|
87
|
+
const STORAGE_CONFIG_TOKEN = optional(token(), {name: 'default storage'});
|
|
103
88
|
|
|
104
89
|
// Create the container.
|
|
105
90
|
const container = createContainer();
|
|
106
91
|
|
|
107
92
|
// Provide a value to the container.
|
|
108
|
-
container.bindValue(
|
|
93
|
+
container.bindValue(STORAGE_CONFIG_TOKEN, {name: 'custom storage'});
|
|
109
94
|
|
|
110
95
|
// Dynamic values are provided by factories.
|
|
111
96
|
|
|
112
97
|
// A factory can be decorated with `injectable()` to resolve its arguments.
|
|
113
98
|
// By default, a factory has `singleton` lifetime.
|
|
114
99
|
container.bindFactory(
|
|
115
|
-
|
|
116
|
-
injectable(createStorage,
|
|
100
|
+
STORAGE_TOKEN,
|
|
101
|
+
injectable(createStorage, STORAGE_CONFIG_TOKEN),
|
|
117
102
|
);
|
|
118
103
|
|
|
119
104
|
// A factory can have `transient` lifetime to create a value on each resolving.
|
|
120
|
-
container.bindFactory(
|
|
105
|
+
container.bindFactory(LOGGER_TOKEN, createLogger, {scope: 'transient'});
|
|
121
106
|
|
|
122
107
|
// A class can be injected by `injectableClass()` which calls its constructor
|
|
123
108
|
// with injected dependencies as arguments.
|
|
124
109
|
container.bindFactory(
|
|
125
|
-
|
|
110
|
+
USER_SERVICE_TOKEN,
|
|
126
111
|
injectable(
|
|
127
112
|
(storage, logger) => new UserService(storage, logger),
|
|
128
|
-
|
|
113
|
+
STORAGE_TOKEN,
|
|
129
114
|
// A token can be made optional to resolve with a default value
|
|
130
115
|
// when it is not found during resolving.
|
|
131
|
-
optional(
|
|
116
|
+
optional(LOGGER_TOKEN),
|
|
132
117
|
),
|
|
133
118
|
{
|
|
134
119
|
// `scoped` and `singleton` scopes can have `onRemoved` callback.
|
|
@@ -139,13 +124,13 @@ container.bindFactory(
|
|
|
139
124
|
);
|
|
140
125
|
|
|
141
126
|
// Get a value from the container, it returns `undefined` in case a value is not found.
|
|
142
|
-
const logger = container.get(
|
|
127
|
+
const logger = container.get(LOGGER_TOKEN);
|
|
143
128
|
|
|
144
129
|
// Resolve a value, it throws `ResolverError` in case a value is not found.
|
|
145
|
-
const userService = container.resolve(
|
|
130
|
+
const userService = container.resolve(userService);
|
|
146
131
|
|
|
147
132
|
// Remove a value from the container.
|
|
148
|
-
container.remove(
|
|
133
|
+
container.remove(LOGGER_TOKEN);
|
|
149
134
|
|
|
150
135
|
// Clean up the container.
|
|
151
136
|
container.removeAll();
|
|
@@ -153,86 +138,96 @@ container.removeAll();
|
|
|
153
138
|
|
|
154
139
|
## Container Hierarchy
|
|
155
140
|
|
|
156
|
-
Ditox.js supports "parent-child" hierarchy. If the child container cannot to
|
|
141
|
+
Ditox.js supports "parent-child" hierarchy. If the child container cannot to
|
|
142
|
+
resolve a token, it asks the parent container to resolve it:
|
|
157
143
|
|
|
158
144
|
```js
|
|
159
145
|
import {creatContainer, token} from 'ditox';
|
|
160
146
|
|
|
161
|
-
const
|
|
162
|
-
const
|
|
147
|
+
const V1_TOKEN = token();
|
|
148
|
+
const V2_TOKEN = token();
|
|
163
149
|
|
|
164
150
|
const parent = createContainer();
|
|
165
|
-
parent.bindValue(
|
|
166
|
-
parent.bindValue(
|
|
151
|
+
parent.bindValue(V1_TOKEN, 10);
|
|
152
|
+
parent.bindValue(V2_TOKEN, 20);
|
|
167
153
|
|
|
168
154
|
const container = createContainer(parent);
|
|
169
|
-
container.bindValue(
|
|
155
|
+
container.bindValue(V2_TOKEN, 21);
|
|
170
156
|
|
|
171
|
-
container.resolve(
|
|
172
|
-
container.resolve(
|
|
157
|
+
container.resolve(V1_TOKEN); // 10
|
|
158
|
+
container.resolve(V2_TOKEN); // 21
|
|
173
159
|
```
|
|
174
160
|
|
|
175
161
|
## Factory Lifetimes
|
|
176
162
|
|
|
177
|
-
Ditox.js supports managing the lifetime of values which are produced by
|
|
178
|
-
There are the following types:
|
|
163
|
+
Ditox.js supports managing the lifetime of values which are produced by
|
|
164
|
+
factories. There are the following types:
|
|
179
165
|
|
|
180
|
-
- `singleton` - **This is the default**. The value is created and cached by the
|
|
181
|
-
|
|
166
|
+
- `singleton` - **This is the default**. The value is created and cached by the
|
|
167
|
+
container which registered the factory.
|
|
168
|
+
- `scoped` - The value is created and cached by the container which starts
|
|
169
|
+
resolving.
|
|
182
170
|
- `transient` - The value is created every time it is resolved.
|
|
183
171
|
|
|
184
172
|
### `singleton`
|
|
185
173
|
|
|
186
|
-
**This is the default scope**. "Singleton" allows to cache a produced value by a
|
|
174
|
+
**This is the default scope**. "Singleton" allows to cache a produced value by a
|
|
175
|
+
parent container which registered the factory:
|
|
187
176
|
|
|
188
177
|
```js
|
|
189
178
|
import {creatContainer, token} from 'ditox';
|
|
190
179
|
|
|
191
|
-
const
|
|
192
|
-
const
|
|
180
|
+
const TAG_TOKEN = token();
|
|
181
|
+
const LOGGER_TOKEN = token();
|
|
193
182
|
|
|
194
183
|
const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
195
184
|
|
|
196
185
|
const parent = createContainer();
|
|
197
|
-
parent.bindValue(
|
|
198
|
-
parent.bindFactory(
|
|
186
|
+
parent.bindValue(TAG_TOKEN, 'parent');
|
|
187
|
+
parent.bindFactory(LOGGER_TOKEN, injectable(createLogger, TAG_TOKEN), {
|
|
188
|
+
scope: 'singleton',
|
|
189
|
+
});
|
|
199
190
|
|
|
200
191
|
const container1 = createContainer(parent);
|
|
201
|
-
container1.bindValue(
|
|
192
|
+
container1.bindValue(TAG_TOKEN, 'container1');
|
|
202
193
|
|
|
203
194
|
const container2 = createContainer(parent);
|
|
204
|
-
container2.bindValue(
|
|
195
|
+
container2.bindValue(TAG_TOKEN, 'container2');
|
|
205
196
|
|
|
206
|
-
parent.resolve(
|
|
207
|
-
container1.resolve(
|
|
208
|
-
container2.resolve(
|
|
197
|
+
parent.resolve(LOGGER_TOKEN)('xyz'); // [parent] xyz
|
|
198
|
+
container1.resolve(LOGGER_TOKEN)('foo'); // [parent] foo
|
|
199
|
+
container2.resolve(LOGGER_TOKEN)('bar'); // [parent] bar
|
|
209
200
|
```
|
|
210
201
|
|
|
211
202
|
### `scoped`
|
|
212
203
|
|
|
213
|
-
"Scoped" lifetime allows to have sub-containers with own instances of some
|
|
204
|
+
"Scoped" lifetime allows to have sub-containers with own instances of some
|
|
205
|
+
services which can be disposed. For example, a context during HTTP request
|
|
206
|
+
handling, or other unit of work:
|
|
214
207
|
|
|
215
208
|
```js
|
|
216
209
|
import {creatContainer, token} from 'ditox';
|
|
217
210
|
|
|
218
|
-
const
|
|
219
|
-
const
|
|
211
|
+
const TAG_TOKEN = token();
|
|
212
|
+
const LOGGER_TOKEN = token();
|
|
220
213
|
|
|
221
214
|
const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
222
215
|
|
|
223
216
|
const parent = createContainer();
|
|
224
217
|
// `scoped` is default scope and can be omitted.
|
|
225
|
-
parent.bindFactory(
|
|
218
|
+
parent.bindFactory(LOGGER_TOKEN, injectable(createLogger, TAG_TOKEN), {
|
|
219
|
+
scope: 'scoped',
|
|
220
|
+
});
|
|
226
221
|
|
|
227
222
|
const container1 = createContainer(parent);
|
|
228
|
-
container1.bindValue(
|
|
223
|
+
container1.bindValue(TAG_TOKEN, 'container1');
|
|
229
224
|
|
|
230
225
|
const container2 = createContainer(parent);
|
|
231
|
-
container2.bindValue(
|
|
226
|
+
container2.bindValue(TAG_TOKEN, 'container2');
|
|
232
227
|
|
|
233
|
-
parent.resolve(
|
|
234
|
-
container1.resolve(
|
|
235
|
-
container2.resolve(
|
|
228
|
+
parent.resolve(LOGGER_TOKEN)('xyz'); // throws ResolverError, the parent does not have TAG value.
|
|
229
|
+
container1.resolve(LOGGER_TOKEN)('foo'); // [container1] foo
|
|
230
|
+
container2.resolve(LOGGER_TOKEN)('bar'); // [container2] bar
|
|
236
231
|
|
|
237
232
|
// Dispose a container.
|
|
238
233
|
container1.removeAll();
|
|
@@ -243,43 +238,54 @@ container1.removeAll();
|
|
|
243
238
|
"Transient" makes to a produce values by the factory for each resolving:
|
|
244
239
|
|
|
245
240
|
```js
|
|
246
|
-
import {
|
|
241
|
+
import {createContainer, token} from 'ditox';
|
|
247
242
|
|
|
248
|
-
const
|
|
249
|
-
const
|
|
243
|
+
const TAG_TOKEN = token();
|
|
244
|
+
const LOGGER_TOKEN = token();
|
|
250
245
|
|
|
251
246
|
const createLogger = (tag) => (message) => console.log(`[${tag}] ${message}`);
|
|
252
247
|
|
|
253
248
|
const parent = createContainer();
|
|
254
|
-
parent.bindValue(
|
|
255
|
-
parent.bindFactory(
|
|
249
|
+
parent.bindValue(TAG_TOKEN, 'parent');
|
|
250
|
+
parent.bindFactory(LOGGER_TOKEN, injectable(createLogger, TAG_TOKEN), {
|
|
251
|
+
scope: 'transient',
|
|
252
|
+
});
|
|
256
253
|
|
|
257
254
|
const container1 = createContainer(parent);
|
|
258
|
-
container1.bindValue(
|
|
255
|
+
container1.bindValue(TAG_TOKEN, 'container1');
|
|
259
256
|
|
|
260
257
|
const container2 = createContainer(parent);
|
|
261
|
-
container2.bindValue(
|
|
258
|
+
container2.bindValue(TAG_TOKEN, 'container2');
|
|
262
259
|
|
|
263
|
-
parent.resolve(
|
|
264
|
-
container1.resolve(
|
|
265
|
-
container2.resolve(
|
|
260
|
+
parent.resolve(LOGGER_TOKEN)('xyz'); // [parent] xyz
|
|
261
|
+
container1.resolve(LOGGER_TOKEN)('foo'); // [container1] foo
|
|
262
|
+
container2.resolve(LOGGER_TOKEN)('bar'); // [container2] bar
|
|
266
263
|
|
|
267
|
-
parent.bindValue(
|
|
268
|
-
parent.resolve(
|
|
264
|
+
parent.bindValue(TAG_TOKEN, 'parent-rebind');
|
|
265
|
+
parent.resolve(LOGGER_TOKEN)('xyz'); // [parent-rebind] xyz
|
|
269
266
|
```
|
|
270
267
|
|
|
271
|
-
## Dependency
|
|
268
|
+
## Dependency Modules
|
|
272
269
|
|
|
273
|
-
Dependencies can be organized as modules in declarative way with
|
|
274
|
-
It is useful for providing pieces of functionality from
|
|
270
|
+
Dependencies can be organized as modules in declarative way with
|
|
271
|
+
`ModuleDeclaration`. It is useful for providing pieces of functionality from
|
|
272
|
+
libraries to an app which depends on them.
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import {Module, ModuleDeclaration, token} from 'ditox';
|
|
276
|
+
import {TRANSPORT_TOKEN} from './transport';
|
|
277
|
+
|
|
278
|
+
export type Logger = {log: (message: string) => void};
|
|
279
|
+
export const LOGGER_TOKEN = token<Logger>();
|
|
275
280
|
|
|
276
|
-
```ts
|
|
277
281
|
type LoggerModule = Module<{logger: Logger}>;
|
|
278
282
|
|
|
279
|
-
const LOGGER_MODULE_TOKEN = token<LoggerModule
|
|
283
|
+
const LOGGER_MODULE_TOKEN = token<LoggerModule>();
|
|
280
284
|
|
|
281
285
|
const LOGGER_MODULE: ModuleDeclaration<LoggerModule> = {
|
|
286
|
+
// An optional explicit token for a module itself
|
|
282
287
|
token: LOGGER_MODULE_TOKEN,
|
|
288
|
+
|
|
283
289
|
factory: (container) => {
|
|
284
290
|
const transport = container.resolve(TRANSPORT_TOKEN).open();
|
|
285
291
|
return {
|
|
@@ -295,7 +301,7 @@ const LOGGER_MODULE: ModuleDeclaration<LoggerModule> = {
|
|
|
295
301
|
|
|
296
302
|
Later such module declarations can be bound to a container:
|
|
297
303
|
|
|
298
|
-
```
|
|
304
|
+
```typescript
|
|
299
305
|
const container = createContainer();
|
|
300
306
|
|
|
301
307
|
// bind a single module
|
|
@@ -305,13 +311,16 @@ bindModule(container, LOGGER_MODULE);
|
|
|
305
311
|
bindModules(container, [DATABASE_MODULE, CONFIG_MODULE, API_MODULE]);
|
|
306
312
|
```
|
|
307
313
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
- `
|
|
314
|
+
Utility functions for module declarations:
|
|
315
|
+
|
|
316
|
+
- `declareModule()` – declare a module as `ModuleDeclaration` however `token`
|
|
317
|
+
field can be optional for anonymous modules.
|
|
318
|
+
- `declareModuleBindings()` – declares an anonymous module with imports. This
|
|
319
|
+
module binds the provided ones to a container.
|
|
311
320
|
|
|
312
321
|
Example for these functions:
|
|
313
322
|
|
|
314
|
-
```
|
|
323
|
+
```typescript
|
|
315
324
|
const LOGGER_MODULE = declareModule<LoggerModule>({
|
|
316
325
|
factory: createLoggerModule,
|
|
317
326
|
exports: {
|
|
@@ -322,11 +331,7 @@ const LOGGER_MODULE = declareModule<LoggerModule>({
|
|
|
322
331
|
const APP_MODULE = declareModuleBinding([LOGGER_MODULE, DATABASE_MODULE]);
|
|
323
332
|
```
|
|
324
333
|
|
|
325
|
-
## API References
|
|
326
|
-
|
|
327
|
-
- [`ditox`](./docs)
|
|
328
|
-
- [`ditox-react`](https://github.com/mnasyrov/ditox/tree/master/packages/ditox-react#readme)
|
|
329
|
-
|
|
330
334
|
---
|
|
331
335
|
|
|
332
|
-
|
|
336
|
+
This project is licensed under the
|
|
337
|
+
[MIT license](https://github.com/mnasyrov/ditox/blob/master/LICENSE).
|
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
|
/**
|
|
@@ -237,9 +237,9 @@ declare function injectableClass<Tokens extends (Token<unknown> | {
|
|
|
237
237
|
[K in keyof Tokens]: Tokens[K] extends Token<infer V> ? V : Tokens[K] extends TokenProps<infer Props> ? Props : never;
|
|
238
238
|
}, Result>(this: unknown, constructor: new (...params: Values) => Result, ...tokens: Tokens): (container: Container) => Result;
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
type AnyObject = Record<string, any>;
|
|
241
|
+
type EmptyObject = Record<string, never>;
|
|
242
|
+
type ModuleController = {
|
|
243
243
|
/** Dispose the module and clean its resources */
|
|
244
244
|
destroy?: () => void;
|
|
245
245
|
};
|
|
@@ -253,8 +253,8 @@ declare type ModuleController = {
|
|
|
253
253
|
* }>;
|
|
254
254
|
* ```
|
|
255
255
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
type Module<ModuleProps extends AnyObject = EmptyObject> = ModuleController & ModuleProps;
|
|
257
|
+
type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
258
258
|
/**
|
|
259
259
|
* Description how to bind the module in declarative way.
|
|
260
260
|
*
|
|
@@ -275,7 +275,7 @@ declare type GetModuleProps<T> = T extends Module<infer Props> ? Props : never;
|
|
|
275
275
|
* };
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
|
|
278
|
+
type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
279
279
|
/** Token for the module */
|
|
280
280
|
token: Token<T>;
|
|
281
281
|
/** Modules for binding */
|
|
@@ -298,10 +298,10 @@ declare type ModuleDeclaration<T extends Module<AnyObject>> = {
|
|
|
298
298
|
* - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory.
|
|
299
299
|
* - `scoped` - The module is created and cached by the container which starts resolving.
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
type BindModuleOptions = {
|
|
302
302
|
scope?: 'scoped' | 'singleton';
|
|
303
303
|
};
|
|
304
|
-
|
|
304
|
+
type ModuleBindingEntry = ModuleDeclaration<AnyObject> | {
|
|
305
305
|
module: ModuleDeclaration<AnyObject>;
|
|
306
306
|
options: BindModuleOptions;
|
|
307
307
|
};
|
|
@@ -346,7 +346,7 @@ declare function bindModules(container: Container, modules: ReadonlyArray<Module
|
|
|
346
346
|
* });
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
|
-
declare function declareModule<T
|
|
349
|
+
declare function declareModule<T extends Module<AnyObject>>(declaration: Omit<ModuleDeclaration<T>, 'token'> & Partial<Pick<ModuleDeclaration<T>, 'token'>>): ModuleDeclaration<T>;
|
|
350
350
|
/**
|
|
351
351
|
* Declares bindings of several modules
|
|
352
352
|
*
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +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
|
|
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="singleton",y=r("ditox.FactoriesMap");function p(o){return o.symbol===u.symbol||o.symbol===l.symbol||o.symbol===c.symbol}function v(o){var n=new Map,t=new Map,r={bindValue:function(o,t){p(o)||n.set(o.symbol,t)},bindFactory:function(o,n,r){p(o)||t.set(o.symbol,{factory:n,options:r})},remove:function(o){var r;if(!p(o)){var e=null===(r=t.get(o.symbol))||void 0===r?void 0:r.options;e&&v(o.symbol,e),n.delete(o.symbol),t.delete(o.symbol)}},removeAll:function(){t.forEach((function(o,n){o.options&&v(n,o.options)})),n.clear(),t.clear(),b()},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 y,p,v=t.get(e.symbol);if(v&&v.factory!==s)switch(y=v.options,null!==(p=null==y?void 0:y.scope)&&void 0!==p?p:f){case"singleton":if(l)return u;if(null==o?void 0:o.hasToken(e))break;var b=v.factory(r);return r.bindValue(e,b),b;case"scoped":var d=v.factory(i);return i.bindValue(e,d),i!==r&&i.bindFactory(e,s,v.options),d;case"transient":return v.factory(i)}if(l)return u;var m=null==o?void 0:o.get(c);return m?m(e,i):a}function v(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 b(){n.set(u.symbol,r),n.set(c.symbol,e),n.set(y.symbol,t),o&&n.set(l.symbol,o)}return b(),r}function b(o){return null!=o&&"object"==typeof o&&"symbol"in o&&"symbol"==typeof o.symbol}function d(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 m(o,n){if(b(n))return o.get(n);var t={};return Object.keys(n).forEach((function(r){return t[r]=o.get(n[r])})),t}function h(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return m(o,n)}))}function g(o,n){if(b(n))return o.resolve(n);var t={};return Object.keys(n).forEach((function(r){return t[r]=o.resolve(n[r])})),t}function O(o){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.map((function(n){return g(o,n)}))}function w(o){for(var n=this,r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return function(e){var i=O.apply(void 0,t([e],r,!1));return o.apply(n,i)}}function k(o){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return w.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 E(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&&j(o,e);var s=new Set;c&&Object.keys(c).forEach((function(n){var t=c[n];t&&(s.add(t),o.bindFactory(t,w((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 j(o,n){n.forEach((function(n){"module"in n?E(o,n.module,n.options):E(o,n)}))}function _(o){var t;return n(n({},o),{token:null!==(t=o.token)&&void 0!==t?t:r()})}function x(o){return _({factory:function(){return{}},imports:o})}export{i as ResolverError,E as bindModule,j as bindModules,d as bindMultiValue,v as createContainer,_ as declareModule,x as declareModuleBindings,w as injectable,k as injectableClass,b as isToken,e as optional,g as resolveValue,O as resolveValues,r as token,m as tryResolveValue,h 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/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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