Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5d3bea5
feat: Add download button component and install size types
Adebesin-Cell Feb 22, 2026
6a28f59
fix: Update function to use correct translation function
Adebesin-Cell Feb 22, 2026
cf35100
feat: Add tarball URLs for dependencies
Adebesin-Cell Feb 22, 2026
91e2933
style: Add tarball URLs to test dependencies
Adebesin-Cell Feb 23, 2026
7a6e29e
feat(Button, PackageDownloadButton): Add async download functionality
Adebesin-Cell Feb 24, 2026
14912af
fix: address CodeRabbit review feedback
Adebesin-Cell Mar 17, 2026
e4b803a
fix: installSize prop type mismatch (undefined → null)
Adebesin-Cell Mar 17, 2026
16e9dd7
fix: wrap DownloadButton in ClientOnly to prevent hydration mismatch
Adebesin-Cell Mar 17, 2026
6ecfc4d
fix: add download button skeleton to package loading state
Adebesin-Cell Mar 17, 2026
60aac4a
Merge branch 'main' into feat/download-button
Adebesin-Cell Mar 17, 2026
f393057
fix: remove useId() and ClientOnly from DownloadButton
Adebesin-Cell Mar 17, 2026
e98977e
fix: add missing composable imports to package page
Adebesin-Cell Mar 17, 2026
70f9d59
fix: make DownloadButton SSR-safe with useId and CSS reduced motion
Adebesin-Cell Mar 19, 2026
c8e7774
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 19, 2026
36461d7
fix: resolve hydration mismatch on package page
Adebesin-Cell Mar 19, 2026
401e44f
fix: add tarballUrl to dependency-resolver test expectation
Adebesin-Cell Mar 19, 2026
989dfa3
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 19, 2026
cef21bb
Update app/components/Package/DownloadButton.vue
Adebesin-Cell Mar 19, 2026
ba7281d
refactor: replace installSize prop with dependencies in DownloadButton
Adebesin-Cell Mar 19, 2026
1c7a680
fix: add missing useI18n import in DownloadButton
Adebesin-Cell Mar 19, 2026
b8c7570
fix: use $t auto-import instead of useI18n in DownloadButton
Adebesin-Cell Mar 19, 2026
cf724bd
fix: use static i18n keys in DownloadButton for static analysis
Adebesin-Cell Mar 19, 2026
b0de596
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 19, 2026
b1ee806
feat: show loading state for dependencies download option
Adebesin-Cell Mar 19, 2026
a91db2b
fix: hide dependencies option when package has no deps
Adebesin-Cell Mar 19, 2026
8f9ac17
feat: make dependencies download script cross-platform using Node.js
Adebesin-Cell Mar 19, 2026
eaa2de2
fix: correct dependencies download label from .sh to .js
Adebesin-Cell Mar 20, 2026
19eb93c
Merge branch 'main' into feat/download-button
Adebesin-Cell Mar 20, 2026
eb8c0da
fix: use Intl.Segmenter for avatar first character extraction
Adebesin-Cell Mar 20, 2026
c76c15c
Revert "fix: use Intl.Segmenter for avatar first character extraction"
Adebesin-Cell Mar 20, 2026
5e0882f
fix: remove download dependencies script option from download button
Adebesin-Cell Mar 21, 2026
f48b384
Merge branch 'main' into feat/download-button
Adebesin-Cell Mar 21, 2026
992b9ea
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 21, 2026
1b7487a
Merge branch 'main' into feat/download-button
ghostdevv Mar 21, 2026
b56aa2e
refactor: simplify button and css
ghostdevv Mar 21, 2026
52a9dcb
refactor: simplify
ghostdevv Mar 21, 2026
02d6bb1
Merge remote-tracking branch 'origin/main' into feat/download-button
ghostdevv Mar 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions app/components/Package/DownloadButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script setup lang="ts">
import type { SlimPackumentVersion } from '#shared/types'

const props = defineProps<{
packageName: string
version: SlimPackumentVersion
}>()

const loading = shallowRef(false)

async function getDownloadUrl(tarballUrl: string) {
try {
const response = await fetch(tarballUrl)
if (!response.ok) {
throw new Error(`Failed to fetch tarball (${response.status})`)
}
const blob = await response.blob()
return URL.createObjectURL(blob)
} catch (error) {
// oxlint-disable-next-line no-console -- error logging
console.error('failed to fetch tarball', { cause: error })
return null
}
}

async function downloadPackage() {
const tarballUrl = props.version.dist.tarball
if (!tarballUrl) return

if (loading.value) return
loading.value = true

const downloadUrl = await getDownloadUrl(tarballUrl)

const link = document.createElement('a')
link.href = downloadUrl ?? tarballUrl
link.download = `${props.packageName.replace(/\//g, '__')}-${props.version.version}.tgz`
document.body.appendChild(link)
link.click()
document.body.removeChild(link)

if (downloadUrl) {
URL.revokeObjectURL(downloadUrl)
}

loading.value = false
}
</script>

