@illuma/core 1.2.1 → 1.3.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 CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 1.3.0 - 2026-01-10
11
+
10
12
  ## 1.2.1 - 2026-01-10
11
13
 
12
14
  ## 1.2.0 - 2026-01-10
package/dist/index.cjs CHANGED
@@ -42,10 +42,89 @@ __export(index_exports, {
42
42
  isInjectable: () => isInjectable,
43
43
  isNodeBase: () => isNodeBase,
44
44
  makeInjectable: () => makeInjectable,
45
- nodeInject: () => nodeInject
45
+ nodeInject: () => nodeInject,
46
+ registerClassAsInjectable: () => registerClassAsInjectable
46
47
  });
47
48
  module.exports = __toCommonJS(index_exports);
48
49
 
50
+ // src/lib/api/token.ts
51
+ var NodeBase = class {
52
+ static {
53
+ __name(this, "NodeBase");
54
+ }
55
+ name;
56
+ opts;
57
+ constructor(name, opts) {
58
+ this.name = name;
59
+ this.opts = opts;
60
+ }
61
+ /** Provides this token with a value */
62
+ withValue(value) {
63
+ return {
64
+ provide: this,
65
+ value
66
+ };
67
+ }
68
+ /** Provides this token using a factory function */
69
+ withFactory(factory) {
70
+ return {
71
+ provide: this,
72
+ factory
73
+ };
74
+ }
75
+ /** Provides this token using a class constructor */
76
+ withClass(ctor) {
77
+ return {
78
+ provide: this,
79
+ useClass: ctor
80
+ };
81
+ }
82
+ /** Creates an alias to another token */
83
+ withAlias(alias) {
84
+ return {
85
+ provide: this,
86
+ alias
87
+ };
88
+ }
89
+ toString() {
90
+ return `Token[${this.name}]`;
91
+ }
92
+ };
93
+ var NodeToken = class extends NodeBase {
94
+ static {
95
+ __name(this, "NodeToken");
96
+ }
97
+ multi = false;
98
+ toString() {
99
+ return `NodeToken[${this.name}]`;
100
+ }
101
+ };
102
+ var MultiNodeToken = class extends NodeBase {
103
+ static {
104
+ __name(this, "MultiNodeToken");
105
+ }
106
+ multi = true;
107
+ toString() {
108
+ return `MultiNodeToken[${this.name}]`;
109
+ }
110
+ };
111
+ function isNodeBase(specimen) {
112
+ return specimen instanceof NodeToken || specimen instanceof MultiNodeToken;
113
+ }
114
+ __name(isNodeBase, "isNodeBase");
115
+ function extractToken(provider, isAlias = false) {
116
+ let token = null;
117
+ if (isInjectable(provider)) {
118
+ token = getInjectableToken(provider);
119
+ } else if (isNodeBase(provider)) token = provider;
120
+ if (!token || !isNodeBase(token)) {
121
+ if (isAlias) throw InjectionError.invalidAlias(provider);
122
+ throw InjectionError.invalidProvider(JSON.stringify(provider));
123
+ }
124
+ return token;
125
+ }
126
+ __name(extractToken, "extractToken");
127
+
49
128
  // src/lib/errors.ts
