@@ -7,9 +7,6 @@ import { OKLCH_NEUTRAL_FALLBACK, transparentizeOklch } from '~/utils/colors'
77import { getFrameworkColor , isListedFramework } from ' ~/utils/frameworks'
88import { drawNpmxLogoAndTaglineWatermark } from ' ~/composables/useChartWatermark'
99import type { RepoRef } from ' #shared/utils/git-providers'
10- import { parseRepoUrl } from ' #shared/utils/git-providers'
11- import type { PackageMetaResponse } from ' #shared/types'
12- import { encodePackageName } from ' #shared/utils/npm'
1310import type {
1411 ChartTimeGranularity ,
1512 DailyDataPoint ,
@@ -337,52 +334,28 @@ const effectivePackageNames = computed<string[]>(() => {
337334 return single ? [single ] : []
338335})
339336
340- const repoRefsByPackage = shallowRef <Record <string , RepoRef | undefined >>({})
341- const repoRefsRequestToken = shallowRef (0 )
342-
343- async function loadRepoRefsForPackages(packages : string []) {
344- if (! import .meta .client ) return
345- if (! packages .length ) {
346- repoRefsByPackage .value = {}
347- return
348- }
349-
350- const currentToken = ++ repoRefsRequestToken .value
351-
352- const settled = await Promise .allSettled (
353- packages .map (async name => {
354- const encoded = encodePackageName (name )
355- const meta = await $fetch <PackageMetaResponse >(` /api/registry/package-meta/${encoded } ` )
356- const repoUrl = meta ?.links ?.repository
357- const ref = repoUrl ? parseRepoUrl (repoUrl ) : undefined
358- return { name , ref }
359- }),
360- )
361-
362- if (currentToken !== repoRefsRequestToken .value ) return
337+ const {
338+ fetchPackageDownloadEvolution,
339+ fetchPackageLikesEvolution,
340+ fetchRepoContributorsEvolution,
341+ fetchRepoRefsForPackages,
342+ } = useCharts ()
363343
364- const next: Record <string , RepoRef | undefined > = {}
365- for (const [index, entry] of settled .entries ()) {
366- const name = packages [index ]
367- if (! name ) continue
368- if (entry .status === ' fulfilled' ) {
369- next [name ] = entry .value .ref ?? undefined
370- } else {
371- next [name ] = undefined
372- }
373- }
374- repoRefsByPackage .value = next
375- }
344+ const repoRefsByPackage = shallowRef <Record <string , RepoRef | null >>({})
345+ const repoRefsRequestToken = shallowRef (0 )
376346
377347watch (
378348 () => effectivePackageNames .value ,
379- names => {
349+ async names => {
380350 if (! import .meta .client ) return
381351 if (! isMultiPackageMode .value ) {
382352 repoRefsByPackage .value = {}
383353 return
384354 }
385- loadRepoRefsForPackages (names )
355+ const currentToken = ++ repoRefsRequestToken .value
356+ const refs = await fetchRepoRefsForPackages (names )
357+ if (currentToken !== repoRefsRequestToken .value ) return
358+ repoRefsByPackage .value = refs
386359 },
387360 { immediate: true },
388361)
@@ -626,18 +599,12 @@ function applyDateRange<T extends Record<string, unknown>>(base: T): T & DateRan
626599 return next
627600}
628601
629- const {
630- fetchPackageDownloadEvolution,
631- fetchPackageLikesEvolution,
632- fetchRepoContributorsEvolution,
633- } = useCharts ()
634-
635602type MetricId = ' downloads' | ' likes' | ' contributors'
636603const DEFAULT_METRIC_ID: MetricId = ' downloads'
637604
638605type MetricContext = {
639606 packageName: string
640- repoRef? : RepoRef | undefined | null
607+ repoRef? : RepoRef | null
641608}
642609
643610type MetricDef = {
@@ -681,7 +648,7 @@ const METRICS = computed<MetricDef[]>(() => {
681648 id: ' contributors' ,
682649 label: $t (' package.trends.items.contributors' ),
683650 fetch : ({ repoRef }, opts ) => fetchRepoContributorsEvolution (repoRef , opts ),
684- supportsMulti: false ,
651+ supportsMulti: true ,
685652 })
686653 }
687654
@@ -700,6 +667,16 @@ const effectivePackageNamesForMetric = computed<string[]>(() => {
700667 )
701668})
702669
670+ const skippedPackagesWithoutGitHub = computed (() => {
671+ if (! isMultiPackageMode .value ) return []
672+ if (selectedMetric .value !== ' contributors' ) return []
673+ if (! effectivePackageNames .value .length ) return []
674+
675+ return effectivePackageNames .value .filter (
676+ name => repoRefsByPackage .value [name ]?.provider !== ' github' ,
677+ )
678+ })
679+
703680const availableGranularities = computed <ChartTimeGranularity []>(() => {
704681 if (selectedMetric .value === ' contributors' ) {
705682 return [' weekly' , ' monthly' , ' yearly' ]
@@ -856,7 +833,7 @@ async function loadMetric(metricId: MetricId) {
856833
857834 const settled = await Promise .allSettled (
858835 packageNames .map (async pkg => {
859- const repoRef = metricId === ' contributors' ? repoRefsByPackage .value [pkg ] : undefined
836+ const repoRef = metricId === ' contributors' ? repoRefsByPackage .value [pkg ] : null
860837 const result = await fetchFn ({ packageName: pkg , repoRef })
861838 return { pkg , result: (result ?? []) as EvolutionData }
862839 }),
@@ -1692,6 +1669,11 @@ watch(selectedMetric, value => {
16921669 <span class =" i-carbon:reset w-5 h-5" aria-hidden =" true" />
16931670 </button >
16941671 </div >
1672+
1673+ <p v-if =" skippedPackagesWithoutGitHub.length > 0" class =" text-2xs font-mono text-fg-subtle" >
1674+ {{ $t('package.trends.contributors_skip', { count: skippedPackagesWithoutGitHub.length }) }}
1675+ {{ skippedPackagesWithoutGitHub.join(', ') }}
1676+ </p >
16951677 </div >
16961678
16971679 <h2 id =" trends-chart-title" class =" sr-only" >
0 commit comments