@tscircuit/runframe 0.0.11 → 0.0.12
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/README.md +31 -1
- package/package.json +10 -2
- package/.github/workflows/bun-formatcheck.yml +0 -26
- package/.github/workflows/bun-pver-release.yml +0 -25
- package/.github/workflows/bun-typecheck.yml +0 -26
- package/biome.json +0 -57
- package/bun.lockb +0 -0
- package/cosmos.config.json +0 -3
- package/cosmos.decorator.tsx +0 -3
- package/examples/resistor.fixture.tsx +0 -12
- package/examples/runframe-with-api-1.fixture.tsx +0 -41
- package/examples/runframe1-basic.fixture.tsx +0 -19
- package/index.html +0 -13
- package/lib/components/BomTable.tsx +0 -69
- package/lib/components/CircuitJsonPreview.tsx +0 -348
- package/lib/components/CircuitJsonTableViewer/CircuitJsonTableViewer.tsx +0 -315
- package/lib/components/CircuitJsonTableViewer/ClickableText.tsx +0 -20
- package/lib/components/CircuitJsonTableViewer/HeaderCell.tsx +0 -26
- package/lib/components/CircuitJsonTableViewer/Modal.tsx +0 -38
- package/lib/components/ErrorFallback.tsx +0 -25
- package/lib/components/ErrorTabContent.tsx +0 -86
- package/lib/components/PcbViewerWithContainerHeight.tsx +0 -47
- package/lib/components/PreviewEmptyState.tsx +0 -14
- package/lib/components/RunFrame.tsx +0 -68
- package/lib/components/RunFrameWithApi/index.tsx +0 -44
- package/lib/components/RunFrameWithApi/standalone.tsx +0 -6
- package/lib/components/RunFrameWithApi/store.ts +0 -122
- package/lib/components/RunFrameWithApi/types.ts +0 -43
- package/lib/components/ui/button.tsx +0 -57
- package/lib/components/ui/dropdown-menu.tsx +0 -203
- package/lib/components/ui/tabs.tsx +0 -53
- package/lib/dev/render-to-circuit-json.ts +0 -7
- package/lib/hooks/use-styles.ts +0 -17
- package/lib/preview.ts +0 -1
- package/lib/runner.ts +0 -2
- package/lib/utils/index.ts +0 -6
- package/lib/utils/pcbManualEditEventHandler.ts +0 -156
- package/postcss.config.js +0 -8
- package/renovate.json +0 -15
- package/scripts/build-css.ts +0 -26
- package/src/main.tsx +0 -13
- package/tailwind.config.js +0 -3
- package/tsconfig.json +0 -45
- package/vite.config.ts +0 -72
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
|
3
|
-
import {
|
|
4
|
-
CheckIcon,
|
|
5
|
-
ChevronRightIcon,
|
|
6
|
-
DotFilledIcon,
|
|
7
|
-
} from "@radix-ui/react-icons"
|
|
8
|
-
|
|
9
|
-
import { cn } from "lib/utils"
|
|
10
|
-
|
|
11
|
-
const DropdownMenu = DropdownMenuPrimitive.Root
|
|
12
|
-
|
|
13
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
14
|
-
|
|
15
|
-
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
|
16
|
-
|
|
17
|
-
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
|
18
|
-
|
|
19
|
-
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
|
20
|
-
|
|
21
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
|
22
|
-
|
|
23
|
-
const DropdownMenuSubTrigger = React.forwardRef<
|
|
24
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
25
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
26
|
-
inset?: boolean
|
|
27
|
-
}
|
|
28
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
29
|
-
<DropdownMenuPrimitive.SubTrigger
|
|
30
|
-
ref={ref}
|
|
31
|
-
className={cn(
|
|
32
|
-
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-slate-100 data-[state=open]:bg-slate-100 dark:focus:bg-slate-800 dark:data-[state=open]:bg-slate-800",
|
|
33
|
-
inset && "pl-8",
|
|
34
|
-
className,
|
|
35
|
-
)}
|
|
36
|
-
{...props}
|
|
37
|
-
>
|
|
38
|
-
{children}
|
|
39
|
-
<ChevronRightIcon className="ml-auto h-4 w-4" />
|
|
40
|
-
</DropdownMenuPrimitive.SubTrigger>
|
|
41
|
-
))
|
|
42
|
-
DropdownMenuSubTrigger.displayName =
|
|
43
|
-
DropdownMenuPrimitive.SubTrigger.displayName
|
|
44
|
-
|
|
45
|
-
const DropdownMenuSubContent = React.forwardRef<
|
|
46
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
47
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
48
|
-
>(({ className, ...props }, ref) => (
|
|
49
|
-
<DropdownMenuPrimitive.SubContent
|
|
50
|
-
ref={ref}
|
|
51
|
-
className={cn(
|
|
52
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",
|
|
53
|
-
className,
|
|
54
|
-
)}
|
|
55
|
-
{...props}
|
|
56
|
-
/>
|
|
57
|
-
))
|
|
58
|
-
DropdownMenuSubContent.displayName =
|
|
59
|
-
DropdownMenuPrimitive.SubContent.displayName
|
|
60
|
-
|
|
61
|
-
const DropdownMenuContent = React.forwardRef<
|
|
62
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
63
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
64
|
-
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
65
|
-
<DropdownMenuPrimitive.Portal>
|
|
66
|
-
<DropdownMenuPrimitive.Content
|
|
67
|
-
ref={ref}
|
|
68
|
-
sideOffset={sideOffset}
|
|
69
|
-
className={cn(
|
|
70
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-200 bg-white p-1 text-slate-950 shadow-md dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",
|
|
71
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
72
|
-
className,
|
|
73
|
-
)}
|
|
74
|
-
{...props}
|
|
75
|
-
/>
|
|
76
|
-
</DropdownMenuPrimitive.Portal>
|
|
77
|
-
))
|
|
78
|
-
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
|
79
|
-
|
|
80
|
-
const DropdownMenuItem = React.forwardRef<
|
|
81
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
82
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
83
|
-
inset?: boolean
|
|
84
|
-
}
|
|
85
|
-
>(({ className, inset, ...props }, ref) => (
|
|
86
|
-
<DropdownMenuPrimitive.Item
|
|
87
|
-
ref={ref}
|
|
88
|
-
className={cn(
|
|
89
|
-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50",
|
|
90
|
-
inset && "pl-8",
|
|
91
|
-
className,
|
|
92
|
-
)}
|
|
93
|
-
{...props}
|
|
94
|
-
/>
|
|
95
|
-
))
|
|
96
|
-
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
|
97
|
-
|
|
98
|
-
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
99
|
-
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
100
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
101
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
102
|
-
<DropdownMenuPrimitive.CheckboxItem
|
|
103
|
-
ref={ref}
|
|
104
|
-
className={cn(
|
|
105
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50",
|
|
106
|
-
className,
|
|
107
|
-
)}
|
|
108
|
-
checked={checked}
|
|
109
|
-
{...props}
|
|
110
|
-
>
|
|
111
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
112
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
113
|
-
<CheckIcon className="h-4 w-4" />
|
|
114
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
115
|
-
</span>
|
|
116
|
-
{children}
|
|
117
|
-
</DropdownMenuPrimitive.CheckboxItem>
|
|
118
|
-
))
|
|
119
|
-
DropdownMenuCheckboxItem.displayName =
|
|
120
|
-
DropdownMenuPrimitive.CheckboxItem.displayName
|
|
121
|
-
|
|
122
|
-
const DropdownMenuRadioItem = React.forwardRef<
|
|
123
|
-
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
124
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
125
|
-
>(({ className, children, ...props }, ref) => (
|
|
126
|
-
<DropdownMenuPrimitive.RadioItem
|
|
127
|
-
ref={ref}
|
|
128
|
-
className={cn(
|
|
129
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50",
|
|
130
|
-
className,
|
|
131
|
-
)}
|
|
132
|
-
{...props}
|
|
133
|
-
>
|
|
134
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
135
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
136
|
-
<DotFilledIcon className="h-4 w-4 fill-current" />
|
|
137
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
138
|
-
</span>
|
|
139
|
-
{children}
|
|
140
|
-
</DropdownMenuPrimitive.RadioItem>
|
|
141
|
-
))
|
|
142
|
-
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
|
143
|
-
|
|
144
|
-
const DropdownMenuLabel = React.forwardRef<
|
|
145
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
146
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
147
|
-
inset?: boolean
|
|
148
|
-
}
|
|
149
|
-
>(({ className, inset, ...props }, ref) => (
|
|
150
|
-
<DropdownMenuPrimitive.Label
|
|
151
|
-
ref={ref}
|
|
152
|
-
className={cn(
|
|
153
|
-
"px-2 py-1.5 text-sm font-semibold",
|
|
154
|
-
inset && "pl-8",
|
|
155
|
-
className,
|
|
156
|
-
)}
|
|
157
|
-
{...props}
|
|
158
|
-
/>
|
|
159
|
-
))
|
|
160
|
-
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
|
161
|
-
|
|
162
|
-
const DropdownMenuSeparator = React.forwardRef<
|
|
163
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
164
|
-
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
165
|
-
>(({ className, ...props }, ref) => (
|
|
166
|
-
<DropdownMenuPrimitive.Separator
|
|
167
|
-
ref={ref}
|
|
168
|
-
className={cn("-mx-1 my-1 h-px bg-slate-100 dark:bg-slate-800", className)}
|
|
169
|
-
{...props}
|
|
170
|
-
/>
|
|
171
|
-
))
|
|
172
|
-
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
|
173
|
-
|
|
174
|
-
const DropdownMenuShortcut = ({
|
|
175
|
-
className,
|
|
176
|
-
...props
|
|
177
|
-
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
178
|
-
return (
|
|
179
|
-
<span
|
|
180
|
-
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
|
181
|
-
{...props}
|
|
182
|
-
/>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
|
186
|
-
|
|
187
|
-
export {
|
|
188
|
-
DropdownMenu,
|
|
189
|
-
DropdownMenuTrigger,
|
|
190
|
-
DropdownMenuContent,
|
|
191
|
-
DropdownMenuItem,
|
|
192
|
-
DropdownMenuCheckboxItem,
|
|
193
|
-
DropdownMenuRadioItem,
|
|
194
|
-
DropdownMenuLabel,
|
|
195
|
-
DropdownMenuSeparator,
|
|
196
|
-
DropdownMenuShortcut,
|
|
197
|
-
DropdownMenuGroup,
|
|
198
|
-
DropdownMenuPortal,
|
|
199
|
-
DropdownMenuSub,
|
|
200
|
-
DropdownMenuSubContent,
|
|
201
|
-
DropdownMenuSubTrigger,
|
|
202
|
-
DropdownMenuRadioGroup,
|
|
203
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
|
3
|
-
|
|
4
|
-
import { cn } from "lib/utils"
|
|
5
|
-
|
|
6
|
-
const Tabs = TabsPrimitive.Root
|
|
7
|
-
|
|
8
|
-
const TabsList = React.forwardRef<
|
|
9
|
-
React.ElementRef<typeof TabsPrimitive.List>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
11
|
-
>(({ className, ...props }, ref) => (
|
|
12
|
-
<TabsPrimitive.List
|
|
13
|
-
ref={ref}
|
|
14
|
-
className={cn(
|
|
15
|
-
"inline-flex h-9 items-center justify-center rounded-lg bg-slate-100 p-1 text-slate-500 dark:bg-slate-800 dark:text-slate-400",
|
|
16
|
-
className,
|
|
17
|
-
)}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
))
|
|
21
|
-
TabsList.displayName = TabsPrimitive.List.displayName
|
|
22
|
-
|
|
23
|
-
const TabsTrigger = React.forwardRef<
|
|
24
|
-
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
25
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
26
|
-
>(({ className, ...props }, ref) => (
|
|
27
|
-
<TabsPrimitive.Trigger
|
|
28
|
-
ref={ref}
|
|
29
|
-
className={cn(
|
|
30
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-white data-[state=active]:text-slate-950 data-[state=active]:shadow dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300 dark:data-[state=active]:bg-slate-950 dark:data-[state=active]:text-slate-50",
|
|
31
|
-
className,
|
|
32
|
-
)}
|
|
33
|
-
{...props}
|
|
34
|
-
/>
|
|
35
|
-
))
|
|
36
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
37
|
-
|
|
38
|
-
const TabsContent = React.forwardRef<
|
|
39
|
-
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
40
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
41
|
-
>(({ className, ...props }, ref) => (
|
|
42
|
-
<TabsPrimitive.Content
|
|
43
|
-
ref={ref}
|
|
44
|
-
className={cn(
|
|
45
|
-
"mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300",
|
|
46
|
-
className,
|
|
47
|
-
)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
))
|
|
51
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
52
|
-
|
|
53
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
package/lib/hooks/use-styles.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react"
|
|
2
|
-
import styles from "./styles.generated"
|
|
3
|
-
|
|
4
|
-
export const useStyles = () => {
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
// Check if styles are already added
|
|
7
|
-
const existingStyle = document.querySelector(
|
|
8
|
-
'style[data-styles="tscircuit-runframe"]',
|
|
9
|
-
)
|
|
10
|
-
if (existingStyle) return
|
|
11
|
-
|
|
12
|
-
const styleElement = document.createElement("style")
|
|
13
|
-
styleElement.setAttribute("data-styles", "tscircuit-runframe")
|
|
14
|
-
styleElement.textContent = styles
|
|
15
|
-
document.head.appendChild(styleElement)
|
|
16
|
-
}, [])
|
|
17
|
-
}
|
package/lib/preview.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./components/CircuitJsonPreview"
|
package/lib/runner.ts
DELETED
package/lib/utils/index.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import type { ManualTraceHint } from "@tscircuit/layout"
|
|
2
|
-
import { getManualTraceHintFromEvent } from "@tscircuit/layout"
|
|
3
|
-
import type { EditEvent } from "@tscircuit/manual-edit-events"
|
|
4
|
-
import type {
|
|
5
|
-
AnyCircuitElement,
|
|
6
|
-
PcbComponent,
|
|
7
|
-
SourceComponentBase,
|
|
8
|
-
} from "circuit-json"
|
|
9
|
-
|
|
10
|
-
export interface PCBPlacement {
|
|
11
|
-
selector: string
|
|
12
|
-
center: { x: number; y: number }
|
|
13
|
-
relative_to: "group_center"
|
|
14
|
-
_edit_event_id?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ManualEditState {
|
|
18
|
-
pcb_placements: PCBPlacement[]
|
|
19
|
-
edit_events: EditEvent[]
|
|
20
|
-
manual_trace_hints: ManualTraceHint[]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const createInitialManualEditState = (): ManualEditState => ({
|
|
24
|
-
pcb_placements: [],
|
|
25
|
-
edit_events: [],
|
|
26
|
-
manual_trace_hints: [],
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const applyPcbEditEvents = ({
|
|
30
|
-
editEvents,
|
|
31
|
-
circuitJson,
|
|
32
|
-
manualEditsFileContent,
|
|
33
|
-
}: {
|
|
34
|
-
editEvents: EditEvent[]
|
|
35
|
-
circuitJson: AnyCircuitElement[]
|
|
36
|
-
manualEditsFileContent?: string
|
|
37
|
-
}): ManualEditState => {
|
|
38
|
-
try {
|
|
39
|
-
// Ensure we have a valid state to work with
|
|
40
|
-
const validatedManualEdits = ensureValidState(manualEditsFileContent)
|
|
41
|
-
|
|
42
|
-
// Create a new state object with properly initialized arrays
|
|
43
|
-
const newManualEditState: ManualEditState = {
|
|
44
|
-
pcb_placements: [...validatedManualEdits.pcb_placements],
|
|
45
|
-
edit_events: [...validatedManualEdits.edit_events],
|
|
46
|
-
manual_trace_hints: [...validatedManualEdits.manual_trace_hints],
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Create a set of handled event IDs
|
|
50
|
-
const handledEventIds = new Set<string>()
|
|
51
|
-
|
|
52
|
-
// Add existing event IDs to the set
|
|
53
|
-
newManualEditState.pcb_placements.forEach((placement) => {
|
|
54
|
-
if (placement._edit_event_id) {
|
|
55
|
-
handledEventIds.add(placement._edit_event_id)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
newManualEditState.edit_events.forEach((event) => {
|
|
60
|
-
if (event.edit_event_id) {
|
|
61
|
-
handledEventIds.add(event.edit_event_id)
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
// Process new edit events
|
|
66
|
-
for (const editEvent of editEvents) {
|
|
67
|
-
if (
|
|
68
|
-
(editEvent.in_progress && !editEvent.edit_event_id) ||
|
|
69
|
-
handledEventIds.has(editEvent.edit_event_id)
|
|
70
|
-
)
|
|
71
|
-
continue
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
editEvent.pcb_edit_event_type === "edit_component_location" &&
|
|
75
|
-
editEvent.pcb_component_id
|
|
76
|
-
) {
|
|
77
|
-
// Find the component in the circuitJson
|
|
78
|
-
const pcbComponent = circuitJson.find(
|
|
79
|
-
(item: AnyCircuitElement) =>
|
|
80
|
-
item.type === "pcb_component" &&
|
|
81
|
-
item.pcb_component_id === editEvent.pcb_component_id,
|
|
82
|
-
) as PcbComponent
|
|
83
|
-
|
|
84
|
-
if (!pcbComponent?.pcb_component_id) continue
|
|
85
|
-
|
|
86
|
-
const nameofComponent = circuitJson.find(
|
|
87
|
-
(item: AnyCircuitElement) =>
|
|
88
|
-
item.type === "source_component" &&
|
|
89
|
-
item.source_component_id === pcbComponent.source_component_id,
|
|
90
|
-
) as SourceComponentBase
|
|
91
|
-
|
|
92
|
-
// Update or add placement
|
|
93
|
-
const existingPlacementIndex =
|
|
94
|
-
newManualEditState.pcb_placements.findIndex(
|
|
95
|
-
(p) => p.selector === nameofComponent.name,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const newPlacement: PCBPlacement = {
|
|
99
|
-
selector: nameofComponent.name,
|
|
100
|
-
center: editEvent.new_center,
|
|
101
|
-
relative_to: "group_center",
|
|
102
|
-
_edit_event_id: editEvent.edit_event_id,
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (existingPlacementIndex !== -1) {
|
|
106
|
-
// Update existing placement
|
|
107
|
-
newManualEditState.pcb_placements[existingPlacementIndex] =
|
|
108
|
-
newPlacement
|
|
109
|
-
} else {
|
|
110
|
-
// Add new placement
|
|
111
|
-
newManualEditState.pcb_placements.push(newPlacement)
|
|
112
|
-
}
|
|
113
|
-
} else if (editEvent.pcb_edit_event_type === "edit_trace_hint") {
|
|
114
|
-
const newTraceHint = getManualTraceHintFromEvent(circuitJson, editEvent)
|
|
115
|
-
if (newTraceHint) {
|
|
116
|
-
newManualEditState.manual_trace_hints = [
|
|
117
|
-
...newManualEditState.manual_trace_hints.filter(
|
|
118
|
-
(th) => th.pcb_port_selector !== newTraceHint.pcb_port_selector,
|
|
119
|
-
),
|
|
120
|
-
newTraceHint,
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
// Add any other type of event to edit_events array
|
|
125
|
-
newManualEditState.edit_events.push(editEvent)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
handledEventIds.add(editEvent.edit_event_id)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return newManualEditState
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error("Error handling edit events:", error)
|
|
134
|
-
// Return a fresh state if there's an error
|
|
135
|
-
return createInitialManualEditState()
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Helper function to ensure we have a valid state
|
|
140
|
-
const ensureValidState = (manualEditsFileContent?: string): ManualEditState => {
|
|
141
|
-
if (!manualEditsFileContent) return createInitialManualEditState()
|
|
142
|
-
|
|
143
|
-
const manualEditState = JSON.parse(manualEditsFileContent)
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
pcb_placements: Array.isArray(manualEditState.pcb_placements)
|
|
147
|
-
? manualEditState.pcb_placements
|
|
148
|
-
: [],
|
|
149
|
-
edit_events: Array.isArray(manualEditState.edit_events)
|
|
150
|
-
? manualEditState.edit_events
|
|
151
|
-
: [],
|
|
152
|
-
manual_trace_hints: Array.isArray(manualEditState.manual_trace_hints)
|
|
153
|
-
? manualEditState.manual_trace_hints
|
|
154
|
-
: [],
|
|
155
|
-
}
|
|
156
|
-
}
|
package/postcss.config.js
DELETED
package/renovate.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
-
"extends": ["config:base"],
|
|
4
|
-
"packageRules": [
|
|
5
|
-
{
|
|
6
|
-
"packagePatterns": ["*"],
|
|
7
|
-
"excludePackagePatterns": ["@tscircuit/*", "circuit-to-svg"],
|
|
8
|
-
"enabled": false
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"matchUpdateTypes": ["major", "minor", "patch"],
|
|
12
|
-
"automerge": true
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
}
|
package/scripts/build-css.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs"
|
|
2
|
-
import postcss from "postcss"
|
|
3
|
-
import tailwindcss from "tailwindcss"
|
|
4
|
-
import autoprefixer from "autoprefixer"
|
|
5
|
-
import cssnano from "cssnano"
|
|
6
|
-
import tailwindConfig from "../tailwind.config"
|
|
7
|
-
|
|
8
|
-
async function buildCss() {
|
|
9
|
-
// Read your base CSS file with @tailwind directives
|
|
10
|
-
const css = "@tailwind components; @tailwind utilities;"
|
|
11
|
-
|
|
12
|
-
const result = await postcss([
|
|
13
|
-
tailwindcss(tailwindConfig),
|
|
14
|
-
autoprefixer,
|
|
15
|
-
cssnano,
|
|
16
|
-
]).process(css, {
|
|
17
|
-
from: undefined,
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
fs.writeFileSync(
|
|
21
|
-
"./lib/hooks/styles.generated.ts",
|
|
22
|
-
`export default \`${result.css.replace(/\\/g, "\\\\")}\``,
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
buildCss()
|
package/src/main.tsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { RunFrameWithApi } from "lib/components/RunFrameWithApi"
|
|
2
|
-
import React from "react"
|
|
3
|
-
import { createRoot } from "react-dom/client"
|
|
4
|
-
|
|
5
|
-
const root = createRoot(document.getElementById("root")!)
|
|
6
|
-
|
|
7
|
-
root.render(
|
|
8
|
-
<React.StrictMode>
|
|
9
|
-
<div style={{ width: "100vw", height: "100vh" }}>
|
|
10
|
-
<RunFrameWithApi />
|
|
11
|
-
</div>
|
|
12
|
-
</React.StrictMode>,
|
|
13
|
-
)
|
package/tailwind.config.js
DELETED
package/tsconfig.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// Enable latest features
|
|
4
|
-
"lib": ["ESNext", "DOM"],
|
|
5
|
-
"target": "ES2020",
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"paths": {
|
|
13
|
-
"lib/*": ["lib/*"]
|
|
14
|
-
},
|
|
15
|
-
"esModuleInterop": true,
|
|
16
|
-
|
|
17
|
-
// Bundler mode
|
|
18
|
-
"moduleResolution": "bundler",
|
|
19
|
-
"allowImportingTsExtensions": true,
|
|
20
|
-
"verbatimModuleSyntax": true,
|
|
21
|
-
"noEmit": true,
|
|
22
|
-
|
|
23
|
-
// Best practices
|
|
24
|
-
"strict": true,
|
|
25
|
-
"skipLibCheck": true,
|
|
26
|
-
"noFallthroughCasesInSwitch": true,
|
|
27
|
-
|
|
28
|
-
// Some stricter flags (disabled by default)
|
|
29
|
-
"noUnusedLocals": false,
|
|
30
|
-
"noUnusedParameters": false,
|
|
31
|
-
"noPropertyAccessFromIndexSignature": false
|
|
32
|
-
},
|
|
33
|
-
"include": [
|
|
34
|
-
"lib/**/*.ts",
|
|
35
|
-
"lib/**/*.tsx",
|
|
36
|
-
"examples/**/*.ts",
|
|
37
|
-
"examples/**/*.tsx",
|
|
38
|
-
"cli/**/*.ts",
|
|
39
|
-
"cli/**/*.tsx",
|
|
40
|
-
"scripts/**/*.ts",
|
|
41
|
-
"scripts/**/*.tsx",
|
|
42
|
-
"src/**/*.ts",
|
|
43
|
-
"src/**/*.tsx"
|
|
44
|
-
]
|
|
45
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { defineConfig, type Plugin } from "vite"
|
|
2
|
-
import react from "@vitejs/plugin-react"
|
|
3
|
-
import { resolve } from "node:path"
|
|
4
|
-
import winterspecBundle from "@tscircuit/file-server/dist/bundle"
|
|
5
|
-
import { getNodeHandler } from "winterspec/adapters/node"
|
|
6
|
-
import { visualizer } from "rollup-plugin-visualizer"
|
|
7
|
-
|
|
8
|
-
const fakeHandler = getNodeHandler(winterspecBundle as any, {})
|
|
9
|
-
|
|
10
|
-
function apiServerPlugin(): Plugin {
|
|
11
|
-
return {
|
|
12
|
-
name: "api-server",
|
|
13
|
-
configureServer(server) {
|
|
14
|
-
server.middlewares.use(async (req, res, next) => {
|
|
15
|
-
if (req.url?.startsWith("/api/")) {
|
|
16
|
-
req.url = req.url.replace("/api/", "/")
|
|
17
|
-
fakeHandler(req, res)
|
|
18
|
-
} else {
|
|
19
|
-
next()
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const plugins: any[] = [react()]
|
|
27
|
-
|
|
28
|
-
if (!process.env.VERCEL && !process.env.STANDALONE) {
|
|
29
|
-
plugins.push(apiServerPlugin())
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let build: any = undefined
|
|
33
|
-
|
|
34
|
-
if (process.env.STANDALONE) {
|
|
35
|
-
// plugins.push(
|
|
36
|
-
// visualizer({
|
|
37
|
-
// filename: "stats.html",
|
|
38
|
-
// open: true, // Will open the stats.html file after build
|
|
39
|
-
// gzipSize: true,
|
|
40
|
-
// brotliSize: true,
|
|
41
|
-
// }),
|
|
42
|
-
// )
|
|
43
|
-
build = {
|
|
44
|
-
lib: {
|
|
45
|
-
entry: resolve(__dirname, "src/main.tsx"),
|
|
46
|
-
name: "standalone",
|
|
47
|
-
fileName: (format) => `standalone.min.js`,
|
|
48
|
-
formats: ["umd"],
|
|
49
|
-
},
|
|
50
|
-
minify: true,
|
|
51
|
-
// reportCompressedSize: true,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default defineConfig({
|
|
56
|
-
plugins,
|
|
57
|
-
resolve: {
|
|
58
|
-
alias: {
|
|
59
|
-
lib: resolve(__dirname, "./lib"),
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
define: {
|
|
63
|
-
global: {
|
|
64
|
-
process: {
|
|
65
|
-
env: {},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
root: ".",
|
|
70
|
-
publicDir: "public",
|
|
71
|
-
build,
|
|
72
|
-
})
|