@kanjijs/platform-hono 0.2.0-beta.15 → 0.2.0-beta.16
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/dist/core/src/di/module-compiler.d.ts +1 -0
- package/dist/index.js +24 -10
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1159,12 +1159,14 @@ class KanjijsIoC {
|
|
|
1159
1159
|
KanjijsIoC.providers.set(target, provider);
|
|
1160
1160
|
}
|
|
1161
1161
|
if (!provider) {
|
|
1162
|
-
|
|
1162
|
+
const targetName2 = typeof target === "function" ? target.name ?? "anonymous" : String(target);
|
|
1163
|
+
throw new Error(`Provider not found for token: ${targetName2}`);
|
|
1163
1164
|
}
|
|
1164
1165
|
if (provider.instance) {
|
|
1165
1166
|
return provider.instance;
|
|
1166
1167
|
}
|
|
1167
|
-
|
|
1168
|
+
const targetName = typeof target === "function" ? target.name ?? "anonymous" : String(target);
|
|
1169
|
+
console.log(`[DI] Creating NEW instance for ${targetName}`);
|
|
1168
1170
|
if (provider.useValue !== undefined) {
|
|
1169
1171
|
provider.instance = provider.useValue;
|
|
1170
1172
|
} else if (provider.useClass) {
|
|
@@ -1193,7 +1195,8 @@ class Container {
|
|
|
1193
1195
|
resolve(token) {
|
|
1194
1196
|
const provider = this.providers.get(token);
|
|
1195
1197
|
if (!provider) {
|
|
1196
|
-
|
|
1198
|
+
const tokenName = typeof token === "function" ? token.name ?? "anonymous" : String(token);
|
|
1199
|
+
throw new Error(`[DI] Provider not found for token: ${tokenName}`);
|
|
1197
1200
|
}
|
|
1198
1201
|
if (provider.instance) {
|
|
1199
1202
|
return provider.instance;
|
|
@@ -1225,12 +1228,11 @@ class ModuleCompiler {
|
|
|
1225
1228
|
this.scan(rootModule);
|
|
1226
1229
|
this.validate();
|
|
1227
1230
|
const container = new Container;
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
container.register(token, definition);
|
|
1232
|
-
}
|
|
1231
|
+
const rootNode = this.nodes.get(rootModule);
|
|
1232
|
+
if (!rootNode) {
|
|
1233
|
+
return container;
|
|
1233
1234
|
}
|
|
1235
|
+
this.registerProviders(rootNode, container, new Set);
|
|
1234
1236
|
return container;
|
|
1235
1237
|
}
|
|
1236
1238
|
scan(target) {
|
|
@@ -1317,16 +1319,28 @@ class ModuleCompiler {
|
|
|
1317
1319
|
return overrideToken || paramType;
|
|
1318
1320
|
});
|
|
1319
1321
|
} else if ("useFactory" in provider) {
|
|
1320
|
-
targetName = typeof provider.provide === "function" ? provider.provide.name : String(provider.provide);
|
|
1322
|
+
targetName = typeof provider.provide === "function" ? provider.provide.name ?? "anonymous" : String(provider.provide);
|
|
1321
1323
|
dependencies = provider.inject || [];
|
|
1322
1324
|
}
|
|
1323
1325
|
for (const dep of dependencies) {
|
|
1324
1326
|
if (!visibleTokens.has(dep)) {
|
|
1325
|
-
const depName = typeof dep === "function" ? dep.name : String(dep);
|
|
1327
|
+
const depName = typeof dep === "function" ? dep.name ?? "anonymous" : String(dep);
|
|
1326
1328
|
throw new Error(`[Kanjijs] strict-di-error: Provider '${targetName}' in Module '${moduleName}' ` + `depends on '${depName}', but it is not visible. ` + `Make sure it is imported and exported by the source module.`);
|
|
1327
1329
|
}
|
|
1328
1330
|
}
|
|
1329
1331
|
}
|
|
1332
|
+
registerProviders(node, container, visited) {
|
|
1333
|
+
if (visited.has(node))
|
|
1334
|
+
return;
|
|
1335
|
+
visited.add(node);
|
|
1336
|
+
for (const imp of node.imports) {
|
|
1337
|
+
this.registerProviders(imp, container, visited);
|
|
1338
|
+
}
|
|
1339
|
+
for (const [token, provider] of node.providers) {
|
|
1340
|
+
const { provide: _provide, ...definition } = provider;
|
|
1341
|
+
container.register(token, definition);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1330
1344
|
}
|
|
1331
1345
|
// ../core/src/exceptions/http.exception.ts
|
|
1332
1346
|
class HttpException extends Error {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanjijs/platform-hono",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"build": "bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@kanjijs/common": "^0.2.0-beta.
|
|
17
|
-
"@kanjijs/contracts": "^0.2.0-beta.
|
|
16
|
+
"@kanjijs/common": "^0.2.0-beta.16",
|
|
17
|
+
"@kanjijs/contracts": "^0.2.0-beta.16",
|
|
18
18
|
"hono": "^4.0.0",
|
|
19
19
|
"reflect-metadata": "^0.2.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@kanjijs/core": "^0.2.0-beta.
|
|
22
|
+
"@kanjijs/core": "^0.2.0-beta.16"
|
|
23
23
|
}
|
|
24
24
|
}
|