chart2txt 0.6.0 → 0.7.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.
Files changed (49) hide show
  1. package/README.md +103 -34
  2. package/dist/chart2txt.d.ts +9 -0
  3. package/dist/chart2txt.js +30 -0
  4. package/dist/chart2txt.min.js +1 -1
  5. package/dist/config/ChartSettings.d.ts +10 -6
  6. package/dist/config/ChartSettings.js +22 -11
  7. package/dist/constants.d.ts +17 -2
  8. package/dist/constants.js +303 -34
  9. package/dist/core/analysis.d.ts +6 -0
  10. package/dist/core/analysis.js +237 -0
  11. package/dist/core/aspectPatterns.d.ts +8 -3
  12. package/dist/core/aspectPatterns.js +234 -218
  13. package/dist/core/aspects.d.ts +14 -11
  14. package/dist/core/aspects.js +49 -32
  15. package/dist/core/dignities.d.ts +2 -27
  16. package/dist/core/dignities.js +56 -121
  17. package/dist/core/dispositors.d.ts +7 -19
  18. package/dist/core/dispositors.js +152 -126
  19. package/dist/core/grouping.d.ts +9 -0
  20. package/dist/core/grouping.js +45 -0
  21. package/dist/core/signDistributions.d.ts +20 -30
  22. package/dist/core/signDistributions.js +25 -122
  23. package/dist/core/stelliums.d.ts +10 -0
  24. package/dist/core/stelliums.js +108 -0
  25. package/dist/formatters/text/sections/aspectPatterns.d.ts +3 -1
  26. package/dist/formatters/text/sections/aspectPatterns.js +118 -94
  27. package/dist/formatters/text/sections/aspects.d.ts +3 -6
  28. package/dist/formatters/text/sections/aspects.js +35 -52
  29. package/dist/formatters/text/sections/dispositors.d.ts +4 -3
  30. package/dist/formatters/text/sections/dispositors.js +12 -8
  31. package/dist/formatters/text/sections/houseOverlays.d.ts +11 -6
  32. package/dist/formatters/text/sections/houseOverlays.js +37 -44
  33. package/dist/formatters/text/sections/metadata.d.ts +2 -0
  34. package/dist/formatters/text/sections/metadata.js +54 -0
  35. package/dist/formatters/text/sections/planets.d.ts +3 -5
  36. package/dist/formatters/text/sections/planets.js +11 -22
  37. package/dist/formatters/text/sections/signDistributions.d.ts +9 -25
  38. package/dist/formatters/text/sections/signDistributions.js +9 -55
  39. package/dist/formatters/text/textFormatter.d.ts +4 -5
  40. package/dist/formatters/text/textFormatter.js +86 -142
  41. package/dist/index.d.ts +7 -4
  42. package/dist/index.js +11 -6
  43. package/dist/types.d.ts +102 -15
  44. package/dist/types.js +15 -0
  45. package/dist/utils/formatting.d.ts +4 -0
  46. package/dist/utils/formatting.js +43 -0
  47. package/dist/utils/houseCalculations.d.ts +10 -13
  48. package/dist/utils/houseCalculations.js +15 -57
  49. package/package.json +1 -1
@@ -1,17 +1,20 @@
1
- import { Point, Aspect, AspectData } from '../types';
1
+ import { Aspect, AspectData, UnionedPoint } from '../types';
2
2
  /**
3
- * Identifies aspects between planets in a single chart.
3
+ * Unified aspect calculation function that handles both single-chart and multi-chart scenarios
4
4
  * @param aspectDefinitions Array of aspect types to check for.
5
- * @param planets Array of planet points.
5
+ * @param unionedPlanets Array of UnionedPoint pairs to analyze.
6
+ * @param skipOutOfSignAspects Whether to skip aspects that cross sign boundaries.
7
+ * @param aspectStrengthThresholds Thresholds for classifying aspect strength.
8
+ * @param forceChartType Optional override for chart type determination.
6
9
  * @returns Array of found aspects.
7
10
  */
