panchanga 0.1.1
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 +21 -0
- package/README.md +272 -0
- package/dist/ayanamsha.d.ts +84 -0
- package/dist/ayanamsha.d.ts.map +1 -0
- package/dist/ayanamsha.js +124 -0
- package/dist/ayanamsha.js.map +1 -0
- package/dist/eclipses.d.ts +58 -0
- package/dist/eclipses.d.ts.map +1 -0
- package/dist/eclipses.js +132 -0
- package/dist/eclipses.js.map +1 -0
- package/dist/elements.d.ts +230 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +603 -0
- package/dist/elements.js.map +1 -0
- package/dist/festivals.d.ts +145 -0
- package/dist/festivals.d.ts.map +1 -0
- package/dist/festivals.js +927 -0
- package/dist/festivals.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/panchanga.d.ts +78 -0
- package/dist/panchanga.d.ts.map +1 -0
- package/dist/panchanga.js +76 -0
- package/dist/panchanga.js.map +1 -0
- package/dist/rules.d.ts +161 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +1058 -0
- package/dist/rules.js.map +1 -0
- package/dist/time.d.ts +306 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +637 -0
- package/dist/time.js.map +1 -0
- package/dist/types.d.ts +169 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/types.ts — the observance-rule GRAMMAR (the engine's keystone).
|
|
3
|
+
*
|
|
4
|
+
* This module is the CANONICAL home for the festival rule algebra. It declares
|
|
5
|
+
* the `Observance` union (how a festival's civil date is determined), the
|
|
6
|
+
* `FestivalRule` record (the authored datum), and the `FestivalResult` output.
|
|
7
|
+
*
|
|
8
|
+
* The grammar is taken verbatim from the plan
|
|
9
|
+
* (`docs/superpowers/plans/2026-06-23-festivals-page-v2.md`, "Rule grammar (the
|
|
10
|
+
* keystone)"). It is the widened algebra derived from the verified spec table —
|
|
11
|
+
* the v1 grammar could not express the festivals it named.
|
|
12
|
+
*
|
|
13
|
+
* SINGLE-DEFINITION POLICY
|
|
14
|
+
* ────────────────────────
|
|
15
|
+
* `Kala` is defined here (it names kāla windows AND the moonrise/sunset/ingress
|
|
16
|
+
* instants observances key on). `GeoLocation` lives in `time.ts` (next to the
|
|
17
|
+
* rise/set machinery that consumes it) and is RE-EXPORTED here so callers can
|
|
18
|
+
* import the whole grammar from one place. There is exactly one definition of
|
|
19
|
+
* each — no divergent duplicates.
|
|
20
|
+
*/
|
|
21
|
+
export type { GeoLocation } from "./time.js";
|
|
22
|
+
/**
|
|
23
|
+
* A named time anchor. The first nine resolve to a kāla *window* (`{start,end}`)
|
|
24
|
+
* via the corresponding `time.ts` function and are usable as a `tithi-pervades`
|
|
25
|
+
* window; the last three (`moonrise`, `sunset`, `sankrantiPunyaKala`) are
|
|
26
|
+
* instants used by the non-`tithi-pervades` observances.
|
|
27
|
+
*
|
|
28
|
+
* Note: `time.ts` exposes `pratahkala` (alias of `sunriseWindow`) for the
|
|
29
|
+
* `"sunrise"` kāla, and `arunodaya` is the pre-sunrise window (4 ghaṭikās
|
|
30
|
+
* before sunrise) for aruṇodaya-vyāpinī observances.
|
|
31
|
+
*/
|
|
32
|
+
export type Kala = "sunrise" | "purvahna" | "madhyahna" | "aparahna" | "pradosha" | "nishita" | "pratahkala" | "brahmaMuhurta" | "moonrise" | "sunset" | "arunodaya" | "sankrantiPunyaKala";
|
|
33
|
+
/**
|
|
34
|
+
* A tithi reference within a paksha: 1..15 (Pratipadā..Pūrṇimā/Amāvāsyā), or a
|
|
35
|
+
* boundary alias. `"purnima"` ≡ tithi 15 of śukla pakṣa; `"amavasya"` ≡ tithi
|
|
36
|
+
* 15 of kṛṣṇa pakṣa.
|
|
37
|
+
*/
|
|
38
|
+
export type TithiRef = number | "purnima" | "amavasya";
|
|
39
|
+
/** Lunar fortnight. */
|
|
40
|
+
export type Paksha = "shukla" | "krishna";
|
|
41
|
+
/**
|
|
42
|
+
* The five ways a festival date resolves. The discriminant is `kind`.
|
|
43
|
+
*/
|
|
44
|
+
export type Observance =
|
|
45
|
+
/**
|
|
46
|
+
* Most lunar festivals: the tithi must PERVADE a kāla window on the chosen
|
|
47
|
+
* civil day. Among the (usually two) candidate days the tithi touches, a
|
|
48
|
+
* `precedence` policy selects the winner.
|
|
49
|
+
*
|
|
50
|
+
* • "max-window-fraction" — the day whose tithi interval covers the larger
|
|
51
|
+
* fraction of that day's `window` wins (the vyāpti/pervasion rule).
|
|
52
|
+
* • "udaya" — the day on which the tithi is present at the window's start
|
|
53
|
+
* (sunrise-prevailing).
|
|
54
|
+
* • "first" / "second" — fixed: the earlier / later candidate.
|
|
55
|
+
*
|
|
56
|
+
* `nakshatra` (e.g. Janmāṣṭamī's Rohiṇī): `"required"` filters out days where
|
|
57
|
+
* the nakshatra is absent; `"preferred"` is only a tie-break.
|
|
58
|
+
* `avoidKarana: "vishti"` (Bhadra — Holikā, Rakhi): the Bhadra overlap is
|
|
59
|
+
* recorded, and (via `bhadraSplit`) its Mukha/Pucchā windows and Vāsa are
|
|
60
|
+
* surfaced in the result instants.
|
|
61
|
+
* `fallback` applies when the tithi pervades the window on NO candidate day:
|
|
62
|
+
* • previous-day / next-day — shift one civil day either way;
|
|
63
|
+
* • nearest-window — keep the candidate day whose kāla window is closest to
|
|
64
|
+
* the tithi (for niśīta festivals where the tithi straddles two midnights
|
|
65
|
+
* without covering either, e.g. Masik Śivarātri at far-western longitudes).
|
|
66
|
+
*/
|
|
67
|
+
{
|
|
68
|
+
kind: "tithi-pervades";
|
|
69
|
+
paksha: Paksha;
|
|
70
|
+
tithi: TithiRef;
|
|
71
|
+
window: Kala;
|
|
72
|
+
precedence: "max-window-fraction" | "udaya" | "first" | "second";
|
|
73
|
+
nakshatra?: {
|
|
74
|
+
name: string;
|
|
75
|
+
window?: Kala;
|
|
76
|
+
mode: "required" | "preferred";
|
|
77
|
+
};
|
|
78
|
+
avoidKarana?: "vishti";
|
|
79
|
+
fallback?: "previous-day" | "next-day" | "nearest-window";
|
|
80
|
+
/**
|
|
81
|
+
* Adhika-māsa policy in a leap-month year. Default = the nija (regular)
|
|
82
|
+
* lunation. `"prefer-adhika"` observes in the ADHIKA lunation of the named
|
|
83
|
+
* month when one exists that year, else falls back to nija — for festivals
|
|
84
|
+
* Drik places in the leap month (e.g. Ganga Dussehra in Adhika Jyeṣṭha).
|
|
85
|
+
*/
|
|
86
|
+
adhika?: "prefer-adhika";
|
|
87
|
+
}
|
|
88
|
+
/** Pure solar: the Sun's sidereal ingress into a rāśi. */
|
|
89
|
+
| {
|
|
90
|
+
kind: "solar-ingress";
|
|
91
|
+
rashi: number;
|
|
92
|
+
punyaKala?: "after-moment-to-sunset" | "around-moment";
|
|
93
|
+
}
|
|
94
|
+
/** Moon-sighting festivals: tithi live at moonrise (Karva Chauth, Sankashti). */
|
|
95
|
+
| {
|
|
96
|
+
kind: "moonrise";
|
|
97
|
+
paksha: Paksha;
|
|
98
|
+
tithi: TithiRef;
|
|
99
|
+
}
|
|
100
|
+
/** Sūrya-arghya festivals: tithi at sunset, and next sunrise (Chhath). */
|
|
101
|
+
| {
|
|
102
|
+
kind: "solar-arghya";
|
|
103
|
+
paksha: Paksha;
|
|
104
|
+
tithi: TithiRef;
|
|
105
|
+
}
|
|
106
|
+
/** Offset from another festival (Holi = Holikā +1). */
|
|
107
|
+
| {
|
|
108
|
+
kind: "derived";
|
|
109
|
+
from: string;
|
|
110
|
+
offsetDays: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Nakṣatra-anchored solar-month festival: the day the Moon occupies
|
|
114
|
+
* `nakshatra` (at sunrise) while the Sun is in rāśi `solarRashi`. E.g. Onam =
|
|
115
|
+
* Śravaṇa (Thiruvoṇam) nakṣatra with the Sun in Siṃha.
|
|
116
|
+
*/
|
|
117
|
+
| {
|
|
118
|
+
kind: "nakshatra-pervades";
|
|
119
|
+
nakshatra: string;
|
|
120
|
+
solarRashi: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Weekday-anchored relative to another festival: the latest `weekday`
|
|
124
|
+
* (0 = Sunday … 6 = Saturday) strictly before the `from` festival's date.
|
|
125
|
+
* E.g. Varalakṣmī Vrat = the Friday before Śrāvaṇa Pūrṇimā.
|
|
126
|
+
*/
|
|
127
|
+
| {
|
|
128
|
+
kind: "weekday-relative";
|
|
129
|
+
from: string;
|
|
130
|
+
weekday: number;
|
|
131
|
+
};
|
|
132
|
+
export type FestivalRule = {
|
|
133
|
+
/** Stable slug. */
|
|
134
|
+
id: string;
|
|
135
|
+
displayName: string;
|
|
136
|
+
/**
|
|
137
|
+
* Pūrṇimānta month label; the amānta label is derived at output time.
|
|
138
|
+
* OPTIONAL: solar-ingress and derived rules don't key on a lunar month, so
|
|
139
|
+
* they omit it rather than carry an empty-string placeholder. For lunar-tithi
|
|
140
|
+
* / moonrise / solar-arghya rules it is required to anchor the lunation.
|
|
141
|
+
*/
|
|
142
|
+
month?: {
|
|
143
|
+
purnimanta: string;
|
|
144
|
+
};
|
|
145
|
+
category: "lunar-tithi" | "solar" | "moonrise" | "derived" | "nakshatra";
|
|
146
|
+
/** True if this is part of the §4b extended set. */
|
|
147
|
+
extended?: boolean;
|
|
148
|
+
observance: Observance;
|
|
149
|
+
/** Default "smarta". */
|
|
150
|
+
sampradaya?: "smarta" | "vaishnava";
|
|
151
|
+
meta?: {
|
|
152
|
+
deity?: string;
|
|
153
|
+
note?: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export type FestivalResult = {
|
|
157
|
+
id: string;
|
|
158
|
+
/** Local civil date (YYYY-MM-DD) in `loc` tz. Empty string when unresolved. */
|
|
159
|
+
date: string;
|
|
160
|
+
/** Key instants (tithi start/end, window start/end, moment, …) as ISO UTC. */
|
|
161
|
+
instants: Record<string, string>;
|
|
162
|
+
monthLabel: {
|
|
163
|
+
purnimanta: string;
|
|
164
|
+
amanta: string;
|
|
165
|
+
};
|
|
166
|
+
/** Never silently drop: any miss is explained here. */
|
|
167
|
+
diagnostics: string[];
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C;;;;;;;;;GASG;AACH,MAAM,MAAM,IAAI,GACZ,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAC9D,SAAS,GAAG,YAAY,GAAG,eAAe,GAC1C,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AAEvD,uBAAuB;AACvB,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAM1C;;GAEG;AACH,MAAM,MAAM,UAAU;AACpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC;IACtE,UAAU,EAAE,qBAAqB,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjE,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,UAAU,GAAG,WAAW,CAAA;KAAE,CAAC;IAC5E,WAAW,CAAC,EAAE,QA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AAwB;IACxB,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IACpC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,uDAAuD;IACvD,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/types.ts — the observance-rule GRAMMAR (the engine's keystone).
|
|
3
|
+
*
|
|
4
|
+
* This module is the CANONICAL home for the festival rule algebra. It declares
|
|
5
|
+
* the `Observance` union (how a festival's civil date is determined), the
|
|
6
|
+
* `FestivalRule` record (the authored datum), and the `FestivalResult` output.
|
|
7
|
+
*
|
|
8
|
+
* The grammar is taken verbatim from the plan
|
|
9
|
+
* (`docs/superpowers/plans/2026-06-23-festivals-page-v2.md`, "Rule grammar (the
|
|
10
|
+
* keystone)"). It is the widened algebra derived from the verified spec table —
|
|
11
|
+
* the v1 grammar could not express the festivals it named.
|
|
12
|
+
*
|
|
13
|
+
* SINGLE-DEFINITION POLICY
|
|
14
|
+
* ────────────────────────
|
|
15
|
+
* `Kala` is defined here (it names kāla windows AND the moonrise/sunset/ingress
|
|
16
|
+
* instants observances key on). `GeoLocation` lives in `time.ts` (next to the
|
|
17
|
+
* rise/set machinery that consumes it) and is RE-EXPORTED here so callers can
|
|
18
|
+
* import the whole grammar from one place. There is exactly one definition of
|
|
19
|
+
* each — no divergent duplicates.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "panchanga",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Drik Panchanga (Smārta, pūrṇimānta) engine for HSNA — computes tithi, vara, nakshatra, yoga, karana, festivals and eclipses from astronomical first principles.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Hindu Society of North America",
|
|
7
|
+
"homepage": "https://github.com/SODIYAL/panchanga#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/SODIYAL/panchanga.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/SODIYAL/panchanga/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"panchang",
|
|
17
|
+
"panchanga",
|
|
18
|
+
"hindu-calendar",
|
|
19
|
+
"tithi",
|
|
20
|
+
"nakshatra",
|
|
21
|
+
"vedic",
|
|
22
|
+
"jyotish",
|
|
23
|
+
"drik-panchang",
|
|
24
|
+
"festivals",
|
|
25
|
+
"ayanamsha",
|
|
26
|
+
"ephemeris"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.json",
|
|
46
|
+
"prepare": "tsc -p tsconfig.json",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"prepublishOnly": "npm test && npm run build"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"astronomy-engine": "^2"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vitest": "^4.1.9"
|
|
56
|
+
}
|
|
57
|
+
}
|