saju8z 0.0.0-stage → 1.0.0

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +194 -2
  3. package/THIRD-PARTY-LICENSES.txt +24 -0
  4. package/dist/core.cjs +1844 -0
  5. package/dist/core.js +1822 -0
  6. package/dist/format.cjs +128 -0
  7. package/dist/format.js +106 -0
  8. package/dist/index.cjs +1854 -0
  9. package/dist/index.js +1832 -0
  10. package/dist/lunar.cjs +1440 -0
  11. package/dist/lunar.js +1418 -0
  12. package/dist/types/application/calculateSajuChart.d.ts +2 -0
  13. package/dist/types/calendar/dateMath.d.ts +8 -0
  14. package/dist/types/calendar/lunar.d.ts +7 -0
  15. package/dist/types/calendar/solarTerms.d.ts +4 -0
  16. package/dist/types/calendar/solarTimeCorrection.d.ts +2 -0
  17. package/dist/types/config/constants.d.ts +4 -0
  18. package/dist/types/config/saju8z.d.ts +3 -0
  19. package/dist/types/contracts/sajuChart.d.ts +16 -0
  20. package/dist/types/core.d.ts +19 -0
  21. package/dist/types/domain/branches.d.ts +4 -0
  22. package/dist/types/domain/hanja.d.ts +9 -0
  23. package/dist/types/domain/sexagenaryCycle.d.ts +7 -0
  24. package/dist/types/domain/stems.d.ts +4 -0
  25. package/dist/types/domain/types.d.ts +50 -0
  26. package/dist/types/format.d.ts +2 -0
  27. package/dist/types/index.d.ts +4 -0
  28. package/dist/types/input/errors.d.ts +2 -0
  29. package/dist/types/lunar.d.ts +1 -0
  30. package/dist/types/output/formatSajuChart.d.ts +3 -0
  31. package/dist/types/saju/calculateDayPillar.d.ts +2 -0
  32. package/dist/types/saju/calculateHourPillar.d.ts +3 -0
  33. package/dist/types/saju/calculateMonthPillar.d.ts +3 -0
  34. package/dist/types/saju/calculateTenGod.d.ts +2 -0
  35. package/dist/types/saju/calculateTenGods.d.ts +2 -0
  36. package/dist/types/saju/calculateYearPillar.d.ts +2 -0
  37. package/dist/types/saju/fourPillars.d.ts +2 -0
  38. package/dist/types-cjs/application/calculateSajuChart.d.ts +2 -0
  39. package/dist/types-cjs/calendar/dateMath.d.ts +8 -0
  40. package/dist/types-cjs/calendar/lunar.d.ts +7 -0
  41. package/dist/types-cjs/calendar/solarTerms.d.ts +4 -0
  42. package/dist/types-cjs/calendar/solarTimeCorrection.d.ts +2 -0
  43. package/dist/types-cjs/config/constants.d.ts +4 -0
  44. package/dist/types-cjs/config/saju8z.d.ts +3 -0
  45. package/dist/types-cjs/contracts/sajuChart.d.ts +16 -0
  46. package/dist/types-cjs/core.d.ts +19 -0
  47. package/dist/types-cjs/domain/branches.d.ts +4 -0
  48. package/dist/types-cjs/domain/hanja.d.ts +9 -0
  49. package/dist/types-cjs/domain/sexagenaryCycle.d.ts +7 -0
  50. package/dist/types-cjs/domain/stems.d.ts +4 -0
  51. package/dist/types-cjs/domain/types.d.ts +50 -0
  52. package/dist/types-cjs/format.d.ts +2 -0
  53. package/dist/types-cjs/index.d.ts +4 -0
  54. package/dist/types-cjs/input/errors.d.ts +2 -0
  55. package/dist/types-cjs/lunar.d.ts +1 -0
  56. package/dist/types-cjs/output/formatSajuChart.d.ts +3 -0
  57. package/dist/types-cjs/package.json +1 -0
  58. package/dist/types-cjs/saju/calculateDayPillar.d.ts +2 -0
  59. package/dist/types-cjs/saju/calculateHourPillar.d.ts +3 -0
  60. package/dist/types-cjs/saju/calculateMonthPillar.d.ts +3 -0
  61. package/dist/types-cjs/saju/calculateTenGod.d.ts +2 -0
  62. package/dist/types-cjs/saju/calculateTenGods.d.ts +2 -0
  63. package/dist/types-cjs/saju/calculateYearPillar.d.ts +2 -0
  64. package/dist/types-cjs/saju/fourPillars.d.ts +2 -0
  65. package/package.json +92 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 frogred8
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,195 @@
1
- # Temporary Holding Version
1
+ # saju8z
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 브라우저와 Node.js에서 생년월일시를 사주팔자로 변환하는 오프라인 만세력 계산 라이브러리입니다. 양력·한국 음력·윤달을 지원하며, 사주팔자와 십성 계산 결과를 객체·텍스트·JSON으로 사용할 수 있습니다.
4
+
5
+ - TypeScript 타입 선언과 ESM·CommonJS 빌드 제공
6
+ - 네트워크·API 키·데이터베이스 없이 실행
7
+ - 현재 시각과 실행 환경의 시간대에 의존하지 않는 계산
8
+ - 음력 변환 의존성을 번들에 포함하여 별도 런타임 의존성 설치 불필요
9
+
10
+ Node.js에서는 22 이상을 사용합니다. 브라우저에서는 ES2022를 지원하는 환경과 ESM 번들러를 사용할 수 있습니다.
11
+
12
+ ## 설치
13
+
14
+ 사용할 프로젝트에서 npm 패키지를 설치합니다.
15
+
16
+ ```sh
17
+ npm install saju8z
18
+ ```
19
+
20
+ 설치 후 `saju8z`에서 함수를 가져와 바로 사용할 수 있습니다. 패키지 사용을 위해 이 저장소를 내려받거나 직접 빌드할 필요는 없습니다.
21
+
22
+ ## 빠른 시작
23
+
24
+ Node.js ESM, TypeScript, 브라우저 번들러 환경에서 동일하게 사용합니다.
25
+
26
+ ```js
27
+ import { calculateSajuChart, formatSajuChart } from "saju8z";
28
+
29
+ const result = calculateSajuChart({
30
+ date: "2000-02-29",
31
+ time: "00:10",
32
+ gmt: "+09:00"
33
+ });
34
+
35
+ console.log(result.fourPillars); // 사주팔자 객체
36
+ console.log(result.tenGods); // 십성 객체
37
+ console.log(formatSajuChart(result, "text")); // Markdown 표 문자열
38
+ console.log(formatSajuChart(result, "json")); // JSON 문자열
39
+ ```
40
+
41
+ CommonJS에서는 `require`로 가져옵니다.
42
+
43
+ ```js
44
+ const { calculateSajuChart, formatSajuChart } = require("saju8z");
45
+
46
+ const result = calculateSajuChart({
47
+ date: "2000-02-29",
48
+ time: "00:10",
49
+ gmt: "+09:00"
50
+ });
51
+ console.log(formatSajuChart(result));
52
+ ```
53
+
54
+ ## 입력
55
+
56
+ `calculateSajuChart(input)`은 다음 객체를 받습니다.
57
+
58
+ | 필드 | 타입 | 필수 | 설명 |
59
+ | ----------- | --------- | -------- | ------------------------------------------------------ | ------------------------------------- |
60
+ | `date` | `string` | 예 | `YYYY-MM-DD`. 선택한 달력 기준의 날짜 |
61
+ | `time` | `string` | 예 | `HH:mm`, `00:00`\~`23:59`. 초는 지원하지 않음 |
62
+ | `gmt` | `string` | 예 | 부호를 포함한 고정 시차 `±HH:mm`, `-12:00`\~`+14:00` |
63
+ | `calendar` | `"solar" | "lunar"` | 아니요 | 양력 또는 한국 음력. 기본값 `"solar"` |
64
+ | `leapMonth` | `boolean` | 아니요 | 음력 윤달 여부. 기본값 `false`, 음력에서만 `true` 허용 |
65
+
66
+ GMT는 출생 당시 날짜·시간의 시차를 직접 지정합니다. 예를 들어 한국 표준시는 `+09:00`, UTC는 `+00:00`입니다. 실행 환경의 시간대나 지역 이름으로 자동 추정하지 않습니다.
67
+
68
+ 음력 윤달은 다음과 같이 입력합니다.
69
+
70
+ ```js
71
+ const result = calculateSajuChart({
72
+ date: "2017-05-01",
73
+ time: "12:00",
74
+ gmt: "+09:00",
75
+ calendar: "lunar",
76
+ leapMonth: true
77
+ });
78
+ // 양력 2017-06-24 12:00, GMT+09:00 입력과 같은 결과
79
+ ```
80
+
81
+ ## 결과와 출력 형식
82
+
83
+ `calculateSajuChart`는 JSON으로 직렬화 가능한 `SajuChartResult` 객체를 반환합니다.
84
+
85
+ | 필드 | 내용 |
86
+ | --------------------- | ----------------------------------------------------------------------------------------------------------- |
87
+ | `normalizedDateTime` | 양력으로 변환하고 GMT+09:00으로 환산한 `{ year, month, day, hour, minute }` |
88
+ | `calculationDateTime` | 환산 시각에 -30분 보정을 적용한 계산 시각 |
89
+ | `fourPillars` | `year`, `month`, `day`, `hour`의 사주팔자. 각 값은 `{ stem, branch }` |
90
+ | `tenGods` | 일간 기준 십성. `yearStem`, `yearBranch`, `monthStem`, `monthBranch`, `dayBranch`, `hourStem`, `hourBranch` |
91
+ | `calculationProfile` | 계산 규칙 식별자. 현재 `saju8z-fixed-gmt-kst-minus30-v1` |
92
+
93
+ 천간·지지·십성은 `"병"`, `"진"`, `"식신"`과 같은 한국어 문자열입니다. 일간 자체의 십성 필드는 없으며, 텍스트 표에서는 `본원`으로 표시합니다.
94
+
95
+ ### 텍스트
96
+
97
+ `formatSajuChart(result)` 또는 `formatSajuChart(result, "text")`는 시주·일주·월주·년주 순서의 Markdown 표를 반환합니다. 천간·지지의 한자, 오행, 십성을 포함합니다. 빠른 시작 예제의 출력은 다음과 같습니다.
98
+
99
+ ```text
100
+ | 구분 | 시주 | 일주 | 월주 | 년주 |
101
+ | --- | --- | --- | --- | --- |
102
+ | 천간 | 무(戊) | 병(丙) | 무(戊) | 경(庚) |
103
+ | 천간 오행 | 土 | 火 | 土 | 金 |
104
+ | 천간 십성 | 식신 | 본원 | 식신 | 편재 |
105
+ | 지지 | 자(子) | 진(辰) | 인(寅) | 진(辰) |
106
+ | 지지 오행 | 水 | 土 | 木 | 土 |
107
+ | 지지 십성 | 정관 | 식신 | 편인 | 식신 |
108
+ ```
109
+
110
+ ### JSON
111
+
112
+ `formatSajuChart(result, "json")`은 결과 객체 전체를 들여쓰기한 JSON 문자열로 반환합니다. 저장하거나 전송할 때 사용합니다. 객체가 필요하면 `calculateSajuChart`의 반환값을 바로 사용하면 됩니다.
113
+
114
+ ```js
115
+ const json = formatSajuChart(result, "json");
116
+ const restored = JSON.parse(json);
117
+ console.log(restored.fourPillars.day); // { stem: "병", branch: "진" }
118
+ ```
119
+
120
+ ## TypeScript와 오류 처리
121
+
122
+ 주 진입점은 계산·출력 함수, 오류 클래스와 세 가지 타입을 제공합니다.
123
+
124
+ ```ts
125
+ import { calculateSajuChart, formatSajuChart, UserInputError } from "saju8z";
126
+ import type { SajuChartInput, SajuChartResult, SajuChartFormat } from "saju8z";
127
+
128
+ const input: SajuChartInput = {
129
+ date: "2000-02-29",
130
+ time: "00:10",
131
+ gmt: "+09:00"
132
+ };
133
+ const format: SajuChartFormat = "json";
134
+
135
+ try {
136
+ const result: SajuChartResult = calculateSajuChart(input);
137
+ console.log(formatSajuChart(result, format));
138
+ } catch (error) {
139
+ if (error instanceof UserInputError) {
140
+ console.error(error.message);
141
+ } else {
142
+ throw error;
143
+ }
144
+ }
145
+ ```
146
+
147
+ 잘못된 날짜·시각·GMT, 지원 범위 밖 날짜, 존재하지 않는 윤달은 `UserInputError`를 발생시킵니다. 출력 형식은 `"text"`와 `"json"`만 허용합니다.
148
+
149
+ ## 추가 진입점
150
+
151
+ | 가져오기 경로 | 용도 |
152
+ | --------------- | ------------------------------------------------------------------------ |
153
+ | `saju8z` | `calculateSajuChart`, `formatSajuChart`, `UserInputError` 및 입출력 타입 |
154
+ | `saju8z/core` | 저수준 계산 함수, 상수, 간지·오행 데이터와 도메인 타입 |
155
+ | `saju8z/lunar` | `lunarToSolar`, `lunarMonthDays`, `hasLunarLeapMonth` |
156
+ | `saju8z/format` | `formatSajuChart`, `SajuChartFormat`, `SajuChartResult` 타입 |
157
+
158
+ 일반적인 만세력 계산에는 `saju8z`를 사용합니다. 저수준 함수는 입력 검증과 보정 적용 방식을 호출자가 확인해야 합니다.
159
+
160
+ ## 계산 기준과 지원 범위
161
+
162
+ 1. 음력이면 양력으로 변환합니다.
163
+ 2. 입력 GMT에서 GMT+09:00으로 환산합니다.
164
+ 3. -30분을 보정한 시각으로 사주팔자를 계산합니다.
165
+
166
+ 년주는 입춘, 월주는 프로젝트의 고정 절입 시각 표, 일주는 자정을 기준으로 합니다. 고정 절입 표는 실제 연도별 천문 절기 시각과 차이가 있을 수 있습니다. 서머타임·역사적 시차·출생지 경도 보정은 자동 적용하지 않습니다.
167
+
168
+ 양력 입력과 GMT+09:00 환산 날짜는 1900~2100년을 지원합니다. 음력은 1900년부터 음력 2050년 11월 18일까지의 유효 날짜를 지원합니다. -30분 보정으로 1900년 첫날이 전년 말로 이동할 수 있습니다.
169
+
170
+ 성별 입력은 필요하지 않습니다. 대운·세운·운세·성격 해석 기능은 제공하지 않습니다.
171
+
172
+ ## 소스 개발과 패키지 검증
173
+
174
+ 라이브러리 자체를 수정하는 경우 저장소를 내려받은 뒤 아래 명령을 사용합니다.
175
+
176
+ ```sh
177
+ npm ci
178
+ npm run build # ESM·CommonJS 번들과 타입 선언 생성
179
+ npm test # 빌드 후 계산·출력 테스트
180
+ npm run lint
181
+ npm run typecheck
182
+ npm pack --dry-run # 배포 파일 목록 확인
183
+ npm run test:package # tarball 설치 후 ESM/CJS·타입·브라우저·시간대 검증
184
+ npm pack # saju8z-1.0.0.tgz 생성
185
+ ```
186
+
187
+ 계산 원본은 `src/`, 테스트는 `test/`, 빌드·패키지 검증 스크립트는 `scripts/`에 있습니다. JavaScript 스크립트는 `package.json`의 `"type": "module"` 설정에 따라 ES 모듈로 실행합니다. `dist/`는 빌드 산출물이며 npm 패키지에는 실행 번들·타입 선언·README·LICENSE·제3자 고지를 포함합니다.
188
+
189
+ ## 라이선스
190
+
191
+ 이 프로젝트는 [MIT 라이선스](LICENSE)로 배포합니다. Copyright (c) 2026 frogred8.
192
+
193
+ 상업적 사용·수정·재배포를 허용하며, 소프트웨어의 복사본이나 주요 부분에 저작권 및 라이선스 고지를 유지해야 합니다. 소프트웨어는 보증 없이 제공됩니다. 정확한 조건은 LICENSE 전문을 참고하세요.
194
+
195
+ 번들에 포함된 `korean-lunar-calendar`의 원 저작권 및 MIT 라이선스 고지는 [THIRD-PARTY-LICENSES.txt](THIRD-PARTY-LICENSES.txt)에 별도로 보존합니다.
@@ -0,0 +1,24 @@
1
+ korean-lunar-calendar 0.4.0
2
+ https://github.com/usingsky/korean_lunar_calendar_js
3
+
4
+ MIT License
5
+
6
+ Copyright (c) 2022 Jinil Lee
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.