@illuma/core 1.0.0 โ†’ 1.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/README.md CHANGED
@@ -1,164 +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
- ## ๐Ÿš€ 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)
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)
package/dist/index.cjs CHANGED
@@ -335,6 +335,13 @@ var InjectionContext = class _InjectionContext {
335
335
  }
336
336
  };
337
337
 
338
+ // src/lib/api/proxy.ts
339
+ var SHAPE_SHIFTER = new Proxy(() => {
340
+ }, {
341
+ get: /* @__PURE__ */ __name(() => SHAPE_SHIFTER, "get"),
342
+ apply: /* @__PURE__ */ __name(() => SHAPE_SHIFTER, "apply")
343
+ });
344
+
338
345
  // src/lib/api/injection.ts
339
346
  function nodeInject(provider, options) {
340
347
  let token = provider;
@@ -351,7 +358,7 @@ function nodeInject(provider, options) {
351
358
  if (InjectionContext.injector) {
352
359
  return InjectionContext.injector(token, options?.optional);
353
360
  }
354
- return injection;
361
+ return SHAPE_SHIFTER;
355
362
  }
356
363
  __name(nodeInject, "nodeInject");
357
364