@typescript-calendar-lib/cli 0.2.2 → 0.2.6
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/dist/bin.d.ts +28 -0
- package/dist/bin.js +164 -0
- package/dist/bin.js.map +1 -0
- package/dist/calendar-DNDADt5T.js +241 -0
- package/dist/calendar-DNDADt5T.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +2 -0
- package/dist/theme-BMYtCxK2.d.ts +53 -0
- package/package.json +16 -8
- package/src/align.ts +0 -35
- package/src/ansi.ts +0 -18
- package/src/bin.ts +0 -234
- package/src/border.ts +0 -37
- package/src/calendar.ts +0 -70
- package/src/index.ts +0 -24
- package/src/month.ts +0 -207
- package/src/render.ts +0 -5
- package/src/theme.ts +0 -148
- package/src/types.ts +0 -27
- package/src/year.ts +0 -50
package/src/theme.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// ─── テーマ ───────────────────────────────────────────────
|
|
2
|
-
|
|
3
|
-
/** 組み込みテーマ名。カスタムテーマは CliTheme オブジェクトを直接渡せる */
|
|
4
|
-
export type ThemeName = "default" | "modern";
|
|
5
|
-
|
|
6
|
-
/** 枠線の文字セット(modern テーマで使用) */
|
|
7
|
-
export interface FrameChars {
|
|
8
|
-
topLeft: string;
|
|
9
|
-
topRight: string;
|
|
10
|
-
bottomLeft: string;
|
|
11
|
-
bottomRight: string;
|
|
12
|
-
/** 水平線 */
|
|
13
|
-
h: string;
|
|
14
|
-
/** 垂直線 */
|
|
15
|
-
v: string;
|
|
16
|
-
/** ヘッダー/本文の区切り行で使う交差(┬ や ┼) */
|
|
17
|
-
j: string;
|
|
18
|
-
/** 下端区切りで使う交差(┴) */
|
|
19
|
-
footJ: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** 文字ベースの見た目定義 */
|
|
23
|
-
export interface CliTheme {
|
|
24
|
-
/** セル幅(日付表記の文字幅) */
|
|
25
|
-
cellWidth: number;
|
|
26
|
-
/** セル間の区切り文字(default: " " / modern: "│") */
|
|
27
|
-
separator: string;
|
|
28
|
-
/** 枠線文字。null なら枠なし */
|
|
29
|
-
frame: FrameChars | null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const THEMES: Record<ThemeName, CliTheme> = {
|
|
33
|
-
default: {
|
|
34
|
-
cellWidth: 3,
|
|
35
|
-
separator: " ",
|
|
36
|
-
frame: null,
|
|
37
|
-
},
|
|
38
|
-
modern: {
|
|
39
|
-
cellWidth: 3,
|
|
40
|
-
separator: "│",
|
|
41
|
-
frame: {
|
|
42
|
-
topLeft: "┌",
|
|
43
|
-
topRight: "┐",
|
|
44
|
-
bottomLeft: "└",
|
|
45
|
-
bottomRight: "┘",
|
|
46
|
-
h: "─",
|
|
47
|
-
v: "│",
|
|
48
|
-
j: "┬",
|
|
49
|
-
footJ: "┴",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export function resolveTheme(theme?: ThemeName | CliTheme): CliTheme {
|
|
55
|
-
if (theme === undefined) return THEMES.default;
|
|
56
|
-
if (typeof theme === "string") return THEMES[theme] ?? THEMES.default;
|
|
57
|
-
return theme;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ─── カラースキーム ───────────────────────────────────────
|
|
61
|
-
|
|
62
|
-
/** 組み込みカラースキーム名。カスタムは CliPalette を直接渡せる */
|
|
63
|
-
export type ColorSchemeName =
|
|
64
|
-
| "default"
|
|
65
|
-
| "ocean"
|
|
66
|
-
| "forest"
|
|
67
|
-
| "sunset"
|
|
68
|
-
| "mono";
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* ANSIカラーパレット。
|
|
72
|
-
* 各フィールドは前景色(またはハイライト時の背景)のANSIコード。
|
|
73
|
-
* undefined はその要素を着色しない。
|
|
74
|
-
*/
|
|
75
|
-
export interface CliPalette {
|
|
76
|
-
title?: number;
|
|
77
|
-
weekday?: number;
|
|
78
|
-
day?: number;
|
|
79
|
-
weekend?: number;
|
|
80
|
-
today?: number;
|
|
81
|
-
/** highlightStyle: "reverse" のときに使うコード(default は 7 = 反転) */
|
|
82
|
-
highlight?: number;
|
|
83
|
-
range?: number;
|
|
84
|
-
frame?: number;
|
|
85
|
-
dim?: number;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const COLOR_SCHEMES: Record<ColorSchemeName, CliPalette> = {
|
|
89
|
-
/** 従来どおり。着色は range(黄) と highlight(反転) のみ */
|
|
90
|
-
default: {
|
|
91
|
-
range: 33,
|
|
92
|
-
highlight: 7,
|
|
93
|
-
},
|
|
94
|
-
ocean: {
|
|
95
|
-
title: 36,
|
|
96
|
-
weekday: 36,
|
|
97
|
-
day: 37,
|
|
98
|
-
weekend: 34,
|
|
99
|
-
today: 36,
|
|
100
|
-
highlight: 7,
|
|
101
|
-
range: 34,
|
|
102
|
-
frame: 36,
|
|
103
|
-
dim: 90,
|
|
104
|
-
},
|
|
105
|
-
forest: {
|
|
106
|
-
title: 32,
|
|
107
|
-
weekday: 32,
|
|
108
|
-
day: 37,
|
|
109
|
-
weekend: 90,
|
|
110
|
-
today: 32,
|
|
111
|
-
highlight: 7,
|
|
112
|
-
range: 32,
|
|
113
|
-
frame: 32,
|
|
114
|
-
dim: 90,
|
|
115
|
-
},
|
|
116
|
-
sunset: {
|
|
117
|
-
title: 35,
|
|
118
|
-
weekday: 35,
|
|
119
|
-
day: 37,
|
|
120
|
-
weekend: 33,
|
|
121
|
-
today: 35,
|
|
122
|
-
highlight: 7,
|
|
123
|
-
range: 35,
|
|
124
|
-
frame: 35,
|
|
125
|
-
dim: 90,
|
|
126
|
-
},
|
|
127
|
-
mono: {
|
|
128
|
-
title: 37,
|
|
129
|
-
weekday: 37,
|
|
130
|
-
day: 37,
|
|
131
|
-
weekend: 90,
|
|
132
|
-
today: 37,
|
|
133
|
-
highlight: 7,
|
|
134
|
-
range: 90,
|
|
135
|
-
frame: 90,
|
|
136
|
-
dim: 90,
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export function resolveColorScheme(
|
|
141
|
-
scheme?: ColorSchemeName | CliPalette,
|
|
142
|
-
): CliPalette {
|
|
143
|
-
if (scheme === undefined) return COLOR_SCHEMES.default;
|
|
144
|
-
if (typeof scheme === "string") {
|
|
145
|
-
return COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default;
|
|
146
|
-
}
|
|
147
|
-
return scheme;
|
|
148
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CalendarOptions as CoreCalendarOptions,
|
|
3
|
-
CalendarRangeOptions as CoreCalendarRangeOptions,
|
|
4
|
-
CalendarYearOptions as CoreCalendarYearOptions,
|
|
5
|
-
RenderMonthOptions as CoreRenderMonthOptions,
|
|
6
|
-
} from "@typescript-calendar-lib/core";
|
|
7
|
-
import type {
|
|
8
|
-
CliPalette,
|
|
9
|
-
CliTheme,
|
|
10
|
-
ColorSchemeName,
|
|
11
|
-
ThemeName,
|
|
12
|
-
} from "./theme.ts";
|
|
13
|
-
|
|
14
|
-
/** CLI 固有のオプション(core のオプションに追加で受け付ける) */
|
|
15
|
-
export interface CliExtraOptions {
|
|
16
|
-
/** 見た目テーマ。既定は "default" */
|
|
17
|
-
theme?: ThemeName | CliTheme;
|
|
18
|
-
/** カラースキーム。color: true のとき有効。既定は "default" */
|
|
19
|
-
colorScheme?: ColorSchemeName | CliPalette;
|
|
20
|
-
/** 今日の基準日。カラースキームの today 着色に使用 */
|
|
21
|
-
today?: Date;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type CalendarOptions = CoreCalendarOptions & CliExtraOptions;
|
|
25
|
-
export type CalendarYearOptions = CoreCalendarYearOptions & CliExtraOptions;
|
|
26
|
-
export type CalendarRangeOptions = CoreCalendarRangeOptions & CliExtraOptions;
|
|
27
|
-
export type RenderMonthOptions = CoreRenderMonthOptions & CliExtraOptions;
|
package/src/year.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { visibleWidth } from "./ansi.ts";
|
|
2
|
-
import { renderMonth } from "./month.ts";
|
|
3
|
-
import type { RenderMonthOptions } from "./types.ts";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 年間カレンダーを4列×3行でテキストで返す
|
|
7
|
-
*/
|
|
8
|
-
export function renderYear(
|
|
9
|
-
year: number,
|
|
10
|
-
options: RenderMonthOptions = {},
|
|
11
|
-
): string {
|
|
12
|
-
const months: string[] = [];
|
|
13
|
-
for (let m = 1; m <= 12; m++) {
|
|
14
|
-
months.push(renderMonth(year, m, options));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const monthLines = months.map((m) => m.split("\n"));
|
|
18
|
-
const maxLines = Math.max(...monthLines.map((l) => l.length));
|
|
19
|
-
|
|
20
|
-
const colWidths = monthLines.map((lines) =>
|
|
21
|
-
Math.max(...lines.map((l) => visibleWidth(l))),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const result: string[] = [];
|
|
25
|
-
for (let row = 0; row < 3; row++) {
|
|
26
|
-
const rowLines: string[] = [];
|
|
27
|
-
for (let lineIdx = 0; lineIdx < maxLines; lineIdx++) {
|
|
28
|
-
const parts: string[] = [];
|
|
29
|
-
for (let col = 0; col < 4; col++) {
|
|
30
|
-
const monthIdx = row * 4 + col;
|
|
31
|
-
if (monthIdx >= 12) {
|
|
32
|
-
parts.push("");
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const lines = monthLines[monthIdx]!;
|
|
36
|
-
const line = lines[lineIdx] ?? "";
|
|
37
|
-
const pad = Math.max(0, colWidths[monthIdx]! - visibleWidth(line));
|
|
38
|
-
parts.push(line + " ".repeat(pad));
|
|
39
|
-
}
|
|
40
|
-
rowLines.push(parts.join(" "));
|
|
41
|
-
}
|
|
42
|
-
result.push(rowLines.join("\n"));
|
|
43
|
-
|
|
44
|
-
if (row < 2) {
|
|
45
|
-
result.push("");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return result.join("\n");
|
|
50
|
-
}
|