Skip to content

Commit bb70eb2

Browse files
authored
improves types, bump dependencies (#1885)
1 parent 969e9c1 commit bb70eb2

File tree

18 files changed

+243
-209
lines changed

18 files changed

+243
-209
lines changed

assets/data.json

Lines changed: 79 additions & 61 deletions
Large diffs are not rendered by default.

bun.lock

Lines changed: 45 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/Library/MetaData.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useContext } from 'react';
2-
import { Platform, StyleSheet, View, Text } from 'react-native';
2+
import { Platform, StyleSheet, View } from 'react-native';
33

44
import { colors, A, P, Caption, darkColors } from '~/common/styleguide';
55
import Tooltip from '~/components/Tooltip';
@@ -79,7 +79,7 @@ function generateData(
7979
</A>
8080
),
8181
},
82-
npm.size
82+
npm?.size
8383
? {
8484
id: 'size',
8585
icon: <PackageSize fill={iconColor} />,
@@ -247,11 +247,7 @@ export function MetaData({ library, secondary }: Props) {
247247
key={id}
248248
sideOffset={2}
249249
delayDuration={100}
250-
trigger={
251-
<View style={styles.iconContainer}>
252-
{icon}
253-
</View>
254-
}>
250+
trigger={<View style={styles.iconContainer}>{icon}</View>}>
255251
{tooltip}
256252
</Tooltip>
257253
{content}

components/Library/UpdateAtView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function UpdatedAtView({ library }: Props) {
2828
const tooltipContent = `
2929
Last update (based on Git activity)
3030
${
31-
library.npm.latestReleaseDate
31+
library.npm?.latestReleaseDate
3232
? ` Last npm release: ${getTimeSinceToday(library.npm.latestReleaseDate)}`
3333
: ''
3434
}`;

components/NavigationTab.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function NavigationTab({ title, path = `/${title.toLowerCase()}` }: Props) {
2626
}),
2727
}}
2828
hoverStyle={{
29-
backgroundColor: isActive ? activeBackground : isDark ? darkColors.background : colors.gray6,
29+
backgroundColor: isActive
30+
? activeBackground
31+
: isDark
32+
? darkColors.background
33+
: colors.gray6,
3034
color: colors.secondary,
3135
}}
3236
target="_self">

