@yamada-ui/cli 1.0.3 → 1.0.4-dev-20240406104355

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.
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
33
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
34
34
  var init_cjs_shims = __esm({
35
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
35
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
36
36
  "use strict";
37
37
  }
38
38
  });
@@ -40,8 +40,7 @@ var init_cjs_shims = __esm({
40
40
  // src/command/colors/index.ts
41
41
  var colors_exports = {};
42
42
  __export(colors_exports, {
43
- actionColors: () => actionColors,
44
- toneColor: () => toneColor
43
+ actionColors: () => actionColors
45
44
  });
46
45
  module.exports = __toCommonJS(colors_exports);
47
46
  init_cjs_shims();
@@ -565,26 +564,36 @@ var prettier = async (content, options) => {
565
564
  };
566
565
 
567
566
  // src/command/colors/index.ts
568
- var toneColor = (color, hue, lCoef, dCoef) => {
569
- const coef = hue < 500 ? lCoef : dCoef;
570
- const amount = (500 - hue) * 1e-3 * coef;
571
- return (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
567
+ var tones = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
568
+ var generateTones = (hex) => {
569
+ let [h, s, l] = (0, import_color2k.parseToHsla)(hex);
570
+ l *= 100;
571
+ const d = l <= 50;
572
+ const x = ((!d ? 100 : 95) - l) / 5;
573
+ const y = (l - (d ? 5 : 15)) / 5;
574
+ return tones.reduce(
575
+ (prev, tone) => {
576
+ const t = tone / 100;
577
+ let z;
578
+ if (t <= 5) {
579
+ z = l + (5 - t) * x;
580
+ } else {
581
+ z = l - (t - 5) * y;
582
+ }
583
+ z /= 100;
584
+ prev[tone] = (0, import_color2k.toHex)((0, import_color2k.hsla)(h, s, z, 1));
585
+ return prev;
586
+ },
587
+ {}
588
+ );
572
589
  };
573
- var hues = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
574
- var actionColors = async (color, { name, coef, out }) => {
590
+ var actionColors = async (color, { name, out }) => {
575
591
  p.intro(source_default.magenta(`Generating Hue colors`));
576
592
  const s = p.spinner();
577
593
  try {
578
594
  const start = process.hrtime.bigint();
579
595
  s.start(`Computing the color`);
580
- const [lCoef, dCoef] = coef?.split(",").map((v) => Number(v.trim())) ?? [
581
- 0.94,
582
- 0.86
583
- ];
584
- const contents = hues.reduce((prev, hue) => {
585
- prev[hue] = toneColor(color, hue, lCoef, dCoef);
586
- return prev;
587
- }, {});
596
+ const contents = generateTones(color);
588
597
  let result = contents;
589
598
  if (name)
590
599
  result = { [name]: result };
@@ -610,6 +619,5 @@ var actionColors = async (color, { name, coef, out }) => {
610
619
  };
611
620
  // Annotate the CommonJS export names for ESM import in node:
612
621
  0 && (module.exports = {
613
- actionColors,
614
- toneColor
622
+ actionColors
615
623
  });
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
33
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
34
34
  var init_cjs_shims = __esm({
35
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
35
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
36
36
  "use strict";
37
37
  }
38
38
  });
@@ -111,7 +111,7 @@ var config = [
111
111
  ];
112
112
 
113
113
  // src/command/tokens/create-theme-typings.ts
114
- var hues = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
114
+ var tones = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
115
115
  var printComponent = (components) => `components: { ${Object.entries(components).map(
116
116
  ([key, unions]) => `${key.match(/^[a-zA-Z0-9\-_]+$/) ? key : `"${key}"`}: { ${print(
117
117
  unions
@@ -158,11 +158,11 @@ var extractTransitions = (theme) => {
158
158
  });
159
159
  return { transitionProperty, transitionDuration, transitionEasing };
160
160
  };
161
- var isHue = (value) => {
161
+ var isTone = (value) => {
162
162
  if (!isObject(value))
163
163
  return false;
164
164
  const keys = Object.keys(value);
165
- return hues.every((key) => keys.includes(key.toString()));
165
+ return tones.every((key) => keys.includes(key.toString()));
166
166
  };
167
167
  var extractColorSchemes = (theme) => {
168
168
  const { colors, semantics } = theme;
@@ -173,7 +173,7 @@ var extractColorSchemes = (theme) => {
173
173
  if (!isObject(colors))
174
174
  return results;
175
175
  Object.entries(colors).forEach(([key, value]) => {
176
- if (!isHue(value))
176
+ if (!isTone(value))
177
177
  return;
178
178
  results.colorSchemes.push(key);
179
179
  const semanticKeys = Object.entries(semantics?.colorSchemes ?? {}).filter(([, relatedKey]) => key === relatedKey).map(([key2]) => key2) ?? [];
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
33
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
34
34
  var init_cjs_shims = __esm({
35
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
35
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
36
36
  "use strict";
37
37
  }
38
38
  });
@@ -609,7 +609,7 @@ var config = [
609
609
  ];
610
610
 
611
611
  // src/command/tokens/create-theme-typings.ts
612
- var hues = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
612
+ var tones = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
613
613
  var printComponent = (components) => `components: { ${Object.entries(components).map(
614
614
  ([key, unions]) => `${key.match(/^[a-zA-Z0-9\-_]+$/) ? key : `"${key}"`}: { ${print(
615
615
  unions
@@ -656,11 +656,11 @@ var extractTransitions = (theme) => {
656
656
  });
657
657
  return { transitionProperty, transitionDuration, transitionEasing };
658
658
  };
659
- var isHue = (value) => {
659
+ var isTone = (value) => {
660
660
  if (!isObject(value))
661
661
  return false;
662
662
  const keys = Object.keys(value);
663
- return hues.every((key) => keys.includes(key.toString()));
663
+ return tones.every((key) => keys.includes(key.toString()));
664
664
  };
665
665
  var extractColorSchemes = (theme) => {
666
666
  const { colors, semantics } = theme;
@@ -671,7 +671,7 @@ var extractColorSchemes = (theme) => {
671
671
  if (!isObject(colors))
672
672
  return results;
673
673
  Object.entries(colors).forEach(([key, value]) => {
674
- if (!isHue(value))
674
+ if (!isTone(value))
675
675
  return;
676
676
  results.colorSchemes.push(key);
677
677
  const semanticKeys = Object.entries(semantics?.colorSchemes ?? {}).filter(([, relatedKey]) => key === relatedKey).map(([key2]) => key2) ?? [];
package/dist/index.js CHANGED
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -17632,26 +17632,36 @@ var omitObject = (obj, keys) => {
17632
17632
  };
17633
17633
 
17634
17634
  // src/command/colors/index.ts
17635
- var toneColor = (color, hue, lCoef, dCoef) => {
17636
- const coef = hue < 500 ? lCoef : dCoef;
17637
- const amount = (500 - hue) * 1e-3 * coef;
17638
- return (0, import_color2k.toHex)((0, import_color2k.lighten)(color, amount));
17635
+ var tones = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
17636
+ var generateTones = (hex) => {
17637
+ let [h, s, l] = (0, import_color2k.parseToHsla)(hex);
17638
+ l *= 100;
17639
+ const d = l <= 50;
17640
+ const x = ((!d ? 100 : 95) - l) / 5;
17641
+ const y = (l - (d ? 5 : 15)) / 5;
17642
+ return tones.reduce(
17643
+ (prev, tone) => {
17644
+ const t = tone / 100;
17645
+ let z;
17646
+ if (t <= 5) {
17647
+ z = l + (5 - t) * x;
17648
+ } else {
17649
+ z = l - (t - 5) * y;
17650
+ }
17651
+ z /= 100;
17652
+ prev[tone] = (0, import_color2k.toHex)((0, import_color2k.hsla)(h, s, z, 1));
17653
+ return prev;
17654
+ },
17655
+ {}
17656
+ );
17639
17657
  };
17640
- var hues = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
17641
- var actionColors = async (color, { name, coef, out }) => {
17658
+ var actionColors = async (color, { name, out }) => {
17642
17659
  p.intro(source_default.magenta(`Generating Hue colors`));
17643
17660
  const s = p.spinner();
17644
17661
  try {
17645
17662
  const start = process.hrtime.bigint();
17646
17663
  s.start(`Computing the color`);
17647
- const [lCoef, dCoef] = coef?.split(",").map((v) => Number(v.trim())) ?? [
17648
- 0.94,
17649
- 0.86
17650
- ];
17651
- const contents = hues.reduce((prev, hue) => {
17652
- prev[hue] = toneColor(color, hue, lCoef, dCoef);
17653
- return prev;
17654
- }, {});
17664
+ const contents = generateTones(color);
17655
17665
  let result = contents;
17656
17666
  if (name)
17657
17667
  result = { [name]: result };
@@ -17709,7 +17719,7 @@ var config = [
17709
17719
  ];
17710
17720
 
17711
17721
  // src/command/tokens/create-theme-typings.ts
17712
- var hues2 = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
17722
+ var tones2 = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
17713
17723
  var printComponent = (components) => `components: { ${Object.entries(components).map(
17714
17724
  ([key, unions]) => `${key.match(/^[a-zA-Z0-9\-_]+$/) ? key : `"${key}"`}: { ${print(
17715
17725
  unions
@@ -17756,11 +17766,11 @@ var extractTransitions = (theme) => {
17756
17766
  });
17757
17767
  return { transitionProperty, transitionDuration, transitionEasing };
17758
17768
  };
17759
- var isHue = (value) => {
17769
+ var isTone = (value) => {
17760
17770
  if (!isObject(value))
17761
17771
  return false;
17762
17772
  const keys = Object.keys(value);
17763
- return hues2.every((key) => keys.includes(key.toString()));
17773
+ return tones2.every((key) => keys.includes(key.toString()));
17764
17774
  };
17765
17775
  var extractColorSchemes = (theme) => {
17766
17776
  const { colors, semantics } = theme;
@@ -17771,7 +17781,7 @@ var extractColorSchemes = (theme) => {
17771
17781
  if (!isObject(colors))
17772
17782
  return results;
17773
17783
  Object.entries(colors).forEach(([key, value]) => {
17774
- if (!isHue(value))
17784
+ if (!isTone(value))
17775
17785
  return;
17776
17786
  results.colorSchemes.push(key);
17777
17787
  const semanticKeys = Object.entries(semantics?.colorSchemes ?? {}).filter(([, relatedKey]) => key === relatedKey).map(([key2]) => key2) ?? [];
@@ -17959,7 +17969,7 @@ var actionTokens = async (themeFile, { out: outFile, watch: watchFile }) => {
17959
17969
  var run = async () => {
17960
17970
  await initCLI();
17961
17971
  import_commander.program.command("tokens <source>").option("-o, --out <path>", `Output file to ${path7.join(...themePath)}`).option("-w, --watch [path]", "Watch directory for changes and rebuild").action(actionTokens);
17962
- import_commander.program.command("colors <color>").option("-n, --name <name>", "Token name of hue object to output").option("-c, --coef <coef>", "Coefficients that adjust the color tone").option("-o, --out", "Out color json data").action(actionColors);
17972
+ import_commander.program.command("colors <color>").option("-n, --name <name>", "Token name of hue object to output").option("-o, --out", "Out color json data").action(actionColors);
17963
17973
  import_commander.program.on("-h, --help", () => {
17964
17974
  console.info(`
17965
17975
  Example call:
package/dist/utils/cli.js CHANGED
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.2/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@8.0.2_typescript@5.4.3/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4-dev-20240406104355",
4
4
  "description": "Generate theme tokens for autocomplete",
5
5
  "keywords": [
6
6
  "theme",