@illuma/core 1.0.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/CHANGELOG.md +46 -0
- package/README.md +164 -0
- package/dist/index.cjs +1089 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +378 -0
- package/dist/index.d.ts +378 -0
- package/dist/index.js +1045 -0
- package/dist/index.js.map +1 -0
- package/dist/injection-CSxu56ds.d.cts +57 -0
- package/dist/injection-Y_bVmBSk.d.ts +57 -0
- package/dist/plugin-container-CwkVlVS4.d.ts +136 -0
- package/dist/plugin-container-D8Zwpigq.d.cts +136 -0
- package/dist/plugins.cjs +80 -0
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.d.cts +9 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.js +54 -0
- package/dist/plugins.js.map +1 -0
- package/dist/providers-D9YA8L_g.d.cts +153 -0
- package/dist/providers-D9YA8L_g.d.ts +153 -0
- package/dist/testkit.cjs +995 -0
- package/dist/testkit.cjs.map +1 -0
- package/dist/testkit.d.cts +44 -0
- package/dist/testkit.d.ts +44 -0
- package/dist/testkit.js +970 -0
- package/dist/testkit.js.map +1 -0
- package/package.json +74 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
## 1.7.0 - 2025-12-28
|
|
11
|
+
|
|
12
|
+
## 1.6.3 - 2025-12-27
|
|
13
|
+
|
|
14
|
+
## 1.6.2 - 2025-12-27
|
|
15
|
+
|
|
16
|
+
## 1.6.1 - 2025-12-27
|
|
17
|
+
|
|
18
|
+
## 1.6.0 - 2025-12-27
|
|
19
|
+
|
|
20
|
+
## 1.5.3 - 2025-12-10
|
|
21
|
+
|
|
22
|
+
## 1.5.2 - 2025-12-10
|
|
23
|
+
|
|
24
|
+
## 1.5.1 - 2025-12-10
|
|
25
|
+
|
|
26
|
+
## 1.5.0 - 2025-12-08
|
|
27
|
+
|
|
28
|
+
## 1.4.0 - 2025-12-08
|
|
29
|
+
|
|
30
|
+
## 1.3.0 - 2025-12-07
|
|
31
|
+
|
|
32
|
+
## 1.2.0 - 2025-11-26
|
|
33
|
+
|
|
34
|
+
## 1.1.2 - 2025-11-23
|
|
35
|
+
|
|
36
|
+
## 1.1.1 - 2025-11-23
|
|
37
|
+
|
|
38
|
+
## 1.1.0 - 2025-11-23
|
|
39
|
+
|
|
40
|
+
## 1.0.3 - 2025-11-22
|
|
41
|
+
|
|
42
|
+
## 1.0.2 - 2025-11-22
|
|
43
|
+
|
|
44
|
+
## 1.0.1 - 2025-11-22
|
|
45
|
+
|
|
46
|
+
## 1.0.0 - 2026-01-01
|
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# ๐ฅ **Illuma** โ Angular-style Dependency Injection for TypeScript
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
A lightweight, type-safe dependency injection container for TypeScript. Zero dependencies.
|
|
9
|
+
|
|
10
|
+
## โจ Features
|
|
11
|
+
|
|
12
|
+
- ๐ฏ **Type-Safe** โ Full TypeScript support with excellent type inference
|
|
13
|
+
- ๐ชถ **Lightweight** โ Zero dependencies, minimal bundle size
|
|
14
|
+
- ๐ **Flexible** โ Classes, factories, values, and aliases
|
|
15
|
+
- ๐จ **Decorators** โ Optional Angular-style `@NodeInjectable()` decorator
|
|
16
|
+
- ๐ **Multi-Tokens** โ Built-in multi-provider support
|
|
17
|
+
- ๐ **Plugin System** โ Extensible architecture with custom scanners and diagnostics
|
|
18
|
+
- ๐ **Universal** โ Node.js, Deno, browser, and Electron
|
|
19
|
+
|
|
20
|
+
## ๐ฆ Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @illuma/core
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## ๐ Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { NodeContainer, NodeInjectable, nodeInject } from '@illuma/core';
|
|
30
|
+
|
|
31
|
+
@NodeInjectable()
|
|
32
|
+
class Logger {
|
|
33
|
+
public log(message: string) {
|
|
34
|
+
console.log(`[LOG]: ${message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@NodeInjectable()
|
|
39
|
+
class UserService {
|
|
40
|
+
private readonly logger = nodeInject(Logger);
|
|
41
|
+
|
|
42
|
+
public getUser(id: string) {
|
|
43
|
+
this.logger.log(`Fetching user ${id}`);
|
|
44
|
+
return { id, name: 'John Doe' };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const container = new NodeContainer();
|
|
49
|
+
container.provide([Logger, UserService]);
|
|
50
|
+
container.bootstrap();
|
|
51
|
+
|
|
52
|
+
const userService = container.get(UserService);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> **Note:** Requires `experimentalDecorators` and `emitDecoratorMetadata` in tsconfig. See [Getting Started](./docs/GETTING_STARTED.md) for decorator-free alternatives.
|
|
56
|
+
|
|
57
|
+
## ๐ท๏ธ Using Tokens
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { NodeToken, MultiNodeToken, NodeContainer } from '@illuma/core';
|
|
61
|
+
|
|
62
|
+
// Single-value token
|
|
63
|
+
const CONFIG = new NodeToken<{ apiUrl: string }>('CONFIG');
|
|
64
|
+
|
|
65
|
+
// Multi-value token (when injected, returns array)
|
|
66
|
+
const PLUGINS = new MultiNodeToken<Plugin>('PLUGINS');
|
|
67
|
+
|
|
68
|
+
const container = new NodeContainer();
|
|
69
|
+
|
|
70
|
+
container.provide([
|
|
71
|
+
// Equivalent to:
|
|
72
|
+
// { provide: CONFIG, value: { apiUrl: 'https://api.example.com' } }
|
|
73
|
+
CONFIG.withValue({ apiUrl: 'https://api.example.com' }),
|
|
74
|
+
|
|
75
|
+
// Equivalent to:
|
|
76
|
+
// { provide: PLUGINS, useClass: AnalyticsPlugin }
|
|
77
|
+
PLUGINS.withClass(AnalyticsPlugin),
|
|
78
|
+
|
|
79
|
+
// Equivalent to:
|
|
80
|
+
// { provide: PLUGINS, useClass: LoggingPlugin }
|
|
81
|
+
PLUGINS.withClass(LoggingPlugin),
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
container.bootstrap();
|
|
85
|
+
|
|
86
|
+
const config = container.get(CONFIG); // { apiUrl: string }
|
|
87
|
+
const plugins = container.get(PLUGINS); // Plugin[]: [AnalyticsPlugin, LoggingPlugin]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
See [Tokens Guide](./docs/TOKENS.md) for more details.
|
|
91
|
+
|
|
92
|
+
## ๐จ Provider Types
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// Class provider
|
|
96
|
+
container.provide(MyService);
|
|
97
|
+
|
|
98
|
+
// Value provider
|
|
99
|
+
container.provide({ provide: CONFIG, value: { apiUrl: '...' } });
|
|
100
|
+
|
|
101
|
+
// Factory provider
|
|
102
|
+
container.provide({ provide: DATABASE, factory: () => {
|
|
103
|
+
const env = nodeInject(ENV);
|
|
104
|
+
return createDatabase(env.connectionString);
|
|
105
|
+
} });
|
|
106
|
+
|
|
107
|
+
// Class provider with custom implementation
|
|
108
|
+
container.provide({ provide: DATABASE, useClass: DatabaseImplementation });
|
|
109
|
+
|
|
110
|
+
// Alias provider
|
|
111
|
+
container.provide({ provide: Database, alias: ExistingDatabase });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
See [Providers Guide](./docs/PROVIDERS.md) for details.
|
|
115
|
+
|
|
116
|
+
## ๐งช Testing
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { createTestFactory } from '@illuma/core/testkit';
|
|
120
|
+
|
|
121
|
+
const createTest = createTestFactory({
|
|
122
|
+
target: UserService,
|
|
123
|
+
provide: [{ provide: Logger, useClass: MockLogger }],
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should fetch user', () => {
|
|
127
|
+
const { instance } = createTest();
|
|
128
|
+
expect(instance.getUser('123')).toBeDefined();
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See [Testing Guide](./docs/TESTKIT.md) for comprehensive examples.
|
|
133
|
+
|
|
134
|
+
## ๐ Documentation
|
|
135
|
+
|
|
136
|
+
| Guide | Description |
|
|
137
|
+
| -------------------------------------------------- | ----------------------------------------------------- |
|
|
138
|
+
| [Getting Started](./docs/GETTING_STARTED.md) | Installation, setup, and basic usage |
|
|
139
|
+
| [Providers](./docs/PROVIDERS.md) | Value, factory, class, and alias providers |
|
|
140
|
+
| [Tokens](./docs/TOKENS.md) | NodeToken and MultiNodeToken |
|
|
141
|
+
| [Async Injection](./docs/ASYNC_INJECTION.md) | Lazy loading and sub-containers |
|
|
142
|
+
| [Testing](./docs/TESTKIT.md) | Testkit and mocking |
|
|
143
|
+
| [Plugins](./docs/PLUGINS.md) | Extending Illuma with custom scanners and diagnostics |
|
|
144
|
+
| [Technical Overview](./docs/TECHNICAL_OVERVIEW.md) | Deep dive into how Illuma works |
|
|
145
|
+
| [API Reference](./docs/API.md) | Complete API documentation |
|
|
146
|
+
| [Troubleshooting](./docs/TROUBLESHOOTING.md) | Error codes and solutions |
|
|
147
|
+
|
|
148
|
+
## ๐ Plugins
|
|
149
|
+
|
|
150
|
+
Illuma supports a plugin system for extending functionality. Check out these plugins:
|
|
151
|
+
|
|
152
|
+
- **[@illuma/reflect](https://github.com/git-illuma/reflect)** โ Constructor metadata and property decorator injection support
|
|
153
|
+
|
|
154
|
+
See [Plugins Guide](./docs/PLUGINS.md) for creating your own plugins.
|
|
155
|
+
|
|
156
|
+
## ๐ License
|
|
157
|
+
|
|
158
|
+
MIT ยฉ [bebrasmell](https://github.com/bebrasmell)
|
|
159
|
+
|
|
160
|
+
## ๐ Links
|
|
161
|
+
|
|
162
|
+
- [GitHub](https://github.com/git-illuma/core)
|
|
163
|
+
- [NPM](https://www.npmjs.com/package/@illuma/core)
|
|
164
|
+
- [Issues](https://github.com/git-illuma/core/issues)
|