@ramcna/capacitor-ephemeris 0.0.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 (56) hide show
  1. package/Package.swift +28 -0
  2. package/README.md +127 -0
  3. package/RamcnaCapacitorEphemeris.podspec +17 -0
  4. package/android/build.gradle +77 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/cpp/CMakeLists.txt +41 -0
  7. package/android/src/main/cpp/cJSON/cJSON.c +3191 -0
  8. package/android/src/main/cpp/cJSON/cJSON.h +306 -0
  9. package/android/src/main/cpp/swe-bridge.cpp +151 -0
  10. package/android/src/main/cpp/swejni/LICENSE +52 -0
  11. package/android/src/main/cpp/swejni/LICENSE.TXT +52 -0
  12. package/android/src/main/cpp/swejni/ephemeris_jni.c +177 -0
  13. package/android/src/main/cpp/swejni/sefstars.txt +1602 -0
  14. package/android/src/main/cpp/swejni/seleapsec.txt +6 -0
  15. package/android/src/main/cpp/swejni/seorbel.txt +97 -0
  16. package/android/src/main/cpp/swejni/swecl.c +6428 -0
  17. package/android/src/main/cpp/swejni/swedate.c +588 -0
  18. package/android/src/main/cpp/swejni/swedate.h +81 -0
  19. package/android/src/main/cpp/swejni/swehel.c +3511 -0
  20. package/android/src/main/cpp/swejni/swehouse.c +3143 -0
  21. package/android/src/main/cpp/swejni/swehouse.h +98 -0
  22. package/android/src/main/cpp/swejni/swejni.c +2057 -0
  23. package/android/src/main/cpp/swejni/swejni.h +757 -0
  24. package/android/src/main/cpp/swejni/swejpl.c +958 -0
  25. package/android/src/main/cpp/swejni/swejpl.h +103 -0
  26. package/android/src/main/cpp/swejni/swemmoon.c +1930 -0
  27. package/android/src/main/cpp/swejni/swemplan.c +967 -0
  28. package/android/src/main/cpp/swejni/swemptab.h +10640 -0
  29. package/android/src/main/cpp/swejni/swenut2000a.h +2819 -0
  30. package/android/src/main/cpp/swejni/sweodef.h +326 -0
  31. package/android/src/main/cpp/swejni/sweph.c +8614 -0
  32. package/android/src/main/cpp/swejni/sweph.h +849 -0
  33. package/android/src/main/cpp/swejni/swephexp.h +1020 -0
  34. package/android/src/main/cpp/swejni/swephlib.c +4634 -0
  35. package/android/src/main/cpp/swejni/swephlib.h +189 -0
  36. package/android/src/main/java/com/vedichoroo/ephemeris/CapacitorEphemerisPlugin.java +182 -0
  37. package/android/src/main/res/.gitkeep +0 -0
  38. package/dist/docs.json +147 -0
  39. package/dist/esm/definitions.d.ts +42 -0
  40. package/dist/esm/definitions.js +2 -0
  41. package/dist/esm/definitions.js.map +1 -0
  42. package/dist/esm/index.d.ts +4 -0
  43. package/dist/esm/index.js +7 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/web.d.ts +31 -0
  46. package/dist/esm/web.js +28 -0
  47. package/dist/esm/web.js.map +1 -0
  48. package/dist/plugin.cjs.js +42 -0
  49. package/dist/plugin.cjs.js.map +1 -0
  50. package/dist/plugin.js +45 -0
  51. package/dist/plugin.js.map +1 -0
  52. package/ios/Sources/CapacitorEphemerisPluginPlugin/CapacitorEphemerisPlugin.swift +8 -0
  53. package/ios/Sources/CapacitorEphemerisPluginPlugin/CapacitorEphemerisPluginImplementation.swift +52 -0
  54. package/ios/Sources/CapacitorEphemerisPluginPlugin/CapacitorEphemerisPluginPlugin.swift +82 -0
  55. package/ios/Tests/CapacitorEphemerisPluginPluginTests/CapacitorEphemerisPluginTests.swift +15 -0
  56. package/package.json +81 -0
