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