@tscircuit/runframe 0.0.1137 → 0.0.1139

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/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-LA5Z7XHL.js";
11
+ } from "./chunk-L5MGTEEA.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  useRunFrameStore,
33
33
  useRunnerStore,
34
34
  useStyles
35
- } from "./chunk-LA5Z7XHL.js";
35
+ } from "./chunk-L5MGTEEA.js";
36
36
 
37
37
  // lib/components/RunFrame/RunFrame.tsx
38
38
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";
@@ -1028,22 +1028,19 @@ var EnhancedFileSelectorCombobox = ({
1028
1028
  files,
1029
1029
  onFileChange,
1030
1030
  currentFile,
1031
- config = {}
1031
+ fileFilter = defaultFileFilter,
1032
+ getDisplayName = defaultDisplayName,
1033
+ placeholder = "Select file",
1034
+ searchPlaceholder = "Search for file",
1035
+ emptyMessage = "No files found in this directory.",
1036
+ pinnedFiles = [],
1037
+ onToggleFavorite
1032
1038
  }) => {
1033
1039
  const [open, setOpen] = useState5(false);
1034
1040
  const [file, setFile] = useState5(currentFile);
1035
1041
  const { currentFolder, navigateToFolder, resetManualNavigation } = useCurrentFolder({ currentFile: file, files });
1036
1042
  const [currentFileIndex, setCurrentFileIndex] = useState5(0);
1037
1043
  const [searchValue, setSearchValue] = useState5("");
1038
- const {
1039
- fileFilter = defaultFileFilter,
1040
- getDisplayName = defaultDisplayName,
1041
- placeholder = "Select file",
1042
- searchPlaceholder = "Search for file",
1043
- emptyMessage = "No files found in this directory.",
1044
- pinnedFiles = [],
1045
- onToggleFavorite
1046
- } = config;
1047
1044
  useEffect6(() => {
1048
1045
  setFile(currentFile);
1049
1046
  }, [currentFile]);
@@ -1112,7 +1109,8 @@ var EnhancedFileSelectorCombobox = ({
1112
1109
  const displayPath = currentFolder ?? "/";
1113
1110
  const shortDisplayPath = displayPath.length > 25 ? "..." + displayPath.slice(-22) : displayPath;
1114
1111
  const getDropdownWidth = () => {
1115
- return "rf-w-[400px] rf-min-w-[400px] rf-max-w-[400px]";
1112
+ const maxWidth = isSearching ? "rf-max-w-[600px]" : "rf-max-w-[1000px]";
1113
+ return `rf-w-full rf-min-w-[600px] ${maxWidth}`;
1116
1114
  };
1117
1115
  return /* @__PURE__ */ jsx5("div", { className: "rf-flex rf-items-center rf-gap-1", children: /* @__PURE__ */ jsxs4(
1118
1116
  Popover,
@@ -1132,7 +1130,7 @@ var EnhancedFileSelectorCombobox = ({
1132
1130
  variant: "outline",
1133
1131
  role: "combobox",
1134
1132
  "aria-expanded": open,
1135
- className: "rf-w-fit rf-min-w-32 rf-max-w-64 rf-justify-center rf-items-center rf-gap-1 !rf-font-normal",
1133
+ className: "rf-w-fit rf-min-w-32 rf-max-w-100 rf-justify-center rf-items-center rf-gap-1 !rf-font-normal",
1136
1134
  children: [
1137
1135
  /* @__PURE__ */ jsx5("span", { className: "rf-truncate rf-text-left", children: file ? getDisplayName(file) : placeholder }),
1138
1136
  /* @__PURE__ */ jsx5(ChevronsUpDown, { className: "rf-opacity-50 rf-flex-shrink-0" })
@@ -1143,7 +1141,7 @@ var EnhancedFileSelectorCombobox = ({
1143
1141
  PopoverContent,
1144
1142
  {
1145
1143
  className: cn(
1146
- "!rf-p-0 !rf-overflow-x-auto !rf-z-[200]",
1144
+ "!rf-p-0 !rf-overflow-hidden !rf-z-[200]",
1147
1145
  getDropdownWidth()
1148
1146
  ),
1149
1147
  children: /* @__PURE__ */ jsxs4(Command, { shouldFilter: false, children: [
@@ -1177,7 +1175,7 @@ var EnhancedFileSelectorCombobox = ({
1177
1175
  index === array.length - 1 ? /* @__PURE__ */ jsx5(
1178
1176
  "span",
1179
1177
  {
1180
- className: "rf-text-slate-800 rf-truncate rf-max-w-[150px]",
1178
+ className: "rf-text-slate-800 rf-truncate rf-max-w-[200px]",
1181
1179
  title: segment,
1182
1180
  children: segment
1183
1181
  }
@@ -1185,7 +1183,7 @@ var EnhancedFileSelectorCombobox = ({
1185
1183
  "button",
1186
1184
  {
1187
1185
  onClick: () => handleNavigateToFolder(pathToSegment),
1188
- className: "rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-truncate rf-max-w-[100px]",
1186
+ className: "rf-text-blue-600 hover:rf-text-blue-800 rf-underline rf-cursor-pointer rf-bg-transparent rf-border-none rf-p-0 rf-truncate rf-max-w-[150px]",
1189
1187
  title: segment,
1190
1188
  children: segment
1191
1189
  }
@@ -1227,7 +1225,7 @@ var EnhancedFileSelectorCombobox = ({
1227
1225
  children: [
1228
1226
  /* @__PURE__ */ jsx5(Star, { className: "rf-mr-2 rf-h-4 rf-w-4 rf-text-amber-500 rf-fill-amber-500" }),
1229
1227
  getDisplayName(path.split("/").pop() || ""),
1230
- /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[120px]", children: getDirectoryPath2(path) }),
1228
+ /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]", children: getDirectoryPath2(path) }),
1231
1229
  /* @__PURE__ */ jsx5(
1232
1230
  Check,
1233
1231
  {
@@ -1268,7 +1266,10 @@ var EnhancedFileSelectorCombobox = ({
1268
1266
  e.stopPropagation();
1269
1267
  onToggleFavorite(fileNode.path);
1270
1268
  },
1271
- className: "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-opacity-0 group-hover:rf-opacity-100 rf-transition-opacity",
1269
+ className: cn(
1270
+ "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-opacity",
1271
+ pinnedFiles.includes(fileNode.path) ? "rf-opacity-100" : "rf-opacity-0 group-hover:rf-opacity-100"
1272
+ ),
1272
1273
  "aria-label": pinnedFiles.includes(fileNode.path) ? "Remove from favorites" : "Add to favorites",
1273
1274
  title: pinnedFiles.includes(fileNode.path) ? "Remove from favorites" : "Add to favorites",
1274
1275
  children: /* @__PURE__ */ jsx5(
@@ -1342,7 +1343,7 @@ var EnhancedFileSelectorCombobox = ({
1342
1343
  /* @__PURE__ */ jsx5("span", { className: "rf-mr-2", children: defaultFileIcon(file2.fileName) }),
1343
1344
  /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-items-center rf-w-full rf-min-w-0", children: [
1344
1345
  /* @__PURE__ */ jsx5("span", { className: "rf-truncate rf-flex-1", children: getDisplayName(file2.fileName) }),
1345
- /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[120px]", children: currentFolder || "/" }),
1346
+ /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]", children: currentFolder || "/" }),
1346
1347
  onToggleFavorite && /* @__PURE__ */ jsx5(
1347
1348
  "button",
1348
1349
  {
@@ -1351,7 +1352,10 @@ var EnhancedFileSelectorCombobox = ({
1351
1352
  e.stopPropagation();
1352
1353
  onToggleFavorite(file2.path);
1353
1354
  },
1354
- className: "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-opacity-0 group-hover:rf-opacity-100 rf-transition-opacity rf-ml-2",
1355
+ className: cn(
1356
+ "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-opacity rf-ml-2",
1357
+ pinnedFiles.includes(file2.path) ? "rf-opacity-100" : "rf-opacity-0 group-hover:rf-opacity-100"
1358
+ ),
1355
1359
  "aria-label": pinnedFiles.includes(file2.path) ? "Remove from favorites" : "Add to favorites",
1356
1360
  title: pinnedFiles.includes(file2.path) ? "Remove from favorites" : "Add to favorites",
1357
1361
  children: /* @__PURE__ */ jsx5(
@@ -1389,7 +1393,7 @@ var EnhancedFileSelectorCombobox = ({
1389
1393
  /* @__PURE__ */ jsx5("span", { className: "rf-mr-2", children: defaultFileIcon(file2.fileName) }),
1390
1394
  /* @__PURE__ */ jsxs4("div", { className: "rf-flex rf-items-center rf-w-full rf-min-w-0", children: [
1391
1395
  /* @__PURE__ */ jsx5("span", { className: "rf-truncate rf-flex-1", children: getDisplayName(file2.fileName) }),
1392
- /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[120px]", children: getDirectoryPath2(file2.path) }),
1396
+ /* @__PURE__ */ jsx5("span", { className: "rf-text-xs rf-text-muted-foreground rf-ml-2 rf-truncate rf-max-w-[40%]", children: getDirectoryPath2(file2.path) }),
1393
1397
  onToggleFavorite && /* @__PURE__ */ jsx5(
1394
1398
  "button",
1395
1399
  {
@@ -1397,7 +1401,10 @@ var EnhancedFileSelectorCombobox = ({
1397
1401
  e.stopPropagation();
1398
1402
  onToggleFavorite(file2.path);
1399
1403
  },
1400
- className: "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-opacity-0 group-hover:rf-opacity-100 rf-transition-opacity rf-ml-2",
1404
+ className: cn(
1405
+ "rf-p-1 rf-rounded hover:rf-bg-slate-200 rf-transition-opacity rf-ml-2",
1406
+ pinnedFiles.includes(file2.path) ? "rf-opacity-100" : "rf-opacity-0 group-hover:rf-opacity-100"
1407
+ ),
1401
1408
  title: pinnedFiles.includes(file2.path) ? "Remove from favorites" : "Add to favorites",
1402
1409
  children: /* @__PURE__ */ jsx5(
1403
1410
  Star,
@@ -1489,11 +1496,34 @@ var RunFrameWithApi = (props) => {
1489
1496
  const params = new URLSearchParams(window.location.hash.slice(1));
1490
1497
  return params.get("file") ?? props.initialMainComponentPath ?? "";
1491
1498
  });
1499
+ const [favorites, setFavorites] = useLocalStorageState(
1500
+ "runframe:favorites",
1501
+ []
1502
+ );
1492
1503
  const isLoadingFiles = !hasReceivedInitialFiles;
1504
+ const handleToggleFavorite = useCallback3(
1505
+ (filePath) => {
1506
+ setFavorites(
1507
+ (prev) => prev.includes(filePath) ? prev.filter((f) => f !== filePath) : [...prev, filePath]
1508
+ );
1509
+ },
1510
+ [setFavorites]
1511
+ );
1493
1512
  useEffect7(() => {
1494
1513
  if (componentPath && boardFiles.includes(componentPath)) {
1495
1514
  return;
1496
1515
  }
1516
+ if (componentPath) {
1517
+ const currentDir = componentPath.includes("/") ? componentPath.substring(0, componentPath.lastIndexOf("/")) : "";
1518
+ const fileInSameDir = boardFiles.find((file) => {
1519
+ const fileDir = file.includes("/") ? file.substring(0, file.lastIndexOf("/")) : "";
1520
+ return fileDir === currentDir;
1521
+ });
1522
+ if (fileInSameDir) {
1523
+ setComponentPath(fileInSameDir);
1524
+ return;
1525
+ }
1526
+ }
1497
1527
  const defaultPath = window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH;
1498
1528
  const candidatePaths = [props.initialMainComponentPath, defaultPath].filter(
1499
1529
  (value) => Boolean(value)
@@ -1566,7 +1596,9 @@ var RunFrameWithApi = (props) => {
1566
1596
  if (typeof fsMap.get(value) === "string") {
1567
1597
  setComponentPath(value);
1568
1598
  }
1569
- }
1599
+ },
1600
+ pinnedFiles: favorites,
1601
+ onToggleFavorite: handleToggleFavorite
1570
1602
  }
1571
1603
  ) })
1572
1604
  ] }),
@@ -2249,12 +2281,6 @@ import { useCallback as useCallback5, useEffect as useEffect9, useState as useSt
2249
2281
 
2250
2282
  // lib/components/RunFrameStaticBuildViewer/CircuitJsonFileSelectorCombobox.tsx
2251
2283
  import { jsx as jsx9 } from "react/jsx-runtime";
2252
- var circuitJsonConfig = {
2253
- fileFilter: () => true,
2254
- placeholder: "Select circuit",
2255
- searchPlaceholder: "Search for circuit file",
2256
- emptyMessage: "No circuit files found in this directory."
2257
- };
2258
2284
  var CircuitJsonFileSelectorCombobox = ({
2259
2285
  files,
2260
2286
  onFileChange,
@@ -2266,7 +2292,10 @@ var CircuitJsonFileSelectorCombobox = ({
2266
2292
  files,
2267
2293
  onFileChange,
2268
2294
  currentFile,
2269
- config: circuitJsonConfig
2295
+ fileFilter: () => true,
2296
+ placeholder: "Select circuit",
2297
+ searchPlaceholder: "Search for circuit file",
2298
+ emptyMessage: "No circuit files found in this directory."
2270
2299
  }
2271
2300
  );
2272
2301
  };