@@ -0,0 +1,177 @@
1
+ #include <jni.h>
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+ #include <string.h>
5
+ #include "swephexp.h"
6
+ #include "cJSON.h"
7
+
8
+ // Helper: strdup replacement
9
+ #define STRDUP(s) ((s) ? strdup(s) : NULL)
10
+
11
+ // Context struct
12
+ typedef struct {
13
+ int year, month, day, hour, minute, second;
14
+ double latitude, longitude;
15
+ int ayanamsaId;
16
+ int useTrueNode;
17
+ } AstroContext;
18
+
19
+ // Parse JSON into AstroContext
20
+ static int parseContext(const char* jsonStr, AstroContext* ctx) {
21
+ cJSON* root = cJSON_Parse(jsonStr);
22
+ if (!root) return 0;
23
+
24
+ ctx->year = cJSON_GetObjectItem(root, "year")->valueint;
25
+ ctx->month = cJSON_GetObjectItem(root, "month")->valueint;
26
+ ctx->day = cJSON_GetObjectItem(root, "day")->valueint;
27
+ ctx->hour = cJSON_GetObjectItem(root, "hour")->valueint;
28
+ ctx->minute = cJSON_GetObjectItem(root, "minute")->valueint;
29
+ ctx->second = cJSON_GetObjectItem(root, "second")->valueint;
30
+ ctx->latitude = cJSON_GetObjectItem(root, "latitude")->valuedouble;
31
+ ctx->longitude = cJSON_GetObjectItem(root, "longitude")->valuedouble;
32
+ ctx->ayanamsaId = cJSON_GetObjectItem(root, "ayanamsaId")->valueint;
33
+ ctx->useTrueNode = cJSON_GetObjectItem(root, "useTrueNode")->valueint;
34
+
35
+ cJSON_Delete(root);
36
+ return 1;
37
+ }
38
+
39
+ // Initialize ephemeris path
40
+ JNIEXPORT jboolean JNICALL
41
+ Java_com_vedichoroo_ephemeris_CapacitorEphemerisPlugin_nativeInitialize(
42
+ JNIEnv* env, jobject thiz, jstring ephPath) {
43
+ const char* pathStr = (*env)->GetStringUTFChars(env, ephPath, NULL);
44
+ swe_set_ephe_path(pathStr);
45
+ (*env)->ReleaseStringUTFChars(env, ephPath, pathStr);
46
+ return JNI_TRUE;
47
+ }
48
+
49
+ // -------------------- GetAscendant --------------------
50
+ JNIEXPORT jdouble JNICALL
51
+ Java_com_vedichoroo_ephemeris_CapacitorEphemerisPlugin_nativeGetAscendant(
52
+ JNIEnv* env, jobject thiz, jstring contextJson) {
53
+
54
+ const char* jsonStr = (*env)->GetStringUTFChars(env, contextJson, NULL);
55
+ AstroContext ctx;
56
+ if (!parseContext(jsonStr, &ctx)) {
57
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
58
+ return -1;
59
+ }
60
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
61
+
62
+ // Julian Day
63
+ double jd_ut = swe_julday(ctx.year, ctx.month, ctx.day,
64
+ ctx.hour + ctx.minute / 60.0 + ctx.second / 3600.0,
65
+ SE_GREG_CAL);
66
+
67
+ // Set ayanamsa
68
+ switch (ctx.ayanamsaId) {
69
+ case 1: swe_set_sid_mode(SE_SIDM_RAMAN, 0, 0); break;
70
+ case 2: case 3: swe_set_sid_mode(SE_SIDM_KRISHNAMURTI, 0, 0); break;
71
+ default: swe_set_sid_mode(SE_SIDM_LAHIRI, 0, 0); break;
72
+ }
73
+
74
+ double cusps[13], ascmc[10];
75
+ swe_houses_ex(jd_ut, SEFLG_SWIEPH | SEFLG_SIDEREAL, ctx.latitude, ctx.longitude, 'P', cusps, ascmc);
76
+
77
+ return ascmc[0]; // Ascendant longitude
78
+ }
79
+
80
+ // -------------------- GetCusps --------------------
81
+ JNIEXPORT jdoubleArray JNICALL
82
+ Java_com_vedichoroo_ephemeris_CapacitorEphemerisPlugin_nativeGetCusps(
83
+ JNIEnv* env, jobject thiz, jstring contextJson) {
84
+
85
+ const char* jsonStr = (*env)->GetStringUTFChars(env, contextJson, NULL);
86
+ AstroContext ctx;
87
+ if (!parseContext(jsonStr, &ctx)) {
88
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
89
+ return NULL;
90
+ }
91
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
92
+
93
+ double cusps[13], ascmc[10];
94
+ double jd_ut = swe_julday(ctx.year, ctx.month, ctx.day,
95
+ ctx.hour + ctx.minute / 60.0 + ctx.second / 3600.0,
96
+ SE_GREG_CAL);
97
+
98
+ switch (ctx.ayanamsaId) {
99
+ case 1: swe_set_sid_mode(SE_SIDM_RAMAN, 0, 0); break;
100
+ case 2: case 3: swe_set_sid_mode(SE_SIDM_KRISHNAMURTI, 0, 0); break;
101
+ default: swe_set_sid_mode(SE_SIDM_LAHIRI, 0, 0); break;
102
+ }
103
+
104
+ swe_houses_ex(jd_ut, SEFLG_SWIEPH | SEFLG_SIDEREAL, ctx.latitude, ctx.longitude, 'P', cusps, ascmc);
105
+
106
+ jdoubleArray result = (*env)->NewDoubleArray(env, 12);
107
+ (*env)->SetDoubleArrayRegion(env, result, 0, 12, cusps + 1);
108
+ return result;
109
+ }
110
+
111
+ // -------------------- GetSMLSubPositions --------------------
112
+ JNIEXPORT jstring JNICALL
113
+ Java_com_vedichoroo_ephemeris_CapacitorEphemerisPlugin_nativeGetSMLSubPositions(
114
+ JNIEnv* env, jobject thiz, jstring contextJson) {
115
+
116
+ const char* jsonStr = (*env)->GetStringUTFChars(env, contextJson, NULL);
117
+ AstroContext ctx;
118
+ if (!parseContext(jsonStr, &ctx)) {
119
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
120
+ return (*env)->NewStringUTF(env, "{\"error\":\"Invalid context\"}");
121
+ }
122
+ (*env)->ReleaseStringUTFChars(env, contextJson, jsonStr);
123
+
124
+ double jd_ut = swe_julday(ctx.year, ctx.month, ctx.day,
125
+ ctx.hour + ctx.minute / 60.0 + ctx.second / 3600.0,
126
+ SE_GREG_CAL);
127
+
128
+ switch (ctx.ayanamsaId) {
129
+ case 1: swe_set_sid_mode(SE_SIDM_RAMAN, 0, 0); break;
130
+ case 2: case 3: swe_set_sid_mode(SE_SIDM_KRISHNAMURTI, 0, 0); break;
131
+ default: swe_set_sid_mode(SE_SIDM_LAHIRI, 0, 0); break;
132
+ }
133
+
134
+ int iflag = SEFLG_SWIEPH | SEFLG_SIDEREAL | SEFLG_SPEED;
135
+ double cusps[13], ascmc[10];
136
+ swe_houses_ex(jd_ut, iflag, ctx.latitude, ctx.longitude, 'P', cusps, ascmc);
137
+
138
+ // Planets: Sun, Moon, Ascendant
139
+ double x[6]; char serr[256];
140
+ cJSON* resultJson = cJSON_CreateObject();
141
+
142
+ // Ascendant
143
+ cJSON_AddNumberToObject(resultJson, "ascendant", ascmc[0]);
144
+
145
+ // Sun
146
+ swe_calc_ut(jd_ut, SE_SUN, iflag, x, serr);
147
+ cJSON* sunJson = cJSON_CreateObject();
148
+ cJSON_AddNumberToObject(sunJson, "longitude", x[0]);
149
+ cJSON_AddNumberToObject(sunJson, "speed", x[3]);
150
+ cJSON_AddItemToObject(resultJson, "sun", sunJson);
151
+
152
+ // Moon
153
+ swe_calc_ut(jd_ut, SE_MOON, iflag, x, serr);
154
+ cJSON* moonJson = cJSON_CreateObject();
155
+ cJSON_AddNumberToObject(moonJson, "longitude", x[0]);
156
+ cJSON_AddNumberToObject(moonJson, "speed", x[3]);
157
+ cJSON_AddItemToObject(resultJson, "moon", moonJson);
158
+
159
+ // Rahu/Ketu
160
+ int nodeId = ctx.useTrueNode ? SE_TRUE_NODE : SE_MEAN_NODE;
161
+ swe_calc_ut(jd_ut, nodeId, iflag, x, serr);
162
+ cJSON* rahuJson = cJSON_CreateObject();
163
+ double ketuLon = fmod(x[0] + 180.0, 360.0);
164
+ cJSON_AddNumberToObject(rahuJson, "longitude", x[0]);
165
+ cJSON_AddNumberToObject(rahuJson, "ketuLongitude", ketuLon);
166
+ cJSON_AddItemToObject(resultJson, "nodes", rahuJson);
167
+
168
+ char* resultStr = cJSON_PrintUnformatted(resultJson);
169
+ jstring jResult = (*env)->NewStringUTF(env, resultStr);
170
+
171
+ free(resultStr);
172
+ cJSON_Delete(resultJson);
173
+ return jResult;
174
+ }
175
+ //
176
+ // Created by Naga on 2/8/2026.
177
+ //