ezfw-core 1.0.3 → 1.0.7

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 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
- const modules = this.ez._loader.getModules();
204
- const path = Object.keys(modules).find(p =>
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
- if (!path) {
210
- throw new EzError({
211
- code: 'EZ_VIEW_404',
212
- source: 'router',
213
- message: `View "${viewName}" not found`,
214
- route: this.ez._context.route,
215
- view: viewName
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
- await this.ez._loader.loadModule(path);
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
- const env = (import.meta as unknown as { env: Record<string, string> }).env;
75
- if (!env.VITE_CRYPTO_SECRET) {
76
- return;
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(/* @vite-ignore */ '../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
- const env = (import.meta as unknown as { env: Record<string, string> }).env;
90
- if (env.VITE_USE_FIREBASE !== 'true') {
91
- return;
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(/* @vite-ignore */ '../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 {
package/modules.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Lazy loaders for all framework modules
2
+ // These are evaluated at build time by Vite
3
+
4
+ export const frameworkModules = import.meta.glob('./**/*.{js,ts}', {
5
+ eager: false
6
+ });
7
+
8
+ export const frameworkStyles = import.meta.glob('./**/*.module.scss', {
9
+ eager: false
10
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezfw-core",
3
- "version": "1.0.3",
3
+ "version": "1.0.7",
4
4
  "description": "Ez Framework - A declarative component framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "./core/ez.ts",
@@ -11,12 +11,16 @@
11
11
  "import": "./core/ez.ts",
12
12
  "types": "./core/ez.ts"
13
13
  },
14
+ "./modules": {
15
+ "import": "./modules.ts"
16
+ },
14
17
  "./*": "./*"
15
18
  },
16
19
  "files": [
17
20
  "core",
18
21
  "components",
19
22
  "services",
23
+ "modules.ts",
20
24
  "template",
21
25
  "themes",
22
26
  "types",