ezfw-core 1.0.2 → 1.0.5
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/core/router.ts +14 -16
- package/core/services.ts +30 -20
- package/package.json +1 -1
package/core/router.ts
CHANGED
|
@@ -200,25 +200,23 @@ export class EzRouter {
|
|
|
200
200
|
this.ez._context.route = route?.path ?? null;
|
|
201
201
|
this.ez._context.controller = null;
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
p.toLowerCase().includes(`/${viewName.toLowerCase()}/`)
|
|
206
|
-
|| p.toLowerCase().endsWith(`/${viewName.toLowerCase()}.js`)
|
|
207
|
-
);
|
|
203
|
+
// First check if view is already registered (via static import)
|
|
204
|
+
let def = this.ez.get(viewName);
|
|
208
205
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
}
|
|
206
|
+
// If not found, try to load via the loader (dynamic import)
|
|
207
|
+
if (!def) {
|
|
208
|
+
const modules = this.ez._loader.getModules();
|
|
209
|
+
const path = Object.keys(modules).find(p =>
|
|
210
|
+
p.toLowerCase().includes(`/${viewName.toLowerCase()}/`)
|
|
211
|
+
|| p.toLowerCase().endsWith(`/${viewName.toLowerCase()}.js`)
|
|
212
|
+
);
|
|
218
213
|
|
|
219
|
-
|
|
214
|
+
if (path) {
|
|
215
|
+
await this.ez._loader.loadModule(path);
|
|
216
|
+
def = this.ez.get(viewName);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
220
219
|
|
|
221
|
-
const def = this.ez.get(viewName);
|
|
222
220
|
if (!def) {
|
|
223
221
|
throw new EzError({
|
|
224
222
|
code: 'EZ_VIEW_404',
|
package/core/services.ts
CHANGED
|
@@ -71,14 +71,19 @@ export class EzServices {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private async _initCrypto(): Promise<void> {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
try {
|
|
75
|
+
const env = (import.meta as unknown as { env: Record<string, string> }).env || {};
|
|
76
|
+
if (!env.VITE_CRYPTO_SECRET) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const { CryptoService } = await import(/* @vite-ignore */ '../services/crypto.js');
|
|
81
|
+
await CryptoService.init(env.VITE_CRYPTO_SECRET);
|
|
82
|
+
this._crypto = CryptoService;
|
|
83
|
+
} catch (e) {
|
|
84
|
+
// Crypto service not available - skip silently
|
|
85
|
+
console.debug('[ez] CryptoService not initialized - libsodium-wrappers not installed');
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
const { CryptoService } = await import('../services/crypto.js');
|
|
80
|
-
await CryptoService.init(env.VITE_CRYPTO_SECRET);
|
|
81
|
-
this._crypto = CryptoService;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
get crypto(): CryptoServiceType | null {
|
|
@@ -86,20 +91,25 @@ export class EzServices {
|
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
private async _initFirebase(): Promise<void> {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
try {
|
|
95
|
+
const env = (import.meta as unknown as { env: Record<string, string> }).env || {};
|
|
96
|
+
if (env.VITE_USE_FIREBASE !== 'true') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const firebaseConfig: FirebaseConfig = {
|
|
101
|
+
apiKey: env.VITE_FIREBASE_API_KEY,
|
|
102
|
+
authDomain: env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
103
|
+
projectId: env.VITE_FIREBASE_PROJECT_ID,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const { FirebaseService } = await import(/* @vite-ignore */ '../services/firebase.js');
|
|
107
|
+
this._firebase = new FirebaseService(firebaseConfig) as unknown as FirebaseService;
|
|
108
|
+
await this._firebase!.init();
|
|
109
|
+
} catch (e) {
|
|
110
|
+
// Firebase not available - skip silently
|
|
111
|
+
console.debug('[ez] FirebaseService not initialized - firebase not installed');
|
|
92
112
|
}
|
|
93
|
-
|
|
94
|
-
const firebaseConfig: FirebaseConfig = {
|
|
95
|
-
apiKey: env.VITE_FIREBASE_API_KEY,
|
|
96
|
-
authDomain: env.VITE_FIREBASE_AUTH_DOMAIN,
|
|
97
|
-
projectId: env.VITE_FIREBASE_PROJECT_ID,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const { FirebaseService } = await import('../services/firebase.js');
|
|
101
|
-
this._firebase = new FirebaseService(firebaseConfig) as unknown as FirebaseService;
|
|
102
|
-
await this._firebase!.init();
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
get firebase(): FirebaseService | null {
|