@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.
Files changed (39) hide show
  1. package/atomix.config.ts +33 -33
  2. package/dist/config.d.ts +187 -112
  3. package/dist/config.js +7 -49
  4. package/dist/config.js.map +1 -1
  5. package/dist/index.d.ts +1958 -900
  6. package/dist/index.esm.js +2275 -383
  7. package/dist/index.esm.js.map +1 -1
  8. package/dist/index.js +2327 -417
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.min.js +1 -1
  11. package/dist/index.min.js.map +1 -1
  12. package/dist/theme.d.ts +1390 -276
  13. package/dist/theme.js +2129 -621
  14. package/dist/theme.js.map +1 -1
  15. package/package.json +1 -1
  16. package/scripts/cli/internal/config-loader.js +30 -20
  17. package/src/lib/config/index.ts +38 -362
  18. package/src/lib/config/loader.ts +419 -0
  19. package/src/lib/config/public-api.ts +43 -0
  20. package/src/lib/config/types.ts +389 -0
  21. package/src/lib/config/validator.ts +305 -0
  22. package/src/lib/theme/adapters/index.ts +1 -1
  23. package/src/lib/theme/adapters/themeAdapter.ts +358 -229
  24. package/src/lib/theme/components/ThemeToggle.tsx +276 -0
  25. package/src/lib/theme/config/configLoader.ts +351 -0
  26. package/src/lib/theme/config/loader.ts +221 -0
  27. package/src/lib/theme/core/createTheme.ts +126 -50
  28. package/src/lib/theme/core/createThemeObject.ts +7 -4
  29. package/src/lib/theme/hooks/useThemeSwitcher.ts +164 -0
  30. package/src/lib/theme/index.ts +322 -38
  31. package/src/lib/theme/runtime/ThemeProvider.tsx +44 -10
  32. package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +44 -393
  33. package/src/lib/theme/runtime/useTheme.ts +1 -0
  34. package/src/lib/theme/tokens/tokens.ts +101 -1
  35. package/src/lib/theme/types.ts +91 -0
  36. package/src/lib/theme/utils/performanceMonitor.ts +315 -0
  37. package/src/lib/theme/utils/responsive.ts +280 -0
  38. package/src/lib/theme/utils/themeUtils.ts +531 -117
  39. package/src/styles/05-objects/_objects.masonry-grid.scss +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shohojdhara/atomix",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Atomix Design System - A modern component library for web applications",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Atomix CLI Configuration Loader
3
- * Supports loading atomix.config.ts and atomix.config.js
3
+ * Supports loading atomix.config.ts, atomix.config.js and atomix.config.json
4
4
  */
5
5
 
6
6
  import { existsSync } from 'fs';
@@ -9,7 +9,7 @@ import { pathToFileURL } from 'url';
9
9
  import { logger } from '../utils/logger.js';
10
10
  import { hookManager } from './hooks.js';
11
11
 
