Skip to content

Commit 8255a54

Browse files
committed
Merge branch 'main' of github.com:npmx-dev/npmx.dev into fix/infinite-api-call
2 parents 09264ee + 0df32a3 commit 8255a54

File tree

12 files changed

+582
-265
lines changed

12 files changed

+582
-265
lines changed

app/components/Package/DownloadAnalytics.vue

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,9 @@ const rootEl = shallowRef<HTMLElement | null>(null)
1919
2020
const { width } = useElementSize(rootEl)
2121
22-
const chartKey = ref(0)
23-
24-
let chartRemountTimeoutId: ReturnType<typeof setTimeout> | null = null
25-
2622
onMounted(() => {
2723
rootEl.value = document.documentElement
2824
resolvedMode.value = colorMode.value === 'dark' ? 'dark' : 'light'
29-
30-
// If the chart is painted too early, built-in auto-sizing does not adapt to the final container size
31-
chartRemountTimeoutId = setTimeout(() => {
32-
chartKey.value += 1
33-
chartRemountTimeoutId = null
34-
}, 10)
35-
})
36-
37-
onBeforeUnmount(() => {
38-
if (chartRemountTimeoutId !== null) {
39-
clearTimeout(chartRemountTimeoutId)
40-
chartRemountTimeoutId = null
41-
}
4225
})
4326
4427
const { colors } = useCssVariables(
@@ -705,12 +688,7 @@ const config = computed(() => {
705688
</div>
706689

707690
<ClientOnly v-if="inModal && chartData.dataset">
708-
<VueUiXy
709-
:dataset="chartData.dataset"
710-
:config="config"
711-
class="[direction:ltr]"
712-
:key="chartKey"
713-
>
691+
<VueUiXy :dataset="chartData.dataset" :config="config" class="[direction:ltr]">
714692
<template #menuIcon="{ isOpen }">
715693
<span v-if="isOpen" class="i-carbon:close w-6 h-6" aria-hidden="true" />
716694
<span v-else class="i-carbon:overflow-menu-vertical w-6 h-6" aria-hidden="true" />

app/composables/useNpmRegistry.ts

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
PackageVersionInfo,
1010
} from '#shared/types'
1111
import type { ReleaseType } from 'semver'
12+
import { mapWithConcurrency } from '#shared/utils/async'
1213
import { maxSatisfying, prerelease, major, minor, diff, gt, compare } from 'semver'
1314
import { isExactVersion } from '~/utils/versions'
1415
import { extractInstallScriptsInfo } from '~/utils/install-scripts'
@@ -546,34 +547,28 @@ export function useOrgPackages(orgName: MaybeRefOrGetter<string>) {
546547

547548
// Fetch packuments and downloads in parallel
548549
const [packuments, downloads] = await Promise.all([
549-
// Fetch packuments in parallel (with concurrency limit)
550+
// Fetch packuments with concurrency limit
550551
(async () => {
551-
const concurrency = 10
552-
const results: MinimalPackument[] = []
553-
for (let i = 0; i < packageNames.length; i += concurrency) {
554-
const batch = packageNames.slice(i, i + concurrency)
555-
const batchResults = await Promise.all(
556-
batch.map(async name => {
557-
try {
558-
const encoded = encodePackageName(name)
559-
const { data: pkg } = await cachedFetch<MinimalPackument>(
560-
`${NPM_REGISTRY}/${encoded}`,
561-
{ signal },
562-
)
563-
return pkg
564-
} catch {
565-
return null
566-
}
567-
}),
568-
)
569-
for (const pkg of batchResults) {
570-
// Filter out any unpublished packages (missing dist-tags)
571-
if (pkg && pkg['dist-tags']) {
572-
results.push(pkg)
552+
const results = await mapWithConcurrency(
553+
packageNames,
554+
async name => {
555+
try {
556+
const encoded = encodePackageName(name)
557+
const { data: pkg } = await cachedFetch<MinimalPackument>(
558+
`${NPM_REGISTRY}/${encoded}`,
559+
{ signal },
560+
)
561+
return pkg
562+
} catch {
563+
return null
573564
}
574-
}
575-
}
576-
return results
565+
},
566+
10,
567+
)
568+
// Filter out any unpublished packages (missing dist-tags)
569+
return results.filter(
570+
(pkg): pkg is MinimalPackument => pkg !== null && !!pkg['dist-tags'],
571+
)
577572
})(),
578573
// Fetch downloads in bulk
579574
fetchBulkDownloads(packageNames, { signal }),
@@ -772,23 +767,20 @@ export function useOutdatedDependencies(
772767
return
773768
}
774769

775-
const results: Record<string, OutdatedDependencyInfo> = {}
776770
const entries = Object.entries(deps)
777-
const batchSize = 5
778-
779-
for (let i = 0; i < entries.length; i += batchSize) {
780-
const batch = entries.slice(i, i + batchSize)
781-
const batchResults = await Promise.all(
782-
batch.map(async ([name, constraint]) => {
783-
const info = await checkDependencyOutdated(cachedFetch, name, constraint)
784-
return [name, info] as const
785-
}),
786-
)
771+
const batchResults = await mapWithConcurrency(
772+
entries,
773+
async ([name, constraint]) => {
774+
const info = await checkDependencyOutdated(cachedFetch, name, constraint)
775+
return [name, info] as const
776+
},
777+
5,
778+
)
787779

788-
for (const [name, info] of batchResults) {
789-
if (info) {
790-
results[name] = info
791-
}
780+
const results: Record<string, OutdatedDependencyInfo> = {}
781+
for (const [name, info] of batchResults) {
782+
if (info) {
783+
results[name] = info
792784
}
793785
}
794786

app/pages/about.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,23 @@ const { data: contributors, status: contributorsStatus } = useFetch<GitHubContri
189189
target="_blank"
190190
rel="noopener noreferrer"
191191
class="group relative"
192-
:title="$t('about.contributors.view_profile', { name: contributor.login })"
192+
:aria-label="$t('about.contributors.view_profile', { name: contributor.login })"
193193
>
194-
<img
195-
:src="`${contributor.avatar_url}&s=64`"
196-
:alt="contributor.login"
197-
width="32"
198-
height="32"
199-
class="w-8 h-8 rounded-full ring-2 ring-transparent group-hover:ring-accent transition-all duration-200"
200-
loading="lazy"
201-
/>
194+
<div class="relative flex items-center">
195+
<img
196+
:src="`${contributor.avatar_url}&s=64`"
197+
:alt="contributor.login"
198+
width="32"
199+
height="32"
200+
class="w-12 h-12 rounded-lg ring-2 ring-transparent group-hover:ring-accent transition-all duration-200 ease-out hover:scale-125 will-change-transform"
201+
loading="lazy"
202+
/>
203+
<span
204+
class="pointer-events-none absolute -top-9 inset-is-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900 text-xs px-2 py-1 shadow-lg opacity-0 scale-95 transition-all duration-150 group-hover:opacity-100 group-hover:scale-100"
205+
>
206+
@{{ contributor.login }}
207+
</span>
208+
</div>
202209
</a>
203210
</div>
204211
</div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"vite-plugin-pwa": "1.2.0",
9292
"vite-plus": "0.0.0-833c515fa25cef20905a7f9affb156dfa6f151ab",
9393
"vue": "3.5.27",
94-
"vue-data-ui": "3.13.7"
94+
"vue-data-ui": "3.14.0"
9595
},
9696
"devDependencies": {
9797
"@npm/types": "2.1.0",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)