@tscircuit/fake-snippets 0.0.94 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/generated-index.js +32 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/create.test.ts +1 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/get.test.ts +12 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/process_all_datasheets.test.ts +1 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/run_async_tasks.test.ts +1 -0
- package/dist/bundle.js +11 -6
- package/dist/index.d.ts +9 -4
- package/dist/index.js +7 -3
- package/dist/schema.d.ts +14 -6
- package/dist/schema.js +2 -1
- package/fake-snippets-api/lib/db/db-client.ts +4 -1
- package/fake-snippets-api/lib/db/schema.ts +1 -0
- package/fake-snippets-api/routes/api/_fake/datasheets/process_all_datasheets.ts +2 -1
- package/package.json +1 -1
- package/src/App.tsx +2 -0
- package/src/components/DownloadButtonAndMenu.tsx +3 -3
- package/src/components/ExpandableText.tsx +29 -0
- package/src/components/Header.tsx +11 -0
- package/src/components/Header2.tsx +6 -0
- package/src/components/PackageCard.tsx +11 -2
- package/src/components/PrefetchPageLink.tsx +11 -2
- package/src/components/ViewPackagePage/components/main-content-header.tsx +1 -1
- package/src/hooks/use-account-balance.ts +2 -1
- package/src/pages/datasheet.tsx +36 -15
- package/src/pages/datasheets.tsx +130 -0
package/dist/index.d.ts
CHANGED
|
@@ -434,6 +434,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
434
434
|
capabilities: string[];
|
|
435
435
|
}>, "many">>;
|
|
436
436
|
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
437
|
+
ai_description: z.ZodNullable<z.ZodString>;
|
|
437
438
|
}, "strip", z.ZodTypeAny, {
|
|
438
439
|
created_at: string;
|
|
439
440
|
datasheet_id: string;
|
|
@@ -445,6 +446,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
445
446
|
capabilities: string[];
|
|
446
447
|
}[] | null;
|
|
447
448
|
datasheet_pdf_urls: string[] | null;
|
|
449
|
+
ai_description: string | null;
|
|
448
450
|
}, {
|
|
449
451
|
created_at: string;
|
|
450
452
|
datasheet_id: string;
|
|
@@ -456,6 +458,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
456
458
|
capabilities: string[];
|
|
457
459
|
}[] | null;
|
|
458
460
|
datasheet_pdf_urls: string[] | null;
|
|
461
|
+
ai_description: string | null;
|
|
459
462
|
}>;
|
|
460
463
|
type Datasheet = z.infer<typeof datasheetSchema>;
|
|
461
464
|
declare const accountPackageSchema: z.ZodObject<{
|
|
@@ -654,6 +657,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
654
657
|
is_private: boolean | null;
|
|
655
658
|
is_public: boolean | null;
|
|
656
659
|
is_unlisted: boolean | null;
|
|
660
|
+
ai_description: string | null;
|
|
657
661
|
package_id: string;
|
|
658
662
|
license: string | null;
|
|
659
663
|
creator_account_id: string;
|
|
@@ -668,7 +672,6 @@ declare const packageSchema: z.ZodObject<{
|
|
|
668
672
|
latest_package_release_id: string | null;
|
|
669
673
|
latest_version: string | null;
|
|
670
674
|
website: string | null;
|
|
671
|
-
ai_description: string | null;
|
|
672
675
|
ai_usage_instructions: string | null;
|
|
673
676
|
latest_package_release_fs_sha: string | null;
|
|
674
677
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -680,6 +683,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
680
683
|
created_at: string;
|
|
681
684
|
updated_at: string;
|
|
682
685
|
description: string | null;
|
|
686
|
+
ai_description: string | null;
|
|
683
687
|
package_id: string;
|
|
684
688
|
license: string | null;
|
|
685
689
|
creator_account_id: string;
|
|
@@ -687,7 +691,6 @@ declare const packageSchema: z.ZodObject<{
|
|
|
687
691
|
owner_github_username: string | null;
|
|
688
692
|
latest_package_release_id: string | null;
|
|
689
693
|
latest_version: string | null;
|
|
690
|
-
ai_description: string | null;
|
|
691
694
|
ai_usage_instructions: string | null;
|
|
692
695
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
693
696
|
star_count?: number | undefined;
|
|
@@ -920,6 +923,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
920
923
|
is_private: boolean | null;
|
|
921
924
|
is_public: boolean | null;
|
|
922
925
|
is_unlisted: boolean | null;
|
|
926
|
+
ai_description: string | null;
|
|
923
927
|
package_id: string;
|
|
924
928
|
license: string | null;
|
|
925
929
|
creator_account_id: string;
|
|
@@ -934,7 +938,6 @@ declare const createDatabase: ({ seed }?: {
|
|
|
934
938
|
latest_package_release_id: string | null;
|
|
935
939
|
latest_version: string | null;
|
|
936
940
|
website: string | null;
|
|
937
|
-
ai_description: string | null;
|
|
938
941
|
ai_usage_instructions: string | null;
|
|
939
942
|
latest_package_release_fs_sha: string | null;
|
|
940
943
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -1068,6 +1071,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1068
1071
|
capabilities: string[];
|
|
1069
1072
|
}[] | null;
|
|
1070
1073
|
datasheet_pdf_urls: string[] | null;
|
|
1074
|
+
ai_description: string | null;
|
|
1071
1075
|
}[];
|
|
1072
1076
|
}, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha" | "addAiReview" | "updateAiReview" | "getAiReviewById" | "listAiReviews" | "addDatasheet" | "getDatasheetById" | "getDatasheetByChipName" | "listDatasheets" | "updateDatasheet"> & {
|
|
1073
1077
|
addOrder: (order: Omit<Order, "order_id">) => Order;
|
|
@@ -1272,6 +1276,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1272
1276
|
is_private: boolean | null;
|
|
1273
1277
|
is_public: boolean | null;
|
|
1274
1278
|
is_unlisted: boolean | null;
|
|
1279
|
+
ai_description: string | null;
|
|
1275
1280
|
package_id: string;
|
|
1276
1281
|
license: string | null;
|
|
1277
1282
|
creator_account_id: string;
|
|
@@ -1286,7 +1291,6 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1286
1291
|
latest_package_release_id: string | null;
|
|
1287
1292
|
latest_version: string | null;
|
|
1288
1293
|
website: string | null;
|
|
1289
|
-
ai_description: string | null;
|
|
1290
1294
|
ai_usage_instructions: string | null;
|
|
1291
1295
|
latest_package_release_fs_sha: string | null;
|
|
1292
1296
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -1420,6 +1424,7 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1420
1424
|
capabilities: string[];
|
|
1421
1425
|
}[] | null;
|
|
1422
1426
|
datasheet_pdf_urls: string[] | null;
|
|
1427
|
+
ai_description: string | null;
|
|
1423
1428
|
}[];
|
|
1424
1429
|
}, "addOrder" | "getOrderById" | "getOrderFilesByOrderId" | "addOrderQuote" | "getOrderQuoteById" | "getJlcpcbOrderStatesByOrderId" | "getJlcpcbOrderStepRunsByJlcpcbOrderStateId" | "updateOrder" | "addJlcpcbOrderState" | "updateJlcpcbOrderState" | "addOrderFile" | "getOrderFileById" | "addAccount" | "addAccountPackage" | "getAccountPackageById" | "updateAccountPackage" | "deleteAccountPackage" | "addSnippet" | "getLatestSnippets" | "getTrendingSnippets" | "getPackagesByAuthor" | "getSnippetByAuthorAndName" | "updateSnippet" | "getSnippetById" | "searchSnippets" | "searchPackages" | "deleteSnippet" | "addSession" | "getSessions" | "createLoginPage" | "getLoginPage" | "updateLoginPage" | "getAccount" | "updateAccount" | "createSession" | "addStar" | "removeStar" | "hasStarred" | "addPackage" | "updatePackage" | "getPackageById" | "getPackageReleaseById" | "addPackageRelease" | "updatePackageRelease" | "deletePackageFile" | "addPackageFile" | "updatePackageFile" | "getStarCount" | "getPackageFilesByReleaseId" | "updatePackageReleaseFsSha" | "addAiReview" | "updateAiReview" | "getAiReviewById" | "listAiReviews" | "addDatasheet" | "getDatasheetById" | "getDatasheetByChipName" | "listDatasheets" | "updateDatasheet"> & {
|
|
1425
1430
|
addOrder: (order: Omit<Order, "order_id">) => Order;
|
package/dist/index.js
CHANGED
|
@@ -141,7 +141,8 @@ var datasheetSchema = z.object({
|
|
|
141
141
|
chip_name: z.string(),
|
|
142
142
|
created_at: z.string(),
|
|
143
143
|
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
144
|
-
datasheet_pdf_urls: z.array(z.string()).nullable()
|
|
144
|
+
datasheet_pdf_urls: z.array(z.string()).nullable(),
|
|
145
|
+
ai_description: z.string().nullable()
|
|
145
146
|
});
|
|
146
147
|
var accountSnippetSchema = z.object({
|
|
147
148
|
account_id: z.string(),
|
|
@@ -3116,7 +3117,8 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3116
3117
|
chip_name,
|
|
3117
3118
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3118
3119
|
pin_information: null,
|
|
3119
|
-
datasheet_pdf_urls: null
|
|
3120
|
+
datasheet_pdf_urls: null,
|
|
3121
|
+
ai_description: null
|
|
3120
3122
|
});
|
|
3121
3123
|
set((state) => ({
|
|
3122
3124
|
datasheets: [...state.datasheets, newDatasheet]
|
|
@@ -3129,7 +3131,9 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3129
3131
|
},
|
|
3130
3132
|
getDatasheetByChipName: (chipName) => {
|
|
3131
3133
|
const state = get();
|
|
3132
|
-
return state.datasheets.find(
|
|
3134
|
+
return state.datasheets.find(
|
|
3135
|
+
(d) => d.chip_name.toLowerCase() === chipName.toLowerCase()
|
|
3136
|
+
);
|
|
3133
3137
|
},
|
|
3134
3138
|
listDatasheets: ({
|
|
3135
3139
|
chip_name,
|
package/dist/schema.d.ts
CHANGED
|
@@ -555,6 +555,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
555
555
|
capabilities: string[];
|
|
556
556
|
}>, "many">>;
|
|
557
557
|
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
558
|
+
ai_description: z.ZodNullable<z.ZodString>;
|
|
558
559
|
}, "strip", z.ZodTypeAny, {
|
|
559
560
|
created_at: string;
|
|
560
561
|
datasheet_id: string;
|
|
@@ -566,6 +567,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
566
567
|
capabilities: string[];
|
|
567
568
|
}[] | null;
|
|
568
569
|
datasheet_pdf_urls: string[] | null;
|
|
570
|
+
ai_description: string | null;
|
|
569
571
|
}, {
|
|
570
572
|
created_at: string;
|
|
571
573
|
datasheet_id: string;
|
|
@@ -577,6 +579,7 @@ declare const datasheetSchema: z.ZodObject<{
|
|
|
577
579
|
capabilities: string[];
|
|
578
580
|
}[] | null;
|
|
579
581
|
datasheet_pdf_urls: string[] | null;
|
|
582
|
+
ai_description: string | null;
|
|
580
583
|
}>;
|
|
581
584
|
type Datasheet = z.infer<typeof datasheetSchema>;
|
|
582
585
|
declare const accountSnippetSchema: z.ZodObject<{
|
|
@@ -795,6 +798,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
795
798
|
is_private: boolean | null;
|
|
796
799
|
is_public: boolean | null;
|
|
797
800
|
is_unlisted: boolean | null;
|
|
801
|
+
ai_description: string | null;
|
|
798
802
|
package_id: string;
|
|
799
803
|
license: string | null;
|
|
800
804
|
creator_account_id: string;
|
|
@@ -809,7 +813,6 @@ declare const packageSchema: z.ZodObject<{
|
|
|
809
813
|
latest_package_release_id: string | null;
|
|
810
814
|
latest_version: string | null;
|
|
811
815
|
website: string | null;
|
|
812
|
-
ai_description: string | null;
|
|
813
816
|
ai_usage_instructions: string | null;
|
|
814
817
|
latest_package_release_fs_sha: string | null;
|
|
815
818
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -821,6 +824,7 @@ declare const packageSchema: z.ZodObject<{
|
|
|
821
824
|
created_at: string;
|
|
822
825
|
updated_at: string;
|
|
823
826
|
description: string | null;
|
|
827
|
+
ai_description: string | null;
|
|
824
828
|
package_id: string;
|
|
825
829
|
license: string | null;
|
|
826
830
|
creator_account_id: string;
|
|
@@ -828,7 +832,6 @@ declare const packageSchema: z.ZodObject<{
|
|
|
828
832
|
owner_github_username: string | null;
|
|
829
833
|
latest_package_release_id: string | null;
|
|
830
834
|
latest_version: string | null;
|
|
831
|
-
ai_description: string | null;
|
|
832
835
|
ai_usage_instructions: string | null;
|
|
833
836
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
834
837
|
star_count?: number | undefined;
|
|
@@ -1296,6 +1299,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1296
1299
|
is_private: boolean | null;
|
|
1297
1300
|
is_public: boolean | null;
|
|
1298
1301
|
is_unlisted: boolean | null;
|
|
1302
|
+
ai_description: string | null;
|
|
1299
1303
|
package_id: string;
|
|
1300
1304
|
license: string | null;
|
|
1301
1305
|
creator_account_id: string;
|
|
@@ -1310,7 +1314,6 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1310
1314
|
latest_package_release_id: string | null;
|
|
1311
1315
|
latest_version: string | null;
|
|
1312
1316
|
website: string | null;
|
|
1313
|
-
ai_description: string | null;
|
|
1314
1317
|
ai_usage_instructions: string | null;
|
|
1315
1318
|
latest_package_release_fs_sha: string | null;
|
|
1316
1319
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -1322,6 +1325,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1322
1325
|
created_at: string;
|
|
1323
1326
|
updated_at: string;
|
|
1324
1327
|
description: string | null;
|
|
1328
|
+
ai_description: string | null;
|
|
1325
1329
|
package_id: string;
|
|
1326
1330
|
license: string | null;
|
|
1327
1331
|
creator_account_id: string;
|
|
@@ -1329,7 +1333,6 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1329
1333
|
owner_github_username: string | null;
|
|
1330
1334
|
latest_package_release_id: string | null;
|
|
1331
1335
|
latest_version: string | null;
|
|
1332
|
-
ai_description: string | null;
|
|
1333
1336
|
ai_usage_instructions: string | null;
|
|
1334
1337
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
1335
1338
|
star_count?: number | undefined;
|
|
@@ -1734,6 +1737,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1734
1737
|
capabilities: string[];
|
|
1735
1738
|
}>, "many">>;
|
|
1736
1739
|
datasheet_pdf_urls: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
|
1740
|
+
ai_description: z.ZodNullable<z.ZodString>;
|
|
1737
1741
|
}, "strip", z.ZodTypeAny, {
|
|
1738
1742
|
created_at: string;
|
|
1739
1743
|
datasheet_id: string;
|
|
@@ -1745,6 +1749,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1745
1749
|
capabilities: string[];
|
|
1746
1750
|
}[] | null;
|
|
1747
1751
|
datasheet_pdf_urls: string[] | null;
|
|
1752
|
+
ai_description: string | null;
|
|
1748
1753
|
}, {
|
|
1749
1754
|
created_at: string;
|
|
1750
1755
|
datasheet_id: string;
|
|
@@ -1756,6 +1761,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1756
1761
|
capabilities: string[];
|
|
1757
1762
|
}[] | null;
|
|
1758
1763
|
datasheet_pdf_urls: string[] | null;
|
|
1764
|
+
ai_description: string | null;
|
|
1759
1765
|
}>, "many">>;
|
|
1760
1766
|
}, "strip", z.ZodTypeAny, {
|
|
1761
1767
|
idCounter: number;
|
|
@@ -1868,6 +1874,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1868
1874
|
is_private: boolean | null;
|
|
1869
1875
|
is_public: boolean | null;
|
|
1870
1876
|
is_unlisted: boolean | null;
|
|
1877
|
+
ai_description: string | null;
|
|
1871
1878
|
package_id: string;
|
|
1872
1879
|
license: string | null;
|
|
1873
1880
|
creator_account_id: string;
|
|
@@ -1882,7 +1889,6 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1882
1889
|
latest_package_release_id: string | null;
|
|
1883
1890
|
latest_version: string | null;
|
|
1884
1891
|
website: string | null;
|
|
1885
|
-
ai_description: string | null;
|
|
1886
1892
|
ai_usage_instructions: string | null;
|
|
1887
1893
|
latest_package_release_fs_sha: string | null;
|
|
1888
1894
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
@@ -2016,6 +2022,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2016
2022
|
capabilities: string[];
|
|
2017
2023
|
}[] | null;
|
|
2018
2024
|
datasheet_pdf_urls: string[] | null;
|
|
2025
|
+
ai_description: string | null;
|
|
2019
2026
|
}[];
|
|
2020
2027
|
}, {
|
|
2021
2028
|
idCounter?: number | undefined;
|
|
@@ -2124,6 +2131,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2124
2131
|
created_at: string;
|
|
2125
2132
|
updated_at: string;
|
|
2126
2133
|
description: string | null;
|
|
2134
|
+
ai_description: string | null;
|
|
2127
2135
|
package_id: string;
|
|
2128
2136
|
license: string | null;
|
|
2129
2137
|
creator_account_id: string;
|
|
@@ -2131,7 +2139,6 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2131
2139
|
owner_github_username: string | null;
|
|
2132
2140
|
latest_package_release_id: string | null;
|
|
2133
2141
|
latest_version: string | null;
|
|
2134
|
-
ai_description: string | null;
|
|
2135
2142
|
ai_usage_instructions: string | null;
|
|
2136
2143
|
snippet_type?: "board" | "package" | "model" | "footprint" | undefined;
|
|
2137
2144
|
star_count?: number | undefined;
|
|
@@ -2276,6 +2283,7 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
2276
2283
|
capabilities: string[];
|
|
2277
2284
|
}[] | null;
|
|
2278
2285
|
datasheet_pdf_urls: string[] | null;
|
|
2286
|
+
ai_description: string | null;
|
|
2279
2287
|
}[] | undefined;
|
|
2280
2288
|
}>;
|
|
2281
2289
|
type DatabaseSchema = z.infer<typeof databaseSchema>;
|
package/dist/schema.js
CHANGED
|
@@ -136,7 +136,8 @@ var datasheetSchema = z.object({
|
|
|
136
136
|
chip_name: z.string(),
|
|
137
137
|
created_at: z.string(),
|
|
138
138
|
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
139
|
-
datasheet_pdf_urls: z.array(z.string()).nullable()
|
|
139
|
+
datasheet_pdf_urls: z.array(z.string()).nullable(),
|
|
140
|
+
ai_description: z.string().nullable()
|
|
140
141
|
});
|
|
141
142
|
var accountSnippetSchema = z.object({
|
|
142
143
|
account_id: z.string(),
|
|
@@ -1387,6 +1387,7 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
1387
1387
|
created_at: new Date().toISOString(),
|
|
1388
1388
|
pin_information: null,
|
|
1389
1389
|
datasheet_pdf_urls: null,
|
|
1390
|
+
ai_description: null,
|
|
1390
1391
|
})
|
|
1391
1392
|
set((state) => ({
|
|
1392
1393
|
datasheets: [...state.datasheets, newDatasheet],
|
|
@@ -1399,7 +1400,9 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
1399
1400
|
},
|
|
1400
1401
|
getDatasheetByChipName: (chipName: string): Datasheet | undefined => {
|
|
1401
1402
|
const state = get()
|
|
1402
|
-
return state.datasheets.find(
|
|
1403
|
+
return state.datasheets.find(
|
|
1404
|
+
(d) => d.chip_name.toLowerCase() === chipName.toLowerCase(),
|
|
1405
|
+
)
|
|
1403
1406
|
},
|
|
1404
1407
|
listDatasheets: ({
|
|
1405
1408
|
chip_name,
|
|
@@ -163,6 +163,7 @@ export const datasheetSchema = z.object({
|
|
|
163
163
|
created_at: z.string(),
|
|
164
164
|
pin_information: datasheetPinInformationSchema.array().nullable(),
|
|
165
165
|
datasheet_pdf_urls: z.array(z.string()).nullable(),
|
|
166
|
+
ai_description: z.string().nullable(),
|
|
166
167
|
})
|
|
167
168
|
export type Datasheet = z.infer<typeof datasheetSchema>
|
|
168
169
|
|
|
@@ -5,7 +5,7 @@ import { z } from "zod"
|
|
|
5
5
|
export const processAllDatasheets = (ctx: any) => {
|
|
6
6
|
const processed = [] as z.infer<typeof datasheetSchema>[]
|
|
7
7
|
ctx.db.datasheets.forEach((ds: any) => {
|
|
8
|
-
if (!ds.pin_information || !ds.datasheet_pdf_urls) {
|
|
8
|
+
if (!ds.pin_information || !ds.datasheet_pdf_urls || !ds.ai_description) {
|
|
9
9
|
const updated = ctx.db.updateDatasheet(ds.datasheet_id, {
|
|
10
10
|
pin_information: [
|
|
11
11
|
{
|
|
@@ -16,6 +16,7 @@ export const processAllDatasheets = (ctx: any) => {
|
|
|
16
16
|
},
|
|
17
17
|
],
|
|
18
18
|
datasheet_pdf_urls: ["https://example.com/datasheet.pdf"],
|
|
19
|
+
ai_description: "Placeholder ai description",
|
|
19
20
|
})
|
|
20
21
|
processed.push(updated!)
|
|
21
22
|
} else {
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -69,6 +69,7 @@ const ViewPackagePage = lazyImport(() => import("@/pages/view-package"))
|
|
|
69
69
|
const PackageBuildsPage = lazyImport(() => import("@/pages/package-builds"))
|
|
70
70
|
const TrendingPage = lazyImport(() => import("@/pages/trending"))
|
|
71
71
|
const DatasheetPage = lazyImport(() => import("@/pages/datasheet"))
|
|
72
|
+
const DatasheetsPage = lazyImport(() => import("@/pages/datasheets"))
|
|
72
73
|
const PackageEditorPage = lazyImport(async () => {
|
|
73
74
|
const [editorModule] = await Promise.all([
|
|
74
75
|
import("@/pages/package-editor"),
|
|
@@ -181,6 +182,7 @@ function App() {
|
|
|
181
182
|
<Route path="/settings" component={SettingsPage} />
|
|
182
183
|
<Route path="/search" component={SearchPage} />
|
|
183
184
|
<Route path="/trending" component={TrendingPage} />
|
|
185
|
+
<Route path="/datasheets" component={DatasheetsPage} />
|
|
184
186
|
<Route path="/datasheets/:chipName" component={DatasheetPage} />
|
|
185
187
|
<Route path="/authorize" component={AuthenticatePage} />
|
|
186
188
|
<Route path="/my-orders" component={MyOrdersPage} />
|
|
@@ -65,11 +65,11 @@ export function DownloadButtonAndMenu({
|
|
|
65
65
|
<DropdownMenuTrigger asChild>
|
|
66
66
|
<Button
|
|
67
67
|
size="sm"
|
|
68
|
-
className="bg-
|
|
68
|
+
className="bg-transparent shadow-inner hover:bg-gray-100 text-gray-700 outline-none"
|
|
69
69
|
>
|
|
70
|
-
<Download className="
|
|
70
|
+
<Download className="h-4 w-4 mr-1.5" />
|
|
71
71
|
Download
|
|
72
|
-
<ChevronDown className="
|
|
72
|
+
<ChevronDown className="h-4 w-4 ml-0.5" />
|
|
73
73
|
</Button>
|
|
74
74
|
</DropdownMenuTrigger>
|
|
75
75
|
<DropdownMenuContent className="!z-[101]">
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
|
|
3
|
+
interface ExpandableTextProps {
|
|
4
|
+
text: string
|
|
5
|
+
maxChars?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ExpandableText = ({ text, maxChars = 30 }: ExpandableTextProps) => {
|
|
9
|
+
const [expanded, setExpanded] = useState(false)
|
|
10
|
+
|
|
11
|
+
if (text.length <= maxChars) {
|
|
12
|
+
return <span>{text}</span>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<span>
|
|
17
|
+
{expanded ? text : `${text.slice(0, maxChars)}...`}
|
|
18
|
+
<button
|
|
19
|
+
className="text-blue-600 underline ml-1"
|
|
20
|
+
type="button"
|
|
21
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
22
|
+
>
|
|
23
|
+
{expanded ? "Show less" : "Show more"}
|
|
24
|
+
</button>
|
|
25
|
+
</span>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default ExpandableText
|
|
@@ -80,6 +80,9 @@ export default function Header() {
|
|
|
80
80
|
Editor
|
|
81
81
|
</HeaderButton>
|
|
82
82
|
</li>
|
|
83
|
+
<li>
|
|
84
|
+
<HeaderButton href="/datasheets">Datasheets</HeaderButton>
|
|
85
|
+
</li>
|
|
83
86
|
<li>
|
|
84
87
|
<a href="https://chat.tscircuit.com">
|
|
85
88
|
<Button variant="ghost">AI</Button>
|
|
@@ -152,6 +155,14 @@ export default function Header() {
|
|
|
152
155
|
Editor
|
|
153
156
|
</HeaderButton>
|
|
154
157
|
</li>
|
|
158
|
+
<li>
|
|
159
|
+
<HeaderButton
|
|
160
|
+
className="w-full justify-start"
|
|
161
|
+
href="/datasheets"
|
|
162
|
+
>
|
|
163
|
+
Datasheets
|
|
164
|
+
</HeaderButton>
|
|
165
|
+
</li>
|
|
155
166
|
<li>
|
|
156
167
|
<HeaderButton
|
|
157
168
|
className="w-full justify-start"
|
|
@@ -88,6 +88,12 @@ export const Header2 = () => {
|
|
|
88
88
|
>
|
|
89
89
|
Editor
|
|
90
90
|
</PrefetchPageLink>
|
|
91
|
+
<PrefetchPageLink
|
|
92
|
+
className="text-sm font-medium hover:underline underline-offset-4"
|
|
93
|
+
href="/datasheets"
|
|
94
|
+
>
|
|
95
|
+
Datasheets
|
|
96
|
+
</PrefetchPageLink>
|
|
91
97
|
{/* <a
|
|
92
98
|
className="text-sm font-medium hover:underline underline-offset-4"
|
|
93
99
|
href="https://github.com/tscircuit/tscircuit"
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
PencilIcon,
|
|
9
9
|
Share2,
|
|
10
10
|
Trash2,
|
|
11
|
+
CircuitBoard,
|
|
11
12
|
} from "lucide-react"
|
|
12
13
|
import { Button } from "@/components/ui/button"
|
|
13
14
|
import {
|
|
@@ -107,13 +108,21 @@ export const PackageCard: React.FC<PackageCardProps> = ({
|
|
|
107
108
|
>
|
|
108
109
|
<div className="flex items-start gap-4">
|
|
109
110
|
<div
|
|
110
|
-
className={`${imageSize} flex-shrink-0 rounded-md overflow-hidden`}
|
|
111
|
+
className={`${imageSize} flex-shrink-0 rounded-md overflow-hidden bg-gray-50 border flex items-center justify-center`}
|
|
111
112
|
>
|
|
112
|
-
<
|
|
113
|
+
<img
|
|
113
114
|
src={`${baseUrl}/packages/images/${pkg.owner_github_username}/${pkg.unscoped_name}/${availableImages.includes(pkg.default_view || "") ? pkg.default_view : "3d"}.png?fs_sha=${pkg.latest_package_release_fs_sha}`}
|
|
114
115
|
alt={`${pkg.unscoped_name} ${availableImages.includes(pkg.default_view || "") ? pkg.default_view : "3D"} view`}
|
|
115
116
|
className={`object-cover h-full w-full ${imageTransform}`}
|
|
117
|
+
onError={(e) => {
|
|
118
|
+
e.currentTarget.style.display = "none"
|
|
119
|
+
e.currentTarget.nextElementSibling?.classList.remove("hidden")
|
|
120
|
+
e.currentTarget.nextElementSibling?.classList.add("flex")
|
|
121
|
+
}}
|
|
116
122
|
/>
|
|
123
|
+
<div className="hidden items-center justify-center h-full w-full">
|
|
124
|
+
<CircuitBoard className="w-6 h-6 text-gray-300" />
|
|
125
|
+
</div>
|
|
117
126
|
</div>
|
|
118
127
|
<div className="flex-1 min-w-0">
|
|
119
128
|
<div className="flex justify-between items-start mb-[2px] -mt-[3px]">
|
|
@@ -14,18 +14,27 @@ const PREFETCHABLE_PAGES = new Set([
|
|
|
14
14
|
"latest",
|
|
15
15
|
"settings",
|
|
16
16
|
"quickstart",
|
|
17
|
+
"datasheets",
|
|
17
18
|
])
|
|
18
19
|
|
|
19
20
|
// Helper to check if a path is a package path (e.g. /username/package-name)
|
|
20
21
|
const isPackagePath = (path: string) => {
|
|
21
22
|
const parts = path.split("/").filter(Boolean)
|
|
22
|
-
|
|
23
|
+
if (parts.length !== 2) return false
|
|
24
|
+
|
|
25
|
+
// Make sure we're not matching paths with query parameters in the first segment
|
|
26
|
+
const firstPart = parts[0].split("?")[0]
|
|
27
|
+
return firstPart.length > 0 && !PREFETCHABLE_PAGES.has(firstPart)
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
// Helper to check if a path is a user profile path
|
|
26
31
|
const isUserProfilePath = (path: string) => {
|
|
27
32
|
const parts = path.split("/").filter(Boolean)
|
|
28
|
-
|
|
33
|
+
if (parts.length !== 1) return false
|
|
34
|
+
|
|
35
|
+
// Extract the base path without query parameters
|
|
36
|
+
const basePath = parts[0].split("?")[0]
|
|
37
|
+
return !PREFETCHABLE_PAGES.has(basePath)
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
export const PrefetchPageLink = ({
|
|
@@ -94,7 +94,7 @@ export default function MainContentHeader({
|
|
|
94
94
|
<DropdownMenuTrigger asChild>
|
|
95
95
|
<Button
|
|
96
96
|
size="sm"
|
|
97
|
-
className="bg-green-600 hover:bg-green-700 dark:bg-[#238636] dark:hover:bg-[#2ea043] text-white"
|
|
97
|
+
className="bg-green-600 shadow-none hover:bg-green-700 dark:bg-[#238636] dark:hover:bg-[#2ea043] text-white"
|
|
98
98
|
>
|
|
99
99
|
<CodeIcon className="h-4 w-4 mr-1.5" />
|
|
100
100
|
Code
|
|
@@ -17,8 +17,9 @@ export const useAccountBalance = () => {
|
|
|
17
17
|
return data.account_balance
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
refetchInterval: 60000, // Refetch every minute
|
|
20
|
+
// refetchInterval: 60000, // Refetch every minute
|
|
21
21
|
enabled: isLoggedIn,
|
|
22
|
+
refetchOnWindowFocus: false,
|
|
22
23
|
},
|
|
23
24
|
)
|
|
24
25
|
}
|
package/src/pages/datasheet.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useDatasheet } from "@/hooks/use-datasheet"
|
|
|
3
3
|
import { useCreateDatasheet } from "@/hooks/use-create-datasheet"
|
|
4
4
|
import Header from "@/components/Header"
|
|
5
5
|
import Footer from "@/components/Footer"
|
|
6
|
+
import ExpandableText from "@/components/ExpandableText"
|
|
6
7
|
import type { Datasheet } from "fake-snippets-api/lib/db/schema"
|
|
7
8
|
|
|
8
9
|
export const DatasheetPage = () => {
|
|
@@ -20,10 +21,38 @@ export const DatasheetPage = () => {
|
|
|
20
21
|
<Header />
|
|
21
22
|
<main className="container mx-auto flex-1 px-4 py-8">
|
|
22
23
|
<h1 className="text-3xl font-bold mb-6">{chipName} Datasheet</h1>
|
|
24
|
+
<p className="mb-4">
|
|
25
|
+
<a
|
|
26
|
+
href={`https://api.tscircuit.com/datasheets/get?chip_name=${encodeURIComponent(chipName)}`}
|
|
27
|
+
className="text-blue-600 underline"
|
|
28
|
+
>
|
|
29
|
+
Download JSON
|
|
30
|
+
</a>
|
|
31
|
+
</p>
|
|
23
32
|
{datasheetQuery.isLoading ? (
|
|
24
33
|
<p>Loading...</p>
|
|
25
34
|
) : datasheetQuery.data ? (
|
|
26
35
|
<div>
|
|
36
|
+
{!datasheetQuery.data.pin_information &&
|
|
37
|
+
!datasheetQuery.data.datasheet_pdf_urls && (
|
|
38
|
+
<p>Datasheet is processing. Please check back later.</p>
|
|
39
|
+
)}
|
|
40
|
+
|
|
41
|
+
<h2 className="text-xl font-semibold mb-2">PDFs</h2>
|
|
42
|
+
{datasheetQuery.data.datasheet_pdf_urls ? (
|
|
43
|
+
<ul className="list-disc pl-5 mb-6">
|
|
44
|
+
{datasheetQuery.data.datasheet_pdf_urls.map((url) => (
|
|
45
|
+
<li key={url}>
|
|
46
|
+
<a href={url} className="text-blue-600 underline">
|
|
47
|
+
{url}
|
|
48
|
+
</a>
|
|
49
|
+
</li>
|
|
50
|
+
))}
|
|
51
|
+
</ul>
|
|
52
|
+
) : (
|
|
53
|
+
<p>No datasheet PDFs available.</p>
|
|
54
|
+
)}
|
|
55
|
+
|
|
27
56
|
<h2 className="text-xl font-semibold mb-2">Pin Information</h2>
|
|
28
57
|
{datasheetQuery.data.pin_information ? (
|
|
29
58
|
<table className="table-auto border-collapse mb-6">
|
|
@@ -32,6 +61,7 @@ export const DatasheetPage = () => {
|
|
|
32
61
|
<th className="border px-2 py-1">Pin</th>
|
|
33
62
|
<th className="border px-2 py-1">Name</th>
|
|
34
63
|
<th className="border px-2 py-1">Description</th>
|
|
64
|
+
<th className="border px-2 py-1">Capabilities</th>
|
|
35
65
|
</tr>
|
|
36
66
|
</thead>
|
|
37
67
|
<tbody>
|
|
@@ -40,6 +70,12 @@ export const DatasheetPage = () => {
|
|
|
40
70
|
<td className="border px-2 py-1">{pin.pin_number}</td>
|
|
41
71
|
<td className="border px-2 py-1">{pin.name}</td>
|
|
42
72
|
<td className="border px-2 py-1">{pin.description}</td>
|
|
73
|
+
<td className="border px-2 py-1">
|
|
74
|
+
<ExpandableText
|
|
75
|
+
text={pin.capabilities.join(", ")}
|
|
76
|
+
maxChars={30}
|
|
77
|
+
/>
|
|
78
|
+
</td>
|
|
43
79
|
</tr>
|
|
44
80
|
))}
|
|
45
81
|
</tbody>
|
|
@@ -47,21 +83,6 @@ export const DatasheetPage = () => {
|
|
|
47
83
|
) : (
|
|
48
84
|
<p>No pin information available.</p>
|
|
49
85
|
)}
|
|
50
|
-
|
|
51
|
-
<h2 className="text-xl font-semibold mb-2">PDFs</h2>
|
|
52
|
-
{datasheetQuery.data.datasheet_pdf_urls ? (
|
|
53
|
-
<ul className="list-disc pl-5">
|
|
54
|
-
{datasheetQuery.data.datasheet_pdf_urls.map((url) => (
|
|
55
|
-
<li key={url}>
|
|
56
|
-
<a href={url} className="text-blue-600 underline">
|
|
57
|
-
{url}
|
|
58
|
-
</a>
|
|
59
|
-
</li>
|
|
60
|
-
))}
|
|
61
|
-
</ul>
|
|
62
|
-
) : (
|
|
63
|
-
<p>No datasheet PDFs available.</p>
|
|
64
|
-
)}
|
|
65
86
|
</div>
|
|
66
87
|
) : datasheetQuery.error &&
|
|
67
88
|
(datasheetQuery.error as any).status === 404 ? (
|