<template>
<TooltipApp :text="$t('package.download.tarball')">
<ButtonBase
ref="triggerRef"
v-bind="$attrs"
type="button"
@click="downloadPackage"
:disabled="loading"
class="border-border-subtle bg-bg-subtle! text-xs text-fg-muted hover:enabled:(text-fg border-border-hover)"
>
<span
class="size-[1em]"
aria-hidden="true"
:class="loading ? 'i-lucide:loader-circle animate-spin' : 'i-lucide:download'"
/>
{{ $t('package.download.button') }}
</ButtonBase>
</TooltipApp>
</template>
7 changes: 5 additions & 2 deletions app/components/Package/Skeleton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@
<h2 class="text-xs font-mono text-fg-subtle uppercase tracking-wider">
{{ $t('package.get_started.title') }}
</h2>
<!-- Package manager select placeholder -->
<SkeletonInline class="h-7 w-24 rounded" />
<!-- Download button + Package manager select placeholder -->
<div class="flex items-center gap-2">
<SkeletonInline class="h-7 w-24 rounded" />
<SkeletonInline class="h-7 w-24 rounded" />
</div>
</div>
<!-- Terminal-style install command — matches TerminalInstall.vue -->
<div class="bg-bg-subtle border border-border rounded-lg overflow-hidden">
Expand Down
11 changes: 9 additions & 2 deletions app/pages/package/[[org]]/[name].vue
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,15 @@ const showSkeleton = shallowRef(false)
{{ $t('package.get_started.title') }}
</LinkBase>
</h2>
<!-- Package manager dropdown -->
<PackageManagerSelect />
<!-- Package manager dropdown + Download button -->
<div class="flex items-center gap-2">
<PackageDownloadButton
v-if="displayVersion"
:package-name="pkg.name"
:version="displayVersion"
/>
<PackageManagerSelect />
</div>
</div>
<div>
<div
Expand Down
4 changes: 4 additions & 0 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,10 @@
"b": "{size} B",
"kb": "{size} kB",
"mb": "{size} MB"
},
"download": {
"button": "Download",
"tarball": "Download Tarball as .tar.gz"
}
},
"connector": {
Expand Down
12 changes: 12 additions & 0 deletions i18n/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,18 @@
}
},
"additionalProperties": false
},
"download": {
"type": "object",
"properties": {
"button": {
"type": "string"
},
"tarball": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
4 changes: 3 additions & 1 deletion server/utils/dependency-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface ResolvedPackage {
name: string
version: string
size: number
tarballUrl: string
optional: boolean
/** Depth level (only when trackDepth is enabled) */
depth?: DependencyDepth
Expand Down Expand Up @@ -152,13 +153,14 @@ export async function resolveDependencyTree(
if (!matchesPlatform(versionData)) return

const size = (versionData.dist as { unpackedSize?: number })?.unpackedSize ?? 0
const tarballUrl = versionData.dist?.tarball ?? ''
const key = `${name}@${version}`

// Build path for this package (path to parent + this package with version)
const currentPath = [...path, `${name}@${version}`]

if (!resolved.has(key)) {
const pkg: ResolvedPackage = { name, version, size, optional }
const pkg: ResolvedPackage = { name, version, size, tarballUrl, optional }
if (options.trackDepth) {
pkg.depth = level === 0 ? 'root' : level === 1 ? 'direct' : 'transitive'
pkg.path = currentPath
Expand Down
1 change: 1 addition & 0 deletions server/utils/install-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const calculateInstallSize = defineCachedFunction(
name: dep.name,
version: dep.version,
size: dep.size,
tarballUrl: dep.tarballUrl,
optional: dep.optional || undefined,
})
totalSize += dep.size
Expand Down
1 change: 1 addition & 0 deletions shared/types/install-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface DependencySize {
name: string
version: string
size: number
tarballUrl: string
/** True if this is an optional dependency */
optional?: boolean
}
Expand Down
18 changes: 18 additions & 0 deletions test/nuxt/a11y.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ import {
PackageListControls,
PackageListToolbar,
PackageMaintainers,
PackageDownloadButton,
PackageManagerSelect,
PackageMetricsBadges,
PackagePlaygrounds,
Expand Down Expand Up @@ -2983,6 +2984,23 @@ describe('component accessibility audits', () => {
})
})

describe('PackageDownloadButton', () => {
it('should have no accessibility violations', async () => {
const component = await mountSuspended(PackageDownloadButton, {
props: {
packageName: 'vue',
version: {
version: '3.5.0',
dist: { tarball: 'https://registry.npmjs.org/vue/-/vue-3.5.0.tgz' },
} as any,
dependencies: null,
},
})
const results = await runAxe(component)
expect(results.violations).toEqual([])
})
})

// Diff components
describe('DiffFileTree', () => {
const mockFiles = [
Expand Down
Loading
Loading