[READ-ONLY] a fast, modern browser for the npm registry

chore: minor cleanups (#1286)

authored by

Robin and committed by
GitHub
0f5adf39 f132bb7e

+12 -13
+1 -1
app/composables/npm/useSearch.ts
··· 38 38 } | null>(null) 39 39 40 40 const isLoadingMore = shallowRef(false) 41 - const isRateLimited = ref(false) 41 + const isRateLimited = shallowRef(false) 42 42 43 43 const suggestions = shallowRef<SearchSuggestion[]>([]) 44 44 const suggestionsLoading = shallowRef(false)
+1 -2
app/composables/useActiveTocItem.ts
··· 10 10 * @public 11 11 */ 12 12 export function useActiveTocItem(toc: Ref<TocItem[]>) { 13 - const activeId = ref<string | null>(null) 13 + const activeId = shallowRef<string | null>(null) 14 14 15 15 // Only run observer logic on client 16 16 if (import.meta.server) { 17 - // eslint-disable-next-line @typescript-eslint/no-empty-function 18 17 return { activeId } 19 18 } 20 19
+1 -1
app/composables/useCanGoBack.ts
··· 1 1 export function useCanGoBack() { 2 - const canGoBack = ref(false) 2 + const canGoBack = shallowRef(false) 3 3 4 4 const router = useRouter() 5 5
+2 -2
app/composables/useCharts.ts
··· 312 312 ) 313 313 314 314 const endDateOnly = toDateOnly(downloadEvolutionOptions.endDate) 315 - const end = endDateOnly ? new Date(`${endDateOnly}T00:00:00.000Z`) : yesterday 315 + const end = endDateOnly ? parseIsoDateOnly(endDateOnly) : yesterday 316 316 317 317 const startDateOnly = toDateOnly(downloadEvolutionOptions.startDate) 318 318 if (startDateOnly) { 319 - const start = new Date(`${startDateOnly}T00:00:00.000Z`) 319 + const start = parseIsoDateOnly(startDateOnly) 320 320 return { start, end } 321 321 } 322 322
+1 -3
app/composables/useFileTreeState.ts
··· 1 1 export function useFileTreeState(baseUrl: string) { 2 - const stateKey = computed(() => `npmx-file-tree${baseUrl}`) 3 - 4 - const expanded = useState<Set<string>>(stateKey.value, () => new Set<string>()) 2 + const expanded = useState<Set<string>>(`npmx-file-tree${baseUrl}`, () => new Set<string>()) 5 3 6 4 function toggleDir(path: string) { 7 5 if (expanded.value.has(path)) {
+5 -3
app/composables/usePreferencesProvider.ts
··· 1 + import { defu } from 'defu' 2 + 1 3 /** 2 4 * Abstraction for preferences storage 3 5 * Currently uses localStorage, designed for future user prefs API ··· 58 60 * Abstracts the storage mechanism to allow future migration to API-based storage 59 61 * 60 62 */ 61 - export function usePreferencesProvider<T>(defaultValue: T) { 63 + export function usePreferencesProvider<T extends object>(defaultValue: T) { 62 64 const provider = createLocalStorageProvider<T>(STORAGE_KEY) 63 - const data = ref<T>(defaultValue) as Ref<T> 65 + const data = ref<T>(defaultValue) 64 66 const isHydrated = shallowRef(false) 65 67 66 68 // Load from storage on client ··· 68 70 const stored = provider.get() 69 71 if (stored) { 70 72 // Merge stored values with defaults to handle schema evolution 71 - data.value = { ...defaultValue, ...stored } 73 + data.value = defu(stored, defaultValue) 72 74 } 73 75 isHydrated.value = true 74 76 })
+1 -1
app/pages/package/[[org]]/[name].vue
··· 453 453 () => likeStatus.value !== 'error' && likeStatus.value !== 'success', 454 454 ) 455 455 456 - const isLikeActionPending = ref(false) 456 + const isLikeActionPending = shallowRef(false) 457 457 458 458 const likeAction = async () => { 459 459 if (user.value?.handle == null) {