@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,34 +0,0 @@
1
- # Edit Event Pipeline
2
-
3
- Whenever someone makes a manual edit to tscircuit, a `manual-edits.ts` file is created
4
- or edited describing what was changed. This file can be loaded into a `<board />` component
5
- with `layout={layout().manualEdits(manualEdits)}`.
6
-
7
- There pipeline for edit events is kind of complicated because the event must appear
8
- to happen instantaneously, but must also be stored, and the circuit should be
9
- re-rendered to determine the new routing.
10
-
11
- If you're debugging the edit event pipeline, turn on the debug logs:
12
-
13
- ```bash
14
- DEBUG=tscircuit:cli:edit-event-watcher
15
- ```
16
-
17
- ## How the Edit Events are Processed
18
-
19
- This these are all the steps that happen to add an edit to `manual-edits.ts`,
20
- then apply it to the circuit.
21
-
22
- 1. The user makes a change inside the `pcb-viewer` or `schematic-viewer`
23
- 2. An edit event is emitted via e.g. `<PCBViewer onEditEventsChanged={...} />`
24
- 3. The edit event is added to the list of `instantEditEvents` in `MainContentView.tsx`
25
- 1. Instant edit events are applied on the browser side, but don't re-route the circuit
26
- 2. You can tell you're in the phase where the edit event is still be processed and hasn't
27
- been rendered because the traces still point to the old location
28
- 4. The edit event is sent to the api server in a post request to `/api/dev_package_examples/update`
29
- 5. The api server adds the edit event to the database
30
- 6. The CLI "watcher" (see `start-edit-event-watcher.ts`) polls for new edit events
31
- 7. The CLI watcher edits the `manual-edits.ts` file and triggers the circuit to re-render
32
- 8. The circuit re-renders and the circuit json (soup) is updated on the server via `/api/dev_package_examples/update`
33
- 9. The browser polls for the updated soup via `/api/dev_package_examples/get_soup` and the browser
34
- updates with the fully routed circuit json
@@ -1,18 +0,0 @@
1
- # seveibar/example-project-3
2
-
3
- To develop and view the examples, run `tsci dev` and open [http://127.0.0.1:3020](http://127.0.0.1:3020) in your browser.
4
-
5
- ## Developing
6
-
7
- You should install an editor like [VS Code](https://code.visualstudio.com/) with a typescript extension. Many web developers already have this.
8
-
9
- Usually, you'll want to develop some named circuits inside of the `lib` directory,
10
- export them in the `index.ts` file, then show how to use them in the `examples` directory.
11
-
12
- Any file in `examples` will be automatically loaded and appear in the browser preview when you run `tsci dev`. It auto-reloads when you make changes, no need to reload the page or re-run the command.
13
-
14
- > [!TIP] Make sure to replace this README with some details about your project and how to use it.
15
-
16
- ## Publishing
17
-
18
- After you're satisfied with your project, publish it on the [tscircuit registry](https://registry.tscircuit.com) with `tsci publish`
@@ -1,5 +0,0 @@
1
- export const CapacitorExample = () => (
2
- <board width="10mm" height="10mm">
3
- <capacitor capacitance="10uF" name="C1" footprint="0805" />
4
- </board>
5
- )
@@ -1,26 +0,0 @@
1
- import "@tscircuit/core"
2
- import { layout } from "@tscircuit/layout"
3
- import manual_edits from "../src/manual-edits"
4
-
5
- export const BasicChip = () => (
6
- <board pcbX={0} pcbY={0} width="20mm" height="20mm">
7
- <group subcircuit>
8
- <chip
9
- name="U2"
10
- schPortArrangement={{
11
- leftSize: 8,
12
- rightSize: 8,
13
- }}
14
- footprint="ssop16"
15
- pinLabels={{
16
- "1": "GND",
17
- "2": "VBUS",
18
- "3": "D-",
19
- "4": "D+",
20
- }}
21
- />
22
- <resistor name="R1" pcbX={4} resistance="10kohm" footprint="0805" />
23
- <trace from=".U2 > .1" to=".R1 > port.1" />
24
- </group>
25
- </board>
26
- )
@@ -1,3 +0,0 @@
1
- import { MyCircuit } from "../src/MyCircuit"
2
-
3
- export const ExampleResistor = () => <MyCircuit />
@@ -1,59 +0,0 @@
1
- import { layout } from "@tscircuit/layout"
2
- import { ArduinoProMicroBreakout } from "example-project/src/ArduinoProMicroBreakout"
3
- import { Key } from "example-project/src/Key"
4
- import manualEdits from "example-project/src/manual-edits"
5
- import { KeyswitchSocket } from "example-project/src/KeyswitchSocket"
6
-
7
- export const MacroKeypad = () => {
8
- const keyPositions = Array.from({ length: 9 })
9
- .map((_, i) => ({
10
- keyNum: i + 1,
11
- col: i % 3,
12
- row: Math.floor(i / 3),
13
- }))
14
- .map((p) => ({
15
- ...p,
16
- x: p.col * 19.05 - 19.05,
17
- y: p.row * 19.05 - 19.05,
18
- }))
19
-
20
- const rowToMicroPin = {
21
- 0: "D2",
22
- 1: "D3",
23
- 2: "D4",
24
- }
25
- const colToMicroPin = {
26
- 0: "D5",
27
- 1: "D6",
28
- 2: "D7",
29
- }
30
-
31
- return (
32
- <board
33
- width="85mm"
34
- height="60mm"
35
- layout={layout().manualEdits(manualEdits)}
36
- >
37
- {keyPositions.map(({ keyNum, x, y }) => (
38
- <Key name={`K${keyNum}`} keyNum={keyNum} pcbX={x - 12.5} pcbY={y + 2} />
39
- ))}
40
- <ArduinoProMicroBreakout key="u1" name="U1" pcbX={30.5} />
41
- {keyPositions.map(({ keyNum, row, col }) => (
42
- <trace
43
- // @ts-ignore
44
- key={`trace-${keyNum}-col`}
45
- from={`.SW${keyNum} .pin1`}
46
- to={`.U1 .${colToMicroPin[col as 0 | 1 | 2]}`}
47
- />
48
- ))}
49
- {keyPositions.map(({ keyNum, row, col }) => (
50
- <trace
51
- // @ts-ignore
52
- key={`trace-${keyNum}-row`}
53
- from={`.D${keyNum} .pin2`}
54
- to={`.U1 .${rowToMicroPin[row as 0 | 1 | 2]}`}
55
- />
56
- ))}
57
- </board>
58
- )
59
- }
@@ -1 +0,0 @@
1
- export * from "./src/MyCircuit"
@@ -1,5 +0,0 @@
1
- {
2
- "name": "example-project",
3
- "description": "An example project for tscircuit, this package.json is required",
4
- "type": "module"
5
- }
@@ -1,37 +0,0 @@
1
- export const ArduinoProMicroBreakout = (props: {
2
- name: string
3
- pcbX?: number
4
- pcbY?: number
5
- }) => (
6
- <chip
7
- {...props}
8
- footprint="dip24_w0.7in_h1.3in"
9
- pinLabels={{
10
- pin1: "TXD",
11
- pin2: "RXI",
12
- pin3: "GND1",
13
- pin4: "GND2",
14
- pin5: "D2",
15
- pin6: "D3",
16
- pin7: "D4",
17
- pin8: "D5",
18
- pin9: "D6",
19
- pin10: "D7",
20
- pin11: "D8",
21
- pin12: "D9",
22
- // right side (from bottom)
23
- pin13: "D10",
24
- pin14: "D16",
25
- pin15: "D14",
26
- pin16: "D15",
27
- pin17: "A0",
28
- pin18: "A1",
29
- pin19: "A2",
30
- pin20: "A3",
31
- pin21: "VCC",
32
- pin22: "RST",
33
- pin23: "GND3",
34
- pin24: "RAW",
35
- }}
36
- />
37
- )
@@ -1,46 +0,0 @@
1
- import { Keyswitch } from "./Keyswitch"
2
- import { KeyswitchSocket } from "./KeyswitchSocket"
3
-
4
- export const Key = (props: {
5
- name: string
6
- keyNum: number
7
- pcbX: number
8
- pcbY: number
9
- }) => {
10
- const socketName = `SW${props.keyNum}`
11
- const switchHoleName = `HO${props.keyNum}`
12
- const diodeName = `D${props.keyNum}`
13
- return (
14
- <>
15
- <KeyswitchSocket
16
- key="shaft1"
17
- layer="bottom"
18
- name={socketName}
19
- pcbX={props.pcbX}
20
- pcbY={props.pcbY}
21
- />
22
- <Keyswitch
23
- key="switch"
24
- name={switchHoleName}
25
- pcbX={props.pcbX + 0.55}
26
- pcbY={props.pcbY + -3.81}
27
- />
28
- <diode
29
- // @ts-ignore
30
- key="diode"
31
- pcbRotation={-90}
32
- name={diodeName}
33
- footprint="0603"
34
- layer="bottom"
35
- pcbX={props.pcbX + 7}
36
- pcbY={props.pcbY - 6}
37
- />
38
- <trace
39
- // @ts-ignore
40
- key="trace1"
41
- from={`.${socketName} .pin2`}
42
- to={`.${diodeName} .pin1`}
43
- />
44
- </>
45
- )
46
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Keyswitch (Brown)
3
- *
4
- * https://www.lcsc.com/datasheet/lcsc_datasheet_1912111437_Kailh-CPG1511F01S03_C400227.pdf
5
- */
6
- export const Keyswitch = (props: {
7
- name: string
8
- pcbX?: number
9
- pcbY?: number
10
- }) => {
11
- return (
12
- <chip
13
- {...props}
14
- cadModel={{
15
- objUrl:
16
- "https://modelcdn.tscircuit.com/easyeda_models/download?pn=C400227",
17
- rotationOffset: { x: 180, y: 0, z: -90 },
18
- }}
19
- footprint={
20
- <footprint>
21
- <hole diameter={2.5} pcbX={0} pcbY={0} />
22
- </footprint>
23
- }
24
- />
25
- )
26
- }
@@ -1,56 +0,0 @@
1
- import "@tscircuit/core"
2
-
3
- /**
4
- * A switch shaft you can use to connect a pluggable Kailh socket.
5
- *
6
- * Datasheet: https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc/2211090930_Kailh-CPG151101S11-1_C5184526.pdf
7
- */
8
- export const KeyswitchSocket = (props: {
9
- name: string
10
- pcbX?: number
11
- pcbY?: number
12
- layer?: "top" | "bottom"
13
- }) => (
14
- <chip
15
- {...props}
16
- pcbRotation={0}
17
- cadModel={{
18
- objUrl: `https://modelcdn.tscircuit.com/easyeda_models/download?pn=C5184526`,
19
- }}
20
- supplierPartNumbers={{
21
- jlcpcb: ["C5184526"],
22
- }}
23
- footprint={
24
- <footprint>
25
- {/* <silkscreentext text={props.name} /> */}
26
- <smtpad
27
- shape="rect"
28
- width="2.55mm"
29
- height="2.5mm"
30
- portHints={["pin1"]}
31
- layer="top"
32
- />
33
- <smtpad
34
- shape="rect"
35
- width="2.55mm"
36
- height="2.5mm"
37
- portHints={["pin2"]}
38
- layer="top"
39
- />
40
- <hole name="H1" diameter="3mm" />
41
- <hole name="H2" diameter="3mm" />
42
- <constraint xDist="6.35mm" centerToCenter left=".H1" right=".H2" />
43
- <constraint yDist="2.54mm" centerToCenter top=".H1" bottom=".H2" />
44
- <constraint edgeToEdge xDist="11.3mm" left=".pin1" right=".pin2" />
45
- <constraint sameY for={[".pin1", ".H1"]} />
46
- <constraint sameY for={[".pin2", ".H2"]} />
47
- <constraint
48
- edgeToEdge
49
- xDist={(11.3 - 6.35 - 3) / 2}
50
- left=".pin1"
51
- right=".H1"
52
- />
53
- </footprint>
54
- }
55
- />
56
- )
@@ -1,38 +0,0 @@
1
- import "@tscircuit/react-fiber"
2
- import { layout } from "@tscircuit/layout"
3
- import manual_edits from "./manual-edits"
4
-
5
- export const MyCircuit = () => (
6
- <board width="40mm" height="40mm" pcbX={0} pcbY={0}>
7
- <resistor
8
- name="R1"
9
- resistance="20kohm"
10
- pcbX={0}
11
- pcbY={0}
12
- footprint="0805"
13
- supplierPartNumbers={{
14
- jlcpcb: ["C2759650"],
15
- }}
16
- />
17
- <resistor
18
- name="R2"
19
- pcbX={5}
20
- pcbY={0}
21
- resistance="20kohm"
22
- footprint="0805"
23
- supplierPartNumbers={{
24
- jlcpcb: ["C2759650"],
25
- }}
26
- />
27
- <trace from=".R1 > .pin1" to=".R2 > .pin2" />
28
- {/* <tracehint
29
- for=".R1 > .right"
30
- offsets={[
31
- {
32
- x: 3,
33
- y: 3,
34
- },
35
- ]}
36
- /> */}
37
- </board>
38
- )
@@ -1,93 +0,0 @@
1
- /**
2
- * DO NOT EDIT THIS FILE DIRECTLY!
3
- *
4
- * This file is automatically edited when running `tsci dev` and dragging things
5
- * around. `tsci dev` searches for a file named "*.manual-edits.ts" and edits
6
- * it when you e.g. move a footprint. If there are multiple files, it'll try
7
- * to pick one based on context or ask.
8
- *
9
- * If you're not running `tsci dev`, you can safely edit this file.
10
- */
11
- export default {
12
- // Generated when this file is created, this unique identifier is used to help
13
- // determine which file to edit when there are many *.manual-edits.ts files
14
- manual_edit_id: "abcdef",
15
-
16
- // Manual pcb placements, added when you drag a footprint
17
- pcb_placements: [
18
- {
19
- _edit_event_id: "0.6668756126702717",
20
- selector: ".U2",
21
- center: {
22
- x: -5.830346475507767,
23
- y: -1.3620071684587813,
24
- },
25
- relative_to: "group_center",
26
- },
27
- {
28
- _edit_event_id: "0.867524742177592",
29
- selector: ".R1",
30
- center: {
31
- x: 3.679808841099163,
32
- y: 3.6320191158900847,
33
- },
34
- relative_to: "group_center",
35
- },
36
- {
37
- _edit_event_id: "0.4555106760070762",
38
- selector: ".C1",
39
- center: {
40
- x: 0,
41
- y: 2.6666666666666665,
42
- },
43
- relative_to: "group_center",
44
- },
45
- {
46
- _edit_event_id: "0.6123290063979561",
47
- selector: ".R2",
48
- center: {
49
- x: 13.457749922536511,
50
- y: 5.576084911465589,
51
- },
52
- relative_to: "group_center",
53
- },
54
- ],
55
- manual_trace_hints: [
56
- {
57
- pcb_port_selector: ".D9 > .pin2",
58
- offsets: [
59
- {
60
- x: 17.58431693903126,
61
- y: 15.875996800068524,
62
- via: false,
63
- },
64
- {
65
- x: 18.01072486303387,
66
- y: 2.621817162320708,
67
- via: false,
68
- },
69
- {
70
- x: 23.127619951065203,
71
- y: 2.4441471939862858,
72
- via: false,
73
- },
74
- ],
75
- },
76
- {
77
- pcb_port_selector: ".D4 > .pin2",
78
- offsets: [
79
- {
80
- x: -21.94914509505002,
81
- y: -3.063375950444515,
82
- via: true,
83
- },
84
- {
85
- x: -16.627383568380463,
86
- y: -3.006761466118242,
87
- via: true,
88
- },
89
- ],
90
- },
91
- ],
92
- edit_events: [],
93
- }
@@ -1,3 +0,0 @@
1
- # @tscircuit/dev-server-frontend
2
-
3
- Frontend for the tscircuit dev server.
Binary file
@@ -1,86 +0,0 @@
1
- import { useEffect, useState } from "react"
2
- import {
3
- Command,
4
- CommandDialog,
5
- CommandGroup,
6
- CommandInput,
7
- CommandItem,
8
- CommandList,
9
- CommandShortcut,
10
- } from "./ui/command"
11
- import { useGlobalStore } from "frontend/hooks/use-global-store"
12
- import { useDevPackageExamples } from "../hooks/use-dev-package-examples"
13
- import { CommandSeparator } from "cmdk"
14
-
15
- export const CommandK = () => {
16
- const [open, setOpen] = useState(false)
17
- const store = useGlobalStore()
18
- useEffect(() => {
19
- const down = (e: KeyboardEvent) => {
20
- if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
21
- e.preventDefault()
22
- setOpen((open) => !open)
23
- }
24
- if (e.key === "Escape") {
25
- setOpen(false)
26
- }
27
- }
28
-
29
- document.addEventListener("keydown", down)
30
- return () => document.removeEventListener("keydown", down)
31
- }, [])
32
-
33
- const { data: examples } = useDevPackageExamples()
34
-
35
- const close = () => {
36
- setOpen(false)
37
- return true
38
- }
39
-
40
- return (
41
- <CommandDialog open={open} onOpenChange={(open) => setOpen(open)}>
42
- <Command className="rounded-lg border shadow-md">
43
- <CommandInput placeholder="Type a command or search..." />
44
- <CommandList>
45
- <CommandGroup heading="Viewing Options">
46
- <CommandItem
47
- onSelect={() => close() && store.setViewMode("schematic")}
48
- >
49
- View Schematic
50
- <CommandShortcut></CommandShortcut>
51
- </CommandItem>
52
- <CommandItem onSelect={() => close() && store.setViewMode("pcb")}>
53
- View PCB
54
- <CommandShortcut></CommandShortcut>
55
- </CommandItem>
56
- <CommandItem onSelect={() => close() && store.setViewMode("split")}>
57
- View in Split Mode
58
- <CommandShortcut></CommandShortcut>
59
- </CommandItem>
60
- <CommandItem onSelect={() => close() && store.setViewMode("split")}>
61
- Vertical Split
62
- <CommandShortcut></CommandShortcut>
63
- </CommandItem>
64
- </CommandGroup>
65
- <CommandSeparator />
66
- <CommandGroup heading="Examples">
67
- {examples?.map((ex) => (
68
- <CommandItem
69
- key={ex.dev_package_example_id}
70
- value={ex.expath}
71
- onSelect={() =>
72
- close() &&
73
- store.setActiveDevExamplePackageId(
74
- ex.dev_package_example_id.toString(),
75
- )
76
- }
77
- >
78
- {ex.expath}
79
- </CommandItem>
80
- ))}
81
- </CommandGroup>
82
- </CommandList>
83
- </Command>
84
- </CommandDialog>
85
- )
86
- }