Skip to content

Commit 47d7471

Browse files
authored
optimize /check endpoint, self-host fonts (#1968)
1 parent 973c32c commit 47d7471

12 files changed

Lines changed: 7141 additions & 98 deletions

assets/check-data.json

Lines changed: 7043 additions & 0 deletions
Large diffs are not rendered by default.

bun.lock

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"@react-native-picker/picker": "^2.11.4",
2727
"@sentry/react": "^10.22.0",
2828
"es-toolkit": "^1.41.0",
29-
"expo": "54.0.20",
29+
"expo": "54.0.21",
3030
"expo-font": "^14.0.9",
31-
"next": "^16.0.0",
31+
"next": "^16.0.1",
3232
"node-emoji": "^2.2.0",
3333
"react": "19.2.0",
3434
"react-content-loader": "^7.1.1",
@@ -42,7 +42,7 @@
4242
},
4343
"devDependencies": {
4444
"@expo/next-adapter": "^6.0.0",
45-
"@next/bundle-analyzer": "^16.0.0",
45+
"@next/bundle-analyzer": "^16.0.1",
4646
"@prettier/plugin-oxc": "^0.0.4",
4747
"@types/bun": "^1.3.1",
4848
"@types/react": "^19.2.2",
@@ -52,7 +52,7 @@
5252
"cheerio": "^1.1.2",
5353
"dotenv": "^17.2.3",
5454
"eslint": "^9.38.0",
55-
"eslint-config-next": "^16.0.0",
55+
"eslint-config-next": "^16.0.1",
5656
"eslint-config-universe": "^15.0.3",
5757
"lint-staged": "^16.2.6",
5858
"next-compose-plugins": "^2.2.1",

pages/api/libraries/check.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
import { type NextApiRequest, type NextApiResponse } from 'next';
22

3-
import data from '~/assets/data.json';
4-
import { type DataAssetType } from '~/types';
5-
import { getNewArchSupportStatus, NewArchSupportStatus } from '~/util/newArchStatus';
3+
import data from '~/assets/check-data.json';
4+
import { type CheckResultsType } from '~/types';
65

7-
type CheckResultsType = Record<
8-
string,
9-
{
10-
unmaintained?: boolean;
11-
newArchitecture: NewArchSupportStatus;
12-
}
13-
>;
14-
15-
// Copy data into an object that is keyed by npm package name for faster lookup
16-
const dataByNpmPackage: CheckResultsType = {};
17-
18-
(data as DataAssetType).libraries.forEach(library => {
19-
dataByNpmPackage[library.npmPkg] = {
20-
unmaintained: library.unmaintained,
21-
newArchitecture: getNewArchSupportStatus(library),
22-
};
23-
});
6+
const DATASET = data as CheckResultsType;
247

258
// Provide library metadata for a list of npm packages
269
export default function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -41,7 +24,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
4124
res.statusCode = 200;
4225
const result: CheckResultsType = {};
4326
packages.forEach(pkgName => {
44-
result[pkgName] = dataByNpmPackage[pkgName];
27+
result[pkgName] = DATASET[pkgName];
4528
});
4629

4730
return res.json(result);
23.1 KB
Binary file not shown.
21.6 KB
Binary file not shown.
22.3 KB
Binary file not shown.

public/manifest.json

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
{
2-
"name": "React Native Directory",
3-
"short_name": "RND",
4-
"description": "A searchable and filterable directory of React Native libraries",
5-
"lang": "en-US",
6-
"categories": ["education", "utilities"],
7-
"display": "minimal-ui",
8-
"orientation": "any",
9-
"start_url": "/",
10-
"scope": "/",
11-
"protocol_handlers": [
12-
{
13-
"protocol": "web+rnd",
14-
"url": "/?search=%s"
15-
}
16-
],
17-
"theme_color": "#20232a",
18-
"background_color": "#20232a",
19-
"icons": [
20-
{
21-
"src": "/icon-192px.png",
22-
"sizes": "192x192",
23-
"type": "image/png",
24-
"purpose": "any"
25-
},
26-
{
27-
"src": "/icon-512px.png",
28-
"sizes": "512x512",
29-
"type": "image/png",
30-
"purpose": "any maskable"
31-
}
32-
]
2+
"name": "React Native Directory",
3+
"short_name": "RND",
4+
"description": "A searchable and filterable directory of React Native libraries",
5+
"lang": "en-US",
6+
"categories": [
7+
"education",
8+
"utilities"
9+
],
10+
"display": "minimal-ui",
11+
"orientation": "any",
12+
"start_url": "/",
13+
"scope": "/",
14+
"protocol_handlers": [
15+
{
16+
"protocol": "web+rnd",
17+
"url": "/?search=%s"
18+
}
19+
],
20+
"theme_color": "#20232a",
21+
"background_color": "#20232a",
22+
"icons": [
23+
{
24+
"src": "/icon-192px.png",
25+
"sizes": "192x192",
26+
"type": "image/png",
27+
"purpose": "any"
28+
},
29+
{
30+
"src": "/icon-512px.png",
31+
"sizes": "512x512",
32+
"type": "image/png",
33+
"purpose": "any maskable"
34+
}
35+
]
3336
}

react-native-libraries.json

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5870,10 +5870,7 @@
58705870
},
58715871
{
58725872
"githubUrl": "https://github.com/AndreiCalazans/rn-tooltip",
5873-
"examples": [
5874-
"https://github.com/AndreiCalazans/rn-tooltip",
5875-
"rn-tooltip"
5876-
],
5873+
"examples": ["https://github.com/AndreiCalazans/rn-tooltip", "rn-tooltip"],
58775874
"images": [
58785875
"https://raw.githubusercontent.com/AndreiCalazans/rn-tooltip/HEAD/tooltipExample.gif"
58795876
],
@@ -17923,42 +17920,31 @@
1792317920
},
1792417921
{
1792517922
"githubUrl": "https://github.com/Daavidaviid/react-native-nitro-udp",
17926-
"examples": [
17927-
"https://github.com/Daavidaviid/react-native-nitro-udp/tree/main/example"
17928-
],
17923+
"examples": ["https://github.com/Daavidaviid/react-native-nitro-udp/tree/main/example"],
1792917924
"ios": true,
1793017925
"android": true
1793117926
},
1793217927
{
1793317928
"githubUrl": "https://github.com/riteshshukla04/react-native-sports-car",
1793417929
"npmPkg": "react-native-sportscar",
17935-
"examples": [
17936-
"https://github.com/riteshshukla04/react-native-sports-car/tree/main/example"
17937-
],
17930+
"examples": ["https://github.com/riteshshukla04/react-native-sports-car/tree/main/example"],
1793817931
"android": true
1793917932
},
1794017933
{
1794117934
"githubUrl": "https://github.com/corasan/react-native-mlx/tree/main/package",
1794217935
"npmPkg": "react-native-mlx",
17943-
"examples": [
17944-
"https://github.com/corasan/react-native-mlx/tree/main/example"
17945-
],
17936+
"examples": ["https://github.com/corasan/react-native-mlx/tree/main/example"],
1794617937
"ios": true
17947-
},
17938+
},
1794817939
{
1794917940
"githubUrl": "https://github.com/ChrisCosentino/expo-iperf",
17950-
"examples": [
17951-
"https://github.com/ChrisCosentino/expo-iperf/tree/main/example"
17952-
],
17941+
"examples": ["https://github.com/ChrisCosentino/expo-iperf/tree/main/example"],
1795317942
"ios": true,
1795417943
"android": true
1795517944
},
1795617945
{
1795717946
"githubUrl": "https://github.com/l2hyunwoo/react-native-nitro-device-info",
17958-
"npmPkg": "react-native-nitro-device-info",
17959-
"examples": [
17960-
"https://github.com/l2hyunwoo/react-native-nitro-device-info/tree/main/example"
17961-
],
17947+
"examples": ["https://github.com/l2hyunwoo/react-native-nitro-device-info/tree/main/example"],
1796217948
"ios": true,
1796317949
"android": true,
1796417950
"newArchitecture": true

scripts/build-and-score-data.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { fetchNpmRegistryData } from '~/scripts/fetch-npm-registry-data';
1010
import { fetchNpmStatDataBulk } from '~/scripts/fetch-npm-stat-data';
1111
import { type APIResponseType, type LibraryDataEntryType, type LibraryType } from '~/types';
1212
import { isLaterThan, TimeRange } from '~/util/datetime';
13+
import { getNewArchSupportStatus } from '~/util/newArchStatus';
1314
import { isEmptyOrNull } from '~/util/strings';
1415

1516
import { calculateDirectoryScore, calculatePopularityScore } from './calculate-score';
@@ -30,6 +31,7 @@ const SCRAPE_GH_IMAGES = false;
3031

3132
const DATASET: LibraryDataEntryType[] = USE_DEBUG_REPOS ? debugGithubRepos : githubRepos;
3233
const DATA_PATH = path.resolve('assets', 'data.json');
34+
const CHECK_DATA_PATH = path.resolve('assets', 'check-data.json');
3335

3436
const CHUNK_SIZE = 25;
3537
const SLEEP_TIME = 250;
@@ -219,31 +221,47 @@ async function buildAndScoreData() {
219221
}
220222
);
221223