8
- export declare function calculateAspects(aspectDefinitions: Aspect[], planets: Point[], skipOutOfSignAspects?: boolean): AspectData[];
11
+ export declare function calculateAspects(aspectDefinitions: Aspect[], unionedPlanets: UnionedPoint[], skipOutOfSignAspects?: boolean): AspectData[];
9
12
  /**
10
- * Identifies aspects between planets across two charts.
11
- * PlanetA is always from chart1Planets, PlanetB always from chart2Planets.
12
- * @param aspectDefinitions Array of aspect types to check for.
13
- * @param chart1Planets Array of planet points for the first chart.
14
- * @param chart2Planets Array of planet points for the second chart.
15
- * @returns Array of found aspects.
13
+ * Calculates aspects in a multi-chart context (synastry, transits, etc.)
14
+ * @param aspectDefinitions Array of aspect types to check for
15
+ * @param unionedPlanets Array of UnionedPoint pairs to analyze
16
+ * @param skipOutOfSignAspects Whether to skip aspects that cross sign boundaries
17
+ * @param aspectStrengthThresholds Thresholds for classifying aspect strength
18
+ * @returns Array of found aspects
16
19
  */
17
- export declare function calculateMultichartAspects(aspectDefinitions: Aspect[], chart1Planets: Point[], chart2Planets: Point[], skipOutOfSignAspects?: boolean): AspectData[];
20
+ export declare function calculateMultichartAspects(aspectDefinitions: Aspect[], unionedPlanets: UnionedPoint[], skipOutOfSignAspects?: boolean): AspectData[];
@@ -81,7 +81,18 @@ function determineAspectApplication(planetA, planetB, aspectAngle) {
81
81
  const isApplying = futureAspectDistance < currentAspectDistance;
82
82
  return isApplying ? 'applying' : 'separating';
83
83
  }
84
- function findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAspects) {
84
+ /**
85
+ * Finds the tightest aspect between two planets using simple orb detection
86
+ * @param aspectDefinitions Array of aspect types to check for
87
+ * @param planetA First planet
88
+ * @param planetB Second planet
89
+ * @param skipOutOfSignAspects Whether to skip aspects that cross sign boundaries
90
+ * @param aspectStrengthThresholds Thresholds for classifying aspect strength
91
+ * @param p1ChartName Optional chart name for planetA
92
+ * @param p2ChartName Optional chart name for planetB
93
+ * @returns The tightest aspect found, or null if none
94
+ */
95
+ function findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAspects, p1ChartName, p2ChartName) {
85
96
  const degreeA = (0, precision_1.roundDegrees)((0, astrology_1.normalizeDegree)(planetA.degree));
86
97
  const degreeB = (0, precision_1.roundDegrees)((0, astrology_1.normalizeDegree)(planetB.degree));
87
98
  let diff = Math.abs(degreeA - degreeB);
@@ -94,7 +105,6 @@ function findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAs
94
105
  const planetASign = Math.floor(degreeA / 30);
95
106
  const planetBSign = Math.floor(degreeB / 30);
96
107
  // Calculate expected sign difference for this aspect
97
- // For major aspects: 0° = 0 signs, 60° = 2 signs, 90° = 3 signs, 120° = 4 signs, 180° = 6 signs
98
108
  const expectedSignDiff = getExpectedSignDifference(aspectType.angle);
99
109
  let actualSignDiff = Math.abs(planetASign - planetBSign);
100
110
  if (actualSignDiff > 6)
@@ -103,12 +113,16 @@ function findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAs
103
113
  continue;
104
114
  }
105
115
  }
