@tscircuit/fake-snippets 0.0.76 → 0.0.78
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/dist/bundle.js +264 -166
- package/dist/index.d.ts +15 -15
- package/dist/index.js +7 -4
- package/dist/schema.d.ts +24 -24
- package/dist/schema.js +3 -3
- package/fake-snippets-api/lib/db/autoload-dev-packages.ts +8 -0
- package/fake-snippets-api/lib/db/schema.ts +3 -3
- package/fake-snippets-api/routes/api/packages/generate_from_jlcpcb.ts +111 -0
- package/package.json +1 -1
- package/src/App.tsx +0 -3
- package/src/components/CircuitJsonImportDialog.tsx +20 -3
- package/src/components/JLCPCBImportDialog.tsx +31 -27
- package/src/components/PackageBuildsPage/LogContent.tsx +25 -9
- package/src/components/PackageBuildsPage/PackageBuildDetailsPage.tsx +5 -5
- package/src/components/PackageBuildsPage/getColorForDisplayStatus.ts +2 -2
- package/src/components/PackageBuildsPage/package-build-details-panel.tsx +3 -4
- package/src/components/dialogs/rename-package-dialog.tsx +5 -0
- package/src/components/package-port/CodeEditor.tsx +28 -16
- package/src/hooks/use-current-package-release.ts +6 -2
- package/src/hooks/use-package-release.ts +16 -3
- package/src/pages/latest.tsx +29 -87
- package/src/pages/beta.tsx +0 -367
package/dist/index.d.ts
CHANGED
|
@@ -421,15 +421,15 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
421
421
|
has_transpiled: z.ZodDefault<z.ZodBoolean>;
|
|
422
422
|
transpilation_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
423
423
|
fs_sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
424
|
-
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
424
|
+
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
425
425
|
total_build_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
426
|
-
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
426
|
+
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
427
427
|
transpilation_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
428
428
|
transpilation_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
429
429
|
transpilation_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
430
430
|
transpilation_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
|
|
431
431
|
transpilation_is_stale: z.ZodDefault<z.ZodBoolean>;
|
|
432
|
-
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
432
|
+
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
433
433
|
circuit_json_build_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
434
434
|
circuit_json_build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
435
435
|
circuit_json_build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -443,12 +443,12 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
443
443
|
is_locked: boolean;
|
|
444
444
|
is_latest: boolean;
|
|
445
445
|
has_transpiled: boolean;
|
|
446
|
-
display_status: "
|
|
447
|
-
transpilation_display_status: "
|
|
446
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
447
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
448
448
|
transpilation_in_progress: boolean;
|
|
449
449
|
transpilation_logs: any[];
|
|
450
450
|
transpilation_is_stale: boolean;
|
|
451
|
-
circuit_json_build_display_status: "
|
|
451
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
452
452
|
circuit_json_build_in_progress: boolean;
|
|
453
453
|
circuit_json_build_logs: any[];
|
|
454
454
|
circuit_json_build_is_stale: boolean;
|
|
@@ -477,15 +477,15 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
477
477
|
has_transpiled?: boolean | undefined;
|
|
478
478
|
transpilation_error?: string | null | undefined;
|
|
479
479
|
fs_sha?: string | null | undefined;
|
|
480
|
-
display_status?: "
|
|
480
|
+
display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
481
481
|
total_build_duration_ms?: number | null | undefined;
|
|
482
|
-
transpilation_display_status?: "
|
|
482
|
+
transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
483
483
|
transpilation_in_progress?: boolean | undefined;
|
|
484
484
|
transpilation_started_at?: string | null | undefined;
|
|
485
485
|
transpilation_completed_at?: string | null | undefined;
|
|
486
486
|
transpilation_logs?: any[] | undefined;
|
|
487
487
|
transpilation_is_stale?: boolean | undefined;
|
|
488
|
-
circuit_json_build_display_status?: "
|
|
488
|
+
circuit_json_build_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
489
489
|
circuit_json_build_in_progress?: boolean | undefined;
|
|
490
490
|
circuit_json_build_started_at?: string | null | undefined;
|
|
491
491
|
circuit_json_build_completed_at?: string | null | undefined;
|
|
@@ -751,12 +751,12 @@ declare const createDatabase: ({ seed }?: {
|
|
|
751
751
|
is_locked: boolean;
|
|
752
752
|
is_latest: boolean;
|
|
753
753
|
has_transpiled: boolean;
|
|
754
|
-
display_status: "
|
|
755
|
-
transpilation_display_status: "
|
|
754
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
755
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
756
756
|
transpilation_in_progress: boolean;
|
|
757
757
|
transpilation_logs: any[];
|
|
758
758
|
transpilation_is_stale: boolean;
|
|
759
|
-
circuit_json_build_display_status: "
|
|
759
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
760
760
|
circuit_json_build_in_progress: boolean;
|
|
761
761
|
circuit_json_build_logs: any[];
|
|
762
762
|
circuit_json_build_is_stale: boolean;
|
|
@@ -1061,12 +1061,12 @@ declare const createDatabase: ({ seed }?: {
|
|
|
1061
1061
|
is_locked: boolean;
|
|
1062
1062
|
is_latest: boolean;
|
|
1063
1063
|
has_transpiled: boolean;
|
|
1064
|
-
display_status: "
|
|
1065
|
-
transpilation_display_status: "
|
|
1064
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
1065
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
1066
1066
|
transpilation_in_progress: boolean;
|
|
1067
1067
|
transpilation_logs: any[];
|
|
1068
1068
|
transpilation_is_stale: boolean;
|
|
1069
|
-
circuit_json_build_display_status: "
|
|
1069
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
1070
1070
|
circuit_json_build_in_progress: boolean;
|
|
1071
1071
|
circuit_json_build_logs: any[];
|
|
1072
1072
|
circuit_json_build_is_stale: boolean;
|
package/dist/index.js
CHANGED
|
@@ -150,17 +150,17 @@ var packageReleaseSchema = z.object({
|
|
|
150
150
|
transpilation_error: z.string().nullable().optional(),
|
|
151
151
|
fs_sha: z.string().nullable().optional(),
|
|
152
152
|
// Build Status and Display
|
|
153
|
-
display_status: z.enum(["pending", "building", "
|
|
153
|
+
display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
154
154
|
total_build_duration_ms: z.number().nullable().optional(),
|
|
155
155
|
// Transpilation Process
|
|
156
|
-
transpilation_display_status: z.enum(["pending", "building", "
|
|
156
|
+
transpilation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
157
157
|
transpilation_in_progress: z.boolean().default(false),
|
|
158
158
|
transpilation_started_at: z.string().datetime().nullable().optional(),
|
|
159
159
|
transpilation_completed_at: z.string().datetime().nullable().optional(),
|
|
160
160
|
transpilation_logs: z.array(z.any()).default([]),
|
|
161
161
|
transpilation_is_stale: z.boolean().default(false),
|
|
162
162
|
// Circuit JSON Build Process
|
|
163
|
-
circuit_json_build_display_status: z.enum(["pending", "building", "
|
|
163
|
+
circuit_json_build_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
164
164
|
circuit_json_build_in_progress: z.boolean().default(false),
|
|
165
165
|
circuit_json_build_started_at: z.string().datetime().nullable().optional(),
|
|
166
166
|
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
@@ -359,7 +359,10 @@ var loadPackageWithDependencies = async (db, owner, name, loadedPackages = /* @_
|
|
|
359
359
|
});
|
|
360
360
|
db.addPackageRelease({
|
|
361
361
|
...release,
|
|
362
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
362
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
363
|
+
transpilation_logs: Array.isArray(release.transpilation_logs) ? release.transpilation_logs : [],
|
|
364
|
+
circuit_json_build_logs: Array.isArray(release.circuit_json_build_logs) ? release.circuit_json_build_logs : [],
|
|
365
|
+
transpilation_display_status: release.transpilation_display_status ?? "pending"
|
|
363
366
|
});
|
|
364
367
|
for (const file of files) {
|
|
365
368
|
db.addPackageFile({
|
package/dist/schema.d.ts
CHANGED
|
@@ -546,15 +546,15 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
546
546
|
has_transpiled: z.ZodDefault<z.ZodBoolean>;
|
|
547
547
|
transpilation_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
548
548
|
fs_sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
549
|
-
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
549
|
+
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
550
550
|
total_build_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
551
|
-
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
551
|
+
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
552
552
|
transpilation_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
553
553
|
transpilation_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
554
554
|
transpilation_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
555
555
|
transpilation_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
|
|
556
556
|
transpilation_is_stale: z.ZodDefault<z.ZodBoolean>;
|
|
557
|
-
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
557
|
+
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
558
558
|
circuit_json_build_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
559
559
|
circuit_json_build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
560
560
|
circuit_json_build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -568,12 +568,12 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
568
568
|
is_locked: boolean;
|
|
569
569
|
is_latest: boolean;
|
|
570
570
|
has_transpiled: boolean;
|
|
571
|
-
display_status: "
|
|
572
|
-
transpilation_display_status: "
|
|
571
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
572
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
573
573
|
transpilation_in_progress: boolean;
|
|
574
574
|
transpilation_logs: any[];
|
|
575
575
|
transpilation_is_stale: boolean;
|
|
576
|
-
circuit_json_build_display_status: "
|
|
576
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
577
577
|
circuit_json_build_in_progress: boolean;
|
|
578
578
|
circuit_json_build_logs: any[];
|
|
579
579
|
circuit_json_build_is_stale: boolean;
|
|
@@ -602,15 +602,15 @@ declare const packageReleaseSchema: z.ZodObject<{
|
|
|
602
602
|
has_transpiled?: boolean | undefined;
|
|
603
603
|
transpilation_error?: string | null | undefined;
|
|
604
604
|
fs_sha?: string | null | undefined;
|
|
605
|
-
display_status?: "
|
|
605
|
+
display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
606
606
|
total_build_duration_ms?: number | null | undefined;
|
|
607
|
-
transpilation_display_status?: "
|
|
607
|
+
transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
608
608
|
transpilation_in_progress?: boolean | undefined;
|
|
609
609
|
transpilation_started_at?: string | null | undefined;
|
|
610
610
|
transpilation_completed_at?: string | null | undefined;
|
|
611
611
|
transpilation_logs?: any[] | undefined;
|
|
612
612
|
transpilation_is_stale?: boolean | undefined;
|
|
613
|
-
circuit_json_build_display_status?: "
|
|
613
|
+
circuit_json_build_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
614
614
|
circuit_json_build_in_progress?: boolean | undefined;
|
|
615
615
|
circuit_json_build_started_at?: string | null | undefined;
|
|
616
616
|
circuit_json_build_completed_at?: string | null | undefined;
|
|
@@ -925,15 +925,15 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
925
925
|
has_transpiled: z.ZodDefault<z.ZodBoolean>;
|
|
926
926
|
transpilation_error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
927
927
|
fs_sha: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
928
|
-
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
928
|
+
display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
929
929
|
total_build_duration_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
930
|
-
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
930
|
+
transpilation_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
931
931
|
transpilation_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
932
932
|
transpilation_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
933
933
|
transpilation_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
934
934
|
transpilation_logs: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
|
|
935
935
|
transpilation_is_stale: z.ZodDefault<z.ZodBoolean>;
|
|
936
|
-
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "
|
|
936
|
+
circuit_json_build_display_status: z.ZodDefault<z.ZodEnum<["pending", "building", "complete", "error"]>>;
|
|
937
937
|
circuit_json_build_in_progress: z.ZodDefault<z.ZodBoolean>;
|
|
938
938
|
circuit_json_build_started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
939
939
|
circuit_json_build_completed_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -947,12 +947,12 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
947
947
|
is_locked: boolean;
|
|
948
948
|
is_latest: boolean;
|
|
949
949
|
has_transpiled: boolean;
|
|
950
|
-
display_status: "
|
|
951
|
-
transpilation_display_status: "
|
|
950
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
951
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
952
952
|
transpilation_in_progress: boolean;
|
|
953
953
|
transpilation_logs: any[];
|
|
954
954
|
transpilation_is_stale: boolean;
|
|
955
|
-
circuit_json_build_display_status: "
|
|
955
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
956
956
|
circuit_json_build_in_progress: boolean;
|
|
957
957
|
circuit_json_build_logs: any[];
|
|
958
958
|
circuit_json_build_is_stale: boolean;
|
|
@@ -981,15 +981,15 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
981
981
|
has_transpiled?: boolean | undefined;
|
|
982
982
|
transpilation_error?: string | null | undefined;
|
|
983
983
|
fs_sha?: string | null | undefined;
|
|
984
|
-
display_status?: "
|
|
984
|
+
display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
985
985
|
total_build_duration_ms?: number | null | undefined;
|
|
986
|
-
transpilation_display_status?: "
|
|
986
|
+
transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
987
987
|
transpilation_in_progress?: boolean | undefined;
|
|
988
988
|
transpilation_started_at?: string | null | undefined;
|
|
989
989
|
transpilation_completed_at?: string | null | undefined;
|
|
990
990
|
transpilation_logs?: any[] | undefined;
|
|
991
991
|
transpilation_is_stale?: boolean | undefined;
|
|
992
|
-
circuit_json_build_display_status?: "
|
|
992
|
+
circuit_json_build_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
993
993
|
circuit_json_build_in_progress?: boolean | undefined;
|
|
994
994
|
circuit_json_build_started_at?: string | null | undefined;
|
|
995
995
|
circuit_json_build_completed_at?: string | null | undefined;
|
|
@@ -1593,12 +1593,12 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1593
1593
|
is_locked: boolean;
|
|
1594
1594
|
is_latest: boolean;
|
|
1595
1595
|
has_transpiled: boolean;
|
|
1596
|
-
display_status: "
|
|
1597
|
-
transpilation_display_status: "
|
|
1596
|
+
display_status: "error" | "pending" | "building" | "complete";
|
|
1597
|
+
transpilation_display_status: "error" | "pending" | "building" | "complete";
|
|
1598
1598
|
transpilation_in_progress: boolean;
|
|
1599
1599
|
transpilation_logs: any[];
|
|
1600
1600
|
transpilation_is_stale: boolean;
|
|
1601
|
-
circuit_json_build_display_status: "
|
|
1601
|
+
circuit_json_build_display_status: "error" | "pending" | "building" | "complete";
|
|
1602
1602
|
circuit_json_build_in_progress: boolean;
|
|
1603
1603
|
circuit_json_build_logs: any[];
|
|
1604
1604
|
circuit_json_build_is_stale: boolean;
|
|
@@ -1831,15 +1831,15 @@ declare const databaseSchema: z.ZodObject<{
|
|
|
1831
1831
|
has_transpiled?: boolean | undefined;
|
|
1832
1832
|
transpilation_error?: string | null | undefined;
|
|
1833
1833
|
fs_sha?: string | null | undefined;
|
|
1834
|
-
display_status?: "
|
|
1834
|
+
display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
1835
1835
|
total_build_duration_ms?: number | null | undefined;
|
|
1836
|
-
transpilation_display_status?: "
|
|
1836
|
+
transpilation_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
1837
1837
|
transpilation_in_progress?: boolean | undefined;
|
|
1838
1838
|
transpilation_started_at?: string | null | undefined;
|
|
1839
1839
|
transpilation_completed_at?: string | null | undefined;
|
|
1840
1840
|
transpilation_logs?: any[] | undefined;
|
|
1841
1841
|
transpilation_is_stale?: boolean | undefined;
|
|
1842
|
-
circuit_json_build_display_status?: "
|
|
1842
|
+
circuit_json_build_display_status?: "error" | "pending" | "building" | "complete" | undefined;
|
|
1843
1843
|
circuit_json_build_in_progress?: boolean | undefined;
|
|
1844
1844
|
circuit_json_build_started_at?: string | null | undefined;
|
|
1845
1845
|
circuit_json_build_completed_at?: string | null | undefined;
|
package/dist/schema.js
CHANGED
|
@@ -145,17 +145,17 @@ var packageReleaseSchema = z.object({
|
|
|
145
145
|
transpilation_error: z.string().nullable().optional(),
|
|
146
146
|
fs_sha: z.string().nullable().optional(),
|
|
147
147
|
// Build Status and Display
|
|
148
|
-
display_status: z.enum(["pending", "building", "
|
|
148
|
+
display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
149
149
|
total_build_duration_ms: z.number().nullable().optional(),
|
|
150
150
|
// Transpilation Process
|
|
151
|
-
transpilation_display_status: z.enum(["pending", "building", "
|
|
151
|
+
transpilation_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
152
152
|
transpilation_in_progress: z.boolean().default(false),
|
|
153
153
|
transpilation_started_at: z.string().datetime().nullable().optional(),
|
|
154
154
|
transpilation_completed_at: z.string().datetime().nullable().optional(),
|
|
155
155
|
transpilation_logs: z.array(z.any()).default([]),
|
|
156
156
|
transpilation_is_stale: z.boolean().default(false),
|
|
157
157
|
// Circuit JSON Build Process
|
|
158
|
-
circuit_json_build_display_status: z.enum(["pending", "building", "
|
|
158
|
+
circuit_json_build_display_status: z.enum(["pending", "building", "complete", "error"]).default("pending"),
|
|
159
159
|
circuit_json_build_in_progress: z.boolean().default(false),
|
|
160
160
|
circuit_json_build_started_at: z.string().datetime().nullable().optional(),
|
|
161
161
|
circuit_json_build_completed_at: z.string().datetime().nullable().optional(),
|
|
@@ -123,6 +123,14 @@ const loadPackageWithDependencies = async (
|
|
|
123
123
|
db.addPackageRelease({
|
|
124
124
|
...release,
|
|
125
125
|
created_at: new Date().toISOString(),
|
|
126
|
+
transpilation_logs: Array.isArray(release.transpilation_logs)
|
|
127
|
+
? release.transpilation_logs
|
|
128
|
+
: [],
|
|
129
|
+
circuit_json_build_logs: Array.isArray(release.circuit_json_build_logs)
|
|
130
|
+
? release.circuit_json_build_logs
|
|
131
|
+
: [],
|
|
132
|
+
transpilation_display_status:
|
|
133
|
+
release.transpilation_display_status ?? "pending",
|
|
126
134
|
})
|
|
127
135
|
|
|
128
136
|
for (const file of files) {
|
|
@@ -178,13 +178,13 @@ export const packageReleaseSchema = z.object({
|
|
|
178
178
|
fs_sha: z.string().nullable().optional(),
|
|
179
179
|
// Build Status and Display
|
|
180
180
|
display_status: z
|
|
181
|
-
.enum(["pending", "building", "
|
|
181
|
+
.enum(["pending", "building", "complete", "error"])
|
|
182
182
|
.default("pending"),
|
|
183
183
|
total_build_duration_ms: z.number().nullable().optional(),
|
|
184
184
|
|
|
185
185
|
// Transpilation Process
|
|
186
186
|
transpilation_display_status: z
|
|
187
|
-
.enum(["pending", "building", "
|
|
187
|
+
.enum(["pending", "building", "complete", "error"])
|
|
188
188
|
.default("pending"),
|
|
189
189
|
transpilation_in_progress: z.boolean().default(false),
|
|
190
190
|
transpilation_started_at: z.string().datetime().nullable().optional(),
|
|
@@ -194,7 +194,7 @@ export const packageReleaseSchema = z.object({
|
|
|
194
194
|
|
|
195
195
|
// Circuit JSON Build Process
|
|
196
196
|
circuit_json_build_display_status: z
|
|
197
|
-
.enum(["pending", "building", "
|
|
197
|
+
.enum(["pending", "building", "complete", "error"])
|
|
198
198
|
.default("pending"),
|
|
199
199
|
circuit_json_build_in_progress: z.boolean().default(false),
|
|
200
200
|
circuit_json_build_started_at: z.string().datetime().nullable().optional(),
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { withRouteSpec } from "fake-snippets-api/lib/middleware/with-winter-spec"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import { packageSchema } from "fake-snippets-api/lib/db/schema"
|
|
4
|
+
import {
|
|
5
|
+
fetchEasyEDAComponent,
|
|
6
|
+
convertRawEasyEdaToTs,
|
|
7
|
+
normalizeManufacturerPartNumber,
|
|
8
|
+
EasyEdaJsonSchema,
|
|
9
|
+
} from "easyeda"
|
|
10
|
+
|
|
11
|
+
export default withRouteSpec({
|
|
12
|
+
methods: ["POST"],
|
|
13
|
+
auth: "session",
|
|
14
|
+
jsonBody: z.object({
|
|
15
|
+
jlcpcb_part_number: z.string().min(1, "JLCPCB part number is required"),
|
|
16
|
+
}),
|
|
17
|
+
jsonResponse: z.object({
|
|
18
|
+
ok: z.boolean(),
|
|
19
|
+
package: packageSchema,
|
|
20
|
+
}),
|
|
21
|
+
})(async (req, ctx) => {
|
|
22
|
+
const { jlcpcb_part_number } = req.jsonBody
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const rawEasyJson = await fetchEasyEDAComponent(jlcpcb_part_number)
|
|
26
|
+
|
|
27
|
+
if (!rawEasyJson) {
|
|
28
|
+
return ctx.error(404, {
|
|
29
|
+
error_code: "component_not_found",
|
|
30
|
+
message: `Component with JLCPCB part number ${jlcpcb_part_number} not found`,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const betterEasy = await EasyEdaJsonSchema.parse(rawEasyJson)
|
|
35
|
+
|
|
36
|
+
const tsxComponent = await convertRawEasyEdaToTs(rawEasyJson)
|
|
37
|
+
|
|
38
|
+
const componentName = normalizeManufacturerPartNumber(
|
|
39
|
+
betterEasy.dataStr.head.c_para["Manufacturer Part"] ?? "",
|
|
40
|
+
)
|
|
41
|
+
.replace(/[^a-zA-Z0-9-_]/g, "-")
|
|
42
|
+
.replace(/--/g, "-")
|
|
43
|
+
|
|
44
|
+
const packageName = `${ctx.auth.github_username}/${componentName}`
|
|
45
|
+
|
|
46
|
+
const existingPackage = ctx.db.packages.find((p) => p.name === packageName)
|
|
47
|
+
|
|
48
|
+
if (existingPackage) {
|
|
49
|
+
return ctx.json({
|
|
50
|
+
ok: true,
|
|
51
|
+
package: existingPackage,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const newPackage = {
|
|
56
|
+
name: packageName,
|
|
57
|
+
unscoped_name: componentName,
|
|
58
|
+
owner_name: ctx.auth.github_username,
|
|
59
|
+
code: tsxComponent,
|
|
60
|
+
created_at: new Date().toISOString(),
|
|
61
|
+
updated_at: new Date().toISOString(),
|
|
62
|
+
description: `Generated from JLCPCB part number ${jlcpcb_part_number}`,
|
|
63
|
+
creator_account_id: ctx.auth.account_id,
|
|
64
|
+
owner_org_id: ctx.auth.personal_org_id,
|
|
65
|
+
owner_github_username: ctx.auth.github_username,
|
|
66
|
+
latest_package_release_id: null,
|
|
67
|
+
latest_package_release_fs_sha: null,
|
|
68
|
+
latest_version: null,
|
|
69
|
+
license: null,
|
|
70
|
+
ai_description: "placeholder ai description",
|
|
71
|
+
ai_usage_instructions: "placeholder ai usage instructions",
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const createdPackage = ctx.db.addPackage(newPackage)
|
|
75
|
+
|
|
76
|
+
const createdPackageRelease = ctx.db.addPackageRelease({
|
|
77
|
+
package_id: createdPackage.package_id,
|
|
78
|
+
version: "1.0.0",
|
|
79
|
+
created_at: new Date().toISOString(),
|
|
80
|
+
is_latest: true,
|
|
81
|
+
is_locked: false,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
ctx.db.updatePackage(createdPackage.package_id, {
|
|
85
|
+
latest_package_release_id: createdPackageRelease.package_release_id,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
ctx.db.addPackageFile({
|
|
89
|
+
package_release_id: createdPackageRelease.package_release_id,
|
|
90
|
+
file_path: "index.tsx",
|
|
91
|
+
content_text: String(tsxComponent),
|
|
92
|
+
created_at: new Date().toISOString(),
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return ctx.json({
|
|
96
|
+
ok: true,
|
|
97
|
+
package: createdPackage as any,
|
|
98
|
+
})
|
|
99
|
+
} catch (error: any) {
|
|
100
|
+
if (String(error).includes("Component not found")) {
|
|
101
|
+
return ctx.error(404, {
|
|
102
|
+
error_code: "component_not_found",
|
|
103
|
+
message: `Component with JLCPCB part number ${jlcpcb_part_number} not found`,
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
return ctx.error(500, {
|
|
107
|
+
error_code: "package_generation_failed",
|
|
108
|
+
message: `Failed to generate package from JLCPCB part: ${error.message || String(error)}`,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
})
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -66,7 +66,6 @@ const SearchPage = lazyImport(() => import("@/pages/search"))
|
|
|
66
66
|
const SettingsPage = lazyImport(() => import("@/pages/settings"))
|
|
67
67
|
const UserProfilePage = lazyImport(() => import("@/pages/user-profile"))
|
|
68
68
|
const DevLoginPage = lazyImport(() => import("@/pages/dev-login"))
|
|
69
|
-
const BetaPage = lazyImport(() => import("@/pages/beta"))
|
|
70
69
|
const ViewPackagePage = lazyImport(() => import("@/pages/view-package"))
|
|
71
70
|
const PackageBuildsPage = lazyImport(() => import("@/pages/package-builds"))
|
|
72
71
|
const TrendingPage = lazyImport(() => import("@/pages/trending"))
|
|
@@ -106,8 +105,6 @@ function App() {
|
|
|
106
105
|
<Suspense fallback={<FullPageLoader />}>
|
|
107
106
|
<Switch>
|
|
108
107
|
<Route path="/" component={LandingPage} />
|
|
109
|
-
<Route path="/beta" component={BetaPage} />
|
|
110
|
-
<Route path="/beta/:author/:packageName" component={BetaPage} />
|
|
111
108
|
<Route
|
|
112
109
|
path="/view-package/:author/:packageName"
|
|
113
110
|
component={ViewPackagePage}
|
|
@@ -174,14 +174,31 @@ export function CircuitJsonImportDialog({
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
177
|
-
if (event.ctrlKey && event.key === "Enter") {
|
|
178
|
-
|
|
177
|
+
if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
|
|
178
|
+
event.preventDefault()
|
|
179
|
+
if (!isLoading && isLoggedIn && (circuitJson.trim() || file)) {
|
|
180
|
+
handleImport()
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const handleDialogKeyDown = (event: React.KeyboardEvent) => {
|
|
186
|
+
if (
|
|
187
|
+
event.key === "Enter" &&
|
|
188
|
+
!event.ctrlKey &&
|
|
189
|
+
!event.metaKey &&
|
|
190
|
+
event.target !== document.querySelector("textarea")
|
|
191
|
+
) {
|
|
192
|
+
event.preventDefault()
|
|
193
|
+
if (!isLoading && isLoggedIn && (circuitJson.trim() || file)) {
|
|
194
|
+
handleImport()
|
|
195
|
+
}
|
|
179
196
|
}
|
|
180
197
|
}
|
|
181
198
|
|
|
182
199
|
return (
|
|
183
200
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
184
|
-
<DialogContent>
|
|
201
|
+
<DialogContent onKeyDown={handleDialogKeyDown}>
|
|
185
202
|
<DialogHeader>
|
|
186
203
|
<DialogTitle>Import Circuit JSON</DialogTitle>
|
|
187
204
|
<DialogDescription>
|
|
@@ -50,31 +50,16 @@ export function JLCPCBImportDialog({
|
|
|
50
50
|
setHasBeenImportedToAccountAlready(false)
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const existingPackageRes = await axios.get(apiUrl, {
|
|
56
|
-
validateStatus: (status) => true,
|
|
53
|
+
const response = await axios.post("/packages/generate_from_jlcpcb", {
|
|
54
|
+
jlcpcb_part_number: partNumber,
|
|
57
55
|
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
setHasBeenImportedToAccountAlready(true)
|
|
56
|
+
if (!response.data.ok) {
|
|
57
|
+
setError("Failed to generate package from JLCPCB part")
|
|
61
58
|
setIsLoading(false)
|
|
62
59
|
return
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
const
|
|
66
|
-
.post("/snippets/generate_from_jlcpcb", {
|
|
67
|
-
jlcpcb_part_number: partNumber,
|
|
68
|
-
})
|
|
69
|
-
.catch((e) => e)
|
|
70
|
-
|
|
71
|
-
const { snippet, error } = response.data
|
|
72
|
-
|
|
73
|
-
if (error) {
|
|
74
|
-
setError(error.message)
|
|
75
|
-
setIsLoading(false)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
62
|
+
const { package: generatedPackage } = response.data
|
|
78
63
|
|
|
79
64
|
toast({
|
|
80
65
|
title: "Import Successful",
|
|
@@ -82,13 +67,21 @@ export function JLCPCBImportDialog({
|
|
|
82
67
|
})
|
|
83
68
|
|
|
84
69
|
onOpenChange(false)
|
|
85
|
-
navigate(`/editor?package_id=${
|
|
86
|
-
} catch (error) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
70
|
+
navigate(`/editor?package_id=${generatedPackage.package_id}`)
|
|
71
|
+
} catch (error: any) {
|
|
72
|
+
if (error.response?.status === 404) {
|
|
73
|
+
setError(`Component with JLCPCB part number ${partNumber} not found`)
|
|
74
|
+
} else if (error.response?.data?.message) {
|
|
75
|
+
setError(error.response.data.message)
|
|
76
|
+
} else {
|
|
77
|
+
setError("Failed to import the JLCPCB component. Please try again.")
|
|
78
|
+
toast({
|
|
79
|
+
title: "Import Failed",
|
|
80
|
+
description:
|
|
81
|
+
"Failed to import the JLCPCB component. Please try again.",
|
|
82
|
+
variant: "destructive",
|
|
83
|
+
})
|
|
84
|
+
}
|
|
92
85
|
} finally {
|
|
93
86
|
setIsLoading(false)
|
|
94
87
|
}
|
|
@@ -116,11 +109,22 @@ export function JLCPCBImportDialog({
|
|
|
116
109
|
className="mt-3"
|
|
117
110
|
placeholder="Enter JLCPCB part number (e.g., C46749)"
|
|
118
111
|
value={partNumber}
|
|
112
|
+
disabled={isLoading}
|
|
119
113
|
onChange={(e) => {
|
|
120
114
|
setPartNumber(e.target.value)
|
|
121
115
|
setError(null)
|
|
122
116
|
setHasBeenImportedToAccountAlready(false)
|
|
123
117
|
}}
|
|
118
|
+
onKeyDown={(e) => {
|
|
119
|
+
if (
|
|
120
|
+
e.key === "Enter" &&
|
|
121
|
+
!isLoading &&
|
|
122
|
+
isLoggedIn &&
|
|
123
|
+
partNumber.trim()
|
|
124
|
+
) {
|
|
125
|
+
handleImport()
|
|
126
|
+
}
|
|
127
|
+
}}
|
|
124
128
|
/>
|
|
125
129
|
{error && !hasBeenImportedToAccountAlready && (
|
|
126
130
|
<p className="bg-red-100 p-2 mt-2 pre-wrap">{error}</p>
|
|
@@ -14,17 +14,33 @@ const getErrorText = (error: ErrorObject | string) => {
|
|
|
14
14
|
export const LogContent = ({
|
|
15
15
|
logs,
|
|
16
16
|
error,
|
|
17
|
-
}: {
|
|
17
|
+
}: {
|
|
18
|
+
logs: Array<{
|
|
19
|
+
type: "info" | "success" | "error"
|
|
20
|
+
message: string
|
|
21
|
+
timestamp: string
|
|
22
|
+
}>
|
|
23
|
+
error?: ErrorObject | string | null
|
|
24
|
+
}) => {
|
|
18
25
|
return (
|
|
19
26
|
<div className="whitespace-pre-wrap font-mono text-xs">
|
|
20
|
-
{logs.map(
|
|
21
|
-
log
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
{logs.map(
|
|
28
|
+
(log, i) =>
|
|
29
|
+
log.timestamp &&
|
|
30
|
+
log.message && (
|
|
31
|
+
<div
|
|
32
|
+
key={i}
|
|
33
|
+
className={
|
|
34
|
+
log.type === "error"
|
|
35
|
+
? "text-red-600"
|
|
36
|
+
: log.type === "success"
|
|
37
|
+
? "text-green-600"
|
|
38
|
+
: "text-gray-600"
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
{new Date(log.timestamp).toLocaleTimeString()} {log.message}
|
|
42
|
+
</div>
|
|
43
|
+
),
|
|
28
44
|
)}
|
|
29
45
|
{error && <div className="text-red-600">{getErrorText(error)}</div>}
|
|
30
46
|
</div>
|