@illuma/core 0.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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
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
+ ## 0.1.0 - 2026-01-07
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # ๐Ÿ”ฅ **Illuma** โ€“ Angular-style Dependency Injection for TypeScript
2
+
3
+ ![NPM Version](https://img.shields.io/npm/v/%40illuma%2Fcore)
4
+ ![NPM Downloads](https://img.shields.io/npm/dw/%40illuma%2Fcore)
5
+ ![npm bundle size](https://img.shields.io/bundlephobia/min/%40illuma%2Fcore)
6
+ ![Test coverage](./badges/coverage.svg)
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
+ ## ๐Ÿค Compatibility
27
+
28
+ Anything that supports ES2015+ (ES6+).
29
+ Practically the library is compatible with Node.js (v14+) and all modern browsers.
30
+ For older environments, consider using a transpiler like Babel or TypeScript or provide polyfills as needed.
31
+
32
+ ## ๐Ÿš€ Quick Start
33
+
34
+ ```typescript
35
+ import { NodeContainer, NodeInjectable, nodeInject } from '@illuma/core';
36
+
37
+ @NodeInjectable()
38
+ class Logger {
39
+ public log(message: string) {
40
+ console.log(`[LOG]: ${message}`);
41
+ }
42
+ }
43
+
44
+ @NodeInjectable()
45
+ class UserService {
46
+ private readonly logger = nodeInject(Logger);
47
+
48
+ public getUser(id: string) {
49
+ this.logger.log(`Fetching user ${id}`);
50
+ return { id, name: 'John Doe' };
51
+ }
52
+ }
53
+
54
+ const container = new NodeContainer();
55
+ container.provide([Logger, UserService]);
56
+ container.bootstrap();
57
+
58
+ const userService = container.get(UserService);
59
+ ```
60
+
61
+ > **Note:** Requires `experimentalDecorators` and `emitDecoratorMetadata` in tsconfig. See [Getting Started](./docs/GETTING_STARTED.md) for decorator-free alternatives.
62
+
63
+ ## ๐Ÿท๏ธ Using Tokens
64
+
65
+ ```typescript
66
+ import { NodeToken, MultiNodeToken, NodeContainer } from '@illuma/core';
67
+
68
+ // Single-value token
69
+ const CONFIG = new NodeToken<{ apiUrl: string }>('CONFIG');
70
+
71
+ // Multi-value token (when injected, returns array)
72
+ const PLUGINS = new MultiNodeToken<Plugin>('PLUGINS');
73
+
74
+ const container = new NodeContainer();
75
+
76
+ container.provide([
77
+ // Equivalent to:
78
+ // { provide: CONFIG, value: { apiUrl: 'https://api.example.com' } }
79
+ CONFIG.withValue({ apiUrl: 'https://api.example.com' }),
80
+
81
+ // Equivalent to:
82
+ // { provide: PLUGINS, useClass: AnalyticsPlugin }
83
+ PLUGINS.withClass(AnalyticsPlugin),
84
+
85
+ // Equivalent to:
86
+ // { provide: PLUGINS, useClass: LoggingPlugin }
87
+ PLUGINS.withClass(LoggingPlugin),
88
+ ]);
89
+
90
+ container.bootstrap();
91
+
92
+ const config = container.get(CONFIG); // { apiUrl: string }
93
+ const plugins = container.get(PLUGINS); // Plugin[]: [AnalyticsPlugin, LoggingPlugin]
94
+ ```
95
+
96
+ See [Tokens Guide](./docs/TOKENS.md) for more details.
97
+
98
+ ## ๐ŸŽจ Provider Types
99
+
100
+ ```typescript
101
+ // Class provider
102
+ container.provide(MyService);
103
+
104
+ // Value provider
105
+ container.provide({ provide: CONFIG, value: { apiUrl: '...' } });
106
+
107
+ // Factory provider
108
+ container.provide({ provide: DATABASE, factory: () => {
109
+ const env = nodeInject(ENV);
110
+ return createDatabase(env.connectionString);
111
+ } });
112
+
113
+ // Class provider with custom implementation
114
+ container.provide({ provide: DATABASE, useClass: DatabaseImplementation });
115
+
116
+ // Alias provider
117
+ container.provide({ provide: Database, alias: ExistingDatabase });
118
+ ```
119
+
120
+ See [Providers Guide](./docs/PROVIDERS.md) for details.
121
+
122
+ ## ๐Ÿงช Testing
123
+
124
+ ```typescript
125
+ import { createTestFactory } from '@illuma/core/testkit';
126
+
127
+ const createTest = createTestFactory({
128
+ target: UserService,
129
+ provide: [{ provide: Logger, useClass: MockLogger }],
130
+ });
131
+
132
+ it('should fetch user', () => {
133
+ const { instance } = createTest();
134
+ expect(instance.getUser('123')).toBeDefined();
135
+ });
136
+ ```
137
+
138
+ See [Testing Guide](./docs/TESTKIT.md) for comprehensive examples.
139
+
140
+ ## ๐Ÿ“š Documentation
141
+
142
+ | Guide | Description |
143
+ | -------------------------------------------------- | ----------------------------------------------------- |
144
+ | [Getting Started](./docs/GETTING_STARTED.md) | Installation, setup, and basic usage |
145
+ | [Providers](./docs/PROVIDERS.md) | Value, factory, class, and alias providers |
146
+ | [Tokens](./docs/TOKENS.md) | NodeToken and MultiNodeToken |
147
+ | [Async Injection](./docs/ASYNC_INJECTION.md) | Lazy loading and sub-containers |
148
+ | [Testing](./docs/TESTKIT.md) | Testkit and mocking |
149
+ | [Plugins](./docs/PLUGINS.md) | Extending Illuma with custom scanners and diagnostics |
150
+ | [Technical Overview](./docs/TECHNICAL_OVERVIEW.md) | Deep dive into how Illuma works |
151
+ | [API Reference](./docs/API.md) | Complete API documentation |
152
+ | [Troubleshooting](./docs/TROUBLESHOOTING.md) | Error codes and solutions |
153
+
154
+ ## ๐Ÿ”Œ Plugins
155
+
156
+ Illuma supports a plugin system for extending functionality. Check out these plugins:
157
+
158
+ - **[@illuma/reflect](https://github.com/git-illuma/reflect)** โ€“ Constructor metadata and property decorator injection support
159
+
160
+ See [Plugins Guide](./docs/PLUGINS.md) for creating your own plugins.
161
+
162
+ ## ๐Ÿ“„ License
163
+
164
+ MIT ยฉ [bebrasmell](https://github.com/bebrasmell)
165
+
166
+ ## ๐Ÿ”— Links
167
+
168
+ - [GitHub](https://github.com/git-illuma/core)
169
+ - [NPM](https://www.npmjs.com/package/@illuma/core)
170
+ - [Issues](https://github.com/git-illuma/core/issues)