106
- if (orb <= aspectType.orb) {
116
+ // Use simple orb from aspect definition
117
+ const maxAllowedOrb = aspectType.orb;
118
+ if (orb <= maxAllowedOrb) {
107
119
  if (!tightestAspect || orb < tightestAspect.orb) {
108
120
  const application = determineAspectApplication(planetA, planetB, aspectType.angle);
109
121
  tightestAspect = {
110
122
  planetA: planetA.name,
111
123
  planetB: planetB.name,
124
+ p1ChartName,
125
+ p2ChartName,
112
126
  aspectType: aspectType.name,
113
127
  orb,
114
128
  application,
@@ -119,20 +133,23 @@ function findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAs
119
133
  return tightestAspect;
120
134
  }
121
135
  /**
122
- * Identifies aspects between planets in a single chart.
136
+ * Unified aspect calculation function that handles both single-chart and multi-chart scenarios
123
137
  * @param aspectDefinitions Array of aspect types to check for.
124
- * @param planets Array of planet points.
138
+ * @param unionedPlanets Array of UnionedPoint pairs to analyze.
139
+ * @param skipOutOfSignAspects Whether to skip aspects that cross sign boundaries.
140
+ * @param aspectStrengthThresholds Thresholds for classifying aspect strength.
141
+ * @param forceChartType Optional override for chart type determination.
125
142
  * @returns Array of found aspects.
126
143
  */
127
- function calculateAspects(aspectDefinitions, planets, skipOutOfSignAspects = true) {
144
+ function calculateAspects(aspectDefinitions, unionedPlanets, skipOutOfSignAspects = true) {
128
145
  const aspects = [];
129
- if (!planets || planets.length < 2)
146
+ if (!unionedPlanets || unionedPlanets.length < 2)
130
147
  return aspects;
131
- for (let i = 0; i < planets.length; i++) {
132
- for (let j = i + 1; j < planets.length; j++) {
133
- const planetA = planets[i];
134
- const planetB = planets[j];
135
- const aspect = findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAspects);
148
+ for (let i = 0; i < unionedPlanets.length; i++) {
149
+ for (let j = i + 1; j < unionedPlanets.length; j++) {
150
+ const [planetA, chartNameA] = unionedPlanets[i];
151
+ const [planetB, chartNameB] = unionedPlanets[j];
152
+ const aspect = findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAspects, chartNameA, chartNameB);
136
153
  if (aspect) {
137
154
  aspects.push(aspect);
138
155
  }
@@ -141,28 +158,28 @@ function calculateAspects(aspectDefinitions, planets, skipOutOfSignAspects = tru
141
158
  return aspects;
142
159
  }
143
160
  /**
144
- * Identifies aspects between planets across two charts.
145
- * PlanetA is always from chart1Planets, PlanetB always from chart2Planets.
146
- * @param aspectDefinitions Array of aspect types to check for.
147
- * @param chart1Planets Array of planet points for the first chart.
148
- * @param chart2Planets Array of planet points for the second chart.
149
- * @returns Array of found aspects.
161
+ * Calculates aspects in a multi-chart context (synastry, transits, etc.)
162
+ * @param aspectDefinitions Array of aspect types to check for
163
+ * @param unionedPlanets Array of UnionedPoint pairs to analyze
164
+ * @param skipOutOfSignAspects Whether to skip aspects that cross sign boundaries
165
+ * @param aspectStrengthThresholds Thresholds for classifying aspect strength
166
+ * @returns Array of found aspects
150
167
  */
151
- function calculateMultichartAspects(aspectDefinitions, chart1Planets, chart2Planets, skipOutOfSignAspects = true) {
152
- const aspects = [];
153
- if (!chart1Planets ||
154
- !chart2Planets ||
155
- chart1Planets.length === 0 ||
156
- chart2Planets.length === 0) {
157
- return aspects;
158
- }
159
- for (const p1 of chart1Planets) {
160
- for (const p2 of chart2Planets) {
161
- const aspect = findTightestAspect(aspectDefinitions, p1, p2, skipOutOfSignAspects);
162
- if (aspect) {
163
- aspects.push(aspect);
168
+ function calculateMultichartAspects(aspectDefinitions, unionedPlanets, skipOutOfSignAspects = true) {
169
+ // Filter to only cross-chart aspects
170
+ const crossChartAspects = [];
171
+ for (let i = 0; i < unionedPlanets.length; i++) {
172
+ for (let j = i + 1; j < unionedPlanets.length; j++) {
173
+ const [planetA, chartNameA] = unionedPlanets[i];
174
+ const [planetB, chartNameB] = unionedPlanets[j];
175
+ // Only calculate aspects between planets from different charts
176
+ if (chartNameA !== chartNameB) {
177
+ const aspect = findTightestAspect(aspectDefinitions, planetA, planetB, skipOutOfSignAspects, chartNameA, chartNameB);
178
+ if (aspect) {
179
+ crossChartAspects.push(aspect);
180
+ }
164
181
  }
165
182
  }
166
183
  }
167
- return aspects;
184
+ return crossChartAspects;
168
185
  }
@@ -1,27 +1,2 @@
1
- import { Point } from '../types';
2
- export interface DignityInfo {
3
- rulers: string[];
4
- exaltation?: string;
5
- detriment?: string;
6
- fall?: string;
7
- }
8
- /**
9
- * Gets the essential dignities for a planet in a specific sign
10
- * @param planetName Name of the planet
11
- * @param sign The zodiac sign
12
- * @returns Array of dignity descriptions
13
- */
14
- export declare function getPlanetDignities(planetName: string, sign: string): string[];
15
- /**
16
- * Gets the ruler(s) of a zodiac sign
17
- * @param sign The zodiac sign
18
- * @returns Array of ruling planets
19
- */
20
- export declare function getSignRulers(sign: string): string[];
21
- /**
22
- * Formats planet dignities for display
23
- * @param planet The planet point
24
- * @param houseCusps Array of house cusps (optional)
25
- * @returns Formatted string with dignities
26
- */
27
- export declare function formatPlanetWithDignities(planet: Point, houseCusps?: number[]): string;
1
+ import { PlanetPosition } from '../types';
2
+ export declare function formatPlanetWithDignities(planet: PlanetPosition): string;
@@ -1,136 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPlanetDignities = getPlanetDignities;
4
- exports.getSignRulers = getSignRulers;
5
3
  exports.formatPlanetWithDignities = formatPlanetWithDignities;
6
- const astrology_1 = require("./astrology");
7
- // Essential dignity mappings
8
- const SIGN_DIGNITIES = {
9
- Aries: {
10
- rulers: ['Mars'],
11
- exaltation: 'Sun',
12
- detriment: 'Venus',
13
- fall: 'Saturn',
4
+ const constants_1 = require("../constants");
5
+ const DIGNITY_MAP = {
6
+ Sun: {
7
+ Leo: ['Domicile'],
8
+ Aries: ['Exaltation'],
9
+ Aquarius: ['Detriment'],
10
+ Libra: ['Fall'],
14
11
  },
15
- Taurus: {
16
- rulers: ['Venus'],
17
- exaltation: 'Moon',
18
- detriment: 'Mars',
19
- fall: 'Uranus',
12
+ Moon: {
13
+ Cancer: ['Domicile'],
14
+ Taurus: ['Exaltation'],
15
+ Capricorn: ['Detriment'],
16
+ Scorpio: ['Fall'],
20
17
  },
21
- Gemini: {
22
- rulers: ['Mercury'],
23
- detriment: 'Jupiter',
18
+ Mercury: {
19
+ Gemini: ['Domicile'],
20
+ Virgo: ['Domicile', 'Exaltation'],
21
+ Pisces: ['Detriment', 'Fall'],
22
+ Sagittarius: ['Detriment'],
24
23
  },
25
- Cancer: {
26
- rulers: ['Moon'],
27
- exaltation: 'Jupiter',
28
- detriment: 'Saturn',
29
- fall: 'Mars',
24
+ Venus: {
25
+ Taurus: ['Domicile'],
26
+ Libra: ['Domicile'],
27
+ Scorpio: ['Detriment'],
28
+ Aries: ['Fall'],
29
+ Virgo: ['Fall'],
30
30
  },
31
- Leo: {
32
- rulers: ['Sun'],
33
- detriment: 'Saturn',
34
- fall: 'Neptune',
31
+ Mars: {
32
+ Aries: ['Domicile'],
33
+ Scorpio: ['Domicile'],
34
+ Libra: ['Detriment'],
35
+ Cancer: ['Fall'],
35
36
  },
36
- Virgo: {
37
- rulers: ['Mercury'],
38
- exaltation: 'Mercury',
39
- detriment: 'Jupiter',
40
- fall: 'Venus',
37
+ Jupiter: {
38
+ Sagittarius: ['Domicile'],
39
+ Pisces: ['Domicile'],
40
+ Gemini: ['Detriment'],
41
+ Virgo: ['Fall'],
41
42
  },
42
- Libra: {
43
- rulers: ['Venus'],
44
- exaltation: 'Saturn',
45
- detriment: 'Mars',
46
- fall: 'Sun',
47
- },
48
- Scorpio: {
49
- rulers: ['Mars'],
50
- detriment: 'Venus',
51
- fall: 'Moon',
52
- },
53
- Sagittarius: {
54
- rulers: ['Jupiter'],
55
- detriment: 'Mercury',
56
- },
57
- Capricorn: {
58
- rulers: ['Saturn'],
59
- exaltation: 'Mars',
60
- detriment: 'Moon',
61
- fall: 'Jupiter',
62
- },
63
- Aquarius: {
64
- rulers: ['Saturn'],
65
- detriment: 'Sun',
66
- fall: 'Neptune',
67
- },
68
- Pisces: {
69
- rulers: ['Jupiter'],
70
- exaltation: 'Venus',
71
- detriment: 'Mercury',
72
- fall: 'Mercury',
43
+ Saturn: {
44
+ Capricorn: ['Domicile'],
45
+ Aquarius: ['Domicile'],
46
+ Cancer: ['Detriment'],
47
+ Leo: ['Fall'],
73
48
  },
74
49
  };
75
- /**
76
- * Gets the essential dignities for a planet in a specific sign
77
- * @param planetName Name of the planet
78
- * @param sign The zodiac sign
79
- * @returns Array of dignity descriptions
80
- */
81
- function getPlanetDignities(planetName, sign) {
82
- const dignities = [];
83
- const normalizedSign = sign.trim();
84
- const signInfo = SIGN_DIGNITIES[normalizedSign];
85
- if (!signInfo)
86
- return dignities;
87
- // Check for rulership (domicile)
88
- if (signInfo.rulers.includes(planetName)) {
89
- dignities.push(`Domicile`);
90
- }
91
- // Check for exaltation
92
- if (signInfo.exaltation === planetName) {
93
- dignities.push(`Exaltation`);
94
- }
95
- // Check for detriment
96
- if (signInfo.detriment === planetName) {
97
- dignities.push(`Detriment`);
98
- }
99
- // Check for fall
100
- if (signInfo.fall && signInfo.fall === planetName) {
101
- dignities.push(`Fall`);
102
- }
103
- return dignities;
104
- }
105
- /**
106
- * Gets the ruler(s) of a zodiac sign
107
- * @param sign The zodiac sign
108
- * @returns Array of ruling planets
109
- */
110
- function getSignRulers(sign) {
111
- const normalizedSign = sign.trim();
112
- const signInfo = SIGN_DIGNITIES[normalizedSign];
113
- return signInfo ? signInfo.rulers : [];
114
- }
115
- /**
116
- * Formats planet dignities for display
117
- * @param planet The planet point
118
- * @param houseCusps Array of house cusps (optional)
119
- * @returns Formatted string with dignities
120
- */
121
- function formatPlanetWithDignities(planet, houseCusps) {
122
- const sign = (0, astrology_1.getDegreeSign)(planet.degree);
123
- const dignities = getPlanetDignities(planet.name, sign);
124
- const rulers = getSignRulers(sign);
125
- let dignitiesStr = '';
126
- if (dignities.length > 0 && dignities.includes('Domicile')) {
127
- dignitiesStr = `[${dignities.join(', ')}]`;
50
+ function formatPlanetWithDignities(planet) {
51
+ const sign = planet.sign;
52
+ const dignities = DIGNITY_MAP[planet.name];
53
+ const ruler = constants_1.ZODIAC_SIGN_DATA.find((s) => s.name === sign)?.ruler;
54
+ const dignityParts = [];
55
+ if (dignities && dignities[sign]) {
56
+ dignityParts.push(...dignities[sign]);
128
57
  }
129
- else if (dignities.length > 0 && rulers.length > 0) {
130
- dignitiesStr = `[${dignities.join(', ')} | Ruler: ${rulers.join(', ')}]`;
58
+ let dignityString = dignityParts.join(', ');
59
+ if (ruler && planet.name !== ruler) {
60
+ if (dignityString) {
61
+ dignityString += ` | Ruler: ${ruler}`;
62
+ }
63
+ else {
64
+ dignityString = `Ruler: ${ruler}`;
65
+ }
131
66
  }
132
- else if (rulers.length > 0) {
133
- dignitiesStr = `[Ruler: ${rulers.join(', ')}]`;
67
+ if (dignityString) {
68
+ return `[${dignityString}]`;
134
69
  }
135
- return dignitiesStr;
70
+ return '';
136
71
  }
@@ -1,22 +1,10 @@
1
1
  import { Point } from '../types';
2
- export interface DispositorChain {
3
- planet: string;
4
- disposedBy: string[];
5
- disposes: string[];
6
- }
7
- export interface DispositorAnalysis {
8
- chains: DispositorChain[];
9
- finalDispositors: string[];
10
- }
11
2
  /**
12
- * Builds dispositor chains for all planets
13
- * @param planets Array of planet points
14
- * @returns Complete dispositor analysis
3
+ * Calculates the full dispositor chain for each planet in the chart.
4
+ * @param planets The list of planets in the chart.
5
+ * @param mode Controls which dispositor chains to include: true (all), false (none), 'finals' (only final dispositors and cycles).
6
+ * @returns A map of each planet to its full dispositor chain string, or a summary in 'finals' mode.
15
7
  */
16
- export declare function analyzeDispositors(planets: Point[]): DispositorAnalysis;
17
- /**
18
- * Formats the dispositor analysis for display
19
- * @param analysis The dispositor analysis
20
- * @returns Array of formatted strings
21
- */
22
- export declare function formatDispositorAnalysis(analysis: DispositorAnalysis): string[];
8
+ export declare function calculateDispositors(planets: Point[], mode?: boolean | 'finals'): {
9
+ [key: string]: string;
10
+ };