@tscircuit/runframe 0.0.567 → 0.0.569

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/runner.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  PcbViewerWithContainerHeight,
17
17
  SchematicViewer,
18
18
  Tabs,
19
+ TabsContent,
19
20
  TabsList,
20
21
  TabsTrigger,
21
22
  buttonVariants,
@@ -27,7 +28,7 @@ import {
27
28
  useOrderDialog,
28
29
  useOrderDialogCli,
29
30
  useRunFrameStore
30
- } from "./chunk-63RKCLSH.js";
31
+ } from "./chunk-KMUV32CG.js";
31
32
 
32
33
  // lib/components/RunFrame/RunFrame.tsx
33
34
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -1053,7 +1054,6 @@ var mapTscircuitSnippetToSearchResult = (tscircuitSnippet) => {
1053
1054
  };
1054
1055
 
1055
1056
  // lib/components/ImportComponentDialog/ImportComponentDialog.tsx
1056
- import { createSvgUrl as createPngUrl } from "@tscircuit/create-snippet-url";
1057
1057
  import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1058
1058
  var ImportComponentDialog = ({
1059
1059
  isOpen,
@@ -1072,6 +1072,28 @@ var ImportComponentDialog = ({
1072
1072
  );
1073
1073
  const [detailsOpen, setDetailsOpen] = useState5(false);
1074
1074
  const [detailsComponent, setDetailsComponent] = useState5(null);
1075
+ const [packageDetails, setPackageDetails] = useState5(null);
1076
+ const [packageDetailsLoading, setPackageDetailsLoading] = useState5(false);
1077
+ const [previewActiveTab, setPreviewActiveTab] = useState5(
1078
+ "pcb"
1079
+ );
1080
+ const fetchPackageDetails = async (owner, name) => {
1081
+ setPackageDetailsLoading(true);
1082
+ try {
1083
+ const response = await fetch(
1084
+ `https://registry-api.tscircuit.com/packages/get?name=${encodeURIComponent(`${owner}/${name}`)}`
1085
+ );
1086
+ if (response.ok) {
1087
+ const data = await response.json();
1088
+ setPackageDetails(data.package || null);
1089
+ }
1090
+ } catch (error) {
1091
+ console.error("Error fetching package details:", error);
1092
+ setPackageDetails(null);
1093
+ } finally {
1094
+ setPackageDetailsLoading(false);
1095
+ }
1096
+ };
1075
1097
  const handleSearch = async () => {
1076
1098
  if (!searchQuery.trim()) return;
1077
1099
  setIsLoading(true);
@@ -1115,6 +1137,12 @@ var ImportComponentDialog = ({
1115
1137
  const showDetails = (component) => {
1116
1138
  setDetailsComponent(component);
1117
1139
  setDetailsOpen(true);
1140
+ setPackageDetails(null);
1141
+ setPreviewActiveTab("pcb");
1142
+ if (component.source === "tscircuit.com" && component.owner) {
1143
+ const packageName = component.name.split("/").pop() || component.name;
1144
+ fetchPackageDetails(component.owner, packageName);
1145
+ }
1118
1146
  };
1119
1147
  return /* @__PURE__ */ jsxs4(AlertDialog, { open: isOpen, onOpenChange: () => onClose(), children: [
1120
1148
  /* @__PURE__ */ jsxs4(AlertDialogContent, { className: "rf-max-w-3xl rf-w-full rf-max-h-[90vh] rf-overflow-y-auto rf-flex rf-flex-col", children: [
@@ -1140,13 +1168,22 @@ var ImportComponentDialog = ({
1140
1168
  {
1141
1169
  placeholder: activeTab === "tscircuit.com" ? "Search components..." : "Search JLCPCB parts (e.g. C14663)...",
1142
1170
  className: "rf-pl-8",
1171
+ spellCheck: false,
1172
+ autoComplete: "off",
1143
1173
  value: searchQuery,
1144
1174
  onChange: (e) => setSearchQuery(e.target.value),
1145
1175
  onKeyDown: handleKeyDown
1146
1176
  }
1147
1177
  )
1148
1178
  ] }),
1149
- /* @__PURE__ */ jsx7(Button, { onClick: handleSearch, disabled: isLoading, children: isLoading ? /* @__PURE__ */ jsx7(Loader22, { className: "rf-h-4 rf-w-4 rf-animate-spin" }) : "Search" })
1179
+ /* @__PURE__ */ jsx7(
1180
+ Button,
1181
+ {
1182
+ onClick: handleSearch,
1183
+ disabled: isLoading || searchQuery.trim().length < 1,
1184
+ children: isLoading ? /* @__PURE__ */ jsx7(Loader22, { className: "rf-h-4 rf-w-4 rf-animate-spin" }) : "Search"
1185
+ }
1186
+ )
1150
1187
  ] }),
1151
1188
  /* @__PURE__ */ jsx7("div", { className: "rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-border rf-rounded-md", children: searchResults.length > 0 ? /* @__PURE__ */ jsx7("div", { className: "rf-divide-y", children: searchResults.map((result) => /* @__PURE__ */ jsxs4(
1152
1189
  "div",
@@ -1200,89 +1237,162 @@ var ImportComponentDialog = ({
1200
1237
  )
1201
1238
  ] })
1202
1239
  ] }),
1203
- /* @__PURE__ */ jsx7(AlertDialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs4(AlertDialogContent, { className: "!rf-max-h-[70%] !rf-overflow-y-auto rf-flex rf-flex-col !rf-max-w-[60vw] !rf-overflow-x-hidden", children: [
1204
- /* @__PURE__ */ jsxs4(AlertDialogHeader, { children: [
1205
- /* @__PURE__ */ jsx7(AlertDialogTitle, { children: detailsComponent?.name }),
1206
- /* @__PURE__ */ jsx7(AlertDialogDescription, { children: "Detailed information about the selected component" }),
1207
- /* @__PURE__ */ jsxs4("div", { className: "rf-text-sm rf-text-muted-foreground", children: [
1208
- detailsComponent?.partNumber && /* @__PURE__ */ jsx7("div", { className: "rf-font-mono rf-text-sm rf-mb-2", children: detailsComponent.partNumber }),
1209
- detailsComponent?.description
1210
- ] })
1211
- ] }),
1212
- detailsComponent?.source === "jlcpcb" && /* @__PURE__ */ jsxs4("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4", children: [
1213
- /* @__PURE__ */ jsx7("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "JLCPCB Details" }),
1214
- /* @__PURE__ */ jsxs4("div", { className: "rf-grid rf-grid-cols-2 rf-gap-2", children: [
1215
- detailsComponent.package && /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-flex-col", children: [
1216
- /* @__PURE__ */ jsx7("span", { className: "rf-text-xs rf-text-zinc-500", children: "Package" }),
1217
- /* @__PURE__ */ jsx7("span", { className: "rf-font-medium", children: detailsComponent.package })
1218
- ] }),
1219
- detailsComponent.price !== void 0 && /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-flex-col", children: [
1220
- /* @__PURE__ */ jsx7("span", { className: "rf-text-xs rf-text-zinc-500", children: "Price" }),
1221
- /* @__PURE__ */ jsxs4("span", { className: "rf-font-medium", children: [
1222
- "$",
1223
- detailsComponent.price.toFixed(4)
1224
- ] })
1225
- ] })
1226
- ] })
1227
- ] }),
1228
- detailsComponent?.source === "tscircuit.com" && /* @__PURE__ */ jsxs4("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4 !rf-max-w-[60vw] !rf-overflow-x-hidden", children: [
1229
- /* @__PURE__ */ jsx7("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "tscircuit Details" }),
1230
- /* @__PURE__ */ jsx7("div", { className: "rf-grid rf-grid-cols-2 rf-gap-2", children: detailsComponent.owner && /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-flex-col", children: [
1231
- /* @__PURE__ */ jsx7("span", { className: "rf-text-xs rf-text-zinc-500", children: "Owner" }),
1232
- /* @__PURE__ */ jsx7("span", { className: "rf-font-medium", children: detailsComponent.owner })
1233
- ] }) }),
1234
- detailsComponent.code && /* @__PURE__ */ jsxs4("div", { className: "rf-mt-2", children: [
1235
- /* @__PURE__ */ jsx7("div", { className: "rf-text-xs rf-text-zinc-500 rf-mb-1", children: "Code Preview" }),
1236
- /* @__PURE__ */ jsxs4("pre", { className: "rf-bg-zinc-50 rf-p-2 rf-rounded rf-text-xs rf-font-mono rf-max-h-32 rf-overflow-y-auto", children: [
1237
- detailsComponent.code.substring(0, 500),
1238
- detailsComponent.code.length > 500 && "..."
1239
- ] })
1240
+ /* @__PURE__ */ jsx7(AlertDialog, { open: detailsOpen, onOpenChange: setDetailsOpen, children: /* @__PURE__ */ jsxs4(AlertDialogContent, { className: "rf-max-w-5xl rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-overflow-y-auto", children: [
1241
+ /* @__PURE__ */ jsx7(AlertDialogHeader, { className: "rf-pb-4 rf-border-b", children: /* @__PURE__ */ jsx7("div", { className: "rf-flex rf-items-start rf-justify-between rf-gap-4", children: /* @__PURE__ */ jsx7("div", { className: "rf-flex-1 rf-min-w-0", children: /* @__PURE__ */ jsx7(AlertDialogTitle, { className: "rf-text-xl rf-font-semibold rf-truncate", children: /* @__PURE__ */ jsx7(
1242
+ "a",
1243
+ {
1244
+ href: `https://tscircuit.com/${detailsComponent?.owner}/${detailsComponent?.name}`,
1245
+ target: "_blank",
1246
+ rel: "noopener noreferrer",
1247
+ className: "rf-text-black hover:rf-underline",
1248
+ children: detailsComponent?.name?.split("/").pop() || detailsComponent?.name
1249
+ }
1250
+ ) }) }) }) }),
1251
+ /* @__PURE__ */ jsxs4("div", { className: "rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6", children: [
1252
+ /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7("div", { className: "rf-space-y-3", children: detailsComponent?.owner && /* @__PURE__ */ jsxs4("div", { children: [
1253
+ /* @__PURE__ */ jsx7("label", { className: "rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide", children: "Created by" }),
1254
+ /* @__PURE__ */ jsx7("div", { className: "rf-mt-1 rf-text-sm rf-font-medium", children: /* @__PURE__ */ jsx7(
1255
+ "a",
1256
+ {
1257
+ href: `https://tscircuit.com/${detailsComponent?.owner}`,
1258
+ target: "_blank",
1259
+ rel: "noopener noreferrer",
1260
+ className: "rf-text-black hover:rf-underline",
1261
+ children: detailsComponent?.owner
1262
+ }
1263
+ ) })
1264
+ ] }) }) }),
1265
+ /* @__PURE__ */ jsxs4("div", { children: [
1266
+ /* @__PURE__ */ jsx7("h3", { className: "rf-text-lg rf-font-semibold rf-mb-4", children: "Preview" }),
1267
+ /* @__PURE__ */ jsxs4(
1268
+ Tabs,
1269
+ {
1270
+ value: previewActiveTab,
1271
+ onValueChange: (value) => setPreviewActiveTab(value),
1272
+ children: [
1273
+ /* @__PURE__ */ jsxs4(TabsList, { className: "rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400", children: [
1274
+ /* @__PURE__ */ jsx7(
1275
+ TabsTrigger,
1276
+ {
1277
+ value: "pcb",
1278
+ className: "rf-inline-flex rf-items-center rf-justify-center rf-whitespace-nowrap rf-rounded-md rf-px-3 rf-py-1 rf-text-sm rf-font-medium rf-ring-offset-white rf-transition-all focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 disabled:rf-pointer-events-none disabled:rf-opacity-50 data-[state=active]:rf-bg-white data-[state=active]:rf-text-zinc-950 data-[state=active]:rf-shadow dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=active]:rf-bg-zinc-950 dark:data-[state=active]:rf-text-zinc-50",
1279
+ children: "PCB"
1280
+ }
1281
+ ),
1282
+ /* @__PURE__ */ jsx7(
1283
+ TabsTrigger,
1284
+ {
1285
+ value: "schematic",
1286
+ className: "rf-inline-flex rf-items-center rf-justify-center rf-whitespace-nowrap rf-rounded-md rf-px-3 rf-py-1 rf-text-sm rf-font-medium rf-ring-offset-white rf-transition-all focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 disabled:rf-pointer-events-none disabled:rf-opacity-50 data-[state=active]:rf-bg-white data-[state=active]:rf-text-zinc-950 data-[state=active]:rf-shadow dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=active]:rf-bg-zinc-950 dark:data-[state=active]:rf-text-zinc-50",
1287
+ children: "Schematic"
1288
+ }
1289
+ )
1290
+ ] }),
1291
+ /* @__PURE__ */ jsxs4("div", { className: "rf-mt-4", children: [
1292
+ /* @__PURE__ */ jsx7(
1293
+ TabsContent,
1294
+ {
1295
+ value: "pcb",
1296
+ className: "rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",
1297
+ children: detailsComponent?.code ? /* @__PURE__ */ jsx7("div", { className: "rf-w-full rf-h-[400px] rf-bg-white rf-flex rf-items-center rf-justify-center rf-p-4", children: /* @__PURE__ */ jsx7(
1298
+ "img",
1299
+ {
1300
+ src: `https://registry-api.tscircuit.com/packages/images/${detailsComponent.owner}/${detailsComponent.name}/pcb.png`,
1301
+ alt: `${detailsComponent.name} PCB preview`,
1302
+ className: "rf-max-w-full rf-max-h-full rf-object-contain rf-rounded",
1303
+ onError: (e) => {
1304
+ const target = e.target;
1305
+ target.style.display = "none";
1306
+ const parent = target.parentElement;
1307
+ if (parent) {
1308
+ parent.innerHTML = '<div class="rf-text-center rf-text-gray-500"><div class="rf-text-sm rf-font-medium">PCB preview not available</div><div class="rf-text-xs rf-mt-1">Image failed to load</div></div>';
1309
+ }
1310
+ }
1311
+ }
1312
+ ) }) : /* @__PURE__ */ jsx7("div", { className: "rf-h-[400px] rf-flex rf-items-center rf-justify-center rf-text-gray-500", children: /* @__PURE__ */ jsxs4("div", { className: "rf-text-center", children: [
1313
+ /* @__PURE__ */ jsx7("div", { className: "rf-text-sm rf-font-medium", children: "No PCB preview available" }),
1314
+ /* @__PURE__ */ jsx7("div", { className: "rf-text-xs rf-mt-1", children: "Preview cannot be generated" })
1315
+ ] }) })
1316
+ }
1317
+ ),
1318
+ /* @__PURE__ */ jsx7(
1319
+ TabsContent,
1320
+ {
1321
+ value: "schematic",
1322
+ className: "rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",
1323
+ children: detailsComponent?.code ? /* @__PURE__ */ jsx7("div", { className: "rf-w-full rf-h-[400px] rf-bg-white rf-flex rf-items-center rf-justify-center rf-p-4", children: /* @__PURE__ */ jsx7(
1324
+ "img",
1325
+ {
1326
+ src: `https://registry-api.tscircuit.com/packages/images/${detailsComponent.owner}/${detailsComponent.name}/schematic.png`,
1327
+ alt: `${detailsComponent.name} schematic preview`,
1328
+ className: "rf-max-w-full rf-max-h-full rf-object-contain rf-rounded",
1329
+ onError: (e) => {
1330
+ const target = e.target;
1331
+ target.style.display = "none";
1332
+ const parent = target.parentElement;
1333
+ if (parent) {
1334
+ parent.innerHTML = '<div class="rf-text-center rf-text-gray-500"><div class="rf-text-sm rf-font-medium">Schematic preview not available</div><div class="rf-text-xs rf-mt-1">Image failed to load</div></div>';
1335
+ }
1336
+ }
1337
+ }
1338
+ ) }) : /* @__PURE__ */ jsx7("div", { className: "rf-h-[400px] rf-flex rf-items-center rf-justify-center rf-text-gray-500", children: /* @__PURE__ */ jsxs4("div", { className: "rf-text-center", children: [
1339
+ /* @__PURE__ */ jsx7("div", { className: "rf-text-sm rf-font-medium", children: "No schematic preview available" }),
1340
+ /* @__PURE__ */ jsx7("div", { className: "rf-text-xs rf-mt-1", children: "Preview cannot be generated" })
1341
+ ] }) })
1342
+ }
1343
+ )
1344
+ ] })
1345
+ ]
1346
+ }
1347
+ )
1348
+ ] }),
1349
+ packageDetails?.ai_description && /* @__PURE__ */ jsxs4("div", { children: [
1350
+ /* @__PURE__ */ jsx7("h3", { className: "rf-text-lg rf-font-semibold rf-mb-3", children: "AI Description" }),
1351
+ /* @__PURE__ */ jsx7("div", { className: "rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4", children: /* @__PURE__ */ jsx7("p", { className: "rf-text-sm rf-text-gray-700 rf-leading-relaxed", children: packageDetails.ai_description }) })
1352
+ ] }),
1353
+ packageDetails?.ai_usage_instructions && /* @__PURE__ */ jsxs4("div", { children: [
1354
+ /* @__PURE__ */ jsx7("h3", { className: "rf-text-lg rf-font-semibold rf-mb-3", children: "Usage Instructions" }),
1355
+ /* @__PURE__ */ jsx7("div", { className: "rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4", children: /* @__PURE__ */ jsx7("p", { className: "rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap", children: packageDetails.ai_usage_instructions }) })
1356
+ ] }),
1357
+ packageDetailsLoading && /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-justify-center rf-text-center rf-items-center rf-gap-2 rf-text-gray-500", children: [
1358
+ /* @__PURE__ */ jsx7(Loader22, { className: "rf-h-4 rf-w-4 rf-animate-spin" }),
1359
+ /* @__PURE__ */ jsx7("span", { className: "rf-text-sm", children: "Loading package details..." })
1240
1360
  ] })
1241
1361
  ] }),
1242
- /* @__PURE__ */ jsxs4("div", { className: "rf-my-4 rf-border rf-rounded-md rf-p-4", children: [
1243
- /* @__PURE__ */ jsx7("div", { className: "rf-text-sm rf-font-medium rf-mb-2", children: "Preview" }),
1244
- detailsComponent?.source === "tscircuit.com" && detailsComponent.code ? /* @__PURE__ */ jsx7("div", { className: "rf-flex rf-justify-center", children: /* @__PURE__ */ jsx7("div", { className: "rf-border rf-rounded rf-p-4 rf-bg-zinc-50", children: /* @__PURE__ */ jsx7(
1245
- "img",
1246
- {
1247
- src: createPngUrl(detailsComponent.code, "pcb"),
1248
- alt: detailsComponent.name,
1249
- className: "rf-w-full rf-aspect-video rf-object-contain"
1250
- }
1251
- ) }) }) : /* @__PURE__ */ jsx7("div", { className: "rf-text-center rf-text-zinc-500 rf-p-4", children: "No preview available" })
1252
- ] }),
1253
- /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-justify-between", children: [
1254
- /* @__PURE__ */ jsxs4(
1362
+ /* @__PURE__ */ jsxs4(AlertDialogFooter, { className: "rf-pt-4 rf-border-t rf-flex rf-justify-between rf-items-center", children: [
1363
+ /* @__PURE__ */ jsx7("div", { className: "rf-flex-1", children: /* @__PURE__ */ jsxs4(
1255
1364
  Button,
1256
1365
  {
1257
1366
  variant: "outline",
1258
1367
  size: "sm",
1259
- className: "rf-gap-1",
1368
+ className: "rf-gap-2",
1260
1369
  onClick: () => {
1261
- const url = detailsComponent?.source === "jlcpcb" ? `https://jlcpcb.com/partdetail/${detailsComponent.partNumber}` : `https://tscircuit.com/${detailsComponent.owner}/${detailsComponent?.name.split("/").pop()}`;
1370
+ const url = `https://tscircuit.com/${detailsComponent?.owner}/${detailsComponent?.name.split("/").pop()}`;
1262
1371
  window.open(url, "_blank");
1263
1372
  },
1264
1373
  children: [
1265
- "View on",
1266
- " ",
1267
- detailsComponent?.source === "jlcpcb" ? "JLCPCB" : "tscircuit.com",
1268
- " ",
1269
- /* @__PURE__ */ jsx7(ExternalLink, { className: "rf-h-3 rf-w-3" })
1374
+ /* @__PURE__ */ jsx7(ExternalLink, { className: "rf-h-4 rf-w-4" }),
1375
+ "View on tscircuit.com"
1270
1376
  ]
1271
1377
  }
1272
- ),
1273
- /* @__PURE__ */ jsx7(
1274
- Button,
1275
- {
1276
- onClick: () => {
1277
- setDetailsOpen(false);
1278
- if (detailsComponent) {
1279
- onImport(detailsComponent);
1280
- onClose();
1281
- }
1282
- },
1283
- children: "Import Component"
1284
- }
1285
- )
1378
+ ) }),
1379
+ /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-gap-2", children: [
1380
+ /* @__PURE__ */ jsx7(AlertDialogCancel, { onClick: () => setDetailsOpen(false), children: "Close" }),
1381
+ /* @__PURE__ */ jsx7(
1382
+ Button,
1383
+ {
1384
+ onClick: () => {
1385
+ setDetailsOpen(false);
1386
+ if (detailsComponent) {
1387
+ onImport(detailsComponent);
1388
+ onClose();
1389
+ }
1390
+ },
1391
+ className: "rf-bg-blue-600 hover:rf-bg-blue-700",
1392
+ children: "Import Component"
1393
+ }
1394
+ )
1395
+ ] })
1286
1396
  ] })
1287
1397
  ] }) })
1288
1398
  ] });