-
-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy path[...package].vue
More file actions
1332 lines (1200 loc) · 45.3 KB
/
[...package].vue
File metadata and controls
1332 lines (1200 loc) · 45.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<script setup lang="ts">
import type {
NpmVersionDist,
PackumentVersion,
ReadmeResponse,
SkillsListResponse,
} from '#shared/types'
import type { JsrPackageInfo } from '#shared/types/jsr'
import { assertValidPackageName } from '#shared/utils/npm'
import { joinURL } from 'ufo'
import { areUrlsEquivalent } from '#shared/utils/url'
import { isEditableElement } from '~/utils/input'
import { formatBytes } from '~/utils/formatters'
import { getDependencyCount } from '~/utils/npm/dependency-count'
import { NuxtLink } from '#components'
import { useModal } from '~/composables/useModal'
import { useAtproto } from '~/composables/atproto/useAtproto'
import { togglePackageLike } from '~/utils/atproto/likes'
definePageMeta({
name: 'package',
alias: ['/:package(.*)*'],
})
const router = useRouter()
const header = useTemplateRef('header')
const isHeaderPinned = shallowRef(false)
function checkHeaderPosition() {
const el = header.value
if (!el) return
const style = getComputedStyle(el)
const top = parseFloat(style.top) || 0
const rect = el.getBoundingClientRect()
isHeaderPinned.value = Math.abs(rect.top - top) < 1
}
useEventListener('scroll', checkHeaderPosition, { passive: true })
useEventListener('resize', checkHeaderPosition)
onMounted(() => {
checkHeaderPosition()
})
const { packageName, requestedVersion, orgName } = usePackageRoute()
const selectedPM = useSelectedPackageManager()
const activePmId = computed(() => selectedPM.value ?? 'npm')
if (import.meta.server) {
assertValidPackageName(packageName.value)
}
const { data: downloads } = usePackageDownloads(packageName, 'last-week')
// Fetch README for specific version if requested, otherwise latest
const { data: readmeData } = useLazyFetch<ReadmeResponse>(
() => {
const base = `/api/registry/readme/${packageName.value}`
const version = requestedVersion.value
return version ? `${base}/v/${version}` : base
},
{ default: () => ({ html: '', playgroundLinks: [], toc: [] }) },
)
// Track active TOC item based on scroll position
const tocItems = computed(() => readmeData.value?.toc ?? [])
const { activeId: activeTocId, scrollToHeading } = useActiveTocItem(tocItems)
// Check if package exists on JSR (only for scoped packages)
const { data: jsrInfo } = useLazyFetch<JsrPackageInfo>(() => `/api/jsr/${packageName.value}`, {
default: () => ({ exists: false }),
// Only fetch for scoped packages (JSR requirement)
immediate: computed(() => packageName.value.startsWith('@')).value,
})
// Fetch total install size (lazy, can be slow for large dependency trees)
interface InstallSizeResult {
package: string
version: string
selfSize: number
totalSize: number
dependencyCount: number
}
const {
data: installSize,
status: installSizeStatus,
execute: fetchInstallSize,
} = useLazyFetch<InstallSizeResult | null>(
() => {
const base = `/api/registry/install-size/${packageName.value}`
const version = requestedVersion.value
return version ? `${base}/v/${version}` : base
},
{
server: false,
immediate: false,
},
)
onMounted(() => fetchInstallSize())
const { data: skillsData } = useLazyFetch<SkillsListResponse>(
() => {
const base = `/skills/${packageName.value}`
const version = requestedVersion.value
return version ? `${base}/v/${version}` : base
},
{ default: () => ({ package: '', version: '', skills: [] }) },
)
const { data: packageAnalysis } = usePackageAnalysis(packageName, requestedVersion)
const { data: moduleReplacement } = useModuleReplacement(packageName)
const {
data: resolvedVersion,
status: versionStatus,
error: versionError,
} = await useResolvedVersion(packageName, requestedVersion)
if (
versionStatus.value === 'error' &&
versionError.value?.statusCode &&
versionError.value.statusCode >= 400 &&
versionError.value.statusCode < 500
) {
throw createError({
statusCode: 404,
statusMessage: $t('package.not_found'),
message: $t('package.not_found_message'),
})
}
const {
data: pkg,
status,
error,
} = usePackage(packageName, resolvedVersion.value ?? requestedVersion)
const displayVersion = computed(() => pkg.value?.requestedVersion ?? null)
// Process package description
const pkgDescription = useMarkdown(() => ({
text: pkg.value?.description ?? '',
packageName: pkg.value?.name,
}))
//copy package name
const { copied: copiedPkgName, copy: copyPkgName } = useClipboard({
source: packageName,
copiedDuring: 2000,
})
// Fetch dependency analysis (lazy, client-side)
// This is the same composable used by PackageVulnerabilityTree and PackageDeprecatedTree
const { data: vulnTree, status: vulnTreeStatus } = useDependencyAnalysis(
packageName,
() => resolvedVersion.value ?? '',
)
// Keep latestVersion for comparison (to show "(latest)" badge)
const latestVersion = computed(() => {
if (!pkg.value) return null
const latestTag = pkg.value['dist-tags']?.latest
if (!latestTag) return null
return pkg.value.versions[latestTag] ?? null
})
const deprecationNotice = computed(() => {
if (!displayVersion.value?.deprecated) return null
const isLatestDeprecated = !!latestVersion.value?.deprecated
// If latest is deprecated, show "package deprecated"
if (isLatestDeprecated) {
return {
type: 'package' as const,
message: displayVersion.value.deprecated,
}
}
// Otherwise show "version deprecated"
return { type: 'version' as const, message: displayVersion.value.deprecated }
})
const deprecationNoticeMessage = useMarkdown(() => ({
text: deprecationNotice.value?.message ?? '',
}))
const { isConnected, npmUser } = useConnector()
const deprecateModal = useTemplateRef<{ open: () => void }>('deprecateModal')
const isPackageOwner = computed(() => {
const maintainers = pkg.value?.maintainers
const user = npmUser.value
if (!maintainers?.length || !user) return false
const userLower = user.toLowerCase()
return maintainers.some((m: { name?: string }) => (m.name ?? '').toLowerCase() === userLower)
})
const sizeTooltip = computed(() => {
const chunks = [
displayVersion.value &&
displayVersion.value.dist.unpackedSize &&
$t('package.stats.size_tooltip.unpacked', {
size: formatBytes(displayVersion.value.dist.unpackedSize),
}),
installSize.value &&
installSize.value.dependencyCount &&
$t('package.stats.size_tooltip.total', {
size: formatBytes(installSize.value.totalSize),
count: installSize.value.dependencyCount,
}),
]
return chunks.filter(Boolean).join('\n')
})
const hasDependencies = computed(() => {
if (!displayVersion.value) return false
const deps = displayVersion.value.dependencies
const peerDeps = displayVersion.value.peerDependencies
const optionalDeps = displayVersion.value.optionalDependencies
return (
(deps && Object.keys(deps).length > 0) ||
(peerDeps && Object.keys(peerDeps).length > 0) ||
(optionalDeps && Object.keys(optionalDeps).length > 0)
)
})
// Vulnerability count for the stats banner
const vulnCount = computed(() => vulnTree.value?.totalCounts.total ?? 0)
const hasVulnerabilities = computed(() => vulnCount.value > 0)
// Total transitive dependencies count (from either vuln tree or install size)
// Subtract 1 to exclude the root package itself
const totalDepsCount = computed(() => {
if (vulnTree.value) {
return vulnTree.value.totalPackages - 1
}
if (installSize.value) {
return installSize.value.dependencyCount
}
return null
})
const repositoryUrl = computed(() => {
const repo = displayVersion.value?.repository
if (!repo?.url) return null
let url = normalizeGitUrl(repo.url)
// append `repository.directory` for monorepo packages
if (repo.directory) {
url = joinURL(`${url}/tree/HEAD`, repo.directory)
}
return url
})
const { meta: repoMeta, repoRef, stars, starsLink, forks, forksLink } = useRepoMeta(repositoryUrl)
const PROVIDER_ICONS: Record<string, string> = {
github: 'i-carbon:logo-github',
gitlab: 'i-simple-icons:gitlab',
bitbucket: 'i-simple-icons:bitbucket',
codeberg: 'i-simple-icons:codeberg',
gitea: 'i-simple-icons:gitea',
forgejo: 'i-simple-icons:forgejo',
gitee: 'i-simple-icons:gitee',
sourcehut: 'i-simple-icons:sourcehut',
tangled: 'i-custom:tangled',
radicle: 'i-carbon:network-3', // Radicle is a P2P network, using network icon
}
const repoProviderIcon = computed(() => {
const provider = repoRef.value?.provider
if (!provider) return 'i-carbon:logo-github'
return PROVIDER_ICONS[provider] ?? 'i-carbon:code'
})
const homepageUrl = computed(() => {
const homepage = displayVersion.value?.homepage
if (!homepage) return null
// Don't show homepage if it's the same as the repository URL
if (repositoryUrl.value && areUrlsEquivalent(homepage, repositoryUrl.value)) {
return null
}
return homepage
})
// Docs URL: use our generated API docs
const docsLink = computed(() => {
if (!resolvedVersion.value) return null
return `/package-docs/${pkg.value!.name}/v/${resolvedVersion.value}`
})
const fundingUrl = computed(() => {
let funding = displayVersion.value?.funding
if (Array.isArray(funding)) funding = funding[0]
if (!funding) return null
return typeof funding === 'string' ? funding : funding.url
})
function normalizeGitUrl(url: string): string {
return url
.replace(/^git\+/, '')
.replace(/^git:\/\//, 'https://')
.replace(/\.git$/, '')
.replace(/^ssh:\/\/git@github\.com/, 'https://github.com')
.replace(/^git@github\.com:/, 'https://github.com/')
}
// Check if a version has provenance/attestations
// The dist object may have attestations that aren't in the base type
function hasProvenance(version: PackumentVersion | null): boolean {
if (!version?.dist) return false
const dist = version.dist as NpmVersionDist
return !!dist.attestations
}
// Get @types package name if available (non-deprecated)
const typesPackageName = computed(() => {
if (!packageAnalysis.value) return null
if (packageAnalysis.value.types.kind !== '@types') return null
if (packageAnalysis.value.types.deprecated) return null
return packageAnalysis.value.types.packageName
})
// Executable detection for run command
const executableInfo = computed(() => {
if (!displayVersion.value || !pkg.value) return null
return getExecutableInfo(pkg.value.name, displayVersion.value.bin)
})
// Detect if package is binary-only (show only execute commands, no install)
const isBinaryOnly = computed(() => {
if (!displayVersion.value || !pkg.value) return false
return isBinaryOnlyPackage({
name: pkg.value.name,
bin: displayVersion.value.bin,
main: displayVersion.value.main,
module: displayVersion.value.module,
exports: displayVersion.value.exports,
})
})
// Detect if package uses create-* naming convention
const isCreatePkg = computed(() => {
if (!pkg.value) return false
return isCreatePackage(pkg.value.name)
})
// Get associated create-* package info (e.g., vite -> create-vite)
const createPackageInfo = computed(() => {
if (!packageAnalysis.value?.createPackage) return null
// Don't show if deprecated
if (packageAnalysis.value.createPackage.deprecated) return null
return packageAnalysis.value.createPackage
})
// Canonical URL for this package page
const canonicalUrl = computed(() => {
const base = `https://npmx.dev/package/${packageName.value}`
return requestedVersion.value ? `${base}/v/${requestedVersion.value}` : base
})
//atproto
// TODO: Maybe set this where it's not loaded here every load?
const { user } = useAtproto()
const authModal = useModal('auth-modal')
const { data: likesData } = useFetch(() => `/api/social/likes/${packageName.value}`, {
default: () => ({ totalLikes: 0, userHasLiked: false }),
server: false,
})
const isLikeActionPending = ref(false)
const likeAction = async () => {
if (user.value?.handle == null) {
authModal.open()
return
}
if (isLikeActionPending.value) return
const currentlyLiked = likesData.value?.userHasLiked ?? false
const currentLikes = likesData.value?.totalLikes ?? 0
// Optimistic update
likesData.value = {
totalLikes: currentlyLiked ? currentLikes - 1 : currentLikes + 1,
userHasLiked: !currentlyLiked,
}
isLikeActionPending.value = true
const result = await togglePackageLike(packageName.value, currentlyLiked, user.value?.handle)
isLikeActionPending.value = false
if (result.success) {
// Update with server response
likesData.value = result.data
} else {
// Revert on error
likesData.value = {
totalLikes: currentLikes,
userHasLiked: currentlyLiked,
}
}
}
useHead({
link: [{ rel: 'canonical', href: canonicalUrl }],
})
useSeoMeta({
title: () => (pkg.value?.name ? `${pkg.value.name} - npmx` : 'Package - npmx'),
description: () => pkg.value?.description ?? '',
})
onKeyStroke(
e => isKeyWithoutModifiers(e, '.') && !isEditableElement(e.target),
e => {
if (pkg.value == null || resolvedVersion.value == null) return
e.preventDefault()
navigateTo({
name: 'code',
params: {
path: [pkg.value.name, 'v', resolvedVersion.value],
},
})
},
{ dedupe: true },
)
onKeyStroke(
e => isKeyWithoutModifiers(e, 'd') && !isEditableElement(e.target),
e => {
if (!docsLink.value) return
e.preventDefault()
navigateTo(docsLink.value)
},
{ dedupe: true },
)
onKeyStroke(
e => isKeyWithoutModifiers(e, 'c') && !isEditableElement(e.target),
e => {
if (!pkg.value) return
e.preventDefault()
router.push({ path: '/compare', query: { packages: pkg.value.name } })
},
)
defineOgImageComponent('Package', {
name: () => pkg.value?.name ?? 'Package',
version: () => resolvedVersion.value ?? '',
downloads: () => (downloads.value ? $n(downloads.value.downloads) : ''),
license: () => pkg.value?.license ?? '',
stars: () => stars.value ?? 0,
primaryColor: '#60a5fa',
})
</script>
<template>
<main class="container flex-1 w-full py-8">
<PackageSkeleton v-if="status === 'pending'" />
<article v-else-if="status === 'success' && pkg" class="package-page">
<!-- Package header -->
<header
class="area-header sticky top-14 z-1 bg-[--bg] py-2 border-border"
ref="header"
:class="{ 'border-b': isHeaderPinned }"
>
<!-- Package name and version -->
<div class="flex items-baseline gap-2 sm:gap-3 flex-wrap min-w-0">
<div class="group relative flex flex-col items-start min-w-0">
<h1
class="font-mono text-2xl sm:text-3xl font-medium min-w-0 break-words"
:title="pkg.name"
>
<NuxtLink
v-if="orgName"
:to="{ name: 'org', params: { org: orgName } }"
class="text-fg-muted hover:text-fg transition-colors duration-200"
>
@{{ orgName }}
</NuxtLink>
<span v-if="orgName">/</span>
<span :class="{ 'text-fg-muted': orgName }">
{{ orgName ? pkg.name.replace(`@${orgName}/`, '') : pkg.name }}
</span>
</h1>
<!-- Floating copy button -->
<button
type="button"
@click="copyPkgName()"
class="copy-button absolute z-20 left-0 top-full inline-flex items-center gap-1 px-2 py-1 rounded border text-xs font-mono whitespace-nowrap transition-all duration-150 opacity-0 -translate-y-1 pointer-events-none group-hover:opacity-100 group-hover:translate-y-0 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:translate-y-0 focus-visible:pointer-events-auto"
:class="
copiedPkgName ? 'text-accent bg-accent/10' : 'text-fg-muted bg-bg border-border'
"
:aria-label="copiedPkgName ? $t('common.copied') : $t('package.copy_name')"
>
<span
:class="copiedPkgName ? 'i-carbon:checkmark' : 'i-carbon:copy'"
class="w-3.5 h-3.5"
aria-hidden="true"
/>
{{ copiedPkgName ? $t('common.copied') : $t('package.copy_name') }}
</button>
</div>
<span
v-if="resolvedVersion"
class="inline-flex items-baseline gap-1.5 font-mono text-base sm:text-lg text-fg-muted shrink-0"
>
<!-- Version resolution indicator (e.g., "latest → 4.2.0") -->
<template v-if="requestedVersion && resolvedVersion !== requestedVersion">
<span class="font-mono text-fg-muted text-sm">{{ requestedVersion }}</span>
<span class="i-carbon:arrow-right rtl-flip w-3 h-3" aria-hidden="true" />
</template>
<NuxtLink
v-if="requestedVersion && resolvedVersion !== requestedVersion"
:to="`/package/${pkg.name}/v/${resolvedVersion}`"
:title="$t('package.view_permalink')"
>{{ resolvedVersion }}</NuxtLink
>
<span v-else>v{{ resolvedVersion }}</span>
<a
v-if="hasProvenance(displayVersion)"
:href="`https://www.npmjs.com/package/${pkg.name}/v/${resolvedVersion}#provenance`"
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center justify-center gap-1.5 text-fg-muted hover:text-fg transition-colors duration-200 min-w-6 min-h-6"
:title="$t('package.verified_provenance')"
>
<span class="i-lucide-shield-check w-3.5 h-3.5 shrink-0" aria-hidden="true" />
</a>
<span
v-if="requestedVersion && latestVersion && resolvedVersion !== latestVersion.version"
class="text-fg-subtle text-sm shrink-0"
>{{ $t('package.not_latest') }}</span
>
</span>
<!-- Package metrics (module format, types) -->
<ClientOnly>
<PackageMetricsBadges
v-if="resolvedVersion"
:package-name="pkg.name"
:version="resolvedVersion"
:is-binary="isBinaryOnly"
class="self-baseline ms-1 sm:ms-2"
/>
<!-- Package likes -->
<button
@click="likeAction"
type="button"
class="inline-flex items-center gap-1.5 font-mono text-sm text-fg hover:text-fg-muted transition-colors duration-200"
:title="$t('package.links.like')"
>
<span
:class="
likesData?.userHasLiked
? 'i-lucide-heart-minus text-red-500'
: 'i-lucide-heart-plus'
"
class="w-4 h-4"
aria-hidden="true"
/>
<span>{{ formatCompactNumber(likesData?.totalLikes ?? 0, { decimals: 1 }) }}</span>
</button>
<template #fallback>
<div class="flex items-center gap-1.5 self-baseline ms-1 sm:ms-2">
<SkeletonBlock class="w-8 h-5 rounded" />
<SkeletonBlock class="w-12 h-5 rounded" />
<SkeletonBlock class="w-5 h-5 rounded" />
</div>
</template>
</ClientOnly>
<!-- Internal navigation: Docs + Code + Compare (hidden on mobile, shown in external links instead) -->
<nav
v-if="resolvedVersion"
:aria-label="$t('package.navigation')"
class="hidden sm:flex items-center gap-0.5 p-0.5 bg-bg-subtle border border-border-subtle rounded-md shrink-0 ms-auto self-center"
>
<NuxtLink
v-if="docsLink"
:to="docsLink"
class="px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 border border-transparent text-fg-subtle hover:text-fg hover:bg-bg hover:shadow hover:border-border inline-flex items-center gap-1.5"
aria-keyshortcuts="d"
>
<span class="i-carbon:document w-3 h-3" aria-hidden="true" />
{{ $t('package.links.docs') }}
<kbd
class="inline-flex items-center justify-center w-4 h-4 text-xs bg-bg-muted border border-border rounded"
aria-hidden="true"
>
d
</kbd>
</NuxtLink>
<NuxtLink
:to="`/package-code/${pkg.name}/v/${resolvedVersion}`"
class="px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 border border-transparent text-fg-subtle hover:text-fg hover:bg-bg hover:shadow hover:border-border inline-flex items-center gap-1.5"
aria-keyshortcuts="."
>
<span class="i-carbon:code w-3 h-3" aria-hidden="true" />
{{ $t('package.links.code') }}
<kbd
class="inline-flex items-center justify-center w-4 h-4 text-xs bg-bg-muted border border-border rounded"
aria-hidden="true"
>
.
</kbd>
</NuxtLink>
<NuxtLink
:to="{ path: '/compare', query: { packages: pkg.name } }"
class="px-2 py-1.5 font-mono text-xs rounded transition-colors duration-150 border border-transparent text-fg-subtle hover:text-fg hover:bg-bg hover:shadow hover:border-border inline-flex items-center gap-1.5"
aria-keyshortcuts="c"
>
<span class="i-carbon:compare w-3 h-3" aria-hidden="true" />
{{ $t('package.links.compare') }}
<kbd
class="inline-flex items-center justify-center w-4 h-4 text-xs bg-bg-muted border border-border rounded"
aria-hidden="true"
>
c
</kbd>
</NuxtLink>
</nav>
</div>
</header>
<!-- Package details -->
<section class="area-details">
<div class="mb-4">
<!-- Description container with min-height to prevent CLS -->
<div class="max-w-2xl min-h-[4.5rem]">
<p v-if="pkgDescription" class="text-fg-muted text-base m-0">
<span v-html="pkgDescription" />
</p>
<p v-else class="text-fg-subtle text-base m-0 italic">
{{ $t('package.no_description') }}
</p>
</div>
<!-- External links -->
<ul class="flex flex-wrap items-center gap-x-3 gap-y-1.5 sm:gap-4 list-none m-0 p-0 mt-3">
<li v-if="repositoryUrl">
<a
:href="repositoryUrl"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="w-4 h-4" :class="repoProviderIcon" aria-hidden="true" />
<span v-if="repoRef">
{{ repoRef.owner }}<span class="opacity-50">/</span>{{ repoRef.repo }}
</span>
<span v-else>{{ $t('package.links.repo') }}</span>
</a>
</li>
<li v-if="repositoryUrl && repoMeta && starsLink">
<a
:href="starsLink"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="w-4 h-4 i-carbon:star" aria-hidden="true" />
{{ formatCompactNumber(stars, { decimals: 1 }) }}
</a>
</li>
<li v-if="forks && forksLink">
<a
:href="forksLink"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:fork w-4 h-4" aria-hidden="true" />
{{ formatCompactNumber(forks, { decimals: 1 }) }}
</a>
</li>
<li v-if="homepageUrl">
<a
:href="homepageUrl"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:link w-4 h-4" aria-hidden="true" />
{{ $t('package.links.homepage') }}
</a>
</li>
<li v-if="displayVersion?.bugs?.url">
<a
:href="displayVersion.bugs.url"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:warning w-4 h-4" aria-hidden="true" />
{{ $t('package.links.issues') }}
</a>
</li>
<li>
<a
:href="`https://www.npmjs.com/package/${pkg.name}`"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
:title="$t('common.view_on_npm')"
>
<span class="i-carbon:logo-npm w-4 h-4" aria-hidden="true" />
npm
</a>
</li>
<li v-if="jsrInfo?.exists && jsrInfo.url">
<a
:href="jsrInfo.url"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
:title="$t('badges.jsr.title')"
>
<span class="i-simple-icons:jsr w-4 h-4" aria-hidden="true" />
{{ $t('package.links.jsr') }}
</a>
</li>
<li v-if="fundingUrl">
<a
:href="fundingUrl"
target="_blank"
rel="noopener noreferrer"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:favorite w-4 h-4" aria-hidden="true" />
{{ $t('package.links.fund') }}
</a>
</li>
<!-- Mobile-only: Docs + Code + Compare links -->
<li v-if="docsLink && displayVersion" class="sm:hidden">
<NuxtLink
:to="docsLink"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:document w-4 h-4" aria-hidden="true" />
{{ $t('package.links.docs') }}
</NuxtLink>
</li>
<li v-if="resolvedVersion" class="sm:hidden">
<NuxtLink
:to="`/package-code/${pkg.name}/v/${resolvedVersion}`"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:code w-4 h-4" aria-hidden="true" />
{{ $t('package.links.code') }}
</NuxtLink>
</li>
<li class="sm:hidden">
<NuxtLink
:to="{ path: '/compare', query: { packages: pkg.name } }"
class="link-subtle font-mono text-sm inline-flex items-center gap-1.5"
>
<span class="i-carbon:compare w-4 h-4" aria-hidden="true" />
{{ $t('package.links.compare') }}
</NuxtLink>
</li>
</ul>
</div>
<div
v-if="deprecationNotice"
class="border border-red-400 bg-red-400/10 rounded-lg px-3 py-2 text-base text-red-400"
>
<h2 class="font-medium mb-2">
{{
deprecationNotice.type === 'package'
? $t('package.deprecation.package')
: $t('package.deprecation.version')
}}
</h2>
<p v-if="deprecationNoticeMessage" class="text-base m-0">
<span v-html="deprecationNoticeMessage" />
</p>
<p v-else class="text-base m-0 italic">
{{ $t('package.deprecation.no_reason') }}
</p>
</div>
<!-- Stats grid -->
<dl
class="grid grid-cols-2 sm:grid-cols-11 gap-3 sm:gap-4 py-4 sm:py-6 mt-4 sm:mt-6 border-t border-b border-border"
>
<div class="space-y-1 sm:col-span-2">
<dt class="text-xs text-fg-subtle uppercase tracking-wider">
{{ $t('package.stats.license') }}
</dt>
<dd class="font-mono text-sm text-fg">
<LicenseDisplay v-if="pkg.license" :license="pkg.license" />
<span v-else>{{ $t('package.license.none') }}</span>
</dd>
</div>
<div class="space-y-1 sm:col-span-2">
<dt class="text-xs text-fg-subtle uppercase tracking-wider">
{{ $t('package.stats.deps') }}
</dt>
<dd class="font-mono text-sm text-fg flex items-center justify-start gap-2">
<!-- Direct deps (muted) -->
<span class="text-fg-muted">{{ getDependencyCount(displayVersion) }}</span>
<!-- Separator and total transitive deps -->
<span class="text-fg-subtle mx-1">/</span>
<ClientOnly>
<span
v-if="
vulnTreeStatus === 'pending' || (installSizeStatus === 'pending' && !vulnTree)
"
class="inline-flex items-center gap-1 text-fg-subtle"
>
<span
class="i-carbon:circle-dash w-3 h-3 motion-safe:animate-spin"
aria-hidden="true"
/>
</span>
<span v-else-if="totalDepsCount !== null">{{ totalDepsCount }}</span>
<span v-else class="text-fg-subtle">-</span>
<template #fallback>
<span class="text-fg-subtle">-</span>
</template>
</ClientOnly>
<a
v-if="getDependencyCount(displayVersion) > 0"
:href="`https://npmgraph.js.org/?q=${pkg.name}`"
target="_blank"
rel="noopener noreferrer"
class="text-fg-subtle hover:text-fg transition-colors duration-200 inline-flex items-center justify-center min-w-6 min-h-6 -m-1 p-1 focus-visible:outline-accent/70 rounded"
:title="$t('package.stats.view_dependency_graph')"
>
<span class="i-carbon:network-3 w-3.5 h-3.5" aria-hidden="true" />
<span class="sr-only">{{ $t('package.stats.view_dependency_graph') }}</span>
</a>
<a
v-if="getDependencyCount(displayVersion) > 0"
:href="`https://node-modules.dev/grid/depth#install=${pkg.name}${resolvedVersion ? `@${resolvedVersion}` : ''}`"
target="_blank"
rel="noopener noreferrer"
class="text-fg-subtle hover:text-fg transition-colors duration-200 inline-flex items-center justify-center min-w-6 min-h-6 -m-1 p-1 focus-visible:outline-accent/70 rounded"
:title="$t('package.stats.inspect_dependency_tree')"
>
<span class="i-lucide-view w-3.5 h-3.5" aria-hidden="true" />
<span class="sr-only">{{ $t('package.stats.inspect_dependency_tree') }}</span>
</a>
</dd>
</div>
<div class="space-y-1 sm:col-span-3">
<dt class="text-xs text-fg-subtle uppercase tracking-wider flex items-center gap-1">
{{ $t('package.stats.install_size') }}
<TooltipApp :text="sizeTooltip">
<span class="i-carbon:information w-3 h-3 text-fg-subtle" aria-hidden="true" />
</TooltipApp>
</dt>
<dd class="font-mono text-sm text-fg">
<!-- Package size (greyed out) -->
<span class="text-fg-muted">
<span v-if="displayVersion?.dist?.unpackedSize">
{{ formatBytes(displayVersion.dist.unpackedSize) }}
</span>
<span v-else>-</span>
</span>
<!-- Separator and install size -->
<span class="text-fg-subtle mx-1">/</span>
<span
v-if="installSizeStatus === 'pending'"
class="inline-flex items-center gap-1 text-fg-subtle"
>
<span
class="i-carbon:circle-dash w-3 h-3 motion-safe:animate-spin"
aria-hidden="true"
/>
</span>
<span v-else-if="installSize?.totalSize">
{{ formatBytes(installSize.totalSize) }}
</span>
<span v-else class="text-fg-subtle">-</span>
</dd>
</div>
<!-- Vulnerabilities count -->
<ClientOnly>
<div class="space-y-1 sm:col-span-2">
<dt class="text-xs text-fg-subtle uppercase tracking-wider">
{{ $t('package.stats.vulns') }}
</dt>
<dd class="font-mono text-sm text-fg">
<span
v-if="vulnTreeStatus === 'pending' || vulnTreeStatus === 'idle'"
class="inline-flex items-center gap-1 text-fg-subtle"
>
<span
class="i-carbon:circle-dash w-3 h-3 motion-safe:animate-spin"
aria-hidden="true"
/>
</span>
<span v-else-if="vulnTreeStatus === 'success'">
<span v-if="hasVulnerabilities" class="text-amber-500">{{ vulnCount }}</span>
<span v-else class="inline-flex items-center gap-1 text-fg-muted">
<span class="i-carbon:checkmark w-3 h-3" aria-hidden="true" />
0
</span>
</span>
<span v-else class="text-fg-subtle">-</span>
</dd>
</div>
<template #fallback>
<div class="space-y-1 sm:col-span-2">
<dt class="text-xs text-fg-subtle uppercase tracking-wider">
{{ $t('package.stats.vulns') }}
</dt>
<dd class="font-mono text-sm text-fg-subtle">-</dd>
</div>
</template>
</ClientOnly>
<div
v-if="resolvedVersion && pkg.time?.[resolvedVersion]"
class="space-y-1 sm:col-span-2"
>
<dt
class="text-xs text-fg-subtle uppercase tracking-wider"
:title="
$t('package.stats.published_tooltip', {
package: pkg.name,
version: resolvedVersion,
})
"
>
{{ $t('package.stats.published') }}
</dt>
<dd class="font-mono text-sm text-fg">
<DateTime :datetime="pkg.time[resolvedVersion]!" date-style="medium" />
</dd>
</div>
</dl>
<!-- Skills Modal -->
<ClientOnly>
<PackageSkillsModal
:skills="skillsData?.skills ?? []"
:package-name="pkg.name"
:version="resolvedVersion || undefined"
/>
</ClientOnly>
</section>
<!-- Binary-only packages: Show only execute command (no install) -->
<section v-if="isBinaryOnly" class="area-install scroll-mt-20">
<div class="flex flex-wrap items-center justify-between mb-3">
<h2 id="run-heading" class="text-xs text-fg-subtle uppercase tracking-wider">
{{ $t('package.run.title') }}
</h2>
<!-- Package manager dropdown -->
<PackageManagerSelect />
</div>
<div
role="tabpanel"
:id="`pm-panel-${activePmId}`"
:aria-labelledby="`pm-tab-${activePmId}`"
>
<TerminalExecute
:package-name="pkg.name"
:jsr-info="jsrInfo"
:is-create-package="isCreatePkg"
/>
</div>
</section>
<!-- Regular packages: Install command with optional run command -->
<section v-else id="get-started" class="area-install scroll-mt-20">
<div class="flex flex-wrap items-center justify-between mb-3">
<h2