@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.
- package/.github/workflows/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-pver-release.yml +25 -0
- package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
- package/LICENSE +21 -0
- package/README.md +33 -36
- package/biome.json +9 -9
- package/bun.lockb +0 -0
- package/cli/CliContext.ts +8 -0
- package/cli/auth/login/register.ts +73 -0
- package/cli/auth/logout/register.ts +11 -0
- package/cli/auth/register.ts +5 -0
- package/cli/clone/register.ts +99 -0
- package/cli/config/print/register.ts +12 -0
- package/cli/config/register.ts +5 -0
- package/cli/dev/register.ts +111 -0
- package/cli/main.ts +33 -0
- package/dist/main.js +537 -0
- package/docs/file-server-api-usage.md +57 -0
- package/docs/run-frame-usage.md +14 -0
- package/example-dir/manual-edits.json +1 -0
- package/example-dir/snippet.d.ts +13 -0
- package/example-dir/snippet.tsx +20 -0
- package/example-dir/types.d.ts +11 -0
- package/lib/cli-config/TypedConfigStore.ts +50 -0
- package/lib/cli-config/index.ts +16 -0
- package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
- package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
- package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
- package/lib/index.ts +2 -0
- package/lib/project-config/index.ts +5 -0
- package/lib/registry-api/endpoint-types.ts +20 -0
- package/lib/registry-api/get-ky.ts +30 -0
- package/lib/server/EventsWatcher.ts +75 -0
- package/lib/server/createServer.ts +62 -0
- package/lib/site/getIndex.ts +18 -0
- package/package.json +27 -144
- package/tsconfig.json +25 -22
- package/.github/workflows/formatbot.yml +0 -63
- package/.github/workflows/release.yml +0 -40
- package/.github/workflows/test.yml +0 -32
- package/.github/workflows/windows-tests.yml +0 -32
- package/.prettierrc +0 -1
- package/DEVELOPMENT.md +0 -7
- package/api/README.md +0 -3
- package/api/db/generic-json-level.ts +0 -123
- package/api/db/get-db.ts +0 -26
- package/api/db/schema.ts +0 -65
- package/api/db/zod-level-db.ts +0 -148
- package/api/index.ts +0 -4
- package/api/lib/middlewares/with-db.ts +0 -18
- package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
- package/api/lib/middlewares/with-error-response.ts +0 -37
- package/api/lib/with-winter-spec.ts +0 -9
- package/api/lib/zod/export_parameters.ts +0 -25
- package/api/routes/api/db/download.ts +0 -25
- package/api/routes/api/dev_package_examples/create.ts +0 -43
- package/api/routes/api/dev_package_examples/get.ts +0 -46
- package/api/routes/api/dev_package_examples/list.ts +0 -36
- package/api/routes/api/dev_package_examples/update.ts +0 -59
- package/api/routes/api/dev_server/reset.ts +0 -13
- package/api/routes/api/export_files/create.ts +0 -27
- package/api/routes/api/export_files/download.ts +0 -25
- package/api/routes/api/export_requests/create.ts +0 -30
- package/api/routes/api/export_requests/get.ts +0 -43
- package/api/routes/api/export_requests/list.ts +0 -26
- package/api/routes/api/export_requests/update.ts +0 -34
- package/api/routes/api/health.ts +0 -11
- package/api/routes/api/package_info/create.ts +0 -26
- package/api/routes/api/package_info/get.ts +0 -16
- package/api/routes/health.ts +0 -11
- package/api/routes/index.ts +0 -16
- package/api/server.ts +0 -20
- package/api/static-routes.ts +0 -24
- package/api/tests/fixtures/get-test-server.ts +0 -31
- package/api/tests/fixtures/start-server.ts +0 -41
- package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
- package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
- package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
- package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
- package/api/tests/routes/export_files/create.test.ts +0 -18
- package/api/tests/routes/export_files/download.test.ts +0 -29
- package/api/tests/routes/export_requests/create.test.ts +0 -24
- package/api/tests/routes/export_requests/get.test.ts +0 -41
- package/api/tests/routes/export_requests/list.test.ts +0 -35
- package/api/tests/routes/export_requests/update.test.ts +0 -50
- package/api/tests/routes/health.test.ts +0 -10
- package/bunfig.toml +0 -2
- package/cli/cli.ts +0 -13
- package/cli/lib/cmd-fns/add.ts +0 -34
- package/cli/lib/cmd-fns/auth-login.ts +0 -59
- package/cli/lib/cmd-fns/auth-logout.ts +0 -7
- package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
- package/cli/lib/cmd-fns/config-clear.ts +0 -5
- package/cli/lib/cmd-fns/config-print-config.ts +0 -6
- package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
- package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
- package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
- package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
- package/cli/lib/cmd-fns/config-set-session.ts +0 -7
- package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
- package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
- package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
- package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
- package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
- package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
- package/cli/lib/cmd-fns/dev/index.ts +0 -168
- package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
- package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
- package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
- package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
- package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
- package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
- package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
- package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
- package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
- package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
- package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
- package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
- package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
- package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
- package/cli/lib/cmd-fns/go.ts +0 -14
- package/cli/lib/cmd-fns/index.ts +0 -46
- package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
- package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
- package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
- package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
- package/cli/lib/cmd-fns/init/index.ts +0 -193
- package/cli/lib/cmd-fns/install.ts +0 -34
- package/cli/lib/cmd-fns/lint.ts +0 -43
- package/cli/lib/cmd-fns/open.ts +0 -19
- package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
- package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
- package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
- package/cli/lib/cmd-fns/package-files-create.ts +0 -31
- package/cli/lib/cmd-fns/package-files-download.ts +0 -29
- package/cli/lib/cmd-fns/package-files-get.ts +0 -3
- package/cli/lib/cmd-fns/package-files-list.ts +0 -28
- package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
- package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
- package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
- package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
- package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
- package/cli/lib/cmd-fns/packages-create.ts +0 -16
- package/cli/lib/cmd-fns/packages-get.ts +0 -16
- package/cli/lib/cmd-fns/packages-list.ts +0 -16
- package/cli/lib/cmd-fns/publish/index.ts +0 -336
- package/cli/lib/cmd-fns/remove.ts +0 -31
- package/cli/lib/cmd-fns/render.ts +0 -45
- package/cli/lib/cmd-fns/soupify.ts +0 -31
- package/cli/lib/cmd-fns/uninstall.ts +0 -31
- package/cli/lib/cmd-fns/version.ts +0 -38
- package/cli/lib/create-config-manager.ts +0 -97
- package/cli/lib/export-fns/export-bom-csv.ts +0 -32
- package/cli/lib/export-fns/export-gerbers.ts +0 -108
- package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
- package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
- package/cli/lib/get-program.ts +0 -387
- package/cli/lib/param-handlers/index.ts +0 -21
- package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
- package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
- package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
- package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
- package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
- package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
- package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
- package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
- package/cli/lib/param-handlers/param-handler-type.ts +0 -7
- package/cli/lib/posthog.ts +0 -23
- package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
- package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
- package/cli/lib/soupify/index.ts +0 -1
- package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
- package/cli/lib/soupify/soupify-with-core.ts +0 -74
- package/cli/lib/soupify/soupify.ts +0 -6
- package/cli/lib/util/app-context.ts +0 -17
- package/cli/lib/util/create-context-and-run-program.ts +0 -168
- package/cli/lib/util/get-all-package-files.ts +0 -66
- package/cli/lib/util/lint-project.ts +0 -137
- package/cli/tests/export-gerber-keyboard.test.ts +0 -16
- package/cli/tests/export-gerber.test.ts +0 -49
- package/cli/tests/export-kicad-pcb.test.ts +0 -23
- package/cli/tests/export-pnp-csv.test.ts +0 -24
- package/cli/tests/fixtures/preload.ts +0 -54
- package/cli/tests/init.test.ts +0 -9
- package/cli/tests/open.test.ts +0 -9
- package/cli/tests/soupify-builder.test.ts +0 -9
- package/cli/tests/soupify-core.test.ts +0 -9
- package/dist/cli.js +0 -3676
- package/docs/EDIT_EVENT_PIPELINE.md +0 -34
- package/example-project/README.md +0 -18
- package/example-project/examples/basic-capacitor.tsx +0 -5
- package/example-project/examples/basic-chip.tsx +0 -26
- package/example-project/examples/basic-resistor.tsx +0 -3
- package/example-project/examples/macrokeypad.tsx +0 -59
- package/example-project/index.ts +0 -1
- package/example-project/package.json +0 -5
- package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
- package/example-project/src/Key.tsx +0 -46
- package/example-project/src/Keyswitch.tsx +0 -26
- package/example-project/src/KeyswitchSocket.tsx +0 -56
- package/example-project/src/MyCircuit.tsx +0 -38
- package/example-project/src/manual-edits.ts +0 -93
- package/frontend/README.md +0 -3
- package/frontend/bun.lockb +0 -0
- package/frontend/components/command-k.tsx +0 -86
- package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
- package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
- package/frontend/components/global-context-providers.tsx +0 -11
- package/frontend/components/select-example-search.tsx +0 -118
- package/frontend/components/ui/alert-dialog.tsx +0 -139
- package/frontend/components/ui/alert.tsx +0 -59
- package/frontend/components/ui/breadcrumb.tsx +0 -115
- package/frontend/components/ui/button.tsx +0 -57
- package/frontend/components/ui/card.tsx +0 -76
- package/frontend/components/ui/command.tsx +0 -153
- package/frontend/components/ui/context-menu.tsx +0 -202
- package/frontend/components/ui/dialog.tsx +0 -120
- package/frontend/components/ui/menubar.tsx +0 -238
- package/frontend/components/ui/navigation-menu.tsx +0 -128
- package/frontend/components/ui/popover.tsx +0 -31
- package/frontend/components/ui/select.tsx +0 -162
- package/frontend/components/ui/tabs.tsx +0 -53
- package/frontend/components/ui/toggle-group.tsx +0 -59
- package/frontend/components/ui/toggle.tsx +0 -43
- package/frontend/components/ui/tooltip.tsx +0 -28
- package/frontend/components.json +0 -17
- package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
- package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
- package/frontend/hooks/use-dev-package-examples.tsx +0 -18
- package/frontend/hooks/use-global-store.ts +0 -42
- package/frontend/index.css +0 -76
- package/frontend/index.html +0 -13
- package/frontend/lib/utils.ts +0 -6
- package/frontend/main.tsx +0 -13
- package/frontend/tailwind.config.js +0 -74
- package/frontend/views/App.tsx +0 -22
- package/frontend/views/Header.tsx +0 -55
- package/frontend/views/HeaderMenu.tsx +0 -326
- package/frontend/views/MainContentView.tsx +0 -172
- package/frontend/vite-env.d.ts +0 -1
- package/frontend/vite.config.ts +0 -50
- package/renovate.json +0 -16
- package/scripts/build-cli.ts +0 -12
- 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
|
-
}
|
package/frontend/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/frontend/vite.config.ts
DELETED
|
@@ -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
|
-
}
|
package/scripts/build-cli.ts
DELETED
|
@@ -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
|
-
})
|