@tscircuit/cli 0.0.83 → 0.0.85

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 { useEffect, 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,18 @@ 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
+ // eslint-disable-next-line prefer-const
46
+ let [editEvents, setEditEvents] = useState<EditEvent[]>([])
47
+
48
+ editEvents = editEvents.filter(
49
+ (ee) => ee.created_at > new Date(pkg?.edit_events_last_applied_at).valueOf()
50
+ )
41
51
 
42
52
  const editorHeight = window.innerHeight - 52
43
53
  const halfHeight = Math.floor(editorHeight / 2)
@@ -47,7 +57,7 @@ export const ExampleContentView = () => {
47
57
 
48
58
  return (
49
59
  <div
50
- key={pkg?.last_updated_at}
60
+ key={pkg?.soup_last_updated_at}
51
61
  className={cn(
52
62
  "relative",
53
63
  `h-[${editorHeight}px]`,
@@ -60,7 +70,7 @@ export const ExampleContentView = () => {
60
70
  {pkg && (viewMode === "schematic" || viewMode === "split") && (
61
71
  <ErrorBoundary fallback={<div>Failed to render Schematic</div>}>
62
72
  <Schematic
63
- key={`sch-${pkg?.last_updated_at}`}
73
+ key={`sch-${pkg?.soup_last_updated_at}`}
64
74
  style={{ height: itemHeight }}
65
75
  soup={pkg.tscircuit_soup}
66
76
  showTable={false}
@@ -70,8 +80,33 @@ export const ExampleContentView = () => {
70
80
  {pkg && (viewMode === "pcb" || viewMode === "split") && (
71
81
  <ErrorBoundary fallback={<div>Failed to render PCB</div>}>
72
82
  <PCBViewer
73
- key={`pcb-${pkg?.last_updated_at}`}
83
+ key={`pcb-${pkg?.soup_last_updated_at}`}
74
84
  height={itemHeight}
85
+ allowEditing
86
+ editEvents={editEvents}
87
+ onEditEventsChanged={(changedEditEvents) => {
88
+ // Look for any edit events that have not been sent to the server
89
+ // and send them, then mark them as sent
90
+ let hasUnsentEditEvents = false
91
+ for (const editEvent of changedEditEvents) {
92
+ if (
93
+ !editEvent.in_progress &&
94
+ !sentEditEvents.current[editEvent.edit_event_id]
95
+ ) {
96
+ hasUnsentEditEvents = true
97
+ sentEditEvents.current[editEvent.edit_event_id] = true
98
+ }
99
+ }
100
+ if (hasUnsentEditEvents) {
101
+ axios.post(`/api/dev_package_examples/update`, {
102
+ dev_package_example_id: devExamplePackageId,
103
+ completed_edit_events: changedEditEvents.filter(
104
+ (ee) => ee.in_progress === false
105
+ ),
106
+ })
107
+ }
108
+ setEditEvents(changedEditEvents)
109
+ }}
75
110
  soup={pkg.tscircuit_soup}
76
111
  />
77
112
  </ErrorBoundary>
@@ -79,7 +114,7 @@ export const ExampleContentView = () => {
79
114
  {pkg && viewMode === "soup" && (
80
115
  <ErrorBoundary fallback={<div>Failed to render Soup</div>}>
81
116
  <SoupTableViewer
82
- key={`soup-${pkg?.last_updated_at}`}
117
+ key={`soup-${pkg?.soup_last_updated_at}`}
83
118
  height={itemHeight}
84
119
  elements={pkg.tscircuit_soup}
85
120
  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")