mesh-ioc 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/out/main/decorators/service.d.ts +1 -1
- package/out/main/decorators/service.js +3 -3
- package/out/main/index.d.ts +0 -1
- package/out/main/index.js +0 -1
- package/out/main/mesh.d.ts +1 -1
- package/out/main/mesh.js +3 -4
- package/package.json +1 -1
- package/out/main/bindings.d.ts +0 -14
- package/out/main/bindings.js +0 -2
- package/out/main/decorators.d.ts +0 -5
- package/out/main/decorators.js +0 -34
- package/out/main/metadata.d.ts +0 -7
- package/out/main/metadata.js +0 -4
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Mesh IoC solves the problem of dependency management of application services. It
|
|
|
6
6
|
|
|
7
7
|
## Key features
|
|
8
8
|
|
|
9
|
-
- 👗 Very slim — about
|
|
9
|
+
- 👗 Very slim — about 2KB minified, few hundred bytes gzipped
|
|
10
10
|
- ⚡️ Blazing fast
|
|
11
11
|
- 🧩 Flexible and composable
|
|
12
12
|
- 🌿 Ergonomic
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.service = exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.service = exports.serviceMetadata = void 0;
|
|
4
|
+
exports.serviceMetadata = [];
|
|
5
5
|
function service(options = {}) {
|
|
6
6
|
return function (target) {
|
|
7
|
-
exports.
|
|
7
|
+
exports.serviceMetadata.push(Object.assign({ class: target }, options));
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
exports.service = service;
|
package/out/main/index.d.ts
CHANGED
package/out/main/index.js
CHANGED
|
@@ -11,7 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./decorators/dep"), exports);
|
|
14
|
-
__exportStar(require("./decorators/service"), exports);
|
|
15
14
|
__exportStar(require("./errors"), exports);
|
|
16
15
|
__exportStar(require("./mesh"), exports);
|
|
17
16
|
__exportStar(require("./scope"), exports);
|
package/out/main/mesh.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class Mesh {
|
|
|
8
8
|
childScopes: Map<string, Scope>;
|
|
9
9
|
instances: Map<string, any>;
|
|
10
10
|
middlewares: Middleware[];
|
|
11
|
-
constructor(name?: string, parent?: Mesh | undefined);
|
|
11
|
+
constructor(name?: string, parent?: Mesh | undefined, scope?: Scope);
|
|
12
12
|
service<T>(impl: ServiceConstructor<T>): this;
|
|
13
13
|
service<T>(key: AbstractClass<T> | string, impl: ServiceConstructor<T>): this;
|
|
14
14
|
constant<T>(key: ServiceKey<T>, value: T): this;
|
package/out/main/mesh.js
CHANGED
|
@@ -6,13 +6,13 @@ const scope_1 = require("./scope");
|
|
|
6
6
|
const util_1 = require("./util");
|
|
7
7
|
exports.MESH_REF = Symbol.for('MESH_REF');
|
|
8
8
|
class Mesh {
|
|
9
|
-
constructor(name = 'default', parent = undefined) {
|
|
9
|
+
constructor(name = 'default', parent = undefined, scope) {
|
|
10
10
|
this.name = name;
|
|
11
11
|
this.parent = parent;
|
|
12
12
|
this.childScopes = new Map();
|
|
13
13
|
this.instances = new Map();
|
|
14
14
|
this.middlewares = [];
|
|
15
|
-
this.currentScope = new scope_1.Scope(name);
|
|
15
|
+
this.currentScope = scope !== null && scope !== void 0 ? scope : new scope_1.Scope(name);
|
|
16
16
|
this.currentScope.constant('Mesh', this);
|
|
17
17
|
}
|
|
18
18
|
service(key, impl) {
|
|
@@ -65,8 +65,7 @@ class Mesh {
|
|
|
65
65
|
createScope(scopeId, scopeName = scopeId) {
|
|
66
66
|
const childScope = this.childScopes.get(scopeId);
|
|
67
67
|
const newScope = new scope_1.Scope(scopeName, childScope !== null && childScope !== void 0 ? childScope : []);
|
|
68
|
-
const mesh = new Mesh(scopeId, this);
|
|
69
|
-
mesh.currentScope = newScope;
|
|
68
|
+
const mesh = new Mesh(scopeId, this, newScope);
|
|
70
69
|
return mesh;
|
|
71
70
|
}
|
|
72
71
|
instantiate(binding) {
|
package/package.json
CHANGED
package/out/main/bindings.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ServiceConstructor } from './types';
|
|
2
|
-
export declare type Binding<T> = ConstantBinding<T> | ServiceBinding<T> | AliasBinding;
|
|
3
|
-
export declare type ConstantBinding<T> = {
|
|
4
|
-
type: 'constant';
|
|
5
|
-
value: T;
|
|
6
|
-
};
|
|
7
|
-
export declare type ServiceBinding<T> = {
|
|
8
|
-
type: 'service';
|
|
9
|
-
class: ServiceConstructor<T>;
|
|
10
|
-
};
|
|
11
|
-
export declare type AliasBinding = {
|
|
12
|
-
type: 'alias';
|
|
13
|
-
key: string;
|
|
14
|
-
};
|
package/out/main/bindings.js
DELETED
package/out/main/decorators.d.ts
DELETED
package/out/main/decorators.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dep = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const errors_1 = require("./errors");
|
|
6
|
-
const mesh_1 = require("./mesh");
|
|
7
|
-
const metadata_1 = require("./metadata");
|
|
8
|
-
function dep(options = {}) {
|
|
9
|
-
return function (target, propertyName) {
|
|
10
|
-
var _a;
|
|
11
|
-
const className = target.constructor.name;
|
|
12
|
-
const designType = Reflect.getMetadata('design:type', target, propertyName);
|
|
13
|
-
const key = (_a = options.key) !== null && _a !== void 0 ? _a : designType === null || designType === void 0 ? void 0 : designType.name;
|
|
14
|
-
if (!key) {
|
|
15
|
-
throw new errors_1.DepKeyNotInferred(className, propertyName);
|
|
16
|
-
}
|
|
17
|
-
metadata_1.depMetadata.push({
|
|
18
|
-
className,
|
|
19
|
-
propertyName,
|
|
20
|
-
designTypeName: designType.name,
|
|
21
|
-
key,
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(target, propertyName, {
|
|
24
|
-
get() {
|
|
25
|
-
const mesh = this[mesh_1.MESH_REF];
|
|
26
|
-
if (!mesh) {
|
|
27
|
-
throw new errors_1.DepInstanceNotConnected(className, propertyName);
|
|
28
|
-
}
|
|
29
|
-
return mesh.resolve(key);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.dep = dep;
|
package/out/main/metadata.d.ts
DELETED
package/out/main/metadata.js
DELETED