50
129
  var ERR_CODES = {
51
130
  // Provider errors
@@ -146,92 +225,15 @@ function isNotFoundError(error) {
146
225
  }
147
226
  __name(isNotFoundError, "isNotFoundError");
148
227
 
149
- // src/lib/api/token.ts
150
- var NodeBase = class {
151
- static {
152
- __name(this, "NodeBase");
153
- }
154
- name;
155
- opts;
156
- constructor(name, opts) {
157
- this.name = name;
158
- this.opts = opts;
159
- }
160
- /** Provides this token with a value */
161
- withValue(value) {
162
- return {
163
- provide: this,
164
- value
165
- };
166
- }
167
- /** Provides this token using a factory function */
168
- withFactory(factory) {
169
- return {
170
- provide: this,
171
- factory
172
- };
173
- }
174
- /** Provides this token using a class constructor */
175
- withClass(ctor) {
176
- return {
177
- provide: this,
178
- useClass: ctor
179
- };
180
- }
181
- /** Creates an alias to another token */
182
- withAlias(alias) {
183
- return {
184
- provide: this,
185
- alias
186
- };
187
- }
188
- toString() {
189
- return `Token[${this.name}]`;
190
- }
191
- };
192
- var NodeToken = class extends NodeBase {
193
- static {
194
- __name(this, "NodeToken");
195
- }
196
- multi = false;
197
- toString() {
198
- return `NodeToken[${this.name}]`;
199
- }
200
- };
201
- var MultiNodeToken = class extends NodeBase {
202
- static {
203
- __name(this, "MultiNodeToken");
204
- }
205
- multi = true;
206
- toString() {
207
- return `MultiNodeToken[${this.name}]`;
208
- }
209
- };
210
- function isNodeBase(specimen) {
211
- return specimen instanceof NodeToken || specimen instanceof MultiNodeToken;
212
- }
213
- __name(isNodeBase, "isNodeBase");
214
- function extractToken(provider, isAlias = false) {
215
- let token = null;
216
- if (isInjectable(provider)) {
217
- token = getInjectableToken(provider);
218
- } else if (isNodeBase(provider)) token = provider;
219
- if (!token || !isNodeBase(token)) {
220
- if (isAlias) throw InjectionError.invalidAlias(provider);
221
- throw InjectionError.invalidProvider(JSON.stringify(provider));
222
- }
223
- return token;
224
- }
225
- __name(extractToken, "extractToken");
226
-
227
228
  // src/lib/api/decorator.ts
229
+ var tokenRegistry = /* @__PURE__ */ new WeakMap();
228
230
  var INJECTION_SYMBOL = Symbol("Injectable");
229
231
  function NodeInjectable() {
230
232
  return (ctor) => {
231
233
  const nodeToken = new NodeToken(`_${ctor.name}`, {
232
234
  factory: /* @__PURE__ */ __name(() => new ctor(), "factory")
233
235
  });
234
- ctor[INJECTION_SYMBOL] = nodeToken;
236
+ registerClassAsInjectable(ctor, nodeToken);
235
237
  return ctor;
236
238
  };
237
239
  }
@@ -240,22 +242,30 @@ function makeInjectable(ctor) {
240
242
  const nodeToken = new NodeToken(`_${ctor.name}`, {
241
243
  factory: /* @__PURE__ */ __name(() => new ctor(), "factory")
242
244
  });
243
- ctor[INJECTION_SYMBOL] = nodeToken;
245
+ registerClassAsInjectable(ctor, nodeToken);
244
246
  return ctor;
245
247
  }
246
248
  __name(makeInjectable, "makeInjectable");
247
249
  function isInjectable(ctor) {
248
- return typeof ctor === "function" && isConstructor(ctor) && INJECTION_SYMBOL in ctor && ctor[INJECTION_SYMBOL] instanceof NodeToken;
250
+ return typeof ctor === "function" && isConstructor(ctor) && (tokenRegistry.has(ctor) || INJECTION_SYMBOL in ctor);
249
251
  }
250
252
  __name(isInjectable, "isInjectable");
251
253
  function getInjectableToken(ctor) {
252
- return ctor[INJECTION_SYMBOL];
254
+ if (tokenRegistry.has(ctor)) return tokenRegistry.get(ctor);
255
+ if (INJECTION_SYMBOL in ctor) {
256
+ return ctor[INJECTION_SYMBOL];
257
+ }
258
+ throw InjectionError.invalidCtor(ctor);
253
259
  }
254
260
  __name(getInjectableToken, "getInjectableToken");
255
261
  function isConstructor(fn) {
256
262
  return typeof fn === "function" && fn.prototype && fn.prototype.constructor === fn;
257
263
  }
258
264
  __name(isConstructor, "isConstructor");
265
+ function registerClassAsInjectable(ctor, token) {
266
+ tokenRegistry.set(ctor, token);
267
+ }
268
+ __name(registerClassAsInjectable, "registerClassAsInjectable");
259
269
 
260
270
  // src/lib/plugins/core/plugin-container.ts
261
271
  var Illuma = class _Illuma {
@@ -509,7 +519,7 @@ var TreeRootNode = class {
509
519
  }
510
520
  instant;
511
521
  _deps = /* @__PURE__ */ new Set();
512
- _treePool = /* @__PURE__ */ new Map();
522
+ _treePool = /* @__PURE__ */ new WeakMap();
513
523
  constructor(instant = true) {
514
524
  this.instant = instant;
515
525
  }
@@ -1172,6 +1182,7 @@ var NodeContainer = class extends Illuma {
1172
1182
  isInjectable,
1173
1183
  isNodeBase,
1174
1184
  makeInjectable,
1175
- nodeInject
1185
+ nodeInject,
1186
+ registerClassAsInjectable
1176
1187
  });
1177
1188
  //# sourceMappingURL=index.cjs.map