@typescript-calendar-lib/cli 0.2.5 → 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 -25
- package/src/bin.ts +0 -209
- package/src/border.ts +0 -55
- package/src/calendar.ts +0 -31
- package/src/index.ts +0 -24
- package/src/month.ts +0 -144
- package/src/render.ts +0 -5
- package/src/theme.ts +0 -146
- package/src/types.ts +0 -27
- package/src/year.ts +0 -48
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,48 +0,0 @@
|
|
|
1
|
-
import { displayWidth } from "./align.ts";
|
|
2
|
-
import { stripAnsi } from "./ansi.ts";
|
|
3
|
-
import { renderMonth } from "./month.ts";
|
|
4
|
-
import type { RenderMonthOptions } from "./types.ts";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 年間カレンダーを4列×3行でテキストで返す
|
|
8
|
-
*
|
|
9
|
-
* 列幅・パディングは「ANSI 除去後のターミナル表示幅」で計算する。
|
|
10
|
-
* 全角文字(日本語・韓国語・中国語の月名や曜日)も正しく揃う。
|
|
11
|
-
*/
|
|
12
|
-
export function renderYear(
|
|
13
|
-
year: number,
|
|
14
|
-
options: RenderMonthOptions = {},
|
|
15
|
-
): string {
|
|
16
|
-
const widthOf = (line: string): number => displayWidth(stripAnsi(line));
|
|
17
|
-
|
|
18
|
-
const months = Array.from({ length: 12 }, (_, i) =>
|
|
19
|
-
renderMonth(year, i + 1, options).split("\n"),
|
|
20
|
-
);
|
|
21
|
-
const maxLines = Math.max(...months.map((lines) => lines.length));
|
|
22
|
-
const colWidths = months.map((lines) => Math.max(...lines.map(widthOf)));
|
|
23
|
-
|
|
24
|
-
/** 月の各行をその列幅まで右パディングする(行が足りなければ空行として埋める) */
|
|
25
|
-
const padMonth = (monthIdx: number): string[] =>
|
|
26
|
-
Array.from({ length: maxLines }, (_, li) => {
|
|
27
|
-
const line = months[monthIdx]![li] ?? "";
|
|
28
|
-
return (
|
|
29
|
-
line + " ".repeat(Math.max(0, colWidths[monthIdx]! - widthOf(line)))
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const padded = months.map((_, mi) => padMonth(mi));
|
|
34
|
-
|
|
35
|
-
const rows: string[] = [];
|
|
36
|
-
for (let row = 0; row < 3; row++) {
|
|
37
|
-
rows.push(
|
|
38
|
-
Array.from({ length: maxLines }, (_, li) =>
|
|
39
|
-
Array.from({ length: 4 }, (_, col) => {
|
|
40
|
-
const monthIdx = row * 4 + col;
|
|
41
|
-
return monthIdx < 12 ? padded[monthIdx]![li]! : "";
|
|
42
|
-
}).join(" "),
|
|
43
|
-
).join("\n"),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return rows.join("\n\n");
|
|
48
|
-
}
|