@stone-js/service-container 0.0.41
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/LICENSE +201 -0
- package/README.md +340 -0
- package/dist/Container.d.ts +178 -0
- package/dist/Proxiable.d.ts +16 -0
- package/dist/declarations.d.ts +45 -0
- package/dist/errors/ContainerError.d.ts +62 -0
- package/dist/index.js +573 -0
- package/dist/models/Binding.d.ts +41 -0
- package/dist/models/Factory.d.ts +25 -0
- package/dist/models/Instance.d.ts +21 -0
- package/dist/models/ResolverBinding.d.ts +26 -0
- package/dist/models/Singleton.d.ts +25 -0
- package/package.json +90 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Container } from '../Container';
|
|
2
|
+
import { BindingValue } from '../declarations';
|
|
3
|
+
import { ResolverBinding } from './ResolverBinding';
|
|
4
|
+
/**
|
|
5
|
+
* Class representing a Singleton.
|
|
6
|
+
*
|
|
7
|
+
* The Singleton class extends the ResolverBinding class, ensuring that the value is only resolved once.
|
|
8
|
+
* Subsequent calls to the `resolve` method will return the previously resolved value, making it behave as a singleton.
|
|
9
|
+
*
|
|
10
|
+
* @template V - The type of value that this binding holds.
|
|
11
|
+
* @author Mr. Stone <evensstone@gmail.com>
|
|
12
|
+
*/
|
|
13
|
+
export declare class Singleton<V extends BindingValue> extends ResolverBinding<V> {
|
|
14
|
+
/**
|
|
15
|
+
* Resolve and return the value of the binding.
|
|
16
|
+
*
|
|
17
|
+
* If the value has already been resolved, return the cached value. Otherwise, use the resolver function
|
|
18
|
+
* to resolve the value, store it, and return it.
|
|
19
|
+
*
|
|
20
|
+
* @param container - The container to resolve dependencies from.
|
|
21
|
+
* @returns The resolved value of the binding.
|
|
22
|
+
* @throws ContainerError if the value cannot be resolved.
|
|
23
|
+
*/
|
|
24
|
+
resolve(container: Container): V | undefined;
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stone-js/service-container",
|
|
3
|
+
"version": "0.0.41",
|
|
4
|
+
"description": "Vanilla Javascript IoC Service Container with proposal decorator, proxy resolver and destructuring injection",
|
|
5
|
+
"author": "Mr. Stone <evensstone@gmail.com>",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": "git@github.com:stonemjs/service-container.git",
|
|
8
|
+
"homepage": "https://github.com/stonemjs/service-container#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/stonemjs/service-container/issues"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"DI",
|
|
14
|
+
"IoC",
|
|
15
|
+
"StoneJS",
|
|
16
|
+
"Service",
|
|
17
|
+
"Factory",
|
|
18
|
+
"Provider",
|
|
19
|
+
"Injector",
|
|
20
|
+
"Container",
|
|
21
|
+
"Injection",
|
|
22
|
+
"Singleton"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"/dist"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": [
|
|
31
|
+
"./dist/declarations.d.ts",
|
|
32
|
+
"./dist/Container.d.ts"
|
|
33
|
+
],
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"lint": "ts-standard src",
|
|
42
|
+
"lint:fix": "ts-standard --fix src tests",
|
|
43
|
+
"predoc": "rimraf docs",
|
|
44
|
+
"doc": "typedoc",
|
|
45
|
+
"prebuild": "rimraf dist && npm run doc",
|
|
46
|
+
"build": "rollup -c",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:cvg": "npm run test -- --coverage",
|
|
49
|
+
"test:text": "npm run test:cvg -- --coverage.reporter=text",
|
|
50
|
+
"test:html": "npm run test:cvg -- --coverage.reporter=html",
|
|
51
|
+
"test:clover": "npm run test:cvg -- --coverage.reporter=clover",
|
|
52
|
+
"prepare": "husky"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"lodash-es": "^4.17.21"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@commitlint/cli": "^19.5.0",
|
|
59
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
60
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
61
|
+
"@rollup/plugin-multi-entry": "^6.0.1",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
63
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
64
|
+
"@types/lodash-es": "^4.17.12",
|
|
65
|
+
"@types/node": "^22.9.0",
|
|
66
|
+
"@types/validator": "^13.12.2",
|
|
67
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
68
|
+
"husky": "^9.1.6",
|
|
69
|
+
"rimraf": "^5.0.5",
|
|
70
|
+
"rollup": "^4.1.5",
|
|
71
|
+
"rollup-plugin-node-externals": "^6.1.2",
|
|
72
|
+
"ts-standard": "^12.0.2",
|
|
73
|
+
"tslib": "^2.8.1",
|
|
74
|
+
"typedoc": "^0.26.11",
|
|
75
|
+
"typedoc-plugin-markdown": "^4.2.10",
|
|
76
|
+
"typescript": "^5.6.3",
|
|
77
|
+
"validator": "^13.12.0",
|
|
78
|
+
"vitest": "^2.1.4"
|
|
79
|
+
},
|
|
80
|
+
"ts-standard": {
|
|
81
|
+
"globals": [
|
|
82
|
+
"it",
|
|
83
|
+
"jest",
|
|
84
|
+
"test",
|
|
85
|
+
"expect",
|
|
86
|
+
"describe",
|
|
87
|
+
"beforeEach"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|