@dsai-io/tools 0.0.1 → 1.1.0
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/README.md +438 -186
- package/bin/dsai-tools.mjs +13 -13
- package/dist/cli/index.cjs +8192 -2757
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +8190 -2757
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.cjs +264 -63
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +537 -1759
- package/dist/config/index.d.ts +537 -1759
- package/dist/config/index.js +259 -63
- package/dist/config/index.js.map +1 -1
- package/dist/icons/index.cjs +1 -1
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.d.cts +1 -1
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/index.js.map +1 -1
- package/dist/index.cjs +8093 -3024
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -5
- package/dist/index.d.ts +214 -5
- package/dist/index.js +8033 -3012
- package/dist/index.js.map +1 -1
- package/dist/tokens/index.cjs +4457 -737
- package/dist/tokens/index.cjs.map +1 -1
- package/dist/tokens/index.d.cts +1258 -17
- package/dist/tokens/index.d.ts +1258 -17
- package/dist/tokens/index.js +4368 -683
- package/dist/tokens/index.js.map +1 -1
- package/dist/{types-Idj08nad.d.cts → types-CtE9f0G0.d.cts} +293 -3
- package/dist/{types-Idj08nad.d.ts → types-CtE9f0G0.d.ts} +293 -3
- package/dist/utils/circuit-breaker.cjs +173 -0
- package/dist/utils/circuit-breaker.cjs.map +1 -0
- package/dist/utils/circuit-breaker.d.cts +123 -0
- package/dist/utils/circuit-breaker.d.ts +123 -0
- package/dist/utils/circuit-breaker.js +169 -0
- package/dist/utils/circuit-breaker.js.map +1 -0
- package/package.json +102 -97
- package/templates/.dsairc.json +37 -37
- package/templates/dsai-config.schema.json +618 -554
- package/templates/dsai.config.mjs +281 -221
package/dist/config/index.cjs
CHANGED
|
@@ -42,37 +42,50 @@ var customTransformSchema = zod.z.object({
|
|
|
42
42
|
name: zod.z.string().min(1, "Transform name is required"),
|
|
43
43
|
description: zod.z.string().optional(),
|
|
44
44
|
type: zod.z.enum(["value", "attribute", "name"]).optional().default("value"),
|
|
45
|
-
transform: zod.z.function().
|
|
46
|
-
filter: zod.z.function().
|
|
47
|
-
matcher: zod.z.function().
|
|
45
|
+
transform: zod.z.function().optional(),
|
|
46
|
+
filter: zod.z.function().optional(),
|
|
47
|
+
matcher: zod.z.function().optional()
|
|
48
48
|
});
|
|
49
49
|
var customFormatSchema = zod.z.object({
|
|
50
50
|
name: zod.z.string().min(1, "Format name is required"),
|
|
51
51
|
description: zod.z.string().optional(),
|
|
52
|
-
formatter: zod.z.function().
|
|
52
|
+
formatter: zod.z.function().optional(),
|
|
53
53
|
extension: zod.z.string().min(1).optional()
|
|
54
54
|
});
|
|
55
|
-
var
|
|
55
|
+
var outputFormatEnum = zod.z.enum(["css", "scss", "js", "ts", "json", "android", "ios"]);
|
|
56
|
+
var themeDefinitionSchema = zod.z.object({
|
|
57
|
+
isDefault: zod.z.boolean().optional().default(false),
|
|
58
|
+
suffix: zod.z.string().nullable().optional(),
|
|
56
59
|
selector: zod.z.string().min(1, "Theme selector is required"),
|
|
57
60
|
mediaQuery: zod.z.string().optional(),
|
|
58
61
|
dataAttribute: zod.z.string().optional(),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
outputFiles: zod.z.record(outputFormatEnum, zod.z.string()).optional()
|
|
63
|
+
});
|
|
64
|
+
var themeSelectorPatternSchema = zod.z.object({
|
|
65
|
+
default: zod.z.string().optional().default(":root"),
|
|
66
|
+
others: zod.z.string().optional().default('[data-dsai-theme="{mode}"]')
|
|
62
67
|
});
|
|
63
68
|
var themesConfigSchema = zod.z.object({
|
|
64
69
|
enabled: zod.z.boolean().optional().default(true),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
autoDetect: zod.z.boolean().optional().default(true),
|
|
71
|
+
default: zod.z.string().optional().default("light"),
|
|
72
|
+
ignoreModes: zod.z.array(zod.z.string()).optional().default([]),
|
|
73
|
+
selectorPattern: themeSelectorPatternSchema.optional(),
|
|
74
|
+
definitions: zod.z.record(zod.z.string(), themeDefinitionSchema).optional(),
|
|
75
|
+
// Legacy fields (for backward compatibility)
|
|
76
|
+
defaultMode: zod.z.enum(["light", "dark", "system"]).optional(),
|
|
77
|
+
modes: zod.z.record(
|
|
78
|
+
zod.z.string(),
|
|
79
|
+
zod.z.object({
|
|
80
|
+
selector: zod.z.string().min(1),
|
|
81
|
+
mediaQuery: zod.z.string().optional(),
|
|
82
|
+
dataAttribute: zod.z.string().optional(),
|
|
83
|
+
cssVariables: zod.z.boolean().optional(),
|
|
84
|
+
generateSeparateFiles: zod.z.boolean().optional(),
|
|
85
|
+
prefix: zod.z.string().optional()
|
|
86
|
+
})
|
|
87
|
+
).optional(),
|
|
88
|
+
outputFileName: zod.z.string().optional(),
|
|
76
89
|
colorScheme: zod.z.object({
|
|
77
90
|
light: zod.z.string().optional(),
|
|
78
91
|
dark: zod.z.string().optional()
|
|
@@ -115,10 +128,44 @@ var tokenBuildConfigSchema = zod.z.object({
|
|
|
115
128
|
selector: zod.z.string().optional(),
|
|
116
129
|
transforms: zod.z.array(zod.z.string()).optional(),
|
|
117
130
|
customTransforms: zod.z.array(customTransformSchema).optional(),
|
|
118
|
-
filter: zod.z.function().
|
|
131
|
+
filter: zod.z.function().optional(),
|
|
119
132
|
header: zod.z.string().optional(),
|
|
120
133
|
footer: zod.z.string().optional()
|
|
121
134
|
});
|
|
135
|
+
var postprocessConfigSchema = zod.z.object({
|
|
136
|
+
enabled: zod.z.boolean().optional(),
|
|
137
|
+
cssDir: zod.z.string().optional(),
|
|
138
|
+
files: zod.z.array(zod.z.string()).optional(),
|
|
139
|
+
replacements: zod.z.array(
|
|
140
|
+
zod.z.object({
|
|
141
|
+
description: zod.z.string().optional(),
|
|
142
|
+
from: zod.z.union([zod.z.string(), zod.z.instanceof(RegExp)]),
|
|
143
|
+
to: zod.z.string()
|
|
144
|
+
})
|
|
145
|
+
).optional()
|
|
146
|
+
});
|
|
147
|
+
var scssConfigSchema = zod.z.object({
|
|
148
|
+
/** Output styles to generate: 'expanded' (readable) or 'compressed' (minified) */
|
|
149
|
+
outputStyles: zod.z.array(zod.z.enum(["expanded", "compressed"])).optional(),
|
|
150
|
+
/** Generate source maps for SCSS compilation */
|
|
151
|
+
generateSourceMaps: zod.z.boolean().optional(),
|
|
152
|
+
/** Suffix for minified files (e.g., '.min') */
|
|
153
|
+
minifiedSuffix: zod.z.string().optional(),
|
|
154
|
+
/** Theme entry point SCSS file */
|
|
155
|
+
themeEntry: zod.z.string().optional(),
|
|
156
|
+
/** Utilities entry point SCSS file */
|
|
157
|
+
utilitiesEntry: zod.z.string().optional(),
|
|
158
|
+
/** Output directory for compiled CSS files */
|
|
159
|
+
cssOutputDir: zod.z.string().optional(),
|
|
160
|
+
/** Additional Sass load paths */
|
|
161
|
+
loadPaths: zod.z.array(zod.z.string()).optional(),
|
|
162
|
+
/** Target CSS framework for variable name mapping */
|
|
163
|
+
framework: zod.z.enum(["bootstrap", "tailwind", "material", "custom"]).optional(),
|
|
164
|
+
/** Custom token to variable name mappings */
|
|
165
|
+
nameMapping: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
166
|
+
/** Output path for Bootstrap-compatible SCSS variables */
|
|
167
|
+
variablesOutput: zod.z.string().optional()
|
|
168
|
+
});
|
|
122
169
|
var tokenCacheConfigSchema = zod.z.object({
|
|
123
170
|
enabled: zod.z.boolean().optional().default(true),
|
|
124
171
|
directory: zod.z.string().optional().default(".cache"),
|
|
@@ -132,14 +179,16 @@ var tokenWatchConfigSchema = zod.z.object({
|
|
|
132
179
|
ignorePatterns: zod.z.array(zod.z.string()).optional().default([])
|
|
133
180
|
});
|
|
134
181
|
var tokensHooksSchema = zod.z.object({
|
|
135
|
-
onBuildStart: zod.z.function().
|
|
136
|
-
onFormatComplete: zod.z.function().
|
|
137
|
-
onAllFormatsComplete: zod.z.function().
|
|
138
|
-
onBuildComplete: zod.z.function().
|
|
139
|
-
onError: zod.z.function().
|
|
182
|
+
onBuildStart: zod.z.function().optional(),
|
|
183
|
+
onFormatComplete: zod.z.function().optional(),
|
|
184
|
+
onAllFormatsComplete: zod.z.function().optional(),
|
|
185
|
+
onBuildComplete: zod.z.function().optional(),
|
|
186
|
+
onError: zod.z.function().optional()
|
|
140
187
|
});
|
|
141
188
|
var buildPipelineStepSchema = zod.z.enum([
|
|
142
189
|
"validate",
|
|
190
|
+
"snapshot",
|
|
191
|
+
"preprocess",
|
|
143
192
|
"transform",
|
|
144
193
|
"style-dictionary",
|
|
145
194
|
"sync",
|
|
@@ -157,41 +206,30 @@ var tokensBuildPipelineSchema = zod.z.object({
|
|
|
157
206
|
* Default includes all steps for full @dsai-io/tokens build.
|
|
158
207
|
* Simpler packages can use subset like ['validate', 'transform', 'style-dictionary']
|
|
159
208
|
*/
|
|
160
|
-
steps: zod.z.array(buildPipelineStepSchema).optional()
|
|
161
|
-
"validate",
|
|
162
|
-
"transform",
|
|
163
|
-
"style-dictionary",
|
|
164
|
-
"sync",
|
|
165
|
-
"sass-theme",
|
|
166
|
-
"sass-theme-minified",
|
|
167
|
-
"postprocess",
|
|
168
|
-
"sass-utilities",
|
|
169
|
-
"sass-utilities-minified",
|
|
170
|
-
"bundle"
|
|
171
|
-
]),
|
|
209
|
+
steps: zod.z.array(buildPipelineStepSchema).optional(),
|
|
172
210
|
/**
|
|
173
211
|
* Paths configuration for build steps
|
|
174
212
|
*/
|
|
175
213
|
paths: zod.z.object({
|
|
176
214
|
/** Source file for sync step (Style Dictionary JS output) */
|
|
177
|
-
syncSource: zod.z.string().optional()
|
|
215
|
+
syncSource: zod.z.string().optional(),
|
|
178
216
|
/** Target file for sync step */
|
|
179
|
-
syncTarget: zod.z.string().optional()
|
|
217
|
+
syncTarget: zod.z.string().optional(),
|
|
180
218
|
/** SCSS theme input file */
|
|
181
|
-
sassThemeInput: zod.z.string().optional()
|
|
219
|
+
sassThemeInput: zod.z.string().optional(),
|
|
182
220
|
/** CSS theme output file */
|
|
183
|
-
sassThemeOutput: zod.z.string().optional()
|
|
221
|
+
sassThemeOutput: zod.z.string().optional(),
|
|
184
222
|
/** CSS theme minified output file */
|
|
185
|
-
sassThemeMinifiedOutput: zod.z.string().optional()
|
|
223
|
+
sassThemeMinifiedOutput: zod.z.string().optional(),
|
|
186
224
|
/** SCSS utilities input file */
|
|
187
|
-
sassUtilitiesInput: zod.z.string().optional()
|
|
225
|
+
sassUtilitiesInput: zod.z.string().optional(),
|
|
188
226
|
/** CSS utilities output file */
|
|
189
|
-
sassUtilitiesOutput: zod.z.string().optional()
|
|
227
|
+
sassUtilitiesOutput: zod.z.string().optional(),
|
|
190
228
|
/** CSS utilities minified output file */
|
|
191
|
-
sassUtilitiesMinifiedOutput: zod.z.string().optional()
|
|
229
|
+
sassUtilitiesMinifiedOutput: zod.z.string().optional()
|
|
192
230
|
}).optional(),
|
|
193
231
|
/** Style Dictionary config file name */
|
|
194
|
-
styleDictionaryConfig: zod.z.string().optional()
|
|
232
|
+
styleDictionaryConfig: zod.z.string().optional()
|
|
195
233
|
});
|
|
196
234
|
var tokensConfigSchema = zod.z.object({
|
|
197
235
|
enabled: zod.z.boolean().optional().default(true),
|
|
@@ -224,8 +262,12 @@ var tokensConfigSchema = zod.z.object({
|
|
|
224
262
|
cache: tokenCacheConfigSchema.optional(),
|
|
225
263
|
watch: tokenWatchConfigSchema.optional(),
|
|
226
264
|
verbose: zod.z.boolean().optional().default(false),
|
|
265
|
+
/** SCSS/CSS output configuration */
|
|
266
|
+
scss: scssConfigSchema.optional(),
|
|
227
267
|
/** Build pipeline configuration */
|
|
228
|
-
pipeline: tokensBuildPipelineSchema.optional()
|
|
268
|
+
pipeline: tokensBuildPipelineSchema.optional(),
|
|
269
|
+
/** Postprocess configuration */
|
|
270
|
+
postprocess: postprocessConfigSchema.optional()
|
|
229
271
|
});
|
|
230
272
|
var buildConfigSchema = zod.z.object({
|
|
231
273
|
outDir: zod.z.string().optional().default("dist"),
|
|
@@ -245,16 +287,32 @@ var globalConfigSchema = zod.z.object({
|
|
|
245
287
|
framework: frameworkSchema.optional(),
|
|
246
288
|
build: buildConfigSchema.optional()
|
|
247
289
|
});
|
|
290
|
+
var aliasesConfigSchema = zod.z.object({
|
|
291
|
+
importAlias: zod.z.string().optional().default("@/"),
|
|
292
|
+
ui: zod.z.string().optional().default("src/components/ui"),
|
|
293
|
+
hooks: zod.z.string().optional().default("src/hooks"),
|
|
294
|
+
utils: zod.z.string().optional().default("src/lib/utils"),
|
|
295
|
+
components: zod.z.string().optional().default("src/components"),
|
|
296
|
+
lib: zod.z.string().optional().default("src/lib")
|
|
297
|
+
});
|
|
298
|
+
var componentsConfigSchema = zod.z.object({
|
|
299
|
+
enabled: zod.z.boolean().optional().default(true),
|
|
300
|
+
registryUrl: zod.z.string().optional().default("https://registry.dsai.dev"),
|
|
301
|
+
tsx: zod.z.boolean().optional().default(true),
|
|
302
|
+
overwrite: zod.z.boolean().optional().default(false)
|
|
303
|
+
});
|
|
248
304
|
var dsaiConfigSchema = zod.z.object({
|
|
249
305
|
$schema: zod.z.string().optional(),
|
|
250
306
|
extends: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).optional(),
|
|
251
307
|
global: globalConfigSchema.optional(),
|
|
252
308
|
tokens: tokensConfigSchema.optional(),
|
|
253
309
|
themes: themesConfigSchema.optional(),
|
|
254
|
-
icons: iconsConfigSchema.optional()
|
|
310
|
+
icons: iconsConfigSchema.optional(),
|
|
311
|
+
aliases: aliasesConfigSchema.optional(),
|
|
312
|
+
components: componentsConfigSchema.optional()
|
|
255
313
|
});
|
|
256
314
|
function formatValidationErrors(zodError) {
|
|
257
|
-
return zodError.
|
|
315
|
+
return zodError.issues.map((err) => ({
|
|
258
316
|
path: err.path.join(".") || "root",
|
|
259
317
|
message: err.message,
|
|
260
318
|
code: err.code,
|
|
@@ -289,7 +347,9 @@ function validateConfigSection(section, config) {
|
|
|
289
347
|
global: globalConfigSchema,
|
|
290
348
|
tokens: tokensConfigSchema,
|
|
291
349
|
themes: themesConfigSchema,
|
|
292
|
-
icons: iconsConfigSchema
|
|
350
|
+
icons: iconsConfigSchema,
|
|
351
|
+
aliases: aliasesConfigSchema,
|
|
352
|
+
components: componentsConfigSchema
|
|
293
353
|
};
|
|
294
354
|
const schema = sectionSchemas[section];
|
|
295
355
|
if (!schema) {
|
|
@@ -353,11 +413,44 @@ var defaultSelectorPattern = {
|
|
|
353
413
|
default: ":root",
|
|
354
414
|
others: '[data-dsai-theme="{mode}"]'
|
|
355
415
|
};
|
|
416
|
+
var defaultThemeDefinitions = {
|
|
417
|
+
light: {
|
|
418
|
+
isDefault: true,
|
|
419
|
+
suffix: null,
|
|
420
|
+
selector: ":root",
|
|
421
|
+
outputFiles: {
|
|
422
|
+
css: "tokens.css",
|
|
423
|
+
scss: "_tokens.scss",
|
|
424
|
+
js: "tokens.js",
|
|
425
|
+
ts: "tokens.ts",
|
|
426
|
+
json: "tokens.json",
|
|
427
|
+
android: "tokens.xml",
|
|
428
|
+
ios: "tokens.h"
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
dark: {
|
|
432
|
+
isDefault: false,
|
|
433
|
+
suffix: "-dark",
|
|
434
|
+
selector: '[data-dsai-theme="dark"]',
|
|
435
|
+
mediaQuery: "(prefers-color-scheme: dark)",
|
|
436
|
+
outputFiles: {
|
|
437
|
+
css: "tokens-dark.css",
|
|
438
|
+
scss: "_tokens-dark.scss",
|
|
439
|
+
js: "tokens-dark.js",
|
|
440
|
+
ts: "tokens-dark.ts",
|
|
441
|
+
json: "tokens-dark.json",
|
|
442
|
+
android: "tokens-dark.xml",
|
|
443
|
+
ios: "tokens-dark.h"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
356
447
|
var defaultThemesConfig = {
|
|
448
|
+
enabled: true,
|
|
357
449
|
autoDetect: true,
|
|
358
|
-
default: "
|
|
450
|
+
default: "light",
|
|
359
451
|
ignoreModes: [],
|
|
360
|
-
selectorPattern: defaultSelectorPattern
|
|
452
|
+
selectorPattern: defaultSelectorPattern,
|
|
453
|
+
definitions: defaultThemeDefinitions
|
|
361
454
|
};
|
|
362
455
|
var defaultIconFramework = "react";
|
|
363
456
|
var defaultIconsConfig = {
|
|
@@ -368,6 +461,20 @@ var defaultIconsConfig = {
|
|
|
368
461
|
optimize: true,
|
|
369
462
|
prefix: "Icon"
|
|
370
463
|
};
|
|
464
|
+
var defaultAliasesConfig = {
|
|
465
|
+
importAlias: "@/",
|
|
466
|
+
ui: "src/components/ui",
|
|
467
|
+
hooks: "src/hooks",
|
|
468
|
+
utils: "src/lib/utils",
|
|
469
|
+
components: "src/components",
|
|
470
|
+
lib: "src/lib"
|
|
471
|
+
};
|
|
472
|
+
var defaultComponentsConfig = {
|
|
473
|
+
enabled: true,
|
|
474
|
+
registryUrl: "https://registry.dsai.dev",
|
|
475
|
+
tsx: true,
|
|
476
|
+
overwrite: false
|
|
477
|
+
};
|
|
371
478
|
var defaultTokensConfig = {
|
|
372
479
|
source: "theme",
|
|
373
480
|
sourceDir: DEFAULT_SOURCE_DIR,
|
|
@@ -402,6 +509,8 @@ var defaultGlobalConfig = {
|
|
|
402
509
|
var defaultConfig = {
|
|
403
510
|
tokens: defaultTokensConfig,
|
|
404
511
|
icons: defaultIconsConfig,
|
|
512
|
+
aliases: defaultAliasesConfig,
|
|
513
|
+
components: defaultComponentsConfig,
|
|
405
514
|
global: defaultGlobalConfig,
|
|
406
515
|
configDir: process.cwd()
|
|
407
516
|
};
|
|
@@ -524,16 +633,75 @@ function resolveGlobalConfig(config, options) {
|
|
|
524
633
|
logLevel: config?.logLevel ?? base.logLevel
|
|
525
634
|
};
|
|
526
635
|
}
|
|
636
|
+
function resolveThemeDefinition(themeName, definition, selectorPattern, _outputFileNames, isDefaultTheme) {
|
|
637
|
+
const generateOutputFiles = () => {
|
|
638
|
+
const suffix = isDefaultTheme ? "" : `-${themeName}`;
|
|
639
|
+
return {
|
|
640
|
+
css: `tokens${suffix}.css`,
|
|
641
|
+
scss: `_tokens${suffix}.scss`,
|
|
642
|
+
js: `tokens${suffix}.js`,
|
|
643
|
+
ts: `tokens${suffix}.ts`,
|
|
644
|
+
json: `tokens${suffix}.json`,
|
|
645
|
+
android: `tokens${suffix}.xml`,
|
|
646
|
+
ios: `tokens${suffix}.h`
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
const generateSelector = () => {
|
|
650
|
+
if (isDefaultTheme) {
|
|
651
|
+
return selectorPattern.default;
|
|
652
|
+
}
|
|
653
|
+
return selectorPattern.others.replace("{mode}", themeName);
|
|
654
|
+
};
|
|
655
|
+
const defaultOutputFiles = generateOutputFiles();
|
|
656
|
+
return {
|
|
657
|
+
isDefault: definition?.isDefault ?? isDefaultTheme,
|
|
658
|
+
suffix: definition?.suffix ?? (isDefaultTheme ? null : `-${themeName}`),
|
|
659
|
+
selector: definition?.selector ?? generateSelector(),
|
|
660
|
+
mediaQuery: definition?.mediaQuery,
|
|
661
|
+
dataAttribute: definition?.dataAttribute,
|
|
662
|
+
outputFiles: {
|
|
663
|
+
...defaultOutputFiles,
|
|
664
|
+
...definition?.outputFiles
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
}
|
|
527
668
|
function resolveThemesConfig(config) {
|
|
528
669
|
const base = defaultThemesConfig;
|
|
670
|
+
const selectorPattern = {
|
|
671
|
+
default: config?.selectorPattern?.default ?? base.selectorPattern.default,
|
|
672
|
+
others: config?.selectorPattern?.others ?? base.selectorPattern.others
|
|
673
|
+
};
|
|
674
|
+
const defaultThemeName = config?.default?.toLowerCase() ?? base.default;
|
|
675
|
+
let definitions;
|
|
676
|
+
if (config?.definitions && Object.keys(config.definitions).length > 0) {
|
|
677
|
+
definitions = {};
|
|
678
|
+
for (const [themeName, definition] of Object.entries(config.definitions)) {
|
|
679
|
+
const normalizedName = themeName.toLowerCase();
|
|
680
|
+
const isDefaultTheme = definition.isDefault ?? normalizedName === defaultThemeName;
|
|
681
|
+
const resolvedDef = resolveThemeDefinition(
|
|
682
|
+
normalizedName,
|
|
683
|
+
definition,
|
|
684
|
+
selectorPattern,
|
|
685
|
+
defaultOutputFileNames,
|
|
686
|
+
isDefaultTheme
|
|
687
|
+
);
|
|
688
|
+
Object.defineProperty(definitions, normalizedName, {
|
|
689
|
+
value: resolvedDef,
|
|
690
|
+
writable: true,
|
|
691
|
+
enumerable: true,
|
|
692
|
+
configurable: true
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
} else {
|
|
696
|
+
definitions = { ...defaultThemeDefinitions };
|
|
697
|
+
}
|
|
529
698
|
return {
|
|
699
|
+
enabled: config?.enabled ?? base.enabled,
|
|
530
700
|
autoDetect: config?.autoDetect ?? base.autoDetect,
|
|
531
|
-
default:
|
|
701
|
+
default: defaultThemeName,
|
|
532
702
|
ignoreModes: config?.ignoreModes ?? [...base.ignoreModes],
|
|
533
|
-
selectorPattern
|
|
534
|
-
|
|
535
|
-
others: config?.selectorPattern?.others ?? base.selectorPattern.others
|
|
536
|
-
}
|
|
703
|
+
selectorPattern,
|
|
704
|
+
definitions
|
|
537
705
|
};
|
|
538
706
|
}
|
|
539
707
|
function resolveIconsConfig(config, options) {
|
|
@@ -601,13 +769,37 @@ function resolveTokensConfig(config, options) {
|
|
|
601
769
|
separateThemeFiles: config?.separateThemeFiles ?? base.separateThemeFiles,
|
|
602
770
|
watch: config?.watch ?? base.watch,
|
|
603
771
|
watchDirectories,
|
|
604
|
-
pipeline: config?.pipeline
|
|
772
|
+
pipeline: config?.pipeline,
|
|
773
|
+
scss: config?.scss,
|
|
774
|
+
postprocess: config?.postprocess
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function resolveAliasesConfig(config) {
|
|
778
|
+
const base = defaultAliasesConfig;
|
|
779
|
+
return {
|
|
780
|
+
importAlias: config?.importAlias ?? base.importAlias,
|
|
781
|
+
ui: config?.ui ?? base.ui,
|
|
782
|
+
hooks: config?.hooks ?? base.hooks,
|
|
783
|
+
utils: config?.utils ?? base.utils,
|
|
784
|
+
components: config?.components ?? base.components,
|
|
785
|
+
lib: config?.lib ?? base.lib
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function resolveComponentsConfig(config) {
|
|
789
|
+
const base = defaultComponentsConfig;
|
|
790
|
+
return {
|
|
791
|
+
enabled: config?.enabled ?? base.enabled,
|
|
792
|
+
registryUrl: config?.registryUrl ?? base.registryUrl,
|
|
793
|
+
tsx: config?.tsx ?? base.tsx,
|
|
794
|
+
overwrite: config?.overwrite ?? base.overwrite
|
|
605
795
|
};
|
|
606
796
|
}
|
|
607
797
|
function applyOverrides(config, overrides) {
|
|
608
798
|
return {
|
|
609
799
|
tokens: overrides.tokens ? { ...config.tokens, ...overrides.tokens } : config.tokens,
|
|
610
800
|
icons: overrides.icons ? { ...config.icons, ...overrides.icons } : config.icons,
|
|
801
|
+
aliases: overrides.aliases ? { ...config.aliases, ...overrides.aliases } : config.aliases,
|
|
802
|
+
components: overrides.components ? { ...config.components, ...overrides.components } : config.components,
|
|
611
803
|
global: overrides.global ? { ...config.global, ...overrides.global } : config.global
|
|
612
804
|
};
|
|
613
805
|
}
|
|
@@ -618,6 +810,8 @@ function resolveConfig(config = {}, options = {}) {
|
|
|
618
810
|
global: resolveGlobalConfig(mergedConfig.global, options),
|
|
619
811
|
tokens: resolveTokensConfig(mergedConfig.tokens, options),
|
|
620
812
|
icons: resolveIconsConfig(mergedConfig.icons, options),
|
|
813
|
+
aliases: resolveAliasesConfig(mergedConfig.aliases),
|
|
814
|
+
components: resolveComponentsConfig(mergedConfig.components),
|
|
621
815
|
configDir
|
|
622
816
|
};
|
|
623
817
|
}
|
|
@@ -633,6 +827,8 @@ function createResolvedConfig(partial = {}) {
|
|
|
633
827
|
global: partial.global ?? defaultConfig.global,
|
|
634
828
|
tokens: partial.tokens ?? defaultConfig.tokens,
|
|
635
829
|
icons: partial.icons ?? defaultConfig.icons,
|
|
830
|
+
aliases: partial.aliases ?? defaultConfig.aliases,
|
|
831
|
+
components: partial.components ?? defaultConfig.components,
|
|
636
832
|
configDir: partial.configDir ?? process.cwd(),
|
|
637
833
|
configPath: partial.configPath
|
|
638
834
|
};
|
|
@@ -816,7 +1012,7 @@ function setNestedValue(obj, path3, value) {
|
|
|
816
1012
|
configurable: true
|
|
817
1013
|
});
|
|
818
1014
|
}
|
|
819
|
-
const nested = obj
|
|
1015
|
+
const nested = Reflect.get(obj, first);
|
|
820
1016
|
Object.defineProperty(nested, second, {
|
|
821
1017
|
value,
|
|
822
1018
|
writable: true,
|
|
@@ -837,7 +1033,7 @@ function setNestedValue(obj, path3, value) {
|
|
|
837
1033
|
configurable: true
|
|
838
1034
|
});
|
|
839
1035
|
}
|
|
840
|
-
const nested1 = obj
|
|
1036
|
+
const nested1 = Reflect.get(obj, first);
|
|
841
1037
|
if (!(second in nested1)) {
|
|
842
1038
|
Object.defineProperty(nested1, second, {
|
|
843
1039
|
value: {},
|
|
@@ -846,7 +1042,7 @@ function setNestedValue(obj, path3, value) {
|
|
|
846
1042
|
configurable: true
|
|
847
1043
|
});
|
|
848
1044
|
}
|
|
849
|
-
const nested2 = nested1
|
|
1045
|
+
const nested2 = Reflect.get(nested1, second);
|
|
850
1046
|
Object.defineProperty(nested2, third, {
|
|
851
1047
|
value,
|
|
852
1048
|
writable: true,
|
|
@@ -864,7 +1060,7 @@ function getConfigFromEnv(options = {}) {
|
|
|
864
1060
|
if (!envKey.startsWith(prefix)) {
|
|
865
1061
|
continue;
|
|
866
1062
|
}
|
|
867
|
-
const envValue = env
|
|
1063
|
+
const envValue = Reflect.get(env, envKey);
|
|
868
1064
|
if (envValue === void 0) {
|
|
869
1065
|
continue;
|
|
870
1066
|
}
|
|
@@ -1048,13 +1244,17 @@ exports.DEFAULT_LOG_LEVEL = DEFAULT_LOG_LEVEL;
|
|
|
1048
1244
|
exports.DEFAULT_OUTPUT_DIR = DEFAULT_OUTPUT_DIR;
|
|
1049
1245
|
exports.DEFAULT_PREFIX = DEFAULT_PREFIX;
|
|
1050
1246
|
exports.DEFAULT_SOURCE_DIR = DEFAULT_SOURCE_DIR;
|
|
1247
|
+
exports.aliasesConfigSchema = aliasesConfigSchema;
|
|
1051
1248
|
exports.buildConfigSchema = buildConfigSchema;
|
|
1052
1249
|
exports.checkDeprecatedOptions = checkDeprecatedOptions;
|
|
1053
1250
|
exports.checkMigrationNeeded = checkMigrationNeeded;
|
|
1054
1251
|
exports.clearConfigCache = clearConfigCache;
|
|
1252
|
+
exports.componentsConfigSchema = componentsConfigSchema;
|
|
1055
1253
|
exports.createResolvedConfig = createResolvedConfig;
|
|
1056
1254
|
exports.customFormatSchema = customFormatSchema;
|
|
1057
1255
|
exports.customTransformSchema = customTransformSchema;
|
|
1256
|
+
exports.defaultAliasesConfig = defaultAliasesConfig;
|
|
1257
|
+
exports.defaultComponentsConfig = defaultComponentsConfig;
|
|
1058
1258
|
exports.defaultConfig = defaultConfig;
|
|
1059
1259
|
exports.defaultFormats = defaultFormats;
|
|
1060
1260
|
exports.defaultGlobalConfig = defaultGlobalConfig;
|
|
@@ -1100,7 +1300,8 @@ exports.outputFormatSchema = outputFormatSchema;
|
|
|
1100
1300
|
exports.resolveConfig = resolveConfig;
|
|
1101
1301
|
exports.searchConfigFile = searchConfigFile;
|
|
1102
1302
|
exports.shouldDisableColors = shouldDisableColors;
|
|
1103
|
-
exports.
|
|
1303
|
+
exports.themeDefinitionSchema = themeDefinitionSchema;
|
|
1304
|
+
exports.themeSelectorPatternSchema = themeSelectorPatternSchema;
|
|
1104
1305
|
exports.themesConfigSchema = themesConfigSchema;
|
|
1105
1306
|
exports.tokenBuildConfigSchema = tokenBuildConfigSchema;
|
|
1106
1307
|
exports.tokenCacheConfigSchema = tokenCacheConfigSchema;
|