@moontra/moonui-pro 2.18.2 → 2.18.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.4",
|
|
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",
|
|
@@ -3,6 +3,19 @@ import { GitHubRepository, GitHubStats, GitHubActivity, LanguageStats, RateLimit
|
|
|
3
3
|
// Cache management
|
|
4
4
|
const cache = new Map<string, { data: any; timestamp: number; expiresAt: number }>()
|
|
5
5
|
|
|
6
|
+
// Docs mode detection
|
|
7
|
+
const isDocsMode = () => {
|
|
8
|
+
return typeof window !== "undefined" &&
|
|
9
|
+
(window.location.pathname.includes("/docs/") ||
|
|
10
|
+
window.location.pathname.includes("/components/"))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Get cache duration based on mode
|
|
14
|
+
const getCacheDuration = (defaultDuration: number) => {
|
|
15
|
+
// Docs modunda cache süresini 30 dakikaya çıkar
|
|
16
|
+
return isDocsMode() ? 1800000 : defaultDuration // 30 dakika : default
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
// Language colors
|
|
7
20
|
export const LANGUAGE_COLORS: Record<string, string> = {
|
|
8
21
|
JavaScript: "#f7df1e",
|
|
@@ -86,7 +99,7 @@ export async function getRateLimitInfo(token?: string): Promise<RateLimitInfo> {
|
|
|
86
99
|
cache.set(cacheKey, {
|
|
87
100
|
data: rateLimitInfo,
|
|
88
101
|
timestamp: Date.now(),
|
|
89
|
-
expiresAt: Date.now() + 60000, //
|
|
102
|
+
expiresAt: Date.now() + getCacheDuration(60000), // Docs modunda daha uzun cache
|
|
90
103
|
})
|
|
91
104
|
|
|
92
105
|
return rateLimitInfo
|
|
@@ -121,7 +134,7 @@ export async function fetchUserRepositories(
|
|
|
121
134
|
cache.set(cacheKey, {
|
|
122
135
|
data: repos,
|
|
123
136
|
timestamp: Date.now(),
|
|
124
|
-
expiresAt: Date.now() + 300000, //
|
|
137
|
+
expiresAt: Date.now() + getCacheDuration(300000), // Docs modunda 30 dakika
|
|
125
138
|
})
|
|
126
139
|
|
|
127
140
|
return repos
|
|
@@ -146,7 +159,7 @@ export async function fetchRepository(
|
|
|
146
159
|
cache.set(cacheKey, {
|
|
147
160
|
data: repository,
|
|
148
161
|
timestamp: Date.now(),
|
|
149
|
-
expiresAt: Date.now() + 300000, //
|
|
162
|
+
expiresAt: Date.now() + getCacheDuration(300000), // Docs modunda 30 dakika
|
|
150
163
|
})
|
|
151
164
|
|
|
152
165
|
return repository
|
|
@@ -180,7 +193,7 @@ export async function fetchContributorsCount(
|
|
|
180
193
|
cache.set(cacheKey, {
|
|
181
194
|
data: count,
|
|
182
195
|
timestamp: Date.now(),
|
|
183
|
-
expiresAt: Date.now() + 3600000, //
|
|
196
|
+
expiresAt: Date.now() + getCacheDuration(3600000), // Docs modunda 30 dakika
|
|
184
197
|
})
|
|
185
198
|
return count
|
|
186
199
|
}
|
|
@@ -193,7 +206,7 @@ export async function fetchContributorsCount(
|
|
|
193
206
|
cache.set(cacheKey, {
|
|
194
207
|
data: count,
|
|
195
208
|
timestamp: Date.now(),
|
|
196
|
-
expiresAt: Date.now() + 3600000, //
|
|
209
|
+
expiresAt: Date.now() + getCacheDuration(3600000), // Docs modunda 30 dakika
|
|
197
210
|
})
|
|
198
211
|
|
|
199
212
|
return count
|
|
@@ -233,7 +246,7 @@ export async function fetchStarHistory(
|
|
|
233
246
|
cache.set(cacheKey, {
|
|
234
247
|
data: history,
|
|
235
248
|
timestamp: Date.now(),
|
|
236
|
-
expiresAt: Date.now() + 3600000, //
|
|
249
|
+
expiresAt: Date.now() + getCacheDuration(3600000), // Docs modunda 30 dakika
|
|
237
250
|
})
|
|
238
251
|
|
|
239
252
|
return history
|
|
@@ -29,6 +29,9 @@ interface UseGitHubDataOptions {
|
|
|
29
29
|
onDataUpdate?: (stats: GitHubStats) => void
|
|
30
30
|
onMilestoneReached?: (milestone: Milestone) => void
|
|
31
31
|
milestones?: number[]
|
|
32
|
+
// Docs mode optimizasyonları için
|
|
33
|
+
docsMode?: boolean
|
|
34
|
+
mockDataFallback?: boolean
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export function useGitHubData({
|
|
@@ -44,7 +47,16 @@ export function useGitHubData({
|
|
|
44
47
|
onDataUpdate,
|
|
45
48
|
onMilestoneReached,
|
|
46
49
|
milestones = [10, 50, 100, 500, 1000, 5000, 10000],
|
|
50
|
+
docsMode = false,
|
|
51
|
+
mockDataFallback = true,
|
|
47
52
|
}: UseGitHubDataOptions) {
|
|
53
|
+
// Docs mode tespiti
|
|
54
|
+
const isDocsMode = docsMode || (typeof window !== "undefined" &&
|
|
55
|
+
(window.location.pathname.includes("/docs/") ||
|
|
56
|
+
window.location.pathname.includes("/components/")))
|
|
57
|
+
|
|
58
|
+
// Docs modunda autoRefresh'i devre dışı bırak
|
|
59
|
+
const effectiveAutoRefresh = isDocsMode ? false : autoRefresh
|
|
48
60
|
const [repos, setRepos] = useState<GitHubRepository[]>([])
|
|
49
61
|
const [stats, setStats] = useState<GitHubStats | null>(null)
|
|
50
62
|
const [loading, setLoading] = useState(true)
|
|
@@ -55,7 +67,9 @@ export function useGitHubData({
|
|
|
55
67
|
const refreshTimeoutRef = useRef<NodeJS.Timeout>()
|
|
56
68
|
const previousStarsRef = useRef<Map<string, number>>(new Map())
|
|
57
69
|
const errorCountRef = useRef<number>(0) // Hata sayısını takip et
|
|
58
|
-
const maxErrorCount = 2 //
|
|
70
|
+
const maxErrorCount = isDocsMode ? 1 : 2 // Docs modunda daha az deneme
|
|
71
|
+
const hasInitialFetchedRef = useRef(false) // İlk fetch yapıldı mı?
|
|
72
|
+
const docsDataCacheRef = useRef<GitHubRepository[] | null>(null) // Docs mode cache
|
|
59
73
|
|
|
60
74
|
// checkMilestones fonksiyonunu ref olarak sakla - bu şekilde her render'da yeniden oluşturulmaz
|
|
61
75
|
const milestonesRef = useRef(milestones)
|
|
@@ -93,11 +107,32 @@ export function useGitHubData({
|
|
|
93
107
|
}, []) // Boş dependency array - fonksiyon asla yeniden oluşturulmaz
|
|
94
108
|
|
|
95
109
|
const fetchData = useCallback(async () => {
|
|
110
|
+
// Docs modunda ve daha önce fetch yapıldıysa, cache'den döndür
|
|
111
|
+
if (isDocsMode && hasInitialFetchedRef.current && docsDataCacheRef.current) {
|
|
112
|
+
console.log("[Docs Mode] Returning cached data, skipping API request")
|
|
113
|
+
setRepos(docsDataCacheRef.current)
|
|
114
|
+
const calculatedStats = calculateStats(docsDataCacheRef.current)
|
|
115
|
+
setStats(calculatedStats)
|
|
116
|
+
setLoading(false)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
96
120
|
// Hata limiti aşıldıysa istek yapma
|
|
97
121
|
if (errorCountRef.current >= maxErrorCount) {
|
|
98
122
|
console.warn("Maximum error count reached. Stopping requests.")
|
|
123
|
+
|
|
124
|
+
// Docs modunda ve mockDataFallback aktifse mock data göster
|
|
125
|
+
if (isDocsMode && mockDataFallback) {
|
|
126
|
+
const mockData = getMockGitHubData(username, repository, repositories)
|
|
127
|
+
setRepos(mockData)
|
|
128
|
+
const calculatedStats = calculateStats(mockData)
|
|
129
|
+
setStats(calculatedStats)
|
|
130
|
+
setError(null)
|
|
131
|
+
} else {
|
|
132
|
+
setError("Maximum retry limit exceeded. Please check your configuration.")
|
|
133
|
+
}
|
|
134
|
+
|
|
99
135
|
setLoading(false)
|
|
100
|
-
setError("Maximum retry limit exceeded. Please check your configuration.")
|
|
101
136
|
return
|
|
102
137
|
}
|
|
103
138
|
|
|
@@ -222,6 +257,12 @@ export function useGitHubData({
|
|
|
222
257
|
setLastUpdated(new Date())
|
|
223
258
|
// Başarılı olduğunda hata sayacını sıfırla
|
|
224
259
|
errorCountRef.current = 0
|
|
260
|
+
|
|
261
|
+
// Docs modunda başarılı veriyi cache'le
|
|
262
|
+
if (isDocsMode) {
|
|
263
|
+
hasInitialFetchedRef.current = true
|
|
264
|
+
docsDataCacheRef.current = enhancedRepos
|
|
265
|
+
}
|
|
225
266
|
} catch (err) {
|
|
226
267
|
const errorMessage = err instanceof Error ? err.message : "Failed to fetch data"
|
|
227
268
|
setError(errorMessage)
|
|
@@ -230,7 +271,17 @@ export function useGitHubData({
|
|
|
230
271
|
errorCountRef.current += 1
|
|
231
272
|
console.error(`GitHub API error (${errorCountRef.current}/${maxErrorCount}):`, errorMessage)
|
|
232
273
|
|
|
233
|
-
|
|
274
|
+
// Docs modunda ve mockDataFallback aktifse mock data göster
|
|
275
|
+
if (isDocsMode && mockDataFallback && !hasInitialFetchedRef.current) {
|
|
276
|
+
console.warn("[Docs Mode] API failed, using mock data")
|
|
277
|
+
const mockData = getMockGitHubData(username, repository, repositories)
|
|
278
|
+
setRepos(mockData)
|
|
279
|
+
const calculatedStats = calculateStats(mockData)
|
|
280
|
+
setStats(calculatedStats)
|
|
281
|
+
setError(null)
|
|
282
|
+
hasInitialFetchedRef.current = true
|
|
283
|
+
docsDataCacheRef.current = mockData
|
|
284
|
+
} else if (onError) {
|
|
234
285
|
onError(err instanceof Error ? err : new Error(errorMessage))
|
|
235
286
|
}
|
|
236
287
|
} finally {
|
|
@@ -246,6 +297,8 @@ export function useGitHubData({
|
|
|
246
297
|
checkMilestones, // Artık stable
|
|
247
298
|
onDataUpdate,
|
|
248
299
|
onError,
|
|
300
|
+
isDocsMode,
|
|
301
|
+
mockDataFallback,
|
|
249
302
|
])
|
|
250
303
|
|
|
251
304
|
// Initial fetch
|
|
@@ -266,7 +319,8 @@ export function useGitHubData({
|
|
|
266
319
|
|
|
267
320
|
// Auto-refresh
|
|
268
321
|
useEffect(() => {
|
|
269
|
-
|
|
322
|
+
// Docs modunda auto-refresh'i tamamen devre dışı bırak
|
|
323
|
+
if (!effectiveAutoRefresh) return
|
|
270
324
|
|
|
271
325
|
const scheduleRefresh = () => {
|
|
272
326
|
refreshTimeoutRef.current = setTimeout(() => {
|
|
@@ -282,9 +336,15 @@ export function useGitHubData({
|
|
|
282
336
|
clearTimeout(refreshTimeoutRef.current)
|
|
283
337
|
}
|
|
284
338
|
}
|
|
285
|
-
}, [
|
|
339
|
+
}, [effectiveAutoRefresh, refreshInterval, fetchData])
|
|
286
340
|
|
|
287
341
|
const refresh = useCallback(() => {
|
|
342
|
+
// Docs modunda refresh'i sınırla
|
|
343
|
+
if (isDocsMode && hasInitialFetchedRef.current) {
|
|
344
|
+
console.warn("[Docs Mode] Refresh disabled after initial fetch")
|
|
345
|
+
return Promise.resolve()
|
|
346
|
+
}
|
|
347
|
+
|
|
288
348
|
// Hata limiti aşıldıysa refresh yapma
|
|
289
349
|
if (errorCountRef.current >= maxErrorCount) {
|
|
290
350
|
console.warn("Cannot refresh: maximum error count reached")
|
|
@@ -293,7 +353,7 @@ export function useGitHubData({
|
|
|
293
353
|
|
|
294
354
|
clearCache()
|
|
295
355
|
return fetchData()
|
|
296
|
-
}, [fetchData])
|
|
356
|
+
}, [fetchData, isDocsMode])
|
|
297
357
|
|
|
298
358
|
return {
|
|
299
359
|
repos,
|
|
@@ -372,4 +432,70 @@ export function useGitHubNotifications(enabled: boolean = true) {
|
|
|
372
432
|
)
|
|
373
433
|
|
|
374
434
|
return { permission, notify }
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Mock data generator for docs mode
|
|
438
|
+
function getMockGitHubData(
|
|
439
|
+
username?: string,
|
|
440
|
+
repository?: string,
|
|
441
|
+
repositories?: string[]
|
|
442
|
+
): GitHubRepository[] {
|
|
443
|
+
const defaultRepos: GitHubRepository[] = [
|
|
444
|
+
{
|
|
445
|
+
id: 1,
|
|
446
|
+
name: repository || "awesome-project",
|
|
447
|
+
full_name: `${username || "moonui"}/${repository || "awesome-project"}`,
|
|
448
|
+
description: "An amazing open source project with great features",
|
|
449
|
+
html_url: `https://github.com/${username || "moonui"}/${repository || "awesome-project"}`,
|
|
450
|
+
homepage: "https://awesome-project.dev",
|
|
451
|
+
stargazers_count: 12453,
|
|
452
|
+
watchers_count: 543,
|
|
453
|
+
forks_count: 2341,
|
|
454
|
+
language: "TypeScript",
|
|
455
|
+
topics: ["react", "ui", "components", "typescript"],
|
|
456
|
+
created_at: "2022-01-15T10:30:00Z",
|
|
457
|
+
updated_at: new Date().toISOString(),
|
|
458
|
+
pushed_at: new Date().toISOString(),
|
|
459
|
+
size: 4567,
|
|
460
|
+
open_issues_count: 23,
|
|
461
|
+
license: {
|
|
462
|
+
key: "mit",
|
|
463
|
+
name: "MIT License",
|
|
464
|
+
spdx_id: "MIT",
|
|
465
|
+
url: "https://api.github.com/licenses/mit",
|
|
466
|
+
},
|
|
467
|
+
owner: {
|
|
468
|
+
login: username || "moonui",
|
|
469
|
+
avatar_url: `https://github.com/${username || "moonui"}.png`,
|
|
470
|
+
html_url: `https://github.com/${username || "moonui"}`,
|
|
471
|
+
type: "Organization",
|
|
472
|
+
},
|
|
473
|
+
contributors_count: 89,
|
|
474
|
+
},
|
|
475
|
+
]
|
|
476
|
+
|
|
477
|
+
if (repositories && repositories.length > 0) {
|
|
478
|
+
return repositories.map((repo, index) => {
|
|
479
|
+
const [owner, name] = repo.includes('/') ? repo.split('/') : [username || "moonui", repo]
|
|
480
|
+
return {
|
|
481
|
+
...defaultRepos[0],
|
|
482
|
+
id: index + 1,
|
|
483
|
+
name: name,
|
|
484
|
+
full_name: `${owner}/${name}`,
|
|
485
|
+
html_url: `https://github.com/${owner}/${name}`,
|
|
486
|
+
stargazers_count: Math.floor(Math.random() * 20000) + 1000,
|
|
487
|
+
forks_count: Math.floor(Math.random() * 3000) + 100,
|
|
488
|
+
watchers_count: Math.floor(Math.random() * 1000) + 50,
|
|
489
|
+
language: ["TypeScript", "JavaScript", "Python", "Go", "Rust"][index % 5],
|
|
490
|
+
owner: {
|
|
491
|
+
login: owner,
|
|
492
|
+
avatar_url: `https://github.com/${owner}.png`,
|
|
493
|
+
html_url: `https://github.com/${owner}`,
|
|
494
|
+
type: "Organization",
|
|
495
|
+
},
|
|
496
|
+
}
|
|
497
|
+
})
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return defaultRepos
|
|
375
501
|
}
|
|
@@ -60,7 +60,16 @@ const GitHubStarsInternal: React.FC<GitHubStarsProps> = ({
|
|
|
60
60
|
size = "md",
|
|
61
61
|
customColors,
|
|
62
62
|
}) => {
|
|
63
|
-
|
|
63
|
+
// Docs mode tespiti
|
|
64
|
+
const isDocsMode = typeof window !== "undefined" &&
|
|
65
|
+
(window.location.pathname.includes("/docs/") ||
|
|
66
|
+
window.location.pathname.includes("/components/"))
|
|
67
|
+
|
|
68
|
+
// Docs modunda bazı özellikleri override et
|
|
69
|
+
const effectiveAutoRefresh = isDocsMode ? false : autoRefresh
|
|
70
|
+
const effectiveNotifications = isDocsMode ? false : enableNotifications
|
|
71
|
+
const effectiveRefreshInterval = isDocsMode ? 3600000 : refreshInterval // Docs modunda 1 saat
|
|
72
|
+
const { notify } = useGitHubNotifications(effectiveNotifications)
|
|
64
73
|
|
|
65
74
|
// onMilestoneReached callback'ini memoize et
|
|
66
75
|
const handleMilestoneReached = React.useCallback((milestone: any) => {
|
|
@@ -96,14 +105,16 @@ const GitHubStarsInternal: React.FC<GitHubStarsProps> = ({
|
|
|
96
105
|
repository,
|
|
97
106
|
repositories,
|
|
98
107
|
token,
|
|
99
|
-
autoRefresh,
|
|
100
|
-
refreshInterval,
|
|
108
|
+
autoRefresh: effectiveAutoRefresh,
|
|
109
|
+
refreshInterval: effectiveRefreshInterval,
|
|
101
110
|
sortBy,
|
|
102
111
|
maxItems,
|
|
103
112
|
onError,
|
|
104
113
|
onDataUpdate,
|
|
105
114
|
onMilestoneReached: handleMilestoneReached,
|
|
106
115
|
milestones,
|
|
116
|
+
docsMode: isDocsMode, // Docs mode flag'ini gönder
|
|
117
|
+
mockDataFallback: true, // Docs modunda mock data kullan
|
|
107
118
|
})
|
|
108
119
|
|
|
109
120
|
const handleExport = React.useCallback((format: "json" | "csv") => {
|
|
@@ -296,8 +307,8 @@ const GitHubStarsInternal: React.FC<GitHubStarsProps> = ({
|
|
|
296
307
|
>
|
|
297
308
|
{renderVariant()}
|
|
298
309
|
|
|
299
|
-
{/* Rate limit warning */}
|
|
300
|
-
{rateLimitInfo && rateLimitInfo.remaining < 10 && (
|
|
310
|
+
{/* Rate limit warning - Docs modunda gösterme */}
|
|
311
|
+
{!isDocsMode && rateLimitInfo && rateLimitInfo.remaining < 10 && (
|
|
301
312
|
<div className="mt-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 rounded-md text-sm">
|
|
302
313
|
<p className="text-yellow-800 dark:text-yellow-200">
|
|
303
314
|
⚠️ Low API rate limit: {rateLimitInfo.remaining} requests remaining.
|
|
@@ -305,6 +316,13 @@ const GitHubStarsInternal: React.FC<GitHubStarsProps> = ({
|
|
|
305
316
|
</p>
|
|
306
317
|
</div>
|
|
307
318
|
)}
|
|
319
|
+
|
|
320
|
+
{/* Docs mode indicator - sadece development modunda göster */}
|
|
321
|
+
{isDocsMode && process.env.NODE_ENV === "development" && (
|
|
322
|
+
<div className="mt-2 text-xs text-muted-foreground text-center">
|
|
323
|
+
📚 Docs Mode: API istekleri optimize edildi
|
|
324
|
+
</div>
|
|
325
|
+
)}
|
|
308
326
|
</motion.div>
|
|
309
327
|
)
|
|
310
328
|
}
|