##// END OF EJS Templates
fixed object activation when a single argument passed to the constructor.
cin -
r46:747292a4f3ac di-typescript
parent child
Show More
@@ -1,450 +1,450
1 1 {
2 2 "name": "@implab/core",
3 3 "version": "0.0.1-dev",
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
7 7 "@types/node": {
8 8 "version": "10.12.12",
9 9 "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.12.tgz",
10 10 "integrity": "sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==",
11 11 "dev": true
12 12 },
13 13 "@types/tape": {
14 14 "version": "4.2.32",
15 15 "resolved": "http://registry.npmjs.org/@types/tape/-/tape-4.2.32.tgz",
16 16 "integrity": "sha512-xil0KO5wkPoixdBWGIGolPv9dekf6dVkjjJLAFYchfKcd4DICou67rgGCIO7wAh3i5Ff/6j9IDgZz+GU9cMaqQ==",
17 17 "dev": true,
18 18 "requires": {
19 19 "@types/node": "*"
20 20 }
21 21 },
22 22 "balanced-match": {
23 23 "version": "1.0.0",
24 24 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
25 25 "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
26 26 "dev": true
27 27 },
28 28 "brace-expansion": {
29 29 "version": "1.1.11",
30 30 "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
31 31 "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
32 32 "dev": true,
33 33 "requires": {
34 34 "balanced-match": "^1.0.0",
35 35 "concat-map": "0.0.1"
36 36 }
37 37 },
38 38 "concat-map": {
39 39 "version": "0.0.1",
40 40 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
41 41 "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
42 42 "dev": true
43 43 },
44 44 "core-util-is": {
45 45 "version": "1.0.2",
46 46 "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
47 47 "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
48 48 "dev": true
49 49 },
50 50 "deep-equal": {
51 51 "version": "0.1.2",
52 52 "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz",
53 53 "integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=",
54 54 "dev": true
55 55 },
56 56 "define-properties": {
57 57 "version": "1.1.3",
58 58 "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
59 59 "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
60 60 "dev": true,
61 61 "requires": {
62 62 "object-keys": "^1.0.12"
63 63 },
64 64 "dependencies": {
65 65 "object-keys": {
66 66 "version": "1.0.12",
67 67 "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
68 68 "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==",
69 69 "dev": true
70 70 }
71 71 }
72 72 },
73 73 "defined": {
74 74 "version": "0.0.0",
75 75 "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz",
76 76 "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=",
77 77 "dev": true
78 78 },
79 79 "dojo": {
80 80 "version": "1.14.2",
81 81 "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz",
82 82 "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==",
83 83 "dev": true
84 84 },
85 85 "duplexer": {
86 86 "version": "0.1.1",
87 "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
87 "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
88 88 "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
89 89 "dev": true
90 90 },
91 91 "es-abstract": {
92 92 "version": "1.12.0",
93 93 "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
94 94 "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
95 95 "dev": true,
96 96 "requires": {
97 97 "es-to-primitive": "^1.1.1",
98 98 "function-bind": "^1.1.1",
99 99 "has": "^1.0.1",
100 100 "is-callable": "^1.1.3",
101 101 "is-regex": "^1.0.4"
102 102 }
103 103 },
104 104 "es-to-primitive": {
105 105 "version": "1.2.0",
106 106 "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz",
107 107 "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==",
108 108 "dev": true,
109 109 "requires": {
110 110 "is-callable": "^1.1.4",
111 111 "is-date-object": "^1.0.1",
112 112 "is-symbol": "^1.0.2"
113 113 }
114 114 },
115 115 "faucet": {
116 116 "version": "0.0.1",
117 117 "resolved": "https://registry.npmjs.org/faucet/-/faucet-0.0.1.tgz",
118 118 "integrity": "sha1-WX3PHSGJosBiMhtZHo8VHtIDnZw=",
119 119 "dev": true,
120 120 "requires": {
121 121 "defined": "0.0.0",
122 122 "duplexer": "~0.1.1",
123 123 "minimist": "0.0.5",
124 124 "sprintf": "~0.1.3",
125 125 "tap-parser": "~0.4.0",
126 126 "tape": "~2.3.2",
127 127 "through2": "~0.2.3"
128 128 },
129 129 "dependencies": {
130 130 "tape": {
131 131 "version": "2.3.3",
132 "resolved": "https://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
132 "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
133 133 "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=",
134 134 "dev": true,
135 135 "requires": {
136 136 "deep-equal": "~0.1.0",
137 137 "defined": "~0.0.0",
138 138 "inherits": "~2.0.1",
139 139 "jsonify": "~0.0.0",
140 140 "resumer": "~0.0.0",
141 141 "through": "~2.3.4"
142 142 }
143 143 }
144 144 }
145 145 },
146 146 "for-each": {
147 147 "version": "0.3.3",
148 148 "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
149 149 "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
150 150 "dev": true,
151 151 "requires": {
152 152 "is-callable": "^1.1.3"
153 153 }
154 154 },
155 155 "fs.realpath": {
156 156 "version": "1.0.0",
157 157 "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
158 158 "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
159 159 "dev": true
160 160 },
161 161 "function-bind": {
162 162 "version": "1.1.1",
163 163 "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
164 164 "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
165 165 "dev": true
166 166 },
167 167 "glob": {
168 168 "version": "7.1.3",
169 169 "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
170 170 "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
171 171 "dev": true,
172 172 "requires": {
173 173 "fs.realpath": "^1.0.0",
174 174 "inflight": "^1.0.4",
175 175 "inherits": "2",
176 176 "minimatch": "^3.0.4",
177 177 "once": "^1.3.0",
178 178 "path-is-absolute": "^1.0.0"
179 179 }
180 180 },
181 181 "has": {
182 182 "version": "1.0.3",
183 183 "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
184 184 "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
185 185 "dev": true,
186 186 "requires": {
187 187 "function-bind": "^1.1.1"
188 188 }
189 189 },
190 190 "has-symbols": {
191 191 "version": "1.0.0",
192 192 "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
193 193 "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=",
194 194 "dev": true
195 195 },
196 196 "inflight": {
197 197 "version": "1.0.6",
198 198 "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
199 199 "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
200 200 "dev": true,
201 201 "requires": {
202 202 "once": "^1.3.0",
203 203 "wrappy": "1"
204 204 }
205 205 },
206 206 "inherits": {
207 207 "version": "2.0.3",
208 208 "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
209 209 "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
210 210 "dev": true
211 211 },
212 212 "is-callable": {
213 213 "version": "1.1.4",
214 214 "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
215 215 "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
216 216 "dev": true
217 217 },
218 218 "is-date-object": {
219 219 "version": "1.0.1",
220 220 "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
221 221 "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
222 222 "dev": true
223 223 },
224 224 "is-regex": {
225 225 "version": "1.0.4",
226 226 "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
227 227 "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
228 228 "dev": true,
229 229 "requires": {
230 230 "has": "^1.0.1"
231 231 }
232 232 },
233 233 "is-symbol": {
234 234 "version": "1.0.2",
235 235 "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz",
236 236 "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
237 237 "dev": true,
238 238 "requires": {
239 239 "has-symbols": "^1.0.0"
240 240 }
241 241 },
242 242 "isarray": {
243 243 "version": "0.0.1",
244 244 "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
245 245 "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
246 246 "dev": true
247 247 },
248 248 "jsonify": {
249 249 "version": "0.0.0",
250 250 "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
251 251 "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
252 252 "dev": true
253 253 },
254 254 "minimatch": {
255 255 "version": "3.0.4",
256 256 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
257 257 "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
258 258 "dev": true,
259 259 "requires": {
260 260 "brace-expansion": "^1.1.7"
261 261 }
262 262 },
263 263 "minimist": {
264 264 "version": "0.0.5",
265 265 "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
266 266 "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=",
267 267 "dev": true
268 268 },
269 269 "object-inspect": {
270 270 "version": "1.6.0",
271 271 "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz",
272 272 "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==",
273 273 "dev": true
274 274 },
275 275 "object-keys": {
276 276 "version": "0.4.0",
277 277 "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
278 278 "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=",
279 279 "dev": true
280 280 },
281 281 "once": {
282 282 "version": "1.4.0",
283 283 "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
284 284 "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
285 285 "dev": true,
286 286 "requires": {
287 287 "wrappy": "1"
288 288 }
289 289 },
290 290 "path-is-absolute": {
291 291 "version": "1.0.1",
292 "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
292 "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
293 293 "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
294 294 "dev": true
295 295 },
296 296 "path-parse": {
297 297 "version": "1.0.6",
298 298 "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
299 299 "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
300 300 "dev": true
301 301 },
302 302 "readable-stream": {
303 303 "version": "1.1.14",
304 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
304 "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
305 305 "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
306 306 "dev": true,
307 307 "requires": {
308 308 "core-util-is": "~1.0.0",
309 309 "inherits": "~2.0.1",
310 310 "isarray": "0.0.1",
311 311 "string_decoder": "~0.10.x"
312 312 }
313 313 },
314 314 "requirejs": {
315 315 "version": "2.3.6",
316 316 "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz",
317 317 "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==",
318 318 "dev": true
319 319 },
320 320 "resolve": {
321 321 "version": "1.7.1",
322 322 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
323 323 "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==",
324 324 "dev": true,
325 325 "requires": {
326 326 "path-parse": "^1.0.5"
327 327 }
328 328 },
329 329 "resumer": {
330 330 "version": "0.0.0",
331 331 "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz",
332 332 "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=",
333 333 "dev": true,
334 334 "requires": {
335 335 "through": "~2.3.4"
336 336 }
337 337 },
338 338 "sprintf": {
339 339 "version": "0.1.5",
340 340 "resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz",
341 341 "integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=",
342 342 "dev": true
343 343 },
344 344 "string.prototype.trim": {
345 345 "version": "1.1.2",
346 346 "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz",
347 347 "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=",
348 348 "dev": true,
349 349 "requires": {
350 350 "define-properties": "^1.1.2",
351 351 "es-abstract": "^1.5.0",
352 352 "function-bind": "^1.0.2"
353 353 }
354 354 },
355 355 "string_decoder": {
356 356 "version": "0.10.31",
357 "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
357 "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
358 358 "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
359 359 "dev": true
360 360 },
361 361 "tap-parser": {
362 362 "version": "0.4.3",
363 363 "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-0.4.3.tgz",
364 364 "integrity": "sha1-pOrhkMENdsehEZIf84u+TVjwnuo=",
365 365 "dev": true,
366 366 "requires": {
367 367 "inherits": "~2.0.1",
368 368 "readable-stream": "~1.1.11"
369 369 }
370 370 },
371 371 "tape": {
372 372 "version": "4.9.1",
373 373 "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz",
374 374 "integrity": "sha512-6fKIXknLpoe/Jp4rzHKFPpJUHDHDqn8jus99IfPnHIjyz78HYlefTGD3b5EkbQzuLfaEvmfPK3IolLgq2xT3kw==",
375 375 "dev": true,
376 376 "requires": {
377 377 "deep-equal": "~1.0.1",
378 378 "defined": "~1.0.0",
379 379 "for-each": "~0.3.3",
380 380 "function-bind": "~1.1.1",
381 381 "glob": "~7.1.2",
382 382 "has": "~1.0.3",
383 383 "inherits": "~2.0.3",
384 384 "minimist": "~1.2.0",
385 385 "object-inspect": "~1.6.0",
386 386 "resolve": "~1.7.1",
387 387 "resumer": "~0.0.0",
388 388 "string.prototype.trim": "~1.1.2",
389 389 "through": "~2.3.8"
390 390 },
391 391 "dependencies": {
392 392 "deep-equal": {
393 393 "version": "1.0.1",
394 394 "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz",
395 395 "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=",
396 396 "dev": true
397 397 },
398 398 "defined": {
399 399 "version": "1.0.0",
400 400 "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
401 401 "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
402 402 "dev": true
403 403 },
404 404 "minimist": {
405 405 "version": "1.2.0",
406 406 "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
407 407 "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
408 408 "dev": true
409 409 }
410 410 }
411 411 },
412 412 "through": {
413 413 "version": "2.3.8",
414 "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
414 "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
415 415 "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
416 416 "dev": true
417 417 },
418 418 "through2": {
419 419 "version": "0.2.3",
420 "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
420 "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
421 421 "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=",
422 422 "dev": true,
423 423 "requires": {
424 424 "readable-stream": "~1.1.9",
425 425 "xtend": "~2.1.1"
426 426 }
427 427 },
428 428 "typescript": {
429 429 "version": "3.2.1",
430 430 "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.1.tgz",
431 431 "integrity": "sha512-jw7P2z/h6aPT4AENXDGjcfHTu5CSqzsbZc6YlUIebTyBAq8XaKp78x7VcSh30xwSCcsu5irZkYZUSFP1MrAMbg==",
432 432 "dev": true
433 433 },
434 434 "wrappy": {
435 435 "version": "1.0.2",
436 436 "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
437 437 "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
438 438 "dev": true
439 439 },
440 440 "xtend": {
441 441 "version": "2.1.2",
442 442 "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz",
443 443 "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=",
444 444 "dev": true,
445 445 "requires": {
446 446 "object-keys": "~0.4.0"
447 447 }
448 448 }
449 449 }
450 450 }
@@ -1,353 +1,353
1 1 import {
2 2 ServiceRegistration,
3 3 TypeRegistration,
4 4 FactoryRegistration,
5 5 ServiceMap,
6 6 isDescriptor,
7 7 isDependencyRegistration,
8 8 DependencyRegistration,
9 9 ValueRegistration,
10 10 ActivationType,
11 11 isValueRegistration,
12 12 isTypeRegistration,
13 13 isFactoryRegistration
14 14 } from "./interfaces";
15 15
16 16 import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get } from "../safe";
17 17 import { AggregateDescriptor } from "./AggregateDescriptor";
18 18 import { ValueDescriptor } from "./ValueDescriptor";
19 19 import { Container } from "./Container";
20 20 import { ReferenceDescriptor } from "./ReferenceDescriptor";
21 21 import { TypeServiceDescriptor } from "./TypeServiceDescriptor";
22 22 import { FactoryServiceDescriptor } from "./FactoryServiceDescriptor";
23 23 import { rjs, createContextRequire, RequireFn } from "./RequireJsHelper";
24 24 import { TraceSource } from "../log/TraceSource";
25 25 import { ConfigError } from "./ConfigError";
26 26 import { Cancellation } from "../Cancellation";
27 27
28 28 const trace = TraceSource.get("@implab/core/di/Configuration");
29 29
30 30 async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> {
31 31 if (data instanceof Array) {
32 32 return Promise.all(map ? data.map(map) : data);
33 33 } else {
34 34 const keys = Object.keys(data);
35 35
36 36 const o: any = {};
37 37
38 38 await Promise.all(keys.map(async k => {
39 39 const v = map ? map(data[k], k) : data[k];
40 40 o[k] = isPromise(v) ? await v : v;
41 41 }));
42 42
43 43 return o;
44 44 }
45 45 }
46 46
47 47 interface MapOf<T> {
48 48 [key: string]: T;
49 49 }
50 50
51 51 type _key = string | number;
52 52
53 53 export class Configuration {
54 54
55 55 _hasInnerDescriptors = false;
56 56
57 57 _container: Container;
58 58
59 59 _path: Array<_key>;
60 60
61 61 _configName: string;
62 62
63 63 _require = rjs;
64 64
65 65 constructor(container: Container) {
66 66 argumentNotNull(container, container);
67 67 this._container = container;
68 68 this._path = [];
69 69 }
70 70
71 71 async loadConfiguration(moduleName: string, ct = Cancellation.none) {
72 72 argumentNotEmptyString(moduleName, "moduleName");
73 73
74 74 trace.log("loadConfiguration {0}", moduleName);
75 75
76 76 this._configName = moduleName;
77 77
78 78 const config = await this._loadModule(moduleName);
79 79
80 80 this._require = await this._createContextRequire(moduleName);
81 81
82 82 let services: ServiceMap;
83 83
84 84 try {
85 85 services = await this._visitRegistrations(config, moduleName);
86 86 } catch (e) {
87 87 throw this._makeError(e);
88 88 }
89 89
90 90 this._container.register(services);
91 91 }
92 92
93 93 async applyConfiguration(data: object, contextRequire?: RequireFn, ct = Cancellation.none) {
94 94 argumentNotNull(data, "data");
95 95
96 96 trace.log("applyConfiguration");
97 97
98 98 this._configName = "$";
99 99
100 100 if (contextRequire)
101 101 this._require = contextRequire;
102 102
103 103 let services: ServiceMap;
104 104
105 105 try {
106 106 services = await this._visitRegistrations(data, "$");
107 107 } catch (e) {
108 108 throw this._makeError(e);
109 109 }
110 110
111 111 this._container.register(services);
112 112 }
113 113
114 114 _makeError(inner) {
115 115 const e = new ConfigError("Failed to load configuration", inner);
116 116 e.configName = this._configName;
117 117 e.path = this._makePath();
118 118 return e;
119 119 }
120 120
121 121 _makePath() {
122 122 return this._path
123 123 .reduce(
124 124 (prev, cur) => typeof cur === "number" ?
125 125 `${prev}[${cur}]` :
126 126 `${prev}.${cur}`
127 127 )
128 128 .toString();
129 129 }
130 130
131 131 async _resolveType(moduleName: string, localName: string) {
132 132 trace.log("resolveType moduleName={0}, localName={1}", moduleName, localName);
133 133 try {
134 134 const m = await this._loadModule(moduleName);
135 135 return localName ? get(localName, m) : m;
136 136 } catch (e) {
137 137 trace.error("Failed to resolve type moduleName={0}, localName={1}", moduleName, localName);
138 138 throw e;
139 139 }
140 140 }
141 141
142 142 async _loadModule(moduleName: string) {
143 trace.log("loadModule {0}", moduleName);
143 trace.debug("loadModule {0}", moduleName);
144 144
145 145 const m = await new Promise(fulfill => {
146 146 this._require([moduleName], fulfill);
147 147 });
148 148
149 149 return m;
150 150 }
151 151
152 152 _createContextRequire(moduleName: string) {
153 153 return createContextRequire(moduleName);
154 154 }
155 155
156 156 async _visitRegistrations(data, name: _key) {
157 157 this._enter(name);
158 158
159 159 if (data.constructor &&
160 160 data.constructor.prototype !== Object.prototype)
161 161 throw new Error("Configuration must be a simple object");
162 162
163 163 const o: ServiceMap = {};
164 164 const keys = Object.keys(data);
165 165
166 166 const services = await mapAll(data, async (v, k) => {
167 167 const d = await this._visit(v, k);
168 168 return isDescriptor(d) ? d : new AggregateDescriptor(d);
169 169 }) as ServiceMap;
170 170
171 171 this._leave();
172 172
173 173 return services;
174 174 }
175 175
176 176 _enter(name: _key) {
177 177 this._path.push(name);
178 178 trace.debug(">{0}", name);
179 179 }
180 180
181 181 _leave() {
182 182 const name = this._path.pop();
183 183 trace.debug("<{0}", name);
184 184 }
185 185
186 186 async _visit(data, name: string): Promise<any> {
187 187 if (isPrimitive(data) || isDescriptor(data))
188 188 return data;
189 189
190 190 if (isDependencyRegistration(data)) {
191 191 return this._visitDependencyRegistration(data, name);
192 192 } else if (isValueRegistration(data)) {
193 193 return this._visitValueRegistration(data, name);
194 194 } else if (isTypeRegistration(data)) {
195 195 return this._visitTypeRegistration(data, name);
196 196 } else if (isFactoryRegistration(data)) {
197 197 return this._visitFactoryRegistration(data, name);
198 198 } else if (data instanceof Array) {
199 199 return this._visitArray(data, name);
200 200 }
201 201
202 202 return this._visitObject(data, name);
203 203 }
204 204
205 205 async _visitObject(data: object, name: _key) {
206 206 if (data.constructor &&
207 207 data.constructor.prototype !== Object.prototype)
208 208 return new ValueDescriptor(data);
209 209
210 210 this._enter(name);
211 211
212 212 const v = await mapAll(data, delegate(this, "_visit"));
213 213
214 214 // TODO: handle inline descriptors properly
215 215 // const ex = {
216 216 // activate(ctx) {
217 217 // const value = ctx.activate(this.prop, "prop");
218 218 // // some code
219 219 // },
220 220 // // will be turned to ReferenceDescriptor
221 221 // prop: { $dependency: "depName" }
222 222 // };
223 223
224 224 this._leave();
225 225 return v;
226 226 }
227 227
228 228 async _visitArray(data: any[], name: _key) {
229 229 if (data.constructor &&
230 230 data.constructor.prototype !== Array.prototype)
231 231 return new ValueDescriptor(data);
232 232
233 233 this._enter(name);
234 234
235 235 const v = await mapAll(data, delegate(this, "_visit"));
236 236 this._leave();
237 237
238 238 return v;
239 239 }
240 240
241 241 _makeServiceParams(data: ServiceRegistration) {
242 242 const opts: any = {
243 243 owner: this._container
244 244 };
245 245 if (data.services)
246 246 opts.services = this._visitRegistrations(data.services, "services");
247 247
248 248 if (data.inject) {
249 249 this._path.push("inject");
250 250 opts.inject = mapAll(
251 251 data.inject instanceof Array ?
252 252 data.inject :
253 253 [data.inject],
254 254 delegate(this, "_visitObject")
255 255 );
256 256 this._leave();
257 257 }
258 258
259 259 if ("params" in data)
260 260 opts.params = data.params instanceof Array ?
261 261 this._visitArray(data.params, "params") :
262 262 this._visit(data.params, "params");
263 263
264 264 if (data.activation) {
265 265 if (typeof (data.activation) === "string") {
266 266 switch (data.activation.toLowerCase()) {
267 267 case "singleton":
268 268 opts.activation = ActivationType.Singleton;
269 269 break;
270 270 case "container":
271 271 opts.activation = ActivationType.Container;
272 272 break;
273 273 case "hierarchy":
274 274 opts.activation = ActivationType.Hierarchy;
275 275 break;
276 276 case "context":
277 277 opts.activation = ActivationType.Context;
278 278 break;
279 279 case "call":
280 280 opts.activation = ActivationType.Call;
281 281 break;
282 282 default:
283 283 throw new Error("Unknown activation type: " +
284 284 data.activation);
285 285 }
286 286 } else {
287 287 opts.activation = Number(data.activation);
288 288 }
289 289 }
290 290
291 291 if (data.cleanup)
292 292 opts.cleanup = data.cleanup;
293 293
294 294 return opts;
295 295 }
296 296
297 297 async _visitValueRegistration(data: ValueRegistration, name: _key) {
298 298 this._enter(name);
299 299 const d = data.parse ? new AggregateDescriptor(data.$value) : new ValueDescriptor(data.$value);
300 300 this._leave();
301 301 return d;
302 302 }
303 303
304 304 async _visitDependencyRegistration(data: DependencyRegistration, name: _key) {
305 305 argumentNotEmptyString(data && data.$dependency, "data.$dependency");
306 306 this._enter(name);
307 307 const d = new ReferenceDescriptor({
308 308 name: data.$dependency,
309 309 lazy: data.lazy,
310 310 optional: data.optional,
311 311 default: data.default,
312 312 services: data.services && await this._visitRegistrations(data.services, "services")
313 313 });
314 314 this._leave();
315 315 return d;
316 316 }
317 317
318 318 async _visitTypeRegistration(data: TypeRegistration, name: _key) {
319 319 argumentNotNull(data.$type, "data.$type");
320 320 this._enter(name);
321 321
322 322 const opts = this._makeServiceParams(data);
323 323 if (data.$type instanceof Function) {
324 324 opts.type = data.$type;
325 325 } else {
326 326 const [moduleName, typeName] = data.$type.split(":", 2);
327 327 opts.type = this._resolveType(moduleName, typeName);
328 328 }
329 329
330 330 const d = new TypeServiceDescriptor(
331 331 await mapAll(opts)
332 332 );
333 333
334 334 this._leave();
335 335
336 336 return d;
337 337 }
338 338
339 339 async _visitFactoryRegistration(data: FactoryRegistration, name: _key) {
340 340 argumentOfType(data.$factory, Function, "data.$type");
341 341 this._enter(name);
342 342
343 343 const opts = this._makeServiceParams(data);
344 344 opts.factory = opts.$factory;
345 345
346 346 const d = new FactoryServiceDescriptor(
347 347 await mapAll(opts)
348 348 );
349 349
350 350 this._leave();
351 351 return d;
352 352 }
353 353 }
@@ -1,235 +1,234
1 1 import { ActivationContext } from "./ActivationContext";
2 2 import { Descriptor, ActivationType, ServiceMap, isDescriptor } from "./interfaces";
3 3 import { Container } from "./Container";
4 4 import { argumentNotNull, isPrimitive } from "../safe";
5 5 import { TraceSource } from "../log/TraceSource";
6 6
7 7 let cacheId = 0;
8 8
9 9 const trace = TraceSource.get("@implab/core/di/ActivationContext");
10 10
11 11 function injectMethod(target, method, context, args) {
12 12 const m = target[method];
13 13 if (!m)
14 14 throw new Error("Method '" + method + "' not found");
15 15
16 16 if (args instanceof Array)
17 17 return m.apply(target, context.parse(args, "." + method));
18 18 else
19 19 return m.call(target, context.parse(args, "." + method));
20 20 }
21 21
22 22 function makeClenupCallback(target, method: ((instance) => void) | string) {
23 23 if (typeof (method) === "string") {
24 24 return () => {
25 25 target[method]();
26 26 };
27 27 } else {
28 28 return () => {
29 29 method(target);
30 30 };
31 31 }
32 32 }
33 33
34 34 // TODO: make async
35 35 function _parse(value, context: ActivationContext, path: string) {
36 36 if (isPrimitive(value))
37 37 return value;
38 38
39 39 trace.debug("parse {0}", path);
40 40
41 41 if (isDescriptor(value))
42 42 return context.activate(value, path);
43 43
44 44 if (value instanceof Array)
45 45 return value.map((x, i) => _parse(x, context, `${path}[${i}]`));
46 46
47 47 const t = {};
48 48 for (const p of Object.keys(value))
49 49 t[p] = _parse(value[p], context, `${path}.${p}`);
50 50
51 51 return t;
52 52 }
53 53
54 54 export interface ServiceDescriptorParams {
55 55 activation?: ActivationType;
56 56
57 57 owner: Container;
58 58
59 59 params?;
60 60
61 61 inject?: object[];
62 62
63 63 services?: ServiceMap;
64 64
65 65 cleanup?: ((x) => void) | string;
66 66 }
67 67
68 68 export class ServiceDescriptor implements Descriptor {
69 69 _instance;
70 70
71 71 _hasInstance = false;
72 72
73 73 _activationType = ActivationType.Call;
74 74
75 75 _services: ServiceMap;
76 76
77 77 _params;
78 78
79 79 _inject: object[];
80 80
81 81 _cleanup: ((x) => void) | string;
82 82
83 83 _cacheId: any;
84 84
85 85 _owner: Container;
86 86
87 87 constructor(opts: ServiceDescriptorParams) {
88 88 argumentNotNull(opts, "opts");
89 89 argumentNotNull(opts.owner, "owner");
90 90
91 91 this._owner = opts.owner;
92 92
93 93 if (opts.activation)
94 94 this._activationType = opts.activation;
95 95
96 96 if (opts.params)
97 97 this._params = opts.params;
98 98
99 99 if (opts.inject)
100 100 this._inject = opts.inject;
101 101
102 102 if (opts.services)
103 103 this._services = opts.services;
104 104
105 105 if (opts.cleanup) {
106 106 if (!(typeof (opts.cleanup) === "string" || opts.cleanup instanceof Function))
107 107 throw new Error(
108 108 "The cleanup parameter must be either a function or a function name");
109 109
110 110 this._cleanup = opts.cleanup;
111 111 }
112 112 }
113 113
114 114 activate(context: ActivationContext) {
115 115 // if we have a local service records, register them first
116 116 let instance;
117 117
118 118 // ensure we have a cache id
119 119 if (!this._cacheId)
120 120 this._cacheId = ++cacheId;
121 121
122 122 switch (this._activationType) {
123 123 case ActivationType.Singleton: // SINGLETON
124 124 // if the value is cached return it
125 125 if (this._hasInstance)
126 126 return this._instance;
127 127
128 128 // singletons are bound to the root container
129 129 const container = context.container.getRootContainer();
130 130
131 131 if (container.has(this._cacheId)) {
132 132 instance = container.get(this._cacheId);
133 133 } else {
134 134 instance = this._create(context);
135 135 container.store(this._cacheId, instance);
136 136 if (this._cleanup)
137 137 container.onDispose(
138 138 makeClenupCallback(instance, this._cleanup));
139 139 }
140 140
141 141 this._hasInstance = true;
142 142 return (this._instance = instance);
143 143
144 144 case ActivationType.Container: // CONTAINER
145 145 // return a cached value
146 146
147 147 if (this._hasInstance)
148 148 return this._instance;
149 149
150 150 // create an instance
151 151 instance = this._create(context);
152 152
153 153 // the instance is bound to the container
154 154 if (this._cleanup)
155 155 this._owner.onDispose(
156 156 makeClenupCallback(instance, this._cleanup));
157 157
158 158 // cache and return the instance
159 159 this._hasInstance = true;
160 160 return (this._instance = instance);
161 161 case ActivationType.Context: // CONTEXT
162 162 // return a cached value if one exists
163 163
164 164 if (context.has(this._cacheId))
165 165 return context.get(this._cacheId);
166 166 // context context activated instances are controlled by callers
167 167 return context.store(this._cacheId, this._create(context));
168 168 case ActivationType.Call: // CALL
169 169 // per-call created instances are controlled by callers
170 170 return this._create(context);
171 171 case ActivationType.Hierarchy: // HIERARCHY
172 172 // hierarchy activated instances are behave much like container activated
173 173 // except they are created and bound to the child container
174 174
175 175 // return a cached value
176 176 if (context.container.has(this._cacheId))
177 177 return context.container.get(this._cacheId);
178 178
179 179 instance = this._create(context);
180 180
181 181 if (this._cleanup)
182 182 context.container.onDispose(makeClenupCallback(
183 183 instance,
184 184 this._cleanup));
185 185
186 186 return context.container.store(this._cacheId, instance);
187 187 default:
188 188 throw new Error("Invalid activation type: " + this._activationType);
189 189 }
190 190 }
191 191
192 192 isInstanceCreated() {
193 193 return this._hasInstance;
194 194 }
195 195
196 196 getInstance() {
197 197 return this._instance;
198 198 }
199 199
200 200 _factory(...params: any[]): any {
201 201 throw Error("Not implemented");
202 202 }
203 203
204 204 _create(context: ActivationContext) {
205 205 trace.debug(`constructing ${context._name}`);
206 206
207 207 if (this._activationType !== ActivationType.Call &&
208 208 context.visit(this._cacheId) > 0)
209 209 throw new Error("Recursion detected");
210 210
211 211 if (this._services) {
212 212 for (const p in this._services)
213 213 context.register(p, this._services[p]);
214 214 }
215 215
216 216 let instance;
217 217
218 218 if (this._params === undefined) {
219 219 instance = this._factory();
220 220 } else if (this._params instanceof Array) {
221 221 instance = this._factory.apply(this, _parse(this._params, context, "args"));
222 222 } else {
223 223 instance = this._factory(_parse(this._params, context, "args"));
224 224 }
225 225
226 226 if (this._inject) {
227 227 this._inject.forEach(spec => {
228 228 for (const m in spec)
229 229 injectMethod(instance, m, context, spec[m]);
230 230 });
231 231 }
232
233 232 return instance;
234 233 }
235 234 }
@@ -1,36 +1,42
1 1 import { ServiceDescriptor, ServiceDescriptorParams } from "./ServiceDescriptor";
2 2 import { Constructor, Factory } from "../interfaces";
3 3 import { argumentNotNull, isPrimitive } from "../safe";
4 4
5 5 export interface TypeServiceDescriptorParams extends ServiceDescriptorParams {
6 6 type: Constructor;
7 7 }
8 8
9 9 export class TypeServiceDescriptor extends ServiceDescriptor {
10 10 _type: Constructor;
11 11
12 12 constructor(opts: TypeServiceDescriptorParams) {
13 13 super(opts);
14 14 argumentNotNull(opts && opts.type, "opts.type");
15 15
16 16 const ctor = this._type = opts.type;
17 17
18 if (this._params && this._params.length) {
18 if (this._params) {
19 if (this._params.length) {
19 20 this._factory = (...args) => {
20 21 const t = Object.create(ctor.prototype);
21 22 const inst = ctor.apply(t, args);
22 23 return isPrimitive(inst) ? t : inst;
23 24 };
24 25 } else {
26 this._factory = arg => {
27 return new ctor(arg);
28 };
29 }
30 } else {
25 31 this._factory = () => {
26 32 return new ctor();
27 33 };
28 34 }
29 35
30 36 }
31 37
32 38 toString() {
33 39 // @constructor {singleton} foo/bar/Baz
34 40 return ``;
35 41 }
36 42 }
@@ -1,17 +1,20
1 1 define({
2 2 foo: {
3 3 $type: "./Foo:Foo"
4 4 },
5 5
6 6 bar: {
7 7 $type: "./Bar:Bar",
8 8 params: {
9 9 db: {
10 10 provider: {
11 11 $dependency: "db"
12 12 }
13 },
14 foo: {
15 $type: "./Foo:Foo"
13 16 }
14 17 }
15 18 },
16 19 db: "db://localhost"
17 20 }); No newline at end of file
@@ -1,93 +1,94
1 1 import { test, TapeWriter } from "./TestTraits";
2 2 import { Container } from "@implab/core/di/Container";
3 3 import { ReferenceDescriptor } from "@implab/core/di/ReferenceDescriptor";
4 4 import { AggregateDescriptor } from "@implab/core/di/AggregateDescriptor";
5 5 import { ValueDescriptor } from "@implab/core/di/ValueDescriptor";
6 6 import { TraceSource, DebugLevel } from "@implab/core/log/TraceSource";
7 7 import { Foo } from "./mock/Foo";
8 8 import { Bar } from "./mock/Bar";
9 9 import { isNull } from "@implab/core/safe";
10 10
11 11 test("Container register/resolve tests", async t => {
12 12 const container = new Container();
13 13
14 14 const connection1 = "db://localhost";
15 15
16 16 t.throws(
17 17 () => container.register("bla-bla", "bla-bla"),
18 18 "Do not allow to register anything other than descriptors"
19 19 );
20 20
21 21 t.doesNotThrow(
22 22 () => container.register("connection", new ValueDescriptor(connection1)),
23 23 "register ValueDescriptor"
24 24 );
25 25
26 26 t.equals(container.resolve("connection"), connection1, "resolve string value");
27 27
28 28 t.doesNotThrow(
29 29 () => container.register(
30 30 "dbParams",
31 31 new AggregateDescriptor({
32 32 timeout: 10,
33 33 connection: new ReferenceDescriptor({ name: "connection" })
34 34 })
35 35 ),
36 36 "register AggregateDescriptor"
37 37 );
38 38
39 39 const dbParams = container.resolve("dbParams");
40 40 t.equals(dbParams.connection, connection1, "should get string value 'dbParams.connection'");
41 41 });
42 42
43 43 test("Container configure/resolve tests", async t => {
44 44
45 45 const container = new Container();
46 46
47 47 await container.configure({
48 48 foo: {
49 49 $type: Foo
50 50 },
51 51
52 52 box: {
53 53 $type: Bar,
54 54 params: {
55 55 $dependency: "foo"
56 56 }
57 57 },
58 58
59 59 bar: {
60 60 $type: Bar,
61 61 params: {
62 62 db: {
63 63 provider: {
64 64 $dependency: "db"
65 65 }
66 66 }
67 67 }
68 68 }
69 69 });
70 70 t.pass("should configure from js object");
71 71
72 72 const f1 = container.resolve("foo");
73 73
74 74 t.assert(!isNull(f1), "foo should be not null");
75 75
76 76 t.throws(() => container.resolve("bar"), "should not resolve dependency 'db'");
77 77
78 78 });
79 79
80 80 test("Load configuration from module", async t => {
81 81 const container = new Container();
82 82
83 83 await container.configure("test/mock/config1");
84 84 t.pass("The configuration should load");
85 85
86 86 const f1 = container.resolve("foo");
87 87
88 88 t.assert(!isNull(f1), "foo should be not null");
89 89
90 const b1 = container.resolve("bar");
90 const b1 = container.resolve("bar") as Bar;
91 91
92 t.assert(!isNull(b1), "foo should be not null");
92 t.assert(!isNull(b1), "bar should not be null");
93 t.assert(!isNull(b1.foo), "bar.foo should not be null");
93 94 });
@@ -1,3 +1,12
1 import { Foo } from "./Foo";
2
1 3 export class Bar {
2 4 name = "bar";
5
6 foo: Foo;
7
8 constructor(_opts) {
9 if (_opts && _opts.foo)
10 this.foo = _opts.foo;
3 11 }
12 }
General Comments 0
You need to be logged in to leave comments. Login now