@yamada-ui/cli 1.2.4 → 2.0.0-dev-20250626070331

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.
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/command/tokens/config.ts
21
- var config_exports = {};
22
- __export(config_exports, {
23
- config: () => config
24
- });
25
- module.exports = __toCommonJS(config_exports);
26
- var config = [
27
- { key: "borders" },
28
- { key: "breakpoints" },
29
- { key: "colors" },
30
- { key: "fonts" },
31
- { key: "fontSizes" },
32
- { key: "fontWeights" },
33
- { key: "letterSpacings" },
34
- { key: "lineHeights" },
35
- { key: "radii" },
36
- { key: "shadows" },
37
- { key: "blurs" },
38
- { key: "sizes" },
39
- { key: "spaces", flatMap: (value) => [value, `-${value}`] },
40
- { key: "zIndices" },
41
- { key: "animations", omitScanKeys: ["keyframes"] },
42
- { key: "gradients" },
43
- { key: "transitions.property", replaceKey: "transitionProperty" },
44
- { key: "transitions.duration", replaceKey: "transitionDuration" },
45
- { key: "transitions.easing", replaceKey: "transitionEasing" }
46
- ];
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- config
50
- });
@@ -1,245 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // ../../node_modules/.pnpm/tsup@8.3.6_@swc+core@1.10.18_jiti@2.4.2_tsx@4.19.3_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js
34
- var init_cjs_shims = __esm({
35
- "../../node_modules/.pnpm/tsup@8.3.6_@swc+core@1.10.18_jiti@2.4.2_tsx@4.19.3_typescript@5.7.3/node_modules/tsup/assets/cjs_shims.js"() {
36
- "use strict";
37
- }
38
- });
39
-
40
- // src/command/tokens/create-theme-typings.ts
41
- var create_theme_typings_exports = {};
42
- __export(create_theme_typings_exports, {
43
- createThemeTypings: () => createThemeTypings
44
- });
45
- module.exports = __toCommonJS(create_theme_typings_exports);
46
- init_cjs_shims();
47
-
48
- // src/utils/assertion.ts
49
- init_cjs_shims();
50
- var isObject = (obj) => obj !== null && (typeof obj === "object" || typeof obj === "function") && !isArray(obj);
51
- var isArray = (value) => Array.isArray(value);
52
-
53
- // src/utils/object.ts
54
- init_cjs_shims();
55
- var getObject = (obj, path2) => {
56
- const keys = path2.split(".");
57
- return keys.reduce((obj2, key) => obj2[key] ?? {}, obj);
58
- };
59
-
60
- // src/utils/prettier.ts
61
- init_cjs_shims();
62
- var import_path = __toESM(require("path"));
63
- var import_prettier = require("prettier");
64
- var prettier = async (content, options) => {
65
- const prettierConfig = await (0, import_prettier.resolveConfig)(
66
- import_path.default.join(process.cwd(), ".prettierrc")
67
- );
68
- try {
69
- return (0, import_prettier.format)(content, {
70
- ...prettierConfig,
71
- parser: "typescript",
72
- ...options
73
- });
74
- } catch {
75
- return content;
76
- }
77
- };
78
-
79
- // src/command/tokens/config.ts
80
- init_cjs_shims();
81
- var config = [
82
- { key: "borders" },
83
- { key: "breakpoints" },
84
- { key: "colors" },
85
- { key: "fonts" },
86
- { key: "fontSizes" },
87
- { key: "fontWeights" },
88
- { key: "letterSpacings" },
89
- { key: "lineHeights" },
90
- { key: "radii" },
91
- { key: "shadows" },
92
- { key: "blurs" },
93
- { key: "sizes" },
94
- { key: "spaces", flatMap: (value) => [value, `-${value}`] },
95
- { key: "zIndices" },
96
- { key: "animations", omitScanKeys: ["keyframes"] },
97
- { key: "gradients" },
98
- { key: "transitions.property", replaceKey: "transitionProperty" },
99
- { key: "transitions.duration", replaceKey: "transitionDuration" },
100
- { key: "transitions.easing", replaceKey: "transitionEasing" }
101
- ];
102
-
103
- // src/command/tokens/create-theme-typings.ts
104
- var TONES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
105
- var printComponent = (components) => `components: { ${Object.entries(components).map(
106
- ([key, unions]) => `${key.match(/^[a-zA-Z0-9\-_]+$/) ? key : `"${key}"`}: { ${print(
107
- unions
108
- )}}`
109
- ).join(`
110
- `)} }`;
111
- var print = (unions) => Object.entries(unions).sort(([a], [b]) => a.localeCompare(b)).map(
112
- ([key, union]) => `${key}: ${union.map((value) => `"${value}"`).concat(["(string & {})"]).join(" | ")};`
113
- ).join("\n");
114
- var extractComponents = ({ components = {} }) => Object.entries(components).reduce((obj, [key, { sizes, variants }]) => {
115
- if (sizes || variants) {
116
- obj[key] = {
117
- sizes: Object.keys(sizes ?? {}),
118
- variants: Object.keys(variants ?? {})
119
- };
120
- }
121
- return obj;
122
- }, {});
123
- var isTone = (value) => {
124
- if (!isObject(value)) return false;
125
- const keys = Object.keys(value);
126
- return TONES.every((key) => keys.includes(key.toString()));
127
- };
128
- var extractColorSchemes = (theme) => {
129
- const { colors, semantics } = theme;
130
- let colorSchemes = [];
131
- let colorSchemeColors = [];
132
- if (!isObject(colors)) return { colorSchemeColors, colorSchemes };
133
- Object.entries(colors).forEach(([key, value]) => {
134
- if (!isTone(value)) return;
135
- colorSchemes.push(key);
136
- });
137
- if (!isObject(semantics?.colorSchemes))
138
- return { colorSchemeColors, colorSchemes };
139
- Object.entries(semantics.colorSchemes).forEach(([key, value]) => {
140
- if (isTone(value)) {
141
- colorSchemes.push(key);
142
- colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
143
- } else {
144
- const hasColorScheme = isArray(value) ? value.every((key2) => Object.keys(colors).includes(String(key2))) : Object.keys(colors).includes(String(value));
145
- if (!hasColorScheme) return;
146
- colorSchemes.push(key);
147
- colorSchemeColors.push(...TONES.map((tone) => `${key}.${tone}`));
148
- }
149
- });
150
- return { colorSchemeColors, colorSchemes };
151
- };
152
- var extractThemeSchemes = (theme) => {
153
- const { themeSchemes } = theme;
154
- if (!isObject(themeSchemes)) return ["base"];
155
- return ["base", ...Object.keys(themeSchemes)];
156
- };
157
- var extractPaths = (target, maxDepth = 3, omitKeys = [], shouldProcess) => {
158
- if (!isObject(target) && !isArray(target) || !maxDepth) return [];
159
- return Object.entries(target).reduce((prev, [key, value]) => {
160
- if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2)) && (!shouldProcess || shouldProcess(value))) {
161
- extractPaths(value, maxDepth - 1, omitKeys, shouldProcess).forEach(
162
- (nestedKey) => prev.push(`${key}.${nestedKey}`)
163
- );
164
- } else {
165
- prev.push(key);
166
- }
167
- return prev;
168
- }, []);
169
- };
170
- var extractKeys = (obj, key) => {
171
- const property = getObject(obj, key);
172
- if (!isObject(property)) return [];
173
- return Object.keys(property);
174
- };
175
- var createThemeTypings = async (theme, { responsive = false }) => {
176
- let shouldProcess = void 0;
177
- if (responsive && isObject(theme.breakpoints)) {
178
- const keys = ["base", ...Object.keys(theme.breakpoints)];
179
- const isResponsive = (obj) => {
180
- const providedKeys = Object.keys(obj);
181
- if (!providedKeys.length) return false;
182
- if (!providedKeys.includes("base")) return false;
183
- return providedKeys.every((key) => keys.includes(key));
184
- };
185
- shouldProcess = (obj) => !isResponsive(obj);
186
- }
187
- const tokens = config.reduce(
188
- (prev, {
189
- key,
190
- flatMap = (value) => value,
191
- maxScanDepth,
192
- omitScanKeys,
193
- replaceKey
194
- }) => {
195
- const target = getObject(theme, key);
196
- prev[replaceKey ?? key] = [];
197
- if (isObject(target) || isArray(target)) {
198
- prev[replaceKey ?? key] = extractPaths(
199
- target,
200
- maxScanDepth,
201
- omitScanKeys,
202
- shouldProcess
203
- ).flatMap(flatMap);
204
- }
205
- if (isObject(theme.semantics)) {
206
- const target2 = getObject(theme.semantics, key);
207
- const semanticKeys = extractPaths(
208
- target2,
209
- maxScanDepth,
210
- omitScanKeys,
211
- shouldProcess
212
- ).flatMap(flatMap);
213
- prev[replaceKey ?? key]?.push(...semanticKeys);
214
- }
215
- return prev;
216
- },
217
- {}
218
- );
219
- const textStyles = extractKeys(theme, "styles.textStyles");
220
- const layerStyles = extractKeys(theme, "styles.layerStyles");
221
- const { colorSchemeColors, colorSchemes } = extractColorSchemes(theme);
222
- const themeSchemes = extractThemeSchemes(theme);
223
- const components = extractComponents(theme);
224
- tokens.colors = [...tokens.colors ?? [], ...colorSchemeColors];
225
- return prettier(
226
- [
227
- `import type { UITheme } from './ui-theme.types'`,
228
- ``,
229
- `export interface GeneratedTheme extends UITheme {`,
230
- print({
231
- ...tokens,
232
- colorSchemes,
233
- layerStyles,
234
- textStyles,
235
- themeSchemes
236
- }),
237
- printComponent(components),
238
- `}`
239
- ].join("\n")
240
- );
241
- };
242
- // Annotate the CommonJS export names for ESM import in node:
243
- 0 && (module.exports = {
244
- createThemeTypings
245
- });