awilix 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/lib/awilix.browser.js +19 -15
- package/lib/awilix.module.js +1 -1
- package/lib/awilix.umd.js +19 -15
- package/lib/list-modules.d.ts +1 -1
- package/lib/list-modules.js +1 -1
- package/lib/list-modules.js.map +1 -1
- package/package.json +17 -18
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ written in [TypeScript](http://typescriptlang.org). **Make IoC great again!**
|
|
|
47
47
|
- [`container.options`](#containeroptions)
|
|
48
48
|
- [`container.resolve()`](#containerresolve)
|
|
49
49
|
- [`container.register()`](#containerregister)
|
|
50
|
-
- [`container.
|
|
50
|
+
- [`container.hasRegistration()`](#containerhasregistration)
|
|
51
51
|
- [`container.loadModules()`](#containerloadmodules)
|
|
52
52
|
- [`container.createScope()`](#containercreatescope)
|
|
53
53
|
- [`container.build()`](#containerbuild)
|
|
@@ -664,7 +664,7 @@ console.log(container.registrations.awesomeService.injectionMode) // 'CLASSIC'
|
|
|
664
664
|
```
|
|
665
665
|
|
|
666
666
|
Additionally, if we add a `name` field and use `loadModules`, the `name` is used
|
|
667
|
-
for registration.
|
|
667
|
+
for registration (ignoring `formatName` if provided).
|
|
668
668
|
|
|
669
669
|
```diff
|
|
670
670
|
// `RESOLVER` is a Symbol.
|
|
@@ -1042,9 +1042,9 @@ container.register('context', asClass(SessionContext).scoped())
|
|
|
1042
1042
|
**The object syntax, key-value syntax and chaining are valid for all `register`
|
|
1043
1043
|
calls!**
|
|
1044
1044
|
|
|
1045
|
-
### `container.
|
|
1045
|
+
### `container.hasRegistration()`
|
|
1046
1046
|
|
|
1047
|
-
- `container.
|
|
1047
|
+
- `container.hasRegistration(name: string | symbol): boolean`
|
|
1048
1048
|
|
|
1049
1049
|
Determines if the container has a registration with the given name. Also checks ancestor containers.
|
|
1050
1050
|
|
package/lib/awilix.browser.js
CHANGED
|
@@ -68,10 +68,14 @@ function __generator(thisArg, body) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function __spreadArray(to, from) {
|
|
72
|
-
for (var i = 0,
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
function __spreadArray(to, from, pack) {
|
|
72
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
73
|
+
if (ar || !(i in from)) {
|
|
74
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
75
|
+
ar[i] = from[i];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
/**
|
|
@@ -139,7 +143,7 @@ var AwilixTypeError = /** @class */ (function (_super) {
|
|
|
139
143
|
* Name of the given type.
|
|
140
144
|
*/
|
|
141
145
|
function AwilixTypeError(funcDescription, paramName, expectedType, givenType) {
|
|
142
|
-
return _super.call(this, funcDescription
|
|
146
|
+
return _super.call(this, "".concat(funcDescription, ": expected ").concat(paramName, " to be ").concat(expectedType, ", but got ").concat(givenType, ".")) || this;
|
|
143
147
|
}
|
|
144
148
|
/**
|
|
145
149
|
* Asserts the given condition, throws an error otherwise.
|
|
@@ -192,12 +196,12 @@ var AwilixResolutionError = /** @class */ (function (_super) {
|
|
|
192
196
|
});
|
|
193
197
|
resolutionStack.push(name);
|
|
194
198
|
var resolutionPathString = resolutionStack.join(' -> ');
|
|
195
|
-
var msg = "Could not resolve '"
|
|
199
|
+
var msg = "Could not resolve '".concat(name, "'.");
|
|
196
200
|
if (message) {
|
|
197
|
-
msg += " "
|
|
201
|
+
msg += " ".concat(message);
|
|
198
202
|
}
|
|
199
203
|
msg += EOL + EOL;
|
|
200
|
-
msg += "Resolution path: "
|
|
204
|
+
msg += "Resolution path: ".concat(resolutionPathString);
|
|
201
205
|
_this = _super.call(this, msg) || this;
|
|
202
206
|
return _this;
|
|
203
207
|
}
|
|
@@ -700,7 +704,7 @@ function parseParameterList(source) {
|
|
|
700
704
|
*/
|
|
701
705
|
/* istanbul ignore next */
|
|
702
706
|
function unexpected() {
|
|
703
|
-
return new SyntaxError("Parsing parameter list, did not expect "
|
|
707
|
+
return new SyntaxError("Parsing parameter list, did not expect ".concat(t.type, " token").concat(t.value ? " (".concat(t.value, ")") : ''));
|
|
704
708
|
}
|
|
705
709
|
}
|
|
706
710
|
|
|
@@ -862,7 +866,7 @@ function makeOptions(defaults) {
|
|
|
862
866
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
863
867
|
rest[_i - 1] = arguments[_i];
|
|
864
868
|
}
|
|
865
|
-
return Object.assign.apply(Object, __spreadArray([{}, defaults], rest));
|
|
869
|
+
return Object.assign.apply(Object, __spreadArray([{}, defaults], rest, false));
|
|
866
870
|
}
|
|
867
871
|
/**
|
|
868
872
|
* Creates a new resolver with props merged from both.
|
|
@@ -900,7 +904,7 @@ function wrapWithLocals(container, locals) {
|
|
|
900
904
|
*/
|
|
901
905
|
function createInjectorProxy(container, injector) {
|
|
902
906
|
var locals = injector(container);
|
|
903
|
-
var allKeys = uniq(__spreadArray(__spreadArray([], Reflect.ownKeys(container.cradle), true), Reflect.ownKeys(locals)));
|
|
907
|
+
var allKeys = uniq(__spreadArray(__spreadArray([], Reflect.ownKeys(container.cradle), true), Reflect.ownKeys(locals), true));
|
|
904
908
|
// TODO: Lots of duplication here from the container proxy.
|
|
905
909
|
// Need to refactor.
|
|
906
910
|
var proxy = new Proxy({}, {
|
|
@@ -1110,7 +1114,7 @@ function createContainer(options, parentContainer) {
|
|
|
1110
1114
|
* @param {string} name
|
|
1111
1115
|
*/
|
|
1112
1116
|
set: function (_target, name) {
|
|
1113
|
-
throw new Error("Attempted setting property \""
|
|
1117
|
+
throw new Error("Attempted setting property \"".concat(name, "\" on container cradle - this is not allowed."));
|
|
1114
1118
|
},
|
|
1115
1119
|
/**
|
|
1116
1120
|
* Used for `Object.keys`.
|
|
@@ -1171,7 +1175,7 @@ function createContainer(options, parentContainer) {
|
|
|
1171
1175
|
* Used by util.inspect (which is used by console.log).
|
|
1172
1176
|
*/
|
|
1173
1177
|
function inspect() {
|
|
1174
|
-
return "[AwilixContainer ("
|
|
1178
|
+
return "[AwilixContainer (".concat(parentContainer ? 'scoped, ' : '', "registrations: ").concat(Object.keys(container.registrations).length, ")]");
|
|
1175
1179
|
}
|
|
1176
1180
|
/**
|
|
1177
1181
|
* Rolls up registrations from the family tree.
|
|
@@ -1231,7 +1235,7 @@ function createContainer(options, parentContainer) {
|
|
|
1231
1235
|
*/
|
|
1232
1236
|
function register(arg1, arg2) {
|
|
1233
1237
|
var obj = nameValueToObject(arg1, arg2);
|
|
1234
|
-
var keys = __spreadArray(__spreadArray([], Object.keys(obj), true), Object.getOwnPropertySymbols(obj));
|
|
1238
|
+
var keys = __spreadArray(__spreadArray([], Object.keys(obj), true), Object.getOwnPropertySymbols(obj), true);
|
|
1235
1239
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
1236
1240
|
var key = keys_1[_i];
|
|
1237
1241
|
var value = obj[key];
|
|
@@ -1348,7 +1352,7 @@ function createContainer(options, parentContainer) {
|
|
|
1348
1352
|
container.cache.set(name, { resolver: resolver, value: resolved });
|
|
1349
1353
|
break;
|
|
1350
1354
|
default:
|
|
1351
|
-
throw new AwilixResolutionError(name, resolutionStack, "Unknown lifetime \""
|
|
1355
|
+
throw new AwilixResolutionError(name, resolutionStack, "Unknown lifetime \"".concat(resolver.lifetime, "\""));
|
|
1352
1356
|
}
|
|
1353
1357
|
// Pop it from the stack again, ready for the next resolution
|
|
1354
1358
|
resolutionStack.pop();
|
package/lib/awilix.module.js
CHANGED
package/lib/awilix.umd.js
CHANGED
|
@@ -74,10 +74,14 @@
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function __spreadArray(to, from) {
|
|
78
|
-
for (var i = 0,
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
function __spreadArray(to, from, pack) {
|
|
78
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
79
|
+
if (ar || !(i in from)) {
|
|
80
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
81
|
+
ar[i] = from[i];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
/**
|
|
@@ -145,7 +149,7 @@
|
|
|
145
149
|
* Name of the given type.
|
|
146
150
|
*/
|
|
147
151
|
function AwilixTypeError(funcDescription, paramName, expectedType, givenType) {
|
|
148
|
-
return _super.call(this, funcDescription
|
|
152
|
+
return _super.call(this, "".concat(funcDescription, ": expected ").concat(paramName, " to be ").concat(expectedType, ", but got ").concat(givenType, ".")) || this;
|
|
149
153
|
}
|
|
150
154
|
/**
|
|
151
155
|
* Asserts the given condition, throws an error otherwise.
|
|
@@ -198,12 +202,12 @@
|
|
|
198
202
|
});
|
|
199
203
|
resolutionStack.push(name);
|
|
200
204
|
var resolutionPathString = resolutionStack.join(' -> ');
|
|
201
|
-
var msg = "Could not resolve '"
|
|
205
|
+
var msg = "Could not resolve '".concat(name, "'.");
|
|
202
206
|
if (message) {
|
|
203
|
-
msg += " "
|
|
207
|
+
msg += " ".concat(message);
|
|
204
208
|
}
|
|
205
209
|
msg += EOL + EOL;
|
|
206
|
-
msg += "Resolution path: "
|
|
210
|
+
msg += "Resolution path: ".concat(resolutionPathString);
|
|
207
211
|
_this = _super.call(this, msg) || this;
|
|
208
212
|
return _this;
|
|
209
213
|
}
|
|
@@ -706,7 +710,7 @@
|
|
|
706
710
|
*/
|
|
707
711
|
/* istanbul ignore next */
|
|
708
712
|
function unexpected() {
|
|
709
|
-
return new SyntaxError("Parsing parameter list, did not expect "
|
|
713
|
+
return new SyntaxError("Parsing parameter list, did not expect ".concat(t.type, " token").concat(t.value ? " (".concat(t.value, ")") : ''));
|
|
710
714
|
}
|
|
711
715
|
}
|
|
712
716
|
|
|
@@ -868,7 +872,7 @@
|
|
|
868
872
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
869
873
|
rest[_i - 1] = arguments[_i];
|
|
870
874
|
}
|
|
871
|
-
return Object.assign.apply(Object, __spreadArray([{}, defaults], rest));
|
|
875
|
+
return Object.assign.apply(Object, __spreadArray([{}, defaults], rest, false));
|
|
872
876
|
}
|
|
873
877
|
/**
|
|
874
878
|
* Creates a new resolver with props merged from both.
|
|
@@ -906,7 +910,7 @@
|
|
|
906
910
|
*/
|
|
907
911
|
function createInjectorProxy(container, injector) {
|
|
908
912
|
var locals = injector(container);
|
|
909
|
-
var allKeys = uniq(__spreadArray(__spreadArray([], Reflect.ownKeys(container.cradle), true), Reflect.ownKeys(locals)));
|
|
913
|
+
var allKeys = uniq(__spreadArray(__spreadArray([], Reflect.ownKeys(container.cradle), true), Reflect.ownKeys(locals), true));
|
|
910
914
|
// TODO: Lots of duplication here from the container proxy.
|
|
911
915
|
// Need to refactor.
|
|
912
916
|
var proxy = new Proxy({}, {
|
|
@@ -1116,7 +1120,7 @@
|
|
|
1116
1120
|
* @param {string} name
|
|
1117
1121
|
*/
|
|
1118
1122
|
set: function (_target, name) {
|
|
1119
|
-
throw new Error("Attempted setting property \""
|
|
1123
|
+
throw new Error("Attempted setting property \"".concat(name, "\" on container cradle - this is not allowed."));
|
|
1120
1124
|
},
|
|
1121
1125
|
/**
|
|
1122
1126
|
* Used for `Object.keys`.
|
|
@@ -1177,7 +1181,7 @@
|
|
|
1177
1181
|
* Used by util.inspect (which is used by console.log).
|
|
1178
1182
|
*/
|
|
1179
1183
|
function inspect() {
|
|
1180
|
-
return "[AwilixContainer ("
|
|
1184
|
+
return "[AwilixContainer (".concat(parentContainer ? 'scoped, ' : '', "registrations: ").concat(Object.keys(container.registrations).length, ")]");
|
|
1181
1185
|
}
|
|
1182
1186
|
/**
|
|
1183
1187
|
* Rolls up registrations from the family tree.
|
|
@@ -1237,7 +1241,7 @@
|
|
|
1237
1241
|
*/
|
|
1238
1242
|
function register(arg1, arg2) {
|
|
1239
1243
|
var obj = nameValueToObject(arg1, arg2);
|
|
1240
|
-
var keys = __spreadArray(__spreadArray([], Object.keys(obj), true), Object.getOwnPropertySymbols(obj));
|
|
1244
|
+
var keys = __spreadArray(__spreadArray([], Object.keys(obj), true), Object.getOwnPropertySymbols(obj), true);
|
|
1241
1245
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
1242
1246
|
var key = keys_1[_i];
|
|
1243
1247
|
var value = obj[key];
|
|
@@ -1354,7 +1358,7 @@
|
|
|
1354
1358
|
container.cache.set(name, { resolver: resolver, value: resolved });
|
|
1355
1359
|
break;
|
|
1356
1360
|
default:
|
|
1357
|
-
throw new AwilixResolutionError(name, resolutionStack, "Unknown lifetime \""
|
|
1361
|
+
throw new AwilixResolutionError(name, resolutionStack, "Unknown lifetime \"".concat(resolver.lifetime, "\""));
|
|
1358
1362
|
}
|
|
1359
1363
|
// Pop it from the stack again, ready for the next resolution
|
|
1360
1364
|
resolutionStack.pop();
|
package/lib/list-modules.d.ts
CHANGED
package/lib/list-modules.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listModules = void 0;
|
|
4
|
-
const glob = require("glob");
|
|
4
|
+
const glob = require("fast-glob");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
// Regex to extract the module name.
|
package/lib/list-modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-modules.js","sourceRoot":"","sources":["../src/list-modules.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"list-modules.js","sourceRoot":"","sources":["../src/list-modules.ts"],"names":[],"mappings":";;;AAAA,kCAAiC;AACjC,6BAA4B;AAC5B,mCAAiC;A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,CAAC;AATD,kCASC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "awilix",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Extremely powerful dependency injection container.",
|
|
5
5
|
"main": "lib/awilix.js",
|
|
6
6
|
"module": "lib/awilix.module.js",
|
|
@@ -50,39 +50,38 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/jeffijoe/awilix#readme",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@babel/core": "^7.16.
|
|
54
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
55
|
-
"@babel/preset-env": "^7.16.
|
|
56
|
-
"@babel/runtime": "^7.16.
|
|
57
|
-
"@types/
|
|
58
|
-
"@types/
|
|
59
|
-
"@types/
|
|
60
|
-
"
|
|
61
|
-
"babel-jest": "^27.3.1",
|
|
53
|
+
"@babel/core": "^7.16.12",
|
|
54
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
55
|
+
"@babel/preset-env": "^7.16.11",
|
|
56
|
+
"@babel/runtime": "^7.16.7",
|
|
57
|
+
"@types/jest": "^27.4.0",
|
|
58
|
+
"@types/node": "^17.0.13",
|
|
59
|
+
"@types/prettier": "^2.4.3",
|
|
60
|
+
"babel-jest": "^27.4.6",
|
|
62
61
|
"coveralls": "^3.1.1",
|
|
63
62
|
"husky": "^7.0.4",
|
|
64
63
|
"istanbul": "^0.4.5",
|
|
65
|
-
"jest": "^27.
|
|
66
|
-
"lint-staged": "^
|
|
67
|
-
"prettier": "^2.
|
|
64
|
+
"jest": "^27.4.7",
|
|
65
|
+
"lint-staged": "^12.3.2",
|
|
66
|
+
"prettier": "^2.5.1",
|
|
68
67
|
"rimraf": "^3.0.2",
|
|
69
|
-
"rollup": "^2.
|
|
68
|
+
"rollup": "^2.66.1",
|
|
70
69
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
71
70
|
"rollup-plugin-copy": "^3.4.0",
|
|
72
71
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
73
72
|
"rollup-plugin-replace": "^2.2.0",
|
|
74
|
-
"rollup-plugin-typescript2": "^0.
|
|
73
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
|
75
74
|
"smid": "^0.1.1",
|
|
76
|
-
"ts-jest": "^27.
|
|
75
|
+
"ts-jest": "^27.1.3",
|
|
77
76
|
"tslib": "^2.3.1",
|
|
78
77
|
"tslint": "^6.1.3",
|
|
79
78
|
"tslint-config-prettier": "^1.18.0",
|
|
80
79
|
"tslint-config-standard": "^9.0.0",
|
|
81
|
-
"typescript": "^4.
|
|
80
|
+
"typescript": "^4.5.5"
|
|
82
81
|
},
|
|
83
82
|
"dependencies": {
|
|
84
83
|
"camel-case": "^4.1.2",
|
|
85
|
-
"glob": "^
|
|
84
|
+
"fast-glob": "^3.2.11"
|
|
86
85
|
},
|
|
87
86
|
"lint-staged": {
|
|
88
87
|
"*.ts": [
|