@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 ADDED
@@ -0,0 +1,28 @@
1
+ import { i as ColorSchemeName, s as ThemeName } from "./theme-BMYtCxK2.js";
2
+ import { HighlightStyle, Locale, WeekStart } from "@typescript-calendar-lib/core";
3
+ //#region src/bin.d.ts
4
+ export interface CliArgs {
5
+ year?: number;
6
+ month?: number;
7
+ theme?: ThemeName;
8
+ colorScheme?: ColorSchemeName;
9
+ color?: boolean;
10
+ locale?: Locale;
11
+ weekStart?: WeekStart;
12
+ highlight?: Date;
13
+ highlightStyle?: HighlightStyle;
14
+ }
15
+ export interface ParseResult {
16
+ args: CliArgs;
17
+ error?: string;
18
+ help?: boolean;
19
+ }
20
+ /** YYYY-MM-DD 形式の日付文字列をパースする */
21
+ export declare function parseDate(value: string): Date | null;
22
+ /**
23
+ * CLI 引数をパースする。テスト可能なように副作用を分離している。
24
+ */
25
+ export declare function parseArgs(args: readonly string[]): ParseResult;
26
+ export declare function printUsage(): string;
27
+ //#endregion
28
+ //# sourceMappingURL=bin.d.ts.map
package/dist/bin.js ADDED
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env bun
2
+ import { t as calendar } from "./calendar-DNDADt5T.js";
3
+ import { createDate } from "@typescript-calendar-lib/core";
4
+ //#region src/bin.ts
5
+ const THEMES = ["default", "modern"];
6
+ const COLOR_SCHEMES = [
7
+ "default",
8
+ "ocean",
9
+ "forest",
10
+ "sunset",
11
+ "mono"
12
+ ];
13
+ const LOCALES = [
14
+ "en",
15
+ "ja",
16
+ "es",
17
+ "de",
18
+ "fr",
19
+ "ko",
20
+ "zh"
21
+ ];
22
+ const WEEK_STARTS = ["sunday", "monday"];
23
+ const HIGHLIGHT_STYLES = ["bracket", "reverse"];
24
+ /** 値を一つ取るオプションと、代入先のフィールド名 */
25
+ const VALUE_OPTIONS = {
26
+ "--theme": "theme",
27
+ "--color-scheme": "colorScheme",
28
+ "--locale": "locale",
29
+ "--week-start": "weekStart",
30
+ "--highlight-style": "highlightStyle"
31
+ };
32
+ /** YYYY-MM-DD 形式の日付文字列をパースする */
33
+ function parseDate(value) {
34
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
35
+ if (!match) return null;
36
+ const year = Number(match[1]);
37
+ const month = Number(match[2]);
38
+ const day = Number(match[3]);
39
+ if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31) return null;
40
+ const date = createDate(year, month - 1, day);
41
+ if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) return null;
42
+ return date;
43
+ }
44
+ /**
45
+ * CLI 引数をパースする。テスト可能なように副作用を分離している。
46
+ */
47
+ function parseArgs(args) {
48
+ const result = {};
49
+ const error = (message) => ({
50
+ args: result,
51
+ error: message
52
+ });
53
+ for (let i = 0; i < args.length; i++) {
54
+ const arg = args[i];
55
+ if (arg === "-h" || arg === "--help") return {
56
+ args: result,
57
+ help: true
58
+ };
59
+ if (arg === "--color") {
60
+ result.color = true;
61
+ continue;
62
+ }
63
+ if (arg === "--highlight") {
64
+ const value = args[++i];
65
+ if (value === void 0) return error("Missing value for option: --highlight");
66
+ const parsed = parseDate(value);
67
+ if (parsed === null) return error(`Invalid --highlight date: "${value}" (expected YYYY-MM-DD, e.g. 2026-09-08)`);
68
+ result.highlight = parsed;
69
+ continue;
70
+ }
71
+ const key = VALUE_OPTIONS[arg];
72
+ if (key !== void 0) {
73
+ const value = args[++i];
74
+ if (value === void 0) return error(`Missing value for option: ${arg}`);
75
+ result[key] = value;
76
+ continue;
77
+ }
78
+ const numeric = /^-?\d+$/.test(arg);
79
+ if (arg.startsWith("-") && !numeric) return error(`Unknown option: ${arg}`);
80
+ if (!numeric) return error(`Invalid argument: "${arg}" (expected a year or month number)`);
81
+ if (result.year === void 0) result.year = Number(arg);
82
+ else if (result.month === void 0) result.month = Number(arg);
83
+ else return error(`Too many arguments: "${arg}"`);
84
+ }
85
+ if (result.year !== void 0 && (result.year < 1 || result.year > 9999)) return error(`Invalid year: ${result.year} (expected 1–9999)`);
86
+ if (result.month !== void 0 && (result.month < 1 || result.month > 12)) return error(`Invalid month: ${result.month} (expected 1–12)`);
87
+ const choiceTable = [
88
+ [
89
+ result.theme,
90
+ THEMES,
91
+ "theme"
92
+ ],
93
+ [
94
+ result.colorScheme,
95
+ COLOR_SCHEMES,
96
+ "color-scheme"
97
+ ],
98
+ [
99
+ result.locale,
100
+ LOCALES,
101
+ "locale"
102
+ ],
103
+ [
104
+ result.weekStart,
105
+ WEEK_STARTS,
106
+ "week-start"
107
+ ],
108
+ [
109
+ result.highlightStyle,
110
+ HIGHLIGHT_STYLES,
111
+ "highlight-style"
112
+ ]
113
+ ];
114
+ for (const [value, choices, name] of choiceTable) if (value !== void 0 && !choices.includes(value)) return error(`Invalid ${name}: "${value}" (expected: ${choices.join(" | ")})`);
115
+ return { args: result };
116
+ }
117
+ function printUsage() {
118
+ return `Usage: typescript-calendar-lib [YYYY] [MM] [options]
119
+
120
+ typescript-calendar-lib Render the current month
121
+ typescript-calendar-lib 2026 Render the current month of 2026
122
+ typescript-calendar-lib 2026 9 Render September 2026
123
+
124
+ Options:
125
+ --theme <name> Look: default | modern (default: default)
126
+ --color-scheme <name> Colors: default | ocean | forest | sunset | mono
127
+ --color Enable ANSI colors
128
+ --locale <lang> Language: en | ja | es | de | fr | ko | zh (default: en)
129
+ --week-start <day> First weekday: sunday | monday (default: sunday)
130
+ --highlight <YYYY-MM-DD> Highlight a date (e.g. 2026-09-08)
131
+ --highlight-style <style> Highlight style: bracket | reverse (default: bracket)
132
+ -h, --help Show this help
133
+ `;
134
+ }
135
+ if (import.meta.main) {
136
+ const { args, error, help } = parseArgs(process.argv.slice(2));
137
+ if (help) {
138
+ console.log(printUsage());
139
+ process.exit(0);
140
+ }
141
+ if (error) {
142
+ console.error(`Error: ${error}`);
143
+ console.error(printUsage());
144
+ process.exit(1);
145
+ }
146
+ const now = /* @__PURE__ */ new Date();
147
+ const year = args.year ?? now.getFullYear();
148
+ const month = args.month ?? now.getMonth() + 1;
149
+ console.log(calendar({
150
+ year,
151
+ month,
152
+ theme: args.theme,
153
+ colorScheme: args.colorScheme,
154
+ color: args.color,
155
+ locale: args.locale,
156
+ weekStart: args.weekStart,
157
+ highlight: args.highlight,
158
+ highlightStyle: args.highlightStyle
159
+ }));
160
+ }
161
+ //#endregion
162
+ export { parseArgs, parseDate, printUsage };
163
+
164
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env bun\nimport type {\n HighlightStyle,\n Locale,\n WeekStart,\n} from \"@typescript-calendar-lib/core\";\nimport { createDate } from \"@typescript-calendar-lib/core\";\nimport { calendar } from \"./calendar.ts\";\nimport type { ColorSchemeName, ThemeName } from \"./theme.ts\";\n\nexport interface CliArgs {\n year?: number;\n month?: number;\n theme?: ThemeName;\n colorScheme?: ColorSchemeName;\n color?: boolean;\n locale?: Locale;\n weekStart?: WeekStart;\n highlight?: Date;\n highlightStyle?: HighlightStyle;\n}\n\nexport interface ParseResult {\n args: CliArgs;\n error?: string;\n help?: boolean;\n}\n\nconst THEMES: readonly ThemeName[] = [\"default\", \"modern\"];\nconst COLOR_SCHEMES: readonly ColorSchemeName[] = [\n \"default\",\n \"ocean\",\n \"forest\",\n \"sunset\",\n \"mono\",\n];\nconst LOCALES: readonly Locale[] = [\"en\", \"ja\", \"es\", \"de\", \"fr\", \"ko\", \"zh\"];\nconst WEEK_STARTS: readonly WeekStart[] = [\"sunday\", \"monday\"];\nconst HIGHLIGHT_STYLES: readonly HighlightStyle[] = [\"bracket\", \"reverse\"];\n\n/** 値を一つ取るオプションと、代入先のフィールド名 */\nconst VALUE_OPTIONS: Record<string, keyof CliArgs> = {\n \"--theme\": \"theme\",\n \"--color-scheme\": \"colorScheme\",\n \"--locale\": \"locale\",\n \"--week-start\": \"weekStart\",\n \"--highlight-style\": \"highlightStyle\",\n};\n\n/** YYYY-MM-DD 形式の日付文字列をパースする */\nexport function parseDate(value: string): Date | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n if (!match) return null;\n const year = Number(match[1]);\n const month = Number(match[2]);\n const day = Number(match[3]);\n if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31) {\n return null;\n }\n const date = createDate(year, month - 1, day);\n if (\n date.getFullYear() !== year ||\n date.getMonth() !== month - 1 ||\n date.getDate() !== day\n ) {\n return null;\n }\n return date;\n}\n\n/**\n * CLI 引数をパースする。テスト可能なように副作用を分離している。\n */\nexport function parseArgs(args: readonly string[]): ParseResult {\n const result: CliArgs = {};\n const error = (message: string): ParseResult => ({\n args: result,\n error: message,\n });\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]!;\n\n if (arg === \"-h\" || arg === \"--help\") {\n return { args: result, help: true };\n }\n if (arg === \"--color\") {\n result.color = true;\n continue;\n }\n if (arg === \"--highlight\") {\n const value = args[++i];\n if (value === undefined) {\n return error(\"Missing value for option: --highlight\");\n }\n const parsed = parseDate(value);\n if (parsed === null) {\n return error(\n `Invalid --highlight date: \"${value}\" (expected YYYY-MM-DD, e.g. 2026-09-08)`,\n );\n }\n result.highlight = parsed;\n continue;\n }\n\n const key = VALUE_OPTIONS[arg];\n if (key !== undefined) {\n const value = args[++i];\n if (value === undefined) {\n return error(`Missing value for option: ${arg}`);\n }\n (result as Record<string, unknown>)[key] = value;\n continue;\n }\n\n const numeric = /^-?\\d+$/.test(arg);\n if (arg.startsWith(\"-\") && !numeric) {\n return error(`Unknown option: ${arg}`);\n }\n if (!numeric) {\n return error(\n `Invalid argument: \"${arg}\" (expected a year or month number)`,\n );\n }\n if (result.year === undefined) {\n result.year = Number(arg);\n } else if (result.month === undefined) {\n result.month = Number(arg);\n } else {\n return error(`Too many arguments: \"${arg}\"`);\n }\n }\n\n // 値のバリデーション\n if (result.year !== undefined && (result.year < 1 || result.year > 9999)) {\n return error(`Invalid year: ${result.year} (expected 1–9999)`);\n }\n if (result.month !== undefined && (result.month < 1 || result.month > 12)) {\n return error(`Invalid month: ${result.month} (expected 1–12)`);\n }\n\n const choiceTable: Array<[string | undefined, readonly string[], string]> = [\n [result.theme, THEMES, \"theme\"],\n [result.colorScheme, COLOR_SCHEMES, \"color-scheme\"],\n [result.locale, LOCALES, \"locale\"],\n [result.weekStart, WEEK_STARTS, \"week-start\"],\n [result.highlightStyle, HIGHLIGHT_STYLES, \"highlight-style\"],\n ];\n for (const [value, choices, name] of choiceTable) {\n if (value !== undefined && !choices.includes(value)) {\n return error(\n `Invalid ${name}: \"${value}\" (expected: ${choices.join(\" | \")})`,\n );\n }\n }\n\n return { args: result };\n}\n\nexport function printUsage(): string {\n return `Usage: typescript-calendar-lib [YYYY] [MM] [options]\n\n typescript-calendar-lib Render the current month\n typescript-calendar-lib 2026 Render the current month of 2026\n typescript-calendar-lib 2026 9 Render September 2026\n\nOptions:\n --theme <name> Look: default | modern (default: default)\n --color-scheme <name> Colors: default | ocean | forest | sunset | mono\n --color Enable ANSI colors\n --locale <lang> Language: en | ja | es | de | fr | ko | zh (default: en)\n --week-start <day> First weekday: sunday | monday (default: sunday)\n --highlight <YYYY-MM-DD> Highlight a date (e.g. 2026-09-08)\n --highlight-style <style> Highlight style: bracket | reverse (default: bracket)\n -h, --help Show this help\n`;\n}\n\nif (import.meta.main) {\n const { args, error, help } = parseArgs(process.argv.slice(2));\n\n if (help) {\n console.log(printUsage());\n process.exit(0);\n }\n if (error) {\n console.error(`Error: ${error}`);\n console.error(printUsage());\n process.exit(1);\n }\n\n const now = new Date();\n const year = args.year ?? now.getFullYear();\n const month = args.month ?? now.getMonth() + 1;\n\n console.log(\n calendar({\n year,\n month,\n theme: args.theme,\n colorScheme: args.colorScheme,\n color: args.color,\n locale: args.locale,\n weekStart: args.weekStart,\n highlight: args.highlight,\n highlightStyle: args.highlightStyle,\n }),\n );\n}\n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KAAK,KAAK,EAAE,EAChE;CAIJ,OAAO,EAAE,MAAM,OAAO;AACxB;AAEA,SAAgB,aAAqB;CACnC,OAAO;;;;;;;;;;;;;;;;AAgBT;AAEA,IAAI,YAAY,MAAM;CACpB,MAAM,EAAE,MAAM,OAAO,SAAS,UAAU,QAAQ,KAAK,MAAM,CAAC,CAAC;CAE7D,IAAI,MAAM;EACR,QAAQ,IAAI,WAAW,CAAC;EACxB,QAAQ,KAAK,CAAC;CAChB;CACA,IAAI,OAAO;EACT,QAAQ,MAAM,UAAU,OAAO;EAC/B,QAAQ,MAAM,WAAW,CAAC;EAC1B,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,sBAAM,IAAI,KAAK;CACrB,MAAM,OAAO,KAAK,QAAQ,IAAI,YAAY;CAC1C,MAAM,QAAQ,KAAK,SAAS,IAAI,SAAS,IAAI;CAE7C,QAAQ,IACN,SAAS;EACP;EACA;EACA,OAAO,KAAK;EACZ,aAAa,KAAK;EAClB,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,WAAW,KAAK;EAChB,gBAAgB,KAAK;CACvB,CAAC,CACH;AACF"}
@@ -0,0 +1,241 @@
1
+ import { buildMonthGrid, createDate, getMonthName, getMonthRange, getWeekdayHeaders, isDateInRange, isSameDay } from "@typescript-calendar-lib/core";
2
+ //#region src/align.ts
3
+ /** 東アジアの全角文字(ターミナル表示幅2列) */
4
+ const WIDE = /[\u1100-\u115f\u2e80-\u303e\u3041-\u33ff\u3400-\u4dbf\u4e00-\u9fff\ua000-\ua4cf\ua960-\ua97f\uac00-\ud7a3\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/;
5
+ /** ターミナル上の表示幅を返す(全角文字は2列として数える) */
6
+ function displayWidth(text) {
7
+ let width = 0;
8
+ for (const ch of text) width += WIDE.test(ch) ? 2 : 1;
9
+ return width;
10
+ }
11
+ /** 表示幅 width に右詰めする(全角文字対応) */
12
+ function padStartWidth(text, width) {
13
+ return " ".repeat(Math.max(0, width - displayWidth(text))) + text;
14
+ }
15
+ /** タイトルを幅の中央に揃える */
16
+ function centerText(text, width) {
17
+ const padding = Math.max(0, Math.floor((width - displayWidth(text)) / 2));
18
+ return " ".repeat(padding) + text;
19
+ }
20
+ /** タイトルを中央に揃え、幅一杯まで埋める(枠内用) */
21
+ function centerTextFull(text, width) {
22
+ const padding = Math.max(0, Math.floor((width - displayWidth(text)) / 2));
23
+ return " ".repeat(padding) + text + " ".repeat(Math.max(0, width - padding - displayWidth(text)));
24
+ }
25
+ //#endregion
26
+ //#region src/ansi.ts
27
+ const ANSI_PATTERN = new RegExp(`\\[[0-9;]*m`, "g");
28
+ /** ANSI コードを付与する(code が undefined ならそのまま) */
29
+ function colorize(text, code, enabled) {
30
+ if (!enabled || code === void 0) return text;
31
+ return `\u001b[${code}m${text}\u001b[0m`;
32
+ }
33
+ /** ANSI エスケープシーケンスを除去した文字列を返す */
34
+ function stripAnsi(text) {
35
+ return text.replace(ANSI_PATTERN, "");
36
+ }
37
+ //#endregion
38
+ //#region src/border.ts
39
+ /** 枠内のコンテンツ幅(例: 7列×3幅+区切り6 = 27) */
40
+ function innerWidth(cellWidth, cols) {
41
+ return cols * cellWidth + (cols - 1);
42
+ }
43
+ /** セル幅の水平線を cols 個つなげた区切り線を生成する */
44
+ function divider(frame, cellWidth, cols, left, right, join) {
45
+ return `${left}${Array(cols).fill(frame.h.repeat(cellWidth)).join(join)}${right}`;
46
+ }
47
+ /** 上枠: ┌────┬────...────┐ */
48
+ function topBorder(frame, cellWidth, cols) {
49
+ return `${frame.topLeft}${frame.h.repeat(innerWidth(cellWidth, cols))}${frame.topRight}`;
50
+ }
51
+ /** 下枠: └────┴────...────┘ */
52
+ function bottomBorder(frame, cellWidth, cols) {
53
+ return divider(frame, cellWidth, cols, frame.bottomLeft, frame.bottomRight, frame.footJ);
54
+ }
55
+ /** 区切り行: ├────┬────...┬────┤ */
56
+ function separatorRow(frame, cellWidth, cols) {
57
+ return divider(frame, cellWidth, cols, "├", "┤", frame.j);
58
+ }
59
+ //#endregion
60
+ //#region src/theme.ts
61
+ const THEMES = {
62
+ default: {
63
+ cellWidth: 3,
64
+ separator: " ",
65
+ frame: null
66
+ },
67
+ modern: {
68
+ cellWidth: 3,
69
+ separator: "│",
70
+ frame: {
71
+ topLeft: "┌",
72
+ topRight: "┐",
73
+ bottomLeft: "└",
74
+ bottomRight: "┘",
75
+ h: "─",
76
+ v: "│",
77
+ j: "┬",
78
+ footJ: "┴"
79
+ }
80
+ }
81
+ };
82
+ function resolveTheme(theme) {
83
+ return typeof theme === "string" ? THEMES[theme] ?? THEMES.default : theme ?? THEMES.default;
84
+ }
85
+ const COLOR_SCHEMES = {
86
+ /** 従来どおり。着色は range(黄) と highlight(反転) のみ */
87
+ default: {
88
+ range: 33,
89
+ highlight: 7
90
+ },
91
+ ocean: {
92
+ title: 36,
93
+ weekday: 36,
94
+ day: 37,
95
+ weekend: 34,
96
+ today: 36,
97
+ highlight: 7,
98
+ range: 34,
99
+ frame: 36,
100
+ dim: 90
101
+ },
102
+ forest: {
103
+ title: 32,
104
+ weekday: 32,
105
+ day: 37,
106
+ weekend: 90,
107
+ today: 32,
108
+ highlight: 7,
109
+ range: 32,
110
+ frame: 32,
111
+ dim: 90
112
+ },
113
+ sunset: {
114
+ title: 35,
115
+ weekday: 35,
116
+ day: 37,
117
+ weekend: 33,
118
+ today: 35,
119
+ highlight: 7,
120
+ range: 35,
121
+ frame: 35,
122
+ dim: 90
123
+ },
124
+ mono: {
125
+ title: 37,
126
+ weekday: 37,
127
+ day: 37,
128
+ weekend: 90,
129
+ today: 37,
130
+ highlight: 7,
131
+ range: 90,
132
+ frame: 90,
133
+ dim: 90
134
+ }
135
+ };
136
+ function resolveColorScheme(scheme) {
137
+ return typeof scheme === "string" ? COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default : scheme ?? COLOR_SCHEMES.default;
138
+ }
139
+ //#endregion
140
+ //#region src/month.ts
141
+ /**
142
+ * 1ヶ月分のカレンダーテキストを描画する
143
+ */
144
+ function renderMonth(year, month, options = {}) {
145
+ const { locale = "en", weekStart = "sunday", highlight, highlightStyle = "bracket", range, color = false, theme: themeOption = "default", colorScheme: schemeOption = "default", today = /* @__PURE__ */ new Date() } = options;
146
+ const theme = resolveTheme(themeOption);
147
+ const palette = resolveColorScheme(schemeOption);
148
+ const frame = theme.frame;
149
+ const title = `${getMonthName(locale, month)} ${year}`;
150
+ const weekdays = getWeekdayHeaders(locale, weekStart);
151
+ const grid = buildMonthGrid(year, month, weekStart);
152
+ const cols = weekdays.length;
153
+ const cellWidth = Math.max(theme.cellWidth, ...weekdays.map(displayWidth), highlight !== void 0 && highlightStyle === "bracket" ? 4 : 2);
154
+ const sep = frame === null ? theme.separator : frame.v;
155
+ /** 1セルを描画する(day は日数または null=空欄) */
156
+ const renderCell = (day) => {
157
+ if (day === null) return " ".repeat(cellWidth);
158
+ const date = createDate(year, month - 1, day);
159
+ const isHighlight = highlight !== void 0 && isSameDay(date, highlight);
160
+ const isInRange = isDateInRange(date, range);
161
+ const isToday = isSameDay(date, today);
162
+ const isWeekend = date.getDay() === 0 || date.getDay() === 6;
163
+ const text = (isHighlight && highlightStyle === "bracket" ? `[${day}]` : String(day)).padStart(cellWidth);
164
+ let code;
165
+ if (isHighlight && highlightStyle === "reverse") code = palette.highlight ?? 7;
166
+ else if (isInRange && !isHighlight) code = palette.range ?? 33;
167
+ else if (isToday && palette.today !== void 0) code = palette.today;
168
+ else if (isWeekend && palette.weekend !== void 0) code = palette.weekend;
169
+ else if (palette.day !== void 0) code = palette.day;
170
+ return colorize(text, code, color);
171
+ };
172
+ const lines = [];
173
+ if (frame === null) {
174
+ const totalWidth = cols * cellWidth + (cols - 1) * sep.length;
175
+ lines.push(centerText(title, totalWidth));
176
+ lines.push(weekdays.map((d) => colorize(padStartWidth(d, cellWidth), palette.weekday, color)).join(sep));
177
+ } else {
178
+ lines.push(colorize(topBorder(frame, cellWidth, cols), palette.frame, color));
179
+ lines.push(colorize(`${frame.v}${centerTextFull(title, innerWidth(cellWidth, cols))}${frame.v}`, palette.title, color));
180
+ lines.push(colorize(separatorRow(frame, cellWidth, cols), palette.frame, color));
181
+ lines.push(colorize(`${frame.v}${weekdays.map((d) => padStartWidth(d, cellWidth)).join(frame.v)}${frame.v}`, palette.weekday, color));
182
+ lines.push(colorize(separatorRow(frame, cellWidth, cols), palette.frame, color));
183
+ }
184
+ for (const row of grid) {
185
+ if (row.every((d) => d === null)) continue;
186
+ const cells = row.map(renderCell).join(sep);
187
+ lines.push(frame === null ? cells : `${frame.v}${cells}${frame.v}`);
188
+ }
189
+ if (frame !== null) lines.push(colorize(bottomBorder(frame, cellWidth, cols), palette.frame, color));
190
+ return lines.join("\n");
191
+ }
192
+ //#endregion
193
+ //#region src/year.ts
194
+ /**
195
+ * 年間カレンダーを4列×3行でテキストで返す
196
+ *
197
+ * 列幅・パディングは「ANSI 除去後のターミナル表示幅」で計算する。
198
+ * 全角文字(日本語・韓国語・中国語の月名や曜日)も正しく揃う。
199
+ */
200
+ function renderYear(year, options = {}) {
201
+ const widthOf = (line) => displayWidth(stripAnsi(line));
202
+ const months = Array.from({ length: 12 }, (_, i) => renderMonth(year, i + 1, options).split("\n"));
203
+ const maxLines = Math.max(...months.map((lines) => lines.length));
204
+ const colWidths = months.map((lines) => Math.max(...lines.map(widthOf)));
205
+ /** 月の各行をその列幅まで右パディングする(行が足りなければ空行として埋める) */
206
+ const padMonth = (monthIdx) => Array.from({ length: maxLines }, (_, li) => {
207
+ const line = months[monthIdx][li] ?? "";
208
+ return line + " ".repeat(Math.max(0, colWidths[monthIdx] - widthOf(line)));
209
+ });
210
+ const padded = months.map((_, mi) => padMonth(mi));
211
+ const rows = [];
212
+ for (let row = 0; row < 3; row++) rows.push(Array.from({ length: maxLines }, (_, li) => Array.from({ length: 4 }, (_, col) => {
213
+ const monthIdx = row * 4 + col;
214
+ return monthIdx < 12 ? padded[monthIdx][li] : "";
215
+ }).join(" ")).join("\n"));
216
+ return rows.join("\n\n");
217
+ }
218
+ //#endregion
219
+ //#region src/calendar.ts
220
+ /**
221
+ * 月カレンダーをテキストで返す
222
+ */
223
+ function calendar(options) {
224
+ return renderMonth(options.year, options.month, options);
225
+ }
226
+ /**
227
+ * 年間カレンダーを4列×3行でテキストで返す
228
+ */
229
+ function calendarYear(options) {
230
+ return renderYear(options.year, options);
231
+ }
232
+ /**
233
+ * 任意の日付範囲のカレンダーをテキストで返す
234
+ */
235
+ function calendarRange(options) {
236
+ return getMonthRange(options.from, options.to).map(({ year, month }) => renderMonth(year, month, options)).join("\n\n");
237
+ }
238
+ //#endregion
239
+ export { THEMES as a, COLOR_SCHEMES as i, calendarRange as n, resolveColorScheme as o, calendarYear as r, resolveTheme as s, calendar as t };
240
+
241
+ //# sourceMappingURL=calendar-DNDADt5T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-DNDADt5T.js","names":[],"sources":["../src/align.ts","../src/ansi.ts","../src/border.ts","../src/theme.ts","../src/month.ts","../src/year.ts","../src/calendar.ts"],"sourcesContent":["// ─── テキスト整列 ────────────────────────────────────────\n\n/** 東アジアの全角文字(ターミナル表示幅2列) */\nconst WIDE =\n /[\\u1100-\\u115f\\u2e80-\\u303e\\u3041-\\u33ff\\u3400-\\u4dbf\\u4e00-\\u9fff\\ua000-\\ua4cf\\ua960-\\ua97f\\uac00-\\ud7a3\\uf900-\\ufaff\\ufe30-\\ufe4f\\uff00-\\uff60\\uffe0-\\uffe6]/;\n\n/** ターミナル上の表示幅を返す(全角文字は2列として数える) */\nexport function displayWidth(text: string): number {\n let width = 0;\n for (const ch of text) {\n width += WIDE.test(ch) ? 2 : 1;\n }\n return width;\n}\n\n/** 表示幅 width に右詰めする(全角文字対応) */\nexport function padStartWidth(text: string, width: number): string {\n return \" \".repeat(Math.max(0, width - displayWidth(text))) + text;\n}\n\n/** タイトルを幅の中央に揃える */\nexport function centerText(text: string, width: number): string {\n const padding = Math.max(0, Math.floor((width - displayWidth(text)) / 2));\n return \" \".repeat(padding) + text;\n}\n\n/** タイトルを中央に揃え、幅一杯まで埋める(枠内用) */\nexport function centerTextFull(text: string, width: number): string {\n const padding = Math.max(0, Math.floor((width - displayWidth(text)) / 2));\n return (\n \" \".repeat(padding) +\n text +\n \" \".repeat(Math.max(0, width - padding - displayWidth(text)))\n );\n}\n","// ─── ANSI 色付け ─────────────────────────────────────────\n\nimport { displayWidth } from \"./align.ts\";\n\nconst ANSI_PATTERN = new RegExp(`${\"\\u001b\"}\\\\[[0-9;]*m`, \"g\");\n\n/** ANSI コードを付与する(code が undefined ならそのまま) */\nexport function colorize(\n text: string,\n code: number | undefined,\n enabled: boolean,\n): string {\n if (!enabled || code === undefined) return text;\n return `\\u001b[${code}m${text}\\u001b[0m`;\n}\n\n/** ANSI エスケープシーケンスを除去した文字列を返す */\nexport function stripAnsi(text: string): string {\n return text.replace(ANSI_PATTERN, \"\");\n}\n\n/** ANSI エスケープシーケンスを除去した表示幅を返す(全角文字は2列) */\nexport function visibleWidth(text: string): number {\n return displayWidth(stripAnsi(text));\n}\n","import type { FrameChars } from \"./theme.ts\";\n\n// ─── 枠線 ─────────────────────────────────────────────────\n\n/** 枠内のコンテンツ幅(例: 7列×3幅+区切り6 = 27) */\nexport function innerWidth(cellWidth: number, cols: number): number {\n return cols * cellWidth + (cols - 1);\n}\n\n/** セル幅の水平線を cols 個つなげた区切り線を生成する */\nfunction divider(\n frame: FrameChars,\n cellWidth: number,\n cols: number,\n left: string,\n right: string,\n join: string,\n): string {\n const segments = Array<string>(cols).fill(frame.h.repeat(cellWidth));\n return `${left}${segments.join(join)}${right}`;\n}\n\n/** 上枠: ┌────┬────...────┐ */\nexport function topBorder(\n frame: FrameChars,\n cellWidth: number,\n cols: number,\n): string {\n return `${frame.topLeft}${frame.h.repeat(innerWidth(cellWidth, cols))}${frame.topRight}`;\n}\n\n/** 下枠: └────┴────...────┘ */\nexport function bottomBorder(\n frame: FrameChars,\n cellWidth: number,\n cols: number,\n): string {\n return divider(\n frame,\n cellWidth,\n cols,\n frame.bottomLeft,\n frame.bottomRight,\n frame.footJ,\n );\n}\n\n/** 区切り行: ├────┬────...┬────┤ */\nexport function separatorRow(\n frame: FrameChars,\n cellWidth: number,\n cols: number,\n): string {\n return divider(frame, cellWidth, cols, \"├\", \"┤\", frame.j);\n}\n","// ─── テーマ ───────────────────────────────────────────────\n\n/** 組み込みテーマ名。カスタムテーマは CliTheme オブジェクトを直接渡せる */\nexport type ThemeName = \"default\" | \"modern\";\n\n/** 枠線の文字セット(modern テーマで使用) */\nexport interface FrameChars {\n topLeft: string;\n topRight: string;\n bottomLeft: string;\n bottomRight: string;\n /** 水平線 */\n h: string;\n /** 垂直線 */\n v: string;\n /** ヘッダー/本文の区切り行で使う交差(┬ や ┼) */\n j: string;\n /** 下端区切りで使う交差(┴) */\n footJ: string;\n}\n\n/** 文字ベースの見た目定義 */\nexport interface CliTheme {\n /** セル幅(日付表記の文字幅) */\n cellWidth: number;\n /** セル間の区切り文字(default: \" \" / modern: \"│\") */\n separator: string;\n /** 枠線文字。null なら枠なし */\n frame: FrameChars | null;\n}\n\nexport const THEMES: Record<ThemeName, CliTheme> = {\n default: {\n cellWidth: 3,\n separator: \" \",\n frame: null,\n },\n modern: {\n cellWidth: 3,\n separator: \"│\",\n frame: {\n topLeft: \"┌\",\n topRight: \"┐\",\n bottomLeft: \"└\",\n bottomRight: \"┘\",\n h: \"─\",\n v: \"│\",\n j: \"┬\",\n footJ: \"┴\",\n },\n },\n};\n\nexport function resolveTheme(theme?: ThemeName | CliTheme): CliTheme {\n return typeof theme === \"string\"\n ? (THEMES[theme] ?? THEMES.default)\n : (theme ?? THEMES.default);\n}\n\n// ─── カラースキーム ───────────────────────────────────────\n\n/** 組み込みカラースキーム名。カスタムは CliPalette を直接渡せる */\nexport type ColorSchemeName =\n | \"default\"\n | \"ocean\"\n | \"forest\"\n | \"sunset\"\n | \"mono\";\n\n/**\n * ANSIカラーパレット。\n * 各フィールドは前景色(またはハイライト時の背景)のANSIコード。\n * undefined はその要素を着色しない。\n */\nexport interface CliPalette {\n title?: number;\n weekday?: number;\n day?: number;\n weekend?: number;\n today?: number;\n /** highlightStyle: \"reverse\" のときに使うコード(default は 7 = 反転) */\n highlight?: number;\n range?: number;\n frame?: number;\n dim?: number;\n}\n\nexport const COLOR_SCHEMES: Record<ColorSchemeName, CliPalette> = {\n /** 従来どおり。着色は range(黄) と highlight(反転) のみ */\n default: {\n range: 33,\n highlight: 7,\n },\n ocean: {\n title: 36,\n weekday: 36,\n day: 37,\n weekend: 34,\n today: 36,\n highlight: 7,\n range: 34,\n frame: 36,\n dim: 90,\n },\n forest: {\n title: 32,\n weekday: 32,\n day: 37,\n weekend: 90,\n today: 32,\n highlight: 7,\n range: 32,\n frame: 32,\n dim: 90,\n },\n sunset: {\n title: 35,\n weekday: 35,\n day: 37,\n weekend: 33,\n today: 35,\n highlight: 7,\n range: 35,\n frame: 35,\n dim: 90,\n },\n mono: {\n title: 37,\n weekday: 37,\n day: 37,\n weekend: 90,\n today: 37,\n highlight: 7,\n range: 90,\n frame: 90,\n dim: 90,\n },\n};\n\nexport function resolveColorScheme(\n scheme?: ColorSchemeName | CliPalette,\n): CliPalette {\n return typeof scheme === \"string\"\n ? (COLOR_SCHEMES[scheme] ?? COLOR_SCHEMES.default)\n : (scheme ?? COLOR_SCHEMES.default);\n}\n","import {\n buildMonthGrid,\n createDate,\n getMonthName,\n getWeekdayHeaders,\n isDateInRange,\n isSameDay,\n} from \"@typescript-calendar-lib/core\";\nimport {\n centerText,\n centerTextFull,\n displayWidth,\n padStartWidth,\n} from \"./align.ts\";\nimport { colorize } from \"./ansi.ts\";\nimport { bottomBorder, innerWidth, separatorRow, topBorder } from \"./border.ts\";\nimport { resolveColorScheme, resolveTheme } from \"./theme.ts\";\nimport type { RenderMonthOptions } from \"./types.ts\";\n\n/**\n * 1ヶ月分のカレンダーテキストを描画する\n */\nexport function renderMonth(\n year: number,\n month: number,\n options: RenderMonthOptions = {},\n): string {\n const {\n locale = \"en\",\n weekStart = \"sunday\",\n highlight,\n highlightStyle = \"bracket\",\n range,\n color = false,\n theme: themeOption = \"default\",\n colorScheme: schemeOption = \"default\",\n today = new Date(),\n } = options;\n\n const theme = resolveTheme(themeOption);\n const palette = resolveColorScheme(schemeOption);\n const frame = theme.frame;\n\n const title = `${getMonthName(locale, month)} ${year}`;\n const weekdays = getWeekdayHeaders(locale, weekStart);\n const grid = buildMonthGrid(year, month, weekStart);\n const cols = weekdays.length;\n\n // セル幅はテーマ指定を基本としつつ、以下を満たすように広げる:\n // - 曜日ヘッダーの表示幅(fr の \"dim.\" 等がセル幅を超えると列が崩れる)\n // - bracket ハイライトは2桁の日付で `[10]` の4文字になるため\n const cellWidth = Math.max(\n theme.cellWidth,\n ...weekdays.map(displayWidth),\n highlight !== undefined && highlightStyle === \"bracket\" ? 4 : 2,\n );\n\n // 枠なしテーマは separator、枠ありテーマは縦線でセルを繋ぐ\n const sep = frame === null ? theme.separator : frame.v;\n\n /** 1セルを描画する(day は日数または null=空欄) */\n const renderCell = (day: number | null): string => {\n if (day === null) return \" \".repeat(cellWidth);\n\n const date = createDate(year, month - 1, day);\n const isHighlight = highlight !== undefined && isSameDay(date, highlight);\n const isInRange = isDateInRange(date, range);\n const isToday = isSameDay(date, today);\n const isWeekend = date.getDay() === 0 || date.getDay() === 6;\n\n const text = (\n isHighlight && highlightStyle === \"bracket\" ? `[${day}]` : String(day)\n ).padStart(cellWidth);\n\n let code: number | undefined;\n if (isHighlight && highlightStyle === \"reverse\") {\n code = palette.highlight ?? 7;\n } else if (isInRange && !isHighlight) {\n code = palette.range ?? 33;\n } else if (isToday && palette.today !== undefined) {\n code = palette.today;\n } else if (isWeekend && palette.weekend !== undefined) {\n code = palette.weekend;\n } else if (palette.day !== undefined) {\n code = palette.day;\n }\n\n return colorize(text, code, color);\n };\n\n const lines: string[] = [];\n\n if (frame === null) {\n // ── 枠なし(default) ──\n const totalWidth = cols * cellWidth + (cols - 1) * sep.length;\n lines.push(centerText(title, totalWidth));\n lines.push(\n weekdays\n .map((d) =>\n colorize(padStartWidth(d, cellWidth), palette.weekday, color),\n )\n .join(sep),\n );\n } else {\n // ── 枠あり(modern) ──\n lines.push(\n colorize(topBorder(frame, cellWidth, cols), palette.frame, color),\n );\n lines.push(\n colorize(\n `${frame.v}${centerTextFull(title, innerWidth(cellWidth, cols))}${frame.v}`,\n palette.title,\n color,\n ),\n );\n lines.push(\n colorize(separatorRow(frame, cellWidth, cols), palette.frame, color),\n );\n lines.push(\n colorize(\n `${frame.v}${weekdays.map((d) => padStartWidth(d, cellWidth)).join(frame.v)}${frame.v}`,\n palette.weekday,\n color,\n ),\n );\n lines.push(\n colorize(separatorRow(frame, cellWidth, cols), palette.frame, color),\n );\n }\n\n for (const row of grid) {\n if (row.every((d) => d === null)) continue;\n const cells = row.map(renderCell).join(sep);\n lines.push(frame === null ? cells : `${frame.v}${cells}${frame.v}`);\n }\n\n if (frame !== null) {\n lines.push(\n colorize(bottomBorder(frame, cellWidth, cols), palette.frame, color),\n );\n }\n\n return lines.join(\"\\n\");\n}\n","import { displayWidth } from \"./align.ts\";\nimport { stripAnsi } from \"./ansi.ts\";\nimport { renderMonth } from \"./month.ts\";\nimport type { RenderMonthOptions } from \"./types.ts\";\n\n/**\n * 年間カレンダーを4列×3行でテキストで返す\n *\n * 列幅・パディングは「ANSI 除去後のターミナル表示幅」で計算する。\n * 全角文字(日本語・韓国語・中国語の月名や曜日)も正しく揃う。\n */\nexport function renderYear(\n year: number,\n options: RenderMonthOptions = {},\n): string {\n const widthOf = (line: string): number => displayWidth(stripAnsi(line));\n\n const months = Array.from({ length: 12 }, (_, i) =>\n renderMonth(year, i + 1, options).split(\"\\n\"),\n );\n const maxLines = Math.max(...months.map((lines) => lines.length));\n const colWidths = months.map((lines) => Math.max(...lines.map(widthOf)));\n\n /** 月の各行をその列幅まで右パディングする(行が足りなければ空行として埋める) */\n const padMonth = (monthIdx: number): string[] =>\n Array.from({ length: maxLines }, (_, li) => {\n const line = months[monthIdx]![li] ?? \"\";\n return (\n line + \" \".repeat(Math.max(0, colWidths[monthIdx]! - widthOf(line)))\n );\n });\n\n const padded = months.map((_, mi) => padMonth(mi));\n\n const rows: string[] = [];\n for (let row = 0; row < 3; row++) {\n rows.push(\n Array.from({ length: maxLines }, (_, li) =>\n Array.from({ length: 4 }, (_, col) => {\n const monthIdx = row * 4 + col;\n return monthIdx < 12 ? padded[monthIdx]![li]! : \"\";\n }).join(\" \"),\n ).join(\"\\n\"),\n );\n }\n\n return rows.join(\"\\n\\n\");\n}\n","import { getMonthRange } from \"@typescript-calendar-lib/core\";\nimport { renderMonth, renderYear } from \"./render.ts\";\nimport type {\n CalendarOptions,\n CalendarRangeOptions,\n CalendarYearOptions,\n} from \"./types.ts\";\n\n/**\n * 月カレンダーをテキストで返す\n */\nexport function calendar(options: CalendarOptions): string {\n return renderMonth(options.year, options.month, options);\n}\n\n/**\n * 年間カレンダーを4列×3行でテキストで返す\n */\nexport function calendarYear(options: CalendarYearOptions): string {\n return renderYear(options.year, options);\n}\n\n/**\n * 任意の日付範囲のカレンダーをテキストで返す\n */\nexport function calendarRange(options: CalendarRangeOptions): string {\n const months = getMonthRange(options.from, options.to);\n return months\n .map(({ year, month }) => renderMonth(year, month, options))\n .join(\"\\n\\n\");\n}\n"],"mappings":";;;AAGA,MAAM,OACJ;;AAGF,SAAgB,aAAa,MAAsB;CACjD,IAAI,QAAQ;CACZ,KAAK,MAAM,MAAM,MACf,SAAS,KAAK,KAAK,EAAE,IAAI,IAAI;CAE/B,OAAO;AACT;;AAGA,SAAgB,cAAc,MAAc,OAAuB;CACjE,OAAO,IAAI,OAAO,KAAK,IAAI,GAAG,QAAQ,aAAa,IAAI,CAAC,CAAC,IAAI;AAC/D;;AAGA,SAAgB,WAAW,MAAc,OAAuB;CAC9D,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,OAAO,QAAQ,aAAa,IAAI,KAAK,CAAC,CAA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AM,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,OAAO;EAC1C,MAAM,OAAO,OAAO,SAAS,CAAE,OAAO;EACtC,OACE,OAAO,IAAI,OAAO,KAAK,IAAI,GAAG,UAAU,YAAa,QAAQ,IAAI,CAAC,CAAC;CAEvE,CAAC;CAEH,MAAM,SAAS,OAAO,KAAK,GAAG,OAAO,SAAS,EAAE,CAAC;CAEjD,MAAM,OAAiB,CAAC;CACxB,KAAK,IAAI,MAAM,GAAG,MAAM,GAAG,OACzB,KAAK,KACH,MAAM,KAAK,EAAE,QAAQ,SAAS,IAAI,GAAG,OACnC,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,QAAQ;EACpC,MAAM,WAAW,MAAM,IAAI;EAC3B,OAAO,WAAW,KAAK,OAAO,SAAS,CAAE,MAAO;CAClD,CAAC,CAAC,CAAC,KAAK,MAAM,CAChB,CAAC,CAAC,KAAK,IAAI,CACb;CAGF,OAAO,KAAK,KAAK,MAAM;AACzB;;;;;;ACpCA,SAAgB,SAAS,SAAkC;CACzD,OAAO,YAAY,QAAQ,MAAM,QAAQ,OAAO,OAAO;AACzD;;;;AAKA,SAAgB,aAAa,SAAsC;CACjE,OAAO,WAAW,QAAQ,MAAM,OAAO;AACzC;;;;AAKA,SAAgB,cAAc,SAAuC;CAEnE,OADe,cAAc,QAAQ,MAAM,QAAQ,EACvC,CAAC,CACV,KAAK,EAAE,MAAM,YAAY,YAAY,MAAM,OAAO,OAAO,CAAC,CAAC,CAC3D,KAAK,MAAM;AAChB"}
@@ -0,0 +1,33 @@
1
+ import { a as FrameChars, c as resolveColorScheme, i as ColorSchemeName, l as resolveTheme, n as CliPalette, o as THEMES, r as CliTheme, s as ThemeName, t as COLOR_SCHEMES } from "./theme-BMYtCxK2.js";
2
+ import { CalendarOptions as CalendarOptions$1, CalendarRangeOptions as CalendarRangeOptions$1, CalendarYearOptions as CalendarYearOptions$1, RenderMonthOptions as RenderMonthOptions$1 } from "@typescript-calendar-lib/core";
3
+ //#region src/types.d.ts
4
+ /** CLI 固有のオプション(core のオプションに追加で受け付ける) */
5
+ interface CliExtraOptions {
6
+ /** 見た目テーマ。既定は "default" */
7
+ theme?: ThemeName | CliTheme;
8
+ /** カラースキーム。color: true のとき有効。既定は "default" */
9
+ colorScheme?: ColorSchemeName | CliPalette;
10
+ /** 今日の基準日。カラースキームの today 着色に使用 */
11
+ today?: Date;
12
+ }
13
+ type CalendarOptions = CalendarOptions$1 & CliExtraOptions;
14
+ type CalendarYearOptions = CalendarYearOptions$1 & CliExtraOptions;
15
+ type CalendarRangeOptions = CalendarRangeOptions$1 & CliExtraOptions;
16
+ type RenderMonthOptions = RenderMonthOptions$1 & CliExtraOptions;
17
+ //#endregion
18
+ //#region src/calendar.d.ts
19
+ /**
20
+ * 月カレンダーをテキストで返す
21
+ */
22
+ export declare function calendar(options: CalendarOptions): string;
23
+ /**
24
+ * 年間カレンダーを4列×3行でテキストで返す
25
+ */
26
+ export declare function calendarYear(options: CalendarYearOptions): string;
27
+ /**
28
+ * 任意の日付範囲のカレンダーをテキストで返す
29
+ */
30
+ export declare function calendarRange(options: CalendarRangeOptions): string;
31
+ //#endregion
32
+ export { COLOR_SCHEMES, type CalendarOptions, type CalendarRangeOptions, type CalendarYearOptions, type CliPalette, type CliTheme, type ColorSchemeName, type FrameChars, type RenderMonthOptions, THEMES, type ThemeName, resolveColorScheme, resolveTheme };
33
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { a as THEMES, i as COLOR_SCHEMES, n as calendarRange, o as resolveColorScheme, r as calendarYear, s as resolveTheme, t as calendar } from "./calendar-DNDADt5T.js";
2
+ export { COLOR_SCHEMES, THEMES, calendar, calendarRange, calendarYear, resolveColorScheme, resolveTheme };
@@ -0,0 +1,53 @@
1
+ //#region src/theme.d.ts
2
+ /** 組み込みテーマ名。カスタムテーマは CliTheme オブジェクトを直接渡せる */
3
+ type ThemeName = "default" | "modern";
4
+ /** 枠線の文字セット(modern テーマで使用) */
5
+ interface FrameChars {
6
+ topLeft: string;
7
+ topRight: string;
8
+ bottomLeft: string;
9
+ bottomRight: string;
10
+ /** 水平線 */
11
+ h: string;
12
+ /** 垂直線 */
13
+ v: string;
14
+ /** ヘッダー/本文の区切り行で使う交差(┬ や ┼) */
15
+ j: string;
16
+ /** 下端区切りで使う交差(┴) */
17
+ footJ: string;
18
+ }
19
+ /** 文字ベースの見た目定義 */
20
+ interface CliTheme {
21
+ /** セル幅(日付表記の文字幅) */
22
+ cellWidth: number;
23
+ /** セル間の区切り文字(default: " " / modern: "│") */
24
+ separator: string;
25
+ /** 枠線文字。null なら枠なし */
26
+ frame: FrameChars | null;
27
+ }
28
+ declare const THEMES: Record<ThemeName, CliTheme>;
29
+ declare function resolveTheme(theme?: ThemeName | CliTheme): CliTheme;
30
+ /** 組み込みカラースキーム名。カスタムは CliPalette を直接渡せる */
31
+ type ColorSchemeName = "default" | "ocean" | "forest" | "sunset" | "mono";
32
+ /**
33
+ * ANSIカラーパレット。
34
+ * 各フィールドは前景色(またはハイライト時の背景)のANSIコード。
35
+ * undefined はその要素を着色しない。
36
+ */
37
+ interface CliPalette {
38
+ title?: number;
39
+ weekday?: number;
40
+ day?: number;
41
+ weekend?: number;
42
+ today?: number;
43
+ /** highlightStyle: "reverse" のときに使うコード(default は 7 = 反転) */
44
+ highlight?: number;
45
+ range?: number;
46
+ frame?: number;
47
+ dim?: number;
48
+ }
49
+ declare const COLOR_SCHEMES: Record<ColorSchemeName, CliPalette>;
50
+ declare function resolveColorScheme(scheme?: ColorSchemeName | CliPalette): CliPalette;
51
+ //#endregion
52
+ export { FrameChars as a, resolveColorScheme as c, ColorSchemeName as i, resolveTheme as l, CliPalette as n, THEMES as o, CliTheme as r, ThemeName as s, COLOR_SCHEMES as t };
53
+ //# sourceMappingURL=theme-BMYtCxK2.d.ts.map
package/package.json CHANGED
@@ -1,25 +1,33 @@
1
1
  {
2
2
  "name": "@typescript-calendar-lib/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "bin": {
6
- "typescript-calendar-lib": "src/bin.ts"
6
+ "typescript-calendar-lib": "./dist/bin.js"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/nazozokc/typescript-calendar-lib"
11
11
  },
12
- "main": "src/index.ts",
13
- "types": "src/index.ts",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "development": "./src/index.ts",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
14
21
  "files": [
15
- "src",
16
- "!src/*.test.ts"
22
+ "dist"
17
23
  ],
18
24
  "dependencies": {
19
- "@typescript-calendar-lib/core": "0.2.2",
20
- "cli-table3": "^0.6.5"
25
+ "@typescript-calendar-lib/core": "0.2.6"
21
26
  },
22
27
  "peerDependencies": {
23
28
  "typescript": "^5"
29
+ },
30
+ "scripts": {
31
+ "build": "tsdown"
24
32
  }
25
33
  }