File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import type { FileDiffResponse , FileChange } from ' #shared/types'
33import { createDiff , insertSkipBlocks , countDiffStats } from ' #shared/utils/diff'
4- // @ts-expect-error: (tasky): idk why this is type-erroring even if it has types? /shrug
54import { motion } from ' motion-v'
65
76const props = defineProps <{
@@ -68,6 +67,12 @@ async function fetchFileContent(version: string): Promise<string | null> {
6867 }
6968
7069 return text
70+ } catch (err ) {
71+ // Provide specific error message for timeout
72+ if (err instanceof Error && err .name === ' AbortError' ) {
73+ throw new Error (` Request timed out after ${DIFF_TIMEOUT / 1000 }s ` , { cause: err })
74+ }
75+ throw err
7176 } finally {
7277 clearTimeout (timeoutId )
7378 }
@@ -80,7 +85,10 @@ function computeDiff() {
8085 const oldContent = fromContent .value ?? ' '
8186 const newContent = toContent .value ?? ' '
8287
83- // Determine type
88+ // Determine diff type based on content availability
89+ // Note: FileDiffResponse uses 'add'/'delete'/'modify' while FileChange uses
90+ // 'added'/'removed'/'modified' - this is intentional to distinguish between
91+ // the file-level change info (FileChange) and the diff content type (FileDiff)
8492 let type: FileDiffResponse [' type' ] = ' modify'
8593 if (fromContent .value === null && toContent .value !== null ) type = ' add'
8694 else if (fromContent .value !== null && toContent .value === null ) type = ' delete'
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ definePageMeta({
77})
88
99const route = useRoute (' compare' )
10- const { t } = useI18n ()
1110
1211// Parse package name and version range from URL
1312// Patterns:
@@ -155,11 +154,6 @@ const toVersionUrlPattern = computed(() => {
155154 return ` /compare/${packageName .value }/v/${fromVersion .value }...{version} `
156155})
157156
158- function getCodeUrl(version : string , path ? : string ): string {
159- const base = ` /code/${packageName .value }/v/${version } `
160- return path ? ` ${base }/${path } ` : base
161- }
162-
163157function packageRoute(ver ? : string | null ) {
164158 const segments = packageName .value .split (' /' )
165159 if (ver ) segments .push (' v' , ver )
You can’t perform that action at this time.
0 commit comments