@tscircuit/cli 0.0.83 → 0.0.84

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.
@@ -7,6 +7,8 @@ import { cn } from "./lib/utils"
7
7
  import { ErrorBoundary } from "react-error-boundary"
8
8
  import { SoupTableViewer } from "@tscircuit/table-viewer"
9
9
  import "react-data-grid/lib/styles.css"
10
+ import { useRef, useState } from "react"
11
+ import type { EditEvent } from "@tscircuit/pcb-viewer"
10
12
 
11
13
  export const ExampleContentView = () => {
12
14
  const devExamplePackageId = useGlobalStore(
@@ -34,10 +36,13 @@ export const ExampleContentView = () => {
34
36
  }
35
37
  )
36
38
 
39
+ const sentEditEvents = useRef<Record<string, boolean>>({})
40
+
37
41
  const notFound = (error as any)?.response?.status === 404
38
42
 
39
43
  const viewMode = useGlobalStore((s) => s.view_mode)
40
44
  const splitMode = useGlobalStore((s) => s.split_mode)
45
+ const [editEvents, setEditEvents] = useState<EditEvent[]>([])
41
46
 
42
47
  const editorHeight = window.innerHeight - 52
43
48
  const halfHeight = Math.floor(editorHeight / 2)
@@ -47,7 +52,7 @@ export const ExampleContentView = () => {
47
52
 
48
53
  return (
49
54
  <div
50
- key={pkg?.last_updated_at}
55
+ key={pkg?.soup_last_updated_at}
51
56
  className={cn(
52
57
  "relative",
53
58
  `h-[${editorHeight}px]`,
@@ -60,7 +65,7 @@ export const ExampleContentView = () => {
60
65
  {pkg && (viewMode === "schematic" || viewMode === "split") && (
61
66
  <ErrorBoundary fallback={<div>Failed to render Schematic</div>}>
62
67
  <Schematic
63
- key={`sch-${pkg?.last_updated_at}`}
68
+ key={`sch-${pkg?.soup_last_updated_at}`}
64
69
  style={{ height: itemHeight }}
65
70
  soup={pkg.tscircuit_soup}
66
71
  showTable={false}
@@ -70,8 +75,33 @@ export const ExampleContentView = () => {
70
75
  {pkg && (viewMode === "pcb" || viewMode === "split") && (
71
76
  <ErrorBoundary fallback={<div>Failed to render PCB</div>}>
72
77
  <PCBViewer
73
- key={`pcb-${pkg?.last_updated_at}`}
78
+ key={`pcb-${pkg?.soup_last_updated_at}`}
74
79
  height={itemHeight}
80
+ allowEditing
81
+ editEvents={editEvents}
82
+ onEditEventsChanged={(changedEditEvents) => {
83
+ // Look for any edit events that have not been sent to the server
84
+ // and send them, then mark them as sent
85
+ let hasUnsentEditEvents = false
86
+ for (const editEvent of changedEditEvents) {
87
+ if (
88
+ !editEvent.in_progress &&
89
+ !sentEditEvents.current[editEvent.edit_event_id]
90
+ ) {
91
+ hasUnsentEditEvents = true
92
+ sentEditEvents.current[editEvent.edit_event_id] = true
93
+ }
94
+ }
95
+ if (hasUnsentEditEvents) {
96
+ axios.post(`/api/dev_package_examples/update`, {
97
+ dev_package_example_id: devExamplePackageId,
98
+ completed_edit_events: changedEditEvents.filter(
99
+ (ee) => ee.in_progress === false
100
+ ),
101
+ })
102
+ }
103
+ setEditEvents(changedEditEvents)
104
+ }}
75
105
  soup={pkg.tscircuit_soup}
76
106
  />
77
107
  </ErrorBoundary>
@@ -79,7 +109,7 @@ export const ExampleContentView = () => {
79
109
  {pkg && viewMode === "soup" && (
80
110
  <ErrorBoundary fallback={<div>Failed to render Soup</div>}>
81
111
  <SoupTableViewer
82
- key={`soup-${pkg?.last_updated_at}`}
112
+ key={`soup-${pkg?.soup_last_updated_at}`}
83
113
  height={itemHeight}
84
114
  elements={pkg.tscircuit_soup}
85
115
  appearance="dark"
@@ -64,7 +64,7 @@ export const HeaderMenu = () => {
64
64
  <Menubar className="border-none shadow-none">
65
65
  <MenubarMenu>
66
66
  <MenubarTrigger>File</MenubarTrigger>
67
- <MenubarContent>
67
+ <MenubarContent className="z-[200]">
68
68
  <MenubarItem disabled>seveibar/arduino@1.0.0</MenubarItem>
69
69
  <MenubarSeparator />
70
70
  <MenubarItem
@@ -110,7 +110,7 @@ export const HeaderMenu = () => {
110
110
  </MenubarMenu>
111
111
  <MenubarMenu>
112
112
  <MenubarTrigger>View</MenubarTrigger>
113
- <MenubarContent>
113
+ <MenubarContent className="z-[200]">
114
114
  <MenubarRadioGroup
115
115
  value={viewMode}
116
116
  onValueChange={(v) => setViewMode(v as any)}
@@ -149,7 +149,7 @@ export const HeaderMenu = () => {
149
149
  </MenubarMenu>
150
150
  <MenubarMenu>
151
151
  <MenubarTrigger>Package</MenubarTrigger>
152
- <MenubarContent>
152
+ <MenubarContent className="z-[200]">
153
153
  <MenubarItem disabled>seveibar/arduino@1.0.0</MenubarItem>
154
154
  <MenubarSeparator />
155
155
  <MenubarCheckboxItem
@@ -187,7 +187,7 @@ export const HeaderMenu = () => {
187
187
  </MenubarMenu>
188
188
  <MenubarMenu>
189
189
  <MenubarTrigger>About</MenubarTrigger>
190
- <MenubarContent>
190
+ <MenubarContent className="z-[200]">
191
191
  <MenubarItem
192
192
  onSelect={() => {
193
193
  window.open("https://github.com/tscircuit/tscircuit", "_blank")