@tscircuit/cli 0.0.394 → 0.1.2

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.
Files changed (246) hide show
  1. package/.github/workflows/bun-formatcheck.yml +26 -0
  2. package/.github/workflows/bun-pver-release.yml +25 -0
  3. package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
  4. package/LICENSE +21 -0
  5. package/README.md +33 -36
  6. package/biome.json +9 -9
  7. package/bun.lockb +0 -0
  8. package/cli/CliContext.ts +8 -0
  9. package/cli/auth/login/register.ts +73 -0
  10. package/cli/auth/logout/register.ts +11 -0
  11. package/cli/auth/register.ts +5 -0
  12. package/cli/clone/register.ts +99 -0
  13. package/cli/config/print/register.ts +12 -0
  14. package/cli/config/register.ts +5 -0
  15. package/cli/dev/register.ts +111 -0
  16. package/cli/main.ts +33 -0
  17. package/dist/main.js +537 -0
  18. package/docs/file-server-api-usage.md +57 -0
  19. package/docs/run-frame-usage.md +14 -0
  20. package/example-dir/manual-edits.json +1 -0
  21. package/example-dir/snippet.d.ts +13 -0
  22. package/example-dir/snippet.tsx +20 -0
  23. package/example-dir/types.d.ts +11 -0
  24. package/lib/cli-config/TypedConfigStore.ts +50 -0
  25. package/lib/cli-config/index.ts +16 -0
  26. package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
  27. package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
  28. package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
  29. package/lib/index.ts +2 -0
  30. package/lib/project-config/index.ts +5 -0
  31. package/lib/registry-api/endpoint-types.ts +20 -0
  32. package/lib/registry-api/get-ky.ts +30 -0
  33. package/lib/server/EventsWatcher.ts +75 -0
  34. package/lib/server/createServer.ts +62 -0
  35. package/lib/site/getIndex.ts +18 -0
  36. package/package.json +27 -144
  37. package/tsconfig.json +25 -22
  38. package/.github/workflows/formatbot.yml +0 -63
  39. package/.github/workflows/release.yml +0 -40
  40. package/.github/workflows/test.yml +0 -32
  41. package/.github/workflows/windows-tests.yml +0 -32
  42. package/.prettierrc +0 -1
  43. package/DEVELOPMENT.md +0 -7
  44. package/api/README.md +0 -3
  45. package/api/db/generic-json-level.ts +0 -123
  46. package/api/db/get-db.ts +0 -26
  47. package/api/db/schema.ts +0 -65
  48. package/api/db/zod-level-db.ts +0 -148
  49. package/api/index.ts +0 -4
  50. package/api/lib/middlewares/with-db.ts +0 -18
  51. package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
  52. package/api/lib/middlewares/with-error-response.ts +0 -37
  53. package/api/lib/with-winter-spec.ts +0 -9
  54. package/api/lib/zod/export_parameters.ts +0 -25
  55. package/api/routes/api/db/download.ts +0 -25
  56. package/api/routes/api/dev_package_examples/create.ts +0 -43
  57. package/api/routes/api/dev_package_examples/get.ts +0 -46
  58. package/api/routes/api/dev_package_examples/list.ts +0 -36
  59. package/api/routes/api/dev_package_examples/update.ts +0 -59
  60. package/api/routes/api/dev_server/reset.ts +0 -13
  61. package/api/routes/api/export_files/create.ts +0 -27
  62. package/api/routes/api/export_files/download.ts +0 -25
  63. package/api/routes/api/export_requests/create.ts +0 -30
  64. package/api/routes/api/export_requests/get.ts +0 -43
  65. package/api/routes/api/export_requests/list.ts +0 -26
  66. package/api/routes/api/export_requests/update.ts +0 -34
  67. package/api/routes/api/health.ts +0 -11
  68. package/api/routes/api/package_info/create.ts +0 -26
  69. package/api/routes/api/package_info/get.ts +0 -16
  70. package/api/routes/health.ts +0 -11
  71. package/api/routes/index.ts +0 -16
  72. package/api/server.ts +0 -20
  73. package/api/static-routes.ts +0 -24
  74. package/api/tests/fixtures/get-test-server.ts +0 -31
  75. package/api/tests/fixtures/start-server.ts +0 -41
  76. package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
  77. package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
  78. package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
  79. package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
  80. package/api/tests/routes/export_files/create.test.ts +0 -18
  81. package/api/tests/routes/export_files/download.test.ts +0 -29
  82. package/api/tests/routes/export_requests/create.test.ts +0 -24
  83. package/api/tests/routes/export_requests/get.test.ts +0 -41
  84. package/api/tests/routes/export_requests/list.test.ts +0 -35
  85. package/api/tests/routes/export_requests/update.test.ts +0 -50
  86. package/api/tests/routes/health.test.ts +0 -10
  87. package/bunfig.toml +0 -2
  88. package/cli/cli.ts +0 -13
  89. package/cli/lib/cmd-fns/add.ts +0 -34
  90. package/cli/lib/cmd-fns/auth-login.ts +0 -59
  91. package/cli/lib/cmd-fns/auth-logout.ts +0 -7
  92. package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
  93. package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
  94. package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
  95. package/cli/lib/cmd-fns/config-clear.ts +0 -5
  96. package/cli/lib/cmd-fns/config-print-config.ts +0 -6
  97. package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
  98. package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
  99. package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
  100. package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
  101. package/cli/lib/cmd-fns/config-set-session.ts +0 -7
  102. package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
  103. package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
  104. package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
  105. package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
  106. package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
  107. package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
  108. package/cli/lib/cmd-fns/dev/index.ts +0 -168
  109. package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
  110. package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
  111. package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
  112. package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
  113. package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
  114. package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
  115. package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
  116. package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
  117. package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
  118. package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
  119. package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
  120. package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
  121. package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
  122. package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
  123. package/cli/lib/cmd-fns/go.ts +0 -14
  124. package/cli/lib/cmd-fns/index.ts +0 -46
  125. package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
  126. package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
  127. package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
  128. package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
  129. package/cli/lib/cmd-fns/init/index.ts +0 -193
  130. package/cli/lib/cmd-fns/install.ts +0 -34
  131. package/cli/lib/cmd-fns/lint.ts +0 -43
  132. package/cli/lib/cmd-fns/open.ts +0 -19
  133. package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
  134. package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
  135. package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
  136. package/cli/lib/cmd-fns/package-files-create.ts +0 -31
  137. package/cli/lib/cmd-fns/package-files-download.ts +0 -29
  138. package/cli/lib/cmd-fns/package-files-get.ts +0 -3
  139. package/cli/lib/cmd-fns/package-files-list.ts +0 -28
  140. package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
  141. package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
  142. package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
  143. package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
  144. package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
  145. package/cli/lib/cmd-fns/packages-create.ts +0 -16
  146. package/cli/lib/cmd-fns/packages-get.ts +0 -16
  147. package/cli/lib/cmd-fns/packages-list.ts +0 -16
  148. package/cli/lib/cmd-fns/publish/index.ts +0 -336
  149. package/cli/lib/cmd-fns/remove.ts +0 -31
  150. package/cli/lib/cmd-fns/render.ts +0 -45
  151. package/cli/lib/cmd-fns/soupify.ts +0 -31
  152. package/cli/lib/cmd-fns/uninstall.ts +0 -31
  153. package/cli/lib/cmd-fns/version.ts +0 -38
  154. package/cli/lib/create-config-manager.ts +0 -97
  155. package/cli/lib/export-fns/export-bom-csv.ts +0 -32
  156. package/cli/lib/export-fns/export-gerbers.ts +0 -108
  157. package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
  158. package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
  159. package/cli/lib/get-program.ts +0 -387
  160. package/cli/lib/param-handlers/index.ts +0 -21
  161. package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
  162. package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
  163. package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
  164. package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
  165. package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
  166. package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
  167. package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
  168. package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
  169. package/cli/lib/param-handlers/param-handler-type.ts +0 -7
  170. package/cli/lib/posthog.ts +0 -23
  171. package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
  172. package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
  173. package/cli/lib/soupify/index.ts +0 -1
  174. package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
  175. package/cli/lib/soupify/soupify-with-core.ts +0 -74
  176. package/cli/lib/soupify/soupify.ts +0 -6
  177. package/cli/lib/util/app-context.ts +0 -17
  178. package/cli/lib/util/create-context-and-run-program.ts +0 -168
  179. package/cli/lib/util/get-all-package-files.ts +0 -66
  180. package/cli/lib/util/lint-project.ts +0 -137
  181. package/cli/tests/export-gerber-keyboard.test.ts +0 -16
  182. package/cli/tests/export-gerber.test.ts +0 -49
  183. package/cli/tests/export-kicad-pcb.test.ts +0 -23
  184. package/cli/tests/export-pnp-csv.test.ts +0 -24
  185. package/cli/tests/fixtures/preload.ts +0 -54
  186. package/cli/tests/init.test.ts +0 -9
  187. package/cli/tests/open.test.ts +0 -9
  188. package/cli/tests/soupify-builder.test.ts +0 -9
  189. package/cli/tests/soupify-core.test.ts +0 -9
  190. package/dist/cli.js +0 -3676
  191. package/docs/EDIT_EVENT_PIPELINE.md +0 -34
  192. package/example-project/README.md +0 -18
  193. package/example-project/examples/basic-capacitor.tsx +0 -5
  194. package/example-project/examples/basic-chip.tsx +0 -26
  195. package/example-project/examples/basic-resistor.tsx +0 -3
  196. package/example-project/examples/macrokeypad.tsx +0 -59
  197. package/example-project/index.ts +0 -1
  198. package/example-project/package.json +0 -5
  199. package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
  200. package/example-project/src/Key.tsx +0 -46
  201. package/example-project/src/Keyswitch.tsx +0 -26
  202. package/example-project/src/KeyswitchSocket.tsx +0 -56
  203. package/example-project/src/MyCircuit.tsx +0 -38
  204. package/example-project/src/manual-edits.ts +0 -93
  205. package/frontend/README.md +0 -3
  206. package/frontend/bun.lockb +0 -0
  207. package/frontend/components/command-k.tsx +0 -86
  208. package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
  209. package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
  210. package/frontend/components/global-context-providers.tsx +0 -11
  211. package/frontend/components/select-example-search.tsx +0 -118
  212. package/frontend/components/ui/alert-dialog.tsx +0 -139
  213. package/frontend/components/ui/alert.tsx +0 -59
  214. package/frontend/components/ui/breadcrumb.tsx +0 -115
  215. package/frontend/components/ui/button.tsx +0 -57
  216. package/frontend/components/ui/card.tsx +0 -76
  217. package/frontend/components/ui/command.tsx +0 -153
  218. package/frontend/components/ui/context-menu.tsx +0 -202
  219. package/frontend/components/ui/dialog.tsx +0 -120
  220. package/frontend/components/ui/menubar.tsx +0 -238
  221. package/frontend/components/ui/navigation-menu.tsx +0 -128
  222. package/frontend/components/ui/popover.tsx +0 -31
  223. package/frontend/components/ui/select.tsx +0 -162
  224. package/frontend/components/ui/tabs.tsx +0 -53
  225. package/frontend/components/ui/toggle-group.tsx +0 -59
  226. package/frontend/components/ui/toggle.tsx +0 -43
  227. package/frontend/components/ui/tooltip.tsx +0 -28
  228. package/frontend/components.json +0 -17
  229. package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
  230. package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
  231. package/frontend/hooks/use-dev-package-examples.tsx +0 -18
  232. package/frontend/hooks/use-global-store.ts +0 -42
  233. package/frontend/index.css +0 -76
  234. package/frontend/index.html +0 -13
  235. package/frontend/lib/utils.ts +0 -6
  236. package/frontend/main.tsx +0 -13
  237. package/frontend/tailwind.config.js +0 -74
  238. package/frontend/views/App.tsx +0 -22
  239. package/frontend/views/Header.tsx +0 -55
  240. package/frontend/views/HeaderMenu.tsx +0 -326
  241. package/frontend/views/MainContentView.tsx +0 -172
  242. package/frontend/vite-env.d.ts +0 -1
  243. package/frontend/vite.config.ts +0 -50
  244. package/renovate.json +0 -16
  245. package/scripts/build-cli.ts +0 -12
  246. package/tsup.config.ts +0 -7
