@shohojdhara/atomix 0.5.2 → 0.5.4
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/atomix.config.ts +33 -33
- package/dist/config.d.ts +187 -112
- package/dist/config.js +7 -49
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1958 -900
- package/dist/index.esm.js +2275 -383
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2327 -417
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +1390 -276
- package/dist/theme.js +2129 -621
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/scripts/cli/internal/config-loader.js +30 -20
- package/src/lib/config/index.ts +38 -362
- package/src/lib/config/loader.ts +419 -0
- package/src/lib/config/public-api.ts +43 -0
- package/src/lib/config/types.ts +389 -0
- package/src/lib/config/validator.ts +305 -0
- package/src/lib/theme/adapters/index.ts +1 -1
- package/src/lib/theme/adapters/themeAdapter.ts +358 -229
- package/src/lib/theme/components/ThemeToggle.tsx +276 -0
- package/src/lib/theme/config/configLoader.ts +351 -0
- package/src/lib/theme/config/loader.ts +221 -0
- package/src/lib/theme/core/createTheme.ts +126 -50
- package/src/lib/theme/core/createThemeObject.ts +7 -4
- package/src/lib/theme/hooks/useThemeSwitcher.ts +164 -0
- package/src/lib/theme/index.ts +322 -38
- package/src/lib/theme/runtime/ThemeProvider.tsx +44 -10
- package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +44 -393
- package/src/lib/theme/runtime/useTheme.ts +1 -0
- package/src/lib/theme/tokens/tokens.ts +101 -1
- package/src/lib/theme/types.ts +91 -0
- package/src/lib/theme/utils/performanceMonitor.ts +315 -0
- package/src/lib/theme/utils/responsive.ts +280 -0
- package/src/lib/theme/utils/themeUtils.ts +531 -117
- package/src/styles/05-objects/_objects.masonry-grid.scss +3 -3
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Atomix configuration system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Theme } from '../theme/types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Design token categories
|
|
11
|
+
*/
|
|
12
|
+
export type DesignTokenCategory =
|
|
13
|
+
| 'colors'
|
|
14
|
+
| 'spacing'
|
|
15
|
+
| 'typography'
|
|
16
|
+
| 'borderRadius'
|
|
17
|
+
| 'shadows'
|
|
18
|
+
| 'zIndex'
|
|
19
|
+
| 'transitions'
|
|
20
|
+
| 'breakpoints';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Design token value types
|
|
24
|
+
*/
|
|
25
|
+
export type DesignTokenValue = string | number;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Color Scale (1-10)
|
|
29
|
+
*/
|
|
30
|
+
export interface ColorScale {
|
|
31
|
+
1?: string;
|
|
32
|
+
2?: string;
|
|
33
|
+
3?: string;
|
|
34
|
+
4?: string;
|
|
35
|
+
5?: string;
|
|
36
|
+
6?: string;
|
|
37
|
+
7?: string;
|
|
38
|
+
8?: string;
|
|
39
|
+
9?: string;
|
|
40
|
+
10?: string;
|
|
41
|
+
[key: string]: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Palette Color Options
|
|
46
|
+
*/
|
|
47
|
+
export interface PaletteColorOptions {
|
|
48
|
+
main: string;
|
|
49
|
+
light?: string;
|
|
50
|
+
dark?: string;
|
|
51
|
+
contrastText?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Interactive Effect Configuration
|
|
56
|
+
*/
|
|
57
|
+
export interface InteractiveEffectsConfig {
|
|
58
|
+
/** Vortex & flow field effects */
|
|
59
|
+
vortex?: {
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
strength?: number;
|
|
62
|
+
radius?: number;
|
|
63
|
+
decay?: number;
|
|
64
|
+
curlNoise?: boolean;
|
|
65
|
+
velocityTracking?: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Chromatic aberration effects */
|
|
69
|
+
chromaticAberration?: {
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
mode?: 'longitudinal' | 'lateral' | 'hybrid';
|
|
72
|
+
redShift?: number;
|
|
73
|
+
greenShift?: number;
|
|
74
|
+
blueShift?: number;
|
|
75
|
+
edgeOnly?: boolean;
|
|
76
|
+
edgeThreshold?: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Mouse interaction settings */
|
|
80
|
+
mouseInteraction?: {
|
|
81
|
+
sensitivity?: number;
|
|
82
|
+
trailEffect?: boolean;
|
|
83
|
+
pressureSensitivity?: boolean;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Animation speed controls */
|
|
87
|
+
animationSpeed?: {
|
|
88
|
+
base?: number;
|
|
89
|
+
timeMultiplier?: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Optimization Configuration
|
|
95
|
+
*/
|
|
96
|
+
export interface OptimizationConfig {
|
|
97
|
+
/** Responsive breakpoint system */
|
|
98
|
+
responsive?: {
|
|
99
|
+
breakpoints?: {
|
|
100
|
+
mobile?: string;
|
|
101
|
+
tablet?: string;
|
|
102
|
+
desktop?: string;
|
|
103
|
+
wide?: string;
|
|
104
|
+
};
|
|
105
|
+
/** Device-aware parameter scaling */
|
|
106
|
+
deviceScaling?: {
|
|
107
|
+
mobile?: number;
|
|
108
|
+
tablet?: number;
|
|
109
|
+
desktop?: number;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Performance monitoring */
|
|
114
|
+
performance?: {
|
|
115
|
+
enabled?: boolean;
|
|
116
|
+
fpsTarget?: number;
|
|
117
|
+
autoScaling?: boolean;
|
|
118
|
+
monitorDashboard?: boolean;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** Auto-scaling logic based on device capabilities */
|
|
122
|
+
autoScaling?: {
|
|
123
|
+
enabled?: boolean;
|
|
124
|
+
qualityThresholds?: {
|
|
125
|
+
lowEnd?: number;
|
|
126
|
+
midRange?: number;
|
|
127
|
+
highEnd?: number;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Visual Polish Configuration
|
|
134
|
+
*/
|
|
135
|
+
export interface VisualPolishConfig {
|
|
136
|
+
/** Advanced border effects */
|
|
137
|
+
borders?: {
|
|
138
|
+
iridescentGlow?: boolean;
|
|
139
|
+
shimmerEffect?: boolean;
|
|
140
|
+
beveledEdges?: boolean;
|
|
141
|
+
pulsingGlow?: boolean;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/** Content-aware blur */
|
|
145
|
+
contentAwareBlur?: {
|
|
146
|
+
enabled?: boolean;
|
|
147
|
+
depthDetection?: boolean;
|
|
148
|
+
edgePreservation?: boolean;
|
|
149
|
+
variableRadius?: boolean;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Holographic effect modes */
|
|
153
|
+
holographicEffects?: {
|
|
154
|
+
enabled?: boolean;
|
|
155
|
+
rainbowDiffraction?: boolean;
|
|
156
|
+
scanlineAnimation?: boolean;
|
|
157
|
+
gridOverlay?: boolean;
|
|
158
|
+
dataStream?: boolean;
|
|
159
|
+
pulseRings?: boolean;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Design Tokens Schema (Tailwind-like)
|
|
165
|
+
*/
|
|
166
|
+
export interface ThemeTokens {
|
|
167
|
+
/** Color palette */
|
|
168
|
+
colors?: Record<string, string | PaletteColorOptions | ColorScale | Record<string, string>>;
|
|
169
|
+
/** Spacing scale */
|
|
170
|
+
spacing?: Record<string, string>;
|
|
171
|
+
/** Border radius scale */
|
|
172
|
+
borderRadius?: Record<string, string>;
|
|
173
|
+
/** Typography scale and settings */
|
|
174
|
+
typography?: {
|
|
175
|
+
fontFamilies?: Record<string, string>;
|
|
176
|
+
fontSizes?: Record<string, string>;
|
|
177
|
+
fontWeights?: Record<string, string | number>;
|
|
178
|
+
lineHeights?: Record<string, string | number>;
|
|
179
|
+
letterSpacings?: Record<string, string>;
|
|
180
|
+
};
|
|
181
|
+
/** Shadow scale */
|
|
182
|
+
shadows?: Record<string, string>;
|
|
183
|
+
/** Z-index scale */
|
|
184
|
+
zIndex?: Record<string, string | number>;
|
|
185
|
+
/** Breakpoints scale */
|
|
186
|
+
breakpoints?: Record<string, string | number>;
|
|
187
|
+
/** Transitions settings */
|
|
188
|
+
transitions?: {
|
|
189
|
+
durations?: Record<string, string>;
|
|
190
|
+
easings?: Record<string, string>;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* CSS Theme Definition
|
|
196
|
+
*/
|
|
197
|
+
export interface CSSThemeDefinition {
|
|
198
|
+
type: 'css';
|
|
199
|
+
name: string;
|
|
200
|
+
class?: string;
|
|
201
|
+
description?: string;
|
|
202
|
+
author?: string;
|
|
203
|
+
version?: string;
|
|
204
|
+
tags?: string[];
|
|
205
|
+
supportsDarkMode?: boolean;
|
|
206
|
+
status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
207
|
+
a11y?: {
|
|
208
|
+
contrastTarget?: number;
|
|
209
|
+
modes?: string[];
|
|
210
|
+
};
|
|
211
|
+
color?: string;
|
|
212
|
+
features?: string[];
|
|
213
|
+
dependencies?: string[];
|
|
214
|
+
cssPath?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* JavaScript Theme Definition
|
|
219
|
+
*/
|
|
220
|
+
export interface JSThemeDefinition {
|
|
221
|
+
type: 'js';
|
|
222
|
+
name: string;
|
|
223
|
+
class?: string;
|
|
224
|
+
description?: string;
|
|
225
|
+
author?: string;
|
|
226
|
+
version?: string;
|
|
227
|
+
tags?: string[];
|
|
228
|
+
supportsDarkMode?: boolean;
|
|
229
|
+
status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
230
|
+
a11y?: {
|
|
231
|
+
contrastTarget?: number;
|
|
232
|
+
modes?: string[];
|
|
233
|
+
};
|
|
234
|
+
color?: string;
|
|
235
|
+
features?: string[];
|
|
236
|
+
dependencies?: string[];
|
|
237
|
+
createTheme: () => Theme;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Theme Definition (CSS or JS)
|
|
242
|
+
*/
|
|
243
|
+
export type ThemeDefinition = CSSThemeDefinition | JSThemeDefinition;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Build configuration
|
|
247
|
+
*/
|
|
248
|
+
export interface BuildConfig {
|
|
249
|
+
output?: {
|
|
250
|
+
directory?: string;
|
|
251
|
+
formats?: {
|
|
252
|
+
expanded?: string;
|
|
253
|
+
compressed?: string;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
sass?: {
|
|
257
|
+
style?: 'expanded' | 'compressed';
|
|
258
|
+
sourceMap?: boolean;
|
|
259
|
+
loadPaths?: string[];
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Runtime configuration
|
|
265
|
+
*/
|
|
266
|
+
export interface RuntimeConfig {
|
|
267
|
+
basePath?: string;
|
|
268
|
+
cdnPath?: string | null;
|
|
269
|
+
preload?: string[];
|
|
270
|
+
lazy?: boolean;
|
|
271
|
+
defaultTheme?: string;
|
|
272
|
+
storageKey?: string;
|
|
273
|
+
dataAttribute?: string;
|
|
274
|
+
enablePersistence?: boolean;
|
|
275
|
+
useMinified?: boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Integration settings
|
|
280
|
+
*/
|
|
281
|
+
export interface IntegrationConfig {
|
|
282
|
+
cssVariables?: Record<string, string>;
|
|
283
|
+
classNames?: {
|
|
284
|
+
theme?: string;
|
|
285
|
+
colorMode?: string;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Plugin Configuration
|
|
291
|
+
*/
|
|
292
|
+
export interface PluginConfig {
|
|
293
|
+
name: string;
|
|
294
|
+
options?: Record<string, any>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Token Provider Configuration
|
|
299
|
+
*/
|
|
300
|
+
export interface TokenProviderConfig {
|
|
301
|
+
type: 'figma' | 'style-dictionary' | 'w3c' | string;
|
|
302
|
+
options?: Record<string, any>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Token Engine Configuration
|
|
307
|
+
*/
|
|
308
|
+
export interface TokenEngineConfig {
|
|
309
|
+
providers?: Record<string, TokenProviderConfig>;
|
|
310
|
+
sync?: {
|
|
311
|
+
pull?: boolean;
|
|
312
|
+
push?: boolean;
|
|
313
|
+
onBuild?: boolean;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* CLI component generator defaults
|
|
319
|
+
*/
|
|
320
|
+
export interface GeneratorConfig {
|
|
321
|
+
/** Default output directory for generated components */
|
|
322
|
+
outputPath?: string;
|
|
323
|
+
/** Override detected framework */
|
|
324
|
+
framework?: 'react' | 'next' | 'vanilla';
|
|
325
|
+
/** Per-feature defaults */
|
|
326
|
+
features?: {
|
|
327
|
+
storybook?: boolean;
|
|
328
|
+
hook?: boolean;
|
|
329
|
+
styles?: boolean;
|
|
330
|
+
tests?: boolean;
|
|
331
|
+
};
|
|
332
|
+
/** Composable hooks directory relative to project root */
|
|
333
|
+
hookOutputDir?: string;
|
|
334
|
+
/** Story file: side-effect import for global Atomix styles */
|
|
335
|
+
storybookCssImport?: string;
|
|
336
|
+
/** Barrel file strategy for new components */
|
|
337
|
+
barrel?: 'index' | 'none';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Atomix Configuration Interface
|
|
342
|
+
*
|
|
343
|
+
* Tailwind-like configuration for external developers.
|
|
344
|
+
*/
|
|
345
|
+
export interface AtomixConfig {
|
|
346
|
+
prefix?: string;
|
|
347
|
+
plugins?: (string | PluginConfig)[];
|
|
348
|
+
tokenEngine?: TokenEngineConfig;
|
|
349
|
+
ai?: {
|
|
350
|
+
provider?: 'openai' | 'anthropic';
|
|
351
|
+
model?: string;
|
|
352
|
+
apiKey?: string;
|
|
353
|
+
temperature?: number;
|
|
354
|
+
maxTokens?: number;
|
|
355
|
+
rateLimit?: {
|
|
356
|
+
requests: number;
|
|
357
|
+
windowMs: number;
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
telemetry?: {
|
|
361
|
+
enabled?: boolean;
|
|
362
|
+
path?: string;
|
|
363
|
+
anonymize?: boolean;
|
|
364
|
+
};
|
|
365
|
+
generator?: GeneratorConfig;
|
|
366
|
+
interactiveEffects?: InteractiveEffectsConfig;
|
|
367
|
+
optimization?: OptimizationConfig;
|
|
368
|
+
visualPolish?: VisualPolishConfig;
|
|
369
|
+
theme?: {
|
|
370
|
+
extend?: ThemeTokens;
|
|
371
|
+
tokens?: ThemeTokens;
|
|
372
|
+
themes?: Record<string, ThemeDefinition>;
|
|
373
|
+
};
|
|
374
|
+
/** @internal Build configuration */
|
|
375
|
+
build?: BuildConfig;
|
|
376
|
+
/** @internal Runtime configuration */
|
|
377
|
+
runtime?: RuntimeConfig;
|
|
378
|
+
/** @internal Integration settings */
|
|
379
|
+
integration?: IntegrationConfig;
|
|
380
|
+
/** @internal Theme dependencies mapping */
|
|
381
|
+
dependencies?: Record<string, string[]>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Helper function to define Atomix configuration with type safety
|
|
386
|
+
*/
|
|
387
|
+
export function defineConfig(config: AtomixConfig): AtomixConfig {
|
|
388
|
+
return config;
|
|
389
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Validator
|
|
3
|
+
*
|
|
4
|
+
* Provides detailed validation and feedback for Atomix configurations,
|
|
5
|
+
* especially for advanced features (Phases 2, 3, and 4).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { AtomixConfig } from './types';
|
|
9
|
+
import { validateConfig } from './loader';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Validation result with detailed information
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidationResult {
|
|
15
|
+
/** Whether the configuration is valid */
|
|
16
|
+
isValid: boolean;
|
|
17
|
+
/** Warnings about potential issues */
|
|
18
|
+
warnings: string[];
|
|
19
|
+
/** Suggestions for improvement */
|
|
20
|
+
suggestions: string[];
|
|
21
|
+
/** Performance impact assessment */
|
|
22
|
+
performanceImpact: 'low' | 'medium' | 'high';
|
|
23
|
+
/** Compatibility report */
|
|
24
|
+
compatibility: {
|
|
25
|
+
/** Browser support status */
|
|
26
|
+
browsers: boolean;
|
|
27
|
+
/** SSR support status */
|
|
28
|
+
ssr: boolean;
|
|
29
|
+
/** Framework compatibility */
|
|
30
|
+
frameworks: ('react' | 'vue' | 'angular' | 'svelte' | 'vanillajs')[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validate an Atomix configuration with detailed feedback
|
|
36
|
+
*
|
|
37
|
+
* @param config - The configuration to validate
|
|
38
|
+
* @param options - Validation options
|
|
39
|
+
* @returns Detailed validation result
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { validateConfiguration } from '@shohojdhara/atomix/config';
|
|
44
|
+
*
|
|
45
|
+
* const config = { /* your config *\/ };
|
|
46
|
+
* const result = validateConfiguration(config);
|
|
47
|
+
*
|
|
48
|
+
* if (!result.isValid) {
|
|
49
|
+
* console.warn('Warnings:', result.warnings);
|
|
50
|
+
* console.info('Suggestions:', result.suggestions);
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function validateConfiguration(
|
|
55
|
+
config: AtomixConfig,
|
|
56
|
+
options?: {
|
|
57
|
+
/** Include performance impact analysis (default: true) */
|
|
58
|
+
performanceAnalysis?: boolean;
|
|
59
|
+
/** Include compatibility report (default: true) */
|
|
60
|
+
compatibilityReport?: boolean;
|
|
61
|
+
}
|
|
62
|
+
): ValidationResult {
|
|
63
|
+
const { performanceAnalysis = true, compatibilityReport = true } = options || {};
|
|
64
|
+
|
|
65
|
+
const warnings: string[] = [];
|
|
66
|
+
const suggestions: string[] = [];
|
|
67
|
+
let performanceImpact: 'low' | 'medium' | 'high' = 'low';
|
|
68
|
+
|
|
69
|
+
// Use the existing validation
|
|
70
|
+
const baseWarnings = validateConfig(config);
|
|
71
|
+
warnings.push(...baseWarnings);
|
|
72
|
+
|
|
73
|
+
// Analyze advanced features for performance impact
|
|
74
|
+
if (performanceAnalysis) {
|
|
75
|
+
performanceImpact = analyzePerformanceImpact(config);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Generate suggestions based on configuration
|
|
79
|
+
generateSuggestions(config, suggestions);
|
|
80
|
+
|
|
81
|
+
// Determine overall validity
|
|
82
|
+
const isValid = warnings.length === 0;
|
|
83
|
+
|
|
84
|
+
// Generate compatibility report
|
|
85
|
+
const compatibility = compatibilityReport
|
|
86
|
+
? generateCompatibilityReport(config)
|
|
87
|
+
: {
|
|
88
|
+
browsers: true,
|
|
89
|
+
ssr: true,
|
|
90
|
+
frameworks: ['react', 'vue', 'angular', 'svelte', 'vanillajs'] as ('react' | 'vue' | 'angular' | 'svelte' | 'vanillajs')[]
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
isValid,
|
|
95
|
+
warnings,
|
|
96
|
+
suggestions,
|
|
97
|
+
performanceImpact,
|
|
98
|
+
compatibility
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Analyze the performance impact of a configuration
|
|
104
|
+
*/
|
|
105
|
+
function analyzePerformanceImpact(config: AtomixConfig): 'low' | 'medium' | 'high' {
|
|
106
|
+
let impactScore = 0;
|
|
107
|
+
|
|
108
|
+
// Analyze interactive effects
|
|
109
|
+
if (config.interactiveEffects) {
|
|
110
|
+
const ie = config.interactiveEffects;
|
|
111
|
+
|
|
112
|
+
if (ie.vortex?.enabled) {
|
|
113
|
+
impactScore += 2;
|
|
114
|
+
}
|
|
115
|
+
if (ie.chromaticAberration?.enabled) {
|
|
116
|
+
impactScore += 1;
|
|
117
|
+
}
|
|
118
|
+
if (ie.mouseInteraction?.trailEffect) {
|
|
119
|
+
impactScore += 1;
|
|
120
|
+
}
|
|
121
|
+
if (ie.mouseInteraction?.pressureSensitivity) {
|
|
122
|
+
impactScore += 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Analyze visual polish effects
|
|
127
|
+
if (config.visualPolish) {
|
|
128
|
+
const vp = config.visualPolish;
|
|
129
|
+
|
|
130
|
+
if (vp.borders?.iridescentGlow) {
|
|
131
|
+
impactScore += 1;
|
|
132
|
+
}
|
|
133
|
+
if (vp.borders?.shimmerEffect) {
|
|
134
|
+
impactScore += 1;
|
|
135
|
+
}
|
|
136
|
+
if (vp.contentAwareBlur?.enabled) {
|
|
137
|
+
impactScore += 2;
|
|
138
|
+
}
|
|
139
|
+
if (vp.holographicEffects?.enabled) {
|
|
140
|
+
impactScore += 2;
|
|
141
|
+
}
|
|
142
|
+
if (vp.holographicEffects?.scanlineAnimation) {
|
|
143
|
+
impactScore += 1;
|
|
144
|
+
}
|
|
145
|
+
if (vp.holographicEffects?.dataStream) {
|
|
146
|
+
impactScore += 1;
|
|
147
|
+
}
|
|
148
|
+
if (vp.holographicEffects?.pulseRings) {
|
|
149
|
+
impactScore += 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Analyze optimization settings
|
|
154
|
+
if (config.optimization?.autoScaling?.enabled) {
|
|
155
|
+
impactScore -= 1; // This improves performance
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (impactScore >= 6) return 'high';
|
|
159
|
+
if (impactScore >= 3) return 'medium';
|
|
160
|
+
return 'low';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generate suggestions based on the configuration
|
|
165
|
+
*/
|
|
166
|
+
function generateSuggestions(config: AtomixConfig, suggestions: string[]): void {
|
|
167
|
+
// Suggest enabling performance optimizations if heavy effects are used
|
|
168
|
+
if (config.interactiveEffects || config.visualPolish?.holographicEffects?.enabled) {
|
|
169
|
+
if (!config.optimization?.autoScaling?.enabled) {
|
|
170
|
+
suggestions.push(
|
|
171
|
+
'Consider enabling auto-scaling in optimization settings to adjust effects ' +
|
|
172
|
+
'based on device performance: optimization.autoScaling.enabled = true'
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!config.optimization?.performance?.fpsTarget) {
|
|
177
|
+
suggestions.push(
|
|
178
|
+
'Set a target FPS in optimization.performance.fpsTarget to ensure smooth performance ' +
|
|
179
|
+
'when using interactive effects'
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Suggest responsive breakpoints if optimization is partially configured
|
|
185
|
+
if (config.optimization && !config.optimization.responsive) {
|
|
186
|
+
suggestions.push(
|
|
187
|
+
'Consider adding responsive breakpoints in optimization.responsive.breakpoints ' +
|
|
188
|
+
'to adapt advanced effects based on device type'
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Suggest disabling heavy effects on lower-end devices
|
|
193
|
+
if (config.visualPolish?.holographicEffects?.enabled) {
|
|
194
|
+
suggestions.push(
|
|
195
|
+
'For better performance on lower-end devices, consider conditionally disabling ' +
|
|
196
|
+
'holographic effects based on device capabilities'
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Suggest using content-aware blur with performance considerations
|
|
201
|
+
if (config.visualPolish?.contentAwareBlur?.enabled) {
|
|
202
|
+
suggestions.push(
|
|
203
|
+
'Content-aware blur can be expensive; consider setting a maximum blur radius ' +
|
|
204
|
+
'or using simpler blur techniques for mobile devices'
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Suggest using chromatic aberration适度
|
|
209
|
+
if (config.interactiveEffects?.chromaticAberration?.enabled) {
|
|
210
|
+
if (config.interactiveEffects.chromaticAberration.redShift &&
|
|
211
|
+
Math.abs(config.interactiveEffects.chromaticAberration.redShift) > 0.05) {
|
|
212
|
+
suggestions.push(
|
|
213
|
+
'High chromatic aberration red shift values (>0.05) may cause discomfort for some users; ' +
|
|
214
|
+
'consider reducing to improve accessibility'
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (config.interactiveEffects.chromaticAberration.blueShift &&
|
|
219
|
+
Math.abs(config.interactiveEffects.chromaticAberration.blueShift) > 0.05) {
|
|
220
|
+
suggestions.push(
|
|
221
|
+
'High chromatic aberration blue shift values (>0.05) may cause discomfort for some users; ' +
|
|
222
|
+
'consider reducing to improve accessibility'
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Generate a compatibility report for the configuration
|
|
230
|
+
*/
|
|
231
|
+
function generateCompatibilityReport(config: AtomixConfig): ValidationResult['compatibility'] {
|
|
232
|
+
// Advanced effects may not work well on older browsers
|
|
233
|
+
const hasHeavyEffects =
|
|
234
|
+
config.visualPolish?.holographicEffects?.enabled ||
|
|
235
|
+
config.visualPolish?.contentAwareBlur?.enabled ||
|
|
236
|
+
config.interactiveEffects?.vortex?.enabled ||
|
|
237
|
+
config.interactiveEffects?.chromaticAberration?.enabled;
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
browsers: !hasHeavyEffects, // May have issues on older browsers
|
|
241
|
+
ssr: true, // Works fine with SSR
|
|
242
|
+
frameworks: ['react', 'vue', 'angular', 'svelte', 'vanillajs'] as ('react' | 'vue' | 'angular' | 'svelte' | 'vanillajs')[] // Compatible with all
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Print a detailed configuration report to the console
|
|
248
|
+
*
|
|
249
|
+
* @param config - The configuration to analyze
|
|
250
|
+
* @param title - Optional title for the report
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* import { printConfigReport } from '@shohojdhara/atomix/config';
|
|
255
|
+
*
|
|
256
|
+
* const config = { /* your config *\/ };
|
|
257
|
+
* printConfigReport(config, 'My Application Config');
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export function printConfigReport(config: AtomixConfig, title?: string): void {
|
|
261
|
+
const result = validateConfiguration(config);
|
|
262
|
+
|
|
263
|
+
const reportTitle = title ? `Atomix Configuration Report: ${title}` : 'Atomix Configuration Report';
|
|
264
|
+
console.log(`\n${reportTitle}`);
|
|
265
|
+
console.log('='.repeat(reportTitle.length));
|
|
266
|
+
|
|
267
|
+
console.log(`\n✅ Valid: ${result.isValid ? 'Yes' : 'No'}`);
|
|
268
|
+
console.log(`⚡ Performance Impact: ${result.performanceImpact.toUpperCase()}`);
|
|
269
|
+
|
|
270
|
+
if (result.warnings.length > 0) {
|
|
271
|
+
console.log('\n⚠️ WARNINGS:');
|
|
272
|
+
result.warnings.forEach(warning => {
|
|
273
|
+
console.log(` • ${warning}`);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (result.suggestions.length > 0) {
|
|
278
|
+
console.log('\n💡 SUGGESTIONS:');
|
|
279
|
+
result.suggestions.forEach(suggestion => {
|
|
280
|
+
console.log(` • ${suggestion}`);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
console.log('\n🌐 COMPATIBILITY:');
|
|
285
|
+
console.log(` Browser Support: ${result.compatibility.browsers ? '✅ Good' : '⚠️ May have issues'}`);
|
|
286
|
+
console.log(` SSR Support: ${result.compatibility.ssr ? '✅ Full' : '❌ Limited'}`);
|
|
287
|
+
|
|
288
|
+
console.log('\n📋 FEATURES DETECTED:');
|
|
289
|
+
const featuresDetected = [];
|
|
290
|
+
|
|
291
|
+
if (config.interactiveEffects) featuresDetected.push('Interactive Effects');
|
|
292
|
+
if (config.optimization) featuresDetected.push('Optimization');
|
|
293
|
+
if (config.visualPolish) featuresDetected.push('Visual Polish');
|
|
294
|
+
if (config.ai) featuresDetected.push('AI Integration');
|
|
295
|
+
if (config.tokenEngine) featuresDetected.push('Token Engine');
|
|
296
|
+
if (config.generator) featuresDetected.push('Component Generator');
|
|
297
|
+
|
|
298
|
+
if (featuresDetected.length > 0) {
|
|
299
|
+
featuresDetected.forEach(feature => console.log(` • ${feature}`));
|
|
300
|
+
} else {
|
|
301
|
+
console.log(' • None - Standard configuration');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
console.log('');
|
|
305
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Adapters for working with DesignTokens and CSS variables
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export { designTokensToCSSVars } from './themeAdapter';
|
|
7
|
+
export { designTokensToTheme, themeToDesignTokens, designTokensToCSSVars, configToTokens } from './themeAdapter';
|
|
8
8
|
|
|
9
9
|
export {
|
|
10
10
|
generateCSSVariableName,
|