@basiclines/rampa 1.1.0 → 1.1.1

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 (2) hide show
  1. package/dist/index.js +45 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9897,6 +9897,41 @@ function formatCss2(ramps) {
9897
9897
  `);
9898
9898
  }
9899
9899
 
9900
+ // src/utils/terminal-colors.ts
9901
+ function hasLimitedColorSupport() {
9902
+ return process.env.TERM_PROGRAM === "Apple_Terminal";
9903
+ }
9904
+ function rgbTo256(r4, g3, b2) {
9905
+ if (r4 === g3 && g3 === b2) {
9906
+ if (r4 < 8)
9907
+ return 16;
9908
+ if (r4 > 248)
9909
+ return 231;
9910
+ return Math.round((r4 - 8) / 10) + 232;
9911
+ }
9912
+ const rIndex = Math.round(r4 / 255 * 5);
9913
+ const gIndex = Math.round(g3 / 255 * 5);
9914
+ const bIndex = Math.round(b2 / 255 * 5);
9915
+ return 16 + 36 * rIndex + 6 * gIndex + bIndex;
9916
+ }
9917
+ function coloredSquare(r4, g3, b2) {
9918
+ if (hasLimitedColorSupport()) {
9919
+ const colorCode = rgbTo256(r4, g3, b2);
9920
+ return `\x1B[38;5;${colorCode}m■\x1B[0m`;
9921
+ }
9922
+ return `\x1B[38;2;${r4};${g3};${b2}m■\x1B[0m`;
9923
+ }
9924
+ function getColorLimitationNote() {
9925
+ if (hasLimitedColorSupport()) {
9926
+ const dim = "\x1B[2m";
9927
+ const yellow = "\x1B[33m";
9928
+ const reset = "\x1B[0m";
9929
+ return `${yellow}Note:${reset} ${dim}Using 256-color mode. macOS Terminal.app has limited truecolor support.${reset}
9930
+ ${dim}For accurate color previews, use iTerm2, Warp, kitty, or another truecolor terminal.${reset}`;
9931
+ }
9932
+ return null;
9933
+ }
9934
+
9900
9935
  // src/index.ts
9901
9936
  if (process.argv.includes("--help") || process.argv.includes("-h")) {
9902
9937
  showHelp();
@@ -9906,7 +9941,7 @@ function showHelp() {
9906
9941
  const dim = "\x1B[2m";
9907
9942
  const reset = "\x1B[0m";
9908
9943
  const help = `
9909
- rampa v1.1.0
9944
+ rampa v1.1.1
9910
9945
  Generate mathematically accurate color palettes from a base color
9911
9946
 
9912
9947
  USAGE
@@ -10144,7 +10179,7 @@ var validFormats = ["hex", "hsl", "rgb", "oklch"];
10144
10179
  var main = defineCommand({
10145
10180
  meta: {
10146
10181
  name: "rampa",
10147
- version: "1.1.0",
10182
+ version: "1.1.1",
10148
10183
  description: "Generate mathematically accurate color palettes from a base color"
10149
10184
  },
10150
10185
  args: {
@@ -10469,6 +10504,13 @@ var main = defineCommand({
10469
10504
  } else if (outputType === "css") {
10470
10505
  console.log(formatCss2(ramps));
10471
10506
  } else {
10507
+ if (args.preview) {
10508
+ const limitationNote = getColorLimitationNote();
10509
+ if (limitationNote) {
10510
+ console.log(limitationNote);
10511
+ console.log("");
10512
+ }
10513
+ }
10472
10514
  ramps.forEach((ramp, rampIndex) => {
10473
10515
  if (rampIndex > 0 || ramps.length > 1) {
10474
10516
  if (rampIndex > 0)
@@ -10479,7 +10521,7 @@ var main = defineCommand({
10479
10521
  if (args.preview) {
10480
10522
  const c4 = chroma_js_default(color);
10481
10523
  const [r4, g3, b2] = c4.rgb();
10482
- const square = `\x1B[38;2;${r4};${g3};${b2}m■\x1B[0m`;
10524
+ const square = coloredSquare(r4, g3, b2);
10483
10525
  console.log(`${square} ${color}`);
10484
10526
  } else {
10485
10527
  console.log(color);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basiclines/rampa",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Generate mathematically accurate color palettes from a base color",
5
5
  "type": "module",
6
6
  "bin": {