components/Pagination.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Props = {
2020

2121
const Pagination = ({ query, total, style, basePath = '/' }: Props) => {
2222
const { isDark } = useContext(CustomAppearanceContext);
23-
const currentOffset = query.offset ? parseInt(query.offset.toString(), 10) : 0;
23+
const currentOffset = query.offset ? parseInt(query.offset, 10) : 0;
2424
const currentPage = Math.floor(currentOffset / NUM_PER_PAGE) + 1;
2525

2626
if (!total || total < 1 || currentOffset >= total) {
@@ -67,7 +67,10 @@ const Pagination = ({ query, total, style, basePath = '/' }: Props) => {
6767
) : (
6868
<HoverEffect>
6969
<Link
70-
href={urlWithQuery(basePath, { ...pageQuery, offset: currentOffset - NUM_PER_PAGE })}
70+
href={urlWithQuery(basePath, {
71+
...pageQuery,
72+
offset: (currentOffset - NUM_PER_PAGE).toString(),
73+
})}
7174
style={{ borderRadius: 4 }}
7275
aria-label="Previous page">
7376
{backArrow(isDark)}
@@ -83,7 +86,10 @@ const Pagination = ({ query, total, style, basePath = '/' }: Props) => {
8386
) : (
8487
<HoverEffect>
8588
<Link
86-
href={urlWithQuery(basePath, { ...pageQuery, offset: currentOffset + NUM_PER_PAGE })}
89+
href={urlWithQuery(basePath, {
90+
...pageQuery,
91+
offset: (currentOffset + NUM_PER_PAGE).toString(),
92+
})}
8793
style={{ borderRadius: 4 }}
8894
aria-label="Next page">
8995
{forwardArrow(isDark)}

components/Sort.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ const sorts = [
5353
export const SortButton = ({ query: { order, direction, offset }, query }: SortButtonProps) => {
5454
const [sortValue, setSortValue] = useState<QueryOrder | undefined>(order);
5555
const [sortDirection, setSortDirection] = useState<QueryOrderDirection | undefined>(direction);
56-
const [paginationOffset, setPaginationOffset] = useState<number | undefined>(
57-
typeof offset === 'string' ? parseInt(offset, 10) : offset
56+
const [paginationOffset, setPaginationOffset] = useState<string | null | undefined>(
57+
typeof offset === 'string' ? offset : offset
5858
);
5959
const [isSortIconHovered, setIsSortIconHovered] = useState(false);
6060
const { isDark } = useContext(CustomAppearanceContext);

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"@radix-ui/react-tooltip": "^1.2.8",
2424
"@react-native-async-storage/async-storage": "^2.2.0",
2525
"@react-native-picker/picker": "^2.11.2",
26-
"@sentry/react": "^9.40.0",
26+
"@sentry/react": "^10.12.0",
2727
"@vercel/blob": "^0.27.3",
28-
"expo": "54.0.6",
28+
"expo": "54.0.8",
2929
"expo-font": "^14.0.8",
3030
"lodash": "^4.17.21",
3131
"next": "^15.5.3",
@@ -43,18 +43,18 @@
4343
"devDependencies": {
4444
"@expo/next-adapter": "^6.0.0",
4545
"@next/bundle-analyzer": "^15.5.3",
46-
"@types/bun": "^1.2.21",
46+
"@types/bun": "^1.2.22",
4747
"@types/lodash": "^4.17.20",
4848
"@types/react": "^19.1.13",
4949
"ajv-cli": "^5.0.0",
50-
"browserslist": "^4.26.0",
50+
"browserslist": "^4.26.2",
5151
"cheerio": "^1.1.2",
5252
"cross-fetch": "^4.1.0",
5353
"dotenv": "^17.2.2",
5454
"eslint": "^9.35.0",
5555
"eslint-config-next": "^15.5.3",
5656
"eslint-config-universe": "^15.0.3",
57-
"lint-staged": "^15.5.1",
57+
"lint-staged": "^16.1.6",
5858
"next-compose-plugins": "^2.2.1",
5959
"next-fonts": "^1.5.1",
6060
"next-images": "^1.8.5",

pages/api/libraries/index.ts

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import take from 'lodash/take';
33
import { NextApiRequest, NextApiResponse } from 'next';
44

55
import data from '~/assets/data.json';
6-
import { type LibraryType } from '~/types';
6+
import { type LibraryType, QueryOrder } from '~/types';
77
import { NUM_PER_PAGE } from '~/util/Constants';
8+
import { parseQueryParams } from '~/util/parseQueryParams';
89
import { handleFilterLibraries } from '~/util/search';
910
import * as Sorting from '~/util/sorting';
1011

@@ -29,7 +30,7 @@ const ReversedSortedData = Object.entries(getData()).reduce(
2930
{}
3031
);
3132

32-
const getAllowedOrderString = (req: NextApiRequest, querySearch?: string) => {
33+
function getAllowedOrderString(req: NextApiRequest, querySearch?: string): QueryOrder {
3334
let sortBy = querySearch ? SortingKeys.at(-1) : SortingKeys[0];
3435

3536
SortingKeys.forEach(sortName => {
@@ -38,58 +39,60 @@ const getAllowedOrderString = (req: NextApiRequest, querySearch?: string) => {
3839
}
3940
});
4041

41-
return sortBy;
42-
};
42+
return sortBy as QueryOrder;
43+
}
4344

4445
export default function handler(req: NextApiRequest, res: NextApiResponse) {
4546
res.statusCode = 200;
4647
res.setHeader('Content-Type', 'application/json');
4748

48-
const querySearch = req.query.search
49-
? req.query.search.toString().toLowerCase().trim()
49+
const parsedQuery = parseQueryParams(req.query);
50+
51+
const querySearch = parsedQuery.search
52+
? parsedQuery.search.toString().toLowerCase().trim()
5053
: undefined;
5154

5255
const sortBy = getAllowedOrderString(req, querySearch);
53-
const sortDirection = req.query.direction ?? 'descending';
56+
const sortDirection = parsedQuery.direction ?? 'descending';
5457
const libraries = sortDirection === 'ascending' ? ReversedSortedData[sortBy] : SortedData[sortBy];
5558

5659
const filteredLibraries = handleFilterLibraries({
5760
libraries,
5861
sortBy,
59-
queryTopic: req.query.topic,
62+
queryTopic: parsedQuery.topic,
6063
querySearch,
6164
support: {
62-
ios: req.query.ios,
63-
android: req.query.android,
64-
web: req.query.web,
65-
windows: req.query.windows,
66-
macos: req.query.macos,
67-
expoGo: req.query.expoGo,
68-
fireos: req.query.fireos,
69-
tvos: req.query.tvos,
70-
visionos: req.query.visionos,
65+
ios: parsedQuery.ios,
66+
android: parsedQuery.android,
67+
web: parsedQuery.web,
68+
windows: parsedQuery.windows,
69+
macos: parsedQuery.macos,
70+
expoGo: parsedQuery.expoGo,
71+
fireos: parsedQuery.fireos,
72+
tvos: parsedQuery.tvos,
73+
visionos: parsedQuery.visionos,
7174
},
72-
hasExample: req.query.hasExample,
73-
hasImage: req.query.hasImage,
74-
hasTypes: req.query.hasTypes,
75-
hasNativeCode: req.query.hasNativeCode,
76-
isMaintained: req.query.isMaintained,
77-
isPopular: req.query.isPopular,
78-
isRecommended: req.query.isRecommended,
79-
wasRecentlyUpdated: req.query.wasRecentlyUpdated,
80-
minPopularity: req.query.minPopularity,
81-
minMonthlyDownloads: req.query.minMonthlyDownloads,
82-
newArchitecture: req.query.newArchitecture,
83-
skipLibs: req.query.skipLibs,
84-
skipTools: req.query.skipTools,
85-
skipTemplates: req.query.skipTemplates,
75+
hasExample: parsedQuery.hasExample,
76+
hasImage: parsedQuery.hasImage,
77+
hasTypes: parsedQuery.hasTypes,
78+
hasNativeCode: parsedQuery.hasNativeCode,
79+
isMaintained: parsedQuery.isMaintained,
80+
isPopular: parsedQuery.isPopular,
81+
isRecommended: parsedQuery.isRecommended,
82+
wasRecentlyUpdated: parsedQuery.wasRecentlyUpdated,
83+
minPopularity: parsedQuery.minPopularity,
84+
minMonthlyDownloads: parsedQuery.minMonthlyDownloads,
85+
newArchitecture: parsedQuery.newArchitecture,
86+
skipLibs: parsedQuery.skipLibs,
87+
skipTools: parsedQuery.skipTools,
88+
skipTemplates: parsedQuery.skipTemplates,
8689
});
8790

88-
const offset = req.query.offset ? parseInt(req.query.offset.toString(), 10) : 0;
89-
const limit = req.query.limit ? parseInt(req.query.limit.toString(), 10) : NUM_PER_PAGE;
91+
const offset = parsedQuery.offset ? parseInt(parsedQuery.offset.toString(), 10) : 0;
92+
const limit = parsedQuery.limit ? parseInt(parsedQuery.limit.toString(), 10) : NUM_PER_PAGE;
9093

9194
const relevanceSortedLibraries =
92-
querySearch?.length && (!req.query.order || req.query.order === 'relevance')
95+
querySearch?.length && (!parsedQuery.order || parsedQuery.order === 'relevance')
9396
? sortDirection === 'ascending'
9497
? Sorting.relevance([...filteredLibraries]).reverse()
9598
: Sorting.relevance([...filteredLibraries])

pages/popular.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const Popular = ({ data }: Props) => {
102102

103103
Popular.getInitialProps = async (ctx: NextPageContext) => {
104104
const url = getApiUrl(
105-
urlWithQuery('/libraries', { limit: 9999, minPopularity: 5, order: 'popularity' }),
105+
urlWithQuery('/libraries', { limit: '9999', minPopularity: '5', order: 'popularity' }),
106106
ctx
107107
);
108108
const response = await fetch(url);

0 commit comments

Comments
 (0)