@narumitw/pi-statusline 0.50.0 → 0.50.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.
@@ -6,36 +6,34 @@ const BLOCK_NAMES: PowerlineBlockName[] = ["header", "directory", "git", "runtim
6
6
  type PaletteRamp = readonly [string, string, string, string, string];
7
7
 
8
8
  export function createRampPreset(backgrounds: PaletteRamp): PowerlinePreset {
9
- return {
10
- lead: backgrounds[0],
11
- blocks: Object.fromEntries(
12
- BLOCK_NAMES.map((block, index) => {
13
- const background = backgrounds[index];
14
- return [block, { fg: contrastColor(background), bg: background }];
15
- }),
16
- ) as Record<PowerlineBlockName, { fg: string; bg: string }>,
17
- extensionSeparator: backgrounds[2],
18
- };
9
+ return {
10
+ lead: backgrounds[0],
11
+ blocks: Object.fromEntries(
12
+ BLOCK_NAMES.map((block, index) => {
13
+ const background = backgrounds[index];
14
+ return [block, { fg: contrastColor(background), bg: background }];
15
+ }),
16
+ ) as Record<PowerlineBlockName, { fg: string; bg: string }>,
17
+ extensionSeparator: backgrounds[2],
18
+ };
19
19
  }
20
20
 
21
21
  function contrastColor(hex: string): string {
22
- const background = relativeLuminance(hex);
23
- const dark = relativeLuminance("#090c0c");
24
- const light = relativeLuminance("#f0f0f0");
25
- return contrastRatio(background, dark) >= contrastRatio(background, light)
26
- ? "#090c0c"
27
- : "#f0f0f0";
22
+ const background = relativeLuminance(hex);
23
+ const dark = relativeLuminance("#090c0c");
24
+ const light = relativeLuminance("#f0f0f0");
25
+ return contrastRatio(background, dark) >= contrastRatio(background, light) ? "#090c0c" : "#f0f0f0";
28
26
  }
29
27
 
30
28
  function contrastRatio(left: number, right: number): number {
31
- return (Math.max(left, right) + 0.05) / (Math.min(left, right) + 0.05);
29
+ return (Math.max(left, right) + 0.05) / (Math.min(left, right) + 0.05);
32
30
  }
33
31
 
34
32
  function relativeLuminance(hex: string): number {
35
- const normalized = hex.slice(1);
36
- const channels = [0, 2, 4].map((offset) => {
37
- const value = Number.parseInt(normalized.slice(offset, offset + 2), 16) / 255;
38
- return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
39
- });
40
- return 0.2126 * (channels[0] ?? 0) + 0.7152 * (channels[1] ?? 0) + 0.0722 * (channels[2] ?? 0);
33
+ const normalized = hex.slice(1);
34
+ const channels = [0, 2, 4].map((offset) => {
35
+ const value = Number.parseInt(normalized.slice(offset, offset + 2), 16) / 255;
36
+ return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
37
+ });
38
+ return 0.2126 * (channels[0] ?? 0) + 0.7152 * (channels[1] ?? 0) + 0.0722 * (channels[2] ?? 0);
41
39
  }
@@ -1,11 +1,11 @@
1
1
  import type { PowerlinePreset } from "./types.js";
2
2
 
3
3
  export const CUSTOM_PRESET: PowerlinePreset = {
4
- blocks: {
5
- header: {},
6
- directory: {},
7
- git: {},
8
- runtime: {},
9
- meter: {},
10
- },
4
+ blocks: {
5
+ header: {},
6
+ directory: {},
7
+ git: {},
8
+ runtime: {},
9
+ meter: {},
10
+ },
11
11
  };
@@ -1,9 +1,3 @@
1
1
  import { createRampPreset } from "./create-ramp.js";
2
2
 
3
- export const FOREST_PRESET = createRampPreset([
4
- "#a7c080",
5
- "#83c092",
6
- "#5f9f75",
7
- "#3f6f55",
8
- "#293f35",
9
- ]);
3
+ export const FOREST_PRESET = createRampPreset(["#a7c080", "#83c092", "#5f9f75", "#3f6f55", "#293f35"]);
@@ -1,10 +1,10 @@
1
1
  import {
2
- type PaletteName,
3
- type PalettePreset,
4
- type PowerlineBlockName,
5
- SEGMENT_NAMES,
6
- type SegmentName,
7
- type SegmentPalette,
2
+ type PaletteName,
3
+ type PalettePreset,
4
+ type PowerlineBlockName,
5
+ SEGMENT_NAMES,
6
+ type SegmentName,
7
+ type SegmentPalette,
8
8
  } from "../types.js";
9
9
  import { CANDY_PRESET } from "./candy.js";
10
10
  import { CUSTOM_PRESET } from "./custom.js";
@@ -17,39 +17,37 @@ import { TOKYO_NIGHT_PRESET } from "./tokyo-night.js";
17
17
  import type { PowerlinePreset } from "./types.js";
18
18
 
19
19
  const PRESETS = {
20
- "tokyo-night": TOKYO_NIGHT_PRESET,
21
- ocean: OCEAN_PRESET,
22
- sunset: SUNSET_PRESET,
23
- forest: FOREST_PRESET,
24
- candy: CANDY_PRESET,
25
- neon: NEON_PRESET,
26
- mono: MONO_PRESET,
27
- custom: CUSTOM_PRESET,
20
+ "tokyo-night": TOKYO_NIGHT_PRESET,
21
+ ocean: OCEAN_PRESET,
22
+ sunset: SUNSET_PRESET,
23
+ forest: FOREST_PRESET,
24
+ candy: CANDY_PRESET,
25
+ neon: NEON_PRESET,
26
+ mono: MONO_PRESET,
27
+ custom: CUSTOM_PRESET,
28
28
  } satisfies Record<PalettePreset, PowerlinePreset>;
29
29
 
30
30
  const SEGMENT_BLOCKS: Record<SegmentName, PowerlineBlockName> = {
31
- brand: "header",
32
- provider: "header",
33
- model: "header",
34
- thinking: "header",
35
- cwd: "directory",
36
- branch: "git",
37
- tools: "runtime",
38
- context: "runtime",
39
- tokens: "runtime",
40
- cache: "runtime",
41
- cost: "meter",
42
- time: "meter",
43
- turn: "meter",
31
+ brand: "header",
32
+ provider: "header",
33
+ model: "header",
34
+ thinking: "header",
35
+ cwd: "directory",
36
+ branch: "git",
37
+ tools: "runtime",
38
+ context: "runtime",
39
+ tokens: "runtime",
40
+ cache: "runtime",
41
+ cost: "meter",
42
+ time: "meter",
43
+ turn: "meter",
44
44
  };
45
45
 
46
46
  export function resolvePreset(preset: PalettePreset): PowerlinePreset {
47
- return PRESETS[preset];
47
+ return PRESETS[preset];
48
48
  }
49
49
 
50
50
  export function segmentPaletteForPreset(preset: PaletteName): SegmentPalette {
51
- const blocks = PRESETS[preset].blocks;
52
- return Object.fromEntries(
53
- SEGMENT_NAMES.map((name) => [name, { ...blocks[SEGMENT_BLOCKS[name]] }]),
54
- ) as SegmentPalette;
51
+ const blocks = PRESETS[preset].blocks;
52
+ return Object.fromEntries(SEGMENT_NAMES.map((name) => [name, { ...blocks[SEGMENT_BLOCKS[name]] }])) as SegmentPalette;
55
53
  }
@@ -1,9 +1,3 @@
1
1
  import { createRampPreset } from "./create-ramp.js";
2
2
 
3
- export const MONO_PRESET = createRampPreset([
4
- "#d4d4d4",
5
- "#a3a3a3",
6
- "#686868",
7
- "#404040",
8
- "#262626",
9
- ]);
3
+ export const MONO_PRESET = createRampPreset(["#d4d4d4", "#a3a3a3", "#686868", "#404040", "#262626"]);
@@ -1,9 +1,3 @@
1
1
  import { createRampPreset } from "./create-ramp.js";
2
2
 
3
- export const NEON_PRESET = createRampPreset([
4
- "#39ff14",
5
- "#00f5ff",
6
- "#ff4fd8",
7
- "#7a2cf3",
8
- "#29134f",
9
- ]);
3
+ export const NEON_PRESET = createRampPreset(["#39ff14", "#00f5ff", "#ff4fd8", "#7a2cf3", "#29134f"]);
@@ -1,9 +1,3 @@
1
1
  import { createRampPreset } from "./create-ramp.js";
2
2
 
3
- export const OCEAN_PRESET = createRampPreset([
4
- "#7dcfff",
5
- "#4f9fba",
6
- "#2d6f88",
7
- "#23475b",
8
- "#182b3a",
9
- ]);
3
+ export const OCEAN_PRESET = createRampPreset(["#7dcfff", "#4f9fba", "#2d6f88", "#23475b", "#182b3a"]);
@@ -1,9 +1,3 @@
1
1
  import { createRampPreset } from "./create-ramp.js";
2
2
 
3
- export const SUNSET_PRESET = createRampPreset([
4
- "#ffcf70",
5
- "#f59e6f",
6
- "#dc718a",
7
- "#8f5b78",
8
- "#493447",
9
- ]);
3
+ export const SUNSET_PRESET = createRampPreset(["#ffcf70", "#f59e6f", "#dc718a", "#8f5b78", "#493447"]);
@@ -1,13 +1,13 @@
1
1
  import type { PowerlinePreset } from "./types.js";
2
2
 
3
3
  export const TOKYO_NIGHT_PRESET: PowerlinePreset = {
4
- lead: "#a3aed2",
5
- blocks: {
6
- header: { fg: "#090c0c", bg: "#a3aed2" },
7
- directory: { fg: "#e3e5e5", bg: "#769ff0" },
8
- git: { fg: "#769ff0", bg: "#394260" },
9
- runtime: { fg: "#769ff0", bg: "#212736" },
10
- meter: { fg: "#a0a9cb", bg: "#1d2230" },
11
- },
12
- extensionSeparator: "#394260",
4
+ lead: "#a3aed2",
5
+ blocks: {
6
+ header: { fg: "#090c0c", bg: "#a3aed2" },
7
+ directory: { fg: "#e3e5e5", bg: "#769ff0" },
8
+ git: { fg: "#769ff0", bg: "#394260" },
9
+ runtime: { fg: "#769ff0", bg: "#212736" },
10
+ meter: { fg: "#a0a9cb", bg: "#1d2230" },
11
+ },
12
+ extensionSeparator: "#394260",
13
13
  };
@@ -1,12 +1,12 @@
1
1
  import type { PowerlineBlockName } from "../types.js";
2
2
 
3
3
  export interface BlockColors {
4
- fg?: string;
5
- bg?: string;
4
+ fg?: string;
5
+ bg?: string;
6
6
  }
7
7
 
8
8
  export interface PowerlinePreset {
9
- lead?: string;
10
- blocks: Record<PowerlineBlockName, BlockColors>;
11
- extensionSeparator?: string;
9
+ lead?: string;
10
+ blocks: Record<PowerlineBlockName, BlockColors>;
11
+ extensionSeparator?: string;
12
12
  }