lichta 1.0.1 → 2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zeforc Labs
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,251 +1,48 @@
1
- # 🌙 LichTa
1
+ # lichta (legacy)
2
2
 
3
- **Vietnamese Solar ↔ Lunar Calendar conversion library for JavaScript/TypeScript.**
3
+ [![npm version](https://img.shields.io/npm/v/lichta.svg)](https://www.npmjs.com/package/lichta)
4
4
 
5
- Supports ready-to-use Svelte 5 components, while exporting a pure TypeScript core for React, Vue, Angular, and vanilla JS.
5
+ > ⚠️ **Package này đã deprecated.** Đây tên npm của thư viện trước khi đổi sang các package có scope `@lichta/*`. Đừng cài package này cho dự án mới — xem bảng bên dưới để chọn đúng package thay thế.
6
6
 
7
- [![npm version](https://img.shields.io/npm/v/lichta)](https://www.npmjs.com/package/lichta)
8
- [![license](https://img.shields.io/npm/l/lichta)](https://github.com/zeforc/lichta/blob/main/LICENSE)
7
+ ## Vì sao package này vẫn tồn tại
9
8
 
10
- 🚀 **[Live Demo](https://lich-ta.vercel.app/)**
9
+ Trước đây toàn bộ thư viện được publish dưới 1 package tên `lichta` duy nhất. Từ khi tách thành monorepo với các package scoped (`@lichta/core`, `@lichta/react`, `@lichta/vue`, `@lichta/svelte`, `@lichta/full-calendar`, `@lichta/event-calendar`, `@lichta/react-big-calendar`), package `lichta` được giữ lại làm cầu nối tương thích ngược cho những dự án đang cài `lichta` từ trước, tránh vỡ code đột ngột khi họ chạy `npm update`.
11
10
 
12
- > 🇻🇳 [Phiên bản Tiếng Việt (Vietnamese version)](./README.vi.md)
11
+ ## Trạng thái hiện tại
13
12
 
14
- ---
13
+ **Package này hiện chỉ re-export `@lichta/svelte`:**
15
14
 
16
- ## ✨ Features
17
-
18
- - 🔄 **Solar Lunar Conversion** Ho Ngoc Duc algorithm (range 1800–2199)
19
- - 🐉 **Sexagenary Cycle (Can Chi)** — Calculate Can Chi for year, month, day, and hour
20
- - 🔮 **Five Elements (Ngũ Hành)** — Calculate destiny element based on birth year
21
- - ⏰ **Auspicious Hours (Giờ Hoàng Đạo)** — 6 auspicious hours in a day
22
- - 📅 **Calendar Component** — Svelte 5 monthly calendar with lunar dates
23
- - 🎨 **Format** — Display traditional lunar dates (Mùng Một tháng Giêng...)
24
- - 🌐 **i18n** — Vietnamese–English–Japanese–Korean support (vi, en, ja, ko)
25
- - 📦 **Multi-framework** — Svelte 5, React, Vue, Angular, vanilla JS
26
-
27
- ---
28
-
29
- ## 📦 Installation
30
-
31
- ```bash
32
- npm install lichta
33
- ```
34
-
35
- ---
36
-
37
- ## 🚀 Usage
38
-
39
- ### Core Logic (Any framework)
40
-
41
- Import from `lichta/core` to use **pure TypeScript** — no Svelte dependency:
42
-
43
- ```typescript
44
- import { LichTa, getYearDetails } from 'lichta/core';
45
-
46
- // Solar → Lunar
47
- const lunar = LichTa.toLunar(10, 2, 2024);
48
- // → {
49
- // day: 1, month: 1, year: 2024,
50
- // isLeap: false,
51
- // yearCanChi: 'Giáp Thìn',
52
- // monthCanChi: 'Bính Dần',
53
- // dayCanChi: '...',
54
- // jd: 2460350
55
- // }
56
-
57
- // Lunar → Solar
58
- const solar = LichTa.toSolar(1, 1, 2024, false);
59
- // → { day: 10, month: 2, year: 2024 }
60
-
61
- // Custom timezone (default is GMT+7)
62
- const lunarChina = LichTa.toLunar(10, 2, 2024, 8); // GMT+8
63
- ```
64
-
65
- ### Sexagenary Cycle & Feng Shui (Can Chi & Phong Thủy)
66
-
67
- ```typescript
68
- import {
69
- getYearDetails,
70
- getDayCanChi,
71
- getMonthCanChi,
72
- getHourCanChi,
73
- getAuspiciousHours
74
- } from 'lichta/core';
75
-
76
- // Can Chi + Element for the year
77
- getYearDetails(2024);
78
- // → { can: 'Giáp', chi: 'Thìn', menh: 'Hỏa',
79
- // fullString: 'Giáp Thìn - Mệnh Hỏa' }
80
-
81
- // Day Can Chi (requires Julian Day Number)
82
- const lunar = LichTa.toLunar(10, 2, 2024);
83
- getDayCanChi(lunar.jd); // → 'Giáp Tý'
84
-
85
- // Month Can Chi
86
- getMonthCanChi(1, 2024); // → month Giêng year Giáp Thìn
87
-
88
- // Hour Can Chi
89
- getHourCanChi(8, lunar.jd); // → hour Thìn (7h-9h)
90
-
91
- // Auspicious Hours
92
- getAuspiciousHours(lunar.jd);
93
- // → ['Tý', 'Sửu', 'Mão', 'Ngọ', 'Mùi', 'Dậu']
94
- ```
95
-
96
- ### Format & Display
97
-
98
- ```typescript
99
- import { formatTraditional, formatLunarDate, getMonthName, getDayName } from 'lichta/utils';
100
-
101
- const lunar = LichTa.toLunar(10, 2, 2024);
102
-
103
- // Traditional format
104
- formatTraditional(lunar);
105
- // → 'Mùng Một tháng Giêng năm Giáp Thìn'
106
-
107
- // Pattern format
108
- formatLunarDate(lunar, 'dd/MM/yyyy'); // → '01/01/2024'
109
- formatLunarDate(lunar, 'CC'); // → 'Giáp Thìn'
110
- formatLunarDate(lunar, 'Ngày DC'); // → 'Ngày Giáp Tý'
111
-
112
- // Traditional names
113
- getMonthName(1); // → 'Giêng'
114
- getMonthName(12); // → 'Chạp'
115
- getDayName(1); // → 'Mùng Một'
116
- getDayName(15); // → 'Rằm'
117
- getDayName(30); // → 'Ba Mươi'
118
- ```
119
-
120
- **Format tokens:**
121
-
122
- | Token | Description | Example |
123
- | ------ | --------------------- | --------- |
124
- | `dd` | 2-digit day | 01, 15 |
125
- | `d` | Day | 1, 15 |
126
- | `MM` | 2-digit month | 01, 12 |
127
- | `M` | Month | 1, 12 |
128
- | `yyyy` | 4-digit year | 2024 |
129
- | `yy` | Last 2 digits of year | 24 |
130
- | `CC` | Year Can Chi | Giáp Thìn |
131
- | `DC` | Day Can Chi | Giáp Tý |
132
- | `MC` | Month Can Chi | Bính Dần |
133
- | `L` | "Nhuận" if leap month | Nhuận |
134
-
135
- ### Svelte 5 Components
136
-
137
- ```svelte
138
- <script>
139
- import { Calendar, Formatter } from 'lichta';
140
- </script>
141
-
142
- <!-- Full monthly calendar -->
143
- <Calendar showLunar={true} locale="vi" onSelect={(date, lunar) => console.log(date, lunar)} />
144
-
145
- <!-- Lunar date formatter -->
146
- <Formatter date={new Date()} />
15
+ ```javascript
16
+ // index.js
17
+ console.warn("[lichta] WARNING: The 'lichta' package is deprecated for Svelte components. ...");
18
+ export * from '@lichta/svelte';
147
19
  ```
148
20
 
149
- #### Calendar Props
21
+ Nghĩa là:
22
+ - Nếu bạn đang dùng Svelte, `import { ... } from 'lichta'` vẫn hoạt động (thực chất là `@lichta/svelte`), nhưng sẽ in cảnh báo deprecation ra console.
23
+ - Nếu bạn dùng React, Vue, hoặc chỉ cần logic tính toán thuần (vanilla JS/TS) — package này **không có đường dẫn tương thích cho bạn**, vì nó chỉ trỏ tới `@lichta/svelte`. Cài `lichta` trong trường hợp này sẽ kéo theo `svelte` như một dependency dù bạn không dùng Svelte.
150
24
 
151
- | Prop | Type | Default | Description |
152
- | -------------- | ---------------------------------------- | ------------- | --------------------------- |
153
- | `month` | `number` | Current month | Displayed month (1-12) |
154
- | `year` | `number` | Current year | Displayed year |
155
- | `selectedDate` | `Date \| null` | `null` | Selected date |
156
- | `onSelect` | `(date: Date, lunar: LunarDate) => void` | — | Callback on date select |
157
- | `showLunar` | `boolean` | `true` | Show lunar dates |
158
- | `locale` | `'vi' \| 'en' \| 'ja' \| 'ko'` | `'vi'` | Language |
159
- | `dayCell` | `Snippet` | — | Custom snippet for day cell |
25
+ ## Nên làm
160
26
 
161
- #### Theming
27
+ Đừng cài `lichta`. Cài thẳng package phù hợp:
162
28
 
163
- The Calendar supports CSS custom properties:
164
-
165
- ```css
166
- :root {
167
- --lichta-primary: #d4a373;
168
- --lichta-bg: #fffcf7;
169
- --lichta-text: #2c1810;
170
- --lichta-today-bg: #d4a373;
171
- --lichta-selected-bg: #a0522d;
172
- --lichta-lunar-text: #b08968;
173
- --lichta-radius: 8px;
174
- --lichta-font: 'Inter', sans-serif;
175
- }
176
- ```
29
+ | Bạn dùng | Cài package |
30
+ |---|---|
31
+ | Chỉ cần logic tính toán (vanilla JS/TS, Node.js) | [`@lichta/core`](https://www.npmjs.com/package/@lichta/core) |
32
+ | React | [`@lichta/react`](https://www.npmjs.com/package/@lichta/react) |
33
+ | Vue | [`@lichta/vue`](https://www.npmjs.com/package/@lichta/vue) |
34
+ | Svelte 5 | [`@lichta/svelte`](https://www.npmjs.com/package/@lichta/svelte) |
35
+ | FullCalendar | [`@lichta/full-calendar`](https://www.npmjs.com/package/@lichta/full-calendar) |
36
+ | EventCalendar | [`@lichta/event-calendar`](https://www.npmjs.com/package/@lichta/event-calendar) |
37
+ | React Big Calendar | [`@lichta/react-big-calendar`](https://www.npmjs.com/package/@lichta/react-big-calendar) |
177
38
 
178
- ### i18n
39
+ Nếu bạn đang cài `lichta` từ trước và dùng API core (`LichTa.toLunar()`, ...), chuyển sang `@lichta/core` — API không đổi, chỉ đổi tên import:
179
40
 
180
- ```typescript
181
- import { t, getZodiacAnimal } from 'lichta';
182
-
183
- // Get dictionary
184
- const vi = t('vi');
185
- vi.heavenlyStems; // ['Giáp', 'Ất', ...]
186
- vi.earthlyBranches; // ['Tý', 'Sửu', ...]
187
- vi.fiveElements; // ['Kim', 'Mộc', 'Thủy', 'Hỏa', 'Thổ']
188
- vi.monthNames; // ['Giêng', 'Hai', ..., 'Chạp']
189
-
190
- const en = t('en');
191
- en.fiveElements; // ['Metal', 'Wood', 'Water', 'Fire', 'Earth']
192
- en.zodiacAnimals; // ['Rat', 'Ox', 'Tiger', ...]
193
-
194
- const ja = t('ja');
195
- ja.weekDays; // ['日', '月', '火', '水', '木', '金', '土']
196
-
197
- const ko = t('ko');
198
- ko.fiveElements; // ['금', '목', '수', '화', '토']
199
-
200
- // Zodiac animal by year
201
- getZodiacAnimal(0, 'vi'); // → 'Chuột'
202
- getZodiacAnimal(4, 'en'); // → 'Dragon'
203
- getZodiacAnimal(0, 'ja'); // → '鼠'
41
+ ```diff
42
+ - import { LichTa } from 'lichta';
43
+ + import { LichTa } from '@lichta/core';
204
44
  ```
205
45
 
206
- ---
207
-
208
- ## 📁 Import Paths
209
-
210
- | Path | Content | Used for |
211
- | -------------- | ---------------------------- | ---------------------------- |
212
- | `lichta` | Full API + Svelte components | Svelte 5 projects |
213
- | `lichta/core` | Pure TypeScript logic | React, Vue, Angular, vanilla |
214
- | `lichta/utils` | Format utilities | Any framework |
215
-
216
- ```typescript
217
- // Svelte 5 — import everything
218
- import { LichTa, Calendar, Formatter, formatTraditional } from 'lichta';
219
-
220
- // React / Vue / Angular — import core logic only
221
- import { LichTa, getYearDetails } from 'lichta/core';
222
- import { formatTraditional, getDayName } from 'lichta/utils';
223
- ```
224
-
225
- ---
226
-
227
- ## 📐 Algorithm
228
-
229
- LichTa uses the lunar conversion algorithm by **Ho Ngoc Duc** (Leipzig University), based on:
230
-
231
- - **Julian Day Number** — Continuous day coordinate system for astronomical calculations
232
- - **New Moon** — Determines the 1st day of the lunar month
233
- - **Solar Terms** — Determines months and leap months
234
- - **Jean Meeus, "Astronomical Algorithms"** — Precise astronomical formulas
235
-
236
- **Range**: 1800 – 2199 | **Default timezone**: GMT+7 (Vietnam)
237
-
238
- See details in [docs/ALGORITHM.md](./docs/ALGORITHM.md).
239
-
240
- ---
241
-
242
- ## 📄 License
46
+ ## License
243
47
 
244
48
  [MIT](./LICENSE)
245
-
246
- ---
247
-
248
- ## 🙏 Credits
249
-
250
- - **Ho Ngoc Duc** — Original algorithm ([informatik.uni-leipzig.de](http://www.informatik.uni-leipzig.de/~duc/amlich/))
251
- - **Jean Meeus** — _Astronomical Algorithms_ (1998)
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@lichta/svelte';
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ console.warn("[lichta] WARNING: The 'lichta' package is deprecated for Svelte components. It will become a pure Vanilla JS core in v3.0.0. Please migrate to '@lichta/svelte' if you are using Svelte.");
2
+
3
+ export * from '@lichta/svelte';
package/package.json CHANGED
@@ -1,105 +1,25 @@
1
1
  {
2
- "name": "lichta",
3
- "version": "1.0.1",
4
- "description": "Thư viện chuyển đổi Dương lịch Âm lịch Việt Nam. Vietnamese lunar calendar conversion library with Svelte 5 components.",
5
- "author": "Zeforc | Stridev",
6
- "license": "MIT",
7
- "scripts": {
8
- "dev": "vite dev",
9
- "build": "vite build && npm run prepack",
10
- "preview": "vite preview",
11
- "prepare": "svelte-kit sync || echo ''",
12
- "prepack": "svelte-kit sync && svelte-package && publint",
13
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
14
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
15
- "lint": "prettier --check . && eslint .",
16
- "format": "prettier --write .",
17
- "test": "vitest run",
18
- "test:watch": "vitest"
19
- },
20
- "files": [
21
- "dist",
22
- "!dist/**/*.test.*",
23
- "!dist/**/*.spec.*"
24
- ],
25
- "sideEffects": [
26
- "**/*.css"
27
- ],
28
- "svelte": "./dist/index.js",
29
- "types": "./dist/index.d.ts",
30
- "type": "module",
31
- "exports": {
32
- ".": {
33
- "types": "./dist/index.d.ts",
34
- "svelte": "./dist/index.js",
35
- "default": "./dist/index.js"
36
- },
37
- "./core": {
38
- "types": "./dist/core/index.d.ts",
39
- "default": "./dist/core/index.js"
40
- },
41
- "./utils": {
42
- "types": "./dist/utils/index.d.ts",
43
- "default": "./dist/utils/index.js"
44
- }
45
- },
46
- "peerDependencies": {
47
- "svelte": "^5.0.0"
48
- },
49
- "peerDependenciesMeta": {
50
- "svelte": {
51
- "optional": true
52
- }
53
- },
54
- "devDependencies": {
55
- "@eslint/js": "^10.0.1",
56
- "@sveltejs/adapter-auto": "^7.0.1",
57
- "@sveltejs/kit": "^2.63.0",
58
- "@sveltejs/package": "^2.5.8",
59
- "@sveltejs/vite-plugin-svelte": "^7.1.2",
60
- "@types/node": "^22",
61
- "@event-calendar/core": "^5.7.1",
62
- "@event-calendar/day-grid": "^3.12.0",
63
- "@fullcalendar/core": "^6.1.20",
64
- "@fullcalendar/daygrid": "^6.1.20",
65
- "moment": "^2.30.1",
66
- "eslint": "^10.4.1",
67
- "eslint-config-prettier": "^10.1.8",
68
- "eslint-plugin-svelte": "^3.19.0",
69
- "globals": "^17.6.0",
70
- "lichta-event-calendar": "^1.0.0",
71
- "lichta-full-calendar": "^1.0.0",
72
- "lichta-react-big-calendar": "^1.0.0",
73
- "prettier": "^3.8.3",
74
- "prettier-plugin-svelte": "^4.1.0",
75
- "publint": "^0.3.21",
76
- "react": "^19.2.7",
77
- "react-big-calendar": "^1.20.0",
78
- "react-dom": "^19.2.7",
79
- "svelte": "^5.56.1",
80
- "svelte-check": "^4.6.0",
81
- "typescript": "^6.0.3",
82
- "typescript-eslint": "^8.60.1",
83
- "vite": "^8.0.16",
84
- "vitest": "^3.2.6"
85
- },
86
- "keywords": [
87
- "svelte",
88
- "lunar-calendar",
89
- "vietnamese",
90
- "am-lich",
91
- "duong-lich",
92
- "can-chi",
93
- "feng-shui",
94
- "calendar",
95
- "date-conversion"
96
- ],
97
- "repository": {
98
- "type": "git",
99
- "url": "git+https://github.com/zeforc/lichta.git"
100
- },
101
- "bugs": {
102
- "url": "https://github.com/zeforc/lichta/issues"
103
- },
104
- "homepage": "https://github.com/zeforc/lichta#readme"
105
- }
2
+ "name": "lichta",
3
+ "version": "2.0.0",
4
+ "description": "LichTa - Thư viện lịch Âm Dương Việt Nam (Tương thích ngược)",
5
+ "author": "Zeforc Labs | Stridev",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "svelte": "./index.js",
9
+ "types": "./index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./index.d.ts",
13
+ "svelte": "./index.js",
14
+ "default": "./index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "index.d.ts",
20
+ "LICENSE"
21
+ ],
22
+ "dependencies": {
23
+ "@lichta/svelte": "2.0.0"
24
+ }
25
+ }