From 0a8cb1cdac0efba8135f0ad5114170ccf1010ec0 Mon Sep 17 00:00:00 2001 From: eugene <135520429+outslept@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:38:37 +0000 Subject: [PATCH 01/18] fix: preserve mailto links in package readmes (#3489) --- server/utils/mdKit.ts | 7 +++-- server/utils/readme.ts | 5 +++ test/unit/server/utils/readme.spec.ts | 45 +++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/server/utils/mdKit.ts b/server/utils/mdKit.ts index 8150de86ad..8c92db5de4 100644 --- a/server/utils/mdKit.ts +++ b/server/utils/mdKit.ts @@ -114,8 +114,11 @@ export function createLink(processLink: ProcessLinkFn): RendererApi['link'] { if (!resolvedHref) return resolvedText // prevents package@1.0.0 being made into an email - if (href.startsWith('mailto:') && !EMAIL_REGEX.test(plainText)) { - return resolvedText + if (href.startsWith('mailto:')) { + const email = href.slice('mailto:'.length).split('?')[0] ?? '' + if (!EMAIL_REGEX.test(email)) { + return resolvedText + } } return `${resolvedText}` diff --git a/server/utils/readme.ts b/server/utils/readme.ts index 791fff7bc0..debb393c12 100644 --- a/server/utils/readme.ts +++ b/server/utils/readme.ts @@ -236,6 +236,11 @@ function resolveUrl( } return url } + // Email addresses are URLs too (`mailto:tj@example.com`), but they point to + // a contact address, not to a file in the repository, so leave them as-is. + if (parsed.protocol === 'mailto:') { + return url + } } catch { // Invalid URL, fall through to resolve as relative } diff --git a/test/unit/server/utils/readme.spec.ts b/test/unit/server/utils/readme.spec.ts index 6126f2f4fa..d3a339f864 100644 --- a/test/unit/server/utils/readme.spec.ts +++ b/test/unit/server/utils/readme.spec.ts @@ -422,6 +422,51 @@ describe('Markdown File URL Resolution', () => { }) }) + describe('mailto links and email addresses', () => { + it('leaves autolinked email addresses unchanged with repository info', async () => { + const repoInfo = createRepoInfo({ + owner: 'debug-js', + repo: 'debug', + }) + const markdown = `Copyright (c) 2014-2017 TJ Holowaychuk ` + const result = await renderReadmeHtml(markdown, 'debug', repoInfo) + expect(result.html).toContain('href="mailto:tj@vision-media.ca"') + expect(result.html).not.toContain('raw.githubusercontent.com') + }) + + it('leaves markdown mailto: links with custom text unchanged', async () => { + const repoInfo = createRepoInfo() + const markdown = `[Contact TJ](mailto:tj@vision-media.ca?subject=Hello)` + const result = await renderReadmeHtml(markdown, 'test-pkg', repoInfo) + expect(result.html).toContain('href="mailto:tj@vision-media.ca?subject=Hello"') + expect(result.html).toContain('>Contact TJ') + expect(result.html).not.toContain('raw.githubusercontent.com') + }) + + it('leaves raw HTML mailto: links unchanged with repository info', async () => { + const repoInfo = createRepoInfo() + const markdown = `Email` + const result = await renderReadmeHtml(markdown, 'test-pkg', repoInfo) + expect(result.html).toContain('href="mailto:tj@vision-media.ca"') + expect(result.html).not.toContain('raw.githubusercontent.com') + }) + + it('leaves mailto: links unchanged without repository info (no jsdelivr fallback)', async () => { + const markdown = `Contact ` + const result = await renderReadmeHtml(markdown, 'test-pkg') + expect(result.html).toContain('href="mailto:tj@vision-media.ca"') + expect(result.html).not.toContain('cdn.jsdelivr.net') + }) + + it('does not turn package@version into a mailto: link', async () => { + const repoInfo = createRepoInfo() + const markdown = `Install debug@4.3.4 to reproduce` + const result = await renderReadmeHtml(markdown, 'test-pkg', repoInfo) + expect(result.html).toContain('debug@4.3.4') + expect(result.html).not.toContain('mailto:') + }) + }) + describe('different git providers', () => { it('uses correct blob URL format for GitLab', async () => { const repoInfo = createRepoInfo({ From f2378cfd225aa9b2a0e078cf41fcc34feb6bc2bf Mon Sep 17 00:00:00 2001 From: Felix Schneider <99918022+trueberryless@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:39:38 +0000 Subject: [PATCH 02/18] fix: fetch bluesky profiles in batches of 25 (#3490) --- app/pages/blog/alpha-release.md | 2 +- modules/blog.ts | 36 +++++--- .../atproto/bluesky-author-profiles.get.ts | 25 ++++-- shared/utils/constants.ts | 2 + .../atproto/bluesky-author-profiles.spec.ts | 87 +++++++++++++++++++ 5 files changed, 131 insertions(+), 21 deletions(-) create mode 100644 test/unit/server/api/atproto/bluesky-author-profiles.spec.ts diff --git a/app/pages/blog/alpha-release.md b/app/pages/blog/alpha-release.md index 1a9483ff6b..2700fe5294 100644 --- a/app/pages/blog/alpha-release.md +++ b/app/pages/blog/alpha-release.md @@ -146,7 +146,7 @@ headline="Read more from the community" { url: 'https://blog.trueberryless.org/blog/npmx/', title: 'Rising community at tomorrow\'s horizon', - authorHandle: 'trueberryless.org', + authorHandle: 'felixs.dev', description: 'Telling the story of a newly founded community.' }, { diff --git a/modules/blog.ts b/modules/blog.ts index da76db2411..abdf68cdc7 100644 --- a/modules/blog.ts +++ b/modules/blog.ts @@ -14,7 +14,7 @@ import { type ResolvedAuthor, } from '../shared/schemas/blog' import { isProduction } from '../config/env' -import { BLUESKY_API } from '../shared/utils/constants' +import { BLUESKY_API, BLUESKY_GET_PROFILES_MAX } from '../shared/utils/constants' import { glob, mkdir, writeFile } from 'node:fs/promises' import { existsSync, readFileSync } from 'node:fs' import { imageMeta } from 'image-meta' @@ -32,23 +32,31 @@ async function fetchBlueskyAvatars( if (handles.length === 0) return avatarMap try { - const params = new URLSearchParams() - for (const handle of handles) { - params.append('actors', handle) - } + const profiles: Array<{ handle: string; avatar?: string }> = [] - const response = await fetch( - `${BLUESKY_API}/xrpc/app.bsky.actor.getProfiles?${params.toString()}`, - ) + // getProfiles rejects the whole request above its actor limit, so fetch in batches + for (let i = 0; i < handles.length; i += BLUESKY_GET_PROFILES_MAX) { + const params = new URLSearchParams() + for (const handle of handles.slice(i, i + BLUESKY_GET_PROFILES_MAX)) { + params.append('actors', handle) + } - if (!response.ok) { - console.warn(`[blog] Failed to fetch Bluesky profiles: ${response.status}`) - return avatarMap - } + const response = await fetch( + `${BLUESKY_API}/xrpc/app.bsky.actor.getProfiles?${params.toString()}`, + ) - const data = (await response.json()) as { profiles: Array<{ handle: string; avatar?: string }> } + if (!response.ok) { + console.warn(`[blog] Failed to fetch Bluesky profiles: ${response.status}`) + continue + } + + const data = (await response.json()) as { + profiles: Array<{ handle: string; avatar?: string }> + } + profiles.push(...data.profiles) + } - for (const profile of data.profiles) { + for (const profile of profiles) { if (profile.avatar) { const hash = crypto.createHash('sha256').update(profile.avatar).digest('hex') const dest = join(imagesDir, `${hash}.png`) diff --git a/server/api/atproto/bluesky-author-profiles.get.ts b/server/api/atproto/bluesky-author-profiles.get.ts index d423278f20..43ac25c348 100644 --- a/server/api/atproto/bluesky-author-profiles.get.ts +++ b/server/api/atproto/bluesky-author-profiles.get.ts @@ -1,6 +1,10 @@ import * as v from 'valibot' import crypto from 'node:crypto' -import { CACHE_MAX_AGE_ONE_DAY, BLUESKY_API } from '#shared/utils/constants' +import { + CACHE_MAX_AGE_ONE_DAY, + BLUESKY_API, + BLUESKY_GET_PROFILES_MAX, +} from '#shared/utils/constants' import { AuthorSchema } from '#shared/schemas/blog' import { Client } from '@atproto/lex' import type { Author, ResolvedAuthor } from '#shared/schemas/blog' @@ -39,7 +43,7 @@ export default defineCachedEventHandler( return { authors: [] } } - const handles = authors.map(a => a.blueskyHandle).filter(handle => handle != null) + const handles = [...new Set(authors.map(a => a.blueskyHandle).filter(handle => handle != null))] if (handles.length === 0) { return { @@ -47,14 +51,23 @@ export default defineCachedEventHandler( } } + // getProfiles rejects the whole request above its actor limit, so fetch in batches const client = new Client({ service: BLUESKY_API }) - const response = await client - .call(app.bsky.actor.getProfiles, { actors: handles }) - .catch(() => ({ profiles: [] })) + const batches: Promise<{ profiles: { handle: string; avatar?: string }[] }>[] = [] + for (let i = 0; i < handles.length; i += BLUESKY_GET_PROFILES_MAX) { + const actors = handles.slice(i, i + BLUESKY_GET_PROFILES_MAX) + batches.push( + client.call(app.bsky.actor.getProfiles, { actors }).catch(error => { + console.warn('[bluesky-author-profiles] Failed to fetch profiles batch:', error) + return { profiles: [] } + }), + ) + } + const profiles = (await Promise.all(batches)).flatMap(batch => batch.profiles) const avatarMap = new Map() - for (const profile of response.profiles) { + for (const profile of profiles) { if (profile.avatar) { avatarMap.set(profile.handle, profile.avatar) } diff --git a/shared/utils/constants.ts b/shared/utils/constants.ts index 6d3a93fb75..369e3772d2 100644 --- a/shared/utils/constants.ts +++ b/shared/utils/constants.ts @@ -15,6 +15,8 @@ export const NPMX_SITE = 'https://npmx.dev' export const NPMX_DOCS_SITE = 'https://docs.npmx.dev' export const NPMX_DID = 'did:plc:u5zp7npt5kpueado77kuihyz' export const BLUESKY_API = 'https://public.api.bsky.app' +/** Max actors per `app.bsky.actor.getProfiles` request; larger requests fail with a 400 */ +export const BLUESKY_GET_PROFILES_MAX = 25 export const BLUESKY_COMMENTS_REQUEST = '/api/atproto/bluesky-comments' export const NPM_REGISTRY = 'https://registry.npmjs.org' export const NPM_API = 'https://api.npmjs.org' diff --git a/test/unit/server/api/atproto/bluesky-author-profiles.spec.ts b/test/unit/server/api/atproto/bluesky-author-profiles.spec.ts new file mode 100644 index 0000000000..861d54a311 --- /dev/null +++ b/test/unit/server/api/atproto/bluesky-author-profiles.spec.ts @@ -0,0 +1,87 @@ +import type * as AtprotoLex from '@atproto/lex' +import { afterAll, beforeEach, describe, expect, it, vi } from 'vite-plus/test' +import type { H3Event } from 'h3' + +const callMock = vi.hoisted(() => vi.fn()) +const getQueryMock = vi.hoisted(() => vi.fn()) + +vi.mock('@atproto/lex', async importOriginal => ({ + ...(await importOriginal()), + Client: class { + call = callMock + }, +})) + +vi.stubGlobal('defineCachedEventHandler', (fn: Function) => fn) +// The route uses Nuxt's auto-imported h3 helpers, which unit tests do not get. +vi.stubGlobal('getQuery', getQueryMock) +vi.stubGlobal( + 'createError', + vi.fn((options: unknown) => options), +) + +const handler = (await import('#server/api/atproto/bluesky-author-profiles.get')).default +const fakeEvent = {} as H3Event + +function authorsWithHandles(count: number) { + return Array.from({ length: count }, (_, i) => ({ + name: `Author ${i}`, + blueskyHandle: `author-${i}.bsky.social`, + })) +} + +function profilesFor(actors: string[]) { + return { profiles: actors.map(handle => ({ handle, avatar: `https://cdn.test/${handle}` })) } +} + +afterAll(() => { + vi.unstubAllGlobals() +}) + +describe('bluesky author profiles API', () => { + beforeEach(() => { + vi.clearAllMocks() + // Like the real API, reject the whole request above 25 actors + callMock.mockImplementation(async (_method: unknown, { actors }: { actors: string[] }) => { + if (actors.length > 25) throw new Error(`array too big (maximum 25, got ${actors.length})`) + return profilesFor(actors) + }) + }) + + it('fetches more than 25 authors in batches and resolves every avatar', async () => { + const authors = authorsWithHandles(27) + getQueryMock.mockReturnValue({ authors: JSON.stringify(authors) }) + + const { authors: resolved } = await handler(fakeEvent) + + expect(callMock.mock.calls.map(([, { actors }]) => actors.length)).toEqual([25, 2]) + expect(resolved.map(author => author.avatar)).toEqual( + authors.map(author => `https://cdn.test/${author.blueskyHandle}`), + ) + }) + + it('requests a handle only once when several articles share an author', async () => { + const authors = [ + ...authorsWithHandles(25), + { name: 'Again', blueskyHandle: 'author-0.bsky.social' }, + ] + getQueryMock.mockReturnValue({ authors: JSON.stringify(authors) }) + + const { authors: resolved } = await handler(fakeEvent) + + expect(callMock).toHaveBeenCalledOnce() + expect(resolved.at(-1)?.avatar).toBe('https://cdn.test/author-0.bsky.social') + }) + + it('keeps the avatars of other batches when one batch fails', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) + callMock.mockRejectedValueOnce(new Error('upstream error')) + getQueryMock.mockReturnValue({ authors: JSON.stringify(authorsWithHandles(27)) }) + + const { authors: resolved } = await handler(fakeEvent) + + expect(resolved.filter(author => author.avatar).length).toBe(2) + expect(warn).toHaveBeenCalledOnce() + warn.mockRestore() + }) +}) From 6c2452ccb6f567f3e94c87d3f65fba5399aa5ddc Mon Sep 17 00:00:00 2001 From: Bryan Lundberg Date: Sun, 29 Nov 2026 15:28:28 +0000 Subject: [PATCH 03/18] fix: keep modal padding even when the scrollbar gutter is reserved (#3493) --- app/components/Modal.client.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/Modal.client.vue b/app/components/Modal.client.vue index 1ca075f782..aac4727064 100644 --- a/app/components/Modal.client.vue +++ b/app/components/Modal.client.vue @@ -97,7 +97,7 @@ dialog { opacity: 0; transition: opacity 200ms ease; transition-behavior: allow-discrete; - scrollbar-gutter: stable; + scrollbar-gutter: stable both-edges; } dialog:modal { From 21e43cc31a50c21b8b2190226faf7ab502344d1f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 29 Nov 2026 15:44:56 +0000 Subject: [PATCH 04/18] fix: prevent layout shift on more package tabs (#3494) --- app/components/Changelog/Markdown.vue | 4 +- app/components/Changelog/Releases.vue | 8 +- app/components/Link/Base.vue | 10 + app/components/Package/Header.vue | 20 +- app/components/Package/TimelineChart.vue | 26 +- app/components/Package/TrendsChart.vue | 72 +++-- .../package-stats/[[org]]/[packageName].vue | 2 +- app/pages/package/[[org]]/[name]/versions.vue | 17 +- modules/runtime/server/cache.ts | 63 ++++- test/e2e/layout-shift.spec.ts | 15 +- test/fixtures/jsdelivr/vue@3.5.26.json | 258 ++++++++++++++++++ test/fixtures/ungh/releases/nuxt/nuxt.json | 31 +++ 12 files changed, 473 insertions(+), 53 deletions(-) create mode 100644 test/fixtures/jsdelivr/vue@3.5.26.json create mode 100644 test/fixtures/ungh/releases/nuxt/nuxt.json diff --git a/app/components/Changelog/Markdown.vue b/app/components/Changelog/Markdown.vue index 20738fe420..512fc8a7ff 100644 --- a/app/components/Changelog/Markdown.vue +++ b/app/components/Changelog/Markdown.vue @@ -45,7 +45,9 @@ if (import.meta.client) { for (const item of toc) { const text = item.text.toLowerCase() if (text.toLowerCase().includes(lcRequestedVersion) && isMatching(text)) { - navigateTo(`#${item.id}`) + if (item !== toc[0]) { + navigateTo(`#${item.id}`) + } return } } diff --git a/app/components/Changelog/Releases.vue b/app/components/Changelog/Releases.vue index d1ca9bc86c..9c0ad7e308 100644 --- a/app/components/Changelog/Releases.vue +++ b/app/components/Changelog/Releases.vue @@ -71,12 +71,16 @@ if (import.meta.client) { match.tag.toLowerCase().includes(goToVersion) || match.title.toLowerCase().includes(goToVersion) ) { - navigateTo(`#release-${slugify(match.title)}`, { replace: true }) + if (match !== uReleases[0]) { + navigateTo(`#release-${slugify(match.title)}`, { replace: true }) + } return } } } - navigateTo(`#date-${date}`, { replace: true }) + if (uReleases[0]?.publishedAt?.slice(0, 10) !== date) { + navigateTo(`#date-${date}`, { replace: true }) + } }, { flush: 'post' }, ) diff --git a/app/components/Link/Base.vue b/app/components/Link/Base.vue index 64906a147c..3621e56ad0 100644 --- a/app/components/Link/Base.vue +++ b/app/components/Link/Base.vue @@ -87,6 +87,7 @@ const keyboardShortcutsEnabled = useKeyboardShortcuts() 'inline-flex': !block, 'gap-x-1 items-center justify-center font-mono border border-transparent rounded-md': isButton, + 'group/link gap-x-1 items-center justify-start font-mono text-fg-muted': isLink, 'text-sm py-2': isButtonMedium && !iconOnly, 'text-sm p-2': isButtonMedium && !!iconOnly, 'px-4': isButtonMedium && !classicon && !iconOnly, @@ -101,6 +102,15 @@ const keyboardShortcutsEnabled = useKeyboardShortcuts() > requestedVersion.value || props.resolvedVersion, true, ) +const changelogAvailable = computed(() => hasChangelog.value || props.page === 'changelog') + +// Rendered even for packages without one, so the tab row does not change with the check. const changelogLink = computed((): RouteLocationRaw | null => { - if ( - // either changelog.value is available or current page is the changelog - !(hasChangelog.value || props.page == 'changelog') || - !packageName.value || - props.resolvedVersion == null - ) { + if (!packageName.value || props.resolvedVersion == null) { return null } return changelogRoute(packageName.value, props.resolvedVersion) @@ -208,7 +206,7 @@ useShortcuts({ 'm': () => mainLink.value, 'd': () => docsLink.value, 'f': () => diffLink.value, - '-': () => changelogLink.value, + '-': () => (changelogAvailable.value ? changelogLink.value : null), 't': () => timelineLink.value, 's': () => statsLink.value, }) @@ -395,9 +393,13 @@ useShortcuts({ {{ $t('package.links.changelog') }} diff --git a/app/components/Package/TimelineChart.vue b/app/components/Package/TimelineChart.vue index f312cbfce1..7767806bb4 100644 --- a/app/components/Package/TimelineChart.vue +++ b/app/components/Package/TimelineChart.vue @@ -33,7 +33,7 @@ import { drawSmallNpmxLogoAndTaglineWatermark } from '~/composables/useChartWate import { useColors } from '~/composables/useColors' import { downloadFileLink } from '~/utils/download' import { useCopyChartPng } from '~/composables/useCopyChartPng' -import { useElementSize, useTimeoutFn } from '@vueuse/core' +import { useMediaQuery, useTimeoutFn } from '@vueuse/core' import TimelineChartDepSizeTooltip from './TimelineChartDepSizeTooltip.vue' import TimelineChartXyTooltip from './TimelineChartXyTooltip.vue' import TimelineChartXySvgSlot from './TimelineChartXySvgSlot.vue' @@ -323,7 +323,6 @@ const { copiedPng, isCopyingPng, copyChartPng } = useCopyChartPng(chartRef) const colorMode = useColorMode() const resolvedMode = shallowRef<'light' | 'dark'>('light') const rootEl = shallowRef(null) -const { width } = useElementSize(rootEl) const compactNumberFormatter = useCompactNumberFormatter() const bytesFormatter = useBytesFormatter() @@ -361,8 +360,7 @@ const watermarkColors = computed(() => ({ fgSubtle: colors.value.fgSubtle ?? OKLCH_NEUTRAL_FALLBACK, })) -const mobileBreakpointWidth = 640 -const isMobile = computed(() => width.value > 0 && width.value < mobileBreakpointWidth) +const isMobile = useMediaQuery('(max-width: 639.9px)') const commonScaleSteps = computed(() => { if (activeTab.value === 'totalSize') { @@ -886,7 +884,7 @@ const timelineMetricTabs = computed(() => [