@xrystal/core 3.14.4 → 3.14.8
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/package.json
CHANGED
package/source/project/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// => import dependencies
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService, ControllerService } from '../loader/index';
|
|
4
|
-
import { packageName, x, kafkaBrokers, systemLoggerLayer, getTmp,
|
|
4
|
+
import { packageName, x, kafkaBrokers, systemLoggerLayer, getTmp, } from '../utils/index';
|
|
5
5
|
//
|
|
6
6
|
let coreHasRun = false;
|
|
7
7
|
export const core = getTmp();
|
|
@@ -59,7 +59,7 @@ const coreLoader = async ({}) => {
|
|
|
59
59
|
{
|
|
60
60
|
service: ControllerService,
|
|
61
61
|
props: {
|
|
62
|
-
type:
|
|
62
|
+
type: configs.loaders.controller.protocol,
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
{
|
|
@@ -6,7 +6,7 @@ export declare class X {
|
|
|
6
6
|
private getSource;
|
|
7
7
|
load(patterns: string | string[], options?: {
|
|
8
8
|
verbose?: boolean;
|
|
9
|
-
exclude?: (string | Function)[];
|
|
9
|
+
exclude?: string | Function | (string | Function)[];
|
|
10
10
|
lifetime?: LifetimeType;
|
|
11
11
|
}): Promise<this>;
|
|
12
12
|
register(Dependency: any, lifetime?: LifetimeType): this;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContainer, asClass, asValue, InjectionMode, listModules, Lifetime } from 'awilix';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
3
4
|
export class X {
|
|
4
5
|
container;
|
|
5
6
|
initializedNames = new Set();
|
|
@@ -14,7 +15,6 @@ export class X {
|
|
|
14
15
|
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
15
16
|
return normalizedPath.includes('node_modules') || !normalizedPath.startsWith(projectRoot) ? 'LIB' : 'APP';
|
|
16
17
|
}
|
|
17
|
-
// 1. ASYNC YAPTIK (await import desteği için)
|
|
18
18
|
async load(patterns, options = {}) {
|
|
19
19
|
const { verbose = false, exclude = [], lifetime = Lifetime.SINGLETON } = options;
|
|
20
20
|
const cwd = process.cwd();
|
|
@@ -36,7 +36,6 @@ export class X {
|
|
|
36
36
|
const normalizedMPath = m.path.replace(/\\/g, '/');
|
|
37
37
|
if (normalizedMPath === __filename.replace(/\\/g, '/') || normalizedMPath.endsWith('.d.ts'))
|
|
38
38
|
continue;
|
|
39
|
-
// --- KRİTİK DÜZELTME 1: DOSYAYI YÜKLEMEDEN ÖNCE EXCLUDE KONTROLÜ ---
|
|
40
39
|
const isPathExcluded = excludeList.some(ex => {
|
|
41
40
|
if (typeof ex === 'string') {
|
|
42
41
|
const normalizedEx = ex.replace(/\\/g, '/');
|
|
@@ -46,17 +45,16 @@ export class X {
|
|
|
46
45
|
});
|
|
47
46
|
if (isPathExcluded) {
|
|
48
47
|
if (verbose)
|
|
49
|
-
console.log(`[DI][${source}]
|
|
48
|
+
console.log(`[DI][${source}] Excluded: ${m.name}`);
|
|
50
49
|
continue;
|
|
51
50
|
}
|
|
52
51
|
try {
|
|
53
|
-
|
|
54
|
-
const loaded = await import(
|
|
52
|
+
const fileUrl = pathToFileURL(m.path).href;
|
|
53
|
+
const loaded = await import(fileUrl);
|
|
55
54
|
let dependency = loaded.default;
|
|
56
55
|
if (!dependency) {
|
|
57
56
|
dependency = Object.values(loaded).find(val => typeof val === 'function' && !!val.prototype && !!val.name);
|
|
58
57
|
}
|
|
59
|
-
// Class referansı üzerinden exclude (Eğer class yüklendiyse)
|
|
60
58
|
const isClassExcluded = excludeList.some(ex => typeof ex === 'function' && dependency === ex);
|
|
61
59
|
if (isClassExcluded)
|
|
62
60
|
continue;
|
|
@@ -74,14 +72,12 @@ export class X {
|
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
catch (err) {
|
|
77
|
-
// Burada hata alıyorsan dosya bozuktur veya import edilemiyordur
|
|
78
75
|
if (verbose)
|
|
79
76
|
console.error(`[DI][${source}] Load Error in ${m.name}:`, err.message);
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
79
|
return this;
|
|
83
80
|
}
|
|
84
|
-
// ... (register, initialize, get metodları aynı kalıyor)
|
|
85
81
|
register(Dependency, lifetime = Lifetime.SINGLETON) {
|
|
86
82
|
if (!Dependency?.name)
|
|
87
83
|
return this;
|