@@ -1,326 +0,0 @@
1
- import axios from "axios"
2
- import { useState } from "react"
3
- import toast from "react-hot-toast"
4
- import { useQuery } from "react-query"
5
- import {
6
- Menubar,
7
- MenubarCheckboxItem,
8
- MenubarContent,
9
- MenubarItem,
10
- MenubarMenu,
11
- MenubarRadioGroup,
12
- MenubarRadioItem,
13
- MenubarSeparator,
14
- MenubarSub,
15
- MenubarSubContent,
16
- MenubarSubTrigger,
17
- MenubarTrigger,
18
- } from "frontend/components/ui/menubar"
19
- import cliPackageJson from "../../package.json"
20
- import { useGenericExportDialog } from "frontend/components/dialogs/generic-export-dialog"
21
- import { useGerberExportDialog } from "frontend/components/dialogs/gerber-export-dialog"
22
- import { useGlobalStore } from "frontend/hooks/use-global-store"
23
-
24
- const DEBUG_URL = "https://debug.tscircuit.com"
25
-
26
- export const HeaderMenu = () => {
27
- const [viewMode, setViewMode] = useGlobalStore((s) => [
28
- s.view_mode,
29
- s.setViewMode,
30
- ])
31
- const [splitMode, setSplitMode] = useGlobalStore((s) => [
32
- s.split_mode,
33
- s.setSplitMode,
34
- ])
35
- const devExamplePackageId = useGlobalStore(
36
- (s) => s.active_dev_example_package_id,
37
- )
38
-
39
- const { data, isLoading } = useQuery(
40
- ["package_info"],
41
- async () => axios.get("/api/package_info/get"),
42
- {
43
- refetchOnWindowFocus: true,
44
- retry: false,
45
- },
46
- )
47
-
48
- const name = data?.data.package_info.name
49
-
50
- const [inDebugMode, setInDebugMode] = useState(false)
51
- const gerberExportDialog = useGerberExportDialog()
52
- const pnpExportDialog = useGenericExportDialog({
53
- dialogTitle: "Export Pick'n'Place",
54
- dialogDescription:
55
- "Export the Pick'n'Place CSV for this example export. You can upload this to an assembler (PCBA) to tell their machines where to place each component.",
56
- exportFileName: "pnp.csv",
57
- exportParameters: {
58
- should_export_pnp_csv: true,
59
- },
60
- })
61
- const bomExportDialog = useGenericExportDialog({
62
- dialogTitle: "Export Bill of Materials",
63
- dialogDescription:
64
- "Export the Bill of Materials CSV for this example export. You can upload this to an assembler (PCBA) so they know how to source each component.",
65
- exportFileName: "bom.csv",
66
- exportParameters: {
67
- should_export_bom_csv: true,
68
- },
69
- })
70
- const soupExportDialog = useGenericExportDialog({
71
- dialogTitle: "Export tscircuit Soup",
72
- dialogDescription:
73
- "Export the tscircuit soup for this example export. This is an internal compiled JSON representation of your circuit.",
74
- exportFileName: "soup.json",
75
- exportParameters: {
76
- should_export_soup_json: true,
77
- },
78
- })
79
-
80
- const kicadPcbExportDialog = useGenericExportDialog({
81
- dialogTitle: "Export KiCad PCB",
82
- dialogDescription:
83
- "Export the circuit as a KiCad PCB file. This can be opened and edited in KiCad.",
84
- exportFileName: "kicad_pcb",
85
- fileExtension: ".kicad_pcb",
86
- exportParameters: {
87
- should_export_kicad_pcb: true,
88
- },
89
- })
90
-
91
- const handleDebugClick = async () => {
92
- const soupData = await axios
93
- .post("/api/dev_package_examples/get", {
94
- dev_package_example_id: devExamplePackageId,
95
- })
96
- .then((r) => r.data.dev_package_example.tscircuit_soup)
97
-
98
- // logSoup module is giving cors error
99
- await axios.post(
100
- `${DEBUG_URL}/api/soup_group/add_soup`,
101
- {
102
- soup_group_name: name,
103
- soup_name: name,
104
- username: "tmp",
105
- content: {
106
- elements: soupData,
107
- },
108
- },
109
- {
110
- headers: {
111
- "Access-Control-Allow-Origin": "*",
112
- "Content-Type": "application/json",
113
- },
114
- },
115
- )
116
- }
117
-
118
- return (
119
- <>
120
- <Menubar className="border-none shadow-none">
121
- <MenubarMenu>
122
- <MenubarTrigger>File</MenubarTrigger>
123
- <MenubarContent className="z-[200]">
124
- <MenubarItem disabled>{name}</MenubarItem>
125
- <MenubarSeparator />
126
- <MenubarItem
127
- onSelect={() => {
128
- toast.error("Not yet implemented!")
129
- }}
130
- >
131
- New Circuit
132
- </MenubarItem>
133
- <MenubarItem
134
- onSelect={() => {
135
- handleDebugClick()
136
- }}
137
- >
138
- Debug
139
- </MenubarItem>
140
- <MenubarSeparator />
141
- <MenubarSub>
142
- <MenubarSubTrigger>Export</MenubarSubTrigger>
143
- <MenubarSubContent>
144
- <MenubarItem onSelect={() => gerberExportDialog.openDialog()}>
145
- Gerbers
146
- </MenubarItem>
147
- <MenubarItem onSelect={() => pnpExportDialog.openDialog()}>
148
- Pick'n'Place CSV
149
- </MenubarItem>
150
- <MenubarItem onSelect={() => bomExportDialog.openDialog()}>
151
- Bill of Materials CSV
152
- </MenubarItem>
153
- <MenubarItem
154
- onSelect={() => {
155
- toast.error("Not yet implemented!")
156
- }}
157
- >
158
- Netlist
159
- </MenubarItem>
160
- <MenubarItem
161
- onSelect={() => {
162
- toast.error("Not yet implemented!")
163
- }}
164
- >
165
- Schematic (PDF)
166
- </MenubarItem>
167
- <MenubarItem onSelect={() => soupExportDialog.openDialog()}>
168
- Circuit JSON
169
- </MenubarItem>
170
- <MenubarItem onSelect={() => kicadPcbExportDialog.openDialog()}>
171
- KiCad PCB
172
- </MenubarItem>
173
- </MenubarSubContent>
174
- </MenubarSub>
175
- </MenubarContent>
176
- </MenubarMenu>
177
- <MenubarMenu>
178
- <MenubarTrigger>View</MenubarTrigger>
179
- <MenubarContent className="z-[200]">
180
- <MenubarRadioGroup
181
- value={viewMode}
182
- onValueChange={(v) => setViewMode(v as any)}
183
- >
184
- <MenubarRadioItem value="schematic">Schematic</MenubarRadioItem>
185
- <MenubarRadioItem value="pcb">PCB</MenubarRadioItem>
186
- <MenubarRadioItem value="split">Split View</MenubarRadioItem>
187
- <MenubarRadioItem value="soup">Soup</MenubarRadioItem>
188
- </MenubarRadioGroup>
189
- <MenubarSeparator />
190
- <MenubarRadioGroup
191
- value={viewMode === "split" ? splitMode : "neither"}
192
- onValueChange={(v) => setSplitMode(v as any)}
193
- >
194
- <MenubarRadioItem
195
- disabled={viewMode !== "split"}
196
- value="horizontal"
197
- >
198
- Horizontal Split
199
- </MenubarRadioItem>
200
- <MenubarRadioItem
201
- disabled={viewMode !== "split"}
202
- value="vertical"
203
- >
204
- Vertical Split
205
- </MenubarRadioItem>
206
- </MenubarRadioGroup>
207
- <MenubarSeparator />
208
- <MenubarCheckboxItem
209
- checked={inDebugMode}
210
- onSelect={() => setInDebugMode(!inDebugMode)}
211
- >
212
- Debug Mode
213
- </MenubarCheckboxItem>
214
- </MenubarContent>
215
- </MenubarMenu>
216
- <MenubarMenu>
217
- <MenubarTrigger>Package</MenubarTrigger>
218
- <MenubarContent className="z-[200]">
219
- <MenubarItem disabled>{name}</MenubarItem>
220
- <MenubarSeparator />
221
- <MenubarCheckboxItem
222
- checked
223
- onSelect={() => toast.error("Not yet implemented!")}
224
- >
225
- Published
226
- </MenubarCheckboxItem>
227
- <MenubarCheckboxItem
228
- onSelect={() => toast.error("Not yet implemented!")}
229
- >
230
- Locked
231
- </MenubarCheckboxItem>
232
- <MenubarItem onSelect={() => toast.error("Not yet implemented!")}>
233
- Publish New Version
234
- </MenubarItem>
235
- <MenubarSeparator />
236
- <MenubarItem
237
- onSelect={() => {
238
- toast.error("Not yet implemented!")
239
- // window.open(`https://registry.tscircuit.com/${}`)
240
- }}
241
- >
242
- View on Registry
243
- </MenubarItem>
244
- <MenubarItem
245
- onSelect={() => {
246
- toast.error("Not yet implemented!")
247
- // window.open(`https://registry.tscircuit.com/${}`)
248
- }}
249
- >
250
- Edit Registry Settings
251
- </MenubarItem>
252
- </MenubarContent>
253
- </MenubarMenu>
254
- <MenubarMenu>
255
- <MenubarTrigger>About</MenubarTrigger>
256
- <MenubarContent className="z-[200]">
257
- <MenubarItem
258
- onSelect={() => {
259
- window.open("https://github.com/tscircuit/tscircuit", "_blank")
260
- }}
261
- >
262
- Github
263
- </MenubarItem>
264
- <MenubarItem
265
- onSelect={() => {
266
- toast.error("Not yet implemented!")
267
- }}
268
- >
269
- Tutorials
270
- </MenubarItem>
271
- <MenubarItem
272
- onSelect={() => {
273
- toast.error("Not yet implemented!")
274
- }}
275
- >
276
- tscircuit.com
277
- </MenubarItem>
278
- <MenubarItem
279
- onSelect={() => {
280
- toast.error("Not yet implemented!")
281
- }}
282
- >
283
- registry.tscircuit.com
284
- </MenubarItem>
285
- <MenubarItem
286
- onSelect={() => {
287
- window.open("https://tscircuit.com/changelog", "_blank")
288
- }}
289
- >
290
- Changelog
291
- </MenubarItem>
292
- <MenubarSeparator />
293
- <MenubarItem disabled>
294
- @tscircuit/cli v{cliPackageJson.version}
295
- </MenubarItem>
296
- <MenubarItem disabled>
297
- @tscircuit/core v
298
- {cliPackageJson.dependencies?.["@tscircuit/core"]?.replace(
299
- /\^/g,
300
- "",
301
- )}
302
- </MenubarItem>
303
- <MenubarItem disabled>
304
- @tscircuit/schematic-viewer v
305
- {cliPackageJson.devDependencies[
306
- "@tscircuit/schematic-viewer"
307
- ].replace(/\^/g, "")}
308
- </MenubarItem>
309
- <MenubarItem disabled>
310
- @tscircuit/pcb-viewer v
311
- {cliPackageJson.devDependencies["@tscircuit/pcb-viewer"].replace(
312
- /\^/g,
313
- "",
314
- )}
315
- </MenubarItem>
316
- </MenubarContent>
317
- </MenubarMenu>
318
- </Menubar>
319
- <gerberExportDialog.Component />
320
- <pnpExportDialog.Component />
321
- <bomExportDialog.Component />
322
- <soupExportDialog.Component />
323
- <kicadPcbExportDialog.Component />
324
- </>
325
- )
326
- }
@@ -1,172 +0,0 @@
1
- import { useQuery } from "react-query"
2
- import { useGlobalStore } from "frontend/hooks/use-global-store"
3
- import axios from "axios"
4
- import { Schematic } from "@tscircuit/schematic-viewer"
5
- import { PCBViewer } from "@tscircuit/pcb-viewer"
6
- import { cn } from "frontend/lib/utils"
7
- import { ErrorBoundary } from "react-error-boundary"
8
- import { SoupTableViewer } from "@tscircuit/table-viewer"
9
- import "react-data-grid/lib/styles.css"
10
- import { useEffect, useRef, useState } from "react"
11
- import type { EditEvent } from "@tscircuit/pcb-viewer"
12
- import { CadViewer } from "@tscircuit/3d-viewer"
13
- import type { PcbHole, PcbSmtPad, PcbCircuitElement } from "circuit-json"
14
-
15
- export const MainContentView = () => {
16
- const devExamplePackageId = useGlobalStore(
17
- (s) => s.active_dev_example_package_id,
18
- )
19
-
20
- const {
21
- data: pkg,
22
- error,
23
- isError,
24
- isLoading,
25
- } = useQuery(
26
- ["dev_package_example", devExamplePackageId],
27
- async () =>
28
- axios
29
- .post(`/api/dev_package_examples/get`, {
30
- dev_package_example_id: devExamplePackageId,
31
- })
32
- .then((r) => r.data.dev_package_example),
33
- {
34
- refetchInterval: 5_000,
35
- refetchIntervalInBackground: true,
36
- refetchOnWindowFocus: true,
37
- retry: false,
38
- },
39
- )
40
-
41
- const sentEditEvents = useRef<Record<string, boolean>>({})
42
-
43
- const notFound = (error as any)?.response?.status === 404
44
-
45
- const viewMode = useGlobalStore((s) => s.view_mode)
46
- const splitMode = useGlobalStore((s) => s.split_mode)
47
- // eslint-disable-next-line prefer-const
48
- let [editEvents, setEditEvents] = useState<EditEvent[]>([])
49
-
50
- editEvents = editEvents.filter(
51
- (ee) =>
52
- ee.created_at > new Date(pkg?.edit_events_last_applied_at).valueOf(),
53
- )
54
-
55
- const editorHeight = window.innerHeight - 52
56
- const halfHeight = Math.floor(editorHeight / 2)
57
-
58
- const itemHeight =
59
- viewMode === "split" && splitMode === "vertical" ? halfHeight : editorHeight
60
-
61
- return (
62
- <div
63
- key={pkg?.soup_last_updated_at}
64
- className={cn(
65
- "relative",
66
- `h-[${editorHeight}px]`,
67
- viewMode === "split" &&
68
- splitMode === "horizontal" &&
69
- "grid grid-cols-2",
70
- viewMode === "split" && splitMode === "vertical" && "grid grid-rows-2",
71
- )}
72
- >
73
- {pkg && (viewMode === "schematic" || viewMode === "split") && (
74
- <ErrorBoundary fallback={<div>Failed to render Schematic</div>}>
75
- <Schematic
76
- key={`sch-${pkg?.dev_package_example_id}-${pkg?.soup_last_updated_at}`}
77
- style={{ height: itemHeight }}
78
- soup={pkg.tscircuit_soup}
79
- showTable={false}
80
- />
81
- </ErrorBoundary>
82
- )}
83
- {pkg && (viewMode === "pcb" || viewMode === "split") && (
84
- <ErrorBoundary fallback={<div>Failed to render PCB</div>}>
85
- <PCBViewer
86
- key={`pcb-${pkg?.dev_package_example_id}`}
87
- height={itemHeight}
88
- allowEditing
89
- editEvents={editEvents}
90
- onEditEventsChanged={(changedEditEvents) => {
91
- // Look for any edit events that have not been sent to the server
92
- // and send them, then mark them as sent
93
- let hasUnsentEditEvents = false
94
- for (const editEvent of changedEditEvents) {
95
- if (
96
- !editEvent.in_progress &&
97
- !sentEditEvents.current[editEvent.edit_event_id]
98
- ) {
99
- hasUnsentEditEvents = true
100
- sentEditEvents.current[editEvent.edit_event_id] = true
101
- }
102
- }
103
- if (hasUnsentEditEvents) {
104
- axios.post(`/api/dev_package_examples/update`, {
105
- dev_package_example_id: devExamplePackageId,
106
- completed_edit_events: changedEditEvents.filter(
107
- (ee) => ee.in_progress === false,
108
- ),
109
- })
110
- }
111
- setEditEvents(changedEditEvents)
112
- }}
113
- soup={pkg.tscircuit_soup}
114
- />
115
- </ErrorBoundary>
116
- )}
117
- {pkg && viewMode === "3d" && (
118
- <ErrorBoundary
119
- fallbackRender={(props) => (
120
- <div style={{ padding: 20 }}>
121
- Failed to render 3d view
122
- <div style={{ marginTop: 20, color: "red" }}>
123
- {props.error.message}
124
- </div>
125
- </div>
126
- )}
127
- >
128
- <div style={{ height: itemHeight }}>
129
- <CadViewer soup={pkg.tscircuit_soup} />
130
- </div>
131
- </ErrorBoundary>
132
- )}
133
- {pkg && viewMode === "soup" && (
134
- <ErrorBoundary fallback={<div>Failed to render Soup</div>}>
135
- <SoupTableViewer
136
- key={`soup-${pkg?.soup_last_updated_at}`}
137
- height={itemHeight}
138
- elements={pkg.tscircuit_soup}
139
- appearance="dark"
140
- />
141
- </ErrorBoundary>
142
- )}
143
- {pkg?.error && viewMode !== "soup" && (
144
- <div className="absolute top-0 w-full">
145
- <div className="p-4 m-16 whitespace-pre border border-red-200 rounded-lg shadow-lg bg-red-50">
146
- {pkg?.error}
147
- </div>
148
- </div>
149
- )}
150
- {notFound && (
151
- <div className="absolute top-0 flex justify-center w-full">
152
- <div className="bg-yellow-50 shadow-lg p-4 m-16 border-yellow-200 border rounded-lg whitespace-pre max-w-[400px]">
153
- Select an example from the menu above
154
- </div>
155
- </div>
156
- )}
157
- {isLoading && !isError && (
158
- <div className="absolute top-0 flex justify-center w-full">
159
- <div className="p-4 m-16 whitespace-pre border border-gray-200 rounded-lg shadow-lg bg-gray-50">
160
- Loading...
161
- </div>
162
- </div>
163
- )}
164
- {pkg && pkg.is_loading && (
165
- <div className="absolute top-0 right-0 z-10 flex items-center p-4 py-2 m-4 bg-white border border-gray-200 rounded-md shadow-lg">
166
- <div className="w-4 h-4 mr-2 border-2 border-blue-400 rounded-full border-t-transparent animate-spin"></div>
167
- Rebuilding...
168
- </div>
169
- )}
170
- </div>
171
- )
172
- }
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,50 +0,0 @@
1
- import react from "@vitejs/plugin-react"
2
- import path from "node:path"
3
- import { defineConfig } from "vite"
4
- import tailwindcss from "tailwindcss"
5
- import autoprefixer from "autoprefixer"
6
-
7
- // https://vitejs.dev/config/
8
- export default defineConfig({
9
- root: path.resolve(__dirname),
10
- plugins: [react()],
11
- resolve: {
12
- alias: [
13
- {
14
- find: "frontend",
15
- replacement: path.resolve(__dirname),
16
- },
17
- {
18
- find: "src",
19
- replacement: path.resolve(__dirname),
20
- },
21
- ],
22
- },
23
- server: {
24
- proxy: {
25
- "/api": "http://127.0.0.1:3020",
26
- },
27
- },
28
- optimizeDeps: {
29
- needsInterop: ["@tscircuit/schematic-viewer"],
30
- },
31
- define: {
32
- // Global var used by some dep inside schematic-viewer
33
- global: {},
34
- },
35
- build: {
36
- outDir: path.resolve(__dirname, "dist"),
37
- rollupOptions: {
38
- input: path.resolve(__dirname, "index.html"),
39
- },
40
- },
41
- base: "/preview",
42
- css: {
43
- postcss: {
44
- plugins: [
45
- tailwindcss(path.resolve(__dirname, "tailwind.config.js")),
46
- autoprefixer,
47
- ],
48
- },
49
- },
50
- })
package/renovate.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": ["config:base"],
4
- "enabled": false,
5
- "packageRules": [
6
- {
7
- "packagePatterns": ["*"],
8
- "excludePackagePatterns": ["@tscircuit/*"],
9
- "enabled": false
10
- },
11
- {
12
- "matchUpdateTypes": ["major", "minor", "patch"],
13
- "automerge": true
14
- }
15
- ]
16
- }
@@ -1,12 +0,0 @@
1
- import mainPkg from "../package.json"
2
-
3
- await Bun.build({
4
- entrypoints: ["./cli/cli.ts"],
5
- external: [
6
- ...Object.keys(mainPkg.dependencies),
7
- ...Object.keys(mainPkg.devDependencies),
8
- ...Object.keys(mainPkg.peerDependencies),
9
- ],
10
- outdir: "dist",
11
- target: "node",
12
- })
package/tsup.config.ts DELETED
@@ -1,7 +0,0 @@
1
- import { defineConfig } from "tsup"
2
-
3
- export default defineConfig({
4
- env: {
5
- POSTHOG_API_KEY: JSON.stringify(process.env.POSTHOG_API_KEY || ""),
6
- },
7
- })