@tscircuit/runframe 0.0.276 → 0.0.277

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.d.ts CHANGED
@@ -85,6 +85,7 @@ declare global {
85
85
  declare const RunFrame: (props: RunFrameProps) => react_jsx_runtime.JSX.Element;
86
86
 
87
87
  declare const guessEntrypoint: (files: string[]) => string | undefined;
88
+ declare const guessManualEditsFilePath: (files: string[]) => string | undefined;
88
89
  interface RunFrameWithApiProps {
89
90
  /**
90
91
  * Base URL for the API endpoints
@@ -103,4 +104,4 @@ declare const RunFrameForCli: (props: {
103
104
  debug?: boolean;
104
105
  }) => react_jsx_runtime.JSX.Element;
105
106
 
106
- export { RunFrame, RunFrameForCli, type RunFrameProps, RunFrameWithApi, type RunFrameWithApiProps, TabId, guessEntrypoint };
107
+ export { RunFrame, RunFrameForCli, type RunFrameProps, RunFrameWithApi, type RunFrameWithApiProps, TabId, guessEntrypoint, guessManualEditsFilePath };
package/dist/runner.js CHANGED
@@ -644,9 +644,11 @@ var useEditEventController = () => {
644
644
 
645
645
  // lib/components/RunFrameWithApi/RunFrameWithApi.tsx
646
646
  import Debug3 from "debug";
647
+ import { applyPcbEditEventsToManualEditsFile } from "@tscircuit/core";
647
648
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
648
649
  var debug5 = Debug3("run-frame:RunFrameWithApi");
649
650
  var guessEntrypoint = (files) => files.find((file) => file.includes("entrypoint.")) ?? files.find((file) => file.includes("index.")) ?? files.find((file) => file.includes("main.")) ?? files.find((file) => file.endsWith(".tsx"));
651
+ var guessManualEditsFilePath = (files) => files.find((file) => file.includes("manual-edits.")) ?? files.find((file) => file.includes("manual-edit.")) ?? files.find((file) => file.endsWith(".json"));
650
652
  var RunFrameWithApi = (props) => {
651
653
  const { apiBaseUrl, leftHeaderContent } = props;
652
654
  useEffect3(() => {
@@ -660,6 +662,7 @@ var RunFrameWithApi = (props) => {
660
662
  })
661
663
  );
662
664
  const fsMap = useRunFrameStore((s) => s.fsMap);
665
+ const circuitJson = useRunFrameStore((s) => s.circuitJson);
663
666
  useEffect3(() => {
664
667
  loadInitialFiles();
665
668
  }, []);
@@ -720,15 +723,31 @@ var RunFrameWithApi = (props) => {
720
723
  ...ee
721
724
  })
722
725
  });
726
+ const manualEditsFilePath = guessManualEditsFilePath(Array.from(fsMap.keys())) ?? "manual-edits.json";
727
+ const manualEditsFile = fsMap.get(manualEditsFilePath);
728
+ const updatedManualEdits = applyPcbEditEventsToManualEditsFile({
729
+ circuitJson,
730
+ editEvents: [ee],
731
+ manualEditsFile: JSON.parse(manualEditsFile ?? "{}")
732
+ });
733
+ fetch(`${API_BASE}/files/upsert`, {
734
+ method: "POST",
735
+ headers: { "Content-Type": "application/json" },
736
+ body: JSON.stringify({
737
+ file_path: manualEditsFilePath,
738
+ text_content: JSON.stringify(updatedManualEdits),
739
+ initiator: "runframe"
740
+ })
741
+ });
723
742
  }
724
743
  }
725
744
  );
726
745
  };
727
746
 
728
747
  // lib/hooks/use-local-storage-state.ts
729
- import { useState as useState4, useEffect as useEffect4 } from "react";
748
+ import { useState as useState3, useEffect as useEffect4 } from "react";
730
749
  function useLocalStorageState(key, initialValue) {
731
- const [state, setState] = useState4(() => {
750
+ const [state, setState] = useState3(() => {
732
751
  try {
733
752
  const item = window.localStorage.getItem(key);
734
753
  return item ? JSON.parse(item) : initialValue;
@@ -748,10 +767,10 @@ function useLocalStorageState(key, initialValue) {
748
767
  }
749
768
 
750
769
  // lib/components/RunFrameForCli/LeftHeader.tsx
751
- import { useEffect as useEffect7, useMemo as useMemo4, useState as useState7 } from "react";
770
+ import { useEffect as useEffect7, useMemo as useMemo3, useState as useState6 } from "react";
752
771
 
753
772
  // lib/components/RunFrameForCli/SelectSnippetDialog.tsx
754
- import { useState as useState5 } from "react";
773
+ import { useState as useState4 } from "react";
755
774
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
756
775
  var SelectSnippetDialog = ({
757
776
  snippetNames,
@@ -759,8 +778,8 @@ var SelectSnippetDialog = ({
759
778
  onCancel,
760
779
  isOpen
761
780
  }) => {
762
- const [selectedName, setSelectedName] = useState5("");
763
- const [searchInput, setSearchInput] = useState5("");
781
+ const [selectedName, setSelectedName] = useState4("");
782
+ const [searchInput, setSearchInput] = useState4("");
764
783
  if (!isOpen) return null;
765
784
  const filteredSnippets = snippetNames.filter(
766
785
  (name) => name.toLowerCase().includes(searchInput.toLowerCase())
@@ -989,7 +1008,7 @@ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
989
1008
 
990
1009
  // lib/components/ImportComponentDialog/ImportComponentDialog.tsx
991
1010
  import "react";
992
- import { useState as useState6, useEffect as useEffect6 } from "react";
1011
+ import { useState as useState5, useEffect as useEffect6 } from "react";
993
1012
  import { Loader2 as Loader22, Search, ExternalLink } from "lucide-react";
994
1013
 
995
1014
  // lib/components/ui/input.tsx
@@ -1085,18 +1104,18 @@ var ImportComponentDialog = ({
1085
1104
  onClose,
1086
1105
  onImport
1087
1106
  }) => {
1088
- const [searchQuery, setSearchQuery] = useState6("");
1089
- const [searchResults, setSearchResults] = useState6(
1107
+ const [searchQuery, setSearchQuery] = useState5("");
1108
+ const [searchResults, setSearchResults] = useState5(
1090
1109
  []
1091
1110
  );
1092
- const [hasSearched, setHasSearched] = useState6(false);
1093
- const [isLoading, setIsLoading] = useState6(false);
1094
- const [selectedComponent, setSelectedComponent] = useState6(null);
1095
- const [activeTab, setActiveTab] = useState6(
1111
+ const [hasSearched, setHasSearched] = useState5(false);
1112
+ const [isLoading, setIsLoading] = useState5(false);
1113
+ const [selectedComponent, setSelectedComponent] = useState5(null);
1114
+ const [activeTab, setActiveTab] = useState5(
1096
1115
  "tscircuit"
1097
1116
  );
1098
- const [detailsOpen, setDetailsOpen] = useState6(false);
1099
- const [detailsComponent, setDetailsComponent] = useState6(null);
1117
+ const [detailsOpen, setDetailsOpen] = useState5(false);
1118
+ const [detailsComponent, setDetailsComponent] = useState5(null);
1100
1119
  const handleSearch = async () => {
1101
1120
  if (!searchQuery.trim()) return;
1102
1121
  setIsLoading(true);
@@ -1328,26 +1347,26 @@ var availableExports = [
1328
1347
  ];
1329
1348
  var RunframeCliLeftHeader = (props) => {
1330
1349
  const lastRunEvalVersion = useRunnerStore((s) => s.lastRunEvalVersion);
1331
- const [snippetName, setSnippetName] = useState7(null);
1332
- const [hasUnsavedChanges, setHasUnsavedChanges] = useState7(false);
1333
- const [hasNeverBeenSaved, setHasNeverBeenSaved] = useState7(true);
1334
- const [isSaving, setIsSaving] = useState7(false);
1335
- const [requestToSaveSentAt, setRequestToSaveSentAt] = useState7(
1350
+ const [snippetName, setSnippetName] = useState6(null);
1351
+ const [hasUnsavedChanges, setHasUnsavedChanges] = useState6(false);
1352
+ const [hasNeverBeenSaved, setHasNeverBeenSaved] = useState6(true);
1353
+ const [isSaving, setIsSaving] = useState6(false);
1354
+ const [requestToSaveSentAt, setRequestToSaveSentAt] = useState6(
1336
1355
  null
1337
1356
  );
1338
- const [availableSnippets, setAvailableSnippets] = useState7(
1357
+ const [availableSnippets, setAvailableSnippets] = useState6(
1339
1358
  null
1340
1359
  );
1341
- const [isSelectSnippetDialogOpen, setIsSelectSnippetDialogOpen] = useState7(false);
1342
- const [notificationMessage, setNotificationMessage] = useState7(
1360
+ const [isSelectSnippetDialogOpen, setIsSelectSnippetDialogOpen] = useState6(false);
1361
+ const [notificationMessage, setNotificationMessage] = useState6(
1343
1362
  null
1344
1363
  );
1345
- const [errorMessage, setErrorMessage] = useState7(null);
1346
- const [isError, setIsError] = useState7(false);
1347
- const [isExporting, setisExporting] = useState7(false);
1364
+ const [errorMessage, setErrorMessage] = useState6(null);
1365
+ const [isError, setIsError] = useState6(false);
1366
+ const [isExporting, setisExporting] = useState6(false);
1348
1367
  const pushEvent = useRunFrameStore((state) => state.pushEvent);
1349
1368
  const recentEvents = useRunFrameStore((state) => state.recentEvents);
1350
- const firstRenderTime = useMemo4(() => Date.now(), []);
1369
+ const firstRenderTime = useMemo3(() => Date.now(), []);
1351
1370
  useEventHandler((event) => {
1352
1371
  if (new Date(event.created_at).valueOf() < firstRenderTime + 500) return;
1353
1372
  if (event.event_type === "FILE_UPDATED") {
@@ -1413,7 +1432,7 @@ var RunframeCliLeftHeader = (props) => {
1413
1432
  snippet_name: snippetName
1414
1433
  });
1415
1434
  };
1416
- const [isImportDialogOpen, setIsImportDialogOpen] = useState7(false);
1435
+ const [isImportDialogOpen, setIsImportDialogOpen] = useState6(false);
1417
1436
  return /* @__PURE__ */ jsxs6(Fragment2, { children: [
1418
1437
  /* @__PURE__ */ jsxs6(DropdownMenu, { children: [
1419
1438
  /* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx8("div", { className: "rf-whitespace-nowrap rf-text-xs font-medium rf-p-2 rf-mx-1 rf-cursor-pointer rf-relative", children: "File" }) }),
@@ -1604,5 +1623,6 @@ export {
1604
1623
  RunFrame,
1605
1624
  RunFrameForCli,
1606
1625
  RunFrameWithApi,
1607
- guessEntrypoint
1626
+ guessEntrypoint,
1627
+ guessManualEditsFilePath
1608
1628
  };