@moontra/moonui-pro 2.18.0 → 2.18.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/dist/index.mjs CHANGED
@@ -61686,6 +61686,8 @@ function useGitHubData({
61686
61686
  const [lastUpdated, setLastUpdated] = useState(null);
61687
61687
  const refreshTimeoutRef = useRef();
61688
61688
  const previousStarsRef = useRef(/* @__PURE__ */ new Map());
61689
+ const errorCountRef = useRef(0);
61690
+ const maxErrorCount = 2;
61689
61691
  const checkMilestones = useCallback((repos2) => {
61690
61692
  if (!onMilestoneReached)
61691
61693
  return;
@@ -61706,6 +61708,24 @@ function useGitHubData({
61706
61708
  });
61707
61709
  }, [milestones, onMilestoneReached]);
61708
61710
  const fetchData = useCallback(async () => {
61711
+ if (errorCountRef.current >= maxErrorCount) {
61712
+ console.warn("Maximum error count reached. Stopping requests.");
61713
+ setLoading(false);
61714
+ setError("Maximum retry limit exceeded. Please check your configuration.");
61715
+ return;
61716
+ }
61717
+ const hasValidInput = username && repository || // Tek repository modu
61718
+ username && repositories && repositories.length > 0 || // Çoklu repository modu
61719
+ repositories && repositories.length > 0 && repositories.every((r2) => r2.includes("/")) || // Full path repositories
61720
+ username;
61721
+ if (!hasValidInput) {
61722
+ console.warn("No valid input provided. Skipping API request.");
61723
+ setLoading(false);
61724
+ setError(null);
61725
+ setRepos([]);
61726
+ setStats(null);
61727
+ return;
61728
+ }
61709
61729
  try {
61710
61730
  setLoading(true);
61711
61731
  setError(null);
@@ -61722,6 +61742,12 @@ function useGitHubData({
61722
61742
  if (repository && username) {
61723
61743
  const repo = await fetchRepository(username, repository, token);
61724
61744
  fetchedRepos = [repo];
61745
+ } else if (repositories && repositories.length > 0 && repositories.every((r2) => r2.includes("/"))) {
61746
+ const repoPromises = repositories.map((fullPath) => {
61747
+ const [owner, name] = fullPath.split("/");
61748
+ return fetchRepository(owner, name, token);
61749
+ });
61750
+ fetchedRepos = await Promise.all(repoPromises);
61725
61751
  } else if (repositories && repositories.length > 0 && username) {
61726
61752
  const repoPromises = repositories.map(
61727
61753
  (repoName) => fetchRepository(username, repoName, token)
@@ -61777,9 +61803,12 @@ function useGitHubData({
61777
61803
  onDataUpdate(calculatedStats);
61778
61804
  }
61779
61805
  setLastUpdated(/* @__PURE__ */ new Date());
61806
+ errorCountRef.current = 0;
61780
61807
  } catch (err) {
61781
61808
  const errorMessage = err instanceof Error ? err.message : "Failed to fetch data";
61782
61809
  setError(errorMessage);
61810
+ errorCountRef.current += 1;
61811
+ console.error(`GitHub API error (${errorCountRef.current}/${maxErrorCount}):`, errorMessage);
61783
61812
  if (onError) {
61784
61813
  onError(err instanceof Error ? err : new Error(errorMessage));
61785
61814
  }
@@ -61798,7 +61827,12 @@ function useGitHubData({
61798
61827
  onError
61799
61828
  ]);
61800
61829
  useEffect(() => {
61801
- fetchData();
61830
+ const hasValidInput = username && repository || username && repositories && repositories.length > 0 || repositories && repositories.length > 0 && repositories.every((r2) => r2.includes("/")) || username;
61831
+ if (hasValidInput) {
61832
+ fetchData();
61833
+ } else {
61834
+ setLoading(false);
61835
+ }
61802
61836
  }, [fetchData]);
61803
61837
  useEffect(() => {
61804
61838
  if (!autoRefresh)
@@ -61817,6 +61851,10 @@ function useGitHubData({
61817
61851
  };
61818
61852
  }, [autoRefresh, refreshInterval, fetchData]);
61819
61853
  const refresh = useCallback(() => {
61854
+ if (errorCountRef.current >= maxErrorCount) {
61855
+ console.warn("Cannot refresh: maximum error count reached");
61856
+ return Promise.resolve();
61857
+ }
61820
61858
  clearCache();
61821
61859
  return fetchData();
61822
61860
  }, [fetchData]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.18.0",
3
+ "version": "2.18.1",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -54,6 +54,8 @@ export function useGitHubData({
54
54
 
55
55
  const refreshTimeoutRef = useRef<NodeJS.Timeout>()
56
56
  const previousStarsRef = useRef<Map<string, number>>(new Map())
57
+ const errorCountRef = useRef<number>(0) // Hata sayısını takip et
58
+ const maxErrorCount = 2 // Maksimum hata sayısı
57
59
 
58
60
  const checkMilestones = useCallback((repos: GitHubRepository[]) => {
59
61
  if (!onMilestoneReached) return
@@ -78,6 +80,30 @@ export function useGitHubData({
78
80
  }, [milestones, onMilestoneReached])
79
81
 
80
82
  const fetchData = useCallback(async () => {
83
+ // Hata limiti aşıldıysa istek yapma
84
+ if (errorCountRef.current >= maxErrorCount) {
85
+ console.warn("Maximum error count reached. Stopping requests.")
86
+ setLoading(false)
87
+ setError("Maximum retry limit exceeded. Please check your configuration.")
88
+ return
89
+ }
90
+
91
+ // Gerekli bilgiler yoksa istek yapma
92
+ const hasValidInput =
93
+ (username && repository) || // Tek repository modu
94
+ (username && repositories && repositories.length > 0) || // Çoklu repository modu
95
+ (repositories && repositories.length > 0 && repositories.every(r => r.includes('/'))) || // Full path repositories
96
+ username // Kullanıcının tüm repositoryleri
97
+
98
+ if (!hasValidInput) {
99
+ console.warn("No valid input provided. Skipping API request.")
100
+ setLoading(false)
101
+ setError(null)
102
+ setRepos([])
103
+ setStats(null)
104
+ return
105
+ }
106
+
81
107
  try {
82
108
  setLoading(true)
83
109
  setError(null)
@@ -101,7 +127,15 @@ export function useGitHubData({
101
127
  const repo = await fetchRepository(username, repository, token)
102
128
  fetchedRepos = [repo]
103
129
  }
104
- // Multiple specific repositories
130
+ // Multiple specific repositories with full paths
131
+ else if (repositories && repositories.length > 0 && repositories.every(r => r.includes('/'))) {
132
+ const repoPromises = repositories.map(fullPath => {
133
+ const [owner, name] = fullPath.split('/')
134
+ return fetchRepository(owner, name, token)
135
+ })
136
+ fetchedRepos = await Promise.all(repoPromises)
137
+ }
138
+ // Multiple specific repositories with username
105
139
  else if (repositories && repositories.length > 0 && username) {
106
140
  const repoPromises = repositories.map(repoName =>
107
141
  fetchRepository(username, repoName, token)
@@ -173,9 +207,16 @@ export function useGitHubData({
173
207
  }
174
208
 
175
209
  setLastUpdated(new Date())
210
+ // Başarılı olduğunda hata sayacını sıfırla
211
+ errorCountRef.current = 0
176
212
  } catch (err) {
177
213
  const errorMessage = err instanceof Error ? err.message : "Failed to fetch data"
178
214
  setError(errorMessage)
215
+
216
+ // Hata sayacını artır
217
+ errorCountRef.current += 1
218
+ console.error(`GitHub API error (${errorCountRef.current}/${maxErrorCount}):`, errorMessage)
219
+
179
220
  if (onError) {
180
221
  onError(err instanceof Error ? err : new Error(errorMessage))
181
222
  }
@@ -196,7 +237,18 @@ export function useGitHubData({
196
237
 
197
238
  // Initial fetch
198
239
  useEffect(() => {
199
- fetchData()
240
+ // Sadece geçerli input varsa fetch yap
241
+ const hasValidInput =
242
+ (username && repository) ||
243
+ (username && repositories && repositories.length > 0) ||
244
+ (repositories && repositories.length > 0 && repositories.every(r => r.includes('/'))) ||
245
+ username
246
+
247
+ if (hasValidInput) {
248
+ fetchData()
249
+ } else {
250
+ setLoading(false)
251
+ }
200
252
  }, [fetchData])
201
253
 
202
254
  // Auto-refresh
@@ -220,6 +272,12 @@ export function useGitHubData({
220
272
  }, [autoRefresh, refreshInterval, fetchData])
221
273
 
222
274
  const refresh = useCallback(() => {
275
+ // Hata limiti aşıldıysa refresh yapma
276
+ if (errorCountRef.current >= maxErrorCount) {
277
+ console.warn("Cannot refresh: maximum error count reached")
278
+ return Promise.resolve()
279
+ }
280
+
223
281
  clearCache()
224
282
  return fetchData()
225
283
  }, [fetchData])