12
- export class ConfigLoader {
12
+ class ConfigLoader {
13
13
  constructor() {
14
14
  this.config = null;
15
15
  this.configPath = null;
@@ -23,7 +23,11 @@ export class ConfigLoader {
23
23
  async load(projectRoot = process.cwd()) {
24
24
  if (this.config) return this.config;
25
25
 
26
- const configFiles = ['atomix.config.ts', 'atomix.config.js'];
26
+ const configFiles = [
27
+ 'atomix.config.ts',
28
+ 'atomix.config.js',
29
+ 'atomix.config.json'
30
+ ];
27
31
  let foundFile = null;
28
32
 
29
33
  for (const file of configFiles) {
@@ -43,23 +47,29 @@ export class ConfigLoader {
43
47
  this.configPath = foundFile;
44
48
 
45
49
  try {
46
- // If it's a TypeScript file, we need to register ts-node
47
- if (foundFile.endsWith('.ts')) {
48
- // Dynamic import to avoid issues in pure JS environments
49
- const { register } = await import('ts-node');
50
- register({
51
- transpileOnly: true,
52
- esm: true,
53
- compilerOptions: {
54
- module: 'ESNext',
55
- target: 'ESNext'
56
- }
57
- });
58
- }
50
+ // Handle JSON files differently from JS/TS files
51
+ if (foundFile.endsWith('.json')) {
52
+ const fs = await import('fs');
53
+ this.config = JSON.parse(fs.readFileSync(foundFile, 'utf8'));
54
+ } else {
55
+ // If it's a TypeScript file, we need to register ts-node
56
+ if (foundFile.endsWith('.ts')) {
57
+ // Dynamic import to avoid issues in pure JS environments
58
+ const { register } = await import('ts-node');
59
+ register({
60
+ transpileOnly: true,
61
+ esm: true,
62
+ compilerOptions: {
63
+ module: 'ESNext',
64
+ target: 'ESNext'
65
+ }
66
+ });
67
+ }
59
68
 
60
- // Use dynamic import for ESM compatibility
61
- const configModule = await import(pathToFileURL(foundFile).href);
62
- this.config = configModule.default || configModule;
69
+ // Use dynamic import for ESM compatibility
70
+ const configModule = await import(pathToFileURL(foundFile).href);
71
+ this.config = configModule.default || configModule;
72
+ }
63
73
 
64
74
  logger.debug(`Loaded configuration from ${foundFile}`);
65
75
 
@@ -159,4 +169,4 @@ export class ConfigLoader {
159
169
  }
160
170
  }
161
171
 
162
- export const configLoader = new ConfigLoader();
172
+ export const configLoader = new ConfigLoader();
@@ -5,367 +5,43 @@
5
5
  *
6
6
  * External developers can create `atomix.config.ts` in their project root
7
7
  * to customize design tokens, similar to Tailwind's tailwind.config.js
8
- *
9
- * @example
10
- * ```typescript
11
- * // atomix.config.ts (in your project)
12
- * import { defineConfig } from '@shohojdhara/atomix/config';
13
- *
14
- * export default defineConfig({
15
- * theme: {
16
- * extend: {
17
- * colors: {
18
- * primary: { main: '#7AFFD7' },
19
- * },
20
- * },
21
- * },
22
- * });
23
- * ```
24
- */
25
-
26
- import type { Theme } from '../theme/types';
27
-
28
- /**
29
- * Color Scale (1-10)
30
- */
31
- export interface ColorScale {
32
- 1?: string;
33
- 2?: string;
34
- 3?: string;
35
- 4?: string;
36
- 5?: string;
37
- 6?: string;
38
- 7?: string;
39
- 8?: string;
40
- 9?: string;
41
- 10?: string;
42
- [key: string]: string | undefined;
43
- }
44
-
45
- /**
46
- * Palette Color Options
47
- */
48
- export interface PaletteColorOptions {
49
- main: string;
50
- light?: string;
51
- dark?: string;
52
- contrastText?: string;
53
- }
54
-
55
- /**
56
- * Design Tokens Schema (Tailwind-like)
57
- */
58
- export interface ThemeTokens {
59
- /** Color palette */
60
- colors?: Record<string, string | PaletteColorOptions | ColorScale | Record<string, string>>;
61
- /** Spacing scale */
62
- spacing?: Record<string, string>;
63
- /** Border radius scale */
64
- borderRadius?: Record<string, string>;
65
- /** Typography scale and settings */
66
- typography?: {
67
- fontFamilies?: Record<string, string>;
68
- fontSizes?: Record<string, string>;
69
- fontWeights?: Record<string, string | number>;
70
- lineHeights?: Record<string, string | number>;
71
- letterSpacings?: Record<string, string>;
72
- };
73
- /** Shadow scale */
74
- shadows?: Record<string, string>;
75
- /** Z-index scale */
76
- zIndex?: Record<string, string | number>;
77
- /** Breakpoints scale */
78
- breakpoints?: Record<string, string | number>;
79
- /** Transitions settings */
80
- transitions?: {
81
- durations?: Record<string, string>;
82
- easings?: Record<string, string>;
83
- };
84
- }
85
-
86
- /**
87
- * CSS Theme Definition
88
- */
89
- export interface CSSThemeDefinition {
90
- type: 'css';
91
- name: string;
92
- class?: string;
93
- description?: string;
94
- author?: string;
95
- version?: string;
96
- tags?: string[];
97
- supportsDarkMode?: boolean;
98
- status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
99
- a11y?: {
100
- contrastTarget?: number;
101
- modes?: string[];
102
- };
103
- color?: string;
104
- features?: string[];
105
- dependencies?: string[];
106
- cssPath?: string;
107
- }
108
-
109
- /**
110
- * JavaScript Theme Definition
111
- */
112
- export interface JSThemeDefinition {
113
- type: 'js';
114
- name: string;
115
- class?: string;
116
- description?: string;
117
- author?: string;
118
- version?: string;
119
- tags?: string[];
120
- supportsDarkMode?: boolean;
121
- status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
122
- a11y?: {
123
- contrastTarget?: number;
124
- modes?: string[];
125
- };
126
- color?: string;
127
- features?: string[];
128
- dependencies?: string[];
129
- createTheme: () => Theme;
130
- }
131
-
132
- /**
133
- * Theme Definition (CSS or JS)
134
- */
135
- export type ThemeDefinition = CSSThemeDefinition | JSThemeDefinition;
136
-
137
- /**
138
- * Build configuration (migrated from theme.config.ts)
139
- */
140
- export interface BuildConfig {
141
- output?: {
142
- directory?: string;
143
- formats?: {
144
- expanded?: string;
145
- compressed?: string;
146
- };
147
- };
148
- sass?: {
149
- style?: 'expanded' | 'compressed';
150
- sourceMap?: boolean;
151
- loadPaths?: string[];
152
- };
153
- }
154
-
155
- /**
156
- * Runtime configuration (migrated from theme.config.ts)
157
- */
158
- export interface RuntimeConfig {
159
- basePath?: string;
160
- cdnPath?: string | null;
161
- preload?: string[];
162
- lazy?: boolean;
163
- defaultTheme?: string;
164
- storageKey?: string;
165
- dataAttribute?: string;
166
- enablePersistence?: boolean;
167
- useMinified?: boolean;
168
- }
169
-
170
- /**
171
- * Integration settings (migrated from theme.config.ts)
172
- */
173
- export interface IntegrationConfig {
174
- cssVariables?: Record<string, string>;
175
- classNames?: {
176
- theme?: string;
177
- colorMode?: string;
178
- };
179
- }
180
-
181
- /**
182
- * Plugin Configuration
183
- */
184
- export interface PluginConfig {
185
- name: string;
186
- options?: Record<string, any>;
187
- }
188
-
189
- /**
190
- * Token Provider Configuration
191
- */
192
- export interface TokenProviderConfig {
193
- type: 'figma' | 'style-dictionary' | 'w3c' | string;
194
- options?: Record<string, any>;
195
- }
196
-
197
- /**
198
- * Token Engine Configuration
199
- */
200
- export interface TokenEngineConfig {
201
- providers?: Record<string, TokenProviderConfig>;
202
- sync?: {
203
- pull?: boolean;
204
- push?: boolean;
205
- onBuild?: boolean;
206
- };
207
- }
208
-
209
- /**
210
- * CLI component generator defaults (merged before CLI flags; flags win).
211
- */
212
- export interface GeneratorConfig {
213
- /** Default output directory for generated components */
214
- outputPath?: string;
215
- /** Override detected framework */
216
- framework?: 'react' | 'next' | 'vanilla';
217
- /** Per-feature defaults (CLI --no-* flags override) */
218
- features?: {
219
- storybook?: boolean;
220
- hook?: boolean;
221
- styles?: boolean;
222
- tests?: boolean;
223
- };
224
- /** Composable hooks directory relative to project root */
225
- hookOutputDir?: string;
226
- /** Story file: side-effect import for global Atomix styles */
227
- storybookCssImport?: string;
228
- /** Barrel file strategy for new components */
229
- barrel?: 'index' | 'none';
230
- }
231
-
232
- /**
233
- * Atomix Configuration Interface
234
- *
235
- * Tailwind-like configuration for external developers.
236
- * Focus on theme customization - build/runtime configs are internal only.
237
8
  */
238
- export interface AtomixConfig {
239
- /**
240
- * CSS variable prefix (default: 'atomix')
241
- *
242
- * Change this to customize all CSS variable names.
243
- * Example: prefix: 'myapp' → --myapp-primary instead of --atomix-primary
244
- */
245
- prefix?: string;
246
-
247
- /**
248
- * Plugins to extend CLI functionality
249
- */
250
- plugins?: (string | PluginConfig)[];
251
-
252
- /**
253
- * Universal Token Engine configuration
254
- */
255
- tokenEngine?: TokenEngineConfig;
256
9
 
257
- /**
258
- * AI-Assisted Scaffolding configuration
259
- */
260
- ai?: {
261
- /** AI provider (default: 'openai') */
262
- provider?: 'openai' | 'anthropic';
263
- /** LLM model to use */
264
- model?: string;
265
- /** API key for the provider */
266
- apiKey?: string;
267
- /** Temperature for AI creativity (0.0-1.0, default: 0.7) */
268
- temperature?: number;
269
- /** Maximum tokens per AI response (default: 4000) */
270
- maxTokens?: number;
271
- /** Rate limiting configuration */
272
- rateLimit?: {
273
- /** Maximum requests allowed */
274
- requests: number;
275
- /** Time window in milliseconds */
276
- windowMs: number;
277
- };
278
- };
279
-
280
- /**
281
- * Performance & Telemetry (Phase 4)
282
- */
283
- telemetry?: {
284
- /** Enable local telemetry logging (default: false) */
285
- enabled?: boolean;
286
- /** Output path for telemetry logs (default: '.atomix/telemetry.json') */
287
- path?: string;
288
- /** Anonymize telemetry data (default: true) */
289
- anonymize?: boolean;
290
- };
291
-
292
- /**
293
- * `atomix generate` defaults (CLI overrides these)
294
- */
295
- generator?: GeneratorConfig;
296
-
297
- /**
298
- * Theme customization (Tailwind-like)
299
- *
300
- * Use `extend` to add or override design tokens.
301
- * Use `tokens` to completely replace the default token system (advanced).
302
- */
303
- theme?: {
304
- /**
305
- * Extend the default design tokens
306
- *
307
- * This is the recommended way to customize Atomix.
308
- * Your values will override or extend the base tokens.
309
- */
310
- extend?: ThemeTokens;
311
-
312
- /**
313
- * Override the default tokens entirely (advanced)
314
- *
315
- * Use with caution - this replaces the entire token system.
316
- * Most users should use `extend` instead.
317
- */
318
- tokens?: ThemeTokens;
319
-
320
- /**
321
- * Register custom themes (optional)
322
- *
323
- * Define CSS or JavaScript themes that can be loaded dynamically.
324
- */
325
- themes?: Record<string, ThemeDefinition>;
326
- };
327
-
328
- // Internal configurations (for library development only)
329
- // These are not needed for external developers
330
- /** @internal Build configuration (internal use only) */
331
- build?: BuildConfig;
332
- /** @internal Runtime configuration (internal use only) */
333
- runtime?: RuntimeConfig;
334
- /** @internal Integration settings (internal use only) */
335
- integration?: IntegrationConfig;
336
- /** @internal Theme dependencies mapping (internal use only) */
337
- dependencies?: Record<string, string[]>;
338
- }
339
-
340
- /**
341
- * Helper function to define Atomix configuration with type safety
342
- *
343
- * @param config - Atomix configuration object
344
- * @returns The configuration object
345
- */
346
- /**
347
- * Helper function to define Atomix configuration with type safety
348
- *
349
- * Similar to Tailwind's defineConfig, provides autocomplete and type checking.
350
- *
351
- * @param config - Atomix configuration object
352
- * @returns The configuration object
353
- *
354
- * @example
355
- * ```typescript
356
- * import { defineConfig } from '@shohojdhara/atomix/config';
357
- *
358
- * export default defineConfig({
359
- * theme: {
360
- * extend: {
361
- * colors: {
362
- * primary: { main: '#7AFFD7' },
363
- * },
364
- * },
365
- * },
366
- * });
367
- * ```
368
- */
369
- export function defineConfig(config: AtomixConfig): AtomixConfig {
370
- return config;
371
- }
10
+ export {
11
+ defineConfig,
12
+ type AtomixConfig,
13
+ type ThemeTokens,
14
+ type ThemeDefinition,
15
+ type CSSThemeDefinition,
16
+ type JSThemeDefinition,
17
+ type ColorScale,
18
+ type PaletteColorOptions,
19
+ type InteractiveEffectsConfig,
20
+ type OptimizationConfig,
21
+ type VisualPolishConfig,
22
+ type BuildConfig,
23
+ type RuntimeConfig,
24
+ type IntegrationConfig,
25
+ type PluginConfig,
26
+ type TokenProviderConfig,
27
+ type TokenEngineConfig,
28
+ type GeneratorConfig,
29
+ type DesignTokenCategory,
30
+ type DesignTokenValue
31
+ } from './types';
32
+
33
+ // Export the config loader functions
34
+ export {
35
+ loadAtomixConfig,
36
+ resolveConfigPath
37
+ } from './loader';
38
+
39
+ // Export the validator
40
+ export {
41
+ validateConfiguration,
42
+ printConfigReport,
43
+ type ValidationResult
44
+ } from './validator';
45
+
46
+ // Export convenience functions from the public API
47
+ export { loadConfig, validateConfig } from './public-api';