ezfw-core 1.0.96 → 1.0.98
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/components/icon/icons.ts +11 -2
- package/core/ezEntryPlugin.js +106 -28
- package/package.json +1 -1
package/components/icon/icons.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Icon utilities
|
|
3
|
-
*
|
|
3
|
+
* Uses a registry pattern - icons are registered by the project's icons.config
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Icon registry - populated by registerIcons()
|
|
7
|
+
let ICONS: Record<string, string> = {};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Register icons from project's icons.config.ts
|
|
11
|
+
* Called automatically by the framework entry point
|
|
12
|
+
*/
|
|
13
|
+
export function registerIcons(icons: Record<string, string>): void {
|
|
14
|
+
ICONS = { ...ICONS, ...icons };
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
18
|
* Get icon SVG content by name
|
package/core/ezEntryPlugin.js
CHANGED
|
@@ -4,26 +4,76 @@
|
|
|
4
4
|
* Generates index.js and hydrate.js entry points with user config inlined.
|
|
5
5
|
* This allows users to only modify ez.config.js while keeping all framework
|
|
6
6
|
* internals hidden.
|
|
7
|
+
*
|
|
8
|
+
* Supports two modes:
|
|
9
|
+
* - Local: when ./ez folder exists (main ez repo)
|
|
10
|
+
* - NPM: when using ezfw-core from node_modules
|
|
7
11
|
*/
|
|
8
12
|
import * as fs from 'fs';
|
|
9
13
|
import * as path from 'path';
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Detect if project uses local ./ez folder or ezfw-core from npm
|
|
17
|
+
*/
|
|
18
|
+
function detectFrameworkMode(root) {
|
|
19
|
+
const localEzPath = path.resolve(root, 'ez/core/ez.js');
|
|
20
|
+
const localEzTsPath = path.resolve(root, 'ez/core/ez.ts');
|
|
21
|
+
if (fs.existsSync(localEzPath) || fs.existsSync(localEzTsPath)) {
|
|
22
|
+
return 'local';
|
|
23
|
+
}
|
|
24
|
+
return 'npm';
|
|
25
|
+
}
|
|
26
|
+
|
|
11
27
|
/**
|
|
12
28
|
* Generate the SPA entry point code (index.js)
|
|
13
29
|
*/
|
|
14
|
-
function generateIndexCode(config) {
|
|
30
|
+
function generateIndexCode(config, mode) {
|
|
15
31
|
const theme = config.theme || 'slate-dark';
|
|
16
32
|
const i18nCode = config.i18n
|
|
17
33
|
? `ez.setLanguages(${JSON.stringify(config.i18n.languages)}, { default: '${config.i18n.default}', debug: ${config.i18n.debug || false} });`
|
|
18
34
|
: '';
|
|
19
35
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import './ez/core/ez.js';
|
|
36
|
+
// Framework imports differ based on mode
|
|
37
|
+
const fwImports = mode === 'local'
|
|
38
|
+
? `import './ez/core/ez.js';
|
|
24
39
|
import './ez-base.css';
|
|
25
40
|
import './ez/themes/ez-theme.scss';
|
|
26
41
|
import './ez/themes/ez-theme-slate.scss';
|
|
42
|
+
import { registerIcons } from './ez/components/icon/icons.js';
|
|
43
|
+
import { ICONS } from './app/config/icons.config.js';`
|
|
44
|
+
: `import 'ezfw-core';
|
|
45
|
+
import 'ezfw-core/ez-base.css';
|
|
46
|
+
import 'ezfw-core/themes/ez-theme.scss';
|
|
47
|
+
import 'ezfw-core/themes/ez-theme-slate.scss';
|
|
48
|
+
import { registerIcons } from 'ezfw-core/components/icon/icons.js';
|
|
49
|
+
import { ICONS } from './app/config/icons.config.js';`;
|
|
50
|
+
|
|
51
|
+
// Framework module globs differ based on mode
|
|
52
|
+
const fwModulesGlob = mode === 'local'
|
|
53
|
+
? `const frameworkModules = import.meta.glob([
|
|
54
|
+
'./ez/**/*.{js,jsx,ts,tsx}',
|
|
55
|
+
'!./ez/islands/**',
|
|
56
|
+
'!./ez/**/*.test.{js,ts}',
|
|
57
|
+
'!./ez/**/*.example.{js,ts}',
|
|
58
|
+
'!./ez/**/*Plugin.{js,ts}'
|
|
59
|
+
]);`
|
|
60
|
+
: `const frameworkModules = import.meta.glob([
|
|
61
|
+
'./node_modules/ezfw-core/**/*.{js,jsx,ts,tsx}',
|
|
62
|
+
'!./node_modules/ezfw-core/islands/**',
|
|
63
|
+
'!./node_modules/ezfw-core/**/*.test.{js,ts}',
|
|
64
|
+
'!./node_modules/ezfw-core/**/*.example.{js,ts}',
|
|
65
|
+
'!./node_modules/ezfw-core/**/*Plugin.{js,ts}'
|
|
66
|
+
]);`;
|
|
67
|
+
|
|
68
|
+
const fwStylesGlob = mode === 'local'
|
|
69
|
+
? `const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');`
|
|
70
|
+
: `const frameworkStyles = import.meta.glob('./node_modules/ezfw-core/**/*.module.scss');`;
|
|
71
|
+
|
|
72
|
+
return `// Generated by Ez Framework - DO NOT EDIT
|
|
73
|
+
// Configuration: ez.config.js
|
|
74
|
+
// Mode: ${mode}
|
|
75
|
+
|
|
76
|
+
${fwImports}
|
|
27
77
|
import { fetchConfigResolver } from './app/fetchConfig.js';
|
|
28
78
|
import { routeResolver } from './app/routes.js';
|
|
29
79
|
import stylesConfig from './ez.styles.config.js';
|
|
@@ -41,14 +91,9 @@ ${i18nCode}
|
|
|
41
91
|
|
|
42
92
|
// Framework internals
|
|
43
93
|
ez.defineStyles(stylesConfig);
|
|
94
|
+
registerIcons(ICONS);
|
|
44
95
|
|
|
45
|
-
|
|
46
|
-
'./ez/**/*.{js,jsx,ts,tsx}',
|
|
47
|
-
'!./ez/islands/**',
|
|
48
|
-
'!./ez/**/*.test.{js,ts}',
|
|
49
|
-
'!./ez/**/*.example.{js,ts}',
|
|
50
|
-
'!./ez/**/*Plugin.{js,ts}'
|
|
51
|
-
]);
|
|
96
|
+
${fwModulesGlob}
|
|
52
97
|
|
|
53
98
|
const desktopModules = import.meta.glob([
|
|
54
99
|
'./app/**/*.{js,jsx,ts,tsx}',
|
|
@@ -61,7 +106,7 @@ const desktopModules = import.meta.glob([
|
|
|
61
106
|
const mobileModules = import.meta.glob('./app/**/*.mobile.{js,jsx,ts,tsx}');
|
|
62
107
|
const tabletModules = import.meta.glob('./app/**/*.tablet.{js,jsx,ts,tsx}');
|
|
63
108
|
|
|
64
|
-
|
|
109
|
+
${fwStylesGlob}
|
|
65
110
|
const appStyles = import.meta.glob('./app/**/*.module.scss');
|
|
66
111
|
|
|
67
112
|
ez.installModules({
|
|
@@ -100,19 +145,53 @@ if (!window.__EZ_SSR_MODE__) {
|
|
|
100
145
|
/**
|
|
101
146
|
* Generate the SSR hydration entry point code (hydrate.js)
|
|
102
147
|
*/
|
|
103
|
-
function generateHydrateCode(config) {
|
|
148
|
+
function generateHydrateCode(config, mode) {
|
|
104
149
|
const theme = config.theme || 'slate-dark';
|
|
105
150
|
const i18nCode = config.i18n
|
|
106
151
|
? `ez.setLanguages(${JSON.stringify(config.i18n.languages)}, { default: '${config.i18n.default}', debug: ${config.i18n.debug || false} });`
|
|
107
152
|
: '';
|
|
108
153
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
import './ez/core/ez.js';
|
|
154
|
+
// Framework imports differ based on mode
|
|
155
|
+
const fwImports = mode === 'local'
|
|
156
|
+
? `import './ez/core/ez.js';
|
|
113
157
|
import './ez-base.css';
|
|
114
158
|
import './ez/themes/ez-theme.scss';
|
|
115
159
|
import './ez/themes/ez-theme-slate.scss';
|
|
160
|
+
import { registerIcons } from './ez/components/icon/icons.js';
|
|
161
|
+
import { ICONS } from './app/config/icons.config.js';`
|
|
162
|
+
: `import 'ezfw-core';
|
|
163
|
+
import 'ezfw-core/ez-base.css';
|
|
164
|
+
import 'ezfw-core/themes/ez-theme.scss';
|
|
165
|
+
import 'ezfw-core/themes/ez-theme-slate.scss';
|
|
166
|
+
import { registerIcons } from 'ezfw-core/components/icon/icons.js';
|
|
167
|
+
import { ICONS } from './app/config/icons.config.js';`;
|
|
168
|
+
|
|
169
|
+
// Framework module globs differ based on mode
|
|
170
|
+
const fwModulesGlob = mode === 'local'
|
|
171
|
+
? `const frameworkModules = import.meta.glob([
|
|
172
|
+
'./ez/**/*.{js,jsx,ts,tsx}',
|
|
173
|
+
'!./ez/islands/**',
|
|
174
|
+
'!./ez/**/*.test.{js,ts}',
|
|
175
|
+
'!./ez/**/*.example.{js,ts}',
|
|
176
|
+
'!./ez/**/*Plugin.{js,ts}'
|
|
177
|
+
]);`
|
|
178
|
+
: `const frameworkModules = import.meta.glob([
|
|
179
|
+
'./node_modules/ezfw-core/**/*.{js,jsx,ts,tsx}',
|
|
180
|
+
'!./node_modules/ezfw-core/islands/**',
|
|
181
|
+
'!./node_modules/ezfw-core/**/*.test.{js,ts}',
|
|
182
|
+
'!./node_modules/ezfw-core/**/*.example.{js,ts}',
|
|
183
|
+
'!./node_modules/ezfw-core/**/*Plugin.{js,ts}'
|
|
184
|
+
]);`;
|
|
185
|
+
|
|
186
|
+
const fwStylesGlob = mode === 'local'
|
|
187
|
+
? `const frameworkStyles = import.meta.glob('./ez/**/*.module.scss');`
|
|
188
|
+
: `const frameworkStyles = import.meta.glob('./node_modules/ezfw-core/**/*.module.scss');`;
|
|
189
|
+
|
|
190
|
+
return `// Generated by Ez Framework - DO NOT EDIT
|
|
191
|
+
// Configuration: ez.config.js
|
|
192
|
+
// Mode: ${mode}
|
|
193
|
+
|
|
194
|
+
${fwImports}
|
|
116
195
|
import { fetchConfigResolver } from './app/fetchConfig.js';
|
|
117
196
|
import { routeResolver } from './app/routes.js';
|
|
118
197
|
import stylesConfig from './ez.styles.config.js';
|
|
@@ -130,14 +209,9 @@ ${i18nCode}
|
|
|
130
209
|
|
|
131
210
|
// Framework internals
|
|
132
211
|
ez.defineStyles(stylesConfig);
|
|
212
|
+
registerIcons(ICONS);
|
|
133
213
|
|
|
134
|
-
|
|
135
|
-
'./ez/**/*.{js,jsx,ts,tsx}',
|
|
136
|
-
'!./ez/islands/**',
|
|
137
|
-
'!./ez/**/*.test.{js,ts}',
|
|
138
|
-
'!./ez/**/*.example.{js,ts}',
|
|
139
|
-
'!./ez/**/*Plugin.{js,ts}'
|
|
140
|
-
]);
|
|
214
|
+
${fwModulesGlob}
|
|
141
215
|
|
|
142
216
|
const desktopModules = import.meta.glob([
|
|
143
217
|
'./app/**/*.{js,jsx,ts,tsx}',
|
|
@@ -150,7 +224,7 @@ const desktopModules = import.meta.glob([
|
|
|
150
224
|
const mobileModules = import.meta.glob('./app/**/*.mobile.{js,jsx,ts,tsx}');
|
|
151
225
|
const tabletModules = import.meta.glob('./app/**/*.tablet.{js,jsx,ts,tsx}');
|
|
152
226
|
|
|
153
|
-
|
|
227
|
+
${fwStylesGlob}
|
|
154
228
|
const appStyles = import.meta.glob('./app/**/*.module.scss');
|
|
155
229
|
|
|
156
230
|
ez.installModules({
|
|
@@ -237,10 +311,14 @@ export function ezEntry() {
|
|
|
237
311
|
// Reload config on each transform (for HMR support)
|
|
238
312
|
config = await loadConfig(root);
|
|
239
313
|
|
|
314
|
+
// Detect if using local ./ez folder or ezfw-core from npm
|
|
315
|
+
const mode = detectFrameworkMode(root);
|
|
316
|
+
console.log('[Ez Entry] Framework mode:', mode);
|
|
317
|
+
|
|
240
318
|
if (fileName === 'index.js') {
|
|
241
319
|
console.log('[Ez Entry] Generating index.js');
|
|
242
320
|
return {
|
|
243
|
-
code: generateIndexCode(config),
|
|
321
|
+
code: generateIndexCode(config, mode),
|
|
244
322
|
map: null
|
|
245
323
|
};
|
|
246
324
|
}
|
|
@@ -248,7 +326,7 @@ export function ezEntry() {
|
|
|
248
326
|
if (fileName === 'hydrate.js') {
|
|
249
327
|
console.log('[Ez Entry] Generating hydrate.js');
|
|
250
328
|
return {
|
|
251
|
-
code: generateHydrateCode(config),
|
|
329
|
+
code: generateHydrateCode(config, mode),
|
|
252
330
|
map: null
|
|
253
331
|
};
|
|
254
332
|
}
|