222-
const finalData = dataWithFallback.filter(({ npmPkg }) => existingPackages.includes(npmPkg));
223224
const validEntries = data.map((entry: LibraryDataEntryType) => entry.githubUrl);
225+
const finalData = dataWithFallback
226+
.filter(({ npmPkg }) => existingPackages.includes(npmPkg))
227+
.filter((entry: LibraryType) => validEntries.includes(entry.githubUrl));
224228

225229
const sortedTopicCounts = Object.fromEntries(
226230
Object.entries(topicCounts).sort((a, b) => b[1] - a[1])
227231
);
228232

229233
fileContent = JSON.stringify(
230234
{
231-
libraries: finalData.filter((entry: LibraryType) => {
232-
return validEntries.includes(entry.githubUrl);
233-
}),
235+
libraries: finalData,
234236
topics: sortedTopicCounts,
235237
topicsList: Object.keys(topicCounts).sort(),
236238
},
237239
null,
238240
2
239241
);
242+
243+
createCheckEndpointData(finalData);
240244
}
241245

242246
if (!(USE_DEBUG_REPOS || ONLY_WRITE_LOCAL_DATA_FILE)) {
243247
await uploadToStore(fileContent);
244248
}
245249

246-
return fs.writeFileSync(DATA_PATH, fileContent);
250+
fs.writeFileSync(DATA_PATH, fileContent);
251+
}
252+
253+
export function createCheckEndpointData(libraries: LibraryType[]) {
254+
const checkData = Object.fromEntries(
255+
libraries.map(library => [
256+
library.npmPkg,
257+
{
258+
unmaintained: library.unmaintained,
259+
newArchitecture: getNewArchSupportStatus(library),
260+
},
261+
])
262+
);
263+
264+
fs.writeFileSync(CHECK_DATA_PATH, JSON.stringify(checkData, null, 2));
247265
}
248266

249267
export async function fetchGithubDataThrottled({

0 commit comments

Comments
 (0)