@noego/ioc 0.0.5 → 0.0.6
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/dist/cjs/framework/decorators/Component.d.ts +10 -0
- package/dist/cjs/framework/decorators/Component.js +25 -0
- package/dist/cjs/framework/decorators/Component.js.map +1 -0
- package/dist/cjs/framework/decorators/Inject.d.ts +7 -0
- package/dist/cjs/framework/decorators/Inject.js +22 -0
- package/dist/cjs/framework/decorators/Inject.js.map +1 -0
- package/dist/cjs/framework/decorators/index.d.ts +3 -0
- package/dist/cjs/framework/decorators/index.js +24 -0
- package/dist/cjs/framework/decorators/index.js.map +1 -0
- package/dist/cjs/framework/decorators/metadataKeys.d.ts +3 -0
- package/dist/cjs/framework/decorators/metadataKeys.js +8 -0
- package/dist/cjs/framework/decorators/metadataKeys.js.map +1 -0
- package/dist/cjs/framework/errors/ContainerErrors.d.ts +33 -0
- package/dist/cjs/framework/errors/ContainerErrors.js +52 -0
- package/dist/cjs/framework/errors/ContainerErrors.js.map +1 -0
- package/dist/cjs/framework/implementation/Container.d.ts +31 -0
- package/dist/cjs/framework/implementation/Container.js +448 -0
- package/dist/cjs/framework/implementation/Container.js.map +1 -0
- package/dist/cjs/framework/implementation/Container.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/Container.test.js +184 -0
- package/dist/cjs/framework/implementation/Container.test.js.map +1 -0
- package/dist/cjs/framework/implementation/ContainerAsync.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/ContainerAsync.test.js +178 -0
- package/dist/cjs/framework/implementation/ContainerAsync.test.js.map +1 -0
- package/dist/cjs/framework/implementation/ContainerBasic.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/ContainerBasic.test.js +101 -0
- package/dist/cjs/framework/implementation/ContainerBasic.test.js.map +1 -0
- package/dist/cjs/framework/implementation/ContainerDecorators.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/ContainerDecorators.test.js +517 -0
- package/dist/cjs/framework/implementation/ContainerDecorators.test.js.map +1 -0
- package/dist/cjs/framework/implementation/ContainerExtension.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/ContainerExtension.test.js +169 -0
- package/dist/cjs/framework/implementation/ContainerExtension.test.js.map +1 -0
- package/dist/cjs/framework/implementation/ContainerLifetimes.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/ContainerLifetimes.test.js +154 -0
- package/dist/cjs/framework/implementation/ContainerLifetimes.test.js.map +1 -0
- package/dist/cjs/framework/implementation/DecoratorSupport.d.ts +31 -0
- package/dist/cjs/framework/implementation/DecoratorSupport.js +96 -0
- package/dist/cjs/framework/implementation/DecoratorSupport.js.map +1 -0
- package/dist/cjs/framework/implementation/LoadAs.d.ts +5 -0
- package/dist/cjs/framework/implementation/LoadAs.js +10 -0
- package/dist/cjs/framework/implementation/LoadAs.js.map +1 -0
- package/dist/cjs/framework/implementation/Parameter.d.ts +33 -0
- package/dist/cjs/framework/implementation/Parameter.js +87 -0
- package/dist/cjs/framework/implementation/Parameter.js.map +1 -0
- package/dist/cjs/framework/implementation/Parameter.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/Parameter.test.js +19 -0
- package/dist/cjs/framework/implementation/Parameter.test.js.map +1 -0
- package/dist/cjs/framework/implementation/SimpleDecoratorTest.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/SimpleDecoratorTest.test.js +78 -0
- package/dist/cjs/framework/implementation/SimpleDecoratorTest.test.js.map +1 -0
- package/dist/cjs/framework/implementation/SingletonTest.test.d.ts +1 -0
- package/dist/cjs/framework/implementation/SingletonTest.test.js +85 -0
- package/dist/cjs/framework/implementation/SingletonTest.test.js.map +1 -0
- package/dist/cjs/framework/interface/Container.d.ts +22 -0
- package/dist/cjs/framework/interface/Container.js +3 -0
- package/dist/cjs/framework/interface/Container.js.map +1 -0
- package/dist/esm/framework/decorators/Component.d.ts +10 -0
- package/dist/esm/framework/decorators/Component.js +21 -0
- package/dist/esm/framework/decorators/Component.js.map +1 -0
- package/dist/esm/framework/decorators/Inject.d.ts +7 -0
- package/dist/esm/framework/decorators/Inject.js +19 -0
- package/dist/esm/framework/decorators/Inject.js.map +1 -0
- package/dist/esm/framework/decorators/index.d.ts +3 -0
- package/dist/esm/framework/decorators/index.js +5 -0
- package/dist/esm/framework/decorators/index.js.map +1 -0
- package/dist/esm/framework/decorators/metadataKeys.d.ts +3 -0
- package/dist/esm/framework/decorators/metadataKeys.js +5 -0
- package/dist/esm/framework/decorators/metadataKeys.js.map +1 -0
- package/dist/esm/framework/errors/ContainerErrors.d.ts +33 -0
- package/dist/esm/framework/errors/ContainerErrors.js +44 -0
- package/dist/esm/framework/errors/ContainerErrors.js.map +1 -0
- package/dist/esm/framework/implementation/Container.d.ts +31 -0
- package/dist/esm/framework/implementation/Container.js +432 -0
- package/dist/esm/framework/implementation/Container.js.map +1 -0
- package/dist/esm/framework/implementation/Container.test.d.ts +1 -0
- package/dist/esm/framework/implementation/Container.test.js +173 -0
- package/dist/esm/framework/implementation/Container.test.js.map +1 -0
- package/dist/esm/framework/implementation/ContainerAsync.test.d.ts +1 -0
- package/dist/esm/framework/implementation/ContainerAsync.test.js +151 -0
- package/dist/esm/framework/implementation/ContainerAsync.test.js.map +1 -0
- package/dist/esm/framework/implementation/ContainerBasic.test.d.ts +1 -0
- package/dist/esm/framework/implementation/ContainerBasic.test.js +90 -0
- package/dist/esm/framework/implementation/ContainerBasic.test.js.map +1 -0
- package/dist/esm/framework/implementation/ContainerDecorators.test.d.ts +1 -0
- package/dist/esm/framework/implementation/ContainerDecorators.test.js +498 -0
- package/dist/esm/framework/implementation/ContainerDecorators.test.js.map +1 -0
- package/dist/esm/framework/implementation/ContainerExtension.test.d.ts +1 -0
- package/dist/esm/framework/implementation/ContainerExtension.test.js +158 -0
- package/dist/esm/framework/implementation/ContainerExtension.test.js.map +1 -0
- package/dist/esm/framework/implementation/ContainerLifetimes.test.d.ts +1 -0
- package/dist/esm/framework/implementation/ContainerLifetimes.test.js +143 -0
- package/dist/esm/framework/implementation/ContainerLifetimes.test.js.map +1 -0
- package/dist/esm/framework/implementation/DecoratorSupport.d.ts +31 -0
- package/dist/esm/framework/implementation/DecoratorSupport.js +87 -0
- package/dist/esm/framework/implementation/DecoratorSupport.js.map +1 -0
- package/dist/esm/framework/implementation/LoadAs.d.ts +5 -0
- package/dist/esm/framework/implementation/LoadAs.js +7 -0
- package/dist/esm/framework/implementation/LoadAs.js.map +1 -0
- package/dist/esm/framework/implementation/Parameter.d.ts +33 -0
- package/dist/esm/framework/implementation/Parameter.js +49 -0
- package/dist/esm/framework/implementation/Parameter.js.map +1 -0
- package/dist/esm/framework/implementation/Parameter.test.d.ts +1 -0
- package/dist/esm/framework/implementation/Parameter.test.js +17 -0
- package/dist/esm/framework/implementation/Parameter.test.js.map +1 -0
- package/dist/esm/framework/implementation/SimpleDecoratorTest.test.d.ts +1 -0
- package/dist/esm/framework/implementation/SimpleDecoratorTest.test.js +67 -0
- package/dist/esm/framework/implementation/SimpleDecoratorTest.test.js.map +1 -0
- package/dist/esm/framework/implementation/SingletonTest.test.d.ts +1 -0
- package/dist/esm/framework/implementation/SingletonTest.test.js +74 -0
- package/dist/esm/framework/implementation/SingletonTest.test.js.map +1 -0
- package/dist/esm/framework/interface/Container.d.ts +22 -0
- package/dist/esm/framework/interface/Container.js +2 -0
- package/dist/esm/framework/interface/Container.js.map +1 -0
- package/package.json +10 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
// SimpleDecoratorTest.test.ts
|
|
8
|
+
import 'reflect-metadata';
|
|
9
|
+
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
10
|
+
import { createContainer } from "./Container";
|
|
11
|
+
import { Component } from '../decorators/Component';
|
|
12
|
+
import { LoadAs } from "./LoadAs";
|
|
13
|
+
describe('Simple Decorator Test', () => {
|
|
14
|
+
let container;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
container = createContainer();
|
|
17
|
+
});
|
|
18
|
+
it('should correctly apply and read decorator metadata', () => {
|
|
19
|
+
let TestClass = class TestClass {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.value = Math.random();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
TestClass = __decorate([
|
|
25
|
+
Component({ scope: LoadAs.Singleton })
|
|
26
|
+
], TestClass);
|
|
27
|
+
// Check metadata is correctly set
|
|
28
|
+
const metadata = Reflect.getMetadata('ComponentOptions', TestClass);
|
|
29
|
+
console.log('Metadata:', metadata);
|
|
30
|
+
expect(metadata).toBeDefined();
|
|
31
|
+
expect(metadata.scope).toBe(LoadAs.Singleton);
|
|
32
|
+
});
|
|
33
|
+
it('should respect singleton scope', async () => {
|
|
34
|
+
class TestSingleton {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.value = Math.random();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Register with explicit singleton scope
|
|
40
|
+
container.registerClass(TestSingleton, { loadAs: LoadAs.Singleton });
|
|
41
|
+
// Get two instances
|
|
42
|
+
const instance1 = await container.instance(TestSingleton);
|
|
43
|
+
const instance2 = await container.instance(TestSingleton);
|
|
44
|
+
// Should be singleton
|
|
45
|
+
expect(instance1).toBe(instance2);
|
|
46
|
+
expect(instance1.value).toBe(instance2.value);
|
|
47
|
+
});
|
|
48
|
+
it('should respect scoped lifetime', async () => {
|
|
49
|
+
class TestScoped {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.value = Math.random();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Register with explicit scoped lifetime
|
|
55
|
+
container.registerClass(TestScoped, { loadAs: LoadAs.Scoped });
|
|
56
|
+
// Get two instances from same container
|
|
57
|
+
const instance1 = await container.instance(TestScoped);
|
|
58
|
+
const instance2 = await container.instance(TestScoped);
|
|
59
|
+
// Same container = same instance
|
|
60
|
+
expect(instance1).toBe(instance2);
|
|
61
|
+
// Different container = different instance
|
|
62
|
+
const childContainer = container.extend();
|
|
63
|
+
const instance3 = await childContainer.instance(TestScoped);
|
|
64
|
+
expect(instance1).not.toBe(instance3);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=SimpleDecoratorTest.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleDecoratorTest.test.js","sourceRoot":"","sources":["../../../../framework/implementation/SimpleDecoratorTest.test.ts"],"names":[],"mappings":";;;;;;AAAA,8BAA8B;AAC9B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACnC,IAAI,SAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACZ,SAAS,GAAG,eAAe,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAE1D,IAAM,SAAS,GAAf,MAAM,SAAS;YAAf;gBACI,UAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,CAAC;SAAA,CAAA;QAFK,SAAS;YADd,SAAS,CAAC,EAA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,MAAM,EAAE,CAAC,CAAC;QAE/D,wCAAwC;QACxC,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACvD,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEvD,iCAAiC;QACjC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAElC,2CAA2C;QAC3C,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
// SingletonTest.test.ts - Minimal test for singleton functionality
|
|
8
|
+
import 'reflect-metadata';
|
|
9
|
+
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
10
|
+
import { createContainer } from "./Container";
|
|
11
|
+
import { Component } from '../decorators/Component';
|
|
12
|
+
import { LoadAs } from "./LoadAs";
|
|
13
|
+
describe('Singleton and Decorator Test', () => {
|
|
14
|
+
let container;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
container = createContainer();
|
|
17
|
+
});
|
|
18
|
+
it('should handle singleton with manual registration', async () => {
|
|
19
|
+
class TestService {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.value = Math.random();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Register with manual singleton option
|
|
25
|
+
container.registerClass(TestService, { loadAs: LoadAs.Singleton });
|
|
26
|
+
// Get two instances
|
|
27
|
+
const instance1 = await container.instance(TestService);
|
|
28
|
+
const instance2 = await container.instance(TestService);
|
|
29
|
+
// Should be same instance
|
|
30
|
+
expect(instance1).toBe(instance2);
|
|
31
|
+
});
|
|
32
|
+
it('should maintain scoped instances within same container', async () => {
|
|
33
|
+
class ScopedService {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.value = Math.random();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Register with manual scoped option
|
|
39
|
+
container.registerClass(ScopedService, { loadAs: LoadAs.Scoped });
|
|
40
|
+
// Get two instances from same container
|
|
41
|
+
const instance1 = await container.instance(ScopedService);
|
|
42
|
+
const instance2 = await container.instance(ScopedService);
|
|
43
|
+
// Should be same instance within same container
|
|
44
|
+
expect(instance1).toBe(instance2);
|
|
45
|
+
});
|
|
46
|
+
it('should handle singleton with decorator', async () => {
|
|
47
|
+
let SingletonWithDecorator = class SingletonWithDecorator {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.value = Math.random();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
SingletonWithDecorator = __decorate([
|
|
53
|
+
Component({ scope: LoadAs.Singleton })
|
|
54
|
+
], SingletonWithDecorator);
|
|
55
|
+
// Check metadata - try both string and symbol keys
|
|
56
|
+
const metadataSymbol = Reflect.getMetadata(Symbol('ioc:component:options'), SingletonWithDecorator);
|
|
57
|
+
const metadataString = Reflect.getMetadata('ComponentOptions', SingletonWithDecorator);
|
|
58
|
+
console.log('Metadata keys:', Reflect.getMetadataKeys(SingletonWithDecorator));
|
|
59
|
+
console.log('Metadata for SingletonWithDecorator (symbol):', metadataSymbol);
|
|
60
|
+
console.log('Metadata for SingletonWithDecorator (string):', metadataString);
|
|
61
|
+
// Manual registration with singleton scope
|
|
62
|
+
container.registerClass(SingletonWithDecorator, { loadAs: LoadAs.Singleton });
|
|
63
|
+
// Get two instances
|
|
64
|
+
const instance1 = await container.instance(SingletonWithDecorator);
|
|
65
|
+
const instance2 = await container.instance(SingletonWithDecorator);
|
|
66
|
+
// Log instance details
|
|
67
|
+
console.log('Instance 1:', instance1);
|
|
68
|
+
console.log('Instance 2:', instance2);
|
|
69
|
+
console.log('Same instance?', instance1 === instance2);
|
|
70
|
+
// Should be same instance
|
|
71
|
+
expect(instance1).toBe(instance2);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=SingletonTest.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingletonTest.test.js","sourceRoot":"","sources":["../../../../framework/implementation/SingletonTest.test.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAmE;AACnE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,IAAI,SAAqB,CAAC;IAE1B,UAAU,CAAC,GAAG,EAAE;QACZ,SAAS,GAAG,eAAe,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,WAAW;YAAjB;gBACI,UAAK,GAAG,IAAI,CAAC,MAAM,EAA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Ac,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,sBAAsB,CAAC,CAAC;QACpG,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;QAEvF,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,cAAc,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,cAAc,CAAC,CAAC;QAE7E,2CAA2C;QAC3C,SAAS,CAAC,aAAa,CAAC,sBAAsB,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAE9E,oBAAoB;QACpB,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;QAEnE,uBAAuB;QACvB,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC;QAEvD,0BAA0B;QAC1B,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ParameterValue } from "../implementation/Parameter";
|
|
2
|
+
import { LoadAs } from "../implementation/LoadAs";
|
|
3
|
+
export interface IContainerClient {
|
|
4
|
+
instance<T, Args extends any[]>(classDefinition: new (...args: Args) => T, params?: ParameterValue<any>[]): Promise<T>;
|
|
5
|
+
get<T>(label: any, param?: ParameterValue<any>[]): Promise<T> | T;
|
|
6
|
+
extend(): IContainerClient;
|
|
7
|
+
}
|
|
8
|
+
export interface IContainerSetup {
|
|
9
|
+
registerClass<T, Args extends any[]>(classDefinition: {
|
|
10
|
+
new (...args: Args): T;
|
|
11
|
+
}, options?: Partial<ContainerOptions>): void;
|
|
12
|
+
registerFunction<T extends (...arg: any[]) => any>(label: any, func: T, options?: ContainerOptions): void;
|
|
13
|
+
}
|
|
14
|
+
export type IContainer = IContainerClient & IContainerSetup;
|
|
15
|
+
export type ContainerOptions = {
|
|
16
|
+
param?: any[];
|
|
17
|
+
loadAs?: LoadAs;
|
|
18
|
+
};
|
|
19
|
+
export interface IContainerFunctionDefinition {
|
|
20
|
+
function: Function;
|
|
21
|
+
options: Partial<ContainerOptions>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../../framework/interface/Container.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noego/ioc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A self contained IoC container for Node.js",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -18,9 +18,18 @@
|
|
|
18
18
|
"require": "./dist/cjs/index.js",
|
|
19
19
|
"import": "./dist/esm/index.js"
|
|
20
20
|
},
|
|
21
|
+
"./*": {
|
|
22
|
+
"types": "./dist/esm/*.d.ts",
|
|
23
|
+
"require": "./dist/cjs/*.js",
|
|
24
|
+
"import": "./dist/esm/*.js"
|
|
25
|
+
},
|
|
21
26
|
"./package.json": "./package.json",
|
|
22
27
|
"./readme.md": "./readme.md"
|
|
23
28
|
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"readme.md"
|
|
32
|
+
],
|
|
24
33
|
"author": "Shavauhn Gabay",
|
|
25
34
|
"license": "ISC",
|
|
26
35
|
"publishConfig": {
|