@tscircuit/core 0.0.1

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 (34) hide show
  1. package/README.md +35 -0
  2. package/dist/index.cjs +5353 -0
  3. package/index.ts +1 -0
  4. package/lib/Project.ts +84 -0
  5. package/lib/components/base-components/NormalComponent.ts +330 -0
  6. package/lib/components/base-components/PrimitiveComponent.ts +299 -0
  7. package/lib/components/base-components/Renderable.ts +113 -0
  8. package/lib/components/index.ts +14 -0
  9. package/lib/components/normal-components/Board.ts +38 -0
  10. package/lib/components/normal-components/Capacitor.ts +23 -0
  11. package/lib/components/normal-components/Diode.ts +27 -0
  12. package/lib/components/normal-components/Led.ts +27 -0
  13. package/lib/components/normal-components/Resistor.ts +19 -0
  14. package/lib/components/primitive-components/Footprint.ts +4 -0
  15. package/lib/components/primitive-components/Group.ts +10 -0
  16. package/lib/components/primitive-components/Net.ts +12 -0
  17. package/lib/components/primitive-components/Port.ts +187 -0
  18. package/lib/components/primitive-components/SmtPad.ts +80 -0
  19. package/lib/components/primitive-components/Trace.ts +219 -0
  20. package/lib/components/primitive-components/TraceHint.ts +4 -0
  21. package/lib/fiber/catalogue.ts +22 -0
  22. package/lib/fiber/create-instance-from-react-element.ts +168 -0
  23. package/lib/fiber/intrinsic-jsx.ts +43 -0
  24. package/lib/index.ts +5 -0
  25. package/lib/register-catalogue.ts +3 -0
  26. package/lib/utils/autorouting/SimpleRouteJson.ts +37 -0
  27. package/lib/utils/autorouting/computeObstacleBounds.ts +10 -0
  28. package/lib/utils/constants.ts +35 -0
  29. package/lib/utils/createComponentsFromSoup.ts +86 -0
  30. package/lib/utils/get-relative-direction.ts +14 -0
  31. package/lib/utils/getPortFromHints.ts +10 -0
  32. package/lib/utils/projectPointInDirection.ts +18 -0
  33. package/lib/utils/selector-matching/index.ts +62 -0
  34. package/package.json +40 -0
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @tscircuit/core
2
+
3
+ [tscircuit](https://github.com/tscircuit/tscircuit) · [Development Guide](./docs/DEVELOPMENT.md)
4
+
5
+ > [!WARNING]
6
+ > You should use [@tscircuit/builder](https://github.com/tscircuit/builder) instead, this package is
7
+ > going to be in alpha for a while.
8
+
9
+ A rewrite of [tscircuit builder](https://github.com/tscircuit/builder) with a ThreeJS/react-three-like API and architecture.
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { Board, Resistor, Led, Trace, Project } from "@tscircuit/core"
15
+
16
+ const project = new Project()
17
+
18
+ const board = new Board({
19
+ width: "10mm",
20
+ height: "10mm",
21
+ })
22
+ project.add(board)
23
+
24
+ const R1 = new Resistor({ resistance: "10k", footprint: "0402" })
25
+ board.add(R1)
26
+
27
+ // You can also add elements with React
28
+ board.add(<led footprint="0402" />)
29
+
30
+ const trace = new Trace({ width: "0.2mm" })
31
+ trace.connect(R1.output, LED1.anode)
32
+ board.add(trace)
33
+
34
+ project.getJson() // [{ type: "board", ...}, { type: "resistor", ...}, ...]
35
+ ```